Path: blob/master/drivers/infiniband/hw/cxgb3/iwch.h
15112 views
/*1* Copyright (c) 2006 Chelsio, Inc. All rights reserved.2*3* This software is available to you under a choice of one of two4* licenses. You may choose to be licensed under the terms of the GNU5* General Public License (GPL) Version 2, available from the file6* COPYING in the main directory of this source tree, or the7* OpenIB.org BSD license below:8*9* Redistribution and use in source and binary forms, with or10* without modification, are permitted provided that the following11* conditions are met:12*13* - Redistributions of source code must retain the above14* copyright notice, this list of conditions and the following15* disclaimer.16*17* - Redistributions in binary form must reproduce the above18* copyright notice, this list of conditions and the following19* disclaimer in the documentation and/or other materials20* provided with the distribution.21*22* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,23* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF24* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND25* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS26* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN27* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN28* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE29* SOFTWARE.30*/31#ifndef __IWCH_H__32#define __IWCH_H__3334#include <linux/mutex.h>35#include <linux/list.h>36#include <linux/spinlock.h>37#include <linux/idr.h>38#include <linux/workqueue.h>3940#include <rdma/ib_verbs.h>4142#include "cxio_hal.h"43#include "cxgb3_offload.h"4445struct iwch_pd;46struct iwch_cq;47struct iwch_qp;48struct iwch_mr;4950struct iwch_rnic_attributes {51u32 max_qps;52u32 max_wrs; /* Max for any SQ/RQ */53u32 max_sge_per_wr;54u32 max_sge_per_rdma_write_wr; /* for RDMA Write WR */55u32 max_cqs;56u32 max_cqes_per_cq;57u32 max_mem_regs;58u32 max_phys_buf_entries; /* for phys buf list */59u32 max_pds;6061/*62* The memory page sizes supported by this RNIC.63* Bit position i in bitmap indicates page of64* size (4k)^i. Phys block list mode unsupported.65*/66u32 mem_pgsizes_bitmask;67u64 max_mr_size;68u8 can_resize_wq;6970/*71* The maximum number of RDMA Reads that can be outstanding72* per QP with this RNIC as the target.73*/74u32 max_rdma_reads_per_qp;7576/*77* The maximum number of resources used for RDMA Reads78* by this RNIC with this RNIC as the target.79*/80u32 max_rdma_read_resources;8182/*83* The max depth per QP for initiation of RDMA Read84* by this RNIC.85*/86u32 max_rdma_read_qp_depth;8788/*89* The maximum depth for initiation of RDMA Read90* operations by this RNIC on all QPs91*/92u32 max_rdma_read_depth;93u8 rq_overflow_handled;94u32 can_modify_ird;95u32 can_modify_ord;96u32 max_mem_windows;97u32 stag0_value;98u8 zbva_support;99u8 local_invalidate_fence;100u32 cq_overflow_detection;101};102103struct iwch_dev {104struct ib_device ibdev;105struct cxio_rdev rdev;106u32 device_cap_flags;107struct iwch_rnic_attributes attr;108struct idr cqidr;109struct idr qpidr;110struct idr mmidr;111spinlock_t lock;112struct list_head entry;113struct delayed_work db_drop_task;114};115116static inline struct iwch_dev *to_iwch_dev(struct ib_device *ibdev)117{118return container_of(ibdev, struct iwch_dev, ibdev);119}120121static inline struct iwch_dev *rdev_to_iwch_dev(struct cxio_rdev *rdev)122{123return container_of(rdev, struct iwch_dev, rdev);124}125126static inline int t3b_device(const struct iwch_dev *rhp)127{128return rhp->rdev.t3cdev_p->type == T3B;129}130131static inline int t3a_device(const struct iwch_dev *rhp)132{133return rhp->rdev.t3cdev_p->type == T3A;134}135136static inline struct iwch_cq *get_chp(struct iwch_dev *rhp, u32 cqid)137{138return idr_find(&rhp->cqidr, cqid);139}140141static inline struct iwch_qp *get_qhp(struct iwch_dev *rhp, u32 qpid)142{143return idr_find(&rhp->qpidr, qpid);144}145146static inline struct iwch_mr *get_mhp(struct iwch_dev *rhp, u32 mmid)147{148return idr_find(&rhp->mmidr, mmid);149}150151static inline int insert_handle(struct iwch_dev *rhp, struct idr *idr,152void *handle, u32 id)153{154int ret;155int newid;156157do {158if (!idr_pre_get(idr, GFP_KERNEL)) {159return -ENOMEM;160}161spin_lock_irq(&rhp->lock);162ret = idr_get_new_above(idr, handle, id, &newid);163BUG_ON(newid != id);164spin_unlock_irq(&rhp->lock);165} while (ret == -EAGAIN);166167return ret;168}169170static inline void remove_handle(struct iwch_dev *rhp, struct idr *idr, u32 id)171{172spin_lock_irq(&rhp->lock);173idr_remove(idr, id);174spin_unlock_irq(&rhp->lock);175}176177extern struct cxgb3_client t3c_client;178extern cxgb3_cpl_handler_func t3c_handlers[NUM_CPL_CMDS];179extern void iwch_ev_dispatch(struct cxio_rdev *rdev_p, struct sk_buff *skb);180181#endif182183184