1 /*
2 * Copyright (c) 2015-2024, Broadcom. All rights reserved. The term
3 * Broadcom refers to Broadcom Limited and/or its subsidiaries.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
18 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * Description: Fast Path Operators (header)
29 */
30
31 #ifndef __BNXT_QPLIB_FP_H__
32 #define __BNXT_QPLIB_FP_H__
33
34 /* Temp header structures for SQ */
35 struct sq_ud_ext_hdr {
36 __le32 dst_qp;
37 __le32 avid;
38 __le64 rsvd;
39 };
40
41 struct sq_raw_ext_hdr {
42 __le32 cfa_meta;
43 __le32 rsvd0;
44 __le64 rsvd1;
45 };
46
47 struct sq_rdma_ext_hdr {
48 __le64 remote_va;
49 __le32 remote_key;
50 __le32 rsvd;
51 };
52
53 struct sq_atomic_ext_hdr {
54 __le64 swap_data;
55 __le64 cmp_data;
56 };
57
58 struct sq_fr_pmr_ext_hdr {
59 __le64 pblptr;
60 __le64 va;
61 };
62
63 struct sq_bind_ext_hdr {
64 __le64 va;
65 __le32 length_lo;
66 __le32 length_hi;
67 };
68
69 struct rq_ext_hdr {
70 __le64 rsvd1;
71 __le64 rsvd2;
72 };
73
74 #define BNXT_QPLIB_ETHTYPE_ROCEV1 0x8915
75
76 struct bnxt_qplib_srq {
77 struct bnxt_qplib_pd *pd;
78 struct bnxt_qplib_dpi *dpi;
79 struct bnxt_qplib_chip_ctx *cctx;
80 struct bnxt_qplib_cq *cq;
81 struct bnxt_qplib_swq *swq;
82 struct bnxt_qplib_hwq hwq;
83 struct bnxt_qplib_db_info dbinfo;
84 struct bnxt_qplib_sg_info sginfo;
85 u64 srq_handle;
86 u32 id;
87 u16 wqe_size;
88 u32 max_wqe;
89 u32 max_sge;
90 u32 threshold;
91 bool arm_req;
92 int start_idx;
93 int last_idx;
94 u16 eventq_hw_ring_id;
95 bool is_user;
96 spinlock_t lock;
97 };
98
99 struct bnxt_qplib_sge {
100 u64 addr;
101 u32 size;
102 u32 lkey;
103 };
104
105 /*
106 * Buffer space for ETH(14), IP or GRH(40), UDP header(8)
107 * and ib_bth + ib_deth (20).
108 * Max required is 82 when RoCE V2 is enabled
109 */
110
111 /*
112 * RoCE V1 (38 bytes needed)
113 * +------------+----------+--------+--------+-------+
114 * |Eth-hdr(14B)| GRH (40B)|bth+deth| Mad | iCRC |
115 * | | supplied | 20B |payload | 4B |
116 * | | by user |supplied| 256B | |
117 * | | mad | |by user | |
118 * | | | | | |
119 * | sge 1 | sge 2 | sge 3 | sge 4 | sge 5 |
120 * +------------+----------+--------+--------+-------+
121 */
122
123 /*
124 * RoCE V2-IPv4 (46 Bytes needed)
125 * +------------+----------+--------+--------+-------+
126 * |Eth-hdr(14B)| IP-hdr |UDP-hdr | Mad | iCRC |
127 * | | supplied | 8B |payload | 4B |
128 * | | by user |bth+deth| 256B | |
129 * | | mad lower| 20B |supplied| |
130 * | | 20B out | (sge 3)|by user | |
131 * | | of 40B | | | |
132 * | | grh space| | | |
133 * | sge 1 | sge 2 | sge 3 | sge 4 | sge 5 |
134 * +------------+----------+--------+--------+-------+
135 */
136
137 /*
138 * RoCE V2-IPv6 (46 Bytes needed)
139 * +------------+----------+--------+--------+-------+
140 * |Eth-hdr(14B)| IPv6 |UDP-hdr | Mad | iCRC |
141 * | | supplied | 8B |payload | 4B |
142 * | | by user |bth+deth| 256B | |
143 * | | mad lower| 20B |supplied| |
144 * | | 40 bytes | |by user | |
145 * | | grh space| | | |
146 * | | | | | |
147 * | sge 1 | sge 2 | sge 3 | sge 4 | sge 5 |
148 * +------------+----------+--------+--------+-------+
149 */
150
151 #define BNXT_QPLIB_MAX_QP1_SQ_HDR_SIZE 74
152 #define BNXT_QPLIB_MAX_QP1_SQ_HDR_SIZE_V2 86
153 #define BNXT_QPLIB_MAX_QP1_RQ_HDR_SIZE 46
154 #define BNXT_QPLIB_MAX_QP1_RQ_ETH_HDR_SIZE 14
155 #define BNXT_QPLIB_MAX_QP1_RQ_HDR_SIZE_V2 512
156 #define BNXT_QPLIB_MAX_GRH_HDR_SIZE_IPV4 20
157 #define BNXT_QPLIB_MAX_GRH_HDR_SIZE_IPV6 40
158 #define BNXT_QPLIB_MAX_QP1_RQ_BDETH_HDR_SIZE 20
159 #define BNXT_QPLIB_MAX_SQSZ 0xFFFF
160
161 struct bnxt_qplib_hdrbuf {
162 dma_addr_t dma_map;
163 void *va;
164 u32 len;
165 u32 step;
166 };
167
168 struct bnxt_qplib_swq {
169 u64 wr_id;
170 int next_idx;
171 u8 type;
172 u8 flags;
173 u32 start_psn;
174 u32 next_psn;
175 u32 slot_idx;
176 u8 slots;
177 /* WIP: make it void * to handle legacy also */
178 struct sq_psn_search *psn_search;
179 void *inline_data;
180 };
181
182 struct bnxt_qplib_swqe {
183 /* General */
184 #define BNXT_QPLIB_FENCE_WRID 0x46454E43 /* "FENC" */
185 #define BNXT_QPLIB_QP1_DUMMY_WRID 0x44554D59 /* "DUMY" */
186 u64 wr_id;
187 u8 reqs_type;
188 u8 type;
189 #define BNXT_QPLIB_SWQE_TYPE_SEND 0
190 #define BNXT_QPLIB_SWQE_TYPE_SEND_WITH_IMM 1
191 #define BNXT_QPLIB_SWQE_TYPE_SEND_WITH_INV 2
192 #define BNXT_QPLIB_SWQE_TYPE_RDMA_WRITE 4
193 #define BNXT_QPLIB_SWQE_TYPE_RDMA_WRITE_WITH_IMM 5
194 #define BNXT_QPLIB_SWQE_TYPE_RDMA_READ 6
195 #define BNXT_QPLIB_SWQE_TYPE_ATOMIC_CMP_AND_SWP 8
196 #define BNXT_QPLIB_SWQE_TYPE_ATOMIC_FETCH_AND_ADD 11
197 #define BNXT_QPLIB_SWQE_TYPE_LOCAL_INV 12
198 #define BNXT_QPLIB_SWQE_TYPE_FAST_REG_MR 13
199 #define BNXT_QPLIB_SWQE_TYPE_REG_MR 13
200 #define BNXT_QPLIB_SWQE_TYPE_BIND_MW 14
201 #define BNXT_QPLIB_SWQE_TYPE_RECV 128
202 #define BNXT_QPLIB_SWQE_TYPE_RECV_RDMA_IMM 129
203 u8 flags;
204 #define BNXT_QPLIB_SWQE_FLAGS_SIGNAL_COMP (1 << 0)
205 #define BNXT_QPLIB_SWQE_FLAGS_RD_ATOMIC_FENCE (1 << 1)
206 #define BNXT_QPLIB_SWQE_FLAGS_UC_FENCE (1 << 2)
207 #define BNXT_QPLIB_SWQE_FLAGS_SOLICIT_EVENT (1 << 3)
208 #define BNXT_QPLIB_SWQE_FLAGS_INLINE (1 << 4)
209 struct bnxt_qplib_sge *sg_list;
210 int num_sge;
211
212 union {
213 /* Send, with imm, inval key */
214 struct {
215 union {
216 __be32 imm_data;
217 u32 inv_key;
218 };
219 u32 q_key;
220 u32 dst_qp;
221 u16 avid;
222 } send;
223
224 /* Send Raw Ethernet and QP1 */
225 struct {
226 u16 lflags;
227 u16 cfa_action;
228 u32 cfa_meta;
229 } rawqp1;
230
231 /* RDMA write, with imm, read */
232 struct {
233 union {
234 __be32 imm_data;
235 u32 inv_key;
236 };
237 u64 remote_va;
238 u32 r_key;
239 } rdma;
240
241 /* Atomic cmp/swap, fetch/add */
242 struct {
243 u64 remote_va;
244 u32 r_key;
245 u64 swap_data;
246 u64 cmp_data;
247 } atomic;
248
249 /* Local Invalidate */
250 struct {
251 u32 inv_l_key;
252 } local_inv;
253
254 /* FR-PMR */
255 struct {
256 u8 access_cntl;
257 u8 pg_sz_log;
258 bool zero_based;
259 u32 l_key;
260 u32 length;
261 u8 pbl_pg_sz_log;
262 #define BNXT_QPLIB_SWQE_PAGE_SIZE_4K 0
263 #define BNXT_QPLIB_SWQE_PAGE_SIZE_8K 1
264 #define BNXT_QPLIB_SWQE_PAGE_SIZE_64K 4
265 #define BNXT_QPLIB_SWQE_PAGE_SIZE_256K 6
266 #define BNXT_QPLIB_SWQE_PAGE_SIZE_1M 8
267 #define BNXT_QPLIB_SWQE_PAGE_SIZE_2M 9
268 #define BNXT_QPLIB_SWQE_PAGE_SIZE_4M 10
269 #define BNXT_QPLIB_SWQE_PAGE_SIZE_1G 18
270 u8 levels;
271 #define PAGE_SHIFT_4K 12
272 __le64 *pbl_ptr;
273 dma_addr_t pbl_dma_ptr;
274 u64 *page_list;
275 u16 page_list_len;
276 u64 va;
277 } frmr;
278
279 /* Bind */
280 struct {
281 u8 access_cntl;
282 #define BNXT_QPLIB_BIND_SWQE_ACCESS_LOCAL_WRITE (1 << 0)
283 #define BNXT_QPLIB_BIND_SWQE_ACCESS_REMOTE_READ (1 << 1)
284 #define BNXT_QPLIB_BIND_SWQE_ACCESS_REMOTE_WRITE (1 << 2)
285 #define BNXT_QPLIB_BIND_SWQE_ACCESS_REMOTE_ATOMIC (1 << 3)
286 #define BNXT_QPLIB_BIND_SWQE_ACCESS_WINDOW_BIND (1 << 4)
287 bool zero_based;
288 u8 mw_type;
289 u32 parent_l_key;
290 u32 r_key;
291 u64 va;
292 u32 length;
293 } bind;
294 };
295 };
296
297 struct bnxt_qplib_q {
298 struct bnxt_qplib_swq *swq;
299 struct bnxt_qplib_db_info dbinfo;
300 struct bnxt_qplib_sg_info sginfo;
301 struct bnxt_qplib_hwq hwq;
302 u32 max_wqe;
303 u32 max_sw_wqe;
304 u16 max_sge;
305 u16 wqe_size;
306 u16 q_full_delta;
307 u32 psn;
308 bool condition;
309 bool single;
310 bool legacy_send_phantom;
311 u32 phantom_wqe_cnt;
312 u32 phantom_cqe_cnt;
313 u32 next_cq_cons;
314 bool flushed;
315 u32 swq_start;
316 u32 swq_last;
317 };
318
319 #define BNXT_QPLIB_PPP_REQ 0x1
320 #define BNXT_QPLIB_PPP_ST_IDX_SHIFT 0x1
321
322 struct bnxt_qplib_ppp {
323 u32 dpi;
324 u8 req;
325 u8 st_idx_en;
326 };
327
328 struct bnxt_qplib_qp {
329 struct bnxt_qplib_pd *pd;
330 struct bnxt_qplib_dpi *dpi;
331 struct bnxt_qplib_chip_ctx *cctx;
332 u64 qp_handle;
333 #define BNXT_QPLIB_QP_ID_INVALID 0xFFFFFFFF
334 u32 id;
335 u8 type;
336 u8 sig_type;
337 u8 wqe_mode;
338 u8 state;
339 u8 cur_qp_state;
340 u8 is_user;
341 u64 modify_flags;
342 u32 max_inline_data;
343 u32 mtu;
344 u32 path_mtu;
345 bool en_sqd_async_notify;
346 u16 pkey_index;
347 u32 qkey;
348 u32 dest_qp_id;
349 u8 access;
350 u8 timeout;
351 u8 retry_cnt;
352 u8 rnr_retry;
353 u64 wqe_cnt;
354 u32 min_rnr_timer;
355 u32 max_rd_atomic;
356 u32 max_dest_rd_atomic;
357 u32 dest_qpn;
358 u8 smac[6];
359 u16 vlan_id;
360 u8 nw_type;
361 u16 port_id;
362 struct bnxt_qplib_ah ah;
363 struct bnxt_qplib_ppp ppp;
364
365 #define BTH_PSN_MASK ((1 << 24) - 1)
366 /* SQ */
367 struct bnxt_qplib_q sq;
368 /* RQ */
369 struct bnxt_qplib_q rq;
370 /* SRQ */
371 struct bnxt_qplib_srq *srq;
372 /* CQ */
373 struct bnxt_qplib_cq *scq;
374 struct bnxt_qplib_cq *rcq;
375 /* IRRQ and ORRQ */
376 struct bnxt_qplib_hwq irrq;
377 struct bnxt_qplib_hwq orrq;
378 /* Header buffer for QP1 */
379 struct bnxt_qplib_hdrbuf *sq_hdr_buf;
380 struct bnxt_qplib_hdrbuf *rq_hdr_buf;
381
382 /* ToS */
383 u8 tos_ecn;
384 u8 tos_dscp;
385 /* To track the SQ and RQ flush list */
386 struct list_head sq_flush;
387 struct list_head rq_flush;
388 /* 4 bytes of QP's scrabled mac received from FW */
389 u32 msn;
390 u32 msn_tbl_sz;
391 /* get devflags in PI code */
392 u16 dev_cap_flags;
393 bool is_host_msn_tbl;
394 };
395
396
397 #define CQE_CMP_VALID(hdr, pass) \
398 (!!((hdr)->cqe_type_toggle & CQ_BASE_TOGGLE) == \
399 !(pass & BNXT_QPLIB_FLAG_EPOCH_CONS_MASK))
400
__bnxt_qplib_get_avail(struct bnxt_qplib_hwq * hwq)401 static inline u32 __bnxt_qplib_get_avail(struct bnxt_qplib_hwq *hwq)
402 {
403 int cons, prod, avail;
404
405 /* False full is possible retrying post-send makes sense */
406 cons = hwq->cons;
407 prod = hwq->prod;
408 avail = cons - prod;
409 if (cons <= prod)
410 avail += hwq->depth;
411 return avail;
412 }
413
bnxt_qplib_queue_full(struct bnxt_qplib_hwq * hwq,u8 slots)414 static inline bool bnxt_qplib_queue_full(struct bnxt_qplib_hwq *hwq, u8 slots)
415 {
416 return __bnxt_qplib_get_avail(hwq) <= slots;
417 }
418
419 struct bnxt_qplib_cqe {
420 u8 status;
421 u8 type;
422 u8 opcode;
423 u32 length;
424 /* Lower 16 is cfa_metadata0, Upper 16 is cfa_metadata1 */
425 u32 cfa_meta;
426 #define BNXT_QPLIB_META1_SHIFT 16
427 #define BNXT_QPLIB_CQE_CFA_META1_VALID 0x80000UL
428 u64 wr_id;
429 union {
430 __be32 immdata;
431 u32 invrkey;
432 };
433 u64 qp_handle;
434 u64 mr_handle;
435 u16 flags;
436 u8 smac[6];
437 u32 src_qp;
438 u16 raweth_qp1_flags;
439 u16 raweth_qp1_errors;
440 u16 raweth_qp1_cfa_code;
441 u32 raweth_qp1_flags2;
442 u32 raweth_qp1_metadata;
443 u8 raweth_qp1_payload_offset;
444 u16 pkey_index;
445 };
446
447 #define BNXT_QPLIB_QUEUE_START_PERIOD 0x01
448 struct bnxt_qplib_cq {
449 struct bnxt_qplib_dpi *dpi;
450 struct bnxt_qplib_chip_ctx *cctx;
451 struct bnxt_qplib_nq *nq;
452 struct bnxt_qplib_db_info dbinfo;
453 struct bnxt_qplib_sg_info sginfo;
454 struct bnxt_qplib_hwq hwq;
455 struct bnxt_qplib_hwq resize_hwq;
456 struct list_head sqf_head;
457 struct list_head rqf_head;
458 u32 max_wqe;
459 u32 id;
460 u16 count;
461 u16 period;
462 u32 cnq_hw_ring_id;
463 u64 cq_handle;
464 atomic_t arm_state;
465 #define CQ_RESIZE_WAIT_TIME_MS 500
466 unsigned long flags;
467 #define CQ_FLAGS_RESIZE_IN_PROG 1
468 wait_queue_head_t waitq;
469 spinlock_t flush_lock; /* lock flush queue list */
470 spinlock_t compl_lock; /* synch CQ handlers */
471 u16 cnq_events;
472 bool is_cq_err_event;
473 bool destroyed;
474 u8 toggle;
475 };
476
477 #define BNXT_QPLIB_MAX_IRRQE_ENTRY_SIZE sizeof(struct xrrq_irrq)
478 #define BNXT_QPLIB_MAX_ORRQE_ENTRY_SIZE sizeof(struct xrrq_orrq)
479 #define IRD_LIMIT_TO_IRRQ_SLOTS(x) (2 * x + 2)
480 #define IRRQ_SLOTS_TO_IRD_LIMIT(s) ((s >> 1) - 1)
481 #define ORD_LIMIT_TO_ORRQ_SLOTS(x) (x + 1)
482 #define ORRQ_SLOTS_TO_ORD_LIMIT(s) (s - 1)
483
484 #define NQE_CMP_VALID(hdr, pass) \
485 (!!(le32_to_cpu((hdr)->info63_v & 0xffffffff) & NQ_BASE_V) == \
486 !(pass & BNXT_QPLIB_FLAG_EPOCH_CONS_MASK))
487
488 #define BNXT_QPLIB_NQE_MAX_CNT (128 * 1024)
489
490 /* MSN table print macros for debugging */
491 #define BNXT_RE_MSN_IDX(m) (((m) & SQ_MSN_SEARCH_START_IDX_MASK) >> \
492 SQ_MSN_SEARCH_START_IDX_SFT)
493 #define BNXT_RE_MSN_NPSN(m) (((m) & SQ_MSN_SEARCH_NEXT_PSN_MASK) >> \
494 SQ_MSN_SEARCH_NEXT_PSN_SFT)
495 #define BNXT_RE_MSN_SPSN(m) (((m) & SQ_MSN_SEARCH_START_PSN_MASK) >> \
496 SQ_MSN_SEARCH_START_PSN_SFT)
497 #define BNXT_MSN_TBLE_SGE 6
498
499 struct bnxt_qplib_nq_stats {
500 u64 num_dbqne_processed;
501 u64 num_srqne_processed;
502 u64 num_cqne_processed;
503 u64 num_tasklet_resched;
504 u64 num_nq_rearm;
505 };
506
507 struct bnxt_qplib_nq_db {
508 struct bnxt_qplib_reg_desc reg;
509 void __iomem *db;
510 struct bnxt_qplib_db_info dbinfo;
511 };
512
513 typedef int (*cqn_handler_t)(struct bnxt_qplib_nq *nq,
514 struct bnxt_qplib_cq *cq);
515 typedef int (*srqn_handler_t)(struct bnxt_qplib_nq *nq,
516 struct bnxt_qplib_srq *srq, u8 event);
517
518 struct bnxt_qplib_nq {
519 struct bnxt_qplib_res *res;
520 struct bnxt_qplib_hwq hwq;
521 struct bnxt_qplib_nq_db nq_db;
522
523 char *name;
524 u16 ring_id;
525 int msix_vec;
526 bool requested;
527 int budget;
528 u32 load;
529 struct mutex lock;
530
531 cqn_handler_t cqn_handler;
532 srqn_handler_t srqn_handler;
533 struct workqueue_struct *cqn_wq;
534 struct bnxt_qplib_nq_stats stats;
535 };
536
537 struct bnxt_qplib_nq_work {
538 struct work_struct work;
539 struct bnxt_qplib_nq *nq;
540 struct bnxt_qplib_cq *cq;
541 };
542
543 static inline dma_addr_t
bnxt_qplib_get_qp_buf_from_index(struct bnxt_qplib_qp * qp,u32 index)544 bnxt_qplib_get_qp_buf_from_index(struct bnxt_qplib_qp *qp, u32 index)
545 {
546 struct bnxt_qplib_hdrbuf *buf;
547
548 buf = qp->rq_hdr_buf;
549 return (buf->dma_map + index * buf->step);
550 }
551
552 void bnxt_qplib_nq_stop_irq(struct bnxt_qplib_nq *nq, bool kill);
553 void bnxt_qplib_disable_nq(struct bnxt_qplib_nq *nq);
554 int bnxt_qplib_nq_start_irq(struct bnxt_qplib_nq *nq, int nq_indx,
555 int msix_vector, bool need_init);
556 int bnxt_qplib_enable_nq(struct bnxt_qplib_nq *nq, int nq_idx,
557 int msix_vector, int bar_reg_offset,
558 cqn_handler_t cqn_handler,
559 srqn_handler_t srq_handler);
560 int bnxt_qplib_create_srq(struct bnxt_qplib_res *res,
561 struct bnxt_qplib_srq *srq);
562 int bnxt_qplib_modify_srq(struct bnxt_qplib_res *res,
563 struct bnxt_qplib_srq *srq);
564 int bnxt_qplib_query_srq(struct bnxt_qplib_res *res,
565 struct bnxt_qplib_srq *srq);
566 int bnxt_qplib_destroy_srq(struct bnxt_qplib_res *res,
567 struct bnxt_qplib_srq *srq);
568 int bnxt_qplib_post_srq_recv(struct bnxt_qplib_srq *srq,
569 struct bnxt_qplib_swqe *wqe);
570 int bnxt_qplib_create_qp1(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp);
571 int bnxt_qplib_create_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp);
572 int bnxt_qplib_modify_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp);
573 int bnxt_qplib_query_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp);
574 int bnxt_qplib_destroy_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp);
575 void bnxt_qplib_clean_qp(struct bnxt_qplib_qp *qp);
576 void bnxt_qplib_free_qp_res(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp);
577 void *bnxt_qplib_get_qp1_sq_buf(struct bnxt_qplib_qp *qp,
578 struct bnxt_qplib_sge *sge);
579 void *bnxt_qplib_get_qp1_rq_buf(struct bnxt_qplib_qp *qp,
580 struct bnxt_qplib_sge *sge);
581 u32 bnxt_qplib_get_rq_prod_index(struct bnxt_qplib_qp *qp);
582 void bnxt_qplib_post_send_db(struct bnxt_qplib_qp *qp);
583 int bnxt_qplib_post_send(struct bnxt_qplib_qp *qp,
584 struct bnxt_qplib_swqe *wqe);
585 void bnxt_qplib_post_recv_db(struct bnxt_qplib_qp *qp);
586 int bnxt_qplib_post_recv(struct bnxt_qplib_qp *qp,
587 struct bnxt_qplib_swqe *wqe);
588 int bnxt_qplib_create_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq);
589 int bnxt_qplib_modify_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq);
590 int bnxt_qplib_resize_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq,
591 int new_cqes);
592 void bnxt_qplib_resize_cq_complete(struct bnxt_qplib_res *res,
593 struct bnxt_qplib_cq *cq);
594 int bnxt_qplib_destroy_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq);
595 void bnxt_qplib_free_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq);
596 int bnxt_qplib_poll_cq(struct bnxt_qplib_cq *cq, struct bnxt_qplib_cqe *cqe,
597 int num, struct bnxt_qplib_qp **qp);
598 bool bnxt_qplib_is_cq_empty(struct bnxt_qplib_cq *cq);
599 void bnxt_qplib_req_notify_cq(struct bnxt_qplib_cq *cq, u32 arm_type);
600 void bnxt_qplib_free_nq_mem(struct bnxt_qplib_nq *nq);
601 int bnxt_qplib_alloc_nq_mem(struct bnxt_qplib_res *res,
602 struct bnxt_qplib_nq *nq);
603 void bnxt_qplib_add_flush_qp(struct bnxt_qplib_qp *qp);
604 void bnxt_qplib_del_flush_qp(struct bnxt_qplib_qp *qp);
605 int bnxt_qplib_process_flush_list(struct bnxt_qplib_cq *cq,
606 struct bnxt_qplib_cqe *cqe,
607 int num_cqes);
608 void bnxt_qplib_flush_cqn_wq(struct bnxt_qplib_qp *qp);
609 void bnxt_qplib_free_hdr_buf(struct bnxt_qplib_res *res,
610 struct bnxt_qplib_qp *qp);
611 int bnxt_qplib_alloc_hdr_buf(struct bnxt_qplib_res *res,
612 struct bnxt_qplib_qp *qp, u32 slen, u32 rlen);
613
__can_request_ppp(struct bnxt_qplib_qp * qp)614 static inline bool __can_request_ppp(struct bnxt_qplib_qp *qp)
615 {
616 bool can_request = false;
617
618 if (qp->cur_qp_state == CMDQ_MODIFY_QP_NEW_STATE_RESET &&
619 qp->state == CMDQ_MODIFY_QP_NEW_STATE_INIT &&
620 qp->ppp.req &&
621 !(qp->ppp.st_idx_en &
622 CREQ_MODIFY_QP_RESP_PINGPONG_PUSH_ENABLED))
623 can_request = true;
624 return can_request;
625 }
626
627 /* MSN table update inlin */
bnxt_re_update_msn_tbl(uint32_t st_idx,uint32_t npsn,uint32_t start_psn)628 static inline uint64_t bnxt_re_update_msn_tbl(uint32_t st_idx, uint32_t npsn, uint32_t start_psn)
629 {
630 return cpu_to_le64((((u64)(st_idx) << SQ_MSN_SEARCH_START_IDX_SFT) &
631 SQ_MSN_SEARCH_START_IDX_MASK) |
632 (((u64)(npsn) << SQ_MSN_SEARCH_NEXT_PSN_SFT) &
633 SQ_MSN_SEARCH_NEXT_PSN_MASK) |
634 (((start_psn) << SQ_MSN_SEARCH_START_PSN_SFT) &
635 SQ_MSN_SEARCH_START_PSN_MASK));
636 }
637
__is_var_wqe(struct bnxt_qplib_qp * qp)638 static inline bool __is_var_wqe(struct bnxt_qplib_qp *qp)
639 {
640 return (qp->wqe_mode == BNXT_QPLIB_WQE_MODE_VARIABLE);
641 }
642
__is_err_cqe_for_var_wqe(struct bnxt_qplib_qp * qp,u8 status)643 static inline bool __is_err_cqe_for_var_wqe(struct bnxt_qplib_qp *qp, u8 status)
644 {
645 return (status != CQ_REQ_STATUS_OK) && __is_var_wqe(qp);
646 }
647
648 void bnxt_re_schedule_dbq_event(struct bnxt_qplib_res *res);
649 u32 bnxt_qplib_get_depth(struct bnxt_qplib_q *que, u8 wqe_mode, bool is_sq);
650 #endif
651