1 /**************************************************************************
3 Copyright (c) 2007, 2008 Chelsio Inc.
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
9 1. Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer.
12 2. Neither the name of the Chelsio Corporation nor the names of its
13 contributors may be used to endorse or promote products derived from
14 this software without specific prior written permission.
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 POSSIBILITY OF SUCH DAMAGE.
30 ***************************************************************************/
46 #define PAGE_MASK_IWARP (~(PAGE_SIZE-1))
48 struct iwch_rnic_attributes {
52 u32 max_wrs; /* Max for any SQ/RQ */
54 u32 max_sge_per_rdma_write_wr; /* for RDMA Write WR */
58 u32 max_phys_buf_entries; /* for phys buf list */
62 * The memory page sizes supported by this RNIC.
63 * Bit position i in bitmap indicates page of
64 * size (4k)^i. Phys block list mode unsupported.
66 u32 mem_pgsizes_bitmask;
71 * The maximum number of RDMA Reads that can be outstanding
72 * per QP with this RNIC as the target.
74 u32 max_rdma_reads_per_qp;
77 * The maximum number of resources used for RDMA Reads
78 * by this RNIC with this RNIC as the target.
80 u32 max_rdma_read_resources;
83 * The max depth per QP for initiation of RDMA Read
86 u32 max_rdma_read_qp_depth;
89 * The maximum depth for initiation of RDMA Read
90 * operations by this RNIC on all QPs
92 u32 max_rdma_read_depth;
93 u8 rq_overflow_handled;
99 u8 local_invalidate_fence;
100 u32 cq_overflow_detection;
104 struct ib_device ibdev;
105 struct cxio_rdev rdev;
106 u32 device_cap_flags;
107 struct iwch_rnic_attributes attr;
112 TAILQ_ENTRY(iwch_dev) entry;
116 #define container_of(p, stype, field) ((stype *)(((uint8_t *)(p)) - offsetof(stype, field)))
119 static inline struct iwch_dev *to_iwch_dev(struct ib_device *ibdev)
121 return container_of(ibdev, struct iwch_dev, ibdev);
124 static inline int t3b_device(const struct iwch_dev *rhp __unused)
129 static inline int t3a_device(const struct iwch_dev *rhp __unused)
134 static inline struct iwch_cq *get_chp(struct iwch_dev *rhp, u32 cqid)
136 return idr_find(&rhp->cqidr, cqid);
139 static inline struct iwch_qp *get_qhp(struct iwch_dev *rhp, u32 qpid)
141 return idr_find(&rhp->qpidr, qpid);
144 static inline struct iwch_mr *get_mhp(struct iwch_dev *rhp, u32 mmid)
146 return idr_find(&rhp->mmidr, mmid);
149 static inline int insert_handle(struct iwch_dev *rhp, struct idr *idr,
150 void *handle, u32 id)
156 if (!idr_pre_get(idr, GFP_KERNEL)) {
159 mtx_lock(&rhp->lock);
160 ret = idr_get_new_above(idr, handle, id, &newid);
162 WARN_ON(!ret && newid != id);
163 mtx_unlock(&rhp->lock);
164 } while (ret == -EAGAIN);
169 static inline void remove_handle(struct iwch_dev *rhp, struct idr *idr, u32 id)
171 mtx_lock(&rhp->lock);
173 mtx_unlock(&rhp->lock);
176 void iwch_ev_dispatch(struct iwch_dev *, struct mbuf *);