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