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#ifndef RXE_LOC_H
35#define RXE_LOC_H
36
37
38
39int rxe_av_chk_attr(struct rxe_dev *rxe, struct rdma_ah_attr *attr);
40
41void rxe_av_from_attr(u8 port_num, struct rxe_av *av,
42 struct rdma_ah_attr *attr);
43
44void rxe_av_to_attr(struct rxe_av *av, struct rdma_ah_attr *attr);
45
46void rxe_av_fill_ip_info(struct rxe_av *av, struct rdma_ah_attr *attr);
47
48struct rxe_av *rxe_get_av(struct rxe_pkt_info *pkt);
49
50
51int rxe_cq_chk_attr(struct rxe_dev *rxe, struct rxe_cq *cq,
52 int cqe, int comp_vector);
53
54int rxe_cq_from_init(struct rxe_dev *rxe, struct rxe_cq *cq, int cqe,
55 int comp_vector, struct ib_ucontext *context,
56 struct rxe_create_cq_resp __user *uresp);
57
58int rxe_cq_resize_queue(struct rxe_cq *cq, int new_cqe,
59 struct rxe_resize_cq_resp __user *uresp);
60
61int rxe_cq_post(struct rxe_cq *cq, struct rxe_cqe *cqe, int solicited);
62
63void rxe_cq_disable(struct rxe_cq *cq);
64
65void rxe_cq_cleanup(struct rxe_pool_entry *arg);
66
67
68int rxe_mcast_get_grp(struct rxe_dev *rxe, union ib_gid *mgid,
69 struct rxe_mc_grp **grp_p);
70
71int rxe_mcast_add_grp_elem(struct rxe_dev *rxe, struct rxe_qp *qp,
72 struct rxe_mc_grp *grp);
73
74int rxe_mcast_drop_grp_elem(struct rxe_dev *rxe, struct rxe_qp *qp,
75 union ib_gid *mgid);
76
77void rxe_drop_all_mcast_groups(struct rxe_qp *qp);
78
79void rxe_mc_cleanup(struct rxe_pool_entry *arg);
80
81
82struct rxe_mmap_info {
83 struct list_head pending_mmaps;
84 struct ib_ucontext *context;
85 struct kref ref;
86 void *obj;
87
88 struct mminfo info;
89};
90
91void rxe_mmap_release(struct kref *ref);
92
93struct rxe_mmap_info *rxe_create_mmap_info(struct rxe_dev *dev,
94 u32 size,
95 struct ib_ucontext *context,
96 void *obj);
97
98int rxe_mmap(struct ib_ucontext *context, struct vm_area_struct *vma);
99
100
101enum copy_direction {
102 to_mem_obj,
103 from_mem_obj,
104};
105
106int rxe_mem_init_dma(struct rxe_pd *pd,
107 int access, struct rxe_mem *mem);
108
109int rxe_mem_init_user(struct rxe_pd *pd, u64 start,
110 u64 length, u64 iova, int access, struct ib_udata *udata,
111 struct rxe_mem *mr);
112
113int rxe_mem_init_fast(struct rxe_pd *pd,
114 int max_pages, struct rxe_mem *mem);
115
116int rxe_mem_copy(struct rxe_mem *mem, u64 iova, void *addr,
117 int length, enum copy_direction dir, u32 *crcp);
118
119int copy_data(struct rxe_pd *pd, int access,
120 struct rxe_dma_info *dma, void *addr, int length,
121 enum copy_direction dir, u32 *crcp);
122
123void *iova_to_vaddr(struct rxe_mem *mem, u64 iova, int length);
124
125enum lookup_type {
126 lookup_local,
127 lookup_remote,
128};
129
130struct rxe_mem *lookup_mem(struct rxe_pd *pd, int access, u32 key,
131 enum lookup_type type);
132
133int mem_check_range(struct rxe_mem *mem, u64 iova, size_t length);
134
135int rxe_mem_map_pages(struct rxe_dev *rxe, struct rxe_mem *mem,
136 u64 *page, int num_pages, u64 iova);
137
138void rxe_mem_cleanup(struct rxe_pool_entry *arg);
139
140int advance_dma_data(struct rxe_dma_info *dma, unsigned int length);
141
142
143void rxe_loopback(struct sk_buff *skb);
144int rxe_send(struct rxe_pkt_info *pkt, struct sk_buff *skb);
145struct sk_buff *rxe_init_packet(struct rxe_dev *rxe, struct rxe_av *av,
146 int paylen, struct rxe_pkt_info *pkt);
147int rxe_prepare(struct rxe_dev *rxe, struct rxe_pkt_info *pkt,
148 struct sk_buff *skb, u32 *crc);
149enum rdma_link_layer rxe_link_layer(struct rxe_dev *rxe, unsigned int port_num);
150const char *rxe_parent_name(struct rxe_dev *rxe, unsigned int port_num);
151struct device *rxe_dma_device(struct rxe_dev *rxe);
152int rxe_mcast_add(struct rxe_dev *rxe, union ib_gid *mgid);
153int rxe_mcast_delete(struct rxe_dev *rxe, union ib_gid *mgid);
154
155
156int rxe_qp_chk_init(struct rxe_dev *rxe, struct ib_qp_init_attr *init);
157
158int rxe_qp_from_init(struct rxe_dev *rxe, struct rxe_qp *qp, struct rxe_pd *pd,
159 struct ib_qp_init_attr *init,
160 struct rxe_create_qp_resp __user *uresp,
161 struct ib_pd *ibpd);
162
163int rxe_qp_to_init(struct rxe_qp *qp, struct ib_qp_init_attr *init);
164
165int rxe_qp_chk_attr(struct rxe_dev *rxe, struct rxe_qp *qp,
166 struct ib_qp_attr *attr, int mask);
167
168int rxe_qp_from_attr(struct rxe_qp *qp, struct ib_qp_attr *attr,
169 int mask, struct ib_udata *udata);
170
171int rxe_qp_to_attr(struct rxe_qp *qp, struct ib_qp_attr *attr, int mask);
172
173void rxe_qp_error(struct rxe_qp *qp);
174
175void rxe_qp_destroy(struct rxe_qp *qp);
176
177void rxe_qp_cleanup(struct rxe_pool_entry *arg);
178
179static inline int qp_num(struct rxe_qp *qp)
180{
181 return qp->ibqp.qp_num;
182}
183
184static inline enum ib_qp_type qp_type(struct rxe_qp *qp)
185{
186 return qp->ibqp.qp_type;
187}
188
189static inline enum ib_qp_state qp_state(struct rxe_qp *qp)
190{
191 return qp->attr.qp_state;
192}
193
194static inline int qp_mtu(struct rxe_qp *qp)
195{
196 if (qp->ibqp.qp_type == IB_QPT_RC || qp->ibqp.qp_type == IB_QPT_UC)
197 return qp->attr.path_mtu;
198 else
199 return RXE_PORT_MAX_MTU;
200}
201
202static inline int rcv_wqe_size(int max_sge)
203{
204 return sizeof(struct rxe_recv_wqe) +
205 max_sge * sizeof(struct ib_sge);
206}
207
208void free_rd_atomic_resource(struct rxe_qp *qp, struct resp_res *res);
209
210static inline void rxe_advance_resp_resource(struct rxe_qp *qp)
211{
212 qp->resp.res_head++;
213 if (unlikely(qp->resp.res_head == qp->attr.max_dest_rd_atomic))
214 qp->resp.res_head = 0;
215}
216
217void retransmit_timer(struct timer_list *t);
218void rnr_nak_timer(struct timer_list *t);
219
220
221#define IB_SRQ_INIT_MASK (~IB_SRQ_LIMIT)
222
223int rxe_srq_chk_attr(struct rxe_dev *rxe, struct rxe_srq *srq,
224 struct ib_srq_attr *attr, enum ib_srq_attr_mask mask);
225
226int rxe_srq_from_init(struct rxe_dev *rxe, struct rxe_srq *srq,
227 struct ib_srq_init_attr *init,
228 struct ib_ucontext *context,
229 struct rxe_create_srq_resp __user *uresp);
230
231int rxe_srq_from_attr(struct rxe_dev *rxe, struct rxe_srq *srq,
232 struct ib_srq_attr *attr, enum ib_srq_attr_mask mask,
233 struct rxe_modify_srq_cmd *ucmd);
234
235void rxe_release(struct kref *kref);
236
237int rxe_completer(void *arg);
238int rxe_requester(void *arg);
239int rxe_responder(void *arg);
240
241u32 rxe_icrc_hdr(struct rxe_pkt_info *pkt, struct sk_buff *skb);
242
243void rxe_resp_queue_pkt(struct rxe_dev *rxe,
244 struct rxe_qp *qp, struct sk_buff *skb);
245
246void rxe_comp_queue_pkt(struct rxe_dev *rxe,
247 struct rxe_qp *qp, struct sk_buff *skb);
248
249static inline unsigned int wr_opcode_mask(int opcode, struct rxe_qp *qp)
250{
251 return rxe_wr_opcode_info[opcode].mask[qp->ibqp.qp_type];
252}
253
254static inline int rxe_xmit_packet(struct rxe_dev *rxe, struct rxe_qp *qp,
255 struct rxe_pkt_info *pkt, struct sk_buff *skb)
256{
257 int err;
258 int is_request = pkt->mask & RXE_REQ_MASK;
259
260 if ((is_request && (qp->req.state != QP_STATE_READY)) ||
261 (!is_request && (qp->resp.state != QP_STATE_READY))) {
262 pr_info("Packet dropped. QP is not in ready state\n");
263 goto drop;
264 }
265
266 if (pkt->mask & RXE_LOOPBACK_MASK) {
267 memcpy(SKB_TO_PKT(skb), pkt, sizeof(*pkt));
268 rxe_loopback(skb);
269 err = 0;
270 } else {
271 err = rxe_send(pkt, skb);
272 }
273
274 if (err) {
275 rxe->xmit_errors++;
276 rxe_counter_inc(rxe, RXE_CNT_SEND_ERR);
277 return err;
278 }
279
280 if ((qp_type(qp) != IB_QPT_RC) &&
281 (pkt->mask & RXE_END_MASK)) {
282 pkt->wqe->state = wqe_state_done;
283 rxe_run_task(&qp->comp.task, 1);
284 }
285
286 rxe_counter_inc(rxe, RXE_CNT_SENT_PKTS);
287 goto done;
288
289drop:
290 kfree_skb(skb);
291 err = 0;
292done:
293 return err;
294}
295
296#endif
297