This source file includes following definitions.
- mlx5_wq_cyc_is_full
- mlx5_wq_cyc_missing
- mlx5_wq_cyc_is_empty
- mlx5_wq_cyc_push
- mlx5_wq_cyc_push_n
- mlx5_wq_cyc_pop
- mlx5_wq_cyc_update_db_record
- mlx5_wq_cyc_ctr2ix
- mlx5_wq_cyc_get_head
- mlx5_wq_cyc_get_tail
- mlx5_wq_cyc_get_wqe
- mlx5_wq_cyc_get_contig_wqebbs
- mlx5_wq_cyc_cc_bigger
- mlx5_cqwq_ctr2ix
- mlx5_cqwq_get_ci
- mlx5_cqwq_get_wqe
- mlx5_cqwq_get_ctr_wrap_cnt
- mlx5_cqwq_get_wrap_cnt
- mlx5_cqwq_pop
- mlx5_cqwq_update_db_record
- mlx5_cqwq_get_cqe
- mlx5_wq_ll_is_full
- mlx5_wq_ll_is_empty
- mlx5_wq_ll_missing
- mlx5_wq_ll_get_wqe
- mlx5_wq_ll_get_wqe_next_ix
- mlx5_wq_ll_push
- mlx5_wq_ll_pop
- mlx5_wq_ll_update_db_record
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 #ifndef __MLX5_WQ_H__
34 #define __MLX5_WQ_H__
35
36 #include <linux/mlx5/mlx5_ifc.h>
37 #include <linux/mlx5/cq.h>
38 #include <linux/mlx5/qp.h>
39
40 struct mlx5_wq_param {
41 int buf_numa_node;
42 int db_numa_node;
43 };
44
45 struct mlx5_wq_ctrl {
46 struct mlx5_core_dev *mdev;
47 struct mlx5_frag_buf buf;
48 struct mlx5_db db;
49 };
50
51 struct mlx5_wq_cyc {
52 struct mlx5_frag_buf_ctrl fbc;
53 __be32 *db;
54 u16 sz;
55 u16 wqe_ctr;
56 u16 cur_sz;
57 };
58
59 struct mlx5_wq_qp {
60 struct mlx5_wq_cyc rq;
61 struct mlx5_wq_cyc sq;
62 };
63
64 struct mlx5_cqwq {
65 struct mlx5_frag_buf_ctrl fbc;
66 __be32 *db;
67 u32 cc;
68 };
69
70 struct mlx5_wq_ll {
71 struct mlx5_frag_buf_ctrl fbc;
72 __be32 *db;
73 __be16 *tail_next;
74 u16 head;
75 u16 wqe_ctr;
76 u16 cur_sz;
77 };
78
79 int mlx5_wq_cyc_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param,
80 void *wqc, struct mlx5_wq_cyc *wq,
81 struct mlx5_wq_ctrl *wq_ctrl);
82 u32 mlx5_wq_cyc_get_size(struct mlx5_wq_cyc *wq);
83 void mlx5_wq_cyc_reset(struct mlx5_wq_cyc *wq);
84
85 int mlx5_wq_qp_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param,
86 void *qpc, struct mlx5_wq_qp *wq,
87 struct mlx5_wq_ctrl *wq_ctrl);
88 void mlx5_wq_ll_reset(struct mlx5_wq_ll *wq);
89
90 int mlx5_cqwq_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param,
91 void *cqc, struct mlx5_cqwq *wq,
92 struct mlx5_wq_ctrl *wq_ctrl);
93 u32 mlx5_cqwq_get_size(struct mlx5_cqwq *wq);
94 u8 mlx5_cqwq_get_log_stride_size(struct mlx5_cqwq *wq);
95
96 int mlx5_wq_ll_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param,
97 void *wqc, struct mlx5_wq_ll *wq,
98 struct mlx5_wq_ctrl *wq_ctrl);
99 u32 mlx5_wq_ll_get_size(struct mlx5_wq_ll *wq);
100
101 void mlx5_wq_destroy(struct mlx5_wq_ctrl *wq_ctrl);
102
103 static inline int mlx5_wq_cyc_is_full(struct mlx5_wq_cyc *wq)
104 {
105 return wq->cur_sz == wq->sz;
106 }
107
108 static inline int mlx5_wq_cyc_missing(struct mlx5_wq_cyc *wq)
109 {
110 return wq->sz - wq->cur_sz;
111 }
112
113 static inline int mlx5_wq_cyc_is_empty(struct mlx5_wq_cyc *wq)
114 {
115 return !wq->cur_sz;
116 }
117
118 static inline void mlx5_wq_cyc_push(struct mlx5_wq_cyc *wq)
119 {
120 wq->wqe_ctr++;
121 wq->cur_sz++;
122 }
123
124 static inline void mlx5_wq_cyc_push_n(struct mlx5_wq_cyc *wq, u8 n)
125 {
126 wq->wqe_ctr += n;
127 wq->cur_sz += n;
128 }
129
130 static inline void mlx5_wq_cyc_pop(struct mlx5_wq_cyc *wq)
131 {
132 wq->cur_sz--;
133 }
134
135 static inline void mlx5_wq_cyc_update_db_record(struct mlx5_wq_cyc *wq)
136 {
137 *wq->db = cpu_to_be32(wq->wqe_ctr);
138 }
139
140 static inline u16 mlx5_wq_cyc_ctr2ix(struct mlx5_wq_cyc *wq, u16 ctr)
141 {
142 return ctr & wq->fbc.sz_m1;
143 }
144
145 static inline u16 mlx5_wq_cyc_get_head(struct mlx5_wq_cyc *wq)
146 {
147 return mlx5_wq_cyc_ctr2ix(wq, wq->wqe_ctr);
148 }
149
150 static inline u16 mlx5_wq_cyc_get_tail(struct mlx5_wq_cyc *wq)
151 {
152 return mlx5_wq_cyc_ctr2ix(wq, wq->wqe_ctr - wq->cur_sz);
153 }
154
155 static inline void *mlx5_wq_cyc_get_wqe(struct mlx5_wq_cyc *wq, u16 ix)
156 {
157 return mlx5_frag_buf_get_wqe(&wq->fbc, ix);
158 }
159
160 static inline u16 mlx5_wq_cyc_get_contig_wqebbs(struct mlx5_wq_cyc *wq, u16 ix)
161 {
162 return mlx5_frag_buf_get_idx_last_contig_stride(&wq->fbc, ix) - ix + 1;
163 }
164
165 static inline int mlx5_wq_cyc_cc_bigger(u16 cc1, u16 cc2)
166 {
167 int equal = (cc1 == cc2);
168 int smaller = 0x8000 & (cc1 - cc2);
169
170 return !equal && !smaller;
171 }
172
173 static inline u32 mlx5_cqwq_ctr2ix(struct mlx5_cqwq *wq, u32 ctr)
174 {
175 return ctr & wq->fbc.sz_m1;
176 }
177
178 static inline u32 mlx5_cqwq_get_ci(struct mlx5_cqwq *wq)
179 {
180 return mlx5_cqwq_ctr2ix(wq, wq->cc);
181 }
182
183 static inline struct mlx5_cqe64 *mlx5_cqwq_get_wqe(struct mlx5_cqwq *wq, u32 ix)
184 {
185 struct mlx5_cqe64 *cqe = mlx5_frag_buf_get_wqe(&wq->fbc, ix);
186
187
188 cqe += wq->fbc.log_stride == 7;
189
190 return cqe;
191 }
192
193 static inline u32 mlx5_cqwq_get_ctr_wrap_cnt(struct mlx5_cqwq *wq, u32 ctr)
194 {
195 return ctr >> wq->fbc.log_sz;
196 }
197
198 static inline u32 mlx5_cqwq_get_wrap_cnt(struct mlx5_cqwq *wq)
199 {
200 return mlx5_cqwq_get_ctr_wrap_cnt(wq, wq->cc);
201 }
202
203 static inline void mlx5_cqwq_pop(struct mlx5_cqwq *wq)
204 {
205 wq->cc++;
206 }
207
208 static inline void mlx5_cqwq_update_db_record(struct mlx5_cqwq *wq)
209 {
210 *wq->db = cpu_to_be32(wq->cc & 0xffffff);
211 }
212
213 static inline struct mlx5_cqe64 *mlx5_cqwq_get_cqe(struct mlx5_cqwq *wq)
214 {
215 u32 ci = mlx5_cqwq_get_ci(wq);
216 struct mlx5_cqe64 *cqe = mlx5_cqwq_get_wqe(wq, ci);
217 u8 cqe_ownership_bit = cqe->op_own & MLX5_CQE_OWNER_MASK;
218 u8 sw_ownership_val = mlx5_cqwq_get_wrap_cnt(wq) & 1;
219
220 if (cqe_ownership_bit != sw_ownership_val)
221 return NULL;
222
223
224 dma_rmb();
225
226 return cqe;
227 }
228
229 static inline int mlx5_wq_ll_is_full(struct mlx5_wq_ll *wq)
230 {
231 return wq->cur_sz == wq->fbc.sz_m1;
232 }
233
234 static inline int mlx5_wq_ll_is_empty(struct mlx5_wq_ll *wq)
235 {
236 return !wq->cur_sz;
237 }
238
239 static inline int mlx5_wq_ll_missing(struct mlx5_wq_ll *wq)
240 {
241 return wq->fbc.sz_m1 - wq->cur_sz;
242 }
243
244 static inline void *mlx5_wq_ll_get_wqe(struct mlx5_wq_ll *wq, u16 ix)
245 {
246 return mlx5_frag_buf_get_wqe(&wq->fbc, ix);
247 }
248
249 static inline u16 mlx5_wq_ll_get_wqe_next_ix(struct mlx5_wq_ll *wq, u16 ix)
250 {
251 struct mlx5_wqe_srq_next_seg *wqe = mlx5_wq_ll_get_wqe(wq, ix);
252
253 return be16_to_cpu(wqe->next_wqe_index);
254 }
255
256 static inline void mlx5_wq_ll_push(struct mlx5_wq_ll *wq, u16 head_next)
257 {
258 wq->head = head_next;
259 wq->wqe_ctr++;
260 wq->cur_sz++;
261 }
262
263 static inline void mlx5_wq_ll_pop(struct mlx5_wq_ll *wq, __be16 ix,
264 __be16 *next_tail_next)
265 {
266 *wq->tail_next = ix;
267 wq->tail_next = next_tail_next;
268 wq->cur_sz--;
269 }
270
271 static inline void mlx5_wq_ll_update_db_record(struct mlx5_wq_ll *wq)
272 {
273 *wq->db = cpu_to_be32(wq->wqe_ctr);
274 }
275
276 #endif