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