1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2 /*
3 * Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved.
4 * Copyright (c) 2015 System Fabric Works, Inc. All rights reserved.
5 */
6
7 #ifndef RXE_LOC_H
8 #define RXE_LOC_H
9
10 /* rxe_av.c */
11 void rxe_init_av(struct rdma_ah_attr *attr, struct rxe_av *av);
12
13 int rxe_av_chk_attr(struct rxe_dev *rxe, struct rdma_ah_attr *attr);
14
15 void rxe_av_from_attr(u8 port_num, struct rxe_av *av,
16 struct rdma_ah_attr *attr);
17
18 void rxe_av_to_attr(struct rxe_av *av, struct rdma_ah_attr *attr);
19
20 void rxe_av_fill_ip_info(struct rxe_av *av, struct rdma_ah_attr *attr);
21
22 struct rxe_av *rxe_get_av(struct rxe_pkt_info *pkt);
23
24 /* rxe_cq.c */
25 int rxe_cq_chk_attr(struct rxe_dev *rxe, struct rxe_cq *cq,
26 int cqe, int comp_vector);
27
28 int rxe_cq_from_init(struct rxe_dev *rxe, struct rxe_cq *cq, int cqe,
29 int comp_vector, struct ib_udata *udata,
30 struct rxe_create_cq_resp __user *uresp);
31
32 int rxe_cq_resize_queue(struct rxe_cq *cq, int new_cqe,
33 struct rxe_resize_cq_resp __user *uresp,
34 struct ib_udata *udata);
35
36 int rxe_cq_post(struct rxe_cq *cq, struct rxe_cqe *cqe, int solicited);
37
38 void rxe_cq_disable(struct rxe_cq *cq);
39
40 void rxe_cq_cleanup(struct rxe_pool_entry *arg);
41
42 /* rxe_mcast.c */
43 int rxe_mcast_get_grp(struct rxe_dev *rxe, union ib_gid *mgid,
44 struct rxe_mc_grp **grp_p);
45
46 int rxe_mcast_add_grp_elem(struct rxe_dev *rxe, struct rxe_qp *qp,
47 struct rxe_mc_grp *grp);
48
49 int rxe_mcast_drop_grp_elem(struct rxe_dev *rxe, struct rxe_qp *qp,
50 union ib_gid *mgid);
51
52 void rxe_drop_all_mcast_groups(struct rxe_qp *qp);
53
54 void rxe_mc_cleanup(struct rxe_pool_entry *arg);
55
56 /* rxe_mmap.c */
57 struct rxe_mmap_info {
58 struct list_head pending_mmaps;
59 struct ib_ucontext *context;
60 struct kref ref;
61 void *obj;
62
63 struct mminfo info;
64 };
65
66 void rxe_mmap_release(struct kref *ref);
67
68 struct rxe_mmap_info *rxe_create_mmap_info(struct rxe_dev *dev, u32 size,
69 struct ib_udata *udata, void *obj);
70
71 int rxe_mmap(struct ib_ucontext *context, struct vm_area_struct *vma);
72
73 /* rxe_mr.c */
74 u8 rxe_get_next_key(u32 last_key);
75 void rxe_mr_init_dma(struct rxe_pd *pd, int access, struct rxe_mr *mr);
76 int rxe_mr_init_user(struct rxe_pd *pd, u64 start, u64 length, u64 iova,
77 int access, struct rxe_mr *mr);
78 int rxe_mr_init_fast(struct rxe_pd *pd, int max_pages, struct rxe_mr *mr);
79 int rxe_mr_copy(struct rxe_mr *mr, u64 iova, void *addr, int length,
80 enum rxe_mr_copy_dir dir);
81 int copy_data(struct rxe_pd *pd, int access, struct rxe_dma_info *dma,
82 void *addr, int length, enum rxe_mr_copy_dir dir);
83 void *iova_to_vaddr(struct rxe_mr *mr, u64 iova, int length);
84 struct rxe_mr *lookup_mr(struct rxe_pd *pd, int access, u32 key,
85 enum rxe_mr_lookup_type type);
86 int mr_check_range(struct rxe_mr *mr, u64 iova, size_t length);
87 int advance_dma_data(struct rxe_dma_info *dma, unsigned int length);
88 int rxe_invalidate_mr(struct rxe_qp *qp, u32 rkey);
89 int rxe_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata);
90 void rxe_mr_cleanup(struct rxe_pool_entry *arg);
91
92 /* rxe_mw.c */
93 int rxe_alloc_mw(struct ib_mw *ibmw, struct ib_udata *udata);
94 int rxe_dealloc_mw(struct ib_mw *ibmw);
95 int rxe_bind_mw(struct rxe_qp *qp, struct rxe_send_wqe *wqe);
96 int rxe_invalidate_mw(struct rxe_qp *qp, u32 rkey);
97 struct rxe_mw *rxe_lookup_mw(struct rxe_qp *qp, int access, u32 rkey);
98 void rxe_mw_cleanup(struct rxe_pool_entry *arg);
99
100 /* rxe_net.c */
101 struct sk_buff *rxe_init_packet(struct rxe_dev *rxe, struct rxe_av *av,
102 int paylen, struct rxe_pkt_info *pkt);
103 int rxe_prepare(struct rxe_pkt_info *pkt, struct sk_buff *skb);
104 int rxe_xmit_packet(struct rxe_qp *qp, struct rxe_pkt_info *pkt,
105 struct sk_buff *skb);
106 const char *rxe_parent_name(struct rxe_dev *rxe, unsigned int port_num);
107 int rxe_mcast_add(struct rxe_dev *rxe, union ib_gid *mgid);
108 int rxe_mcast_delete(struct rxe_dev *rxe, union ib_gid *mgid);
109
110 /* rxe_qp.c */
111 int rxe_qp_chk_init(struct rxe_dev *rxe, struct ib_qp_init_attr *init);
112
113 int rxe_qp_from_init(struct rxe_dev *rxe, struct rxe_qp *qp, struct rxe_pd *pd,
114 struct ib_qp_init_attr *init,
115 struct rxe_create_qp_resp __user *uresp,
116 struct ib_pd *ibpd, struct ib_udata *udata);
117
118 int rxe_qp_to_init(struct rxe_qp *qp, struct ib_qp_init_attr *init);
119
120 int rxe_qp_chk_attr(struct rxe_dev *rxe, struct rxe_qp *qp,
121 struct ib_qp_attr *attr, int mask);
122
123 int rxe_qp_from_attr(struct rxe_qp *qp, struct ib_qp_attr *attr,
124 int mask, struct ib_udata *udata);
125
126 int rxe_qp_to_attr(struct rxe_qp *qp, struct ib_qp_attr *attr, int mask);
127
128 void rxe_qp_error(struct rxe_qp *qp);
129
130 void rxe_qp_destroy(struct rxe_qp *qp);
131
132 void rxe_qp_cleanup(struct rxe_pool_entry *arg);
133
qp_num(struct rxe_qp * qp)134 static inline int qp_num(struct rxe_qp *qp)
135 {
136 return qp->ibqp.qp_num;
137 }
138
qp_type(struct rxe_qp * qp)139 static inline enum ib_qp_type qp_type(struct rxe_qp *qp)
140 {
141 return qp->ibqp.qp_type;
142 }
143
qp_state(struct rxe_qp * qp)144 static inline enum ib_qp_state qp_state(struct rxe_qp *qp)
145 {
146 return qp->attr.qp_state;
147 }
148
qp_mtu(struct rxe_qp * qp)149 static inline int qp_mtu(struct rxe_qp *qp)
150 {
151 if (qp->ibqp.qp_type == IB_QPT_RC || qp->ibqp.qp_type == IB_QPT_UC)
152 return qp->attr.path_mtu;
153 else
154 return IB_MTU_4096;
155 }
156
rcv_wqe_size(int max_sge)157 static inline int rcv_wqe_size(int max_sge)
158 {
159 return sizeof(struct rxe_recv_wqe) +
160 max_sge * sizeof(struct ib_sge);
161 }
162
163 void free_rd_atomic_resource(struct rxe_qp *qp, struct resp_res *res);
164
rxe_advance_resp_resource(struct rxe_qp * qp)165 static inline void rxe_advance_resp_resource(struct rxe_qp *qp)
166 {
167 qp->resp.res_head++;
168 if (unlikely(qp->resp.res_head == qp->attr.max_dest_rd_atomic))
169 qp->resp.res_head = 0;
170 }
171
172 void retransmit_timer(struct timer_list *t);
173 void rnr_nak_timer(struct timer_list *t);
174
175 /* rxe_srq.c */
176 #define IB_SRQ_INIT_MASK (~IB_SRQ_LIMIT)
177
178 int rxe_srq_chk_attr(struct rxe_dev *rxe, struct rxe_srq *srq,
179 struct ib_srq_attr *attr, enum ib_srq_attr_mask mask);
180
181 int rxe_srq_from_init(struct rxe_dev *rxe, struct rxe_srq *srq,
182 struct ib_srq_init_attr *init, struct ib_udata *udata,
183 struct rxe_create_srq_resp __user *uresp);
184
185 int rxe_srq_from_attr(struct rxe_dev *rxe, struct rxe_srq *srq,
186 struct ib_srq_attr *attr, enum ib_srq_attr_mask mask,
187 struct rxe_modify_srq_cmd *ucmd, struct ib_udata *udata);
188
189 void rxe_dealloc(struct ib_device *ib_dev);
190
191 int rxe_completer(void *arg);
192 int rxe_requester(void *arg);
193 int rxe_responder(void *arg);
194
195 /* rxe_icrc.c */
196 int rxe_icrc_init(struct rxe_dev *rxe);
197 int rxe_icrc_check(struct sk_buff *skb, struct rxe_pkt_info *pkt);
198 void rxe_icrc_generate(struct sk_buff *skb, struct rxe_pkt_info *pkt);
199
200 void rxe_resp_queue_pkt(struct rxe_qp *qp, struct sk_buff *skb);
201
202 void rxe_comp_queue_pkt(struct rxe_qp *qp, struct sk_buff *skb);
203
wr_opcode_mask(int opcode,struct rxe_qp * qp)204 static inline unsigned int wr_opcode_mask(int opcode, struct rxe_qp *qp)
205 {
206 return rxe_wr_opcode_info[opcode].mask[qp->ibqp.qp_type];
207 }
208
209 #endif /* RXE_LOC_H */
210