]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb.h
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.git] / sys / dev / cxgb / ulp / iw_cxgb / iw_cxgb.h
1 /**************************************************************************
2
3 Copyright (c) 2007, 2008 Chelsio Inc.
4 All rights reserved.
5
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
8
9  1. Redistributions of source code must retain the above copyright notice,
10     this list of conditions and the following disclaimer.
11
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.
15
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.
27
28 $FreeBSD$
29
30 ***************************************************************************/
31
32 #ifndef __IWCH_H__
33 #define __IWCH_H__
34
35 struct iwch_pd;
36 struct iwch_cq;
37 struct iwch_qp;
38 struct iwch_mr;
39
40
41 struct iwch_rnic_attributes {
42         u32 vendor_id;
43         u32 vendor_part_id;
44         u32 max_qps;
45         u32 max_wrs;                            /* Max for any SQ/RQ */
46         u32 max_sge_per_wr;
47         u32 max_sge_per_rdma_write_wr;  /* for RDMA Write WR */
48         u32 max_cqs;
49         u32 max_cqes_per_cq;
50         u32 max_mem_regs;
51         u32 max_phys_buf_entries;               /* for phys buf list */
52         u32 max_pds;
53
54         /*
55          * The memory page sizes supported by this RNIC.
56          * Bit position i in bitmap indicates page of
57          * size (4k)^i.  Phys block list mode unsupported.
58          */
59         u32 mem_pgsizes_bitmask;
60         u8 can_resize_wq;
61
62         /*
63          * The maximum number of RDMA Reads that can be outstanding
64          * per QP with this RNIC as the target.
65          */
66         u32 max_rdma_reads_per_qp;
67
68         /*
69          * The maximum number of resources used for RDMA Reads
70          * by this RNIC with this RNIC as the target.
71          */
72         u32 max_rdma_read_resources;
73
74         /*
75          * The max depth per QP for initiation of RDMA Read
76          * by this RNIC.
77          */
78         u32 max_rdma_read_qp_depth;
79
80         /*
81          * The maximum depth for initiation of RDMA Read
82          * operations by this RNIC on all QPs
83          */
84         u32 max_rdma_read_depth;
85         u8 rq_overflow_handled;
86         u32 can_modify_ird;
87         u32 can_modify_ord;
88         u32 max_mem_windows;
89         u32 stag0_value;
90         u8 zbva_support;
91         u8 local_invalidate_fence;
92         u32 cq_overflow_detection;
93 };
94
95 struct iwch_dev {
96         struct ib_device ibdev;
97         struct cxio_rdev rdev;
98         u32 device_cap_flags;
99         struct iwch_rnic_attributes attr;
100         struct kvl cqidr;
101         struct kvl qpidr;
102         struct kvl mmidr;
103         struct mtx lock;
104         TAILQ_ENTRY(iwch_dev) entry;
105 };
106
107 #ifndef container_of
108 #define container_of(p, stype, field) ((stype *)(((uint8_t *)(p)) - offsetof(stype, field)))
109 #endif
110
111 static inline struct iwch_dev *to_iwch_dev(struct ib_device *ibdev)
112 {
113         return container_of(ibdev, struct iwch_dev, ibdev);
114 }
115
116 static inline int t3b_device(const struct iwch_dev *rhp)
117 {
118         return rhp->rdev.t3cdev_p->type == T3B;
119 }
120
121 static inline int t3a_device(const struct iwch_dev *rhp)
122 {
123         return rhp->rdev.t3cdev_p->type == T3A;
124 }
125
126 static inline struct iwch_cq *get_chp(struct iwch_dev *rhp, u32 cqid)
127 {
128         return kvl_lookup(&rhp->cqidr, cqid);
129 }
130
131 static inline struct iwch_qp *get_qhp(struct iwch_dev *rhp, u32 qpid)
132 {
133         return kvl_lookup(&rhp->qpidr, qpid);
134 }
135
136 static inline struct iwch_mr *get_mhp(struct iwch_dev *rhp, u32 mmid)
137 {
138         return kvl_lookup(&rhp->mmidr, mmid);
139 }
140
141 static inline int insert_handle(struct iwch_dev *rhp, struct kvl *kvlp,
142                                 void *handle, u32 id)
143 {
144         int ret;
145         u32 newid;
146
147         do {
148                 mtx_lock(&rhp->lock);
149                 ret = kvl_alloc_above(kvlp, handle, id, &newid);
150                 WARN_ON(ret != 0);
151                 WARN_ON(!ret && newid != id);
152                 mtx_unlock(&rhp->lock);
153         } while (ret == -EAGAIN);
154
155         return ret;
156 }
157
158 static inline void remove_handle(struct iwch_dev *rhp, struct kvl *kvlp, u32 id)
159 {
160         mtx_lock(&rhp->lock);
161         kvl_delete(kvlp, id);
162         mtx_unlock(&rhp->lock);
163 }
164
165 extern struct cxgb_client t3c_client;
166 extern cxgb_cpl_handler_func t3c_handlers[NUM_CPL_CMDS];
167 extern void iwch_ev_dispatch(struct cxio_rdev *rdev_p, struct mbuf *m);
168 #endif