Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2010-2017 Intel Corporation
3 : : */
4 : :
5 : : #ifndef _I40E_ETHDEV_H_
6 : : #define _I40E_ETHDEV_H_
7 : :
8 : : #include <stdint.h>
9 : : #include <sys/queue.h>
10 : :
11 : : #include <rte_time.h>
12 : : #include <rte_kvargs.h>
13 : : #include <rte_hash.h>
14 : : #include <rte_flow.h>
15 : : #include <rte_flow_driver.h>
16 : : #include <rte_tm_driver.h>
17 : : #include "rte_pmd_i40e.h"
18 : :
19 : : #include "base/i40e_register.h"
20 : : #include "base/i40e_type.h"
21 : : #include "base/virtchnl.h"
22 : :
23 : : /**
24 : : * _i=0...143,
25 : : * counters 0-127 are for the 128 VFs,
26 : : * counters 128-143 are for the 16 PFs
27 : : */
28 : : #define I40E_GL_RXERR1_H(_i) (0x00318004 + ((_i) * 8))
29 : :
30 : : #define I40E_AQ_LEN 32
31 : : #define I40E_AQ_BUF_SZ 4096
32 : : /* Number of queues per TC should be one of 1, 2, 4, 8, 16, 32, 64 */
33 : : #define I40E_MAX_Q_PER_TC 64
34 : : #define I40E_NUM_DESC_DEFAULT 512
35 : : #define I40E_NUM_DESC_ALIGN 32
36 : : #define I40E_BUF_SIZE_MIN 1024
37 : : #define I40E_FRAME_SIZE_MAX 9728
38 : : #define I40E_TSO_FRAME_SIZE_MAX 262144
39 : : #define I40E_QUEUE_BASE_ADDR_UNIT 128
40 : : /* number of VSIs and queue default setting */
41 : : #define I40E_MAX_QP_NUM_PER_VF 16
42 : : #define I40E_DEFAULT_QP_NUM_FDIR 1
43 : : #define I40E_UINT32_BIT_SIZE (CHAR_BIT * sizeof(uint32_t))
44 : : #define I40E_VFTA_SIZE (4096 / I40E_UINT32_BIT_SIZE)
45 : : /* Maximun number of MAC addresses */
46 : : #define I40E_NUM_MACADDR_MAX 64
47 : : /* Maximum number of VFs */
48 : : #define I40E_MAX_VF 128
49 : : /*flag of no loopback*/
50 : : #define I40E_AQ_LB_MODE_NONE 0x0
51 : : #define I40E_AQ_LB_MODE_EN 0x01
52 : : #define I40E_AQ_LB_MAC 0x01
53 : : #define I40E_AQ_LB_MAC_LOCAL_X722 0x04
54 : : /*
55 : : * vlan_id is a 12 bit number.
56 : : * The VFTA array is actually a 4096 bit array, 128 of 32bit elements.
57 : : * 2^5 = 32. The val of lower 5 bits specifies the bit in the 32bit element.
58 : : * The higher 7 bit val specifies VFTA array index.
59 : : */
60 : : #define I40E_VFTA_BIT(vlan_id) (1 << ((vlan_id) & 0x1F))
61 : : #define I40E_VFTA_IDX(vlan_id) ((vlan_id) >> 5)
62 : :
63 : : /* Default TC traffic in case DCB is not enabled */
64 : : #define I40E_DEFAULT_TCMAP 0x1
65 : : #define I40E_FDIR_QUEUE_ID 0
66 : :
67 : : /* Always assign pool 0 to main VSI, VMDQ will start from 1 */
68 : : #define I40E_VMDQ_POOL_BASE 1
69 : :
70 : : #define I40E_DEFAULT_RX_FREE_THRESH 32
71 : : #define I40E_DEFAULT_RX_PTHRESH 8
72 : : #define I40E_DEFAULT_RX_HTHRESH 8
73 : : #define I40E_DEFAULT_RX_WTHRESH 0
74 : :
75 : : #define I40E_DEFAULT_TX_FREE_THRESH 32
76 : : #define I40E_DEFAULT_TX_PTHRESH 32
77 : : #define I40E_DEFAULT_TX_HTHRESH 0
78 : : #define I40E_DEFAULT_TX_WTHRESH 0
79 : : #define I40E_DEFAULT_TX_RSBIT_THRESH 32
80 : :
81 : : /* Bit shift and mask */
82 : : #define I40E_4_BIT_WIDTH (CHAR_BIT / 2)
83 : : #define I40E_4_BIT_MASK RTE_LEN2MASK(I40E_4_BIT_WIDTH, uint8_t)
84 : : #define I40E_8_BIT_WIDTH CHAR_BIT
85 : : #define I40E_8_BIT_MASK UINT8_MAX
86 : : #define I40E_16_BIT_WIDTH (CHAR_BIT * 2)
87 : : #define I40E_16_BIT_MASK UINT16_MAX
88 : : #define I40E_32_BIT_WIDTH (CHAR_BIT * 4)
89 : : #define I40E_32_BIT_MASK UINT32_MAX
90 : : #define I40E_48_BIT_WIDTH (CHAR_BIT * 6)
91 : : #define I40E_48_BIT_MASK RTE_LEN2MASK(I40E_48_BIT_WIDTH, uint64_t)
92 : :
93 : : /* Linux PF host with virtchnl version 1.1 */
94 : : #define PF_IS_V11(vf) \
95 : : (((vf)->version_major == VIRTCHNL_VERSION_MAJOR) && \
96 : : ((vf)->version_minor == 1))
97 : :
98 : : #define I40E_WRITE_GLB_REG(hw, reg, value) \
99 : : do { \
100 : : uint32_t ori_val; \
101 : : struct rte_eth_dev *dev; \
102 : : struct rte_eth_dev_data *dev_data; \
103 : : ori_val = I40E_READ_REG((hw), (reg)); \
104 : : dev_data = ((struct i40e_adapter *)hw->back)->pf.dev_data; \
105 : : dev = &rte_eth_devices[dev_data->port_id]; \
106 : : I40E_PCI_REG_WRITE(I40E_PCI_REG_ADDR((hw), \
107 : : (reg)), (value)); \
108 : : if (ori_val != value) \
109 : : PMD_DRV_LOG(WARNING, \
110 : : "i40e device %s changed global " \
111 : : "register [0x%08x]. original: 0x%08x, " \
112 : : "new: 0x%08x ", \
113 : : (dev->device->name), (reg), \
114 : : (ori_val), (value)); \
115 : : } while (0)
116 : :
117 : : /* index flex payload per layer */
118 : : enum i40e_flxpld_layer_idx {
119 : : I40E_FLXPLD_L2_IDX = 0,
120 : : I40E_FLXPLD_L3_IDX = 1,
121 : : I40E_FLXPLD_L4_IDX = 2,
122 : : I40E_MAX_FLXPLD_LAYER = 3,
123 : : };
124 : : #define I40E_MAX_FLXPLD_FIED 3 /* max number of flex payload fields */
125 : : #define I40E_FDIR_BITMASK_NUM_WORD 2 /* max number of bitmask words */
126 : : #define I40E_FDIR_MAX_FLEXWORD_NUM 8 /* max number of flexpayload words */
127 : : #define I40E_FDIR_MAX_FLEX_LEN 16 /* len in bytes of flex payload */
128 : : #define I40E_INSET_MASK_NUM_REG 2 /* number of input set mask registers */
129 : :
130 : : /* i40e flags */
131 : : #define I40E_FLAG_RSS (1ULL << 0)
132 : : #define I40E_FLAG_DCB (1ULL << 1)
133 : : #define I40E_FLAG_VMDQ (1ULL << 2)
134 : : #define I40E_FLAG_SRIOV (1ULL << 3)
135 : : #define I40E_FLAG_HEADER_SPLIT_DISABLED (1ULL << 4)
136 : : #define I40E_FLAG_HEADER_SPLIT_ENABLED (1ULL << 5)
137 : : #define I40E_FLAG_FDIR (1ULL << 6)
138 : : #define I40E_FLAG_VXLAN (1ULL << 7)
139 : : #define I40E_FLAG_RSS_AQ_CAPABLE (1ULL << 8)
140 : : #define I40E_FLAG_ALL (I40E_FLAG_RSS | \
141 : : I40E_FLAG_DCB | \
142 : : I40E_FLAG_VMDQ | \
143 : : I40E_FLAG_SRIOV | \
144 : : I40E_FLAG_HEADER_SPLIT_DISABLED | \
145 : : I40E_FLAG_HEADER_SPLIT_ENABLED | \
146 : : I40E_FLAG_FDIR | \
147 : : I40E_FLAG_VXLAN | \
148 : : I40E_FLAG_RSS_AQ_CAPABLE)
149 : :
150 : : #define I40E_RSS_OFFLOAD_ALL ( \
151 : : RTE_ETH_RSS_FRAG_IPV4 | \
152 : : RTE_ETH_RSS_NONFRAG_IPV4_TCP | \
153 : : RTE_ETH_RSS_NONFRAG_IPV4_UDP | \
154 : : RTE_ETH_RSS_NONFRAG_IPV4_SCTP | \
155 : : RTE_ETH_RSS_NONFRAG_IPV4_OTHER | \
156 : : RTE_ETH_RSS_FRAG_IPV6 | \
157 : : RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
158 : : RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
159 : : RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \
160 : : RTE_ETH_RSS_NONFRAG_IPV6_OTHER | \
161 : : RTE_ETH_RSS_L2_PAYLOAD)
162 : :
163 : : /* All bits of RSS hash enable for X722*/
164 : : #define I40E_RSS_HENA_ALL_X722 ( \
165 : : (1ULL << I40E_FILTER_PCTYPE_NONF_UNICAST_IPV4_UDP) | \
166 : : (1ULL << I40E_FILTER_PCTYPE_NONF_MULTICAST_IPV4_UDP) | \
167 : : (1ULL << I40E_FILTER_PCTYPE_NONF_IPV4_TCP_SYN_NO_ACK) | \
168 : : (1ULL << I40E_FILTER_PCTYPE_NONF_UNICAST_IPV6_UDP) | \
169 : : (1ULL << I40E_FILTER_PCTYPE_NONF_MULTICAST_IPV6_UDP) | \
170 : : (1ULL << I40E_FILTER_PCTYPE_NONF_IPV6_TCP_SYN_NO_ACK) | \
171 : : I40E_RSS_HENA_ALL)
172 : :
173 : : /* All bits of RSS hash enable */
174 : : #define I40E_RSS_HENA_ALL ( \
175 : : (1ULL << I40E_FILTER_PCTYPE_NONF_IPV4_UDP) | \
176 : : (1ULL << I40E_FILTER_PCTYPE_NONF_IPV4_TCP) | \
177 : : (1ULL << I40E_FILTER_PCTYPE_NONF_IPV4_SCTP) | \
178 : : (1ULL << I40E_FILTER_PCTYPE_NONF_IPV4_OTHER) | \
179 : : (1ULL << I40E_FILTER_PCTYPE_FRAG_IPV4) | \
180 : : (1ULL << I40E_FILTER_PCTYPE_NONF_IPV6_UDP) | \
181 : : (1ULL << I40E_FILTER_PCTYPE_NONF_IPV6_TCP) | \
182 : : (1ULL << I40E_FILTER_PCTYPE_NONF_IPV6_SCTP) | \
183 : : (1ULL << I40E_FILTER_PCTYPE_NONF_IPV6_OTHER) | \
184 : : (1ULL << I40E_FILTER_PCTYPE_FRAG_IPV6) | \
185 : : (1ULL << I40E_FILTER_PCTYPE_FCOE_OX) | \
186 : : (1ULL << I40E_FILTER_PCTYPE_FCOE_RX) | \
187 : : (1ULL << I40E_FILTER_PCTYPE_FCOE_OTHER) | \
188 : : (1ULL << I40E_FILTER_PCTYPE_L2_PAYLOAD))
189 : :
190 : : #define I40E_MISC_VEC_ID RTE_INTR_VEC_ZERO_OFFSET
191 : : #define I40E_RX_VEC_START RTE_INTR_VEC_RXTX_OFFSET
192 : :
193 : : /* Default queue interrupt throttling time in microseconds */
194 : : #define I40E_ITR_INDEX_DEFAULT 0
195 : : #define I40E_ITR_INDEX_NONE 3
196 : : #define I40E_QUEUE_ITR_INTERVAL_DEFAULT 32 /* 32 us */
197 : : #define I40E_QUEUE_ITR_INTERVAL_MAX 8160 /* 8160 us */
198 : : #define I40E_VF_QUEUE_ITR_INTERVAL_DEFAULT 32 /* 32 us */
199 : : /* Special FW support this floating VEB feature */
200 : : #define FLOATING_VEB_SUPPORTED_FW_MAJ 5
201 : : #define FLOATING_VEB_SUPPORTED_FW_MIN 0
202 : :
203 : : #define I40E_GL_SWT_L2TAGCTRL(_i) (0x001C0A70 + ((_i) * 4))
204 : : #define I40E_GL_SWT_L2TAGCTRL_ETHERTYPE_SHIFT 16
205 : : #define I40E_GL_SWT_L2TAGCTRL_ETHERTYPE_MASK \
206 : : I40E_MASK(0xFFFF, I40E_GL_SWT_L2TAGCTRL_ETHERTYPE_SHIFT)
207 : :
208 : : #define I40E_RSS_TYPE_NONE 0ULL
209 : : #define I40E_RSS_TYPE_INVALID 1ULL
210 : :
211 : : #define I40E_INSET_NONE 0x00000000000000000ULL
212 : :
213 : : /* bit0 ~ bit 7 */
214 : : #define I40E_INSET_DMAC 0x0000000000000001ULL
215 : : #define I40E_INSET_SMAC 0x0000000000000002ULL
216 : : #define I40E_INSET_VLAN_OUTER 0x0000000000000004ULL
217 : : #define I40E_INSET_VLAN_INNER 0x0000000000000008ULL
218 : : #define I40E_INSET_VLAN_TUNNEL 0x0000000000000010ULL
219 : :
220 : : /* bit 8 ~ bit 15 */
221 : : #define I40E_INSET_IPV4_SRC 0x0000000000000100ULL
222 : : #define I40E_INSET_IPV4_DST 0x0000000000000200ULL
223 : : #define I40E_INSET_IPV6_SRC 0x0000000000000400ULL
224 : : #define I40E_INSET_IPV6_DST 0x0000000000000800ULL
225 : : #define I40E_INSET_SRC_PORT 0x0000000000001000ULL
226 : : #define I40E_INSET_DST_PORT 0x0000000000002000ULL
227 : : #define I40E_INSET_SCTP_VT 0x0000000000004000ULL
228 : :
229 : : /* bit 16 ~ bit 31 */
230 : : #define I40E_INSET_IPV4_TOS 0x0000000000010000ULL
231 : : #define I40E_INSET_IPV4_PROTO 0x0000000000020000ULL
232 : : #define I40E_INSET_IPV4_TTL 0x0000000000040000ULL
233 : : #define I40E_INSET_IPV6_TC 0x0000000000080000ULL
234 : : #define I40E_INSET_IPV6_FLOW 0x0000000000100000ULL
235 : : #define I40E_INSET_IPV6_NEXT_HDR 0x0000000000200000ULL
236 : : #define I40E_INSET_IPV6_HOP_LIMIT 0x0000000000400000ULL
237 : : #define I40E_INSET_TCP_FLAGS 0x0000000000800000ULL
238 : :
239 : : /* bit 32 ~ bit 47, tunnel fields */
240 : : #define I40E_INSET_TUNNEL_IPV4_DST 0x0000000100000000ULL
241 : : #define I40E_INSET_TUNNEL_IPV6_DST 0x0000000200000000ULL
242 : : #define I40E_INSET_TUNNEL_DMAC 0x0000000400000000ULL
243 : : #define I40E_INSET_TUNNEL_SRC_PORT 0x0000000800000000ULL
244 : : #define I40E_INSET_TUNNEL_DST_PORT 0x0000001000000000ULL
245 : : #define I40E_INSET_TUNNEL_ID 0x0000002000000000ULL
246 : :
247 : : /* bit 48 ~ bit 55 */
248 : : #define I40E_INSET_LAST_ETHER_TYPE 0x0001000000000000ULL
249 : :
250 : : /* bit 56 ~ bit 63, Flex Payload */
251 : : #define I40E_INSET_FLEX_PAYLOAD_W1 0x0100000000000000ULL
252 : : #define I40E_INSET_FLEX_PAYLOAD_W2 0x0200000000000000ULL
253 : : #define I40E_INSET_FLEX_PAYLOAD_W3 0x0400000000000000ULL
254 : : #define I40E_INSET_FLEX_PAYLOAD_W4 0x0800000000000000ULL
255 : : #define I40E_INSET_FLEX_PAYLOAD_W5 0x1000000000000000ULL
256 : : #define I40E_INSET_FLEX_PAYLOAD_W6 0x2000000000000000ULL
257 : : #define I40E_INSET_FLEX_PAYLOAD_W7 0x4000000000000000ULL
258 : : #define I40E_INSET_FLEX_PAYLOAD_W8 0x8000000000000000ULL
259 : : #define I40E_INSET_FLEX_PAYLOAD \
260 : : (I40E_INSET_FLEX_PAYLOAD_W1 | I40E_INSET_FLEX_PAYLOAD_W2 | \
261 : : I40E_INSET_FLEX_PAYLOAD_W3 | I40E_INSET_FLEX_PAYLOAD_W4 | \
262 : : I40E_INSET_FLEX_PAYLOAD_W5 | I40E_INSET_FLEX_PAYLOAD_W6 | \
263 : : I40E_INSET_FLEX_PAYLOAD_W7 | I40E_INSET_FLEX_PAYLOAD_W8)
264 : :
265 : : /* The max bandwidth of i40e is 40Gbps. */
266 : : #define I40E_QOS_BW_MAX 40000
267 : : /* The bandwidth should be the multiple of 50Mbps. */
268 : : #define I40E_QOS_BW_GRANULARITY 50
269 : : /* The min bandwidth weight is 1. */
270 : : #define I40E_QOS_BW_WEIGHT_MIN 1
271 : : /* The max bandwidth weight is 127. */
272 : : #define I40E_QOS_BW_WEIGHT_MAX 127
273 : : /* The max queue region index is 7. */
274 : : #define I40E_REGION_MAX_INDEX 7
275 : :
276 : : #define I40E_MAX_PERCENT 100
277 : : #define I40E_DEFAULT_DCB_APP_NUM 1
278 : : #define I40E_DEFAULT_DCB_APP_PRIO 3
279 : :
280 : : #define I40E_FDIR_PRG_PKT_CNT 128
281 : : #define I40E_FDIR_ID_BIT_SHIFT 13
282 : :
283 : : /*
284 : : * Struct to store flow created.
285 : : */
286 : : struct rte_flow {
287 : : TAILQ_ENTRY(rte_flow) node;
288 : : enum rte_filter_type filter_type;
289 : : void *rule;
290 : : };
291 : :
292 : : /**
293 : : * The overhead from MTU to max frame size.
294 : : * Considering QinQ packet, the VLAN tag needs to be counted twice.
295 : : */
296 : : #define I40E_ETH_OVERHEAD \
297 : : (RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN + RTE_VLAN_HLEN * 2)
298 : : #define I40E_ETH_MAX_LEN (RTE_ETHER_MTU + I40E_ETH_OVERHEAD)
299 : :
300 : : #define I40E_RXTX_BYTES_H_16_BIT(bytes) ((bytes) & ~I40E_48_BIT_MASK)
301 : : #define I40E_RXTX_BYTES_L_48_BIT(bytes) ((bytes) & I40E_48_BIT_MASK)
302 : :
303 : : struct i40e_adapter;
304 : : struct rte_pci_driver;
305 : :
306 : : /**
307 : : * MAC filter type
308 : : */
309 : : enum i40e_mac_filter_type {
310 : : I40E_MAC_PERFECT_MATCH = 1, /**< exact match of MAC addr. */
311 : : I40E_MACVLAN_PERFECT_MATCH, /**< exact match of MAC addr and VLAN ID. */
312 : : I40E_MAC_HASH_MATCH, /**< hash match of MAC addr. */
313 : : /** hash match of MAC addr and exact match of VLAN ID. */
314 : : I40E_MACVLAN_HASH_MATCH,
315 : : };
316 : :
317 : : /**
318 : : * MAC filter structure
319 : : */
320 : : struct i40e_mac_filter_info {
321 : : enum i40e_mac_filter_type filter_type;
322 : : struct rte_ether_addr mac_addr;
323 : : };
324 : :
325 : : TAILQ_HEAD(i40e_mac_filter_list, i40e_mac_filter);
326 : :
327 : : /* MAC filter list structure */
328 : : struct i40e_mac_filter {
329 : : TAILQ_ENTRY(i40e_mac_filter) next;
330 : : struct i40e_mac_filter_info mac_info;
331 : : };
332 : :
333 : : TAILQ_HEAD(i40e_vsi_list_head, i40e_vsi_list);
334 : :
335 : : struct i40e_vsi;
336 : :
337 : : /* VSI list structure */
338 : : struct i40e_vsi_list {
339 : : TAILQ_ENTRY(i40e_vsi_list) list;
340 : : struct i40e_vsi *vsi;
341 : : };
342 : :
343 : : struct i40e_rx_queue;
344 : : struct i40e_tx_queue;
345 : :
346 : : /* Bandwidth limit information */
347 : : struct i40e_bw_info {
348 : : uint16_t bw_limit; /* BW Limit (0 = disabled) */
349 : : uint8_t bw_max; /* Max BW limit if enabled */
350 : :
351 : : /* Relative credits within same TC with respect to other VSIs or Comps */
352 : : uint8_t bw_ets_share_credits[I40E_MAX_TRAFFIC_CLASS];
353 : : /* Bandwidth limit per TC */
354 : : uint16_t bw_ets_credits[I40E_MAX_TRAFFIC_CLASS];
355 : : /* Max bandwidth limit per TC */
356 : : uint8_t bw_ets_max[I40E_MAX_TRAFFIC_CLASS];
357 : : };
358 : :
359 : : /* Structure that defines a VEB */
360 : : struct i40e_veb {
361 : : struct i40e_vsi_list_head head;
362 : : struct i40e_vsi *associate_vsi; /* Associate VSI who owns the VEB */
363 : : struct i40e_pf *associate_pf; /* Associate PF who owns the VEB */
364 : : uint16_t seid; /* The seid of VEB itself */
365 : : uint16_t uplink_seid; /* The uplink seid of this VEB */
366 : : uint16_t stats_idx;
367 : : struct i40e_eth_stats stats;
368 : : uint8_t enabled_tc; /* The traffic class enabled */
369 : : uint8_t strict_prio_tc; /* bit map of TCs set to strict priority mode */
370 : : struct i40e_bw_info bw_info; /* VEB bandwidth information */
371 : : };
372 : :
373 : : /* i40e MACVLAN filter structure */
374 : : struct i40e_macvlan_filter {
375 : : struct rte_ether_addr macaddr;
376 : : enum i40e_mac_filter_type filter_type;
377 : : uint16_t vlan_id;
378 : : };
379 : :
380 : : /*
381 : : * Structure that defines a VSI, associated with a adapter.
382 : : */
383 : : struct i40e_vsi {
384 : : struct i40e_adapter *adapter; /* Backreference to associated adapter */
385 : : struct i40e_aqc_vsi_properties_data info; /* VSI properties */
386 : :
387 : : struct i40e_eth_stats eth_stats_offset;
388 : : struct i40e_eth_stats eth_stats;
389 : : /*
390 : : * When drivers loaded, only a default main VSI exists. In case new VSI
391 : : * needs to add, HW needs to know the layout that VSIs are organized.
392 : : * Besides that, VSI isan element and can't switch packets, which needs
393 : : * to add new component VEB to perform switching. So, a new VSI needs
394 : : * to specify the uplink VSI (Parent VSI) before created. The
395 : : * uplink VSI will check whether it had a VEB to switch packets. If no,
396 : : * it will try to create one. Then, uplink VSI will move the new VSI
397 : : * into its' sib_vsi_list to manage all the downlink VSI.
398 : : * sib_vsi_list: the VSI list that shared the same uplink VSI.
399 : : * parent_vsi : the uplink VSI. It's NULL for main VSI.
400 : : * veb : the VEB associates with the VSI.
401 : : */
402 : : struct i40e_vsi_list sib_vsi_list; /* sibling vsi list */
403 : : struct i40e_vsi *parent_vsi;
404 : : struct i40e_veb *veb; /* Associated veb, could be null */
405 : : struct i40e_veb *floating_veb; /* Associated floating veb */
406 : : bool offset_loaded;
407 : : enum i40e_vsi_type type; /* VSI types */
408 : : uint16_t vlan_num; /* Total VLAN number */
409 : : uint16_t mac_num; /* Total mac number */
410 : : uint32_t vfta[I40E_VFTA_SIZE]; /* VLAN bitmap */
411 : : struct i40e_mac_filter_list mac_list; /* macvlan filter list */
412 : : /* specific VSI-defined parameters, SRIOV stored the vf_id */
413 : : uint32_t user_param;
414 : : uint16_t seid; /* The seid of VSI itself */
415 : : uint16_t uplink_seid; /* The uplink seid of this VSI */
416 : : uint16_t nb_qps; /* Number of queue pairs VSI can occupy */
417 : : uint16_t nb_used_qps; /* Number of queue pairs VSI uses */
418 : : uint16_t max_macaddrs; /* Maximum number of MAC addresses */
419 : : uint16_t base_queue; /* The first queue index of this VSI */
420 : : /*
421 : : * The offset to visit VSI related register, assigned by HW when
422 : : * creating VSI
423 : : */
424 : : uint16_t vsi_id;
425 : : uint16_t msix_intr; /* The MSIX interrupt binds to VSI */
426 : : uint16_t nb_msix; /* The max number of msix vector */
427 : : uint8_t enabled_tc; /* The traffic class enabled */
428 : : uint8_t vlan_anti_spoof_on; /* The VLAN anti-spoofing enabled */
429 : : uint8_t vlan_filter_on; /* The VLAN filter enabled */
430 : : struct i40e_bw_info bw_info; /* VSI bandwidth information */
431 : : uint64_t prev_rx_bytes;
432 : : uint64_t prev_tx_bytes;
433 : : };
434 : :
435 : : struct pool_entry {
436 : : LIST_ENTRY(pool_entry) next;
437 : : uint16_t base;
438 : : uint16_t len;
439 : : };
440 : :
441 : : LIST_HEAD(res_list, pool_entry);
442 : :
443 : : struct i40e_res_pool_info {
444 : : uint32_t base; /* Resource start index */
445 : : uint32_t num_alloc; /* Allocated resource number */
446 : : uint32_t num_free; /* Total available resource number */
447 : : struct res_list alloc_list; /* Allocated resource list */
448 : : struct res_list free_list; /* Available resource list */
449 : : };
450 : :
451 : : enum I40E_VF_STATE {
452 : : I40E_VF_INACTIVE = 0,
453 : : I40E_VF_INRESET,
454 : : I40E_VF_ININIT,
455 : : I40E_VF_ACTIVE,
456 : : };
457 : :
458 : : /*
459 : : * Structure to store private data for PF host.
460 : : */
461 : : struct i40e_pf_vf {
462 : : struct i40e_pf *pf;
463 : : struct i40e_vsi *vsi;
464 : : enum I40E_VF_STATE state; /* The number of queue pairs available */
465 : : uint16_t vf_idx; /* VF index in pf->vfs */
466 : : uint16_t lan_nb_qps; /* Actual queues allocated */
467 : : uint16_t reset_cnt; /* Total vf reset times */
468 : : struct rte_ether_addr mac_addr; /* Default MAC address */
469 : : /* version of the virtchnl from VF */
470 : : struct virtchnl_version_info version;
471 : : uint32_t request_caps; /* offload caps requested from VF */
472 : : uint64_t num_mdd_events; /* num of mdd events detected */
473 : :
474 : : /*
475 : : * Variables for store the arrival timestamp of VF messages.
476 : : * If the timestamp of latest message stored at
477 : : * `msg_timestamps[index % max]` then the timestamp of
478 : : * earliest message stored at `msg_time[(index + 1) % max]`.
479 : : * When a new message come, the timestamp of this message
480 : : * will be stored at `msg_timestamps[(index + 1) % max]` and the
481 : : * earliest message timestamp is at
482 : : * `msg_timestamps[(index + 2) % max]` now...
483 : : */
484 : : uint32_t msg_index;
485 : : uint64_t *msg_timestamps;
486 : :
487 : : /* cycle of stop ignoring VF message */
488 : : uint64_t ignore_end_cycle;
489 : : };
490 : :
491 : : /*
492 : : * Structure to store private data for flow control.
493 : : */
494 : : struct i40e_fc_conf {
495 : : uint16_t pause_time; /* Flow control pause timer */
496 : : /* FC high water 0-7 for pfc and 8 for lfc unit:kilobytes */
497 : : uint32_t high_water[I40E_MAX_TRAFFIC_CLASS + 1];
498 : : /* FC low water 0-7 for pfc and 8 for lfc unit:kilobytes */
499 : : uint32_t low_water[I40E_MAX_TRAFFIC_CLASS + 1];
500 : : };
501 : :
502 : : /*
503 : : * Structure to store private data for VMDQ instance
504 : : */
505 : : struct i40e_vmdq_info {
506 : : struct i40e_pf *pf;
507 : : struct i40e_vsi *vsi;
508 : : };
509 : :
510 : : #define I40E_FDIR_MAX_FLEXLEN 16 /**< Max length of flexbytes. */
511 : : #define I40E_MAX_FLX_SOURCE_OFF 480
512 : : #define NONUSE_FLX_PIT_DEST_OFF 63
513 : : #define NONUSE_FLX_PIT_FSIZE 1
514 : : #define I40E_FLX_OFFSET_IN_FIELD_VECTOR 50
515 : : #define MK_FLX_PIT(src_offset, fsize, dst_offset) ( \
516 : : (((src_offset) << I40E_PRTQF_FLX_PIT_SOURCE_OFF_SHIFT) & \
517 : : I40E_PRTQF_FLX_PIT_SOURCE_OFF_MASK) | \
518 : : (((fsize) << I40E_PRTQF_FLX_PIT_FSIZE_SHIFT) & \
519 : : I40E_PRTQF_FLX_PIT_FSIZE_MASK) | \
520 : : ((((dst_offset) == NONUSE_FLX_PIT_DEST_OFF ? \
521 : : NONUSE_FLX_PIT_DEST_OFF : \
522 : : ((dst_offset) + I40E_FLX_OFFSET_IN_FIELD_VECTOR)) << \
523 : : I40E_PRTQF_FLX_PIT_DEST_OFF_SHIFT) & \
524 : : I40E_PRTQF_FLX_PIT_DEST_OFF_MASK))
525 : : #define I40E_WORD(hi, lo) (uint16_t)((((hi) << 8) & 0xFF00) | ((lo) & 0xFF))
526 : : #define I40E_FLEX_WORD_MASK(off) (0x80 >> (off))
527 : : #define I40E_FDIR_IPv6_TC_OFFSET 20
528 : :
529 : : /* A structure used to define the input for GTP flow */
530 : : struct i40e_gtp_flow {
531 : : struct rte_eth_udpv4_flow udp; /* IPv4 UDP fields to match. */
532 : : uint8_t msg_type; /* Message type. */
533 : : uint32_t teid; /* TEID in big endian. */
534 : : };
535 : :
536 : : /* A structure used to define the input for GTP IPV4 flow */
537 : : struct i40e_gtp_ipv4_flow {
538 : : struct i40e_gtp_flow gtp;
539 : : struct rte_eth_ipv4_flow ip4;
540 : : };
541 : :
542 : : /* A structure used to define the input for GTP IPV6 flow */
543 : : struct i40e_gtp_ipv6_flow {
544 : : struct i40e_gtp_flow gtp;
545 : : struct rte_eth_ipv6_flow ip6;
546 : : };
547 : :
548 : : /* A structure used to define the input for ESP IPV4 flow */
549 : : struct i40e_esp_ipv4_flow {
550 : : struct rte_eth_ipv4_flow ipv4;
551 : : uint32_t spi; /* SPI in big endian. */
552 : : };
553 : :
554 : : /* A structure used to define the input for ESP IPV6 flow */
555 : : struct i40e_esp_ipv6_flow {
556 : : struct rte_eth_ipv6_flow ipv6;
557 : : uint32_t spi; /* SPI in big endian. */
558 : : };
559 : : /* A structure used to define the input for ESP IPV4 UDP flow */
560 : : struct i40e_esp_ipv4_udp_flow {
561 : : struct rte_eth_udpv4_flow udp;
562 : : uint32_t spi; /* SPI in big endian. */
563 : : };
564 : :
565 : : /* A structure used to define the input for ESP IPV6 UDP flow */
566 : : struct i40e_esp_ipv6_udp_flow {
567 : : struct rte_eth_udpv6_flow udp;
568 : : uint32_t spi; /* SPI in big endian. */
569 : : };
570 : :
571 : : /* A structure used to define the input for raw type flow */
572 : : struct i40e_raw_flow {
573 : : uint16_t pctype;
574 : : void *packet;
575 : : uint32_t length;
576 : : };
577 : :
578 : : /* A structure used to define the input for L2TPv3 over IPv4 flow */
579 : : struct i40e_ipv4_l2tpv3oip_flow {
580 : : struct rte_eth_ipv4_flow ip4;
581 : : uint32_t session_id; /* Session ID in big endian. */
582 : : };
583 : :
584 : : /* A structure used to define the input for L2TPv3 over IPv6 flow */
585 : : struct i40e_ipv6_l2tpv3oip_flow {
586 : : struct rte_eth_ipv6_flow ip6;
587 : : uint32_t session_id; /* Session ID in big endian. */
588 : : };
589 : :
590 : : /* A structure used to define the input for l2 dst type flow */
591 : : struct i40e_l2_flow {
592 : : struct rte_ether_addr dst;
593 : : struct rte_ether_addr src;
594 : : uint16_t ether_type; /**< Ether type in big endian */
595 : : };
596 : :
597 : : /*
598 : : * A union contains the inputs for all types of flow
599 : : * items in flows need to be in big endian
600 : : */
601 : : union i40e_fdir_flow {
602 : : struct i40e_l2_flow l2_flow;
603 : : struct rte_eth_udpv4_flow udp4_flow;
604 : : struct rte_eth_tcpv4_flow tcp4_flow;
605 : : struct rte_eth_sctpv4_flow sctp4_flow;
606 : : struct rte_eth_ipv4_flow ip4_flow;
607 : : struct rte_eth_udpv6_flow udp6_flow;
608 : : struct rte_eth_tcpv6_flow tcp6_flow;
609 : : struct rte_eth_sctpv6_flow sctp6_flow;
610 : : struct rte_eth_ipv6_flow ipv6_flow;
611 : : struct i40e_gtp_flow gtp_flow;
612 : : struct i40e_gtp_ipv4_flow gtp_ipv4_flow;
613 : : struct i40e_gtp_ipv6_flow gtp_ipv6_flow;
614 : : struct i40e_raw_flow raw_flow;
615 : : struct i40e_ipv4_l2tpv3oip_flow ip4_l2tpv3oip_flow;
616 : : struct i40e_ipv6_l2tpv3oip_flow ip6_l2tpv3oip_flow;
617 : : struct i40e_esp_ipv4_flow esp_ipv4_flow;
618 : : struct i40e_esp_ipv6_flow esp_ipv6_flow;
619 : : struct i40e_esp_ipv4_udp_flow esp_ipv4_udp_flow;
620 : : struct i40e_esp_ipv6_udp_flow esp_ipv6_udp_flow;
621 : : };
622 : :
623 : : enum i40e_fdir_ip_type {
624 : : I40E_FDIR_IPTYPE_IPV4,
625 : : I40E_FDIR_IPTYPE_IPV6,
626 : : };
627 : :
628 : : /**
629 : : * Structure to store flex pit for flow diretor.
630 : : */
631 : : struct i40e_fdir_flex_pit {
632 : : uint8_t src_offset; /* offset in words from the beginning of payload */
633 : : uint8_t size; /* size in words */
634 : : uint8_t dst_offset; /* offset in words of flexible payload */
635 : : };
636 : :
637 : : /* A structure used to contain extend input of flow */
638 : : struct i40e_fdir_flow_ext {
639 : : uint16_t vlan_tci;
640 : : uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
641 : : /* It is filled by the flexible payload to match. */
642 : : uint8_t flex_mask[I40E_FDIR_MAX_FLEX_LEN];
643 : : uint8_t raw_id;
644 : : uint8_t is_vf; /* 1 for VF, 0 for port dev */
645 : : uint16_t dst_id; /* VF ID, available when is_vf is 1*/
646 : : uint64_t input_set;
647 : : bool inner_ip; /* If there is inner ip */
648 : : enum i40e_fdir_ip_type iip_type; /* ip type for inner ip */
649 : : enum i40e_fdir_ip_type oip_type; /* ip type for outer ip */
650 : : bool customized_pctype; /* If customized pctype is used */
651 : : bool pkt_template; /* If raw packet template is used */
652 : : bool is_udp; /* ipv4|ipv6 udp flow */
653 : : enum i40e_flxpld_layer_idx layer_idx;
654 : : struct i40e_fdir_flex_pit flex_pit[I40E_MAX_FLXPLD_LAYER * I40E_MAX_FLXPLD_FIED];
655 : : bool is_flex_flow;
656 : : };
657 : :
658 : : /* A structure used to define the input for a flow director filter entry */
659 : : struct i40e_fdir_input {
660 : : enum i40e_filter_pctype pctype;
661 : : union i40e_fdir_flow flow;
662 : : /* Flow fields to match, dependent on flow_type */
663 : : struct i40e_fdir_flow_ext flow_ext;
664 : : /* Additional fields to match */
665 : : };
666 : :
667 : : /* Behavior will be taken if FDIR match */
668 : : enum i40e_fdir_behavior {
669 : : I40E_FDIR_ACCEPT = 0,
670 : : I40E_FDIR_REJECT,
671 : : I40E_FDIR_PASSTHRU,
672 : : };
673 : :
674 : : /* Flow director report status
675 : : * It defines what will be reported if FDIR entry is matched.
676 : : */
677 : : enum i40e_fdir_status {
678 : : I40E_FDIR_NO_REPORT_STATUS = 0, /* Report nothing. */
679 : : I40E_FDIR_REPORT_ID, /* Only report FD ID. */
680 : : I40E_FDIR_REPORT_ID_FLEX_4, /* Report FD ID and 4 flex bytes. */
681 : : I40E_FDIR_REPORT_FLEX_8, /* Report 8 flex bytes. */
682 : : };
683 : :
684 : : /* A structure used to define an action when match FDIR packet filter. */
685 : : struct i40e_fdir_action {
686 : : uint16_t rx_queue; /* Queue assigned to if FDIR match. */
687 : : enum i40e_fdir_behavior behavior; /* Behavior will be taken */
688 : : enum i40e_fdir_status report_status; /* Status report option */
689 : : /* If report_status is I40E_FDIR_REPORT_ID_FLEX_4 or
690 : : * I40E_FDIR_REPORT_FLEX_8, flex_off specifies where the reported
691 : : * flex bytes start from in flexible payload.
692 : : */
693 : : uint8_t flex_off;
694 : : };
695 : :
696 : : /* A structure used to define the flow director filter entry by filter_ctrl API
697 : : * It supports RTE_ETH_FILTER_FDIR data representation.
698 : : */
699 : : struct i40e_fdir_filter_conf {
700 : : uint32_t soft_id;
701 : : /* ID, an unique value is required when deal with FDIR entry */
702 : : struct i40e_fdir_input input; /* Input set */
703 : : struct i40e_fdir_action action; /* Action taken when match */
704 : : };
705 : :
706 : : struct i40e_fdir_flex_mask {
707 : : uint8_t word_mask; /**< Bit i enables word i of flexible payload */
708 : : uint8_t nb_bitmask;
709 : : struct {
710 : : uint8_t offset;
711 : : uint16_t mask;
712 : : } bitmask[I40E_FDIR_BITMASK_NUM_WORD];
713 : : };
714 : :
715 : : #define I40E_FILTER_PCTYPE_INVALID 0
716 : : #define I40E_FILTER_PCTYPE_MAX 64
717 : : #define I40E_MAX_FDIR_FILTER_NUM (1024 * 8)
718 : :
719 : : struct i40e_fdir_filter {
720 : : TAILQ_ENTRY(i40e_fdir_filter) rules;
721 : : struct i40e_fdir_filter_conf fdir;
722 : : };
723 : :
724 : : /* fdir memory pool entry */
725 : : struct i40e_fdir_entry {
726 : : struct rte_flow flow;
727 : : uint32_t idx;
728 : : };
729 : :
730 : : /* pre-allocated fdir memory pool */
731 : : struct i40e_fdir_flow_pool {
732 : : /* a bitmap to manage the fdir pool */
733 : : struct rte_bitmap *bitmap;
734 : : /* the size the pool is pf->fdir->fdir_space_size */
735 : : struct i40e_fdir_entry *pool;
736 : : };
737 : :
738 : : #define FLOW_TO_FLOW_BITMAP(f) \
739 : : container_of((f), struct i40e_fdir_entry, flow)
740 : :
741 : : TAILQ_HEAD(i40e_fdir_filter_list, i40e_fdir_filter);
742 : : /*
743 : : * A structure used to define fields of a FDIR related info.
744 : : */
745 : : struct i40e_fdir_info {
746 : : struct i40e_vsi *fdir_vsi; /* pointer to fdir VSI structure */
747 : : uint16_t match_counter_index; /* Statistic counter index used for fdir*/
748 : : struct i40e_tx_queue *txq;
749 : : struct i40e_rx_queue *rxq;
750 : : void *prg_pkt[I40E_FDIR_PRG_PKT_CNT]; /* memory for fdir program packet */
751 : : uint64_t dma_addr[I40E_FDIR_PRG_PKT_CNT]; /* physic address of packet memory*/
752 : : /*
753 : : * txq available buffer counter, indicates how many available buffers
754 : : * for fdir programming, initialized as I40E_FDIR_PRG_PKT_CNT
755 : : */
756 : : int txq_available_buf_count;
757 : :
758 : : /* input set bits for each pctype */
759 : : uint64_t input_set[I40E_FILTER_PCTYPE_MAX];
760 : : /*
761 : : * the rule how bytes stream is extracted as flexible payload
762 : : * for each payload layer, the setting can up to three elements
763 : : */
764 : : struct i40e_fdir_flex_pit flex_set[I40E_MAX_FLXPLD_LAYER * I40E_MAX_FLXPLD_FIED];
765 : : struct i40e_fdir_flex_mask flex_mask[I40E_FILTER_PCTYPE_MAX];
766 : :
767 : : struct i40e_fdir_filter_list fdir_list;
768 : : struct i40e_fdir_filter **hash_map;
769 : : struct rte_hash *hash_table;
770 : : /* An array to store the inserted rules input */
771 : : struct i40e_fdir_filter *fdir_filter_array;
772 : :
773 : : /*
774 : : * Priority ordering at filter invalidation(destroying a flow) between
775 : : * "best effort" space and "guaranteed" space.
776 : : *
777 : : * 0 = At filter invalidation, the hardware first tries to increment the
778 : : * "best effort" space. The "guaranteed" space is incremented only when
779 : : * the global "best effort" space is at it max value or the "best effort"
780 : : * space of the PF is at its max value.
781 : : * 1 = At filter invalidation, the hardware first tries to increment its
782 : : * "guaranteed" space. The "best effort" space is incremented only when
783 : : * it is already at its max value.
784 : : */
785 : : uint32_t fdir_invalprio;
786 : : /* the total size of the fdir, this number is the sum of the guaranteed +
787 : : * shared space
788 : : */
789 : : uint32_t fdir_space_size;
790 : : /* the actual number of the fdir rules in hardware, initialized as 0 */
791 : : uint32_t fdir_actual_cnt;
792 : : /* the free guaranteed space of the fdir */
793 : : uint32_t fdir_guarantee_free_space;
794 : : /* the fdir total guaranteed space */
795 : : uint32_t fdir_guarantee_total_space;
796 : : /* the pre-allocated pool of the rte_flow */
797 : : struct i40e_fdir_flow_pool fdir_flow_pool;
798 : :
799 : : /* Mark if flex pit and mask is set */
800 : : bool flex_pit_flag[I40E_MAX_FLXPLD_LAYER];
801 : : bool flex_mask_flag[I40E_FILTER_PCTYPE_MAX];
802 : :
803 : : uint32_t flow_count[I40E_FILTER_PCTYPE_MAX];
804 : :
805 : : uint32_t flex_flow_count[I40E_MAX_FLXPLD_LAYER];
806 : : };
807 : :
808 : : /* Ethertype filter number HW supports */
809 : : #define I40E_MAX_ETHERTYPE_FILTER_NUM 768
810 : :
811 : : /* Ethertype filter struct */
812 : : struct i40e_ethertype_filter_input {
813 : : struct rte_ether_addr mac_addr; /* Mac address to match */
814 : : uint16_t ether_type; /* Ether type to match */
815 : : };
816 : :
817 : : struct i40e_ethertype_filter {
818 : : TAILQ_ENTRY(i40e_ethertype_filter) rules;
819 : : struct i40e_ethertype_filter_input input;
820 : : uint16_t flags; /* Flags from RTE_ETHTYPE_FLAGS_* */
821 : : uint16_t queue; /* Queue assigned to when match */
822 : : };
823 : :
824 : : TAILQ_HEAD(i40e_ethertype_filter_list, i40e_ethertype_filter);
825 : :
826 : : struct i40e_ethertype_rule {
827 : : struct i40e_ethertype_filter_list ethertype_list;
828 : : struct i40e_ethertype_filter **hash_map;
829 : : struct rte_hash *hash_table;
830 : : };
831 : :
832 : : /* queue region info */
833 : : struct i40e_queue_region_info {
834 : : /* the region id for this configuration */
835 : : uint8_t region_id;
836 : : /* the start queue index for this region */
837 : : uint8_t queue_start_index;
838 : : /* the total queue number of this queue region */
839 : : uint8_t queue_num;
840 : : /* the total number of user priority for this region */
841 : : uint8_t user_priority_num;
842 : : /* the packet's user priority for this region */
843 : : uint8_t user_priority[I40E_MAX_USER_PRIORITY];
844 : : /* the total number of flowtype for this region */
845 : : uint8_t flowtype_num;
846 : : /**
847 : : * the pctype or hardware flowtype of packet,
848 : : * the specific index for each type has been defined
849 : : * in file i40e_type.h as enum i40e_filter_pctype.
850 : : */
851 : : uint8_t hw_flowtype[I40E_FILTER_PCTYPE_MAX];
852 : : };
853 : :
854 : : struct i40e_queue_regions {
855 : : /* the total number of queue region for this port */
856 : : uint16_t queue_region_number;
857 : : struct i40e_queue_region_info region[I40E_REGION_MAX_INDEX + 1];
858 : : };
859 : :
860 : : struct i40e_rss_pattern_info {
861 : : uint8_t action_flag;
862 : : uint64_t types;
863 : : };
864 : :
865 : : /* Tunnel filter number HW supports */
866 : : #define I40E_MAX_TUNNEL_FILTER_NUM 400
867 : :
868 : : #define I40E_AQC_REPLACE_CLOUD_CMD_INPUT_FV_TEID_WORD0 44
869 : : #define I40E_AQC_REPLACE_CLOUD_CMD_INPUT_FV_TEID_WORD1 45
870 : : #define I40E_AQC_REPLACE_CLOUD_CMD_INPUT_FV_SRC_PORT 29
871 : : #define I40E_AQC_REPLACE_CLOUD_CMD_INPUT_FV_DST_PORT 30
872 : : #define I40E_AQC_ADD_CLOUD_TNL_TYPE_MPLSOUDP 8
873 : : #define I40E_AQC_ADD_CLOUD_TNL_TYPE_MPLSOGRE 9
874 : : #define I40E_AQC_ADD_CLOUD_FILTER_0X10 0x10
875 : : #define I40E_AQC_ADD_CLOUD_FILTER_0X11 0x11
876 : : #define I40E_AQC_ADD_CLOUD_FILTER_0X12 0x12
877 : : #define I40E_AQC_ADD_L1_FILTER_0X10 0x10
878 : : #define I40E_AQC_ADD_L1_FILTER_0X11 0x11
879 : : #define I40E_AQC_ADD_L1_FILTER_0X12 0x12
880 : : #define I40E_AQC_ADD_L1_FILTER_0X13 0x13
881 : : #define I40E_AQC_NEW_TR_21 21
882 : : #define I40E_AQC_NEW_TR_22 22
883 : :
884 : : enum i40e_tunnel_iptype {
885 : : I40E_TUNNEL_IPTYPE_IPV4,
886 : : I40E_TUNNEL_IPTYPE_IPV6,
887 : : };
888 : :
889 : : /* Tunnel filter struct */
890 : : struct i40e_tunnel_filter_input {
891 : : uint8_t outer_mac[6]; /* Outer mac address to match */
892 : : uint8_t inner_mac[6]; /* Inner mac address to match */
893 : : uint16_t inner_vlan; /* Inner vlan address to match */
894 : : enum i40e_tunnel_iptype ip_type;
895 : : uint16_t flags; /* Filter type flag */
896 : : uint32_t tenant_id; /* Tenant id to match */
897 : : uint16_t general_fields[32]; /* Big buffer */
898 : : };
899 : :
900 : : struct i40e_tunnel_filter {
901 : : TAILQ_ENTRY(i40e_tunnel_filter) rules;
902 : : struct i40e_tunnel_filter_input input;
903 : : uint8_t is_to_vf; /* 0 - to PF, 1 - to VF */
904 : : uint16_t vf_id; /* VF id, available when is_to_vf is 1. */
905 : : uint16_t queue; /* Queue assigned to when match */
906 : : };
907 : :
908 : : TAILQ_HEAD(i40e_tunnel_filter_list, i40e_tunnel_filter);
909 : :
910 : : struct i40e_tunnel_rule {
911 : : struct i40e_tunnel_filter_list tunnel_list;
912 : : struct i40e_tunnel_filter **hash_map;
913 : : struct rte_hash *hash_table;
914 : : };
915 : :
916 : : /**
917 : : * Tunnel type.
918 : : */
919 : : enum i40e_tunnel_type {
920 : : I40E_TUNNEL_TYPE_NONE = 0,
921 : : I40E_TUNNEL_TYPE_VXLAN,
922 : : I40E_TUNNEL_TYPE_GENEVE,
923 : : I40E_TUNNEL_TYPE_TEREDO,
924 : : I40E_TUNNEL_TYPE_NVGRE,
925 : : I40E_TUNNEL_TYPE_IP_IN_GRE,
926 : : I40E_L2_TUNNEL_TYPE_E_TAG,
927 : : I40E_TUNNEL_TYPE_MPLSoUDP,
928 : : I40E_TUNNEL_TYPE_MPLSoGRE,
929 : : I40E_TUNNEL_TYPE_QINQ,
930 : : I40E_TUNNEL_TYPE_GTPC,
931 : : I40E_TUNNEL_TYPE_GTPU,
932 : : I40E_TUNNEL_TYPE_ESPoUDP,
933 : : I40E_TUNNEL_TYPE_ESPoIP,
934 : : I40E_CLOUD_TYPE_UDP,
935 : : I40E_CLOUD_TYPE_TCP,
936 : : I40E_CLOUD_TYPE_SCTP,
937 : : I40E_TUNNEL_TYPE_MAX,
938 : : };
939 : :
940 : : /**
941 : : * L4 port type.
942 : : */
943 : : enum i40e_l4_port_type {
944 : : I40E_L4_PORT_TYPE_SRC = 0,
945 : : I40E_L4_PORT_TYPE_DST,
946 : : };
947 : :
948 : : /**
949 : : * Tunneling Packet filter configuration.
950 : : */
951 : : struct i40e_tunnel_filter_conf {
952 : : struct rte_ether_addr outer_mac; /**< Outer MAC address to match. */
953 : : struct rte_ether_addr inner_mac; /**< Inner MAC address to match. */
954 : : uint16_t inner_vlan; /**< Inner VLAN to match. */
955 : : uint32_t outer_vlan; /**< Outer VLAN to match */
956 : : enum i40e_tunnel_iptype ip_type; /**< IP address type. */
957 : : /**
958 : : * Outer destination IP address to match if ETH_TUNNEL_FILTER_OIP
959 : : * is set in filter_type, or inner destination IP address to match
960 : : * if ETH_TUNNEL_FILTER_IIP is set in filter_type.
961 : : */
962 : : union {
963 : : uint32_t ipv4_addr; /**< IPv4 address in big endian. */
964 : : uint32_t ipv6_addr[4]; /**< IPv6 address in big endian. */
965 : : } ip_addr;
966 : : /** Flags from ETH_TUNNEL_FILTER_XX - see above. */
967 : : uint16_t filter_type;
968 : : enum i40e_tunnel_type tunnel_type; /**< Tunnel Type. */
969 : : enum i40e_l4_port_type l4_port_type; /**< L4 Port Type. */
970 : : uint32_t tenant_id; /**< Tenant ID to match. VNI, GRE key... */
971 : : uint16_t queue_id; /**< Queue assigned to if match. */
972 : : uint8_t is_to_vf; /**< 0 - to PF, 1 - to VF */
973 : : uint16_t vf_id; /**< VF id, available when is_to_vf is 1. */
974 : : };
975 : :
976 : : TAILQ_HEAD(i40e_flow_list, rte_flow);
977 : :
978 : : /* Struct to store Traffic Manager shaper profile. */
979 : : struct i40e_tm_shaper_profile {
980 : : TAILQ_ENTRY(i40e_tm_shaper_profile) node;
981 : : uint32_t shaper_profile_id;
982 : : uint32_t reference_count;
983 : : struct rte_tm_shaper_params profile;
984 : : };
985 : :
986 : : TAILQ_HEAD(i40e_shaper_profile_list, i40e_tm_shaper_profile);
987 : :
988 : : /* node type of Traffic Manager */
989 : : enum i40e_tm_node_type {
990 : : I40E_TM_NODE_TYPE_PORT,
991 : : I40E_TM_NODE_TYPE_TC,
992 : : I40E_TM_NODE_TYPE_QUEUE,
993 : : I40E_TM_NODE_TYPE_MAX,
994 : : };
995 : :
996 : : /* Struct to store Traffic Manager node configuration. */
997 : : struct i40e_tm_node {
998 : : TAILQ_ENTRY(i40e_tm_node) node;
999 : : uint32_t id;
1000 : : uint32_t priority;
1001 : : uint32_t weight;
1002 : : uint32_t reference_count;
1003 : : struct i40e_tm_node *parent;
1004 : : struct i40e_tm_shaper_profile *shaper_profile;
1005 : : struct rte_tm_node_params params;
1006 : : };
1007 : :
1008 : : TAILQ_HEAD(i40e_tm_node_list, i40e_tm_node);
1009 : :
1010 : : /* Struct to store all the Traffic Manager configuration. */
1011 : : struct i40e_tm_conf {
1012 : : struct i40e_shaper_profile_list shaper_profile_list;
1013 : : struct i40e_tm_node *root; /* root node - port */
1014 : : struct i40e_tm_node_list tc_list; /* node list for all the TCs */
1015 : : struct i40e_tm_node_list queue_list; /* node list for all the queues */
1016 : : /**
1017 : : * The number of added TC nodes.
1018 : : * It should be no more than the TC number of this port.
1019 : : */
1020 : : uint32_t nb_tc_node;
1021 : : /**
1022 : : * The number of added queue nodes.
1023 : : * It should be no more than the queue number of this port.
1024 : : */
1025 : : uint32_t nb_queue_node;
1026 : : /**
1027 : : * This flag is used to check if APP can change the TM node
1028 : : * configuration.
1029 : : * When it's true, means the configuration is applied to HW,
1030 : : * APP should not change the configuration.
1031 : : * As we don't support on-the-fly configuration, when starting
1032 : : * the port, APP should call the hierarchy_commit API to set this
1033 : : * flag to true. When stopping the port, this flag should be set
1034 : : * to false.
1035 : : */
1036 : : bool committed;
1037 : : };
1038 : :
1039 : : enum i40e_new_pctype {
1040 : : I40E_CUSTOMIZED_GTPC = 0,
1041 : : I40E_CUSTOMIZED_GTPU_IPV4,
1042 : : I40E_CUSTOMIZED_GTPU_IPV6,
1043 : : I40E_CUSTOMIZED_GTPU,
1044 : : I40E_CUSTOMIZED_IPV4_L2TPV3,
1045 : : I40E_CUSTOMIZED_IPV6_L2TPV3,
1046 : : I40E_CUSTOMIZED_ESP_IPV4,
1047 : : I40E_CUSTOMIZED_ESP_IPV6,
1048 : : I40E_CUSTOMIZED_ESP_IPV4_UDP,
1049 : : I40E_CUSTOMIZED_ESP_IPV6_UDP,
1050 : : I40E_CUSTOMIZED_AH_IPV4,
1051 : : I40E_CUSTOMIZED_AH_IPV6,
1052 : : I40E_CUSTOMIZED_MAX,
1053 : : };
1054 : :
1055 : : #define I40E_FILTER_PCTYPE_INVALID 0
1056 : : struct i40e_customized_pctype {
1057 : : enum i40e_new_pctype index; /* Indicate which customized pctype */
1058 : : uint8_t pctype; /* New pctype value */
1059 : : bool valid; /* Check if it's valid */
1060 : : };
1061 : :
1062 : : struct i40e_rte_flow_rss_conf {
1063 : : struct rte_flow_action_rss conf; /**< RSS parameters. */
1064 : :
1065 : : uint8_t key[(I40E_VFQF_HKEY_MAX_INDEX > I40E_PFQF_HKEY_MAX_INDEX ?
1066 : : I40E_VFQF_HKEY_MAX_INDEX : I40E_PFQF_HKEY_MAX_INDEX + 1) *
1067 : : sizeof(uint32_t)]; /**< Hash key. */
1068 : : uint16_t queue[RTE_ETH_RSS_RETA_SIZE_512]; /**< Queues indices to use. */
1069 : :
1070 : : bool symmetric_enable; /**< true, if enable symmetric */
1071 : : uint64_t config_pctypes; /**< All PCTYPES with the flow */
1072 : : uint64_t inset; /**< input sets */
1073 : :
1074 : : uint8_t region_priority; /**< queue region priority */
1075 : : uint8_t region_queue_num; /**< region queue number */
1076 : : uint16_t region_queue_start; /**< region queue start */
1077 : :
1078 : : uint32_t misc_reset_flags;
1079 : : #define I40E_HASH_FLOW_RESET_FLAG_FUNC 0x01UL
1080 : : #define I40E_HASH_FLOW_RESET_FLAG_KEY 0x02UL
1081 : : #define I40E_HASH_FLOW_RESET_FLAG_QUEUE 0x04UL
1082 : : #define I40E_HASH_FLOW_RESET_FLAG_REGION 0x08UL
1083 : :
1084 : : /**< All PCTYPES that reset with the flow */
1085 : : uint64_t reset_config_pctypes;
1086 : : /**< Symmetric function should reset on PCTYPES */
1087 : : uint64_t reset_symmetric_pctypes;
1088 : : };
1089 : :
1090 : : /* RSS filter list structure */
1091 : : struct i40e_rss_filter {
1092 : : TAILQ_ENTRY(i40e_rss_filter) next;
1093 : : struct i40e_rte_flow_rss_conf rss_filter_info;
1094 : : };
1095 : :
1096 : : TAILQ_HEAD(i40e_rss_conf_list, i40e_rss_filter);
1097 : :
1098 : : struct i40e_vf_msg_cfg {
1099 : : /* maximal VF message during a statistic period */
1100 : : uint32_t max_msg;
1101 : :
1102 : : /* statistic period, in second */
1103 : : uint32_t period;
1104 : : /*
1105 : : * If message statistics from a VF exceed the maximal limitation,
1106 : : * the PF will ignore any new message from that VF for
1107 : : * 'ignore_second' time.
1108 : : */
1109 : : uint32_t ignore_second;
1110 : : };
1111 : :
1112 : : struct i40e_mbuf_stats {
1113 : : uint64_t tx_pkt_errors;
1114 : : };
1115 : :
1116 : : /*
1117 : : * Structure to store private data specific for PF instance.
1118 : : */
1119 : : struct i40e_pf {
1120 : : struct i40e_adapter *adapter; /* The adapter this PF associate to */
1121 : : struct i40e_vsi *main_vsi; /* pointer to main VSI structure */
1122 : : uint16_t mac_seid; /* The seid of the MAC of this PF */
1123 : : uint16_t main_vsi_seid; /* The seid of the main VSI */
1124 : : uint16_t max_num_vsi;
1125 : : struct i40e_res_pool_info qp_pool; /*Queue pair pool */
1126 : : struct i40e_res_pool_info msix_pool; /* MSIX interrupt pool */
1127 : :
1128 : : struct i40e_hw_port_stats stats_offset;
1129 : : struct i40e_hw_port_stats stats;
1130 : : struct i40e_mbuf_stats mbuf_stats;
1131 : : u64 rx_err1; /* rxerr1 */
1132 : : u64 rx_err1_offset;
1133 : :
1134 : : /* internal packet statistics, it should be excluded from the total */
1135 : : struct i40e_eth_stats internal_stats_offset;
1136 : : struct i40e_eth_stats internal_stats;
1137 : : bool offset_loaded;
1138 : :
1139 : : struct rte_eth_dev_data *dev_data; /* Pointer to the device data */
1140 : : struct rte_ether_addr dev_addr; /* PF device mac address */
1141 : : uint64_t flags; /* PF feature flags */
1142 : : /* All kinds of queue pair setting for different VSIs */
1143 : : struct i40e_pf_vf *vfs;
1144 : : uint16_t vf_num;
1145 : : /* Each of below queue pairs should be power of 2 since it's the
1146 : : precondition after TC configuration applied */
1147 : : uint16_t lan_nb_qp_max;
1148 : : uint16_t lan_nb_qps; /* The number of queue pairs of LAN */
1149 : : uint16_t lan_qp_offset;
1150 : : uint16_t vmdq_nb_qp_max;
1151 : : uint16_t vmdq_nb_qps; /* The number of queue pairs of VMDq */
1152 : : uint16_t vmdq_qp_offset;
1153 : : uint16_t vf_nb_qp_max;
1154 : : uint16_t vf_nb_qps; /* The number of queue pairs of VF */
1155 : : uint16_t vf_qp_offset;
1156 : : uint16_t fdir_nb_qps; /* The number of queue pairs of Flow Director */
1157 : : uint16_t fdir_qp_offset;
1158 : :
1159 : : uint16_t hash_lut_size; /* The size of hash lookup table */
1160 : : bool hash_filter_enabled;
1161 : : uint64_t hash_enabled_queues;
1162 : : /* input set bits for each pctype */
1163 : : uint64_t hash_input_set[I40E_FILTER_PCTYPE_MAX];
1164 : : /* store VXLAN UDP ports */
1165 : : uint16_t vxlan_ports[I40E_MAX_PF_UDP_OFFLOAD_PORTS];
1166 : : uint16_t vxlan_bitmap; /* Vxlan bit mask */
1167 : :
1168 : : /* VMDQ related info */
1169 : : uint16_t max_nb_vmdq_vsi; /* Max number of VMDQ VSIs supported */
1170 : : uint16_t nb_cfg_vmdq_vsi; /* number of VMDQ VSIs configured */
1171 : : struct i40e_vmdq_info *vmdq;
1172 : :
1173 : : struct i40e_fdir_info fdir; /* flow director info */
1174 : : struct i40e_ethertype_rule ethertype; /* Ethertype filter rule */
1175 : : struct i40e_tunnel_rule tunnel; /* Tunnel filter rule */
1176 : : struct i40e_rss_conf_list rss_config_list; /* RSS rule list */
1177 : : struct i40e_queue_regions queue_region; /* queue region info */
1178 : : struct i40e_fc_conf fc_conf; /* Flow control conf */
1179 : : bool floating_veb; /* The flag to use the floating VEB */
1180 : : /* The floating enable flag for the specific VF */
1181 : : bool floating_veb_list[I40E_MAX_VF];
1182 : : struct i40e_flow_list flow_list;
1183 : : bool mpls_replace_flag; /* 1 - MPLS filter replace is done */
1184 : : bool gtp_replace_flag; /* 1 - GTP-C/U filter replace is done */
1185 : : bool qinq_replace_flag; /* QINQ filter replace is done */
1186 : : /* l4 port flag */
1187 : : bool sport_replace_flag; /* Source port replace is done */
1188 : : bool dport_replace_flag; /* Destination port replace is done */
1189 : : struct i40e_tm_conf tm_conf;
1190 : : bool support_multi_driver; /* 1 - support multiple driver */
1191 : :
1192 : : /* Dynamic Device Personalization */
1193 : : bool gtp_support; /* 1 - support GTP-C and GTP-U */
1194 : : bool esp_support; /* 1 - support ESP SPI */
1195 : : /* customer customized pctype */
1196 : : struct i40e_customized_pctype customized_pctype[I40E_CUSTOMIZED_MAX];
1197 : : /* Switch Domain Id */
1198 : : uint16_t switch_domain_id;
1199 : :
1200 : : /* When firmware > 8.3, the enable flag for outer VLAN processing */
1201 : : bool fw8_3gt;
1202 : :
1203 : : struct i40e_vf_msg_cfg vf_msg_cfg;
1204 : : uint64_t prev_rx_bytes;
1205 : : uint64_t prev_tx_bytes;
1206 : : uint64_t internal_prev_rx_bytes;
1207 : : uint64_t internal_prev_tx_bytes;
1208 : : };
1209 : :
1210 : : enum pending_msg {
1211 : : PFMSG_LINK_CHANGE = 0x1,
1212 : : PFMSG_RESET_IMPENDING = 0x2,
1213 : : PFMSG_DRIVER_CLOSE = 0x4,
1214 : : };
1215 : :
1216 : : struct i40e_vsi_vlan_pvid_info {
1217 : : uint16_t on; /* Enable or disable pvid */
1218 : : union {
1219 : : uint16_t pvid; /* Valid in case 'on' is set to set pvid */
1220 : : struct {
1221 : : /* Valid in case 'on' is cleared. 'tagged' will reject tagged packets,
1222 : : * while 'untagged' will reject untagged packets.
1223 : : */
1224 : : uint8_t tagged;
1225 : : uint8_t untagged;
1226 : : } reject;
1227 : : } config;
1228 : : };
1229 : :
1230 : : #define I40E_MAX_PKT_TYPE 256
1231 : : #define I40E_FLOW_TYPE_MAX 64
1232 : :
1233 : : #define I40E_MBUF_CHECK_F_TX_MBUF (1ULL << 0)
1234 : : #define I40E_MBUF_CHECK_F_TX_SIZE (1ULL << 1)
1235 : : #define I40E_MBUF_CHECK_F_TX_SEGMENT (1ULL << 2)
1236 : : #define I40E_MBUF_CHECK_F_TX_OFFLOAD (1ULL << 3)
1237 : :
1238 : : /*
1239 : : * Structure to store private data for each PF/VF instance.
1240 : : */
1241 : : struct i40e_adapter {
1242 : : /* Common for both PF and VF */
1243 : : struct i40e_hw hw;
1244 : :
1245 : : /* Specific for PF */
1246 : : struct i40e_pf pf;
1247 : :
1248 : : /* For vector PMD */
1249 : : bool rx_bulk_alloc_allowed;
1250 : : bool rx_vec_allowed;
1251 : : bool tx_simple_allowed;
1252 : : bool tx_vec_allowed;
1253 : :
1254 : : uint64_t mbuf_check; /* mbuf check flags. */
1255 : : uint16_t max_pkt_len; /* Maximum packet length */
1256 : : eth_tx_burst_t tx_pkt_burst;
1257 : :
1258 : : /* For PTP */
1259 : : struct rte_timecounter systime_tc;
1260 : : struct rte_timecounter rx_tstamp_tc;
1261 : : struct rte_timecounter tx_tstamp_tc;
1262 : :
1263 : : /* ptype mapping table */
1264 : : uint32_t ptype_tbl[I40E_MAX_PKT_TYPE] __rte_cache_min_aligned;
1265 : : /* flow type to pctype mapping table */
1266 : : uint64_t pctypes_tbl[I40E_FLOW_TYPE_MAX] __rte_cache_min_aligned;
1267 : : uint64_t flow_types_mask;
1268 : : uint64_t pctypes_mask;
1269 : :
1270 : : /* For RSS reta table update */
1271 : : uint8_t rss_reta_updated;
1272 : : #ifdef RTE_ARCH_X86
1273 : : bool rx_use_avx2;
1274 : : bool rx_use_avx512;
1275 : : bool tx_use_avx2;
1276 : : bool tx_use_avx512;
1277 : : #endif
1278 : : };
1279 : :
1280 : : /**
1281 : : * Structure to store private data for each VF representor instance
1282 : : */
1283 : : struct i40e_vf_representor {
1284 : : uint16_t switch_domain_id;
1285 : : /**< Virtual Function ID */
1286 : : uint16_t vf_id;
1287 : : /**< Virtual Function ID */
1288 : : struct i40e_adapter *adapter;
1289 : : /**< Private data store of associated physical function */
1290 : : struct i40e_eth_stats stats_offset;
1291 : : /**< Zero-point of VF statistics*/
1292 : : };
1293 : :
1294 : : extern const struct rte_flow_ops i40e_flow_ops;
1295 : :
1296 : : union i40e_filter_t {
1297 : : struct rte_eth_ethertype_filter ethertype_filter;
1298 : : struct i40e_fdir_filter_conf fdir_filter;
1299 : : struct rte_eth_tunnel_filter_conf tunnel_filter;
1300 : : struct i40e_tunnel_filter_conf consistent_tunnel_filter;
1301 : : struct i40e_rte_flow_rss_conf rss_conf;
1302 : : };
1303 : :
1304 : : typedef int (*parse_filter_t)(struct rte_eth_dev *dev,
1305 : : const struct rte_flow_attr *attr,
1306 : : const struct rte_flow_item pattern[],
1307 : : const struct rte_flow_action actions[],
1308 : : struct rte_flow_error *error,
1309 : : union i40e_filter_t *filter);
1310 : : struct i40e_valid_pattern {
1311 : : enum rte_flow_item_type *items;
1312 : : parse_filter_t parse_filter;
1313 : : };
1314 : :
1315 : : int i40e_dev_switch_queues(struct i40e_pf *pf, bool on);
1316 : : int i40e_vsi_release(struct i40e_vsi *vsi);
1317 : : struct i40e_vsi *i40e_vsi_setup(struct i40e_pf *pf,
1318 : : enum i40e_vsi_type type,
1319 : : struct i40e_vsi *uplink_vsi,
1320 : : uint16_t user_param);
1321 : : int i40e_switch_rx_queue(struct i40e_hw *hw, uint16_t q_idx, bool on);
1322 : : int i40e_switch_tx_queue(struct i40e_hw *hw, uint16_t q_idx, bool on);
1323 : : int i40e_vsi_add_vlan(struct i40e_vsi *vsi, uint16_t vlan);
1324 : : int i40e_vsi_delete_vlan(struct i40e_vsi *vsi, uint16_t vlan);
1325 : : int i40e_vsi_add_mac(struct i40e_vsi *vsi, struct i40e_mac_filter_info *filter);
1326 : : int i40e_vsi_delete_mac(struct i40e_vsi *vsi, struct rte_ether_addr *addr);
1327 : : void i40e_update_vsi_stats(struct i40e_vsi *vsi);
1328 : : void i40e_pf_disable_irq0(struct i40e_hw *hw);
1329 : : void i40e_pf_enable_irq0(struct i40e_hw *hw);
1330 : : int i40e_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete);
1331 : : int i40e_vsi_queues_bind_intr(struct i40e_vsi *vsi, uint16_t itr_idx);
1332 : : void i40e_vsi_queues_unbind_intr(struct i40e_vsi *vsi);
1333 : : void i40e_vsi_disable_queues_intr(struct i40e_vsi *vsi);
1334 : : int i40e_vsi_vlan_pvid_set(struct i40e_vsi *vsi,
1335 : : struct i40e_vsi_vlan_pvid_info *info);
1336 : : int i40e_vsi_config_vlan_stripping(struct i40e_vsi *vsi, bool on);
1337 : : int i40e_vsi_config_vlan_filter(struct i40e_vsi *vsi, bool on);
1338 : : uint64_t i40e_config_hena(const struct i40e_adapter *adapter, uint64_t flags);
1339 : : uint64_t i40e_parse_hena(const struct i40e_adapter *adapter, uint64_t flags);
1340 : : enum i40e_status_code i40e_fdir_setup_tx_resources(struct i40e_pf *pf);
1341 : : enum i40e_status_code i40e_fdir_setup_rx_resources(struct i40e_pf *pf);
1342 : : int i40e_fdir_setup(struct i40e_pf *pf);
1343 : : void i40e_vsi_enable_queues_intr(struct i40e_vsi *vsi);
1344 : : const struct rte_memzone *i40e_memzone_reserve(const char *name,
1345 : : uint32_t len,
1346 : : int socket_id);
1347 : : int i40e_fdir_configure(struct rte_eth_dev *dev);
1348 : : void i40e_fdir_rx_proc_enable(struct rte_eth_dev *dev, bool on);
1349 : : void i40e_fdir_teardown(struct i40e_pf *pf);
1350 : : enum i40e_filter_pctype
1351 : : i40e_flowtype_to_pctype(const struct i40e_adapter *adapter,
1352 : : uint16_t flow_type);
1353 : : uint16_t i40e_pctype_to_flowtype(const struct i40e_adapter *adapter,
1354 : : enum i40e_filter_pctype pctype);
1355 : : int i40e_dev_set_gre_key_len(struct i40e_hw *hw, uint8_t len);
1356 : : void i40e_fdir_info_get(struct rte_eth_dev *dev,
1357 : : struct rte_eth_fdir_info *fdir);
1358 : : void i40e_fdir_stats_get(struct rte_eth_dev *dev,
1359 : : struct rte_eth_fdir_stats *stat);
1360 : : int i40e_select_filter_input_set(struct i40e_hw *hw,
1361 : : struct rte_eth_input_set_conf *conf,
1362 : : enum rte_filter_type filter);
1363 : : void i40e_fdir_filter_restore(struct i40e_pf *pf);
1364 : : int i40e_set_hash_inset(struct i40e_hw *hw, uint64_t input_set,
1365 : : uint32_t pctype, bool add);
1366 : : int i40e_pf_host_send_msg_to_vf(struct i40e_pf_vf *vf, uint32_t opcode,
1367 : : uint32_t retval, uint8_t *msg,
1368 : : uint16_t msglen);
1369 : : void i40e_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
1370 : : struct rte_eth_rxq_info *qinfo);
1371 : : void i40e_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
1372 : : struct rte_eth_txq_info *qinfo);
1373 : : void i40e_recycle_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
1374 : : struct rte_eth_recycle_rxq_info *recycle_rxq_info);
1375 : : int i40e_rx_burst_mode_get(struct rte_eth_dev *dev, uint16_t queue_id,
1376 : : struct rte_eth_burst_mode *mode);
1377 : : int i40e_tx_burst_mode_get(struct rte_eth_dev *dev, uint16_t queue_id,
1378 : : struct rte_eth_burst_mode *mode);
1379 : : struct i40e_ethertype_filter *
1380 : : i40e_sw_ethertype_filter_lookup(struct i40e_ethertype_rule *ethertype_rule,
1381 : : const struct i40e_ethertype_filter_input *input);
1382 : : int i40e_sw_ethertype_filter_del(struct i40e_pf *pf,
1383 : : struct i40e_ethertype_filter_input *input);
1384 : : int i40e_sw_fdir_filter_del(struct i40e_pf *pf,
1385 : : struct i40e_fdir_input *input);
1386 : : struct i40e_tunnel_filter *
1387 : : i40e_sw_tunnel_filter_lookup(struct i40e_tunnel_rule *tunnel_rule,
1388 : : const struct i40e_tunnel_filter_input *input);
1389 : : int i40e_sw_tunnel_filter_del(struct i40e_pf *pf,
1390 : : struct i40e_tunnel_filter_input *input);
1391 : : uint64_t i40e_get_default_input_set(uint16_t pctype);
1392 : : int i40e_ethertype_filter_set(struct i40e_pf *pf,
1393 : : struct rte_eth_ethertype_filter *filter,
1394 : : bool add);
1395 : : struct rte_flow *
1396 : : i40e_fdir_entry_pool_get(struct i40e_fdir_info *fdir_info);
1397 : : void i40e_fdir_entry_pool_put(struct i40e_fdir_info *fdir_info,
1398 : : struct rte_flow *flow);
1399 : : int i40e_flow_add_del_fdir_filter(struct rte_eth_dev *dev,
1400 : : const struct i40e_fdir_filter_conf *filter,
1401 : : bool add);
1402 : : int i40e_dev_tunnel_filter_set(struct i40e_pf *pf,
1403 : : struct rte_eth_tunnel_filter_conf *tunnel_filter,
1404 : : uint8_t add);
1405 : : int i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,
1406 : : struct i40e_tunnel_filter_conf *tunnel_filter,
1407 : : uint8_t add);
1408 : : int i40e_fdir_flush(struct rte_eth_dev *dev);
1409 : : int i40e_find_all_vlan_for_mac(struct i40e_vsi *vsi,
1410 : : struct i40e_macvlan_filter *mv_f,
1411 : : int num, struct rte_ether_addr *addr);
1412 : : int i40e_remove_macvlan_filters(struct i40e_vsi *vsi,
1413 : : struct i40e_macvlan_filter *filter,
1414 : : int total);
1415 : : void i40e_set_vlan_filter(struct i40e_vsi *vsi, uint16_t vlan_id, bool on);
1416 : : int i40e_add_macvlan_filters(struct i40e_vsi *vsi,
1417 : : struct i40e_macvlan_filter *filter,
1418 : : int total);
1419 : : bool is_device_supported(struct rte_eth_dev *dev, struct rte_pci_driver *drv);
1420 : : bool is_i40e_supported(struct rte_eth_dev *dev);
1421 : : void i40e_set_symmetric_hash_enable_per_port(struct i40e_hw *hw,
1422 : : uint8_t enable);
1423 : : int i40e_validate_input_set(enum i40e_filter_pctype pctype,
1424 : : enum rte_filter_type filter, uint64_t inset);
1425 : : int i40e_generate_inset_mask_reg(struct i40e_hw *hw, uint64_t inset,
1426 : : uint32_t *mask, uint8_t nb_elem);
1427 : : uint64_t i40e_translate_input_set_reg(enum i40e_mac_type type, uint64_t input);
1428 : : void i40e_check_write_reg(struct i40e_hw *hw, uint32_t addr, uint32_t val);
1429 : : void i40e_check_write_global_reg(struct i40e_hw *hw,
1430 : : uint32_t addr, uint32_t val);
1431 : :
1432 : : int i40e_tm_ops_get(struct rte_eth_dev *dev, void *ops);
1433 : : void i40e_tm_conf_init(struct rte_eth_dev *dev);
1434 : : void i40e_tm_conf_uninit(struct rte_eth_dev *dev);
1435 : : struct i40e_customized_pctype*
1436 : : i40e_find_customized_pctype(struct i40e_pf *pf, uint8_t index);
1437 : : void i40e_update_customized_info(struct rte_eth_dev *dev, uint8_t *pkg,
1438 : : uint32_t pkg_size,
1439 : : enum rte_pmd_i40e_package_op op);
1440 : : int i40e_dcb_init_configure(struct rte_eth_dev *dev, bool sw_dcb);
1441 : : int i40e_flush_queue_region_all_conf(struct rte_eth_dev *dev,
1442 : : struct i40e_hw *hw, struct i40e_pf *pf, uint16_t on);
1443 : : void i40e_init_queue_region_conf(struct rte_eth_dev *dev);
1444 : : void i40e_flex_payload_reg_set_default(struct i40e_hw *hw);
1445 : : void i40e_pf_disable_rss(struct i40e_pf *pf);
1446 : : int i40e_pf_calc_configured_queues_num(struct i40e_pf *pf);
1447 : : int i40e_pf_reset_rss_reta(struct i40e_pf *pf);
1448 : : int i40e_pf_reset_rss_key(struct i40e_pf *pf);
1449 : : int i40e_pf_config_rss(struct i40e_pf *pf);
1450 : : int i40e_pf_set_source_prune(struct i40e_pf *pf, int on);
1451 : : int i40e_set_rss_key(struct i40e_vsi *vsi, uint8_t *key, uint8_t key_len);
1452 : : int i40e_set_rss_lut(struct i40e_vsi *vsi, uint8_t *lut, uint16_t lut_size);
1453 : : int i40e_vf_representor_init(struct rte_eth_dev *ethdev, void *init_params);
1454 : : int i40e_vf_representor_uninit(struct rte_eth_dev *ethdev);
1455 : :
1456 : : #define I40E_DEV_TO_PCI(eth_dev) \
1457 : : RTE_DEV_TO_PCI((eth_dev)->device)
1458 : :
1459 : : /* I40E_DEV_PRIVATE_TO */
1460 : : #define I40E_DEV_PRIVATE_TO_PF(adapter) \
1461 : : (&((struct i40e_adapter *)adapter)->pf)
1462 : : #define I40E_DEV_PRIVATE_TO_HW(adapter) \
1463 : : (&((struct i40e_adapter *)adapter)->hw)
1464 : : #define I40E_DEV_PRIVATE_TO_ADAPTER(adapter) \
1465 : : ((struct i40e_adapter *)adapter)
1466 : :
1467 : : static inline struct i40e_vsi *
1468 : : i40e_get_vsi_from_adapter(struct i40e_adapter *adapter)
1469 : : {
1470 [ # # ]: 0 : if (!adapter)
1471 : : return NULL;
1472 : :
1473 : : struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(adapter);
1474 : :
1475 : 0 : return pf->main_vsi;
1476 : : }
1477 : : #define I40E_DEV_PRIVATE_TO_MAIN_VSI(adapter) \
1478 : : i40e_get_vsi_from_adapter((struct i40e_adapter *)adapter)
1479 : :
1480 : : /* I40E_VSI_TO */
1481 : : #define I40E_VSI_TO_HW(vsi) \
1482 : : (&(((struct i40e_vsi *)vsi)->adapter->hw))
1483 : : #define I40E_VSI_TO_PF(vsi) \
1484 : : (&(((struct i40e_vsi *)vsi)->adapter->pf))
1485 : : #define I40E_VSI_TO_VF(vsi) \
1486 : : (&(((struct i40e_vsi *)vsi)->adapter->vf))
1487 : : #define I40E_VSI_TO_DEV_DATA(vsi) \
1488 : : (((struct i40e_vsi *)vsi)->adapter->pf.dev_data)
1489 : : #define I40E_VSI_TO_ETH_DEV(vsi) \
1490 : : (&rte_eth_devices[((struct i40e_vsi *)vsi)->adapter->pf.dev_data->port_id])
1491 : :
1492 : : /* I40E_PF_TO */
1493 : : #define I40E_PF_TO_HW(pf) \
1494 : : (&(((struct i40e_pf *)pf)->adapter->hw))
1495 : : #define I40E_PF_TO_ADAPTER(pf) \
1496 : : ((struct i40e_adapter *)pf->adapter)
1497 : :
1498 : : static inline void
1499 : : i40e_init_adminq_parameter(struct i40e_hw *hw)
1500 : : {
1501 : 0 : hw->aq.num_arq_entries = I40E_AQ_LEN;
1502 : 0 : hw->aq.num_asq_entries = I40E_AQ_LEN;
1503 : 0 : hw->aq.arq_buf_size = I40E_AQ_BUF_SZ;
1504 : 0 : hw->aq.asq_buf_size = I40E_AQ_BUF_SZ;
1505 : : }
1506 : :
1507 : : static inline int
1508 : : i40e_align_floor(int n)
1509 : : {
1510 [ # # # # ]: 0 : if (n == 0)
1511 : : return 0;
1512 : 0 : return 1 << (sizeof(n) * CHAR_BIT - 1 - rte_clz32(n));
1513 : : }
1514 : :
1515 : : static inline uint16_t
1516 : : i40e_calc_itr_interval(bool is_pf, bool is_multi_drv)
1517 : : {
1518 : : uint16_t interval = 0;
1519 : :
1520 : : if (is_multi_drv) {
1521 : : interval = I40E_QUEUE_ITR_INTERVAL_DEFAULT;
1522 : : } else {
1523 : : if (is_pf)
1524 : : interval = I40E_QUEUE_ITR_INTERVAL_DEFAULT;
1525 : : else
1526 : : interval = I40E_VF_QUEUE_ITR_INTERVAL_DEFAULT;
1527 : : }
1528 : :
1529 : : /* Convert to hardware count, as writing each 1 represents 2 us */
1530 : : return interval / 2;
1531 : : }
1532 : :
1533 : : #define I40E_VALID_FLOW(flow_type) \
1534 : : ((flow_type) == RTE_ETH_FLOW_FRAG_IPV4 || \
1535 : : (flow_type) == RTE_ETH_FLOW_NONFRAG_IPV4_TCP || \
1536 : : (flow_type) == RTE_ETH_FLOW_NONFRAG_IPV4_UDP || \
1537 : : (flow_type) == RTE_ETH_FLOW_NONFRAG_IPV4_SCTP || \
1538 : : (flow_type) == RTE_ETH_FLOW_NONFRAG_IPV4_OTHER || \
1539 : : (flow_type) == RTE_ETH_FLOW_FRAG_IPV6 || \
1540 : : (flow_type) == RTE_ETH_FLOW_NONFRAG_IPV6_TCP || \
1541 : : (flow_type) == RTE_ETH_FLOW_NONFRAG_IPV6_UDP || \
1542 : : (flow_type) == RTE_ETH_FLOW_NONFRAG_IPV6_SCTP || \
1543 : : (flow_type) == RTE_ETH_FLOW_NONFRAG_IPV6_OTHER || \
1544 : : (flow_type) == RTE_ETH_FLOW_L2_PAYLOAD)
1545 : :
1546 : : #define I40E_VALID_PCTYPE_X722(pctype) \
1547 : : ((pctype) == I40E_FILTER_PCTYPE_FRAG_IPV4 || \
1548 : : (pctype) == I40E_FILTER_PCTYPE_NONF_IPV4_TCP || \
1549 : : (pctype) == I40E_FILTER_PCTYPE_NONF_IPV4_TCP_SYN_NO_ACK || \
1550 : : (pctype) == I40E_FILTER_PCTYPE_NONF_IPV4_UDP || \
1551 : : (pctype) == I40E_FILTER_PCTYPE_NONF_UNICAST_IPV4_UDP || \
1552 : : (pctype) == I40E_FILTER_PCTYPE_NONF_MULTICAST_IPV4_UDP || \
1553 : : (pctype) == I40E_FILTER_PCTYPE_NONF_IPV4_SCTP || \
1554 : : (pctype) == I40E_FILTER_PCTYPE_NONF_IPV4_OTHER || \
1555 : : (pctype) == I40E_FILTER_PCTYPE_FRAG_IPV6 || \
1556 : : (pctype) == I40E_FILTER_PCTYPE_NONF_IPV6_UDP || \
1557 : : (pctype) == I40E_FILTER_PCTYPE_NONF_UNICAST_IPV6_UDP || \
1558 : : (pctype) == I40E_FILTER_PCTYPE_NONF_MULTICAST_IPV6_UDP || \
1559 : : (pctype) == I40E_FILTER_PCTYPE_NONF_IPV6_TCP || \
1560 : : (pctype) == I40E_FILTER_PCTYPE_NONF_IPV6_TCP_SYN_NO_ACK || \
1561 : : (pctype) == I40E_FILTER_PCTYPE_NONF_IPV6_SCTP || \
1562 : : (pctype) == I40E_FILTER_PCTYPE_NONF_IPV6_OTHER || \
1563 : : (pctype) == I40E_FILTER_PCTYPE_L2_PAYLOAD)
1564 : :
1565 : : #define I40E_VALID_PCTYPE(pctype) \
1566 : : ((pctype) == I40E_FILTER_PCTYPE_FRAG_IPV4 || \
1567 : : (pctype) == I40E_FILTER_PCTYPE_NONF_IPV4_TCP || \
1568 : : (pctype) == I40E_FILTER_PCTYPE_NONF_IPV4_UDP || \
1569 : : (pctype) == I40E_FILTER_PCTYPE_NONF_IPV4_SCTP || \
1570 : : (pctype) == I40E_FILTER_PCTYPE_NONF_IPV4_OTHER || \
1571 : : (pctype) == I40E_FILTER_PCTYPE_FRAG_IPV6 || \
1572 : : (pctype) == I40E_FILTER_PCTYPE_NONF_IPV6_UDP || \
1573 : : (pctype) == I40E_FILTER_PCTYPE_NONF_IPV6_TCP || \
1574 : : (pctype) == I40E_FILTER_PCTYPE_NONF_IPV6_SCTP || \
1575 : : (pctype) == I40E_FILTER_PCTYPE_NONF_IPV6_OTHER || \
1576 : : (pctype) == I40E_FILTER_PCTYPE_L2_PAYLOAD)
1577 : :
1578 : : #define I40E_PHY_TYPE_SUPPORT_40G(phy_type) \
1579 : : (((phy_type) & I40E_CAP_PHY_TYPE_40GBASE_KR4) || \
1580 : : ((phy_type) & I40E_CAP_PHY_TYPE_40GBASE_CR4_CU) || \
1581 : : ((phy_type) & I40E_CAP_PHY_TYPE_40GBASE_AOC) || \
1582 : : ((phy_type) & I40E_CAP_PHY_TYPE_40GBASE_CR4) || \
1583 : : ((phy_type) & I40E_CAP_PHY_TYPE_40GBASE_SR4) || \
1584 : : ((phy_type) & I40E_CAP_PHY_TYPE_40GBASE_LR4))
1585 : :
1586 : : #define I40E_PHY_TYPE_SUPPORT_25G(phy_type) \
1587 : : (((phy_type) & I40E_CAP_PHY_TYPE_25GBASE_KR) || \
1588 : : ((phy_type) & I40E_CAP_PHY_TYPE_25GBASE_CR) || \
1589 : : ((phy_type) & I40E_CAP_PHY_TYPE_25GBASE_SR) || \
1590 : : ((phy_type) & I40E_CAP_PHY_TYPE_25GBASE_LR) || \
1591 : : ((phy_type) & I40E_CAP_PHY_TYPE_25GBASE_AOC) || \
1592 : : ((phy_type) & I40E_CAP_PHY_TYPE_25GBASE_ACC))
1593 : :
1594 : : #endif /* _I40E_ETHDEV_H_ */
|