xref: /openbmc/linux/drivers/net/ethernet/huawei/hinic/hinic_hw_wqe.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
12025cf9eSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
2b15a9f37SAviad Krawczyk /*
3b15a9f37SAviad Krawczyk  * Huawei HiNIC PCI Express Linux driver
4b15a9f37SAviad Krawczyk  * Copyright(c) 2017 Huawei Technologies Co., Ltd
5b15a9f37SAviad Krawczyk  */
6b15a9f37SAviad Krawczyk 
7b15a9f37SAviad Krawczyk #ifndef HINIC_HW_WQE_H
8b15a9f37SAviad Krawczyk #define HINIC_HW_WQE_H
9b15a9f37SAviad Krawczyk 
10b15a9f37SAviad Krawczyk #include "hinic_common.h"
11b15a9f37SAviad Krawczyk 
1276baca2eSAviad Krawczyk #define HINIC_CMDQ_CTRL_PI_SHIFT                        0
1376baca2eSAviad Krawczyk #define HINIC_CMDQ_CTRL_CMD_SHIFT                       16
1476baca2eSAviad Krawczyk #define HINIC_CMDQ_CTRL_MOD_SHIFT                       24
1576baca2eSAviad Krawczyk #define HINIC_CMDQ_CTRL_ACK_TYPE_SHIFT                  29
1676baca2eSAviad Krawczyk #define HINIC_CMDQ_CTRL_HW_BUSY_BIT_SHIFT               31
1776baca2eSAviad Krawczyk 
1876baca2eSAviad Krawczyk #define HINIC_CMDQ_CTRL_PI_MASK                         0xFFFF
1976baca2eSAviad Krawczyk #define HINIC_CMDQ_CTRL_CMD_MASK                        0xFF
2076baca2eSAviad Krawczyk #define HINIC_CMDQ_CTRL_MOD_MASK                        0x1F
2176baca2eSAviad Krawczyk #define HINIC_CMDQ_CTRL_ACK_TYPE_MASK                   0x3
2276baca2eSAviad Krawczyk #define HINIC_CMDQ_CTRL_HW_BUSY_BIT_MASK                0x1
2376baca2eSAviad Krawczyk 
2476baca2eSAviad Krawczyk #define HINIC_CMDQ_CTRL_SET(val, member)                        \
2576baca2eSAviad Krawczyk 			(((u32)(val) & HINIC_CMDQ_CTRL_##member##_MASK) \
2676baca2eSAviad Krawczyk 			 << HINIC_CMDQ_CTRL_##member##_SHIFT)
2776baca2eSAviad Krawczyk 
2876baca2eSAviad Krawczyk #define HINIC_CMDQ_CTRL_GET(val, member)                        \
2976baca2eSAviad Krawczyk 			(((val) >> HINIC_CMDQ_CTRL_##member##_SHIFT) \
3076baca2eSAviad Krawczyk 			 & HINIC_CMDQ_CTRL_##member##_MASK)
3176baca2eSAviad Krawczyk 
3276baca2eSAviad Krawczyk #define HINIC_CMDQ_WQE_HEADER_BUFDESC_LEN_SHIFT         0
3376baca2eSAviad Krawczyk #define HINIC_CMDQ_WQE_HEADER_COMPLETE_FMT_SHIFT        15
3476baca2eSAviad Krawczyk #define HINIC_CMDQ_WQE_HEADER_DATA_FMT_SHIFT            22
3576baca2eSAviad Krawczyk #define HINIC_CMDQ_WQE_HEADER_COMPLETE_REQ_SHIFT        23
3676baca2eSAviad Krawczyk #define HINIC_CMDQ_WQE_HEADER_COMPLETE_SECT_LEN_SHIFT   27
3776baca2eSAviad Krawczyk #define HINIC_CMDQ_WQE_HEADER_CTRL_LEN_SHIFT            29
3876baca2eSAviad Krawczyk #define HINIC_CMDQ_WQE_HEADER_TOGGLED_WRAPPED_SHIFT     31
3976baca2eSAviad Krawczyk 
4076baca2eSAviad Krawczyk #define HINIC_CMDQ_WQE_HEADER_BUFDESC_LEN_MASK          0xFF
4176baca2eSAviad Krawczyk #define HINIC_CMDQ_WQE_HEADER_COMPLETE_FMT_MASK         0x1
4276baca2eSAviad Krawczyk #define HINIC_CMDQ_WQE_HEADER_DATA_FMT_MASK             0x1
4376baca2eSAviad Krawczyk #define HINIC_CMDQ_WQE_HEADER_COMPLETE_REQ_MASK         0x1
4476baca2eSAviad Krawczyk #define HINIC_CMDQ_WQE_HEADER_COMPLETE_SECT_LEN_MASK    0x3
4576baca2eSAviad Krawczyk #define HINIC_CMDQ_WQE_HEADER_CTRL_LEN_MASK             0x3
4676baca2eSAviad Krawczyk #define HINIC_CMDQ_WQE_HEADER_TOGGLED_WRAPPED_MASK      0x1
4776baca2eSAviad Krawczyk 
4876baca2eSAviad Krawczyk #define HINIC_CMDQ_WQE_HEADER_SET(val, member)                  \
4976baca2eSAviad Krawczyk 			(((u32)(val) & HINIC_CMDQ_WQE_HEADER_##member##_MASK) \
5076baca2eSAviad Krawczyk 			 << HINIC_CMDQ_WQE_HEADER_##member##_SHIFT)
5176baca2eSAviad Krawczyk 
5276baca2eSAviad Krawczyk #define HINIC_CMDQ_WQE_HEADER_GET(val, member)                  \
5376baca2eSAviad Krawczyk 			(((val) >> HINIC_CMDQ_WQE_HEADER_##member##_SHIFT) \
5476baca2eSAviad Krawczyk 			 & HINIC_CMDQ_WQE_HEADER_##member##_MASK)
5576baca2eSAviad Krawczyk 
56b15a9f37SAviad Krawczyk #define HINIC_SQ_CTRL_BUFDESC_SECT_LEN_SHIFT           0
57b15a9f37SAviad Krawczyk #define HINIC_SQ_CTRL_TASKSECT_LEN_SHIFT               16
58b15a9f37SAviad Krawczyk #define HINIC_SQ_CTRL_DATA_FORMAT_SHIFT                22
59b15a9f37SAviad Krawczyk #define HINIC_SQ_CTRL_LEN_SHIFT                        29
60b15a9f37SAviad Krawczyk 
61b15a9f37SAviad Krawczyk #define HINIC_SQ_CTRL_BUFDESC_SECT_LEN_MASK            0xFF
62b15a9f37SAviad Krawczyk #define HINIC_SQ_CTRL_TASKSECT_LEN_MASK                0x1F
63b15a9f37SAviad Krawczyk #define HINIC_SQ_CTRL_DATA_FORMAT_MASK                 0x1
64b15a9f37SAviad Krawczyk #define HINIC_SQ_CTRL_LEN_MASK                         0x3
65b15a9f37SAviad Krawczyk 
66cc18a754SZhao Chen #define HINIC_SQ_CTRL_QUEUE_INFO_PLDOFF_SHIFT          2
67cc18a754SZhao Chen #define HINIC_SQ_CTRL_QUEUE_INFO_UFO_SHIFT             10
68cc18a754SZhao Chen #define HINIC_SQ_CTRL_QUEUE_INFO_TSO_SHIFT             11
69cc18a754SZhao Chen #define HINIC_SQ_CTRL_QUEUE_INFO_TCPUDP_CS_SHIFT       12
70b15a9f37SAviad Krawczyk #define HINIC_SQ_CTRL_QUEUE_INFO_MSS_SHIFT             13
71cc18a754SZhao Chen #define HINIC_SQ_CTRL_QUEUE_INFO_SCTP_SHIFT            27
72cc18a754SZhao Chen #define HINIC_SQ_CTRL_QUEUE_INFO_UC_SHIFT              28
73cc18a754SZhao Chen #define HINIC_SQ_CTRL_QUEUE_INFO_PRI_SHIFT             29
74b15a9f37SAviad Krawczyk 
75cc18a754SZhao Chen #define HINIC_SQ_CTRL_QUEUE_INFO_PLDOFF_MASK           0xFF
76cc18a754SZhao Chen #define HINIC_SQ_CTRL_QUEUE_INFO_UFO_MASK              0x1
77cc18a754SZhao Chen #define HINIC_SQ_CTRL_QUEUE_INFO_TSO_MASK              0x1
78cc18a754SZhao Chen #define HINIC_SQ_CTRL_QUEUE_INFO_TCPUDP_CS_MASK	       0x1
79b15a9f37SAviad Krawczyk #define HINIC_SQ_CTRL_QUEUE_INFO_MSS_MASK              0x3FFF
80cc18a754SZhao Chen #define HINIC_SQ_CTRL_QUEUE_INFO_SCTP_MASK             0x1
81cc18a754SZhao Chen #define HINIC_SQ_CTRL_QUEUE_INFO_UC_MASK               0x1
82cc18a754SZhao Chen #define HINIC_SQ_CTRL_QUEUE_INFO_PRI_MASK              0x7
83b15a9f37SAviad Krawczyk 
84b15a9f37SAviad Krawczyk #define HINIC_SQ_CTRL_SET(val, member)          \
85b15a9f37SAviad Krawczyk 		(((u32)(val) & HINIC_SQ_CTRL_##member##_MASK) \
86b15a9f37SAviad Krawczyk 		 << HINIC_SQ_CTRL_##member##_SHIFT)
87b15a9f37SAviad Krawczyk 
88b15a9f37SAviad Krawczyk #define HINIC_SQ_CTRL_GET(val, member)          \
89b15a9f37SAviad Krawczyk 		(((val) >> HINIC_SQ_CTRL_##member##_SHIFT) \
90b15a9f37SAviad Krawczyk 		 & HINIC_SQ_CTRL_##member##_MASK)
91b15a9f37SAviad Krawczyk 
92cc18a754SZhao Chen #define HINIC_SQ_CTRL_CLEAR(val, member)	\
93cc18a754SZhao Chen 		((u32)(val) & (~(HINIC_SQ_CTRL_##member##_MASK \
94cc18a754SZhao Chen 		 << HINIC_SQ_CTRL_##member##_SHIFT)))
95cc18a754SZhao Chen 
96b15a9f37SAviad Krawczyk #define HINIC_SQ_TASK_INFO0_L2HDR_LEN_SHIFT     0
97b15a9f37SAviad Krawczyk #define HINIC_SQ_TASK_INFO0_L4_OFFLOAD_SHIFT    8
98b15a9f37SAviad Krawczyk #define HINIC_SQ_TASK_INFO0_INNER_L3TYPE_SHIFT  10
99b15a9f37SAviad Krawczyk #define HINIC_SQ_TASK_INFO0_VLAN_OFFLOAD_SHIFT  12
100b15a9f37SAviad Krawczyk #define HINIC_SQ_TASK_INFO0_PARSE_FLAG_SHIFT    13
101b15a9f37SAviad Krawczyk /* 1 bit reserved */
102b15a9f37SAviad Krawczyk #define HINIC_SQ_TASK_INFO0_TSO_FLAG_SHIFT      15
103b15a9f37SAviad Krawczyk #define HINIC_SQ_TASK_INFO0_VLAN_TAG_SHIFT      16
104b15a9f37SAviad Krawczyk 
105b15a9f37SAviad Krawczyk #define HINIC_SQ_TASK_INFO0_L2HDR_LEN_MASK      0xFF
106b15a9f37SAviad Krawczyk #define HINIC_SQ_TASK_INFO0_L4_OFFLOAD_MASK     0x3
107b15a9f37SAviad Krawczyk #define HINIC_SQ_TASK_INFO0_INNER_L3TYPE_MASK   0x3
108b15a9f37SAviad Krawczyk #define HINIC_SQ_TASK_INFO0_VLAN_OFFLOAD_MASK   0x1
109b15a9f37SAviad Krawczyk #define HINIC_SQ_TASK_INFO0_PARSE_FLAG_MASK     0x1
110b15a9f37SAviad Krawczyk /* 1 bit reserved */
111b15a9f37SAviad Krawczyk #define HINIC_SQ_TASK_INFO0_TSO_FLAG_MASK       0x1
112b15a9f37SAviad Krawczyk #define HINIC_SQ_TASK_INFO0_VLAN_TAG_MASK       0xFFFF
113b15a9f37SAviad Krawczyk 
114b15a9f37SAviad Krawczyk #define HINIC_SQ_TASK_INFO0_SET(val, member)    \
115b15a9f37SAviad Krawczyk 		(((u32)(val) & HINIC_SQ_TASK_INFO0_##member##_MASK) <<  \
116b15a9f37SAviad Krawczyk 		 HINIC_SQ_TASK_INFO0_##member##_SHIFT)
117b15a9f37SAviad Krawczyk 
118b15a9f37SAviad Krawczyk /* 8 bits reserved */
119b15a9f37SAviad Krawczyk #define HINIC_SQ_TASK_INFO1_MEDIA_TYPE_SHIFT    8
120cc18a754SZhao Chen #define HINIC_SQ_TASK_INFO1_INNER_L4LEN_SHIFT   16
121cc18a754SZhao Chen #define HINIC_SQ_TASK_INFO1_INNER_L3LEN_SHIFT   24
122b15a9f37SAviad Krawczyk 
123b15a9f37SAviad Krawczyk /* 8 bits reserved */
124b15a9f37SAviad Krawczyk #define HINIC_SQ_TASK_INFO1_MEDIA_TYPE_MASK     0xFF
125cc18a754SZhao Chen #define HINIC_SQ_TASK_INFO1_INNER_L4LEN_MASK    0xFF
126cc18a754SZhao Chen #define HINIC_SQ_TASK_INFO1_INNER_L3LEN_MASK    0xFF
127b15a9f37SAviad Krawczyk 
128b15a9f37SAviad Krawczyk #define HINIC_SQ_TASK_INFO1_SET(val, member)    \
129b15a9f37SAviad Krawczyk 		(((u32)(val) & HINIC_SQ_TASK_INFO1_##member##_MASK) <<  \
130b15a9f37SAviad Krawczyk 		 HINIC_SQ_TASK_INFO1_##member##_SHIFT)
131b15a9f37SAviad Krawczyk 
132cc18a754SZhao Chen #define HINIC_SQ_TASK_INFO2_TUNNEL_L4LEN_SHIFT  0
133cc18a754SZhao Chen #define HINIC_SQ_TASK_INFO2_OUTER_L3LEN_SHIFT   8
134cc18a754SZhao Chen #define HINIC_SQ_TASK_INFO2_TUNNEL_L4TYPE_SHIFT 16
135b15a9f37SAviad Krawczyk /* 1 bit reserved */
136cc18a754SZhao Chen #define HINIC_SQ_TASK_INFO2_OUTER_L3TYPE_SHIFT  24
137b15a9f37SAviad Krawczyk /* 8 bits reserved */
138b15a9f37SAviad Krawczyk 
139cc18a754SZhao Chen #define HINIC_SQ_TASK_INFO2_TUNNEL_L4LEN_MASK   0xFF
140cc18a754SZhao Chen #define HINIC_SQ_TASK_INFO2_OUTER_L3LEN_MASK    0xFF
141cc18a754SZhao Chen #define HINIC_SQ_TASK_INFO2_TUNNEL_L4TYPE_MASK  0x7
142b15a9f37SAviad Krawczyk /* 1 bit reserved */
143b15a9f37SAviad Krawczyk #define HINIC_SQ_TASK_INFO2_OUTER_L3TYPE_MASK   0x3
144b15a9f37SAviad Krawczyk /* 8 bits reserved */
145b15a9f37SAviad Krawczyk 
146b15a9f37SAviad Krawczyk #define HINIC_SQ_TASK_INFO2_SET(val, member)    \
147b15a9f37SAviad Krawczyk 		(((u32)(val) & HINIC_SQ_TASK_INFO2_##member##_MASK) <<  \
148b15a9f37SAviad Krawczyk 		 HINIC_SQ_TASK_INFO2_##member##_SHIFT)
149b15a9f37SAviad Krawczyk 
150b15a9f37SAviad Krawczyk /* 31 bits reserved */
151b15a9f37SAviad Krawczyk #define HINIC_SQ_TASK_INFO4_L2TYPE_SHIFT        31
152b15a9f37SAviad Krawczyk 
153b15a9f37SAviad Krawczyk /* 31 bits reserved */
154b15a9f37SAviad Krawczyk #define HINIC_SQ_TASK_INFO4_L2TYPE_MASK         0x1
155b15a9f37SAviad Krawczyk 
156b15a9f37SAviad Krawczyk #define HINIC_SQ_TASK_INFO4_SET(val, member)    \
157b15a9f37SAviad Krawczyk 		(((u32)(val) & HINIC_SQ_TASK_INFO4_##member##_MASK) << \
158b15a9f37SAviad Krawczyk 		 HINIC_SQ_TASK_INFO4_##member##_SHIFT)
159b15a9f37SAviad Krawczyk 
160b15a9f37SAviad Krawczyk #define HINIC_RQ_CQE_STATUS_RXDONE_SHIFT        31
161b15a9f37SAviad Krawczyk 
162b15a9f37SAviad Krawczyk #define HINIC_RQ_CQE_STATUS_RXDONE_MASK         0x1
163b15a9f37SAviad Krawczyk 
1644a61abb1SXue Chaojing #define HINIC_RQ_CQE_STATUS_CSUM_ERR_SHIFT	0
1654a61abb1SXue Chaojing 
1664a61abb1SXue Chaojing #define HINIC_RQ_CQE_STATUS_CSUM_ERR_MASK	0xFFFFU
1674a61abb1SXue Chaojing 
168b15a9f37SAviad Krawczyk #define HINIC_RQ_CQE_STATUS_GET(val, member)    \
169b15a9f37SAviad Krawczyk 		(((val) >> HINIC_RQ_CQE_STATUS_##member##_SHIFT) & \
170b15a9f37SAviad Krawczyk 		 HINIC_RQ_CQE_STATUS_##member##_MASK)
171b15a9f37SAviad Krawczyk 
172b15a9f37SAviad Krawczyk #define HINIC_RQ_CQE_STATUS_CLEAR(val, member)  \
173b15a9f37SAviad Krawczyk 		((val) & (~(HINIC_RQ_CQE_STATUS_##member##_MASK << \
174b15a9f37SAviad Krawczyk 		 HINIC_RQ_CQE_STATUS_##member##_SHIFT)))
175b15a9f37SAviad Krawczyk 
176b15a9f37SAviad Krawczyk #define HINIC_RQ_CQE_SGE_LEN_SHIFT              16
177b15a9f37SAviad Krawczyk 
178b15a9f37SAviad Krawczyk #define HINIC_RQ_CQE_SGE_LEN_MASK               0xFFFF
179b15a9f37SAviad Krawczyk 
180b15a9f37SAviad Krawczyk #define HINIC_RQ_CQE_SGE_GET(val, member)       \
181b15a9f37SAviad Krawczyk 		(((val) >> HINIC_RQ_CQE_SGE_##member##_SHIFT) & \
182b15a9f37SAviad Krawczyk 		 HINIC_RQ_CQE_SGE_##member##_MASK)
183b15a9f37SAviad Krawczyk 
184b15a9f37SAviad Krawczyk #define HINIC_RQ_CTRL_BUFDESC_SECT_LEN_SHIFT    0
185b15a9f37SAviad Krawczyk #define HINIC_RQ_CTRL_COMPLETE_FORMAT_SHIFT     15
186b15a9f37SAviad Krawczyk #define HINIC_RQ_CTRL_COMPLETE_LEN_SHIFT        27
187b15a9f37SAviad Krawczyk #define HINIC_RQ_CTRL_LEN_SHIFT                 29
188b15a9f37SAviad Krawczyk 
189b15a9f37SAviad Krawczyk #define HINIC_RQ_CTRL_BUFDESC_SECT_LEN_MASK     0xFF
190b15a9f37SAviad Krawczyk #define HINIC_RQ_CTRL_COMPLETE_FORMAT_MASK      0x1
191b15a9f37SAviad Krawczyk #define HINIC_RQ_CTRL_COMPLETE_LEN_MASK         0x3
192b15a9f37SAviad Krawczyk #define HINIC_RQ_CTRL_LEN_MASK                  0x3
193b15a9f37SAviad Krawczyk 
194b15a9f37SAviad Krawczyk #define HINIC_RQ_CTRL_SET(val, member)          \
195b15a9f37SAviad Krawczyk 		(((u32)(val) & HINIC_RQ_CTRL_##member##_MASK) << \
196b15a9f37SAviad Krawczyk 		 HINIC_RQ_CTRL_##member##_SHIFT)
197b15a9f37SAviad Krawczyk 
198b15a9f37SAviad Krawczyk #define HINIC_SQ_WQE_SIZE(nr_sges)              \
199b15a9f37SAviad Krawczyk 		(sizeof(struct hinic_sq_ctrl) + \
200b15a9f37SAviad Krawczyk 		 sizeof(struct hinic_sq_task) + \
201b15a9f37SAviad Krawczyk 		 (nr_sges) * sizeof(struct hinic_sq_bufdesc))
202b15a9f37SAviad Krawczyk 
20376baca2eSAviad Krawczyk #define HINIC_SCMD_DATA_LEN                     16
20476baca2eSAviad Krawczyk 
205b15a9f37SAviad Krawczyk #define HINIC_MAX_SQ_BUFDESCS                   17
206b15a9f37SAviad Krawczyk 
207b15a9f37SAviad Krawczyk #define HINIC_SQ_WQE_MAX_SIZE                   320
208b15a9f37SAviad Krawczyk #define HINIC_RQ_WQE_SIZE                       32
209b15a9f37SAviad Krawczyk 
210cc18a754SZhao Chen #define HINIC_MSS_DEFAULT		        0x3E00
211cc18a754SZhao Chen #define HINIC_MSS_MIN		                0x50
212cc18a754SZhao Chen 
2131e007181SXue Chaojing #define RQ_CQE_STATUS_NUM_LRO_SHIFT		16
2141e007181SXue Chaojing #define RQ_CQE_STATUS_NUM_LRO_MASK		0xFFU
2151e007181SXue Chaojing 
2161e007181SXue Chaojing #define RQ_CQE_STATUS_GET(val, member)		(((val) >> \
2171e007181SXue Chaojing 			RQ_CQE_STATUS_##member##_SHIFT) & \
2181e007181SXue Chaojing 			RQ_CQE_STATUS_##member##_MASK)
2191e007181SXue Chaojing 
2201e007181SXue Chaojing #define HINIC_GET_RX_NUM_LRO(status)	\
2211e007181SXue Chaojing 		RQ_CQE_STATUS_GET(status, NUM_LRO)
2221e007181SXue Chaojing 
2231e007181SXue Chaojing #define RQ_CQE_OFFOLAD_TYPE_PKT_TYPE_SHIFT		0
2241e007181SXue Chaojing #define RQ_CQE_OFFOLAD_TYPE_PKT_TYPE_MASK		0xFFFU
225*aebd17b7SXue Chaojing #define RQ_CQE_OFFOLAD_TYPE_VLAN_EN_SHIFT		21
226*aebd17b7SXue Chaojing #define RQ_CQE_OFFOLAD_TYPE_VLAN_EN_MASK		0x1U
2271e007181SXue Chaojing 
2281e007181SXue Chaojing #define RQ_CQE_OFFOLAD_TYPE_GET(val, member)		(((val) >> \
2291e007181SXue Chaojing 				RQ_CQE_OFFOLAD_TYPE_##member##_SHIFT) & \
2301e007181SXue Chaojing 				RQ_CQE_OFFOLAD_TYPE_##member##_MASK)
2311e007181SXue Chaojing 
2321e007181SXue Chaojing #define HINIC_GET_RX_PKT_TYPE(offload_type)	\
2331e007181SXue Chaojing 			RQ_CQE_OFFOLAD_TYPE_GET(offload_type, PKT_TYPE)
2341e007181SXue Chaojing 
235*aebd17b7SXue Chaojing #define HINIC_GET_RX_VLAN_OFFLOAD_EN(offload_type)	\
236*aebd17b7SXue Chaojing 			RQ_CQE_OFFOLAD_TYPE_GET(offload_type, VLAN_EN)
237*aebd17b7SXue Chaojing 
238*aebd17b7SXue Chaojing #define RQ_CQE_SGE_VLAN_MASK				0xFFFFU
239*aebd17b7SXue Chaojing #define RQ_CQE_SGE_VLAN_SHIFT				0
240*aebd17b7SXue Chaojing 
241*aebd17b7SXue Chaojing #define RQ_CQE_SGE_GET(val, member)			(((val) >> \
242*aebd17b7SXue Chaojing 					RQ_CQE_SGE_##member##_SHIFT) & \
243*aebd17b7SXue Chaojing 					RQ_CQE_SGE_##member##_MASK)
244*aebd17b7SXue Chaojing 
245*aebd17b7SXue Chaojing #define HINIC_GET_RX_VLAN_TAG(vlan_len)	\
246*aebd17b7SXue Chaojing 		RQ_CQE_SGE_GET(vlan_len, VLAN)
247*aebd17b7SXue Chaojing 
248421e9526SXue Chaojing #define HINIC_RSS_TYPE_VALID_SHIFT			23
249421e9526SXue Chaojing #define HINIC_RSS_TYPE_TCP_IPV6_EXT_SHIFT		24
250421e9526SXue Chaojing #define HINIC_RSS_TYPE_IPV6_EXT_SHIFT			25
251421e9526SXue Chaojing #define HINIC_RSS_TYPE_TCP_IPV6_SHIFT			26
252421e9526SXue Chaojing #define HINIC_RSS_TYPE_IPV6_SHIFT			27
253421e9526SXue Chaojing #define HINIC_RSS_TYPE_TCP_IPV4_SHIFT			28
254421e9526SXue Chaojing #define HINIC_RSS_TYPE_IPV4_SHIFT			29
255421e9526SXue Chaojing #define HINIC_RSS_TYPE_UDP_IPV6_SHIFT			30
256421e9526SXue Chaojing #define HINIC_RSS_TYPE_UDP_IPV4_SHIFT			31
257421e9526SXue Chaojing 
258421e9526SXue Chaojing #define HINIC_RSS_TYPE_SET(val, member)                        \
259421e9526SXue Chaojing 		(((u32)(val) & 0x1) << HINIC_RSS_TYPE_##member##_SHIFT)
260421e9526SXue Chaojing 
261421e9526SXue Chaojing #define HINIC_RSS_TYPE_GET(val, member)                        \
262421e9526SXue Chaojing 		(((u32)(val) >> HINIC_RSS_TYPE_##member##_SHIFT) & 0x1)
263421e9526SXue Chaojing 
264cc18a754SZhao Chen enum hinic_l3_offload_type {
265cc18a754SZhao Chen 	L3TYPE_UNKNOWN = 0,
266cc18a754SZhao Chen 	IPV6_PKT = 1,
267cc18a754SZhao Chen 	IPV4_PKT_NO_CHKSUM_OFFLOAD = 2,
268cc18a754SZhao Chen 	IPV4_PKT_WITH_CHKSUM_OFFLOAD = 3,
269cc18a754SZhao Chen };
270cc18a754SZhao Chen 
271cc18a754SZhao Chen enum hinic_l4_offload_type {
272cc18a754SZhao Chen 	OFFLOAD_DISABLE     = 0,
273cc18a754SZhao Chen 	TCP_OFFLOAD_ENABLE  = 1,
274cc18a754SZhao Chen 	SCTP_OFFLOAD_ENABLE = 2,
275cc18a754SZhao Chen 	UDP_OFFLOAD_ENABLE  = 3,
276cc18a754SZhao Chen };
277cc18a754SZhao Chen 
278cc18a754SZhao Chen enum hinic_l4_tunnel_type {
279cc18a754SZhao Chen 	NOT_TUNNEL,
280cc18a754SZhao Chen 	TUNNEL_UDP_NO_CSUM,
281cc18a754SZhao Chen 	TUNNEL_UDP_CSUM,
282cc18a754SZhao Chen };
283cc18a754SZhao Chen 
284b15a9f37SAviad Krawczyk enum hinic_outer_l3type {
285b15a9f37SAviad Krawczyk 	HINIC_OUTER_L3TYPE_UNKNOWN              = 0,
286b15a9f37SAviad Krawczyk 	HINIC_OUTER_L3TYPE_IPV6                 = 1,
287b15a9f37SAviad Krawczyk 	HINIC_OUTER_L3TYPE_IPV4_NO_CHKSUM       = 2,
288b15a9f37SAviad Krawczyk 	HINIC_OUTER_L3TYPE_IPV4_CHKSUM          = 3,
289b15a9f37SAviad Krawczyk };
290b15a9f37SAviad Krawczyk 
291b15a9f37SAviad Krawczyk enum hinic_l2type {
292b15a9f37SAviad Krawczyk 	HINIC_L2TYPE_ETH = 0,
293b15a9f37SAviad Krawczyk };
294b15a9f37SAviad Krawczyk 
29576baca2eSAviad Krawczyk struct hinic_cmdq_header {
29676baca2eSAviad Krawczyk 	u32     header_info;
29776baca2eSAviad Krawczyk 	u32     saved_data;
29876baca2eSAviad Krawczyk };
29976baca2eSAviad Krawczyk 
30076baca2eSAviad Krawczyk struct hinic_status {
30176baca2eSAviad Krawczyk 	u32 status_info;
30276baca2eSAviad Krawczyk };
30376baca2eSAviad Krawczyk 
30476baca2eSAviad Krawczyk struct hinic_ctrl {
30576baca2eSAviad Krawczyk 	u32 ctrl_info;
30676baca2eSAviad Krawczyk };
30776baca2eSAviad Krawczyk 
30876baca2eSAviad Krawczyk struct hinic_sge_resp {
30976baca2eSAviad Krawczyk 	struct hinic_sge        sge;
31076baca2eSAviad Krawczyk 	u32                     rsvd;
31176baca2eSAviad Krawczyk };
31276baca2eSAviad Krawczyk 
31376baca2eSAviad Krawczyk struct hinic_cmdq_completion {
31476baca2eSAviad Krawczyk 	/* HW Format */
31576baca2eSAviad Krawczyk 	union {
31676baca2eSAviad Krawczyk 		struct hinic_sge_resp   sge_resp;
31776baca2eSAviad Krawczyk 		u64                     direct_resp;
31876baca2eSAviad Krawczyk 	};
31976baca2eSAviad Krawczyk };
32076baca2eSAviad Krawczyk 
32176baca2eSAviad Krawczyk struct hinic_scmd_bufdesc {
32276baca2eSAviad Krawczyk 	u32     buf_len;
32376baca2eSAviad Krawczyk 	u32     rsvd;
32476baca2eSAviad Krawczyk 	u8      data[HINIC_SCMD_DATA_LEN];
32576baca2eSAviad Krawczyk };
32676baca2eSAviad Krawczyk 
32776baca2eSAviad Krawczyk struct hinic_lcmd_bufdesc {
32876baca2eSAviad Krawczyk 	struct hinic_sge        sge;
32976baca2eSAviad Krawczyk 	u32                     rsvd1;
33076baca2eSAviad Krawczyk 	u64                     rsvd2;
33176baca2eSAviad Krawczyk 	u64                     rsvd3;
33276baca2eSAviad Krawczyk };
33376baca2eSAviad Krawczyk 
33476baca2eSAviad Krawczyk struct hinic_cmdq_wqe_scmd {
33576baca2eSAviad Krawczyk 	struct hinic_cmdq_header        header;
33676baca2eSAviad Krawczyk 	u64                             rsvd;
33776baca2eSAviad Krawczyk 	struct hinic_status             status;
33876baca2eSAviad Krawczyk 	struct hinic_ctrl               ctrl;
33976baca2eSAviad Krawczyk 	struct hinic_cmdq_completion    completion;
34076baca2eSAviad Krawczyk 	struct hinic_scmd_bufdesc       buf_desc;
34176baca2eSAviad Krawczyk };
34276baca2eSAviad Krawczyk 
34376baca2eSAviad Krawczyk struct hinic_cmdq_wqe_lcmd {
34476baca2eSAviad Krawczyk 	struct hinic_cmdq_header        header;
34576baca2eSAviad Krawczyk 	struct hinic_status             status;
34676baca2eSAviad Krawczyk 	struct hinic_ctrl               ctrl;
34776baca2eSAviad Krawczyk 	struct hinic_cmdq_completion    completion;
34876baca2eSAviad Krawczyk 	struct hinic_lcmd_bufdesc       buf_desc;
34976baca2eSAviad Krawczyk };
35076baca2eSAviad Krawczyk 
35176baca2eSAviad Krawczyk struct hinic_cmdq_direct_wqe {
35276baca2eSAviad Krawczyk 	struct hinic_cmdq_wqe_scmd      wqe_scmd;
35376baca2eSAviad Krawczyk };
35476baca2eSAviad Krawczyk 
35576baca2eSAviad Krawczyk struct hinic_cmdq_wqe {
35676baca2eSAviad Krawczyk 	/* HW Format */
35776baca2eSAviad Krawczyk 	union {
35876baca2eSAviad Krawczyk 		struct hinic_cmdq_direct_wqe    direct_wqe;
35976baca2eSAviad Krawczyk 		struct hinic_cmdq_wqe_lcmd      wqe_lcmd;
36076baca2eSAviad Krawczyk 	};
36176baca2eSAviad Krawczyk };
36276baca2eSAviad Krawczyk 
363b15a9f37SAviad Krawczyk struct hinic_sq_ctrl {
364b15a9f37SAviad Krawczyk 	u32     ctrl_info;
365b15a9f37SAviad Krawczyk 	u32     queue_info;
366b15a9f37SAviad Krawczyk };
367b15a9f37SAviad Krawczyk 
368b15a9f37SAviad Krawczyk struct hinic_sq_task {
369b15a9f37SAviad Krawczyk 	u32     pkt_info0;
370b15a9f37SAviad Krawczyk 	u32     pkt_info1;
371b15a9f37SAviad Krawczyk 	u32     pkt_info2;
372b15a9f37SAviad Krawczyk 	u32     ufo_v6_identify;
373b15a9f37SAviad Krawczyk 	u32     pkt_info4;
374b15a9f37SAviad Krawczyk 	u32     zero_pad;
375b15a9f37SAviad Krawczyk };
376b15a9f37SAviad Krawczyk 
377b15a9f37SAviad Krawczyk struct hinic_sq_bufdesc {
378b15a9f37SAviad Krawczyk 	struct hinic_sge sge;
379b15a9f37SAviad Krawczyk 	u32     rsvd;
380b15a9f37SAviad Krawczyk };
381b15a9f37SAviad Krawczyk 
382b15a9f37SAviad Krawczyk struct hinic_sq_wqe {
383b15a9f37SAviad Krawczyk 	struct hinic_sq_ctrl            ctrl;
384b15a9f37SAviad Krawczyk 	struct hinic_sq_task            task;
385b15a9f37SAviad Krawczyk 	struct hinic_sq_bufdesc         buf_descs[HINIC_MAX_SQ_BUFDESCS];
386b15a9f37SAviad Krawczyk };
387b15a9f37SAviad Krawczyk 
388b15a9f37SAviad Krawczyk struct hinic_rq_cqe {
389b15a9f37SAviad Krawczyk 	u32     status;
390b15a9f37SAviad Krawczyk 	u32     len;
391b15a9f37SAviad Krawczyk 
3921e007181SXue Chaojing 	u32     offload_type;
393b15a9f37SAviad Krawczyk 	u32     rsvd3;
394b15a9f37SAviad Krawczyk 	u32     rsvd4;
395b15a9f37SAviad Krawczyk 	u32     rsvd5;
396b15a9f37SAviad Krawczyk 	u32     rsvd6;
397b15a9f37SAviad Krawczyk 	u32     rsvd7;
398b15a9f37SAviad Krawczyk };
399b15a9f37SAviad Krawczyk 
400b15a9f37SAviad Krawczyk struct hinic_rq_ctrl {
401b15a9f37SAviad Krawczyk 	u32     ctrl_info;
402b15a9f37SAviad Krawczyk };
403b15a9f37SAviad Krawczyk 
404b15a9f37SAviad Krawczyk struct hinic_rq_cqe_sect {
405b15a9f37SAviad Krawczyk 	struct hinic_sge        sge;
406b15a9f37SAviad Krawczyk 	u32                     rsvd;
407b15a9f37SAviad Krawczyk };
408b15a9f37SAviad Krawczyk 
409b15a9f37SAviad Krawczyk struct hinic_rq_bufdesc {
410b15a9f37SAviad Krawczyk 	u32     hi_addr;
411b15a9f37SAviad Krawczyk 	u32     lo_addr;
412b15a9f37SAviad Krawczyk };
413b15a9f37SAviad Krawczyk 
414b15a9f37SAviad Krawczyk struct hinic_rq_wqe {
415b15a9f37SAviad Krawczyk 	struct hinic_rq_ctrl            ctrl;
416b15a9f37SAviad Krawczyk 	u32                             rsvd;
417b15a9f37SAviad Krawczyk 	struct hinic_rq_cqe_sect        cqe_sect;
418b15a9f37SAviad Krawczyk 	struct hinic_rq_bufdesc         buf_desc;
419b15a9f37SAviad Krawczyk };
420b15a9f37SAviad Krawczyk 
421b15a9f37SAviad Krawczyk struct hinic_hw_wqe {
422b15a9f37SAviad Krawczyk 	/* HW Format */
423b15a9f37SAviad Krawczyk 	union {
42476baca2eSAviad Krawczyk 		struct hinic_cmdq_wqe   cmdq_wqe;
425b15a9f37SAviad Krawczyk 		struct hinic_sq_wqe     sq_wqe;
426b15a9f37SAviad Krawczyk 		struct hinic_rq_wqe     rq_wqe;
427b15a9f37SAviad Krawczyk 	};
428b15a9f37SAviad Krawczyk };
429b15a9f37SAviad Krawczyk 
430b15a9f37SAviad Krawczyk #endif
431