xref: /linux/drivers/infiniband/hw/bnxt_re/qplib_fp.h (revision d54bd5abf4d26e1b6722238f75e36069ea91def9)
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 */
10837cb11acSDevesh Sharma };
10937cb11acSDevesh Sharma 
1101ac5a404SSelvin Xavier struct bnxt_qplib_sge {
1111ac5a404SSelvin Xavier 	u64				addr;
1121ac5a404SSelvin Xavier 	u32				lkey;
1131ac5a404SSelvin Xavier 	u32				size;
1141ac5a404SSelvin Xavier };
1151ac5a404SSelvin Xavier 
1161ac5a404SSelvin Xavier #define BNXT_QPLIB_QP_MAX_SGL	6
1171ac5a404SSelvin Xavier struct bnxt_qplib_swq {
1181ac5a404SSelvin Xavier 	u64				wr_id;
11937cb11acSDevesh Sharma 	int				next_idx;
1201ac5a404SSelvin Xavier 	u8				type;
1211ac5a404SSelvin Xavier 	u8				flags;
1221ac5a404SSelvin Xavier 	u32				start_psn;
1231ac5a404SSelvin Xavier 	u32				next_psn;
1242bb3c32cSDevesh Sharma 	u32				slot_idx;
125159fb4ceSDevesh Sharma 	u8				slots;
1261ac5a404SSelvin Xavier 	struct sq_psn_search		*psn_search;
12737f91cffSDevesh Sharma 	struct sq_psn_search_ext	*psn_ext;
1281ac5a404SSelvin Xavier };
1291ac5a404SSelvin Xavier 
1301ac5a404SSelvin Xavier struct bnxt_qplib_swqe {
1311ac5a404SSelvin Xavier 	/* General */
1329152e0b7SEddie Wai #define	BNXT_QPLIB_FENCE_WRID	0x46454E43	/* "FENC" */
1331ac5a404SSelvin Xavier 	u64				wr_id;
1341ac5a404SSelvin Xavier 	u8				reqs_type;
1351ac5a404SSelvin Xavier 	u8				type;
1361ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_TYPE_SEND			0
1371ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_TYPE_SEND_WITH_IMM		1
1381ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_TYPE_SEND_WITH_INV		2
1391ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_TYPE_RDMA_WRITE			4
1401ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_TYPE_RDMA_WRITE_WITH_IMM	5
1411ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_TYPE_RDMA_READ			6
1421ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_TYPE_ATOMIC_CMP_AND_SWP		8
1431ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_TYPE_ATOMIC_FETCH_AND_ADD	11
1441ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_TYPE_LOCAL_INV			12
1451ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_TYPE_FAST_REG_MR		13
1461ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_TYPE_REG_MR			13
1471ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_TYPE_BIND_MW			14
1481ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_TYPE_RECV			128
1491ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_TYPE_RECV_RDMA_IMM		129
1501ac5a404SSelvin Xavier 	u8				flags;
1511ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_FLAGS_SIGNAL_COMP		BIT(0)
1521ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_FLAGS_RD_ATOMIC_FENCE		BIT(1)
1531ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_FLAGS_UC_FENCE			BIT(2)
1541ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_FLAGS_SOLICIT_EVENT		BIT(3)
1551ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_FLAGS_INLINE			BIT(4)
1561ac5a404SSelvin Xavier 	struct bnxt_qplib_sge		sg_list[BNXT_QPLIB_QP_MAX_SGL];
1571ac5a404SSelvin Xavier 	int				num_sge;
1581ac5a404SSelvin Xavier 	/* Max inline data is 96 bytes */
1591ac5a404SSelvin Xavier 	u32				inline_len;
1601ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_MAX_INLINE_LENGTH		96
1611ac5a404SSelvin Xavier 	u8		inline_data[BNXT_QPLIB_SWQE_MAX_INLINE_LENGTH];
1621ac5a404SSelvin Xavier 
1631ac5a404SSelvin Xavier 	union {
1641ac5a404SSelvin Xavier 		/* Send, with imm, inval key */
1651ac5a404SSelvin Xavier 		struct {
1661ac5a404SSelvin Xavier 			union {
1671ac5a404SSelvin Xavier 				__be32	imm_data;
1681ac5a404SSelvin Xavier 				u32	inv_key;
1691ac5a404SSelvin Xavier 			};
1701ac5a404SSelvin Xavier 			u32		q_key;
1711ac5a404SSelvin Xavier 			u32		dst_qp;
1721ac5a404SSelvin Xavier 			u16		avid;
1731ac5a404SSelvin Xavier 		} send;
1741ac5a404SSelvin Xavier 
1751ac5a404SSelvin Xavier 		/* Send Raw Ethernet and QP1 */
1761ac5a404SSelvin Xavier 		struct {
1771ac5a404SSelvin Xavier 			u16		lflags;
1781ac5a404SSelvin Xavier 			u16		cfa_action;
1791ac5a404SSelvin Xavier 			u32		cfa_meta;
1801ac5a404SSelvin Xavier 		} rawqp1;
1811ac5a404SSelvin Xavier 
1821ac5a404SSelvin Xavier 		/* RDMA write, with imm, read */
1831ac5a404SSelvin Xavier 		struct {
1841ac5a404SSelvin Xavier 			union {
1851ac5a404SSelvin Xavier 				__be32	imm_data;
1861ac5a404SSelvin Xavier 				u32	inv_key;
1871ac5a404SSelvin Xavier 			};
1881ac5a404SSelvin Xavier 			u64		remote_va;
1891ac5a404SSelvin Xavier 			u32		r_key;
1901ac5a404SSelvin Xavier 		} rdma;
1911ac5a404SSelvin Xavier 
1921ac5a404SSelvin Xavier 		/* Atomic cmp/swap, fetch/add */
1931ac5a404SSelvin Xavier 		struct {
1941ac5a404SSelvin Xavier 			u64		remote_va;
1951ac5a404SSelvin Xavier 			u32		r_key;
1961ac5a404SSelvin Xavier 			u64		swap_data;
1971ac5a404SSelvin Xavier 			u64		cmp_data;
1981ac5a404SSelvin Xavier 		} atomic;
1991ac5a404SSelvin Xavier 
2001ac5a404SSelvin Xavier 		/* Local Invalidate */
2011ac5a404SSelvin Xavier 		struct {
2021ac5a404SSelvin Xavier 			u32		inv_l_key;
2031ac5a404SSelvin Xavier 		} local_inv;
2041ac5a404SSelvin Xavier 
2051ac5a404SSelvin Xavier 		/* FR-PMR */
2061ac5a404SSelvin Xavier 		struct {
2071ac5a404SSelvin Xavier 			u8		access_cntl;
2081ac5a404SSelvin Xavier 			u8		pg_sz_log;
2091ac5a404SSelvin Xavier 			bool		zero_based;
2101ac5a404SSelvin Xavier 			u32		l_key;
2111ac5a404SSelvin Xavier 			u32		length;
2121ac5a404SSelvin Xavier 			u8		pbl_pg_sz_log;
2131ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_PAGE_SIZE_4K			0
2141ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_PAGE_SIZE_8K			1
2151ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_PAGE_SIZE_64K			4
2161ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_PAGE_SIZE_256K			6
2171ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_PAGE_SIZE_1M			8
2181ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_PAGE_SIZE_2M			9
2191ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_PAGE_SIZE_4M			10
2201ac5a404SSelvin Xavier #define BNXT_QPLIB_SWQE_PAGE_SIZE_1G			18
2211ac5a404SSelvin Xavier 			u8		levels;
2221ac5a404SSelvin Xavier #define PAGE_SHIFT_4K	12
2231ac5a404SSelvin Xavier 			__le64		*pbl_ptr;
2241ac5a404SSelvin Xavier 			dma_addr_t	pbl_dma_ptr;
2251ac5a404SSelvin Xavier 			u64		*page_list;
2261ac5a404SSelvin Xavier 			u16		page_list_len;
2271ac5a404SSelvin Xavier 			u64		va;
2281ac5a404SSelvin Xavier 		} frmr;
2291ac5a404SSelvin Xavier 
2301ac5a404SSelvin Xavier 		/* Bind */
2311ac5a404SSelvin Xavier 		struct {
2321ac5a404SSelvin Xavier 			u8		access_cntl;
2331ac5a404SSelvin Xavier #define BNXT_QPLIB_BIND_SWQE_ACCESS_LOCAL_WRITE		BIT(0)
2341ac5a404SSelvin Xavier #define BNXT_QPLIB_BIND_SWQE_ACCESS_REMOTE_READ		BIT(1)
2351ac5a404SSelvin Xavier #define BNXT_QPLIB_BIND_SWQE_ACCESS_REMOTE_WRITE	BIT(2)
2361ac5a404SSelvin Xavier #define BNXT_QPLIB_BIND_SWQE_ACCESS_REMOTE_ATOMIC	BIT(3)
2371ac5a404SSelvin Xavier #define BNXT_QPLIB_BIND_SWQE_ACCESS_WINDOW_BIND		BIT(4)
2381ac5a404SSelvin Xavier 			bool		zero_based;
2391ac5a404SSelvin Xavier 			u8		mw_type;
2401ac5a404SSelvin Xavier 			u32		parent_l_key;
2411ac5a404SSelvin Xavier 			u32		r_key;
2421ac5a404SSelvin Xavier 			u64		va;
2431ac5a404SSelvin Xavier 			u32		length;
2441ac5a404SSelvin Xavier 		} bind;
2451ac5a404SSelvin Xavier 	};
2461ac5a404SSelvin Xavier };
2471ac5a404SSelvin Xavier 
2481ac5a404SSelvin Xavier struct bnxt_qplib_q {
2491ac5a404SSelvin Xavier 	struct bnxt_qplib_hwq		hwq;
2501ac5a404SSelvin Xavier 	struct bnxt_qplib_swq		*swq;
2516f53196bSDevesh Sharma 	struct bnxt_qplib_db_info	dbinfo;
2525aa84840SSelvin Xavier 	struct bnxt_qplib_sg_info	sg_info;
2531ac5a404SSelvin Xavier 	u32				max_wqe;
254fddcbbb0SDevesh Sharma 	u16				wqe_size;
2559152e0b7SEddie Wai 	u16				q_full_delta;
2561ac5a404SSelvin Xavier 	u16				max_sge;
2571ac5a404SSelvin Xavier 	u32				psn;
2589152e0b7SEddie Wai 	bool				condition;
2599152e0b7SEddie Wai 	bool				single;
2609152e0b7SEddie Wai 	bool				send_phantom;
2619152e0b7SEddie Wai 	u32				phantom_wqe_cnt;
2629152e0b7SEddie Wai 	u32				phantom_cqe_cnt;
2639152e0b7SEddie Wai 	u32				next_cq_cons;
264f218d67eSSelvin Xavier 	bool				flushed;
265159fb4ceSDevesh Sharma 	u32				swq_start;
266159fb4ceSDevesh Sharma 	u32				swq_last;
2671ac5a404SSelvin Xavier };
2681ac5a404SSelvin Xavier 
2691ac5a404SSelvin Xavier struct bnxt_qplib_qp {
2701ac5a404SSelvin Xavier 	struct bnxt_qplib_pd		*pd;
2711ac5a404SSelvin Xavier 	struct bnxt_qplib_dpi		*dpi;
27237f91cffSDevesh Sharma 	struct bnxt_qplib_chip_ctx	*cctx;
2731ac5a404SSelvin Xavier 	u64				qp_handle;
274f218d67eSSelvin Xavier #define BNXT_QPLIB_QP_ID_INVALID        0xFFFFFFFF
2751ac5a404SSelvin Xavier 	u32				id;
2761ac5a404SSelvin Xavier 	u8				type;
2771ac5a404SSelvin Xavier 	u8				sig_type;
2781da968e0SDevesh Sharma 	u8				wqe_mode;
2791ac5a404SSelvin Xavier 	u8				state;
2801ac5a404SSelvin Xavier 	u8				cur_qp_state;
2811da968e0SDevesh Sharma 	u64				modify_flags;
2821ac5a404SSelvin Xavier 	u32				max_inline_data;
2831ac5a404SSelvin Xavier 	u32				mtu;
2841ac5a404SSelvin Xavier 	u8				path_mtu;
2851ac5a404SSelvin Xavier 	bool				en_sqd_async_notify;
2861ac5a404SSelvin Xavier 	u16				pkey_index;
2871ac5a404SSelvin Xavier 	u32				qkey;
2881ac5a404SSelvin Xavier 	u32				dest_qp_id;
2891ac5a404SSelvin Xavier 	u8				access;
2901ac5a404SSelvin Xavier 	u8				timeout;
2911ac5a404SSelvin Xavier 	u8				retry_cnt;
2921ac5a404SSelvin Xavier 	u8				rnr_retry;
2933fb755b3SSomnath Kotur 	u64				wqe_cnt;
2941ac5a404SSelvin Xavier 	u32				min_rnr_timer;
2951ac5a404SSelvin Xavier 	u32				max_rd_atomic;
2961ac5a404SSelvin Xavier 	u32				max_dest_rd_atomic;
2971ac5a404SSelvin Xavier 	u32				dest_qpn;
2981ac5a404SSelvin Xavier 	u8				smac[6];
2991ac5a404SSelvin Xavier 	u16				vlan_id;
3001ac5a404SSelvin Xavier 	u8				nw_type;
3011ac5a404SSelvin Xavier 	struct bnxt_qplib_ah		ah;
3021ac5a404SSelvin Xavier 
3031ac5a404SSelvin Xavier #define BTH_PSN_MASK			((1 << 24) - 1)
3041ac5a404SSelvin Xavier 	/* SQ */
3051ac5a404SSelvin Xavier 	struct bnxt_qplib_q		sq;
3061ac5a404SSelvin Xavier 	/* RQ */
3071ac5a404SSelvin Xavier 	struct bnxt_qplib_q		rq;
3081ac5a404SSelvin Xavier 	/* SRQ */
3091ac5a404SSelvin Xavier 	struct bnxt_qplib_srq		*srq;
3101ac5a404SSelvin Xavier 	/* CQ */
3111ac5a404SSelvin Xavier 	struct bnxt_qplib_cq		*scq;
3121ac5a404SSelvin Xavier 	struct bnxt_qplib_cq		*rcq;
3131ac5a404SSelvin Xavier 	/* IRRQ and ORRQ */
3141ac5a404SSelvin Xavier 	struct bnxt_qplib_hwq		irrq;
3151ac5a404SSelvin Xavier 	struct bnxt_qplib_hwq		orrq;
3161ac5a404SSelvin Xavier 	/* Header buffer for QP1 */
3171ac5a404SSelvin Xavier 	int				sq_hdr_buf_size;
3181ac5a404SSelvin Xavier 	int				rq_hdr_buf_size;
3191ac5a404SSelvin Xavier /*
3201ac5a404SSelvin Xavier  * Buffer space for ETH(14), IP or GRH(40), UDP header(8)
3211ac5a404SSelvin Xavier  * and ib_bth + ib_deth (20).
3221ac5a404SSelvin Xavier  * Max required is 82 when RoCE V2 is enabled
3231ac5a404SSelvin Xavier  */
3241ac5a404SSelvin Xavier #define BNXT_QPLIB_MAX_QP1_SQ_HDR_SIZE_V2	86
3251ac5a404SSelvin Xavier 	/* Ethernet header	=  14 */
3261ac5a404SSelvin Xavier 	/* ib_grh		=  40 (provided by MAD) */
3271ac5a404SSelvin Xavier 	/* ib_bth + ib_deth	=  20 */
3281ac5a404SSelvin Xavier 	/* MAD			= 256 (provided by MAD) */
3291ac5a404SSelvin Xavier 	/* iCRC			=   4 */
3301ac5a404SSelvin Xavier #define BNXT_QPLIB_MAX_QP1_RQ_ETH_HDR_SIZE	14
3311ac5a404SSelvin Xavier #define BNXT_QPLIB_MAX_QP1_RQ_HDR_SIZE_V2	512
3321ac5a404SSelvin Xavier #define BNXT_QPLIB_MAX_GRH_HDR_SIZE_IPV4	20
3331ac5a404SSelvin Xavier #define BNXT_QPLIB_MAX_GRH_HDR_SIZE_IPV6	40
3341ac5a404SSelvin Xavier #define BNXT_QPLIB_MAX_QP1_RQ_BDETH_HDR_SIZE	20
3351ac5a404SSelvin Xavier 	void				*sq_hdr_buf;
3361ac5a404SSelvin Xavier 	dma_addr_t			sq_hdr_buf_map;
3371ac5a404SSelvin Xavier 	void				*rq_hdr_buf;
3381ac5a404SSelvin Xavier 	dma_addr_t			rq_hdr_buf_map;
339f218d67eSSelvin Xavier 	struct list_head		sq_flush;
340f218d67eSSelvin Xavier 	struct list_head		rq_flush;
3411ac5a404SSelvin Xavier };
3421ac5a404SSelvin Xavier 
3431ac5a404SSelvin Xavier #define BNXT_QPLIB_MAX_CQE_ENTRY_SIZE	sizeof(struct cq_base)
3441ac5a404SSelvin Xavier 
3451ac5a404SSelvin Xavier #define CQE_CNT_PER_PG		(PAGE_SIZE / BNXT_QPLIB_MAX_CQE_ENTRY_SIZE)
3461ac5a404SSelvin Xavier #define CQE_MAX_IDX_PER_PG	(CQE_CNT_PER_PG - 1)
3471ac5a404SSelvin Xavier #define CQE_PG(x)		(((x) & ~CQE_MAX_IDX_PER_PG) / CQE_CNT_PER_PG)
3481ac5a404SSelvin Xavier #define CQE_IDX(x)		((x) & CQE_MAX_IDX_PER_PG)
3491ac5a404SSelvin Xavier 
3501ac5a404SSelvin Xavier #define ROCE_CQE_CMP_V			0
3511ac5a404SSelvin Xavier #define CQE_CMP_VALID(hdr, raw_cons, cp_bit)			\
3521ac5a404SSelvin Xavier 	(!!((hdr)->cqe_type_toggle & CQ_BASE_TOGGLE) ==		\
3531ac5a404SSelvin Xavier 	   !((raw_cons) & (cp_bit)))
3541ac5a404SSelvin Xavier 
3552bb3c32cSDevesh Sharma static inline bool bnxt_qplib_queue_full(struct bnxt_qplib_q *que,
3562bb3c32cSDevesh Sharma 					 u8 slots)
3579152e0b7SEddie Wai {
3582bb3c32cSDevesh Sharma 	struct bnxt_qplib_hwq *hwq;
3592bb3c32cSDevesh Sharma 	int avail;
3602bb3c32cSDevesh Sharma 
3612bb3c32cSDevesh Sharma 	hwq = &que->hwq;
3622bb3c32cSDevesh Sharma 	/* False full is possible, retrying post-send makes sense */
3632bb3c32cSDevesh Sharma 	avail = hwq->cons - hwq->prod;
3642bb3c32cSDevesh Sharma 	if (hwq->cons <= hwq->prod)
3652bb3c32cSDevesh Sharma 		avail += hwq->depth;
3662bb3c32cSDevesh Sharma 	return avail <= slots;
3679152e0b7SEddie Wai }
3689152e0b7SEddie Wai 
3691ac5a404SSelvin Xavier struct bnxt_qplib_cqe {
3701ac5a404SSelvin Xavier 	u8				status;
3711ac5a404SSelvin Xavier 	u8				type;
3721ac5a404SSelvin Xavier 	u8				opcode;
3731ac5a404SSelvin Xavier 	u32				length;
374374c5285SDevesh Sharma 	u16				cfa_meta;
3751ac5a404SSelvin Xavier 	u64				wr_id;
3761ac5a404SSelvin Xavier 	union {
3771ac5a404SSelvin Xavier 		__be32			immdata;
3781ac5a404SSelvin Xavier 		u32			invrkey;
3791ac5a404SSelvin Xavier 	};
3801ac5a404SSelvin Xavier 	u64				qp_handle;
3811ac5a404SSelvin Xavier 	u64				mr_handle;
3821ac5a404SSelvin Xavier 	u16				flags;
3831ac5a404SSelvin Xavier 	u8				smac[6];
3841ac5a404SSelvin Xavier 	u32				src_qp;
3851ac5a404SSelvin Xavier 	u16				raweth_qp1_flags;
3861ac5a404SSelvin Xavier 	u16				raweth_qp1_errors;
3871ac5a404SSelvin Xavier 	u16				raweth_qp1_cfa_code;
3881ac5a404SSelvin Xavier 	u32				raweth_qp1_flags2;
3891ac5a404SSelvin Xavier 	u32				raweth_qp1_metadata;
3901ac5a404SSelvin Xavier 	u8				raweth_qp1_payload_offset;
3911ac5a404SSelvin Xavier 	u16				pkey_index;
3921ac5a404SSelvin Xavier };
3931ac5a404SSelvin Xavier 
3941ac5a404SSelvin Xavier #define BNXT_QPLIB_QUEUE_START_PERIOD		0x01
3951ac5a404SSelvin Xavier struct bnxt_qplib_cq {
3961ac5a404SSelvin Xavier 	struct bnxt_qplib_dpi		*dpi;
3976f53196bSDevesh Sharma 	struct bnxt_qplib_db_info	dbinfo;
3981ac5a404SSelvin Xavier 	u32				max_wqe;
3991ac5a404SSelvin Xavier 	u32				id;
4001ac5a404SSelvin Xavier 	u16				count;
4011ac5a404SSelvin Xavier 	u16				period;
4021ac5a404SSelvin Xavier 	struct bnxt_qplib_hwq		hwq;
403*d54bd5abSSelvin Xavier 	struct bnxt_qplib_hwq		resize_hwq;
4041ac5a404SSelvin Xavier 	u32				cnq_hw_ring_id;
405f218d67eSSelvin Xavier 	struct bnxt_qplib_nq		*nq;
4061ac5a404SSelvin Xavier 	bool				resize_in_progress;
4075aa84840SSelvin Xavier 	struct bnxt_qplib_sg_info	sg_info;
4081ac5a404SSelvin Xavier 	u64				cq_handle;
4091ac5a404SSelvin Xavier 
4101ac5a404SSelvin Xavier #define CQ_RESIZE_WAIT_TIME_MS		500
4111ac5a404SSelvin Xavier 	unsigned long			flags;
4121ac5a404SSelvin Xavier #define CQ_FLAGS_RESIZE_IN_PROG		1
4131ac5a404SSelvin Xavier 	wait_queue_head_t		waitq;
414f218d67eSSelvin Xavier 	struct list_head		sqf_head, rqf_head;
415f218d67eSSelvin Xavier 	atomic_t			arm_state;
416f218d67eSSelvin Xavier 	spinlock_t			compl_lock; /* synch CQ handlers */
417942c9b6cSSelvin Xavier /* Locking Notes:
418942c9b6cSSelvin Xavier  * QP can move to error state from modify_qp, async error event or error
419942c9b6cSSelvin Xavier  * CQE as part of poll_cq. When QP is moved to error state, it gets added
420942c9b6cSSelvin Xavier  * to two flush lists, one each for SQ and RQ.
421942c9b6cSSelvin Xavier  * Each flush list is protected by qplib_cq->flush_lock. Both scq and rcq
422942c9b6cSSelvin Xavier  * flush_locks should be acquired when QP is moved to error. The control path
423942c9b6cSSelvin Xavier  * operations(modify_qp and async error events) are synchronized with poll_cq
424942c9b6cSSelvin Xavier  * using upper level CQ locks (bnxt_re_cq->cq_lock) of both SCQ and RCQ.
425942c9b6cSSelvin Xavier  * The qplib_cq->flush_lock is required to synchronize two instances of poll_cq
426942c9b6cSSelvin Xavier  * of the same QP while manipulating the flush list.
427942c9b6cSSelvin Xavier  */
428942c9b6cSSelvin Xavier 	spinlock_t			flush_lock; /* QP flush management */
429b1d56fdcSSelvin Xavier 	u16				cnq_events;
4301ac5a404SSelvin Xavier };
4311ac5a404SSelvin Xavier 
4321ac5a404SSelvin Xavier #define BNXT_QPLIB_MAX_IRRQE_ENTRY_SIZE	sizeof(struct xrrq_irrq)
4331ac5a404SSelvin Xavier #define BNXT_QPLIB_MAX_ORRQE_ENTRY_SIZE	sizeof(struct xrrq_orrq)
4341ac5a404SSelvin Xavier #define IRD_LIMIT_TO_IRRQ_SLOTS(x)	(2 * (x) + 2)
4351ac5a404SSelvin Xavier #define IRRQ_SLOTS_TO_IRD_LIMIT(s)	(((s) >> 1) - 1)
4361ac5a404SSelvin Xavier #define ORD_LIMIT_TO_ORRQ_SLOTS(x)	((x) + 1)
4371ac5a404SSelvin Xavier #define ORRQ_SLOTS_TO_ORD_LIMIT(s)	((s) - 1)
4381ac5a404SSelvin Xavier 
4391ac5a404SSelvin Xavier #define BNXT_QPLIB_MAX_NQE_ENTRY_SIZE	sizeof(struct nq_base)
4401ac5a404SSelvin Xavier 
4411ac5a404SSelvin Xavier #define NQE_CNT_PER_PG		(PAGE_SIZE / BNXT_QPLIB_MAX_NQE_ENTRY_SIZE)
4421ac5a404SSelvin Xavier #define NQE_MAX_IDX_PER_PG	(NQE_CNT_PER_PG - 1)
4431ac5a404SSelvin Xavier #define NQE_PG(x)		(((x) & ~NQE_MAX_IDX_PER_PG) / NQE_CNT_PER_PG)
4441ac5a404SSelvin Xavier #define NQE_IDX(x)		((x) & NQE_MAX_IDX_PER_PG)
4451ac5a404SSelvin Xavier 
4461ac5a404SSelvin Xavier #define NQE_CMP_VALID(hdr, raw_cons, cp_bit)			\
4471ac5a404SSelvin Xavier 	(!!(le32_to_cpu((hdr)->info63_v[0]) & NQ_BASE_V) ==	\
4481ac5a404SSelvin Xavier 	   !((raw_cons) & (cp_bit)))
4491ac5a404SSelvin Xavier 
4501ac5a404SSelvin Xavier #define BNXT_QPLIB_NQE_MAX_CNT		(128 * 1024)
4511ac5a404SSelvin Xavier 
4521ac5a404SSelvin Xavier #define NQ_CONS_PCI_BAR_REGION		2
4531ac5a404SSelvin Xavier #define NQ_DB_KEY_CP			(0x2 << CMPL_DOORBELL_KEY_SFT)
4541ac5a404SSelvin Xavier #define NQ_DB_IDX_VALID			CMPL_DOORBELL_IDX_VALID
4551ac5a404SSelvin Xavier #define NQ_DB_IRQ_DIS			CMPL_DOORBELL_MASK
4561ac5a404SSelvin Xavier #define NQ_DB_CP_FLAGS_REARM		(NQ_DB_KEY_CP |		\
4571ac5a404SSelvin Xavier 					 NQ_DB_IDX_VALID)
4581ac5a404SSelvin Xavier #define NQ_DB_CP_FLAGS			(NQ_DB_KEY_CP    |	\
4591ac5a404SSelvin Xavier 					 NQ_DB_IDX_VALID |	\
4601ac5a404SSelvin Xavier 					 NQ_DB_IRQ_DIS)
461b353ce55SDevesh Sharma 
4629555352bSDevesh Sharma struct bnxt_qplib_nq_db {
4639555352bSDevesh Sharma 	struct bnxt_qplib_reg_desc	reg;
4646f53196bSDevesh Sharma 	struct bnxt_qplib_db_info	dbinfo;
4659555352bSDevesh Sharma };
4669555352bSDevesh Sharma 
4679555352bSDevesh Sharma typedef int (*cqn_handler_t)(struct bnxt_qplib_nq *nq,
4689555352bSDevesh Sharma 		struct bnxt_qplib_cq *cq);
4699555352bSDevesh Sharma typedef int (*srqn_handler_t)(struct bnxt_qplib_nq *nq,
4709555352bSDevesh Sharma 		struct bnxt_qplib_srq *srq, u8 event);
4719555352bSDevesh Sharma 
4721ac5a404SSelvin Xavier struct bnxt_qplib_nq {
4731ac5a404SSelvin Xavier 	struct pci_dev			*pdev;
474ae8637e1SDevesh Sharma 	struct bnxt_qplib_res		*res;
4756a5df91bSSelvin Xavier 	char				name[32];
4769555352bSDevesh Sharma 	struct bnxt_qplib_hwq		hwq;
4779555352bSDevesh Sharma 	struct bnxt_qplib_nq_db		nq_db;
4789555352bSDevesh Sharma 	u16				ring_id;
4799555352bSDevesh Sharma 	int				msix_vec;
4809555352bSDevesh Sharma 	cpumask_t			mask;
4819555352bSDevesh Sharma 	struct tasklet_struct		nq_tasklet;
4829555352bSDevesh Sharma 	bool				requested;
4839555352bSDevesh Sharma 	int				budget;
4849555352bSDevesh Sharma 
4859555352bSDevesh Sharma 	cqn_handler_t			cqn_handler;
4869555352bSDevesh Sharma 	srqn_handler_t			srqn_handler;
4879555352bSDevesh Sharma 	struct workqueue_struct		*cqn_wq;
488f218d67eSSelvin Xavier };
489f218d67eSSelvin Xavier 
490f218d67eSSelvin Xavier struct bnxt_qplib_nq_work {
491f218d67eSSelvin Xavier 	struct work_struct      work;
492f218d67eSSelvin Xavier 	struct bnxt_qplib_nq    *nq;
493f218d67eSSelvin Xavier 	struct bnxt_qplib_cq    *cq;
4941ac5a404SSelvin Xavier };
4951ac5a404SSelvin Xavier 
4966e04b103SDevesh Sharma void bnxt_qplib_nq_stop_irq(struct bnxt_qplib_nq *nq, bool kill);
4971ac5a404SSelvin Xavier void bnxt_qplib_disable_nq(struct bnxt_qplib_nq *nq);
4986e04b103SDevesh Sharma int bnxt_qplib_nq_start_irq(struct bnxt_qplib_nq *nq, int nq_indx,
4996e04b103SDevesh Sharma 			    int msix_vector, bool need_init);
5001ac5a404SSelvin Xavier int bnxt_qplib_enable_nq(struct pci_dev *pdev, struct bnxt_qplib_nq *nq,
5016a5df91bSSelvin Xavier 			 int nq_idx, int msix_vector, int bar_reg_offset,
5029555352bSDevesh Sharma 			 cqn_handler_t cqn_handler,
5039555352bSDevesh Sharma 			 srqn_handler_t srq_handler);
50437cb11acSDevesh Sharma int bnxt_qplib_create_srq(struct bnxt_qplib_res *res,
50537cb11acSDevesh Sharma 			  struct bnxt_qplib_srq *srq);
50637cb11acSDevesh Sharma int bnxt_qplib_modify_srq(struct bnxt_qplib_res *res,
50737cb11acSDevesh Sharma 			  struct bnxt_qplib_srq *srq);
50837cb11acSDevesh Sharma int bnxt_qplib_query_srq(struct bnxt_qplib_res *res,
50937cb11acSDevesh Sharma 			 struct bnxt_qplib_srq *srq);
51068e326deSLeon Romanovsky void bnxt_qplib_destroy_srq(struct bnxt_qplib_res *res,
51137cb11acSDevesh Sharma 			    struct bnxt_qplib_srq *srq);
51237cb11acSDevesh Sharma int bnxt_qplib_post_srq_recv(struct bnxt_qplib_srq *srq,
51337cb11acSDevesh Sharma 			     struct bnxt_qplib_swqe *wqe);
5141ac5a404SSelvin Xavier int bnxt_qplib_create_qp1(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp);
5151ac5a404SSelvin Xavier int bnxt_qplib_create_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp);
5161ac5a404SSelvin Xavier int bnxt_qplib_modify_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp);
5171ac5a404SSelvin Xavier int bnxt_qplib_query_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp);
5181ac5a404SSelvin Xavier int bnxt_qplib_destroy_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp);
5193b921e3bSSelvin Xavier void bnxt_qplib_clean_qp(struct bnxt_qplib_qp *qp);
5203b921e3bSSelvin Xavier void bnxt_qplib_free_qp_res(struct bnxt_qplib_res *res,
5213b921e3bSSelvin Xavier 			    struct bnxt_qplib_qp *qp);
5221ac5a404SSelvin Xavier void *bnxt_qplib_get_qp1_sq_buf(struct bnxt_qplib_qp *qp,
5231ac5a404SSelvin Xavier 				struct bnxt_qplib_sge *sge);
5241ac5a404SSelvin Xavier void *bnxt_qplib_get_qp1_rq_buf(struct bnxt_qplib_qp *qp,
5251ac5a404SSelvin Xavier 				struct bnxt_qplib_sge *sge);
5261ac5a404SSelvin Xavier u32 bnxt_qplib_get_rq_prod_index(struct bnxt_qplib_qp *qp);
5271ac5a404SSelvin Xavier dma_addr_t bnxt_qplib_get_qp_buf_from_index(struct bnxt_qplib_qp *qp,
5281ac5a404SSelvin Xavier 					    u32 index);
5291ac5a404SSelvin Xavier void bnxt_qplib_post_send_db(struct bnxt_qplib_qp *qp);
5301ac5a404SSelvin Xavier int bnxt_qplib_post_send(struct bnxt_qplib_qp *qp,
5311ac5a404SSelvin Xavier 			 struct bnxt_qplib_swqe *wqe);
5321ac5a404SSelvin Xavier void bnxt_qplib_post_recv_db(struct bnxt_qplib_qp *qp);
5331ac5a404SSelvin Xavier int bnxt_qplib_post_recv(struct bnxt_qplib_qp *qp,
5341ac5a404SSelvin Xavier 			 struct bnxt_qplib_swqe *wqe);
5351ac5a404SSelvin Xavier int bnxt_qplib_create_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq);
536*d54bd5abSSelvin Xavier int bnxt_qplib_resize_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq,
537*d54bd5abSSelvin Xavier 			 int new_cqes);
538*d54bd5abSSelvin Xavier void bnxt_qplib_resize_cq_complete(struct bnxt_qplib_res *res,
539*d54bd5abSSelvin Xavier 				   struct bnxt_qplib_cq *cq);
5401ac5a404SSelvin Xavier int bnxt_qplib_destroy_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq);
5411ac5a404SSelvin Xavier int bnxt_qplib_poll_cq(struct bnxt_qplib_cq *cq, struct bnxt_qplib_cqe *cqe,
5429152e0b7SEddie Wai 		       int num, struct bnxt_qplib_qp **qp);
543499e4569SSelvin Xavier bool bnxt_qplib_is_cq_empty(struct bnxt_qplib_cq *cq);
5441ac5a404SSelvin Xavier void bnxt_qplib_req_notify_cq(struct bnxt_qplib_cq *cq, u32 arm_type);
5451ac5a404SSelvin Xavier void bnxt_qplib_free_nq(struct bnxt_qplib_nq *nq);
5460c4dcd60SDevesh Sharma int bnxt_qplib_alloc_nq(struct bnxt_qplib_res *res, struct bnxt_qplib_nq *nq);
547f218d67eSSelvin Xavier void bnxt_qplib_add_flush_qp(struct bnxt_qplib_qp *qp);
548f218d67eSSelvin Xavier void bnxt_qplib_acquire_cq_locks(struct bnxt_qplib_qp *qp,
549f218d67eSSelvin Xavier 				 unsigned long *flags);
550f218d67eSSelvin Xavier void bnxt_qplib_release_cq_locks(struct bnxt_qplib_qp *qp,
551f218d67eSSelvin Xavier 				 unsigned long *flags);
552f218d67eSSelvin Xavier int bnxt_qplib_process_flush_list(struct bnxt_qplib_cq *cq,
553f218d67eSSelvin Xavier 				  struct bnxt_qplib_cqe *cqe,
554f218d67eSSelvin Xavier 				  int num_cqes);
555c88a7858SSelvin Xavier void bnxt_qplib_flush_cqn_wq(struct bnxt_qplib_qp *qp);
556159fb4ceSDevesh Sharma 
557159fb4ceSDevesh Sharma static inline void *bnxt_qplib_get_swqe(struct bnxt_qplib_q *que, u32 *swq_idx)
558159fb4ceSDevesh Sharma {
559159fb4ceSDevesh Sharma 	u32 idx;
560159fb4ceSDevesh Sharma 
561159fb4ceSDevesh Sharma 	idx = que->swq_start;
562159fb4ceSDevesh Sharma 	if (swq_idx)
563159fb4ceSDevesh Sharma 		*swq_idx = idx;
564159fb4ceSDevesh Sharma 	return &que->swq[idx];
565159fb4ceSDevesh Sharma }
566159fb4ceSDevesh Sharma 
567159fb4ceSDevesh Sharma static inline void bnxt_qplib_swq_mod_start(struct bnxt_qplib_q *que, u32 idx)
568159fb4ceSDevesh Sharma {
569159fb4ceSDevesh Sharma 	que->swq_start = que->swq[idx].next_idx;
570159fb4ceSDevesh Sharma }
571159fb4ceSDevesh Sharma 
5722bb3c32cSDevesh Sharma static inline u32 bnxt_qplib_get_depth(struct bnxt_qplib_q *que)
5732bb3c32cSDevesh Sharma {
5742bb3c32cSDevesh Sharma 	return (que->wqe_size * que->max_wqe) / sizeof(struct sq_sge);
5752bb3c32cSDevesh Sharma }
5762bb3c32cSDevesh Sharma 
5772bb3c32cSDevesh Sharma static inline u32 bnxt_qplib_set_sq_size(struct bnxt_qplib_q *que, u8 wqe_mode)
5782bb3c32cSDevesh Sharma {
5792bb3c32cSDevesh Sharma 	return (wqe_mode == BNXT_QPLIB_WQE_MODE_STATIC) ?
5802bb3c32cSDevesh Sharma 		que->max_wqe : bnxt_qplib_get_depth(que);
5812bb3c32cSDevesh Sharma }
5822bb3c32cSDevesh Sharma 
5832bb3c32cSDevesh Sharma static inline u32 bnxt_qplib_set_sq_max_slot(u8 wqe_mode)
5842bb3c32cSDevesh Sharma {
5852bb3c32cSDevesh Sharma 	return (wqe_mode == BNXT_QPLIB_WQE_MODE_STATIC) ?
5862bb3c32cSDevesh Sharma 		sizeof(struct sq_send) / sizeof(struct sq_sge) : 1;
5872bb3c32cSDevesh Sharma }
5882bb3c32cSDevesh Sharma 
5892bb3c32cSDevesh Sharma static inline u32 bnxt_qplib_set_rq_max_slot(u32 wqe_size)
5902bb3c32cSDevesh Sharma {
5912bb3c32cSDevesh Sharma 	return (wqe_size / sizeof(struct sq_sge));
5922bb3c32cSDevesh Sharma }
5932bb3c32cSDevesh Sharma 
5942bb3c32cSDevesh Sharma static inline u16 __xlate_qfd(u16 delta, u16 wqe_bytes)
5952bb3c32cSDevesh Sharma {
5962bb3c32cSDevesh Sharma 	/* For Cu/Wh delta = 128, stride = 16, wqe_bytes = 128
5972bb3c32cSDevesh Sharma 	 * For Gen-p5 B/C mode delta = 0, stride = 16, wqe_bytes = 128.
5982bb3c32cSDevesh Sharma 	 * For Gen-p5 delta = 0, stride = 16, 32 <= wqe_bytes <= 512.
5992bb3c32cSDevesh Sharma 	 * when 8916 is disabled.
6002bb3c32cSDevesh Sharma 	 */
6012bb3c32cSDevesh Sharma 	return (delta * wqe_bytes) / sizeof(struct sq_sge);
6022bb3c32cSDevesh Sharma }
6032bb3c32cSDevesh Sharma 
6042bb3c32cSDevesh Sharma static inline u16 bnxt_qplib_calc_ilsize(struct bnxt_qplib_swqe *wqe, u16 max)
6052bb3c32cSDevesh Sharma {
6062bb3c32cSDevesh Sharma 	u16 size = 0;
6072bb3c32cSDevesh Sharma 	int indx;
6082bb3c32cSDevesh Sharma 
6092bb3c32cSDevesh Sharma 	for (indx = 0; indx < wqe->num_sge; indx++)
6102bb3c32cSDevesh Sharma 		size += wqe->sg_list[indx].size;
6112bb3c32cSDevesh Sharma 	if (size > max)
6122bb3c32cSDevesh Sharma 		size = max;
6132bb3c32cSDevesh Sharma 
6142bb3c32cSDevesh Sharma 	return size;
6152bb3c32cSDevesh Sharma }
6161ac5a404SSelvin Xavier #endif /* __BNXT_QPLIB_FP_H__ */
617