6dc969b0f8b0f2d1c3e024f364e9315e22cf49f3
[deb_dpdk.git] / drivers / net / qede / base / eth_common.h
1 /*
2  * Copyright (c) 2016 QLogic Corporation.
3  * All rights reserved.
4  * www.qlogic.com
5  *
6  * See LICENSE.qede_pmd for copyright and licensing details.
7  */
8
9 #ifndef __ETH_COMMON__
10 #define __ETH_COMMON__
11 /********************/
12 /* ETH FW CONSTANTS */
13 /********************/
14
15 /* FP HSI version. FP HSI is compatible if (fwVer.major == drvVer.major &&
16  * fwVer.minor >= drvVer.minor)
17  */
18 /* ETH FP HSI Major version */
19 #define ETH_HSI_VER_MAJOR                   3
20 /* ETH FP HSI Minor version */
21 #define ETH_HSI_VER_MINOR                   10
22
23 /* Alias for 8.7.x.x/8.8.x.x ETH FP HSI MINOR version. In this version driver
24  * is not required to set pkt_len field in eth_tx_1st_bd struct, and tunneling
25  * offload is not supported.
26  */
27 #define ETH_HSI_VER_NO_PKT_LEN_TUNN         5
28
29 #define ETH_CACHE_LINE_SIZE                 64
30 #define ETH_RX_CQE_GAP                      32
31 #define ETH_MAX_RAMROD_PER_CON              8
32 #define ETH_TX_BD_PAGE_SIZE_BYTES           4096
33 #define ETH_RX_BD_PAGE_SIZE_BYTES           4096
34 #define ETH_RX_CQE_PAGE_SIZE_BYTES          4096
35 #define ETH_RX_NUM_NEXT_PAGE_BDS            2
36
37 /* Limitation for Tunneled LSO Packets on the offset (in bytes) of the inner IP
38  * header (relevant to LSO for tunneled packet):
39  */
40 /* Offset is limited to 253 bytes (inclusive). */
41 #define ETH_MAX_TUNN_LSO_INNER_IPV4_OFFSET          253
42 /* Offset is limited to 251 bytes (inclusive). */
43 #define ETH_MAX_TUNN_LSO_INNER_IPV6_OFFSET          251
44
45 #define ETH_TX_MIN_BDS_PER_NON_LSO_PKT              1
46 #define ETH_TX_MAX_BDS_PER_NON_LSO_PACKET           18
47 #define ETH_TX_MAX_BDS_PER_LSO_PACKET               255
48 #define ETH_TX_MAX_LSO_HDR_NBD                      4
49 #define ETH_TX_MIN_BDS_PER_LSO_PKT                  3
50 #define ETH_TX_MIN_BDS_PER_TUNN_IPV6_WITH_EXT_PKT   3
51 #define ETH_TX_MIN_BDS_PER_IPV6_WITH_EXT_PKT        2
52 #define ETH_TX_MIN_BDS_PER_PKT_W_LOOPBACK_MODE      2
53 /* (QM_REG_TASKBYTECRDCOST_0, QM_VOQ_BYTE_CRD_TASK_COST) -
54  * (VLAN-TAG + CRC + IPG + PREAMBLE)
55  */
56 #define ETH_TX_MAX_NON_LSO_PKT_LEN                  (9700 - (4 + 4 + 12 + 8))
57 #define ETH_TX_MAX_LSO_HDR_BYTES                    510
58 /* Number of BDs to consider for LSO sliding window restriction is
59  * (ETH_TX_LSO_WINDOW_BDS_NUM - hdr_nbd)
60  */
61 #define ETH_TX_LSO_WINDOW_BDS_NUM                   (18 - 1)
62 /* Minimum data length (in bytes) in LSO sliding window */
63 #define ETH_TX_LSO_WINDOW_MIN_LEN                   9700
64 /* Maximum LSO packet TCP payload length (in bytes) */
65 #define ETH_TX_MAX_LSO_PAYLOAD_LEN                  0xFE000
66 /* Number of same-as-last resources in tx switching */
67 #define ETH_TX_NUM_SAME_AS_LAST_ENTRIES             320
68 /* Value for a connection for which same as last feature is disabled */
69 #define ETH_TX_INACTIVE_SAME_AS_LAST                0xFFFF
70
71 /* Maximum number of statistics counters */
72 #define ETH_NUM_STATISTIC_COUNTERS                  MAX_NUM_VPORTS
73 /* Maximum number of statistics counters when doubled VF zone used */
74 #define ETH_NUM_STATISTIC_COUNTERS_DOUBLE_VF_ZONE \
75         (ETH_NUM_STATISTIC_COUNTERS - MAX_NUM_VFS / 2)
76 /* Maximum number of statistics counters when quad VF zone used */
77 #define ETH_NUM_STATISTIC_COUNTERS_QUAD_VF_ZONE \
78         (ETH_NUM_STATISTIC_COUNTERS - 3 * MAX_NUM_VFS / 4)
79
80 /* Maximum number of buffers, used for RX packet placement */
81 #define ETH_RX_MAX_BUFF_PER_PKT             5
82
83 /* num of MAC/VLAN filters */
84 #define ETH_NUM_MAC_FILTERS                 512
85 #define ETH_NUM_VLAN_FILTERS                512
86
87 /* approx. multicast constants */
88 /* CRC seed for multicast bin calculation */
89 #define ETH_MULTICAST_BIN_FROM_MAC_SEED     0
90 #define ETH_MULTICAST_MAC_BINS              256
91 #define ETH_MULTICAST_MAC_BINS_IN_REGS      (ETH_MULTICAST_MAC_BINS / 32)
92
93 /*  ethernet vport update constants */
94 #define ETH_FILTER_RULES_COUNT              10
95 /* number of RSS indirection table entries, per Vport) */
96 #define ETH_RSS_IND_TABLE_ENTRIES_NUM       128
97 /* Length of RSS key (in regs) */
98 #define ETH_RSS_KEY_SIZE_REGS               10
99 /* number of available RSS engines in K2 */
100 #define ETH_RSS_ENGINE_NUM_K2               207
101 /* number of available RSS engines in BB */
102 #define ETH_RSS_ENGINE_NUM_BB               127
103
104 /* TPA constants */
105 /* Maximum number of open TPA aggregations */
106 #define ETH_TPA_MAX_AGGS_NUM              64
107 /* Maximum number of additional buffers, reported by TPA-start CQE */
108 #define ETH_TPA_CQE_START_LEN_LIST_SIZE   ETH_RX_MAX_BUFF_PER_PKT
109 /* Maximum number of buffers, reported by TPA-continue CQE */
110 #define ETH_TPA_CQE_CONT_LEN_LIST_SIZE    6
111 /* Maximum number of buffers, reported by TPA-end CQE */
112 #define ETH_TPA_CQE_END_LEN_LIST_SIZE     4
113
114 /* Control frame check constants */
115 /* Number of etherType values configured by driver for control frame check */
116 #define ETH_CTL_FRAME_ETH_TYPE_NUM              4
117
118
119
120 /*
121  * Destination port mode
122  */
123 enum dest_port_mode {
124         DEST_PORT_PHY /* Send to physical port. */,
125         DEST_PORT_LOOPBACK /* Send to loopback port. */,
126         DEST_PORT_PHY_LOOPBACK /* Send to physical and loopback port. */,
127         DEST_PORT_DROP /* Drop the packet in PBF. */,
128         MAX_DEST_PORT_MODE
129 };
130
131
132 /*
133  * Ethernet address type
134  */
135 enum eth_addr_type {
136         BROADCAST_ADDRESS,
137         MULTICAST_ADDRESS,
138         UNICAST_ADDRESS,
139         UNKNOWN_ADDRESS,
140         MAX_ETH_ADDR_TYPE
141 };
142
143
144 struct eth_tx_1st_bd_flags {
145         u8 bitfields;
146 /* Set to 1 in the first BD. (for debug) */
147 #define ETH_TX_1ST_BD_FLAGS_START_BD_MASK         0x1
148 #define ETH_TX_1ST_BD_FLAGS_START_BD_SHIFT        0
149 /* Do not allow additional VLAN manipulations on this packet. */
150 #define ETH_TX_1ST_BD_FLAGS_FORCE_VLAN_MODE_MASK  0x1
151 #define ETH_TX_1ST_BD_FLAGS_FORCE_VLAN_MODE_SHIFT 1
152 /* Recalculate IP checksum. For tunneled packet - relevant to inner header. */
153 #define ETH_TX_1ST_BD_FLAGS_IP_CSUM_MASK          0x1
154 #define ETH_TX_1ST_BD_FLAGS_IP_CSUM_SHIFT         2
155 /* Recalculate TCP/UDP checksum.
156  * For tunneled packet - relevant to inner header.
157  */
158 #define ETH_TX_1ST_BD_FLAGS_L4_CSUM_MASK          0x1
159 #define ETH_TX_1ST_BD_FLAGS_L4_CSUM_SHIFT         3
160 /* If set, insert VLAN tag from vlan field to the packet.
161  * For tunneled packet - relevant to outer header.
162  */
163 #define ETH_TX_1ST_BD_FLAGS_VLAN_INSERTION_MASK   0x1
164 #define ETH_TX_1ST_BD_FLAGS_VLAN_INSERTION_SHIFT  4
165 /* If set, this is an LSO packet. Note: For Tunneled LSO packets, the offset of
166  * the inner IPV4 (and IPV6) header is limited to 253 (and 251 respectively)
167  * bytes, inclusive.
168  */
169 #define ETH_TX_1ST_BD_FLAGS_LSO_MASK              0x1
170 #define ETH_TX_1ST_BD_FLAGS_LSO_SHIFT             5
171 /* Recalculate Tunnel IP Checksum (if Tunnel IP Header is IPv4) */
172 #define ETH_TX_1ST_BD_FLAGS_TUNN_IP_CSUM_MASK     0x1
173 #define ETH_TX_1ST_BD_FLAGS_TUNN_IP_CSUM_SHIFT    6
174 /* Recalculate Tunnel UDP/GRE Checksum (Depending on Tunnel Type) */
175 #define ETH_TX_1ST_BD_FLAGS_TUNN_L4_CSUM_MASK     0x1
176 #define ETH_TX_1ST_BD_FLAGS_TUNN_L4_CSUM_SHIFT    7
177 };
178
179 /*
180  * The parsing information data for the first tx bd of a given packet.
181  */
182 struct eth_tx_data_1st_bd {
183 /* VLAN tag to insert to packet (if enabled by vlan_insertion flag). */
184         __le16 vlan;
185 /* Number of BDs in packet. Should be at least 1 in non-LSO packet and at least
186  * 3 in LSO (or Tunnel with IPv6+ext) packet.
187  */
188         u8 nbds;
189         struct eth_tx_1st_bd_flags bd_flags;
190         __le16 bitfields;
191 /* Indicates a tunneled packet. Must be set for encapsulated packet. */
192 #define ETH_TX_DATA_1ST_BD_TUNN_FLAG_MASK  0x1
193 #define ETH_TX_DATA_1ST_BD_TUNN_FLAG_SHIFT 0
194 #define ETH_TX_DATA_1ST_BD_RESERVED0_MASK  0x1
195 #define ETH_TX_DATA_1ST_BD_RESERVED0_SHIFT 1
196 /* Total packet length - must be filled for non-LSO packets. */
197 #define ETH_TX_DATA_1ST_BD_PKT_LEN_MASK    0x3FFF
198 #define ETH_TX_DATA_1ST_BD_PKT_LEN_SHIFT   2
199 };
200
201 /*
202  * The parsing information data for the second tx bd of a given packet.
203  */
204 struct eth_tx_data_2nd_bd {
205 /* For tunnel with IPv6+ext - Tunnel header IP datagram length (in BYTEs) */
206         __le16 tunn_ip_size;
207         __le16 bitfields1;
208 /* For Tunnel header with IPv6 ext. - Inner L2 Header Size (in 2-byte WORDs) */
209 #define ETH_TX_DATA_2ND_BD_TUNN_INNER_L2_HDR_SIZE_W_MASK  0xF
210 #define ETH_TX_DATA_2ND_BD_TUNN_INNER_L2_HDR_SIZE_W_SHIFT 0
211 /* For Tunnel header with IPv6 ext. - Inner L2 Header MAC DA Type
212  * (use enum eth_addr_type)
213  */
214 #define ETH_TX_DATA_2ND_BD_TUNN_INNER_ETH_TYPE_MASK       0x3
215 #define ETH_TX_DATA_2ND_BD_TUNN_INNER_ETH_TYPE_SHIFT      4
216 /* Destination port mode. (use enum dest_port_mode) */
217 #define ETH_TX_DATA_2ND_BD_DEST_PORT_MODE_MASK            0x3
218 #define ETH_TX_DATA_2ND_BD_DEST_PORT_MODE_SHIFT           6
219 /* Should be 0 in all the BDs, except the first one. (for debug) */
220 #define ETH_TX_DATA_2ND_BD_START_BD_MASK                  0x1
221 #define ETH_TX_DATA_2ND_BD_START_BD_SHIFT                 8
222 /* For Tunnel header with IPv6 ext. - Tunnel Type (use enum eth_tx_tunn_type) */
223 #define ETH_TX_DATA_2ND_BD_TUNN_TYPE_MASK                 0x3
224 #define ETH_TX_DATA_2ND_BD_TUNN_TYPE_SHIFT                9
225 /* For LSO / Tunnel header with IPv6+ext - Set if inner header is IPv6 */
226 #define ETH_TX_DATA_2ND_BD_TUNN_INNER_IPV6_MASK           0x1
227 #define ETH_TX_DATA_2ND_BD_TUNN_INNER_IPV6_SHIFT          11
228 /* In tunneling mode - Set to 1 when the Inner header is IPv6 with extension.
229  * Otherwise set to 1 if the header is IPv6 with extension.
230  */
231 #define ETH_TX_DATA_2ND_BD_IPV6_EXT_MASK                  0x1
232 #define ETH_TX_DATA_2ND_BD_IPV6_EXT_SHIFT                 12
233 /* Set to 1 if Tunnel (outer = encapsulating) header has IPv6 ext. (Note: 3rd BD
234  * is required, hence EDPM does not support Tunnel [outer] header with Ipv6Ext)
235  */
236 #define ETH_TX_DATA_2ND_BD_TUNN_IPV6_EXT_MASK             0x1
237 #define ETH_TX_DATA_2ND_BD_TUNN_IPV6_EXT_SHIFT            13
238 /* Set if (inner) L4 protocol is UDP. (Required when IPv6+ext (or tunnel with
239  * inner or outer Ipv6+ext) and l4_csum is set)
240  */
241 #define ETH_TX_DATA_2ND_BD_L4_UDP_MASK                    0x1
242 #define ETH_TX_DATA_2ND_BD_L4_UDP_SHIFT                   14
243 /* The pseudo header checksum type in the L4 checksum field. Required when
244  * IPv6+ext and l4_csum is set. (use enum eth_l4_pseudo_checksum_mode)
245  */
246 #define ETH_TX_DATA_2ND_BD_L4_PSEUDO_CSUM_MODE_MASK       0x1
247 #define ETH_TX_DATA_2ND_BD_L4_PSEUDO_CSUM_MODE_SHIFT      15
248         __le16 bitfields2;
249 /* For inner/outer header IPv6+ext - (inner) L4 header offset (in 2-byte WORDs).
250  * For regular packet - offset from the beginning of the packet. For tunneled
251  * packet - offset from the beginning of the inner header
252  */
253 #define ETH_TX_DATA_2ND_BD_L4_HDR_START_OFFSET_W_MASK     0x1FFF
254 #define ETH_TX_DATA_2ND_BD_L4_HDR_START_OFFSET_W_SHIFT    0
255 #define ETH_TX_DATA_2ND_BD_RESERVED0_MASK                 0x7
256 #define ETH_TX_DATA_2ND_BD_RESERVED0_SHIFT                13
257 };
258
259 /*
260  * Firmware data for L2-EDPM packet.
261  */
262 struct eth_edpm_fw_data {
263 /* Parsing information data from the 1st BD. */
264         struct eth_tx_data_1st_bd data_1st_bd;
265 /* Parsing information data from the 2nd BD. */
266         struct eth_tx_data_2nd_bd data_2nd_bd;
267         __le32 reserved;
268 };
269
270
271 /*
272  * FW debug.
273  */
274 struct eth_fast_path_cqe_fw_debug {
275         __le16 reserved2 /* FW reserved. */;
276 };
277
278
279 /*
280  * tunneling parsing flags
281  */
282 struct eth_tunnel_parsing_flags {
283         u8 flags;
284 /* 0 - no tunneling, 1 - GENEVE, 2 - GRE, 3 - VXLAN
285  * (use enum eth_rx_tunn_type)
286  */
287 #define ETH_TUNNEL_PARSING_FLAGS_TYPE_MASK              0x3
288 #define ETH_TUNNEL_PARSING_FLAGS_TYPE_SHIFT             0
289 /*  If it s not an encapsulated packet then put 0x0. If it s an encapsulated
290  *  packet but the tenant-id doesn t exist then put 0x0. Else put 0x1
291  *
292  */
293 #define ETH_TUNNEL_PARSING_FLAGS_TENNANT_ID_EXIST_MASK  0x1
294 #define ETH_TUNNEL_PARSING_FLAGS_TENNANT_ID_EXIST_SHIFT 2
295 /* Type of the next header above the tunneling: 0 - unknown, 1 - L2, 2 - Ipv4,
296  * 3 - IPv6 (use enum tunnel_next_protocol)
297  */
298 #define ETH_TUNNEL_PARSING_FLAGS_NEXT_PROTOCOL_MASK     0x3
299 #define ETH_TUNNEL_PARSING_FLAGS_NEXT_PROTOCOL_SHIFT    3
300 /* The result of comparing the DA-ip of the tunnel header. */
301 #define ETH_TUNNEL_PARSING_FLAGS_FIRSTHDRIPMATCH_MASK   0x1
302 #define ETH_TUNNEL_PARSING_FLAGS_FIRSTHDRIPMATCH_SHIFT  5
303 #define ETH_TUNNEL_PARSING_FLAGS_IPV4_FRAGMENT_MASK     0x1
304 #define ETH_TUNNEL_PARSING_FLAGS_IPV4_FRAGMENT_SHIFT    6
305 #define ETH_TUNNEL_PARSING_FLAGS_IPV4_OPTIONS_MASK      0x1
306 #define ETH_TUNNEL_PARSING_FLAGS_IPV4_OPTIONS_SHIFT     7
307 };
308
309 /*
310  * PMD flow control bits
311  */
312 struct eth_pmd_flow_flags {
313         u8 flags;
314 #define ETH_PMD_FLOW_FLAGS_VALID_MASK     0x1 /* CQE valid bit */
315 #define ETH_PMD_FLOW_FLAGS_VALID_SHIFT    0
316 #define ETH_PMD_FLOW_FLAGS_TOGGLE_MASK    0x1 /* CQE ring toggle bit */
317 #define ETH_PMD_FLOW_FLAGS_TOGGLE_SHIFT   1
318 #define ETH_PMD_FLOW_FLAGS_RESERVED_MASK  0x3F
319 #define ETH_PMD_FLOW_FLAGS_RESERVED_SHIFT 2
320 };
321
322 /*
323  * Regular ETH Rx FP CQE.
324  */
325 struct eth_fast_path_rx_reg_cqe {
326         u8 type /* CQE type */;
327         u8 bitfields;
328 /* Type of calculated RSS hash (use enum rss_hash_type) */
329 #define ETH_FAST_PATH_RX_REG_CQE_RSS_HASH_TYPE_MASK  0x7
330 #define ETH_FAST_PATH_RX_REG_CQE_RSS_HASH_TYPE_SHIFT 0
331 /* Traffic Class */
332 #define ETH_FAST_PATH_RX_REG_CQE_TC_MASK             0xF
333 #define ETH_FAST_PATH_RX_REG_CQE_TC_SHIFT            3
334 #define ETH_FAST_PATH_RX_REG_CQE_RESERVED0_MASK      0x1
335 #define ETH_FAST_PATH_RX_REG_CQE_RESERVED0_SHIFT     7
336         __le16 pkt_len /* Total packet length (from the parser) */;
337 /* Parsing and error flags from the parser */
338         struct parsing_and_err_flags pars_flags;
339         __le16 vlan_tag /* 802.1q VLAN tag */;
340         __le32 rss_hash /* RSS hash result */;
341         __le16 len_on_first_bd /* Number of bytes placed on first BD */;
342         u8 placement_offset /* Offset of placement from BD start */;
343 /* Tunnel Parsing Flags */
344         struct eth_tunnel_parsing_flags tunnel_pars_flags;
345         u8 bd_num /* Number of BDs, used for packet */;
346         u8 reserved[9];
347         struct eth_fast_path_cqe_fw_debug fw_debug /* FW reserved. */;
348         u8 reserved1[3];
349         struct eth_pmd_flow_flags pmd_flags /* CQE valid and toggle bits */;
350 };
351
352
353 /*
354  * TPA-continue ETH Rx FP CQE.
355  */
356 struct eth_fast_path_rx_tpa_cont_cqe {
357         u8 type /* CQE type */;
358         u8 tpa_agg_index /* TPA aggregation index */;
359 /* List of the segment sizes */
360         __le16 len_list[ETH_TPA_CQE_CONT_LEN_LIST_SIZE];
361         u8 reserved;
362         u8 reserved1 /* FW reserved. */;
363         __le16 reserved2[ETH_TPA_CQE_CONT_LEN_LIST_SIZE] /* FW reserved. */;
364         u8 reserved3[3];
365         struct eth_pmd_flow_flags pmd_flags /* CQE valid and toggle bits */;
366 };
367
368
369 /*
370  * TPA-end ETH Rx FP CQE .
371  */
372 struct eth_fast_path_rx_tpa_end_cqe {
373         u8 type /* CQE type */;
374         u8 tpa_agg_index /* TPA aggregation index */;
375         __le16 total_packet_len /* Total aggregated packet length */;
376         u8 num_of_bds /* Total number of BDs comprising the packet */;
377 /* Aggregation end reason. Use enum eth_tpa_end_reason */
378         u8 end_reason;
379         __le16 num_of_coalesced_segs /* Number of coalesced TCP segments */;
380         __le32 ts_delta /* TCP timestamp delta */;
381 /* List of the segment sizes */
382         __le16 len_list[ETH_TPA_CQE_END_LEN_LIST_SIZE];
383         __le16 reserved3[ETH_TPA_CQE_END_LEN_LIST_SIZE] /* FW reserved. */;
384         __le16 reserved1;
385         u8 reserved2 /* FW reserved. */;
386         struct eth_pmd_flow_flags pmd_flags /* CQE valid and toggle bits */;
387 };
388
389
390 /*
391  * TPA-start ETH Rx FP CQE.
392  */
393 struct eth_fast_path_rx_tpa_start_cqe {
394         u8 type /* CQE type */;
395         u8 bitfields;
396 /* Type of calculated RSS hash (use enum rss_hash_type) */
397 #define ETH_FAST_PATH_RX_TPA_START_CQE_RSS_HASH_TYPE_MASK  0x7
398 #define ETH_FAST_PATH_RX_TPA_START_CQE_RSS_HASH_TYPE_SHIFT 0
399 /* Traffic Class */
400 #define ETH_FAST_PATH_RX_TPA_START_CQE_TC_MASK             0xF
401 #define ETH_FAST_PATH_RX_TPA_START_CQE_TC_SHIFT            3
402 #define ETH_FAST_PATH_RX_TPA_START_CQE_RESERVED0_MASK      0x1
403 #define ETH_FAST_PATH_RX_TPA_START_CQE_RESERVED0_SHIFT     7
404         __le16 seg_len /* Segment length (packetLen from the parser) */;
405 /* Parsing and error flags from the parser */
406         struct parsing_and_err_flags pars_flags;
407         __le16 vlan_tag /* 802.1q VLAN tag */;
408         __le32 rss_hash /* RSS hash result */;
409         __le16 len_on_first_bd /* Number of bytes placed on first BD */;
410         u8 placement_offset /* Offset of placement from BD start */;
411 /* Tunnel Parsing Flags */
412         struct eth_tunnel_parsing_flags tunnel_pars_flags;
413         u8 tpa_agg_index /* TPA aggregation index */;
414         u8 header_len /* Packet L2+L3+L4 header length */;
415 /* Additional BDs length list. */
416         __le16 ext_bd_len_list[ETH_TPA_CQE_START_LEN_LIST_SIZE];
417         struct eth_fast_path_cqe_fw_debug fw_debug /* FW reserved. */;
418         u8 reserved;
419         struct eth_pmd_flow_flags pmd_flags /* CQE valid and toggle bits */;
420 };
421
422
423 /*
424  * The L4 pseudo checksum mode for Ethernet
425  */
426 enum eth_l4_pseudo_checksum_mode {
427 /* Pseudo Header checksum on packet is calculated with the correct packet length
428  * field.
429  */
430         ETH_L4_PSEUDO_CSUM_CORRECT_LENGTH,
431 /* Pseudo Header checksum on packet is calculated with zero length field. */
432         ETH_L4_PSEUDO_CSUM_ZERO_LENGTH,
433         MAX_ETH_L4_PSEUDO_CHECKSUM_MODE
434 };
435
436
437
438 struct eth_rx_bd {
439         struct regpair addr /* single continues buffer */;
440 };
441
442
443 /*
444  * regular ETH Rx SP CQE
445  */
446 struct eth_slow_path_rx_cqe {
447         u8 type /* CQE type */;
448         u8 ramrod_cmd_id;
449         u8 error_flag;
450         u8 reserved[25];
451         __le16 echo;
452         u8 reserved1;
453         struct eth_pmd_flow_flags pmd_flags /* CQE valid and toggle bits */;
454 };
455
456 /*
457  * union for all ETH Rx CQE types
458  */
459 union eth_rx_cqe {
460 /* Regular FP CQE */
461         struct eth_fast_path_rx_reg_cqe fast_path_regular;
462 /* TPA-start CQE */
463         struct eth_fast_path_rx_tpa_start_cqe fast_path_tpa_start;
464 /* TPA-continue CQE */
465         struct eth_fast_path_rx_tpa_cont_cqe fast_path_tpa_cont;
466 /* TPA-end CQE */
467         struct eth_fast_path_rx_tpa_end_cqe fast_path_tpa_end;
468         struct eth_slow_path_rx_cqe slow_path /* SP CQE */;
469 };
470
471
472 /*
473  * ETH Rx CQE type
474  */
475 enum eth_rx_cqe_type {
476         ETH_RX_CQE_TYPE_UNUSED,
477         ETH_RX_CQE_TYPE_REGULAR /* Regular FP ETH Rx CQE */,
478         ETH_RX_CQE_TYPE_SLOW_PATH /* Slow path ETH Rx CQE */,
479         ETH_RX_CQE_TYPE_TPA_START /* TPA start ETH Rx CQE */,
480         ETH_RX_CQE_TYPE_TPA_CONT /* TPA Continue ETH Rx CQE */,
481         ETH_RX_CQE_TYPE_TPA_END /* TPA end ETH Rx CQE */,
482         MAX_ETH_RX_CQE_TYPE
483 };
484
485
486 /*
487  * Wrapper for PD RX CQE - used in order to cover full cache line when writing
488  * CQE
489  */
490 struct eth_rx_pmd_cqe {
491         union eth_rx_cqe cqe /* CQE data itself */;
492         u8 reserved[ETH_RX_CQE_GAP];
493 };
494
495
496 /*
497  * Eth RX Tunnel Type
498  */
499 enum eth_rx_tunn_type {
500         ETH_RX_NO_TUNN /* No Tunnel. */,
501         ETH_RX_TUNN_GENEVE /* GENEVE Tunnel. */,
502         ETH_RX_TUNN_GRE /* GRE Tunnel. */,
503         ETH_RX_TUNN_VXLAN /* VXLAN Tunnel. */,
504         MAX_ETH_RX_TUNN_TYPE
505 };
506
507
508
509 /*
510  * Aggregation end reason.
511  */
512 enum eth_tpa_end_reason {
513         ETH_AGG_END_UNUSED,
514         ETH_AGG_END_SP_UPDATE /* SP configuration update */,
515 /* Maximum aggregation length or maximum buffer number used. */
516         ETH_AGG_END_MAX_LEN,
517 /* TCP PSH flag or TCP payload length below continue threshold. */
518         ETH_AGG_END_LAST_SEG,
519         ETH_AGG_END_TIMEOUT /* Timeout expiration. */,
520 /* Packet header not consistency: different IPv4 TOS, TTL or flags, IPv6 TC,
521  * Hop limit or Flow label, TCP header length or TS options. In GRO different
522  * TS value, SMAC, DMAC, ackNum, windowSize or VLAN
523  */
524         ETH_AGG_END_NOT_CONSISTENT,
525 /* Out of order or retransmission packet: sequence, ack or timestamp not
526  * consistent with previous segment.
527  */
528         ETH_AGG_END_OUT_OF_ORDER,
529 /* Next segment cant be aggregated due to LLC/SNAP, IP error, IP fragment, IPv4
530  * options, IPv6 extension, IP ECN = CE, TCP errors, TCP options, zero TCP
531  * payload length , TCP flags or not supported tunnel header options.
532  */
533         ETH_AGG_END_NON_TPA_SEG,
534         MAX_ETH_TPA_END_REASON
535 };
536
537
538
539 /*
540  * The first tx bd of a given packet
541  */
542 struct eth_tx_1st_bd {
543         struct regpair addr /* Single continuous buffer */;
544         __le16 nbytes /* Number of bytes in this BD. */;
545         struct eth_tx_data_1st_bd data /* Parsing information data. */;
546 };
547
548
549
550 /*
551  * The second tx bd of a given packet
552  */
553 struct eth_tx_2nd_bd {
554         struct regpair addr /* Single continuous buffer */;
555         __le16 nbytes /* Number of bytes in this BD. */;
556         struct eth_tx_data_2nd_bd data /* Parsing information data. */;
557 };
558
559
560 /*
561  * The parsing information data for the third tx bd of a given packet.
562  */
563 struct eth_tx_data_3rd_bd {
564         __le16 lso_mss /* For LSO packet - the MSS in bytes. */;
565         __le16 bitfields;
566 /* For LSO with inner/outer IPv6+ext - TCP header length (in 4-byte WORDs) */
567 #define ETH_TX_DATA_3RD_BD_TCP_HDR_LEN_DW_MASK  0xF
568 #define ETH_TX_DATA_3RD_BD_TCP_HDR_LEN_DW_SHIFT 0
569 /* LSO - number of BDs which contain headers. value should be in range
570  * (1..ETH_TX_MAX_LSO_HDR_NBD).
571  */
572 #define ETH_TX_DATA_3RD_BD_HDR_NBD_MASK         0xF
573 #define ETH_TX_DATA_3RD_BD_HDR_NBD_SHIFT        4
574 /* Should be 0 in all the BDs, except the first one. (for debug) */
575 #define ETH_TX_DATA_3RD_BD_START_BD_MASK        0x1
576 #define ETH_TX_DATA_3RD_BD_START_BD_SHIFT       8
577 #define ETH_TX_DATA_3RD_BD_RESERVED0_MASK       0x7F
578 #define ETH_TX_DATA_3RD_BD_RESERVED0_SHIFT      9
579 /* For tunnel with IPv6+ext - Pointer to tunnel L4 Header (in 2-byte WORDs) */
580         u8 tunn_l4_hdr_start_offset_w;
581 /* For tunnel with IPv6+ext - Total size of Tunnel Header (in 2-byte WORDs) */
582         u8 tunn_hdr_size_w;
583 };
584
585 /*
586  * The third tx bd of a given packet
587  */
588 struct eth_tx_3rd_bd {
589         struct regpair addr /* Single continuous buffer */;
590         __le16 nbytes /* Number of bytes in this BD. */;
591         struct eth_tx_data_3rd_bd data /* Parsing information data. */;
592 };
593
594
595 /*
596  * Complementary information for the regular tx bd of a given packet.
597  */
598 struct eth_tx_data_bd {
599         __le16 reserved0;
600         __le16 bitfields;
601 #define ETH_TX_DATA_BD_RESERVED1_MASK  0xFF
602 #define ETH_TX_DATA_BD_RESERVED1_SHIFT 0
603 /* Should be 0 in all the BDs, except the first one. (for debug) */
604 #define ETH_TX_DATA_BD_START_BD_MASK   0x1
605 #define ETH_TX_DATA_BD_START_BD_SHIFT  8
606 #define ETH_TX_DATA_BD_RESERVED2_MASK  0x7F
607 #define ETH_TX_DATA_BD_RESERVED2_SHIFT 9
608         __le16 reserved3;
609 };
610
611 /*
612  * The common regular TX BD ring element
613  */
614 struct eth_tx_bd {
615         struct regpair addr /* Single continuous buffer */;
616         __le16 nbytes /* Number of bytes in this BD. */;
617         struct eth_tx_data_bd data /* Complementary information. */;
618 };
619
620
621 union eth_tx_bd_types {
622         struct eth_tx_1st_bd first_bd /* The first tx bd of a given packet */;
623 /* The second tx bd of a given packet */
624         struct eth_tx_2nd_bd second_bd;
625         struct eth_tx_3rd_bd third_bd /* The third tx bd of a given packet */;
626         struct eth_tx_bd reg_bd /* The common non-special bd */;
627 };
628
629
630
631
632
633
634 /*
635  * Eth Tx Tunnel Type
636  */
637 enum eth_tx_tunn_type {
638         ETH_TX_TUNN_GENEVE /* GENEVE Tunnel. */,
639         ETH_TX_TUNN_TTAG /* T-Tag Tunnel. */,
640         ETH_TX_TUNN_GRE /* GRE Tunnel. */,
641         ETH_TX_TUNN_VXLAN /* VXLAN Tunnel. */,
642         MAX_ETH_TX_TUNN_TYPE
643 };
644
645
646 /*
647  * Ystorm Queue Zone
648  */
649 struct xstorm_eth_queue_zone {
650 /* Tx interrupt coalescing TimeSet */
651         struct coalescing_timeset int_coalescing_timeset;
652         u8 reserved[7];
653 };
654
655
656 /*
657  * ETH doorbell data
658  */
659 struct eth_db_data {
660         u8 params;
661 /* destination of doorbell (use enum db_dest) */
662 #define ETH_DB_DATA_DEST_MASK         0x3
663 #define ETH_DB_DATA_DEST_SHIFT        0
664 /* aggregative command to CM (use enum db_agg_cmd_sel) */
665 #define ETH_DB_DATA_AGG_CMD_MASK      0x3
666 #define ETH_DB_DATA_AGG_CMD_SHIFT     2
667 #define ETH_DB_DATA_BYPASS_EN_MASK    0x1 /* enable QM bypass */
668 #define ETH_DB_DATA_BYPASS_EN_SHIFT   4
669 #define ETH_DB_DATA_RESERVED_MASK     0x1
670 #define ETH_DB_DATA_RESERVED_SHIFT    5
671 /* aggregative value selection */
672 #define ETH_DB_DATA_AGG_VAL_SEL_MASK  0x3
673 #define ETH_DB_DATA_AGG_VAL_SEL_SHIFT 6
674 /* bit for every DQ counter flags in CM context that DQ can increment */
675         u8 agg_flags;
676         __le16 bd_prod;
677 };
678
679 #endif /* __ETH_COMMON__ */