1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39#ifndef __BNXT_RE_IB_VERBS_H__
40#define __BNXT_RE_IB_VERBS_H__
41
42struct bnxt_re_gid_ctx {
43 u32 idx;
44 u32 refcnt;
45};
46
47#define BNXT_RE_FENCE_BYTES 64
48struct bnxt_re_fence_data {
49 u32 size;
50 u8 va[BNXT_RE_FENCE_BYTES];
51 dma_addr_t dma_addr;
52 struct bnxt_re_mr *mr;
53 struct ib_mw *mw;
54 struct bnxt_qplib_swqe bind_wqe;
55 u32 bind_rkey;
56};
57
58struct bnxt_re_pd {
59 struct ib_pd ib_pd;
60 struct bnxt_re_dev *rdev;
61 struct bnxt_qplib_pd qplib_pd;
62 struct bnxt_re_fence_data fence;
63};
64
65struct bnxt_re_ah {
66 struct ib_ah ib_ah;
67 struct bnxt_re_dev *rdev;
68 struct bnxt_qplib_ah qplib_ah;
69};
70
71struct bnxt_re_srq {
72 struct ib_srq ib_srq;
73 struct bnxt_re_dev *rdev;
74 u32 srq_limit;
75 struct bnxt_qplib_srq qplib_srq;
76 struct ib_umem *umem;
77 spinlock_t lock;
78};
79
80struct bnxt_re_qp {
81 struct ib_qp ib_qp;
82 struct list_head list;
83 struct bnxt_re_dev *rdev;
84 spinlock_t sq_lock;
85 spinlock_t rq_lock;
86 struct bnxt_qplib_qp qplib_qp;
87 struct ib_umem *sumem;
88 struct ib_umem *rumem;
89
90 u32 send_psn;
91 struct ib_ud_header qp1_hdr;
92 struct bnxt_re_cq *scq;
93 struct bnxt_re_cq *rcq;
94};
95
96struct bnxt_re_cq {
97 struct ib_cq ib_cq;
98 struct bnxt_re_dev *rdev;
99 spinlock_t cq_lock;
100 u16 cq_count;
101 u16 cq_period;
102 struct bnxt_qplib_cq qplib_cq;
103 struct bnxt_qplib_cqe *cql;
104#define MAX_CQL_PER_POLL 1024
105 u32 max_cql;
106 struct ib_umem *umem;
107};
108
109struct bnxt_re_mr {
110 struct bnxt_re_dev *rdev;
111 struct ib_mr ib_mr;
112 struct ib_umem *ib_umem;
113 struct bnxt_qplib_mrw qplib_mr;
114 u32 npages;
115 u64 *pages;
116 struct bnxt_qplib_frpl qplib_frpl;
117};
118
119struct bnxt_re_frpl {
120 struct bnxt_re_dev *rdev;
121 struct bnxt_qplib_frpl qplib_frpl;
122 u64 *page_list;
123};
124
125struct bnxt_re_mw {
126 struct bnxt_re_dev *rdev;
127 struct ib_mw ib_mw;
128 struct bnxt_qplib_mrw qplib_mw;
129};
130
131struct bnxt_re_ucontext {
132 struct ib_ucontext ib_uctx;
133 struct bnxt_re_dev *rdev;
134 struct bnxt_qplib_dpi dpi;
135 void *shpg;
136 spinlock_t sh_lock;
137};
138
139static inline u16 bnxt_re_get_swqe_size(int nsge)
140{
141 return sizeof(struct sq_send_hdr) + nsge * sizeof(struct sq_sge);
142}
143
144static inline u16 bnxt_re_get_rwqe_size(int nsge)
145{
146 return sizeof(struct rq_wqe_hdr) + (nsge * sizeof(struct sq_sge));
147}
148
149int bnxt_re_query_device(struct ib_device *ibdev,
150 struct ib_device_attr *ib_attr,
151 struct ib_udata *udata);
152int bnxt_re_query_port(struct ib_device *ibdev, u32 port_num,
153 struct ib_port_attr *port_attr);
154int bnxt_re_get_port_immutable(struct ib_device *ibdev, u32 port_num,
155 struct ib_port_immutable *immutable);
156void bnxt_re_query_fw_str(struct ib_device *ibdev, char *str);
157int bnxt_re_query_pkey(struct ib_device *ibdev, u32 port_num,
158 u16 index, u16 *pkey);
159int bnxt_re_del_gid(const struct ib_gid_attr *attr, void **context);
160int bnxt_re_add_gid(const struct ib_gid_attr *attr, void **context);
161int bnxt_re_query_gid(struct ib_device *ibdev, u32 port_num,
162 int index, union ib_gid *gid);
163enum rdma_link_layer bnxt_re_get_link_layer(struct ib_device *ibdev,
164 u32 port_num);
165int bnxt_re_alloc_pd(struct ib_pd *pd, struct ib_udata *udata);
166int bnxt_re_dealloc_pd(struct ib_pd *pd, struct ib_udata *udata);
167int bnxt_re_create_ah(struct ib_ah *ah, struct rdma_ah_init_attr *init_attr,
168 struct ib_udata *udata);
169int bnxt_re_modify_ah(struct ib_ah *ah, struct rdma_ah_attr *ah_attr);
170int bnxt_re_query_ah(struct ib_ah *ah, struct rdma_ah_attr *ah_attr);
171int bnxt_re_destroy_ah(struct ib_ah *ah, u32 flags);
172int bnxt_re_create_srq(struct ib_srq *srq,
173 struct ib_srq_init_attr *srq_init_attr,
174 struct ib_udata *udata);
175int bnxt_re_modify_srq(struct ib_srq *srq, struct ib_srq_attr *srq_attr,
176 enum ib_srq_attr_mask srq_attr_mask,
177 struct ib_udata *udata);
178int bnxt_re_query_srq(struct ib_srq *srq, struct ib_srq_attr *srq_attr);
179int bnxt_re_destroy_srq(struct ib_srq *srq, struct ib_udata *udata);
180int bnxt_re_post_srq_recv(struct ib_srq *srq, const struct ib_recv_wr *recv_wr,
181 const struct ib_recv_wr **bad_recv_wr);
182int bnxt_re_create_qp(struct ib_qp *qp, struct ib_qp_init_attr *qp_init_attr,
183 struct ib_udata *udata);
184int bnxt_re_modify_qp(struct ib_qp *qp, struct ib_qp_attr *qp_attr,
185 int qp_attr_mask, struct ib_udata *udata);
186int bnxt_re_query_qp(struct ib_qp *qp, struct ib_qp_attr *qp_attr,
187 int qp_attr_mask, struct ib_qp_init_attr *qp_init_attr);
188int bnxt_re_destroy_qp(struct ib_qp *qp, struct ib_udata *udata);
189int bnxt_re_post_send(struct ib_qp *qp, const struct ib_send_wr *send_wr,
190 const struct ib_send_wr **bad_send_wr);
191int bnxt_re_post_recv(struct ib_qp *qp, const struct ib_recv_wr *recv_wr,
192 const struct ib_recv_wr **bad_recv_wr);
193int bnxt_re_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
194 struct ib_udata *udata);
195int bnxt_re_destroy_cq(struct ib_cq *cq, struct ib_udata *udata);
196int bnxt_re_poll_cq(struct ib_cq *cq, int num_entries, struct ib_wc *wc);
197int bnxt_re_req_notify_cq(struct ib_cq *cq, enum ib_cq_notify_flags flags);
198struct ib_mr *bnxt_re_get_dma_mr(struct ib_pd *pd, int mr_access_flags);
199
200int bnxt_re_map_mr_sg(struct ib_mr *ib_mr, struct scatterlist *sg, int sg_nents,
201 unsigned int *sg_offset);
202struct ib_mr *bnxt_re_alloc_mr(struct ib_pd *ib_pd, enum ib_mr_type mr_type,
203 u32 max_num_sg);
204int bnxt_re_dereg_mr(struct ib_mr *mr, struct ib_udata *udata);
205struct ib_mw *bnxt_re_alloc_mw(struct ib_pd *ib_pd, enum ib_mw_type type,
206 struct ib_udata *udata);
207int bnxt_re_dealloc_mw(struct ib_mw *mw);
208struct ib_mr *bnxt_re_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
209 u64 virt_addr, int mr_access_flags,
210 struct ib_udata *udata);
211int bnxt_re_alloc_ucontext(struct ib_ucontext *ctx, struct ib_udata *udata);
212void bnxt_re_dealloc_ucontext(struct ib_ucontext *context);
213int bnxt_re_mmap(struct ib_ucontext *context, struct vm_area_struct *vma);
214
215unsigned long bnxt_re_lock_cqs(struct bnxt_re_qp *qp);
216void bnxt_re_unlock_cqs(struct bnxt_re_qp *qp, unsigned long flags);
217#endif
218