11ac5a404SSelvin Xavier /*
21ac5a404SSelvin Xavier * Broadcom NetXtreme-E RoCE driver.
31ac5a404SSelvin Xavier *
41ac5a404SSelvin Xavier * Copyright (c) 2016 - 2017, Broadcom. All rights reserved. The term
51ac5a404SSelvin Xavier * Broadcom refers to Broadcom Limited and/or its subsidiaries.
61ac5a404SSelvin Xavier *
71ac5a404SSelvin Xavier * This software is available to you under a choice of one of two
81ac5a404SSelvin Xavier * licenses. You may choose to be licensed under the terms of the GNU
91ac5a404SSelvin Xavier * General Public License (GPL) Version 2, available from the file
101ac5a404SSelvin Xavier * COPYING in the main directory of this source tree, or the
111ac5a404SSelvin Xavier * BSD license below:
121ac5a404SSelvin Xavier *
131ac5a404SSelvin Xavier * Redistribution and use in source and binary forms, with or without
141ac5a404SSelvin Xavier * modification, are permitted provided that the following conditions
151ac5a404SSelvin Xavier * are met:
161ac5a404SSelvin Xavier *
171ac5a404SSelvin Xavier * 1. Redistributions of source code must retain the above copyright
181ac5a404SSelvin Xavier * notice, this list of conditions and the following disclaimer.
191ac5a404SSelvin Xavier * 2. Redistributions in binary form must reproduce the above copyright
201ac5a404SSelvin Xavier * notice, this list of conditions and the following disclaimer in
211ac5a404SSelvin Xavier * the documentation and/or other materials provided with the
221ac5a404SSelvin Xavier * distribution.
231ac5a404SSelvin Xavier *
241ac5a404SSelvin Xavier * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
251ac5a404SSelvin Xavier * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
261ac5a404SSelvin Xavier * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
271ac5a404SSelvin Xavier * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
281ac5a404SSelvin Xavier * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
291ac5a404SSelvin Xavier * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
301ac5a404SSelvin Xavier * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
311ac5a404SSelvin Xavier * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
321ac5a404SSelvin Xavier * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
331ac5a404SSelvin Xavier * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
341ac5a404SSelvin Xavier * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
351ac5a404SSelvin Xavier *
361ac5a404SSelvin Xavier * Description: Fast Path Operators (header)
371ac5a404SSelvin Xavier */
381ac5a404SSelvin Xavier
391ac5a404SSelvin Xavier #ifndef __BNXT_QPLIB_FP_H__
401ac5a404SSelvin Xavier #define __BNXT_QPLIB_FP_H__
411ac5a404SSelvin Xavier
4287974051SDevesh Sharma #include <rdma/bnxt_re-abi.h>
4387974051SDevesh Sharma
4454ace984SDevesh Sharma /* Few helper structures temporarily defined here
4554ace984SDevesh Sharma * should get rid of these when roce_hsi.h is updated
4654ace984SDevesh Sharma * in original code base
4754ace984SDevesh Sharma */
4854ace984SDevesh Sharma struct sq_ud_ext_hdr {
4954ace984SDevesh Sharma __le32 dst_qp;
5054ace984SDevesh Sharma __le32 avid;
5154ace984SDevesh Sharma __le64 rsvd;
5254ace984SDevesh Sharma };
5354ace984SDevesh Sharma
5454ace984SDevesh Sharma struct sq_raw_ext_hdr {
5554ace984SDevesh Sharma __le32 cfa_meta;
5654ace984SDevesh Sharma __le32 rsvd0;
5754ace984SDevesh Sharma __le64 rsvd1;
5854ace984SDevesh Sharma };
5954ace984SDevesh Sharma
6054ace984SDevesh Sharma struct sq_rdma_ext_hdr {
6154ace984SDevesh Sharma __le64 remote_va;
6254ace984SDevesh Sharma __le32 remote_key;
6354ace984SDevesh Sharma __le32 rsvd;
6454ace984SDevesh Sharma };
6554ace984SDevesh Sharma
6654ace984SDevesh Sharma struct sq_atomic_ext_hdr {
6754ace984SDevesh Sharma __le64 swap_data;
6854ace984SDevesh Sharma __le64 cmp_data;
6954ace984SDevesh Sharma };
7054ace984SDevesh Sharma
7154ace984SDevesh Sharma struct sq_fr_pmr_ext_hdr {
7254ace984SDevesh Sharma __le64 pblptr;
7354ace984SDevesh Sharma __le64 va;
7454ace984SDevesh Sharma };
7554ace984SDevesh Sharma
7654ace984SDevesh Sharma struct sq_bind_ext_hdr {
7754ace984SDevesh Sharma __le64 va;
7854ace984SDevesh Sharma __le32 length_lo;
7954ace984SDevesh Sharma __le32 length_hi;
8054ace984SDevesh Sharma };
8154ace984SDevesh Sharma
8254ace984SDevesh Sharma struct rq_ext_hdr {
8354ace984SDevesh Sharma __le64 rsvd1;
8454ace984SDevesh Sharma __le64 rsvd2;
8554ace984SDevesh Sharma };
8654ace984SDevesh Sharma
8754ace984SDevesh Sharma /* Helper structures end */
8854ace984SDevesh Sharma
8937cb11acSDevesh Sharma struct bnxt_qplib_srq {
9037cb11acSDevesh Sharma struct bnxt_qplib_pd *pd;
9137cb11acSDevesh Sharma struct bnxt_qplib_dpi *dpi;
926f53196bSDevesh Sharma struct bnxt_qplib_db_info dbinfo;
9337cb11acSDevesh Sharma u64 srq_handle;
9437cb11acSDevesh Sharma u32 id;
95fddcbbb0SDevesh Sharma u16 wqe_size;
9637cb11acSDevesh Sharma u32 max_wqe;
9737cb11acSDevesh Sharma u32 max_sge;
9837cb11acSDevesh Sharma u32 threshold;
9937cb11acSDevesh Sharma bool arm_req;
10037cb11acSDevesh Sharma struct bnxt_qplib_cq *cq;
10137cb11acSDevesh Sharma struct bnxt_qplib_hwq hwq;
10237cb11acSDevesh Sharma struct bnxt_qplib_swq *swq;
10337cb11acSDevesh Sharma int start_idx;
10437cb11acSDevesh Sharma int last_idx;
1055aa84840SSelvin Xavier struct bnxt_qplib_sg_info sg_info;
10637cb11acSDevesh Sharma u16 eventq_hw_ring_id;
10737cb11acSDevesh Sharma spinlock_t lock; /* protect SRQE link list */
108640c2cf8SHongguang Gao u8 toggle;
10937cb11acSDevesh Sharma };
11037cb11acSDevesh Sharma
1111ac5a404SSelvin Xavier struct bnxt_qplib_sge {
1121ac5a404SSelvin Xavier u64 addr;
1131ac5a404SSelvin Xavier u32 lkey;
1141ac5a404SSelvin Xavier u32 size;
1151ac5a404SSelvin Xavier };
1161ac5a404SSelvin Xavier
1171ac5a404SSelvin Xavier #define BNXT_QPLIB_QP_MAX_SGL 6
1181ac5a404SSelvin Xavier struct bnxt_qplib_swq {
1191ac5a404SSelvin Xavier u64 wr_id;
12037cb11acSDevesh Sharma int next_idx;
1211ac5a404SSelvin Xavier u8 type;
1221ac5a404SSelvin Xavier u8 flags;
1231ac5a404SSelvin Xavier u32 start_psn;
1241ac5a404SSelvin Xavier u32 next_psn;
1252bb3c32cSDevesh Sharma u32 slot_idx;
126159fb4ceSDevesh Sharma u8 slots;
1271ac5a404SSelvin Xavier struct sq_psn_search *psn_search;
12837f91cffSDevesh Sharma struct sq_psn_search_ext *psn_ext;
1291ac5a404SSelvin Xavier };
1301ac5a404SSelvin Xavier
1311ac5a404SSelvin Xavier struct bnxt_qplib_swqe {
1321ac5a404SSelvin Xavier /* General */
1339152e0b7SEddie Wai #define BNXT_QPLIB_FENCE_WRID 0x46454E43 /* "FENC" */
1341ac5a404SSelvin Xavier u64 wr_id;
1351ac5a404SSelvin Xavier u8 reqs_type;
1361ac5a404SSelvin Xavier u8 type;
1371ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_TYPE_SEND 0
1381ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_TYPE_SEND_WITH_IMM 1
1391ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_TYPE_SEND_WITH_INV 2
1401ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_TYPE_RDMA_WRITE 4
1411ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_TYPE_RDMA_WRITE_WITH_IMM 5
1421ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_TYPE_RDMA_READ 6
1431ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_TYPE_ATOMIC_CMP_AND_SWP 8
1441ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_TYPE_ATOMIC_FETCH_AND_ADD 11
1451ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_TYPE_LOCAL_INV 12
1461ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_TYPE_FAST_REG_MR 13
1471ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_TYPE_REG_MR 13
1481ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_TYPE_BIND_MW 14
1491ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_TYPE_RECV 128
1501ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_TYPE_RECV_RDMA_IMM 129
1511ac5a404SSelvin Xavier u8 flags;
1521ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_FLAGS_SIGNAL_COMP BIT(0)
1531ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_FLAGS_RD_ATOMIC_FENCE BIT(1)
1541ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_FLAGS_UC_FENCE BIT(2)
1551ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_FLAGS_SOLICIT_EVENT BIT(3)
1561ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_FLAGS_INLINE BIT(4)
1571ac5a404SSelvin Xavier struct bnxt_qplib_sge sg_list[BNXT_QPLIB_QP_MAX_SGL];
1581ac5a404SSelvin Xavier int num_sge;
1591ac5a404SSelvin Xavier /* Max inline data is 96 bytes */
1601ac5a404SSelvin Xavier u32 inline_len;
1611ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_MAX_INLINE_LENGTH 96
1621ac5a404SSelvin Xavier u8 inline_data[BNXT_QPLIB_SWQE_MAX_INLINE_LENGTH];
1631ac5a404SSelvin Xavier
1641ac5a404SSelvin Xavier union {
1651ac5a404SSelvin Xavier /* Send, with imm, inval key */
1661ac5a404SSelvin Xavier struct {
1671ac5a404SSelvin Xavier union {
16895b087f8SJack Wang u32 imm_data;
1691ac5a404SSelvin Xavier u32 inv_key;
1701ac5a404SSelvin Xavier };
1711ac5a404SSelvin Xavier u32 q_key;
1721ac5a404SSelvin Xavier u32 dst_qp;
173*9ab20f76SSaravanan Vajravel u32 avid;
1741ac5a404SSelvin Xavier } send;
1751ac5a404SSelvin Xavier
1761ac5a404SSelvin Xavier /* Send Raw Ethernet and QP1 */
1771ac5a404SSelvin Xavier struct {
1781ac5a404SSelvin Xavier u16 lflags;
1791ac5a404SSelvin Xavier u16 cfa_action;
1801ac5a404SSelvin Xavier u32 cfa_meta;
1811ac5a404SSelvin Xavier } rawqp1;
1821ac5a404SSelvin Xavier
1831ac5a404SSelvin Xavier /* RDMA write, with imm, read */
1841ac5a404SSelvin Xavier struct {
1851ac5a404SSelvin Xavier union {
18695b087f8SJack Wang u32 imm_data;
1871ac5a404SSelvin Xavier u32 inv_key;
1881ac5a404SSelvin Xavier };
1891ac5a404SSelvin Xavier u64 remote_va;
1901ac5a404SSelvin Xavier u32 r_key;
1911ac5a404SSelvin Xavier } rdma;
1921ac5a404SSelvin Xavier
1931ac5a404SSelvin Xavier /* Atomic cmp/swap, fetch/add */
1941ac5a404SSelvin Xavier struct {
1951ac5a404SSelvin Xavier u64 remote_va;
1961ac5a404SSelvin Xavier u32 r_key;
1971ac5a404SSelvin Xavier u64 swap_data;
1981ac5a404SSelvin Xavier u64 cmp_data;
1991ac5a404SSelvin Xavier } atomic;
2001ac5a404SSelvin Xavier
2011ac5a404SSelvin Xavier /* Local Invalidate */
2021ac5a404SSelvin Xavier struct {
2031ac5a404SSelvin Xavier u32 inv_l_key;
2041ac5a404SSelvin Xavier } local_inv;
2051ac5a404SSelvin Xavier
2061ac5a404SSelvin Xavier /* FR-PMR */
2071ac5a404SSelvin Xavier struct {
2081ac5a404SSelvin Xavier u8 access_cntl;
2091ac5a404SSelvin Xavier u8 pg_sz_log;
2101ac5a404SSelvin Xavier bool zero_based;
2111ac5a404SSelvin Xavier u32 l_key;
2121ac5a404SSelvin Xavier u32 length;
2131ac5a404SSelvin Xavier u8 pbl_pg_sz_log;
2141ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_PAGE_SIZE_4K 0
2151ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_PAGE_SIZE_8K 1
2161ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_PAGE_SIZE_64K 4
2171ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_PAGE_SIZE_256K 6
2181ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_PAGE_SIZE_1M 8
2191ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_PAGE_SIZE_2M 9
2201ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_PAGE_SIZE_4M 10
2211ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_PAGE_SIZE_1G 18
2221ac5a404SSelvin Xavier u8 levels;
2231ac5a404SSelvin Xavier #define PAGE_SHIFT_4K 12
2241ac5a404SSelvin Xavier __le64 *pbl_ptr;
2251ac5a404SSelvin Xavier dma_addr_t pbl_dma_ptr;
2261ac5a404SSelvin Xavier u64 *page_list;
2271ac5a404SSelvin Xavier u16 page_list_len;
2281ac5a404SSelvin Xavier u64 va;
2291ac5a404SSelvin Xavier } frmr;
2301ac5a404SSelvin Xavier
2311ac5a404SSelvin Xavier /* Bind */
2321ac5a404SSelvin Xavier struct {
2331ac5a404SSelvin Xavier u8 access_cntl;
2341ac5a404SSelvin Xavier #define BNXT_QPLIB_BIND_SWQE_ACCESS_LOCAL_WRITE BIT(0)
2351ac5a404SSelvin Xavier #define BNXT_QPLIB_BIND_SWQE_ACCESS_REMOTE_READ BIT(1)
2361ac5a404SSelvin Xavier #define BNXT_QPLIB_BIND_SWQE_ACCESS_REMOTE_WRITE BIT(2)
2371ac5a404SSelvin Xavier #define BNXT_QPLIB_BIND_SWQE_ACCESS_REMOTE_ATOMIC BIT(3)
2381ac5a404SSelvin Xavier #define BNXT_QPLIB_BIND_SWQE_ACCESS_WINDOW_BIND BIT(4)
2391ac5a404SSelvin Xavier bool zero_based;
2401ac5a404SSelvin Xavier u8 mw_type;
2411ac5a404SSelvin Xavier u32 parent_l_key;
2421ac5a404SSelvin Xavier u32 r_key;
2431ac5a404SSelvin Xavier u64 va;
2441ac5a404SSelvin Xavier u32 length;
2451ac5a404SSelvin Xavier } bind;
2461ac5a404SSelvin Xavier };
2471ac5a404SSelvin Xavier };
2481ac5a404SSelvin Xavier
2491ac5a404SSelvin Xavier struct bnxt_qplib_q {
2501ac5a404SSelvin Xavier struct bnxt_qplib_hwq hwq;
2511ac5a404SSelvin Xavier struct bnxt_qplib_swq *swq;
2526f53196bSDevesh Sharma struct bnxt_qplib_db_info dbinfo;
2535aa84840SSelvin Xavier struct bnxt_qplib_sg_info sg_info;
2541ac5a404SSelvin Xavier u32 max_wqe;
255de1d364cSSelvin Xavier u32 max_sw_wqe;
256fddcbbb0SDevesh Sharma u16 wqe_size;
2579152e0b7SEddie Wai u16 q_full_delta;
2581ac5a404SSelvin Xavier u16 max_sge;
2591ac5a404SSelvin Xavier u32 psn;
2609152e0b7SEddie Wai bool condition;
2619152e0b7SEddie Wai bool single;
2629152e0b7SEddie Wai bool send_phantom;
2639152e0b7SEddie Wai u32 phantom_wqe_cnt;
2649152e0b7SEddie Wai u32 phantom_cqe_cnt;
2659152e0b7SEddie Wai u32 next_cq_cons;
266f218d67eSSelvin Xavier bool flushed;
267159fb4ceSDevesh Sharma u32 swq_start;
268159fb4ceSDevesh Sharma u32 swq_last;
2691ac5a404SSelvin Xavier };
2701ac5a404SSelvin Xavier
2711ac5a404SSelvin Xavier struct bnxt_qplib_qp {
2721ac5a404SSelvin Xavier struct bnxt_qplib_pd *pd;
2731ac5a404SSelvin Xavier struct bnxt_qplib_dpi *dpi;
27437f91cffSDevesh Sharma struct bnxt_qplib_chip_ctx *cctx;
2751ac5a404SSelvin Xavier u64 qp_handle;
276f218d67eSSelvin Xavier #define BNXT_QPLIB_QP_ID_INVALID 0xFFFFFFFF
2771ac5a404SSelvin Xavier u32 id;
2781ac5a404SSelvin Xavier u8 type;
2791ac5a404SSelvin Xavier u8 sig_type;
2801da968e0SDevesh Sharma u8 wqe_mode;
2811ac5a404SSelvin Xavier u8 state;
2821ac5a404SSelvin Xavier u8 cur_qp_state;
2831da968e0SDevesh Sharma u64 modify_flags;
2841ac5a404SSelvin Xavier u32 max_inline_data;
2851ac5a404SSelvin Xavier u32 mtu;
2861ac5a404SSelvin Xavier u8 path_mtu;
2871ac5a404SSelvin Xavier bool en_sqd_async_notify;
2881ac5a404SSelvin Xavier u16 pkey_index;
2891ac5a404SSelvin Xavier u32 qkey;
2901ac5a404SSelvin Xavier u32 dest_qp_id;
2911ac5a404SSelvin Xavier u8 access;
2921ac5a404SSelvin Xavier u8 timeout;
2931ac5a404SSelvin Xavier u8 retry_cnt;
2941ac5a404SSelvin Xavier u8 rnr_retry;
2953fb755b3SSomnath Kotur u64 wqe_cnt;
2961ac5a404SSelvin Xavier u32 min_rnr_timer;
2971ac5a404SSelvin Xavier u32 max_rd_atomic;
2981ac5a404SSelvin Xavier u32 max_dest_rd_atomic;
2991ac5a404SSelvin Xavier u32 dest_qpn;
3001ac5a404SSelvin Xavier u8 smac[6];
3011ac5a404SSelvin Xavier u16 vlan_id;
3021ac5a404SSelvin Xavier u8 nw_type;
3031ac5a404SSelvin Xavier struct bnxt_qplib_ah ah;
3041ac5a404SSelvin Xavier
3051ac5a404SSelvin Xavier #define BTH_PSN_MASK ((1 << 24) - 1)
3061ac5a404SSelvin Xavier /* SQ */
3071ac5a404SSelvin Xavier struct bnxt_qplib_q sq;
3081ac5a404SSelvin Xavier /* RQ */
3091ac5a404SSelvin Xavier struct bnxt_qplib_q rq;
3101ac5a404SSelvin Xavier /* SRQ */
3111ac5a404SSelvin Xavier struct bnxt_qplib_srq *srq;
3121ac5a404SSelvin Xavier /* CQ */
3131ac5a404SSelvin Xavier struct bnxt_qplib_cq *scq;
3141ac5a404SSelvin Xavier struct bnxt_qplib_cq *rcq;
3151ac5a404SSelvin Xavier /* IRRQ and ORRQ */
3161ac5a404SSelvin Xavier struct bnxt_qplib_hwq irrq;
3171ac5a404SSelvin Xavier struct bnxt_qplib_hwq orrq;
3181ac5a404SSelvin Xavier /* Header buffer for QP1 */
3191ac5a404SSelvin Xavier int sq_hdr_buf_size;
3201ac5a404SSelvin Xavier int rq_hdr_buf_size;
3211ac5a404SSelvin Xavier /*
3221ac5a404SSelvin Xavier * Buffer space for ETH(14), IP or GRH(40), UDP header(8)
3231ac5a404SSelvin Xavier * and ib_bth + ib_deth (20).
3241ac5a404SSelvin Xavier * Max required is 82 when RoCE V2 is enabled
3251ac5a404SSelvin Xavier */
3261ac5a404SSelvin Xavier #define BNXT_QPLIB_MAX_QP1_SQ_HDR_SIZE_V2 86
3271ac5a404SSelvin Xavier /* Ethernet header = 14 */
3281ac5a404SSelvin Xavier /* ib_grh = 40 (provided by MAD) */
3291ac5a404SSelvin Xavier /* ib_bth + ib_deth = 20 */
3301ac5a404SSelvin Xavier /* MAD = 256 (provided by MAD) */
3311ac5a404SSelvin Xavier /* iCRC = 4 */
3321ac5a404SSelvin Xavier #define BNXT_QPLIB_MAX_QP1_RQ_ETH_HDR_SIZE 14
3331ac5a404SSelvin Xavier #define BNXT_QPLIB_MAX_QP1_RQ_HDR_SIZE_V2 512
3341ac5a404SSelvin Xavier #define BNXT_QPLIB_MAX_GRH_HDR_SIZE_IPV4 20
3351ac5a404SSelvin Xavier #define BNXT_QPLIB_MAX_GRH_HDR_SIZE_IPV6 40
3361ac5a404SSelvin Xavier #define BNXT_QPLIB_MAX_QP1_RQ_BDETH_HDR_SIZE 20
3371ac5a404SSelvin Xavier void *sq_hdr_buf;
3381ac5a404SSelvin Xavier dma_addr_t sq_hdr_buf_map;
3391ac5a404SSelvin Xavier void *rq_hdr_buf;
3401ac5a404SSelvin Xavier dma_addr_t rq_hdr_buf_map;
341f218d67eSSelvin Xavier struct list_head sq_flush;
342f218d67eSSelvin Xavier struct list_head rq_flush;
34307f830aeSSelvin Xavier u32 msn;
34407f830aeSSelvin Xavier u32 msn_tbl_sz;
3458d310ba8SSelvin Xavier bool is_host_msn_tbl;
3461ac5a404SSelvin Xavier };
3471ac5a404SSelvin Xavier
3481ac5a404SSelvin Xavier #define BNXT_QPLIB_MAX_CQE_ENTRY_SIZE sizeof(struct cq_base)
3491ac5a404SSelvin Xavier
3501ac5a404SSelvin Xavier #define CQE_CNT_PER_PG (PAGE_SIZE / BNXT_QPLIB_MAX_CQE_ENTRY_SIZE)
3511ac5a404SSelvin Xavier #define CQE_MAX_IDX_PER_PG (CQE_CNT_PER_PG - 1)
3521ac5a404SSelvin Xavier #define CQE_PG(x) (((x) & ~CQE_MAX_IDX_PER_PG) / CQE_CNT_PER_PG)
3531ac5a404SSelvin Xavier #define CQE_IDX(x) ((x) & CQE_MAX_IDX_PER_PG)
3541ac5a404SSelvin Xavier
3551ac5a404SSelvin Xavier #define ROCE_CQE_CMP_V 0
3563a4304d8SChandramohan Akula #define CQE_CMP_VALID(hdr, pass) \
3571ac5a404SSelvin Xavier (!!((hdr)->cqe_type_toggle & CQ_BASE_TOGGLE) == \
3583a4304d8SChandramohan Akula !((pass) & BNXT_QPLIB_FLAG_EPOCH_CONS_MASK))
3593a4304d8SChandramohan Akula
__bnxt_qplib_get_avail(struct bnxt_qplib_hwq * hwq)3603a4304d8SChandramohan Akula static inline u32 __bnxt_qplib_get_avail(struct bnxt_qplib_hwq *hwq)
3613a4304d8SChandramohan Akula {
3623a4304d8SChandramohan Akula int cons, prod, avail;
3633a4304d8SChandramohan Akula
3643a4304d8SChandramohan Akula cons = hwq->cons;
3653a4304d8SChandramohan Akula prod = hwq->prod;
3663a4304d8SChandramohan Akula avail = cons - prod;
3673a4304d8SChandramohan Akula if (cons <= prod)
3683a4304d8SChandramohan Akula avail += hwq->depth;
3693a4304d8SChandramohan Akula return avail;
3703a4304d8SChandramohan Akula }
3711ac5a404SSelvin Xavier
bnxt_qplib_queue_full(struct bnxt_qplib_q * que,u8 slots)3722bb3c32cSDevesh Sharma static inline bool bnxt_qplib_queue_full(struct bnxt_qplib_q *que,
3732bb3c32cSDevesh Sharma u8 slots)
3749152e0b7SEddie Wai {
3752bb3c32cSDevesh Sharma struct bnxt_qplib_hwq *hwq;
3762bb3c32cSDevesh Sharma int avail;
3772bb3c32cSDevesh Sharma
3782bb3c32cSDevesh Sharma hwq = &que->hwq;
3792bb3c32cSDevesh Sharma /* False full is possible, retrying post-send makes sense */
3802bb3c32cSDevesh Sharma avail = hwq->cons - hwq->prod;
3812bb3c32cSDevesh Sharma if (hwq->cons <= hwq->prod)
3822bb3c32cSDevesh Sharma avail += hwq->depth;
3832bb3c32cSDevesh Sharma return avail <= slots;
3849152e0b7SEddie Wai }
3859152e0b7SEddie Wai
3861ac5a404SSelvin Xavier struct bnxt_qplib_cqe {
3871ac5a404SSelvin Xavier u8 status;
3881ac5a404SSelvin Xavier u8 type;
3891ac5a404SSelvin Xavier u8 opcode;
3901ac5a404SSelvin Xavier u32 length;
391374c5285SDevesh Sharma u16 cfa_meta;
3921ac5a404SSelvin Xavier u64 wr_id;
3931ac5a404SSelvin Xavier union {
39495b087f8SJack Wang __le32 immdata;
3951ac5a404SSelvin Xavier u32 invrkey;
3961ac5a404SSelvin Xavier };
3971ac5a404SSelvin Xavier u64 qp_handle;
3981ac5a404SSelvin Xavier u64 mr_handle;
3991ac5a404SSelvin Xavier u16 flags;
4001ac5a404SSelvin Xavier u8 smac[6];
4011ac5a404SSelvin Xavier u32 src_qp;
4021ac5a404SSelvin Xavier u16 raweth_qp1_flags;
4031ac5a404SSelvin Xavier u16 raweth_qp1_errors;
4041ac5a404SSelvin Xavier u16 raweth_qp1_cfa_code;
4051ac5a404SSelvin Xavier u32 raweth_qp1_flags2;
4061ac5a404SSelvin Xavier u32 raweth_qp1_metadata;
4071ac5a404SSelvin Xavier u8 raweth_qp1_payload_offset;
4081ac5a404SSelvin Xavier u16 pkey_index;
4091ac5a404SSelvin Xavier };
4101ac5a404SSelvin Xavier
4111ac5a404SSelvin Xavier #define BNXT_QPLIB_QUEUE_START_PERIOD 0x01
4121ac5a404SSelvin Xavier struct bnxt_qplib_cq {
4131ac5a404SSelvin Xavier struct bnxt_qplib_dpi *dpi;
4146f53196bSDevesh Sharma struct bnxt_qplib_db_info dbinfo;
4151ac5a404SSelvin Xavier u32 max_wqe;
4161ac5a404SSelvin Xavier u32 id;
4171ac5a404SSelvin Xavier u16 count;
4181ac5a404SSelvin Xavier u16 period;
4191ac5a404SSelvin Xavier struct bnxt_qplib_hwq hwq;
420d54bd5abSSelvin Xavier struct bnxt_qplib_hwq resize_hwq;
4211ac5a404SSelvin Xavier u32 cnq_hw_ring_id;
422f218d67eSSelvin Xavier struct bnxt_qplib_nq *nq;
4231ac5a404SSelvin Xavier bool resize_in_progress;
4245aa84840SSelvin Xavier struct bnxt_qplib_sg_info sg_info;
4251ac5a404SSelvin Xavier u64 cq_handle;
4266027c20dSSelvin Xavier u8 toggle;
4271ac5a404SSelvin Xavier
4281ac5a404SSelvin Xavier #define CQ_RESIZE_WAIT_TIME_MS 500
4291ac5a404SSelvin Xavier unsigned long flags;
4301ac5a404SSelvin Xavier #define CQ_FLAGS_RESIZE_IN_PROG 1
4311ac5a404SSelvin Xavier wait_queue_head_t waitq;
432f218d67eSSelvin Xavier struct list_head sqf_head, rqf_head;
433f218d67eSSelvin Xavier atomic_t arm_state;
434f218d67eSSelvin Xavier spinlock_t compl_lock; /* synch CQ handlers */
435942c9b6cSSelvin Xavier /* Locking Notes:
436942c9b6cSSelvin Xavier * QP can move to error state from modify_qp, async error event or error
437942c9b6cSSelvin Xavier * CQE as part of poll_cq. When QP is moved to error state, it gets added
438942c9b6cSSelvin Xavier * to two flush lists, one each for SQ and RQ.
439942c9b6cSSelvin Xavier * Each flush list is protected by qplib_cq->flush_lock. Both scq and rcq
440942c9b6cSSelvin Xavier * flush_locks should be acquired when QP is moved to error. The control path
441942c9b6cSSelvin Xavier * operations(modify_qp and async error events) are synchronized with poll_cq
442942c9b6cSSelvin Xavier * using upper level CQ locks (bnxt_re_cq->cq_lock) of both SCQ and RCQ.
443942c9b6cSSelvin Xavier * The qplib_cq->flush_lock is required to synchronize two instances of poll_cq
444942c9b6cSSelvin Xavier * of the same QP while manipulating the flush list.
445942c9b6cSSelvin Xavier */
446942c9b6cSSelvin Xavier spinlock_t flush_lock; /* QP flush management */
447b1d56fdcSSelvin Xavier u16 cnq_events;
4481ac5a404SSelvin Xavier };
4491ac5a404SSelvin Xavier
4501ac5a404SSelvin Xavier #define BNXT_QPLIB_MAX_IRRQE_ENTRY_SIZE sizeof(struct xrrq_irrq)
4511ac5a404SSelvin Xavier #define BNXT_QPLIB_MAX_ORRQE_ENTRY_SIZE sizeof(struct xrrq_orrq)
4521ac5a404SSelvin Xavier #define IRD_LIMIT_TO_IRRQ_SLOTS(x) (2 * (x) + 2)
4531ac5a404SSelvin Xavier #define IRRQ_SLOTS_TO_IRD_LIMIT(s) (((s) >> 1) - 1)
4541ac5a404SSelvin Xavier #define ORD_LIMIT_TO_ORRQ_SLOTS(x) ((x) + 1)
4551ac5a404SSelvin Xavier #define ORRQ_SLOTS_TO_ORD_LIMIT(s) ((s) - 1)
4561ac5a404SSelvin Xavier
4571ac5a404SSelvin Xavier #define BNXT_QPLIB_MAX_NQE_ENTRY_SIZE sizeof(struct nq_base)
4581ac5a404SSelvin Xavier
4591ac5a404SSelvin Xavier #define NQE_CNT_PER_PG (PAGE_SIZE / BNXT_QPLIB_MAX_NQE_ENTRY_SIZE)
4601ac5a404SSelvin Xavier #define NQE_MAX_IDX_PER_PG (NQE_CNT_PER_PG - 1)
4611ac5a404SSelvin Xavier #define NQE_PG(x) (((x) & ~NQE_MAX_IDX_PER_PG) / NQE_CNT_PER_PG)
4621ac5a404SSelvin Xavier #define NQE_IDX(x) ((x) & NQE_MAX_IDX_PER_PG)
4631ac5a404SSelvin Xavier
4643a4304d8SChandramohan Akula #define NQE_CMP_VALID(hdr, pass) \
4651ac5a404SSelvin Xavier (!!(le32_to_cpu((hdr)->info63_v[0]) & NQ_BASE_V) == \
4663a4304d8SChandramohan Akula !((pass) & BNXT_QPLIB_FLAG_EPOCH_CONS_MASK))
4671ac5a404SSelvin Xavier
4681ac5a404SSelvin Xavier #define BNXT_QPLIB_NQE_MAX_CNT (128 * 1024)
4691ac5a404SSelvin Xavier
4701ac5a404SSelvin Xavier #define NQ_CONS_PCI_BAR_REGION 2
4711ac5a404SSelvin Xavier #define NQ_DB_KEY_CP (0x2 << CMPL_DOORBELL_KEY_SFT)
4721ac5a404SSelvin Xavier #define NQ_DB_IDX_VALID CMPL_DOORBELL_IDX_VALID
4731ac5a404SSelvin Xavier #define NQ_DB_IRQ_DIS CMPL_DOORBELL_MASK
4741ac5a404SSelvin Xavier #define NQ_DB_CP_FLAGS_REARM (NQ_DB_KEY_CP | \
4751ac5a404SSelvin Xavier NQ_DB_IDX_VALID)
4761ac5a404SSelvin Xavier #define NQ_DB_CP_FLAGS (NQ_DB_KEY_CP | \
4771ac5a404SSelvin Xavier NQ_DB_IDX_VALID | \
4781ac5a404SSelvin Xavier NQ_DB_IRQ_DIS)
479b353ce55SDevesh Sharma
4809555352bSDevesh Sharma struct bnxt_qplib_nq_db {
4819555352bSDevesh Sharma struct bnxt_qplib_reg_desc reg;
4826f53196bSDevesh Sharma struct bnxt_qplib_db_info dbinfo;
4839555352bSDevesh Sharma };
4849555352bSDevesh Sharma
4859555352bSDevesh Sharma typedef int (*cqn_handler_t)(struct bnxt_qplib_nq *nq,
4869555352bSDevesh Sharma struct bnxt_qplib_cq *cq);
4879555352bSDevesh Sharma typedef int (*srqn_handler_t)(struct bnxt_qplib_nq *nq,
4889555352bSDevesh Sharma struct bnxt_qplib_srq *srq, u8 event);
4899555352bSDevesh Sharma
4901ac5a404SSelvin Xavier struct bnxt_qplib_nq {
4911ac5a404SSelvin Xavier struct pci_dev *pdev;
492ae8637e1SDevesh Sharma struct bnxt_qplib_res *res;
493ff2e4bfdSKalesh AP char *name;
4949555352bSDevesh Sharma struct bnxt_qplib_hwq hwq;
4959555352bSDevesh Sharma struct bnxt_qplib_nq_db nq_db;
4969555352bSDevesh Sharma u16 ring_id;
4979555352bSDevesh Sharma int msix_vec;
4989555352bSDevesh Sharma cpumask_t mask;
4999555352bSDevesh Sharma struct tasklet_struct nq_tasklet;
5009555352bSDevesh Sharma bool requested;
5019555352bSDevesh Sharma int budget;
5029555352bSDevesh Sharma
5039555352bSDevesh Sharma cqn_handler_t cqn_handler;
5049555352bSDevesh Sharma srqn_handler_t srqn_handler;
5059555352bSDevesh Sharma struct workqueue_struct *cqn_wq;
506f218d67eSSelvin Xavier };
507f218d67eSSelvin Xavier
508f218d67eSSelvin Xavier struct bnxt_qplib_nq_work {
509f218d67eSSelvin Xavier struct work_struct work;
510f218d67eSSelvin Xavier struct bnxt_qplib_nq *nq;
511f218d67eSSelvin Xavier struct bnxt_qplib_cq *cq;
5121ac5a404SSelvin Xavier };
5131ac5a404SSelvin Xavier
5146e04b103SDevesh Sharma void bnxt_qplib_nq_stop_irq(struct bnxt_qplib_nq *nq, bool kill);
5151ac5a404SSelvin Xavier void bnxt_qplib_disable_nq(struct bnxt_qplib_nq *nq);
5166e04b103SDevesh Sharma int bnxt_qplib_nq_start_irq(struct bnxt_qplib_nq *nq, int nq_indx,
5176e04b103SDevesh Sharma int msix_vector, bool need_init);
5181ac5a404SSelvin Xavier int bnxt_qplib_enable_nq(struct pci_dev *pdev, struct bnxt_qplib_nq *nq,
5196a5df91bSSelvin Xavier int nq_idx, int msix_vector, int bar_reg_offset,
5209555352bSDevesh Sharma cqn_handler_t cqn_handler,
5219555352bSDevesh Sharma srqn_handler_t srq_handler);
52237cb11acSDevesh Sharma int bnxt_qplib_create_srq(struct bnxt_qplib_res *res,
52337cb11acSDevesh Sharma struct bnxt_qplib_srq *srq);
52437cb11acSDevesh Sharma int bnxt_qplib_modify_srq(struct bnxt_qplib_res *res,
52537cb11acSDevesh Sharma struct bnxt_qplib_srq *srq);
52637cb11acSDevesh Sharma int bnxt_qplib_query_srq(struct bnxt_qplib_res *res,
52737cb11acSDevesh Sharma struct bnxt_qplib_srq *srq);
52868e326deSLeon Romanovsky void bnxt_qplib_destroy_srq(struct bnxt_qplib_res *res,
52937cb11acSDevesh Sharma struct bnxt_qplib_srq *srq);
53037cb11acSDevesh Sharma int bnxt_qplib_post_srq_recv(struct bnxt_qplib_srq *srq,
53137cb11acSDevesh Sharma struct bnxt_qplib_swqe *wqe);
5321ac5a404SSelvin Xavier int bnxt_qplib_create_qp1(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp);
5331ac5a404SSelvin Xavier int bnxt_qplib_create_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp);
5341ac5a404SSelvin Xavier int bnxt_qplib_modify_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp);
5351ac5a404SSelvin Xavier int bnxt_qplib_query_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp);
5361ac5a404SSelvin Xavier int bnxt_qplib_destroy_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp);
5373b921e3bSSelvin Xavier void bnxt_qplib_clean_qp(struct bnxt_qplib_qp *qp);
5383b921e3bSSelvin Xavier void bnxt_qplib_free_qp_res(struct bnxt_qplib_res *res,
5393b921e3bSSelvin Xavier struct bnxt_qplib_qp *qp);
5401ac5a404SSelvin Xavier void *bnxt_qplib_get_qp1_sq_buf(struct bnxt_qplib_qp *qp,
5411ac5a404SSelvin Xavier struct bnxt_qplib_sge *sge);
5421ac5a404SSelvin Xavier void *bnxt_qplib_get_qp1_rq_buf(struct bnxt_qplib_qp *qp,
5431ac5a404SSelvin Xavier struct bnxt_qplib_sge *sge);
5441ac5a404SSelvin Xavier u32 bnxt_qplib_get_rq_prod_index(struct bnxt_qplib_qp *qp);
5451ac5a404SSelvin Xavier dma_addr_t bnxt_qplib_get_qp_buf_from_index(struct bnxt_qplib_qp *qp,
5461ac5a404SSelvin Xavier u32 index);
5471ac5a404SSelvin Xavier void bnxt_qplib_post_send_db(struct bnxt_qplib_qp *qp);
5481ac5a404SSelvin Xavier int bnxt_qplib_post_send(struct bnxt_qplib_qp *qp,
5491ac5a404SSelvin Xavier struct bnxt_qplib_swqe *wqe);
5501ac5a404SSelvin Xavier void bnxt_qplib_post_recv_db(struct bnxt_qplib_qp *qp);
5511ac5a404SSelvin Xavier int bnxt_qplib_post_recv(struct bnxt_qplib_qp *qp,
5521ac5a404SSelvin Xavier struct bnxt_qplib_swqe *wqe);
5531ac5a404SSelvin Xavier int bnxt_qplib_create_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq);
554d54bd5abSSelvin Xavier int bnxt_qplib_resize_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq,
555d54bd5abSSelvin Xavier int new_cqes);
556d54bd5abSSelvin Xavier void bnxt_qplib_resize_cq_complete(struct bnxt_qplib_res *res,
557d54bd5abSSelvin Xavier struct bnxt_qplib_cq *cq);
5581ac5a404SSelvin Xavier int bnxt_qplib_destroy_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq);
5591ac5a404SSelvin Xavier int bnxt_qplib_poll_cq(struct bnxt_qplib_cq *cq, struct bnxt_qplib_cqe *cqe,
5609152e0b7SEddie Wai int num, struct bnxt_qplib_qp **qp);
561499e4569SSelvin Xavier bool bnxt_qplib_is_cq_empty(struct bnxt_qplib_cq *cq);
5621ac5a404SSelvin Xavier void bnxt_qplib_req_notify_cq(struct bnxt_qplib_cq *cq, u32 arm_type);
5631ac5a404SSelvin Xavier void bnxt_qplib_free_nq(struct bnxt_qplib_nq *nq);
5640c4dcd60SDevesh Sharma int bnxt_qplib_alloc_nq(struct bnxt_qplib_res *res, struct bnxt_qplib_nq *nq);
565f218d67eSSelvin Xavier void bnxt_qplib_add_flush_qp(struct bnxt_qplib_qp *qp);
566f218d67eSSelvin Xavier void bnxt_qplib_acquire_cq_locks(struct bnxt_qplib_qp *qp,
567f218d67eSSelvin Xavier unsigned long *flags);
568f218d67eSSelvin Xavier void bnxt_qplib_release_cq_locks(struct bnxt_qplib_qp *qp,
569f218d67eSSelvin Xavier unsigned long *flags);
570f218d67eSSelvin Xavier int bnxt_qplib_process_flush_list(struct bnxt_qplib_cq *cq,
571f218d67eSSelvin Xavier struct bnxt_qplib_cqe *cqe,
572f218d67eSSelvin Xavier int num_cqes);
573c88a7858SSelvin Xavier void bnxt_qplib_flush_cqn_wq(struct bnxt_qplib_qp *qp);
574b5bbc655SKashyap Desai void bnxt_re_synchronize_nq(struct bnxt_qplib_nq *nq);
575159fb4ceSDevesh Sharma
bnxt_qplib_get_swqe(struct bnxt_qplib_q * que,u32 * swq_idx)576159fb4ceSDevesh Sharma static inline void *bnxt_qplib_get_swqe(struct bnxt_qplib_q *que, u32 *swq_idx)
577159fb4ceSDevesh Sharma {
578159fb4ceSDevesh Sharma u32 idx;
579159fb4ceSDevesh Sharma
580159fb4ceSDevesh Sharma idx = que->swq_start;
581159fb4ceSDevesh Sharma if (swq_idx)
582159fb4ceSDevesh Sharma *swq_idx = idx;
583159fb4ceSDevesh Sharma return &que->swq[idx];
584159fb4ceSDevesh Sharma }
585159fb4ceSDevesh Sharma
bnxt_qplib_swq_mod_start(struct bnxt_qplib_q * que,u32 idx)586159fb4ceSDevesh Sharma static inline void bnxt_qplib_swq_mod_start(struct bnxt_qplib_q *que, u32 idx)
587159fb4ceSDevesh Sharma {
588159fb4ceSDevesh Sharma que->swq_start = que->swq[idx].next_idx;
589159fb4ceSDevesh Sharma }
590159fb4ceSDevesh Sharma
bnxt_qplib_get_depth(struct bnxt_qplib_q * que,u8 wqe_mode,bool is_sq)591de1d364cSSelvin Xavier static inline u32 bnxt_qplib_get_depth(struct bnxt_qplib_q *que, u8 wqe_mode, bool is_sq)
5922bb3c32cSDevesh Sharma {
593de1d364cSSelvin Xavier u32 slots;
594de1d364cSSelvin Xavier
595de1d364cSSelvin Xavier /* Queue depth is the number of slots. */
596de1d364cSSelvin Xavier slots = (que->wqe_size * que->max_wqe) / sizeof(struct sq_sge);
597de1d364cSSelvin Xavier /* For variable WQE mode, need to align the slots to 256 */
598de1d364cSSelvin Xavier if (wqe_mode == BNXT_QPLIB_WQE_MODE_VARIABLE && is_sq)
599de1d364cSSelvin Xavier slots = ALIGN(slots, BNXT_VAR_MAX_SLOT_ALIGN);
600de1d364cSSelvin Xavier return slots;
6012bb3c32cSDevesh Sharma }
6022bb3c32cSDevesh Sharma
bnxt_qplib_set_sq_size(struct bnxt_qplib_q * que,u8 wqe_mode)6032bb3c32cSDevesh Sharma static inline u32 bnxt_qplib_set_sq_size(struct bnxt_qplib_q *que, u8 wqe_mode)
6042bb3c32cSDevesh Sharma {
6052bb3c32cSDevesh Sharma return (wqe_mode == BNXT_QPLIB_WQE_MODE_STATIC) ?
606de1d364cSSelvin Xavier que->max_wqe : bnxt_qplib_get_depth(que, wqe_mode, true);
6072bb3c32cSDevesh Sharma }
6082bb3c32cSDevesh Sharma
bnxt_qplib_set_sq_max_slot(u8 wqe_mode)6092bb3c32cSDevesh Sharma static inline u32 bnxt_qplib_set_sq_max_slot(u8 wqe_mode)
6102bb3c32cSDevesh Sharma {
6112bb3c32cSDevesh Sharma return (wqe_mode == BNXT_QPLIB_WQE_MODE_STATIC) ?
6122bb3c32cSDevesh Sharma sizeof(struct sq_send) / sizeof(struct sq_sge) : 1;
6132bb3c32cSDevesh Sharma }
6142bb3c32cSDevesh Sharma
bnxt_qplib_set_rq_max_slot(u32 wqe_size)6152bb3c32cSDevesh Sharma static inline u32 bnxt_qplib_set_rq_max_slot(u32 wqe_size)
6162bb3c32cSDevesh Sharma {
6172bb3c32cSDevesh Sharma return (wqe_size / sizeof(struct sq_sge));
6182bb3c32cSDevesh Sharma }
6192bb3c32cSDevesh Sharma
__xlate_qfd(u16 delta,u16 wqe_bytes)6202bb3c32cSDevesh Sharma static inline u16 __xlate_qfd(u16 delta, u16 wqe_bytes)
6212bb3c32cSDevesh Sharma {
6222bb3c32cSDevesh Sharma /* For Cu/Wh delta = 128, stride = 16, wqe_bytes = 128
6232bb3c32cSDevesh Sharma * For Gen-p5 B/C mode delta = 0, stride = 16, wqe_bytes = 128.
6242bb3c32cSDevesh Sharma * For Gen-p5 delta = 0, stride = 16, 32 <= wqe_bytes <= 512.
6252bb3c32cSDevesh Sharma * when 8916 is disabled.
6262bb3c32cSDevesh Sharma */
6272bb3c32cSDevesh Sharma return (delta * wqe_bytes) / sizeof(struct sq_sge);
6282bb3c32cSDevesh Sharma }
6292bb3c32cSDevesh Sharma
bnxt_qplib_calc_ilsize(struct bnxt_qplib_swqe * wqe,u16 max)6302bb3c32cSDevesh Sharma static inline u16 bnxt_qplib_calc_ilsize(struct bnxt_qplib_swqe *wqe, u16 max)
6312bb3c32cSDevesh Sharma {
6322bb3c32cSDevesh Sharma u16 size = 0;
6332bb3c32cSDevesh Sharma int indx;
6342bb3c32cSDevesh Sharma
6352bb3c32cSDevesh Sharma for (indx = 0; indx < wqe->num_sge; indx++)
6362bb3c32cSDevesh Sharma size += wqe->sg_list[indx].size;
6372bb3c32cSDevesh Sharma if (size > max)
6382bb3c32cSDevesh Sharma size = max;
6392bb3c32cSDevesh Sharma
6402bb3c32cSDevesh Sharma return size;
6412bb3c32cSDevesh Sharma }
64207f830aeSSelvin Xavier
64307f830aeSSelvin Xavier /* MSN table update inlin */
bnxt_re_update_msn_tbl(u32 st_idx,u32 npsn,u32 start_psn)64482a8903aSSelvin Xavier static inline __le64 bnxt_re_update_msn_tbl(u32 st_idx, u32 npsn, u32 start_psn)
64507f830aeSSelvin Xavier {
64607f830aeSSelvin Xavier return cpu_to_le64((((u64)(st_idx) << SQ_MSN_SEARCH_START_IDX_SFT) &
64707f830aeSSelvin Xavier SQ_MSN_SEARCH_START_IDX_MASK) |
64807f830aeSSelvin Xavier (((u64)(npsn) << SQ_MSN_SEARCH_NEXT_PSN_SFT) &
64907f830aeSSelvin Xavier SQ_MSN_SEARCH_NEXT_PSN_MASK) |
65007f830aeSSelvin Xavier (((start_psn) << SQ_MSN_SEARCH_START_PSN_SFT) &
65107f830aeSSelvin Xavier SQ_MSN_SEARCH_START_PSN_MASK));
65207f830aeSSelvin Xavier }
65351edebb7SSelvin Xavier
__is_var_wqe(struct bnxt_qplib_qp * qp)65451edebb7SSelvin Xavier static inline bool __is_var_wqe(struct bnxt_qplib_qp *qp)
65551edebb7SSelvin Xavier {
65651edebb7SSelvin Xavier return (qp->wqe_mode == BNXT_QPLIB_WQE_MODE_VARIABLE);
65751edebb7SSelvin Xavier }
65851edebb7SSelvin Xavier
__is_err_cqe_for_var_wqe(struct bnxt_qplib_qp * qp,u8 status)65951edebb7SSelvin Xavier static inline bool __is_err_cqe_for_var_wqe(struct bnxt_qplib_qp *qp, u8 status)
66051edebb7SSelvin Xavier {
66151edebb7SSelvin Xavier return (status != CQ_REQ_STATUS_OK) && __is_var_wqe(qp);
66251edebb7SSelvin Xavier }
6631ac5a404SSelvin Xavier #endif /* __BNXT_QPLIB_FP_H__ */
664