4 * Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #ifndef _I40E_ETHDEV_H_
35 #define _I40E_ETHDEV_H_
37 #include <rte_eth_ctrl.h>
40 #define I40E_VLAN_TAG_SIZE 4
42 #define I40E_AQ_LEN 32
43 #define I40E_AQ_BUF_SZ 4096
44 /* Number of queues per TC should be one of 1, 2, 4, 8, 16, 32, 64 */
45 #define I40E_MAX_Q_PER_TC 64
46 #define I40E_NUM_DESC_DEFAULT 512
47 #define I40E_NUM_DESC_ALIGN 32
48 #define I40E_BUF_SIZE_MIN 1024
49 #define I40E_FRAME_SIZE_MAX 9728
50 #define I40E_QUEUE_BASE_ADDR_UNIT 128
51 /* number of VSIs and queue default setting */
52 #define I40E_MAX_QP_NUM_PER_VF 16
53 #define I40E_DEFAULT_QP_NUM_FDIR 1
54 #define I40E_UINT32_BIT_SIZE (CHAR_BIT * sizeof(uint32_t))
55 #define I40E_VFTA_SIZE (4096 / I40E_UINT32_BIT_SIZE)
57 * vlan_id is a 12 bit number.
58 * The VFTA array is actually a 4096 bit array, 128 of 32bit elements.
59 * 2^5 = 32. The val of lower 5 bits specifies the bit in the 32bit element.
60 * The higher 7 bit val specifies VFTA array index.
62 #define I40E_VFTA_BIT(vlan_id) (1 << ((vlan_id) & 0x1F))
63 #define I40E_VFTA_IDX(vlan_id) ((vlan_id) >> 5)
65 /* Default TC traffic in case DCB is not enabled */
66 #define I40E_DEFAULT_TCMAP 0x1
67 #define I40E_FDIR_QUEUE_ID 0
69 /* Always assign pool 0 to main VSI, VMDQ will start from 1 */
70 #define I40E_VMDQ_POOL_BASE 1
72 #define I40E_DEFAULT_RX_FREE_THRESH 32
73 #define I40E_DEFAULT_RX_PTHRESH 8
74 #define I40E_DEFAULT_RX_HTHRESH 8
75 #define I40E_DEFAULT_RX_WTHRESH 0
77 #define I40E_DEFAULT_TX_FREE_THRESH 32
78 #define I40E_DEFAULT_TX_PTHRESH 32
79 #define I40E_DEFAULT_TX_HTHRESH 0
80 #define I40E_DEFAULT_TX_WTHRESH 0
81 #define I40E_DEFAULT_TX_RSBIT_THRESH 32
83 /* Bit shift and mask */
84 #define I40E_4_BIT_WIDTH (CHAR_BIT / 2)
85 #define I40E_4_BIT_MASK RTE_LEN2MASK(I40E_4_BIT_WIDTH, uint8_t)
86 #define I40E_8_BIT_WIDTH CHAR_BIT
87 #define I40E_8_BIT_MASK UINT8_MAX
88 #define I40E_16_BIT_WIDTH (CHAR_BIT * 2)
89 #define I40E_16_BIT_MASK UINT16_MAX
90 #define I40E_32_BIT_WIDTH (CHAR_BIT * 4)
91 #define I40E_32_BIT_MASK UINT32_MAX
92 #define I40E_48_BIT_WIDTH (CHAR_BIT * 6)
93 #define I40E_48_BIT_MASK RTE_LEN2MASK(I40E_48_BIT_WIDTH, uint64_t)
95 /* Linux PF host with virtchnl version 1.1 */
96 #define PF_IS_V11(vf) \
97 (((vf)->version_major == I40E_VIRTCHNL_VERSION_MAJOR) && \
98 ((vf)->version_minor == 1))
100 /* index flex payload per layer */
101 enum i40e_flxpld_layer_idx {
102 I40E_FLXPLD_L2_IDX = 0,
103 I40E_FLXPLD_L3_IDX = 1,
104 I40E_FLXPLD_L4_IDX = 2,
105 I40E_MAX_FLXPLD_LAYER = 3,
107 #define I40E_MAX_FLXPLD_FIED 3 /* max number of flex payload fields */
108 #define I40E_FDIR_BITMASK_NUM_WORD 2 /* max number of bitmask words */
109 #define I40E_FDIR_MAX_FLEXWORD_NUM 8 /* max number of flexpayload words */
110 #define I40E_FDIR_MAX_FLEX_LEN 16 /* len in bytes of flex payload */
111 #define I40E_INSET_MASK_NUM_REG 2 /* number of input set mask registers */
114 #define I40E_FLAG_RSS (1ULL << 0)
115 #define I40E_FLAG_DCB (1ULL << 1)
116 #define I40E_FLAG_VMDQ (1ULL << 2)
117 #define I40E_FLAG_SRIOV (1ULL << 3)
118 #define I40E_FLAG_HEADER_SPLIT_DISABLED (1ULL << 4)
119 #define I40E_FLAG_HEADER_SPLIT_ENABLED (1ULL << 5)
120 #define I40E_FLAG_FDIR (1ULL << 6)
121 #define I40E_FLAG_VXLAN (1ULL << 7)
122 #define I40E_FLAG_RSS_AQ_CAPABLE (1ULL << 8)
123 #define I40E_FLAG_ALL (I40E_FLAG_RSS | \
127 I40E_FLAG_HEADER_SPLIT_DISABLED | \
128 I40E_FLAG_HEADER_SPLIT_ENABLED | \
131 I40E_FLAG_RSS_AQ_CAPABLE)
133 #define I40E_RSS_OFFLOAD_ALL ( \
134 ETH_RSS_FRAG_IPV4 | \
135 ETH_RSS_NONFRAG_IPV4_TCP | \
136 ETH_RSS_NONFRAG_IPV4_UDP | \
137 ETH_RSS_NONFRAG_IPV4_SCTP | \
138 ETH_RSS_NONFRAG_IPV4_OTHER | \
139 ETH_RSS_FRAG_IPV6 | \
140 ETH_RSS_NONFRAG_IPV6_TCP | \
141 ETH_RSS_NONFRAG_IPV6_UDP | \
142 ETH_RSS_NONFRAG_IPV6_SCTP | \
143 ETH_RSS_NONFRAG_IPV6_OTHER | \
146 /* All bits of RSS hash enable */
147 #define I40E_RSS_HENA_ALL ( \
148 (1ULL << I40E_FILTER_PCTYPE_NONF_IPV4_UDP) | \
149 (1ULL << I40E_FILTER_PCTYPE_NONF_IPV4_TCP) | \
150 (1ULL << I40E_FILTER_PCTYPE_NONF_IPV4_SCTP) | \
151 (1ULL << I40E_FILTER_PCTYPE_NONF_IPV4_OTHER) | \
152 (1ULL << I40E_FILTER_PCTYPE_FRAG_IPV4) | \
153 (1ULL << I40E_FILTER_PCTYPE_NONF_IPV6_UDP) | \
154 (1ULL << I40E_FILTER_PCTYPE_NONF_IPV6_TCP) | \
155 (1ULL << I40E_FILTER_PCTYPE_NONF_IPV6_SCTP) | \
156 (1ULL << I40E_FILTER_PCTYPE_NONF_IPV6_OTHER) | \
157 (1ULL << I40E_FILTER_PCTYPE_FRAG_IPV6) | \
158 (1ULL << I40E_FILTER_PCTYPE_FCOE_OX) | \
159 (1ULL << I40E_FILTER_PCTYPE_FCOE_RX) | \
160 (1ULL << I40E_FILTER_PCTYPE_FCOE_OTHER) | \
161 (1ULL << I40E_FILTER_PCTYPE_L2_PAYLOAD))
163 #define I40E_MISC_VEC_ID RTE_INTR_VEC_ZERO_OFFSET
164 #define I40E_RX_VEC_START RTE_INTR_VEC_RXTX_OFFSET
166 /* Default queue interrupt throttling time in microseconds */
167 #define I40E_ITR_INDEX_DEFAULT 0
168 #define I40E_QUEUE_ITR_INTERVAL_DEFAULT 32 /* 32 us */
169 #define I40E_QUEUE_ITR_INTERVAL_MAX 8160 /* 8160 us */
174 * MAC filter structure
176 struct i40e_mac_filter_info {
177 enum rte_mac_filter_type filter_type;
178 struct ether_addr mac_addr;
181 TAILQ_HEAD(i40e_mac_filter_list, i40e_mac_filter);
183 /* MAC filter list structure */
184 struct i40e_mac_filter {
185 TAILQ_ENTRY(i40e_mac_filter) next;
186 struct i40e_mac_filter_info mac_info;
189 TAILQ_HEAD(i40e_vsi_list_head, i40e_vsi_list);
193 /* VSI list structure */
194 struct i40e_vsi_list {
195 TAILQ_ENTRY(i40e_vsi_list) list;
196 struct i40e_vsi *vsi;
199 struct i40e_rx_queue;
200 struct i40e_tx_queue;
202 /* Bandwidth limit information */
203 struct i40e_bw_info {
204 uint16_t bw_limit; /* BW Limit (0 = disabled) */
205 uint8_t bw_max; /* Max BW limit if enabled */
207 /* Relative credits within same TC with respect to other VSIs or Comps */
208 uint8_t bw_ets_share_credits[I40E_MAX_TRAFFIC_CLASS];
209 /* Bandwidth limit per TC */
210 uint8_t bw_ets_credits[I40E_MAX_TRAFFIC_CLASS];
211 /* Max bandwidth limit per TC */
212 uint8_t bw_ets_max[I40E_MAX_TRAFFIC_CLASS];
215 /* Structure that defines a VEB */
217 struct i40e_vsi_list_head head;
218 struct i40e_vsi *associate_vsi; /* Associate VSI who owns the VEB */
219 uint16_t seid; /* The seid of VEB itself */
220 uint16_t uplink_seid; /* The uplink seid of this VEB */
222 struct i40e_eth_stats stats;
223 uint8_t enabled_tc; /* The traffic class enabled */
224 struct i40e_bw_info bw_info; /* VEB bandwidth information */
227 /* i40e MACVLAN filter structure */
228 struct i40e_macvlan_filter {
229 struct ether_addr macaddr;
230 enum rte_mac_filter_type filter_type;
235 * Structure that defines a VSI, associated with a adapter.
238 struct i40e_adapter *adapter; /* Backreference to associated adapter */
239 struct i40e_aqc_vsi_properties_data info; /* VSI properties */
241 struct i40e_eth_stats eth_stats_offset;
242 struct i40e_eth_stats eth_stats;
244 * When drivers loaded, only a default main VSI exists. In case new VSI
245 * needs to add, HW needs to know the layout that VSIs are organized.
246 * Besides that, VSI isan element and can't switch packets, which needs
247 * to add new component VEB to perform switching. So, a new VSI needs
248 * to specify the the uplink VSI (Parent VSI) before created. The
249 * uplink VSI will check whether it had a VEB to switch packets. If no,
250 * it will try to create one. Then, uplink VSI will move the new VSI
251 * into its' sib_vsi_list to manage all the downlink VSI.
252 * sib_vsi_list: the VSI list that shared the same uplink VSI.
253 * parent_vsi : the uplink VSI. It's NULL for main VSI.
254 * veb : the VEB associates with the VSI.
256 struct i40e_vsi_list sib_vsi_list; /* sibling vsi list */
257 struct i40e_vsi *parent_vsi;
258 struct i40e_veb *veb; /* Associated veb, could be null */
260 enum i40e_vsi_type type; /* VSI types */
261 uint16_t vlan_num; /* Total VLAN number */
262 uint16_t mac_num; /* Total mac number */
263 uint32_t vfta[I40E_VFTA_SIZE]; /* VLAN bitmap */
264 struct i40e_mac_filter_list mac_list; /* macvlan filter list */
265 /* specific VSI-defined parameters, SRIOV stored the vf_id */
267 uint16_t seid; /* The seid of VSI itself */
268 uint16_t uplink_seid; /* The uplink seid of this VSI */
269 uint16_t nb_qps; /* Number of queue pairs VSI can occupy */
270 uint16_t nb_used_qps; /* Number of queue pairs VSI uses */
271 uint16_t max_macaddrs; /* Maximum number of MAC addresses */
272 uint16_t base_queue; /* The first queue index of this VSI */
274 * The offset to visit VSI related register, assigned by HW when
278 uint16_t msix_intr; /* The MSIX interrupt binds to VSI */
279 uint16_t nb_msix; /* The max number of msix vector */
280 uint8_t enabled_tc; /* The traffic class enabled */
281 struct i40e_bw_info bw_info; /* VSI bandwidth information */
285 LIST_ENTRY(pool_entry) next;
290 LIST_HEAD(res_list, pool_entry);
292 struct i40e_res_pool_info {
293 uint32_t base; /* Resource start index */
294 uint32_t num_alloc; /* Allocated resource number */
295 uint32_t num_free; /* Total available resource number */
296 struct res_list alloc_list; /* Allocated resource list */
297 struct res_list free_list; /* Available resource list */
301 I40E_VF_INACTIVE = 0,
308 * Structure to store private data for PF host.
312 struct i40e_vsi *vsi;
313 enum I40E_VF_STATE state; /* The number of queue pairs availiable */
314 uint16_t vf_idx; /* VF index in pf->vfs */
315 uint16_t lan_nb_qps; /* Actual queues allocated */
316 uint16_t reset_cnt; /* Total vf reset times */
317 struct ether_addr mac_addr; /* Default MAC address */
321 * Structure to store private data for flow control.
323 struct i40e_fc_conf {
324 uint16_t pause_time; /* Flow control pause timer */
325 /* FC high water 0-7 for pfc and 8 for lfc unit:kilobytes */
326 uint32_t high_water[I40E_MAX_TRAFFIC_CLASS + 1];
327 /* FC low water 0-7 for pfc and 8 for lfc unit:kilobytes */
328 uint32_t low_water[I40E_MAX_TRAFFIC_CLASS + 1];
332 * Structure to store private data for VMDQ instance
334 struct i40e_vmdq_info {
336 struct i40e_vsi *vsi;
340 * Structure to store flex pit for flow diretor.
342 struct i40e_fdir_flex_pit {
343 uint8_t src_offset; /* offset in words from the beginning of payload */
344 uint8_t size; /* size in words */
345 uint8_t dst_offset; /* offset in words of flexible payload */
348 struct i40e_fdir_flex_mask {
349 uint8_t word_mask; /**< Bit i enables word i of flexible payload */
353 } bitmask[I40E_FDIR_BITMASK_NUM_WORD];
356 #define I40E_FILTER_PCTYPE_MAX 64
358 * A structure used to define fields of a FDIR related info.
360 struct i40e_fdir_info {
361 struct i40e_vsi *fdir_vsi; /* pointer to fdir VSI structure */
362 uint16_t match_counter_index; /* Statistic counter index used for fdir*/
363 struct i40e_tx_queue *txq;
364 struct i40e_rx_queue *rxq;
365 void *prg_pkt; /* memory for fdir program packet */
366 uint64_t dma_addr; /* physic address of packet memory*/
368 * the rule how bytes stream is extracted as flexible payload
369 * for each payload layer, the setting can up to three elements
371 struct i40e_fdir_flex_pit flex_set[I40E_MAX_FLXPLD_LAYER * I40E_MAX_FLXPLD_FIED];
372 struct i40e_fdir_flex_mask flex_mask[I40E_FILTER_PCTYPE_MAX];
375 #define I40E_MIRROR_MAX_ENTRIES_PER_RULE 64
376 #define I40E_MAX_MIRROR_RULES 64
378 * Mirror rule structure
380 struct i40e_mirror_rule {
381 TAILQ_ENTRY(i40e_mirror_rule) rules;
383 uint16_t index; /* the sw index of mirror rule */
384 uint16_t id; /* the rule id assigned by firmware */
385 uint16_t dst_vsi_seid; /* destination vsi for this mirror rule. */
386 uint16_t num_entries;
387 /* the info stores depend on the rule type.
388 If type is I40E_MIRROR_TYPE_VLAN, vlan ids are stored here.
389 If type is I40E_MIRROR_TYPE_VPORT_*, vsi's seid are stored.
391 uint16_t entries[I40E_MIRROR_MAX_ENTRIES_PER_RULE];
394 TAILQ_HEAD(i40e_mirror_rule_list, i40e_mirror_rule);
397 * Structure to store private data specific for PF instance.
400 struct i40e_adapter *adapter; /* The adapter this PF associate to */
401 struct i40e_vsi *main_vsi; /* pointer to main VSI structure */
402 uint16_t mac_seid; /* The seid of the MAC of this PF */
403 uint16_t main_vsi_seid; /* The seid of the main VSI */
404 uint16_t max_num_vsi;
405 struct i40e_res_pool_info qp_pool; /*Queue pair pool */
406 struct i40e_res_pool_info msix_pool; /* MSIX interrupt pool */
408 struct i40e_hw_port_stats stats_offset;
409 struct i40e_hw_port_stats stats;
412 struct rte_eth_dev_data *dev_data; /* Pointer to the device data */
413 struct ether_addr dev_addr; /* PF device mac address */
414 uint64_t flags; /* PF featuer flags */
415 /* All kinds of queue pair setting for different VSIs */
416 struct i40e_pf_vf *vfs;
418 /* Each of below queue pairs should be power of 2 since it's the
419 precondition after TC configuration applied */
420 uint16_t lan_nb_qp_max;
421 uint16_t lan_nb_qps; /* The number of queue pairs of LAN */
422 uint16_t lan_qp_offset;
423 uint16_t vmdq_nb_qp_max;
424 uint16_t vmdq_nb_qps; /* The number of queue pairs of VMDq */
425 uint16_t vmdq_qp_offset;
426 uint16_t vf_nb_qp_max;
427 uint16_t vf_nb_qps; /* The number of queue pairs of VF */
428 uint16_t vf_qp_offset;
429 uint16_t fdir_nb_qps; /* The number of queue pairs of Flow Director */
430 uint16_t fdir_qp_offset;
432 uint16_t hash_lut_size; /* The size of hash lookup table */
433 /* store VXLAN UDP ports */
434 uint16_t vxlan_ports[I40E_MAX_PF_UDP_OFFLOAD_PORTS];
435 uint16_t vxlan_bitmap; /* Vxlan bit mask */
437 /* VMDQ related info */
438 uint16_t max_nb_vmdq_vsi; /* Max number of VMDQ VSIs supported */
439 uint16_t nb_cfg_vmdq_vsi; /* number of VMDQ VSIs configured */
440 struct i40e_vmdq_info *vmdq;
442 struct i40e_fdir_info fdir; /* flow director info */
443 struct i40e_fc_conf fc_conf; /* Flow control conf */
444 struct i40e_mirror_rule_list mirror_list;
445 uint16_t nb_mirror_rule; /* The number of mirror rules */
449 PFMSG_LINK_CHANGE = 0x1,
450 PFMSG_RESET_IMPENDING = 0x2,
451 PFMSG_DRIVER_CLOSE = 0x4,
454 struct i40e_vsi_vlan_pvid_info {
455 uint16_t on; /* Enable or disable pvid */
457 uint16_t pvid; /* Valid in case 'on' is set to set pvid */
459 /* Valid in case 'on' is cleared. 'tagged' will reject tagged packets,
460 * while 'untagged' will reject untagged packets.
468 struct i40e_vf_rx_queues {
469 uint64_t rx_dma_addr;
470 uint32_t rx_ring_len;
474 struct i40e_vf_tx_queues {
475 uint64_t tx_dma_addr;
476 uint32_t tx_ring_len;
480 * Structure to store private data specific for VF instance.
483 struct i40e_adapter *adapter; /* The adapter this VF associate to */
484 struct rte_eth_dev_data *dev_data; /* Pointer to the device data */
485 uint16_t num_queue_pairs;
486 uint16_t max_pkt_len; /* Maximum packet length */
487 bool promisc_unicast_enabled;
488 bool promisc_multicast_enabled;
490 uint32_t version_major; /* Major version number */
491 uint32_t version_minor; /* Minor version number */
492 uint16_t promisc_flags; /* Promiscuous setting */
493 uint32_t vlan[I40E_VFTA_SIZE]; /* VLAN bit map */
499 volatile uint32_t pend_cmd; /* pending command not finished yet */
500 u16 pend_msg; /* flags indicates events from pf not handled yet */
503 struct i40e_virtchnl_vf_resource *vf_res; /* All VSIs */
504 struct i40e_virtchnl_vsi_resource *vsi_res; /* LAN VSI */
510 * Structure to store private data for each PF/VF instance.
512 struct i40e_adapter {
513 /* Common for both PF and VF */
515 struct rte_eth_dev *eth_dev;
517 /* Specific for PF or VF */
524 bool rx_bulk_alloc_allowed;
526 bool tx_simple_allowed;
530 struct rte_timecounter systime_tc;
531 struct rte_timecounter rx_tstamp_tc;
532 struct rte_timecounter tx_tstamp_tc;
535 int i40e_dev_switch_queues(struct i40e_pf *pf, bool on);
536 int i40e_vsi_release(struct i40e_vsi *vsi);
537 struct i40e_vsi *i40e_vsi_setup(struct i40e_pf *pf,
538 enum i40e_vsi_type type,
539 struct i40e_vsi *uplink_vsi,
540 uint16_t user_param);
541 int i40e_switch_rx_queue(struct i40e_hw *hw, uint16_t q_idx, bool on);
542 int i40e_switch_tx_queue(struct i40e_hw *hw, uint16_t q_idx, bool on);
543 int i40e_vsi_add_vlan(struct i40e_vsi *vsi, uint16_t vlan);
544 int i40e_vsi_delete_vlan(struct i40e_vsi *vsi, uint16_t vlan);
545 int i40e_vsi_add_mac(struct i40e_vsi *vsi, struct i40e_mac_filter_info *filter);
546 int i40e_vsi_delete_mac(struct i40e_vsi *vsi, struct ether_addr *addr);
547 void i40e_update_vsi_stats(struct i40e_vsi *vsi);
548 void i40e_pf_disable_irq0(struct i40e_hw *hw);
549 void i40e_pf_enable_irq0(struct i40e_hw *hw);
550 int i40e_dev_link_update(struct rte_eth_dev *dev,
551 __rte_unused int wait_to_complete);
552 void i40e_vsi_queues_bind_intr(struct i40e_vsi *vsi);
553 void i40e_vsi_queues_unbind_intr(struct i40e_vsi *vsi);
554 int i40e_vsi_vlan_pvid_set(struct i40e_vsi *vsi,
555 struct i40e_vsi_vlan_pvid_info *info);
556 int i40e_vsi_config_vlan_stripping(struct i40e_vsi *vsi, bool on);
557 int i40e_vsi_config_vlan_filter(struct i40e_vsi *vsi, bool on);
558 uint64_t i40e_config_hena(uint64_t flags);
559 uint64_t i40e_parse_hena(uint64_t flags);
560 enum i40e_status_code i40e_fdir_setup_tx_resources(struct i40e_pf *pf);
561 enum i40e_status_code i40e_fdir_setup_rx_resources(struct i40e_pf *pf);
562 int i40e_fdir_setup(struct i40e_pf *pf);
563 const struct rte_memzone *i40e_memzone_reserve(const char *name,
566 int i40e_fdir_configure(struct rte_eth_dev *dev);
567 void i40e_fdir_teardown(struct i40e_pf *pf);
568 enum i40e_filter_pctype i40e_flowtype_to_pctype(uint16_t flow_type);
569 uint16_t i40e_pctype_to_flowtype(enum i40e_filter_pctype pctype);
570 int i40e_fdir_ctrl_func(struct rte_eth_dev *dev,
571 enum rte_filter_op filter_op,
573 int i40e_select_filter_input_set(struct i40e_hw *hw,
574 struct rte_eth_input_set_conf *conf,
575 enum rte_filter_type filter);
576 int i40e_filter_inset_select(struct i40e_hw *hw,
577 struct rte_eth_input_set_conf *conf,
578 enum rte_filter_type filter);
580 void i40e_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
581 struct rte_eth_rxq_info *qinfo);
582 void i40e_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
583 struct rte_eth_txq_info *qinfo);
585 /* I40E_DEV_PRIVATE_TO */
586 #define I40E_DEV_PRIVATE_TO_PF(adapter) \
587 (&((struct i40e_adapter *)adapter)->pf)
588 #define I40E_DEV_PRIVATE_TO_HW(adapter) \
589 (&((struct i40e_adapter *)adapter)->hw)
590 #define I40E_DEV_PRIVATE_TO_ADAPTER(adapter) \
591 ((struct i40e_adapter *)adapter)
593 /* I40EVF_DEV_PRIVATE_TO */
594 #define I40EVF_DEV_PRIVATE_TO_VF(adapter) \
595 (&((struct i40e_adapter *)adapter)->vf)
597 static inline struct i40e_vsi *
598 i40e_get_vsi_from_adapter(struct i40e_adapter *adapter)
605 hw = I40E_DEV_PRIVATE_TO_HW(adapter);
606 if (hw->mac.type == I40E_MAC_VF || hw->mac.type == I40E_MAC_X722_VF) {
607 struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(adapter);
610 struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(adapter);
614 #define I40E_DEV_PRIVATE_TO_MAIN_VSI(adapter) \
615 i40e_get_vsi_from_adapter((struct i40e_adapter *)adapter)
618 #define I40E_VSI_TO_HW(vsi) \
619 (&(((struct i40e_vsi *)vsi)->adapter->hw))
620 #define I40E_VSI_TO_PF(vsi) \
621 (&(((struct i40e_vsi *)vsi)->adapter->pf))
622 #define I40E_VSI_TO_VF(vsi) \
623 (&(((struct i40e_vsi *)vsi)->adapter->vf))
624 #define I40E_VSI_TO_DEV_DATA(vsi) \
625 (((struct i40e_vsi *)vsi)->adapter->pf.dev_data)
626 #define I40E_VSI_TO_ETH_DEV(vsi) \
627 (((struct i40e_vsi *)vsi)->adapter->eth_dev)
630 #define I40E_PF_TO_HW(pf) \
631 (&(((struct i40e_pf *)pf)->adapter->hw))
632 #define I40E_PF_TO_ADAPTER(pf) \
633 ((struct i40e_adapter *)pf->adapter)
636 #define I40E_VF_TO_HW(vf) \
637 (&(((struct i40e_vf *)vf)->adapter->hw))
640 i40e_init_adminq_parameter(struct i40e_hw *hw)
642 hw->aq.num_arq_entries = I40E_AQ_LEN;
643 hw->aq.num_asq_entries = I40E_AQ_LEN;
644 hw->aq.arq_buf_size = I40E_AQ_BUF_SZ;
645 hw->aq.asq_buf_size = I40E_AQ_BUF_SZ;
649 i40e_align_floor(int n)
653 return 1 << (sizeof(n) * CHAR_BIT - 1 - __builtin_clz(n));
656 static inline uint16_t
657 i40e_calc_itr_interval(int16_t interval)
659 if (interval < 0 || interval > I40E_QUEUE_ITR_INTERVAL_MAX)
660 interval = I40E_QUEUE_ITR_INTERVAL_DEFAULT;
662 /* Convert to hardware count, as writing each 1 represents 2 us */
666 #define I40E_VALID_FLOW(flow_type) \
667 ((flow_type) == RTE_ETH_FLOW_FRAG_IPV4 || \
668 (flow_type) == RTE_ETH_FLOW_NONFRAG_IPV4_TCP || \
669 (flow_type) == RTE_ETH_FLOW_NONFRAG_IPV4_UDP || \
670 (flow_type) == RTE_ETH_FLOW_NONFRAG_IPV4_SCTP || \
671 (flow_type) == RTE_ETH_FLOW_NONFRAG_IPV4_OTHER || \
672 (flow_type) == RTE_ETH_FLOW_FRAG_IPV6 || \
673 (flow_type) == RTE_ETH_FLOW_NONFRAG_IPV6_TCP || \
674 (flow_type) == RTE_ETH_FLOW_NONFRAG_IPV6_UDP || \
675 (flow_type) == RTE_ETH_FLOW_NONFRAG_IPV6_SCTP || \
676 (flow_type) == RTE_ETH_FLOW_NONFRAG_IPV6_OTHER || \
677 (flow_type) == RTE_ETH_FLOW_L2_PAYLOAD)
679 #define I40E_VALID_PCTYPE(pctype) \
680 ((pctype) == I40E_FILTER_PCTYPE_FRAG_IPV4 || \
681 (pctype) == I40E_FILTER_PCTYPE_NONF_IPV4_TCP || \
682 (pctype) == I40E_FILTER_PCTYPE_NONF_IPV4_UDP || \
683 (pctype) == I40E_FILTER_PCTYPE_NONF_IPV4_SCTP || \
684 (pctype) == I40E_FILTER_PCTYPE_NONF_IPV4_OTHER || \
685 (pctype) == I40E_FILTER_PCTYPE_FRAG_IPV6 || \
686 (pctype) == I40E_FILTER_PCTYPE_NONF_IPV6_UDP || \
687 (pctype) == I40E_FILTER_PCTYPE_NONF_IPV6_TCP || \
688 (pctype) == I40E_FILTER_PCTYPE_NONF_IPV6_SCTP || \
689 (pctype) == I40E_FILTER_PCTYPE_NONF_IPV6_OTHER || \
690 (pctype) == I40E_FILTER_PCTYPE_L2_PAYLOAD)
692 #endif /* _I40E_ETHDEV_H_ */