4 * Copyright(c) 2010-2017 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 #include <sys/queue.h>
42 #include <netinet/in.h>
43 #include <rte_byteorder.h>
44 #include <rte_common.h>
45 #include <rte_cycles.h>
47 #include <rte_interrupts.h>
49 #include <rte_debug.h>
51 #include <rte_bus_pci.h>
52 #include <rte_atomic.h>
53 #include <rte_branch_prediction.h>
54 #include <rte_memory.h>
55 #include <rte_memzone.h>
57 #include <rte_alarm.h>
58 #include <rte_ether.h>
59 #include <rte_ethdev.h>
60 #include <rte_ethdev_pci.h>
61 #include <rte_malloc.h>
62 #include <rte_random.h>
64 #include <rte_hash_crc.h>
65 #ifdef RTE_LIBRTE_SECURITY
66 #include <rte_security_driver.h>
69 #include "ixgbe_logs.h"
70 #include "base/ixgbe_api.h"
71 #include "base/ixgbe_vf.h"
72 #include "base/ixgbe_common.h"
73 #include "ixgbe_ethdev.h"
74 #include "ixgbe_bypass.h"
75 #include "ixgbe_rxtx.h"
76 #include "base/ixgbe_type.h"
77 #include "base/ixgbe_phy.h"
78 #include "ixgbe_regs.h"
81 * High threshold controlling when to start sending XOFF frames. Must be at
82 * least 8 bytes less than receive packet buffer size. This value is in units
85 #define IXGBE_FC_HI 0x80
88 * Low threshold controlling when to start sending XON frames. This value is
89 * in units of 1024 bytes.
91 #define IXGBE_FC_LO 0x40
93 /* Default minimum inter-interrupt interval for EITR configuration */
94 #define IXGBE_MIN_INTER_INTERRUPT_INTERVAL_DEFAULT 0x79E
96 /* Timer value included in XOFF frames. */
97 #define IXGBE_FC_PAUSE 0x680
99 #define IXGBE_LINK_DOWN_CHECK_TIMEOUT 4000 /* ms */
100 #define IXGBE_LINK_UP_CHECK_TIMEOUT 1000 /* ms */
101 #define IXGBE_VMDQ_NUM_UC_MAC 4096 /* Maximum nb. of UC MAC addr. */
103 #define IXGBE_MMW_SIZE_DEFAULT 0x4
104 #define IXGBE_MMW_SIZE_JUMBO_FRAME 0x14
105 #define IXGBE_MAX_RING_DESC 4096 /* replicate define from rxtx */
108 * Default values for RX/TX configuration
110 #define IXGBE_DEFAULT_RX_FREE_THRESH 32
111 #define IXGBE_DEFAULT_RX_PTHRESH 8
112 #define IXGBE_DEFAULT_RX_HTHRESH 8
113 #define IXGBE_DEFAULT_RX_WTHRESH 0
115 #define IXGBE_DEFAULT_TX_FREE_THRESH 32
116 #define IXGBE_DEFAULT_TX_PTHRESH 32
117 #define IXGBE_DEFAULT_TX_HTHRESH 0
118 #define IXGBE_DEFAULT_TX_WTHRESH 0
119 #define IXGBE_DEFAULT_TX_RSBIT_THRESH 32
121 /* Bit shift and mask */
122 #define IXGBE_4_BIT_WIDTH (CHAR_BIT / 2)
123 #define IXGBE_4_BIT_MASK RTE_LEN2MASK(IXGBE_4_BIT_WIDTH, uint8_t)
124 #define IXGBE_8_BIT_WIDTH CHAR_BIT
125 #define IXGBE_8_BIT_MASK UINT8_MAX
127 #define IXGBEVF_PMD_NAME "rte_ixgbevf_pmd" /* PMD name */
129 #define IXGBE_QUEUE_STAT_COUNTERS (sizeof(hw_stats->qprc) / sizeof(hw_stats->qprc[0]))
131 #define IXGBE_HKEY_MAX_INDEX 10
133 /* Additional timesync values. */
134 #define NSEC_PER_SEC 1000000000L
135 #define IXGBE_INCVAL_10GB 0x66666666
136 #define IXGBE_INCVAL_1GB 0x40000000
137 #define IXGBE_INCVAL_100 0x50000000
138 #define IXGBE_INCVAL_SHIFT_10GB 28
139 #define IXGBE_INCVAL_SHIFT_1GB 24
140 #define IXGBE_INCVAL_SHIFT_100 21
141 #define IXGBE_INCVAL_SHIFT_82599 7
142 #define IXGBE_INCPER_SHIFT_82599 24
144 #define IXGBE_CYCLECOUNTER_MASK 0xffffffffffffffffULL
146 #define IXGBE_VT_CTL_POOLING_MODE_MASK 0x00030000
147 #define IXGBE_VT_CTL_POOLING_MODE_ETAG 0x00010000
148 #define DEFAULT_ETAG_ETYPE 0x893f
149 #define IXGBE_ETAG_ETYPE 0x00005084
150 #define IXGBE_ETAG_ETYPE_MASK 0x0000ffff
151 #define IXGBE_ETAG_ETYPE_VALID 0x80000000
152 #define IXGBE_RAH_ADTYPE 0x40000000
153 #define IXGBE_RAL_ETAG_FILTER_MASK 0x00003fff
154 #define IXGBE_VMVIR_TAGA_MASK 0x18000000
155 #define IXGBE_VMVIR_TAGA_ETAG_INSERT 0x08000000
156 #define IXGBE_VMTIR(_i) (0x00017000 + ((_i) * 4)) /* 64 of these (0-63) */
157 #define IXGBE_QDE_STRIP_TAG 0x00000004
158 #define IXGBE_VTEICR_MASK 0x07
160 #define IXGBE_EXVET_VET_EXT_SHIFT 16
161 #define IXGBE_DMATXCTL_VT_MASK 0xFFFF0000
163 static int eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev);
164 static int eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev);
165 static int ixgbe_fdir_filter_init(struct rte_eth_dev *eth_dev);
166 static int ixgbe_fdir_filter_uninit(struct rte_eth_dev *eth_dev);
167 static int ixgbe_l2_tn_filter_init(struct rte_eth_dev *eth_dev);
168 static int ixgbe_l2_tn_filter_uninit(struct rte_eth_dev *eth_dev);
169 static int ixgbe_ntuple_filter_uninit(struct rte_eth_dev *eth_dev);
170 static int ixgbe_dev_configure(struct rte_eth_dev *dev);
171 static int ixgbe_dev_start(struct rte_eth_dev *dev);
172 static void ixgbe_dev_stop(struct rte_eth_dev *dev);
173 static int ixgbe_dev_set_link_up(struct rte_eth_dev *dev);
174 static int ixgbe_dev_set_link_down(struct rte_eth_dev *dev);
175 static void ixgbe_dev_close(struct rte_eth_dev *dev);
176 static int ixgbe_dev_reset(struct rte_eth_dev *dev);
177 static void ixgbe_dev_promiscuous_enable(struct rte_eth_dev *dev);
178 static void ixgbe_dev_promiscuous_disable(struct rte_eth_dev *dev);
179 static void ixgbe_dev_allmulticast_enable(struct rte_eth_dev *dev);
180 static void ixgbe_dev_allmulticast_disable(struct rte_eth_dev *dev);
181 static int ixgbe_dev_link_update(struct rte_eth_dev *dev,
182 int wait_to_complete);
183 static int ixgbe_dev_stats_get(struct rte_eth_dev *dev,
184 struct rte_eth_stats *stats);
185 static int ixgbe_dev_xstats_get(struct rte_eth_dev *dev,
186 struct rte_eth_xstat *xstats, unsigned n);
187 static int ixgbevf_dev_xstats_get(struct rte_eth_dev *dev,
188 struct rte_eth_xstat *xstats, unsigned n);
190 ixgbe_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids,
191 uint64_t *values, unsigned int n);
192 static void ixgbe_dev_stats_reset(struct rte_eth_dev *dev);
193 static void ixgbe_dev_xstats_reset(struct rte_eth_dev *dev);
194 static int ixgbe_dev_xstats_get_names(struct rte_eth_dev *dev,
195 struct rte_eth_xstat_name *xstats_names,
197 static int ixgbevf_dev_xstats_get_names(struct rte_eth_dev *dev,
198 struct rte_eth_xstat_name *xstats_names, unsigned limit);
199 static int ixgbe_dev_xstats_get_names_by_id(
200 struct rte_eth_dev *dev,
201 struct rte_eth_xstat_name *xstats_names,
204 static int ixgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
208 static int ixgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
210 static void ixgbe_dev_info_get(struct rte_eth_dev *dev,
211 struct rte_eth_dev_info *dev_info);
212 static const uint32_t *ixgbe_dev_supported_ptypes_get(struct rte_eth_dev *dev);
213 static void ixgbevf_dev_info_get(struct rte_eth_dev *dev,
214 struct rte_eth_dev_info *dev_info);
215 static int ixgbe_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
217 static int ixgbe_vlan_filter_set(struct rte_eth_dev *dev,
218 uint16_t vlan_id, int on);
219 static int ixgbe_vlan_tpid_set(struct rte_eth_dev *dev,
220 enum rte_vlan_type vlan_type,
222 static void ixgbe_vlan_hw_strip_bitmap_set(struct rte_eth_dev *dev,
223 uint16_t queue, bool on);
224 static void ixgbe_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue,
226 static int ixgbe_vlan_offload_set(struct rte_eth_dev *dev, int mask);
227 static void ixgbe_vlan_hw_strip_enable(struct rte_eth_dev *dev, uint16_t queue);
228 static void ixgbe_vlan_hw_strip_disable(struct rte_eth_dev *dev, uint16_t queue);
229 static void ixgbe_vlan_hw_extend_enable(struct rte_eth_dev *dev);
230 static void ixgbe_vlan_hw_extend_disable(struct rte_eth_dev *dev);
232 static int ixgbe_dev_led_on(struct rte_eth_dev *dev);
233 static int ixgbe_dev_led_off(struct rte_eth_dev *dev);
234 static int ixgbe_flow_ctrl_get(struct rte_eth_dev *dev,
235 struct rte_eth_fc_conf *fc_conf);
236 static int ixgbe_flow_ctrl_set(struct rte_eth_dev *dev,
237 struct rte_eth_fc_conf *fc_conf);
238 static int ixgbe_priority_flow_ctrl_set(struct rte_eth_dev *dev,
239 struct rte_eth_pfc_conf *pfc_conf);
240 static int ixgbe_dev_rss_reta_update(struct rte_eth_dev *dev,
241 struct rte_eth_rss_reta_entry64 *reta_conf,
243 static int ixgbe_dev_rss_reta_query(struct rte_eth_dev *dev,
244 struct rte_eth_rss_reta_entry64 *reta_conf,
246 static void ixgbe_dev_link_status_print(struct rte_eth_dev *dev);
247 static int ixgbe_dev_lsc_interrupt_setup(struct rte_eth_dev *dev, uint8_t on);
248 static int ixgbe_dev_macsec_interrupt_setup(struct rte_eth_dev *dev);
249 static int ixgbe_dev_rxq_interrupt_setup(struct rte_eth_dev *dev);
250 static int ixgbe_dev_interrupt_get_status(struct rte_eth_dev *dev);
251 static int ixgbe_dev_interrupt_action(struct rte_eth_dev *dev,
252 struct rte_intr_handle *handle);
253 static void ixgbe_dev_interrupt_handler(void *param);
254 static void ixgbe_dev_interrupt_delayed_handler(void *param);
255 static int ixgbe_add_rar(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
256 uint32_t index, uint32_t pool);
257 static void ixgbe_remove_rar(struct rte_eth_dev *dev, uint32_t index);
258 static void ixgbe_set_default_mac_addr(struct rte_eth_dev *dev,
259 struct ether_addr *mac_addr);
260 static void ixgbe_dcb_init(struct ixgbe_hw *hw, struct ixgbe_dcb_config *dcb_config);
261 static bool is_device_supported(struct rte_eth_dev *dev,
262 struct rte_pci_driver *drv);
264 /* For Virtual Function support */
265 static int eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev);
266 static int eth_ixgbevf_dev_uninit(struct rte_eth_dev *eth_dev);
267 static int ixgbevf_dev_configure(struct rte_eth_dev *dev);
268 static int ixgbevf_dev_start(struct rte_eth_dev *dev);
269 static int ixgbevf_dev_link_update(struct rte_eth_dev *dev,
270 int wait_to_complete);
271 static void ixgbevf_dev_stop(struct rte_eth_dev *dev);
272 static void ixgbevf_dev_close(struct rte_eth_dev *dev);
273 static int ixgbevf_dev_reset(struct rte_eth_dev *dev);
274 static void ixgbevf_intr_disable(struct ixgbe_hw *hw);
275 static void ixgbevf_intr_enable(struct ixgbe_hw *hw);
276 static int ixgbevf_dev_stats_get(struct rte_eth_dev *dev,
277 struct rte_eth_stats *stats);
278 static void ixgbevf_dev_stats_reset(struct rte_eth_dev *dev);
279 static int ixgbevf_vlan_filter_set(struct rte_eth_dev *dev,
280 uint16_t vlan_id, int on);
281 static void ixgbevf_vlan_strip_queue_set(struct rte_eth_dev *dev,
282 uint16_t queue, int on);
283 static int ixgbevf_vlan_offload_set(struct rte_eth_dev *dev, int mask);
284 static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on);
285 static int ixgbevf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev,
287 static int ixgbevf_dev_rx_queue_intr_disable(struct rte_eth_dev *dev,
289 static void ixgbevf_set_ivar_map(struct ixgbe_hw *hw, int8_t direction,
290 uint8_t queue, uint8_t msix_vector);
291 static void ixgbevf_configure_msix(struct rte_eth_dev *dev);
292 static void ixgbevf_dev_allmulticast_enable(struct rte_eth_dev *dev);
293 static void ixgbevf_dev_allmulticast_disable(struct rte_eth_dev *dev);
295 /* For Eth VMDQ APIs support */
296 static int ixgbe_uc_hash_table_set(struct rte_eth_dev *dev, struct
297 ether_addr * mac_addr, uint8_t on);
298 static int ixgbe_uc_all_hash_table_set(struct rte_eth_dev *dev, uint8_t on);
299 static int ixgbe_mirror_rule_set(struct rte_eth_dev *dev,
300 struct rte_eth_mirror_conf *mirror_conf,
301 uint8_t rule_id, uint8_t on);
302 static int ixgbe_mirror_rule_reset(struct rte_eth_dev *dev,
304 static int ixgbe_dev_rx_queue_intr_enable(struct rte_eth_dev *dev,
306 static int ixgbe_dev_rx_queue_intr_disable(struct rte_eth_dev *dev,
308 static void ixgbe_set_ivar_map(struct ixgbe_hw *hw, int8_t direction,
309 uint8_t queue, uint8_t msix_vector);
310 static void ixgbe_configure_msix(struct rte_eth_dev *dev);
312 static int ixgbevf_add_mac_addr(struct rte_eth_dev *dev,
313 struct ether_addr *mac_addr,
314 uint32_t index, uint32_t pool);
315 static void ixgbevf_remove_mac_addr(struct rte_eth_dev *dev, uint32_t index);
316 static void ixgbevf_set_default_mac_addr(struct rte_eth_dev *dev,
317 struct ether_addr *mac_addr);
318 static int ixgbe_syn_filter_get(struct rte_eth_dev *dev,
319 struct rte_eth_syn_filter *filter);
320 static int ixgbe_syn_filter_handle(struct rte_eth_dev *dev,
321 enum rte_filter_op filter_op,
323 static int ixgbe_add_5tuple_filter(struct rte_eth_dev *dev,
324 struct ixgbe_5tuple_filter *filter);
325 static void ixgbe_remove_5tuple_filter(struct rte_eth_dev *dev,
326 struct ixgbe_5tuple_filter *filter);
327 static int ixgbe_ntuple_filter_handle(struct rte_eth_dev *dev,
328 enum rte_filter_op filter_op,
330 static int ixgbe_get_ntuple_filter(struct rte_eth_dev *dev,
331 struct rte_eth_ntuple_filter *filter);
332 static int ixgbe_ethertype_filter_handle(struct rte_eth_dev *dev,
333 enum rte_filter_op filter_op,
335 static int ixgbe_get_ethertype_filter(struct rte_eth_dev *dev,
336 struct rte_eth_ethertype_filter *filter);
337 static int ixgbe_dev_filter_ctrl(struct rte_eth_dev *dev,
338 enum rte_filter_type filter_type,
339 enum rte_filter_op filter_op,
341 static int ixgbevf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu);
343 static int ixgbe_dev_set_mc_addr_list(struct rte_eth_dev *dev,
344 struct ether_addr *mc_addr_set,
345 uint32_t nb_mc_addr);
346 static int ixgbe_dev_get_dcb_info(struct rte_eth_dev *dev,
347 struct rte_eth_dcb_info *dcb_info);
349 static int ixgbe_get_reg_length(struct rte_eth_dev *dev);
350 static int ixgbe_get_regs(struct rte_eth_dev *dev,
351 struct rte_dev_reg_info *regs);
352 static int ixgbe_get_eeprom_length(struct rte_eth_dev *dev);
353 static int ixgbe_get_eeprom(struct rte_eth_dev *dev,
354 struct rte_dev_eeprom_info *eeprom);
355 static int ixgbe_set_eeprom(struct rte_eth_dev *dev,
356 struct rte_dev_eeprom_info *eeprom);
358 static int ixgbevf_get_reg_length(struct rte_eth_dev *dev);
359 static int ixgbevf_get_regs(struct rte_eth_dev *dev,
360 struct rte_dev_reg_info *regs);
362 static int ixgbe_timesync_enable(struct rte_eth_dev *dev);
363 static int ixgbe_timesync_disable(struct rte_eth_dev *dev);
364 static int ixgbe_timesync_read_rx_timestamp(struct rte_eth_dev *dev,
365 struct timespec *timestamp,
367 static int ixgbe_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
368 struct timespec *timestamp);
369 static int ixgbe_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta);
370 static int ixgbe_timesync_read_time(struct rte_eth_dev *dev,
371 struct timespec *timestamp);
372 static int ixgbe_timesync_write_time(struct rte_eth_dev *dev,
373 const struct timespec *timestamp);
374 static void ixgbevf_dev_interrupt_handler(void *param);
376 static int ixgbe_dev_l2_tunnel_eth_type_conf
377 (struct rte_eth_dev *dev, struct rte_eth_l2_tunnel_conf *l2_tunnel);
378 static int ixgbe_dev_l2_tunnel_offload_set
379 (struct rte_eth_dev *dev,
380 struct rte_eth_l2_tunnel_conf *l2_tunnel,
383 static int ixgbe_dev_l2_tunnel_filter_handle(struct rte_eth_dev *dev,
384 enum rte_filter_op filter_op,
387 static int ixgbe_dev_udp_tunnel_port_add(struct rte_eth_dev *dev,
388 struct rte_eth_udp_tunnel *udp_tunnel);
389 static int ixgbe_dev_udp_tunnel_port_del(struct rte_eth_dev *dev,
390 struct rte_eth_udp_tunnel *udp_tunnel);
391 static int ixgbe_filter_restore(struct rte_eth_dev *dev);
392 static void ixgbe_l2_tunnel_conf(struct rte_eth_dev *dev);
395 * Define VF Stats MACRO for Non "cleared on read" register
397 #define UPDATE_VF_STAT(reg, last, cur) \
399 uint32_t latest = IXGBE_READ_REG(hw, reg); \
400 cur += (latest - last) & UINT_MAX; \
404 #define UPDATE_VF_STAT_36BIT(lsb, msb, last, cur) \
406 u64 new_lsb = IXGBE_READ_REG(hw, lsb); \
407 u64 new_msb = IXGBE_READ_REG(hw, msb); \
408 u64 latest = ((new_msb << 32) | new_lsb); \
409 cur += (0x1000000000LL + latest - last) & 0xFFFFFFFFFLL; \
413 #define IXGBE_SET_HWSTRIP(h, q) do {\
414 uint32_t idx = (q) / (sizeof((h)->bitmap[0]) * NBBY); \
415 uint32_t bit = (q) % (sizeof((h)->bitmap[0]) * NBBY); \
416 (h)->bitmap[idx] |= 1 << bit;\
419 #define IXGBE_CLEAR_HWSTRIP(h, q) do {\
420 uint32_t idx = (q) / (sizeof((h)->bitmap[0]) * NBBY); \
421 uint32_t bit = (q) % (sizeof((h)->bitmap[0]) * NBBY); \
422 (h)->bitmap[idx] &= ~(1 << bit);\
425 #define IXGBE_GET_HWSTRIP(h, q, r) do {\
426 uint32_t idx = (q) / (sizeof((h)->bitmap[0]) * NBBY); \
427 uint32_t bit = (q) % (sizeof((h)->bitmap[0]) * NBBY); \
428 (r) = (h)->bitmap[idx] >> bit & 1;\
432 * The set of PCI devices this driver supports
434 static const struct rte_pci_id pci_id_ixgbe_map[] = {
435 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598) },
436 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598_BX) },
437 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AF_DUAL_PORT) },
438 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AF_SINGLE_PORT) },
439 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AT) },
440 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AT2) },
441 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598EB_SFP_LOM) },
442 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598EB_CX4) },
443 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598_CX4_DUAL_PORT) },
444 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598_DA_DUAL_PORT) },
445 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM) },
446 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598EB_XF_LR) },
447 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_KX4) },
448 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_KX4_MEZZ) },
449 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_KR) },
450 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_COMBO_BACKPLANE) },
451 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_CX4) },
452 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP) },
453 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_BACKPLANE_FCOE) },
454 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP_FCOE) },
455 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP_EM) },
456 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP_SF2) },
457 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP_SF_QP) },
458 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_QSFP_SF_QP) },
459 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599EN_SFP) },
460 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_XAUI_LOM) },
461 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_T3_LOM) },
462 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_LS) },
463 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X540T) },
464 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X540T1) },
465 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_SFP) },
466 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_10G_T) },
467 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_1G_T) },
468 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550T) },
469 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550T1) },
470 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_KR) },
471 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_KR_L) },
472 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_SFP_N) },
473 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_SGMII) },
474 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_SGMII_L) },
475 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_10G_T) },
476 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_QSFP) },
477 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_QSFP_N) },
478 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_SFP) },
479 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_1G_T) },
480 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_1G_T_L) },
481 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_KX4) },
482 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_KR) },
483 #ifdef RTE_LIBRTE_IXGBE_BYPASS
484 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_BYPASS) },
486 { .vendor_id = 0, /* sentinel */ },
490 * The set of PCI devices this driver supports (for 82599 VF)
492 static const struct rte_pci_id pci_id_ixgbevf_map[] = {
493 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_VF) },
494 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_VF_HV) },
495 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X540_VF) },
496 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X540_VF_HV) },
497 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550_VF_HV) },
498 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550_VF) },
499 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_VF) },
500 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_VF_HV) },
501 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_VF) },
502 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_VF_HV) },
503 { .vendor_id = 0, /* sentinel */ },
506 static const struct rte_eth_desc_lim rx_desc_lim = {
507 .nb_max = IXGBE_MAX_RING_DESC,
508 .nb_min = IXGBE_MIN_RING_DESC,
509 .nb_align = IXGBE_RXD_ALIGN,
512 static const struct rte_eth_desc_lim tx_desc_lim = {
513 .nb_max = IXGBE_MAX_RING_DESC,
514 .nb_min = IXGBE_MIN_RING_DESC,
515 .nb_align = IXGBE_TXD_ALIGN,
516 .nb_seg_max = IXGBE_TX_MAX_SEG,
517 .nb_mtu_seg_max = IXGBE_TX_MAX_SEG,
520 static const struct eth_dev_ops ixgbe_eth_dev_ops = {
521 .dev_configure = ixgbe_dev_configure,
522 .dev_start = ixgbe_dev_start,
523 .dev_stop = ixgbe_dev_stop,
524 .dev_set_link_up = ixgbe_dev_set_link_up,
525 .dev_set_link_down = ixgbe_dev_set_link_down,
526 .dev_close = ixgbe_dev_close,
527 .dev_reset = ixgbe_dev_reset,
528 .promiscuous_enable = ixgbe_dev_promiscuous_enable,
529 .promiscuous_disable = ixgbe_dev_promiscuous_disable,
530 .allmulticast_enable = ixgbe_dev_allmulticast_enable,
531 .allmulticast_disable = ixgbe_dev_allmulticast_disable,
532 .link_update = ixgbe_dev_link_update,
533 .stats_get = ixgbe_dev_stats_get,
534 .xstats_get = ixgbe_dev_xstats_get,
535 .xstats_get_by_id = ixgbe_dev_xstats_get_by_id,
536 .stats_reset = ixgbe_dev_stats_reset,
537 .xstats_reset = ixgbe_dev_xstats_reset,
538 .xstats_get_names = ixgbe_dev_xstats_get_names,
539 .xstats_get_names_by_id = ixgbe_dev_xstats_get_names_by_id,
540 .queue_stats_mapping_set = ixgbe_dev_queue_stats_mapping_set,
541 .fw_version_get = ixgbe_fw_version_get,
542 .dev_infos_get = ixgbe_dev_info_get,
543 .dev_supported_ptypes_get = ixgbe_dev_supported_ptypes_get,
544 .mtu_set = ixgbe_dev_mtu_set,
545 .vlan_filter_set = ixgbe_vlan_filter_set,
546 .vlan_tpid_set = ixgbe_vlan_tpid_set,
547 .vlan_offload_set = ixgbe_vlan_offload_set,
548 .vlan_strip_queue_set = ixgbe_vlan_strip_queue_set,
549 .rx_queue_start = ixgbe_dev_rx_queue_start,
550 .rx_queue_stop = ixgbe_dev_rx_queue_stop,
551 .tx_queue_start = ixgbe_dev_tx_queue_start,
552 .tx_queue_stop = ixgbe_dev_tx_queue_stop,
553 .rx_queue_setup = ixgbe_dev_rx_queue_setup,
554 .rx_queue_intr_enable = ixgbe_dev_rx_queue_intr_enable,
555 .rx_queue_intr_disable = ixgbe_dev_rx_queue_intr_disable,
556 .rx_queue_release = ixgbe_dev_rx_queue_release,
557 .rx_queue_count = ixgbe_dev_rx_queue_count,
558 .rx_descriptor_done = ixgbe_dev_rx_descriptor_done,
559 .rx_descriptor_status = ixgbe_dev_rx_descriptor_status,
560 .tx_descriptor_status = ixgbe_dev_tx_descriptor_status,
561 .tx_queue_setup = ixgbe_dev_tx_queue_setup,
562 .tx_queue_release = ixgbe_dev_tx_queue_release,
563 .dev_led_on = ixgbe_dev_led_on,
564 .dev_led_off = ixgbe_dev_led_off,
565 .flow_ctrl_get = ixgbe_flow_ctrl_get,
566 .flow_ctrl_set = ixgbe_flow_ctrl_set,
567 .priority_flow_ctrl_set = ixgbe_priority_flow_ctrl_set,
568 .mac_addr_add = ixgbe_add_rar,
569 .mac_addr_remove = ixgbe_remove_rar,
570 .mac_addr_set = ixgbe_set_default_mac_addr,
571 .uc_hash_table_set = ixgbe_uc_hash_table_set,
572 .uc_all_hash_table_set = ixgbe_uc_all_hash_table_set,
573 .mirror_rule_set = ixgbe_mirror_rule_set,
574 .mirror_rule_reset = ixgbe_mirror_rule_reset,
575 .set_queue_rate_limit = ixgbe_set_queue_rate_limit,
576 .reta_update = ixgbe_dev_rss_reta_update,
577 .reta_query = ixgbe_dev_rss_reta_query,
578 .rss_hash_update = ixgbe_dev_rss_hash_update,
579 .rss_hash_conf_get = ixgbe_dev_rss_hash_conf_get,
580 .filter_ctrl = ixgbe_dev_filter_ctrl,
581 .set_mc_addr_list = ixgbe_dev_set_mc_addr_list,
582 .rxq_info_get = ixgbe_rxq_info_get,
583 .txq_info_get = ixgbe_txq_info_get,
584 .timesync_enable = ixgbe_timesync_enable,
585 .timesync_disable = ixgbe_timesync_disable,
586 .timesync_read_rx_timestamp = ixgbe_timesync_read_rx_timestamp,
587 .timesync_read_tx_timestamp = ixgbe_timesync_read_tx_timestamp,
588 .get_reg = ixgbe_get_regs,
589 .get_eeprom_length = ixgbe_get_eeprom_length,
590 .get_eeprom = ixgbe_get_eeprom,
591 .set_eeprom = ixgbe_set_eeprom,
592 .get_dcb_info = ixgbe_dev_get_dcb_info,
593 .timesync_adjust_time = ixgbe_timesync_adjust_time,
594 .timesync_read_time = ixgbe_timesync_read_time,
595 .timesync_write_time = ixgbe_timesync_write_time,
596 .l2_tunnel_eth_type_conf = ixgbe_dev_l2_tunnel_eth_type_conf,
597 .l2_tunnel_offload_set = ixgbe_dev_l2_tunnel_offload_set,
598 .udp_tunnel_port_add = ixgbe_dev_udp_tunnel_port_add,
599 .udp_tunnel_port_del = ixgbe_dev_udp_tunnel_port_del,
600 .tm_ops_get = ixgbe_tm_ops_get,
604 * dev_ops for virtual function, bare necessities for basic vf
605 * operation have been implemented
607 static const struct eth_dev_ops ixgbevf_eth_dev_ops = {
608 .dev_configure = ixgbevf_dev_configure,
609 .dev_start = ixgbevf_dev_start,
610 .dev_stop = ixgbevf_dev_stop,
611 .link_update = ixgbevf_dev_link_update,
612 .stats_get = ixgbevf_dev_stats_get,
613 .xstats_get = ixgbevf_dev_xstats_get,
614 .stats_reset = ixgbevf_dev_stats_reset,
615 .xstats_reset = ixgbevf_dev_stats_reset,
616 .xstats_get_names = ixgbevf_dev_xstats_get_names,
617 .dev_close = ixgbevf_dev_close,
618 .dev_reset = ixgbevf_dev_reset,
619 .allmulticast_enable = ixgbevf_dev_allmulticast_enable,
620 .allmulticast_disable = ixgbevf_dev_allmulticast_disable,
621 .dev_infos_get = ixgbevf_dev_info_get,
622 .dev_supported_ptypes_get = ixgbe_dev_supported_ptypes_get,
623 .mtu_set = ixgbevf_dev_set_mtu,
624 .vlan_filter_set = ixgbevf_vlan_filter_set,
625 .vlan_strip_queue_set = ixgbevf_vlan_strip_queue_set,
626 .vlan_offload_set = ixgbevf_vlan_offload_set,
627 .rx_queue_setup = ixgbe_dev_rx_queue_setup,
628 .rx_queue_release = ixgbe_dev_rx_queue_release,
629 .rx_descriptor_done = ixgbe_dev_rx_descriptor_done,
630 .rx_descriptor_status = ixgbe_dev_rx_descriptor_status,
631 .tx_descriptor_status = ixgbe_dev_tx_descriptor_status,
632 .tx_queue_setup = ixgbe_dev_tx_queue_setup,
633 .tx_queue_release = ixgbe_dev_tx_queue_release,
634 .rx_queue_intr_enable = ixgbevf_dev_rx_queue_intr_enable,
635 .rx_queue_intr_disable = ixgbevf_dev_rx_queue_intr_disable,
636 .mac_addr_add = ixgbevf_add_mac_addr,
637 .mac_addr_remove = ixgbevf_remove_mac_addr,
638 .set_mc_addr_list = ixgbe_dev_set_mc_addr_list,
639 .rxq_info_get = ixgbe_rxq_info_get,
640 .txq_info_get = ixgbe_txq_info_get,
641 .mac_addr_set = ixgbevf_set_default_mac_addr,
642 .get_reg = ixgbevf_get_regs,
643 .reta_update = ixgbe_dev_rss_reta_update,
644 .reta_query = ixgbe_dev_rss_reta_query,
645 .rss_hash_update = ixgbe_dev_rss_hash_update,
646 .rss_hash_conf_get = ixgbe_dev_rss_hash_conf_get,
649 /* store statistics names and its offset in stats structure */
650 struct rte_ixgbe_xstats_name_off {
651 char name[RTE_ETH_XSTATS_NAME_SIZE];
655 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_stats_strings[] = {
656 {"rx_crc_errors", offsetof(struct ixgbe_hw_stats, crcerrs)},
657 {"rx_illegal_byte_errors", offsetof(struct ixgbe_hw_stats, illerrc)},
658 {"rx_error_bytes", offsetof(struct ixgbe_hw_stats, errbc)},
659 {"mac_local_errors", offsetof(struct ixgbe_hw_stats, mlfc)},
660 {"mac_remote_errors", offsetof(struct ixgbe_hw_stats, mrfc)},
661 {"rx_length_errors", offsetof(struct ixgbe_hw_stats, rlec)},
662 {"tx_xon_packets", offsetof(struct ixgbe_hw_stats, lxontxc)},
663 {"rx_xon_packets", offsetof(struct ixgbe_hw_stats, lxonrxc)},
664 {"tx_xoff_packets", offsetof(struct ixgbe_hw_stats, lxofftxc)},
665 {"rx_xoff_packets", offsetof(struct ixgbe_hw_stats, lxoffrxc)},
666 {"rx_size_64_packets", offsetof(struct ixgbe_hw_stats, prc64)},
667 {"rx_size_65_to_127_packets", offsetof(struct ixgbe_hw_stats, prc127)},
668 {"rx_size_128_to_255_packets", offsetof(struct ixgbe_hw_stats, prc255)},
669 {"rx_size_256_to_511_packets", offsetof(struct ixgbe_hw_stats, prc511)},
670 {"rx_size_512_to_1023_packets", offsetof(struct ixgbe_hw_stats,
672 {"rx_size_1024_to_max_packets", offsetof(struct ixgbe_hw_stats,
674 {"rx_broadcast_packets", offsetof(struct ixgbe_hw_stats, bprc)},
675 {"rx_multicast_packets", offsetof(struct ixgbe_hw_stats, mprc)},
676 {"rx_fragment_errors", offsetof(struct ixgbe_hw_stats, rfc)},
677 {"rx_undersize_errors", offsetof(struct ixgbe_hw_stats, ruc)},
678 {"rx_oversize_errors", offsetof(struct ixgbe_hw_stats, roc)},
679 {"rx_jabber_errors", offsetof(struct ixgbe_hw_stats, rjc)},
680 {"rx_management_packets", offsetof(struct ixgbe_hw_stats, mngprc)},
681 {"rx_management_dropped", offsetof(struct ixgbe_hw_stats, mngpdc)},
682 {"tx_management_packets", offsetof(struct ixgbe_hw_stats, mngptc)},
683 {"rx_total_packets", offsetof(struct ixgbe_hw_stats, tpr)},
684 {"rx_total_bytes", offsetof(struct ixgbe_hw_stats, tor)},
685 {"tx_total_packets", offsetof(struct ixgbe_hw_stats, tpt)},
686 {"tx_size_64_packets", offsetof(struct ixgbe_hw_stats, ptc64)},
687 {"tx_size_65_to_127_packets", offsetof(struct ixgbe_hw_stats, ptc127)},
688 {"tx_size_128_to_255_packets", offsetof(struct ixgbe_hw_stats, ptc255)},
689 {"tx_size_256_to_511_packets", offsetof(struct ixgbe_hw_stats, ptc511)},
690 {"tx_size_512_to_1023_packets", offsetof(struct ixgbe_hw_stats,
692 {"tx_size_1024_to_max_packets", offsetof(struct ixgbe_hw_stats,
694 {"tx_multicast_packets", offsetof(struct ixgbe_hw_stats, mptc)},
695 {"tx_broadcast_packets", offsetof(struct ixgbe_hw_stats, bptc)},
696 {"rx_mac_short_packet_dropped", offsetof(struct ixgbe_hw_stats, mspdc)},
697 {"rx_l3_l4_xsum_error", offsetof(struct ixgbe_hw_stats, xec)},
699 {"flow_director_added_filters", offsetof(struct ixgbe_hw_stats,
701 {"flow_director_removed_filters", offsetof(struct ixgbe_hw_stats,
703 {"flow_director_filter_add_errors", offsetof(struct ixgbe_hw_stats,
705 {"flow_director_filter_remove_errors", offsetof(struct ixgbe_hw_stats,
707 {"flow_director_matched_filters", offsetof(struct ixgbe_hw_stats,
709 {"flow_director_missed_filters", offsetof(struct ixgbe_hw_stats,
712 {"rx_fcoe_crc_errors", offsetof(struct ixgbe_hw_stats, fccrc)},
713 {"rx_fcoe_dropped", offsetof(struct ixgbe_hw_stats, fcoerpdc)},
714 {"rx_fcoe_mbuf_allocation_errors", offsetof(struct ixgbe_hw_stats,
716 {"rx_fcoe_packets", offsetof(struct ixgbe_hw_stats, fcoeprc)},
717 {"tx_fcoe_packets", offsetof(struct ixgbe_hw_stats, fcoeptc)},
718 {"rx_fcoe_bytes", offsetof(struct ixgbe_hw_stats, fcoedwrc)},
719 {"tx_fcoe_bytes", offsetof(struct ixgbe_hw_stats, fcoedwtc)},
720 {"rx_fcoe_no_direct_data_placement", offsetof(struct ixgbe_hw_stats,
722 {"rx_fcoe_no_direct_data_placement_ext_buff",
723 offsetof(struct ixgbe_hw_stats, fcoe_noddp_ext_buff)},
725 {"tx_flow_control_xon_packets", offsetof(struct ixgbe_hw_stats,
727 {"rx_flow_control_xon_packets", offsetof(struct ixgbe_hw_stats,
729 {"tx_flow_control_xoff_packets", offsetof(struct ixgbe_hw_stats,
731 {"rx_flow_control_xoff_packets", offsetof(struct ixgbe_hw_stats,
733 {"rx_total_missed_packets", offsetof(struct ixgbe_hw_stats, mpctotal)},
736 #define IXGBE_NB_HW_STATS (sizeof(rte_ixgbe_stats_strings) / \
737 sizeof(rte_ixgbe_stats_strings[0]))
739 /* MACsec statistics */
740 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_macsec_strings[] = {
741 {"out_pkts_untagged", offsetof(struct ixgbe_macsec_stats,
743 {"out_pkts_encrypted", offsetof(struct ixgbe_macsec_stats,
744 out_pkts_encrypted)},
745 {"out_pkts_protected", offsetof(struct ixgbe_macsec_stats,
746 out_pkts_protected)},
747 {"out_octets_encrypted", offsetof(struct ixgbe_macsec_stats,
748 out_octets_encrypted)},
749 {"out_octets_protected", offsetof(struct ixgbe_macsec_stats,
750 out_octets_protected)},
751 {"in_pkts_untagged", offsetof(struct ixgbe_macsec_stats,
753 {"in_pkts_badtag", offsetof(struct ixgbe_macsec_stats,
755 {"in_pkts_nosci", offsetof(struct ixgbe_macsec_stats,
757 {"in_pkts_unknownsci", offsetof(struct ixgbe_macsec_stats,
758 in_pkts_unknownsci)},
759 {"in_octets_decrypted", offsetof(struct ixgbe_macsec_stats,
760 in_octets_decrypted)},
761 {"in_octets_validated", offsetof(struct ixgbe_macsec_stats,
762 in_octets_validated)},
763 {"in_pkts_unchecked", offsetof(struct ixgbe_macsec_stats,
765 {"in_pkts_delayed", offsetof(struct ixgbe_macsec_stats,
767 {"in_pkts_late", offsetof(struct ixgbe_macsec_stats,
769 {"in_pkts_ok", offsetof(struct ixgbe_macsec_stats,
771 {"in_pkts_invalid", offsetof(struct ixgbe_macsec_stats,
773 {"in_pkts_notvalid", offsetof(struct ixgbe_macsec_stats,
775 {"in_pkts_unusedsa", offsetof(struct ixgbe_macsec_stats,
777 {"in_pkts_notusingsa", offsetof(struct ixgbe_macsec_stats,
778 in_pkts_notusingsa)},
781 #define IXGBE_NB_MACSEC_STATS (sizeof(rte_ixgbe_macsec_strings) / \
782 sizeof(rte_ixgbe_macsec_strings[0]))
784 /* Per-queue statistics */
785 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_rxq_strings[] = {
786 {"mbuf_allocation_errors", offsetof(struct ixgbe_hw_stats, rnbc)},
787 {"dropped", offsetof(struct ixgbe_hw_stats, mpc)},
788 {"xon_packets", offsetof(struct ixgbe_hw_stats, pxonrxc)},
789 {"xoff_packets", offsetof(struct ixgbe_hw_stats, pxoffrxc)},
792 #define IXGBE_NB_RXQ_PRIO_STATS (sizeof(rte_ixgbe_rxq_strings) / \
793 sizeof(rte_ixgbe_rxq_strings[0]))
794 #define IXGBE_NB_RXQ_PRIO_VALUES 8
796 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_txq_strings[] = {
797 {"xon_packets", offsetof(struct ixgbe_hw_stats, pxontxc)},
798 {"xoff_packets", offsetof(struct ixgbe_hw_stats, pxofftxc)},
799 {"xon_to_xoff_packets", offsetof(struct ixgbe_hw_stats,
803 #define IXGBE_NB_TXQ_PRIO_STATS (sizeof(rte_ixgbe_txq_strings) / \
804 sizeof(rte_ixgbe_txq_strings[0]))
805 #define IXGBE_NB_TXQ_PRIO_VALUES 8
807 static const struct rte_ixgbe_xstats_name_off rte_ixgbevf_stats_strings[] = {
808 {"rx_multicast_packets", offsetof(struct ixgbevf_hw_stats, vfmprc)},
811 #define IXGBEVF_NB_XSTATS (sizeof(rte_ixgbevf_stats_strings) / \
812 sizeof(rte_ixgbevf_stats_strings[0]))
815 * Atomically reads the link status information from global
816 * structure rte_eth_dev.
819 * - Pointer to the structure rte_eth_dev to read from.
820 * - Pointer to the buffer to be saved with the link status.
823 * - On success, zero.
824 * - On failure, negative value.
827 rte_ixgbe_dev_atomic_read_link_status(struct rte_eth_dev *dev,
828 struct rte_eth_link *link)
830 struct rte_eth_link *dst = link;
831 struct rte_eth_link *src = &(dev->data->dev_link);
833 if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
834 *(uint64_t *)src) == 0)
841 * Atomically writes the link status information into global
842 * structure rte_eth_dev.
845 * - Pointer to the structure rte_eth_dev to read from.
846 * - Pointer to the buffer to be saved with the link status.
849 * - On success, zero.
850 * - On failure, negative value.
853 rte_ixgbe_dev_atomic_write_link_status(struct rte_eth_dev *dev,
854 struct rte_eth_link *link)
856 struct rte_eth_link *dst = &(dev->data->dev_link);
857 struct rte_eth_link *src = link;
859 if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
860 *(uint64_t *)src) == 0)
867 * This function is the same as ixgbe_is_sfp() in base/ixgbe.h.
870 ixgbe_is_sfp(struct ixgbe_hw *hw)
872 switch (hw->phy.type) {
873 case ixgbe_phy_sfp_avago:
874 case ixgbe_phy_sfp_ftl:
875 case ixgbe_phy_sfp_intel:
876 case ixgbe_phy_sfp_unknown:
877 case ixgbe_phy_sfp_passive_tyco:
878 case ixgbe_phy_sfp_passive_unknown:
885 static inline int32_t
886 ixgbe_pf_reset_hw(struct ixgbe_hw *hw)
891 status = ixgbe_reset_hw(hw);
893 ctrl_ext = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
894 /* Set PF Reset Done bit so PF/VF Mail Ops can work */
895 ctrl_ext |= IXGBE_CTRL_EXT_PFRSTD;
896 IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl_ext);
897 IXGBE_WRITE_FLUSH(hw);
899 if (status == IXGBE_ERR_SFP_NOT_PRESENT)
900 status = IXGBE_SUCCESS;
905 ixgbe_enable_intr(struct rte_eth_dev *dev)
907 struct ixgbe_interrupt *intr =
908 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
909 struct ixgbe_hw *hw =
910 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
912 IXGBE_WRITE_REG(hw, IXGBE_EIMS, intr->mask);
913 IXGBE_WRITE_FLUSH(hw);
917 * This function is based on ixgbe_disable_intr() in base/ixgbe.h.
920 ixgbe_disable_intr(struct ixgbe_hw *hw)
922 PMD_INIT_FUNC_TRACE();
924 if (hw->mac.type == ixgbe_mac_82598EB) {
925 IXGBE_WRITE_REG(hw, IXGBE_EIMC, ~0);
927 IXGBE_WRITE_REG(hw, IXGBE_EIMC, 0xFFFF0000);
928 IXGBE_WRITE_REG(hw, IXGBE_EIMC_EX(0), ~0);
929 IXGBE_WRITE_REG(hw, IXGBE_EIMC_EX(1), ~0);
931 IXGBE_WRITE_FLUSH(hw);
935 * This function resets queue statistics mapping registers.
936 * From Niantic datasheet, Initialization of Statistics section:
937 * "...if software requires the queue counters, the RQSMR and TQSM registers
938 * must be re-programmed following a device reset.
941 ixgbe_reset_qstat_mappings(struct ixgbe_hw *hw)
945 for (i = 0; i != IXGBE_NB_STAT_MAPPING_REGS; i++) {
946 IXGBE_WRITE_REG(hw, IXGBE_RQSMR(i), 0);
947 IXGBE_WRITE_REG(hw, IXGBE_TQSM(i), 0);
953 ixgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
958 #define QSM_REG_NB_BITS_PER_QMAP_FIELD 8
959 #define NB_QMAP_FIELDS_PER_QSM_REG 4
960 #define QMAP_FIELD_RESERVED_BITS_MASK 0x0f
962 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
963 struct ixgbe_stat_mapping_registers *stat_mappings =
964 IXGBE_DEV_PRIVATE_TO_STAT_MAPPINGS(eth_dev->data->dev_private);
965 uint32_t qsmr_mask = 0;
966 uint32_t clearing_mask = QMAP_FIELD_RESERVED_BITS_MASK;
970 if ((hw->mac.type != ixgbe_mac_82599EB) &&
971 (hw->mac.type != ixgbe_mac_X540) &&
972 (hw->mac.type != ixgbe_mac_X550) &&
973 (hw->mac.type != ixgbe_mac_X550EM_x) &&
974 (hw->mac.type != ixgbe_mac_X550EM_a))
977 PMD_INIT_LOG(DEBUG, "Setting port %d, %s queue_id %d to stat index %d",
978 (int)(eth_dev->data->port_id), is_rx ? "RX" : "TX",
981 n = (uint8_t)(queue_id / NB_QMAP_FIELDS_PER_QSM_REG);
982 if (n >= IXGBE_NB_STAT_MAPPING_REGS) {
983 PMD_INIT_LOG(ERR, "Nb of stat mapping registers exceeded");
986 offset = (uint8_t)(queue_id % NB_QMAP_FIELDS_PER_QSM_REG);
988 /* Now clear any previous stat_idx set */
989 clearing_mask <<= (QSM_REG_NB_BITS_PER_QMAP_FIELD * offset);
991 stat_mappings->tqsm[n] &= ~clearing_mask;
993 stat_mappings->rqsmr[n] &= ~clearing_mask;
995 q_map = (uint32_t)stat_idx;
996 q_map &= QMAP_FIELD_RESERVED_BITS_MASK;
997 qsmr_mask = q_map << (QSM_REG_NB_BITS_PER_QMAP_FIELD * offset);
999 stat_mappings->tqsm[n] |= qsmr_mask;
1001 stat_mappings->rqsmr[n] |= qsmr_mask;
1003 PMD_INIT_LOG(DEBUG, "Set port %d, %s queue_id %d to stat index %d",
1004 (int)(eth_dev->data->port_id), is_rx ? "RX" : "TX",
1005 queue_id, stat_idx);
1006 PMD_INIT_LOG(DEBUG, "%s[%d] = 0x%08x", is_rx ? "RQSMR" : "TQSM", n,
1007 is_rx ? stat_mappings->rqsmr[n] : stat_mappings->tqsm[n]);
1009 /* Now write the mapping in the appropriate register */
1011 PMD_INIT_LOG(DEBUG, "Write 0x%x to RX IXGBE stat mapping reg:%d",
1012 stat_mappings->rqsmr[n], n);
1013 IXGBE_WRITE_REG(hw, IXGBE_RQSMR(n), stat_mappings->rqsmr[n]);
1015 PMD_INIT_LOG(DEBUG, "Write 0x%x to TX IXGBE stat mapping reg:%d",
1016 stat_mappings->tqsm[n], n);
1017 IXGBE_WRITE_REG(hw, IXGBE_TQSM(n), stat_mappings->tqsm[n]);
1023 ixgbe_restore_statistics_mapping(struct rte_eth_dev *dev)
1025 struct ixgbe_stat_mapping_registers *stat_mappings =
1026 IXGBE_DEV_PRIVATE_TO_STAT_MAPPINGS(dev->data->dev_private);
1027 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1030 /* write whatever was in stat mapping table to the NIC */
1031 for (i = 0; i < IXGBE_NB_STAT_MAPPING_REGS; i++) {
1033 IXGBE_WRITE_REG(hw, IXGBE_RQSMR(i), stat_mappings->rqsmr[i]);
1036 IXGBE_WRITE_REG(hw, IXGBE_TQSM(i), stat_mappings->tqsm[i]);
1041 ixgbe_dcb_init(struct ixgbe_hw *hw, struct ixgbe_dcb_config *dcb_config)
1044 struct ixgbe_dcb_tc_config *tc;
1045 uint8_t dcb_max_tc = IXGBE_DCB_MAX_TRAFFIC_CLASS;
1047 dcb_config->num_tcs.pg_tcs = dcb_max_tc;
1048 dcb_config->num_tcs.pfc_tcs = dcb_max_tc;
1049 for (i = 0; i < dcb_max_tc; i++) {
1050 tc = &dcb_config->tc_config[i];
1051 tc->path[IXGBE_DCB_TX_CONFIG].bwg_id = i;
1052 tc->path[IXGBE_DCB_TX_CONFIG].bwg_percent =
1053 (uint8_t)(100/dcb_max_tc + (i & 1));
1054 tc->path[IXGBE_DCB_RX_CONFIG].bwg_id = i;
1055 tc->path[IXGBE_DCB_RX_CONFIG].bwg_percent =
1056 (uint8_t)(100/dcb_max_tc + (i & 1));
1057 tc->pfc = ixgbe_dcb_pfc_disabled;
1060 /* Initialize default user to priority mapping, UPx->TC0 */
1061 tc = &dcb_config->tc_config[0];
1062 tc->path[IXGBE_DCB_TX_CONFIG].up_to_tc_bitmap = 0xFF;
1063 tc->path[IXGBE_DCB_RX_CONFIG].up_to_tc_bitmap = 0xFF;
1064 for (i = 0; i < IXGBE_DCB_MAX_BW_GROUP; i++) {
1065 dcb_config->bw_percentage[IXGBE_DCB_TX_CONFIG][i] = 100;
1066 dcb_config->bw_percentage[IXGBE_DCB_RX_CONFIG][i] = 100;
1068 dcb_config->rx_pba_cfg = ixgbe_dcb_pba_equal;
1069 dcb_config->pfc_mode_enable = false;
1070 dcb_config->vt_mode = true;
1071 dcb_config->round_robin_enable = false;
1072 /* support all DCB capabilities in 82599 */
1073 dcb_config->support.capabilities = 0xFF;
1075 /*we only support 4 Tcs for X540, X550 */
1076 if (hw->mac.type == ixgbe_mac_X540 ||
1077 hw->mac.type == ixgbe_mac_X550 ||
1078 hw->mac.type == ixgbe_mac_X550EM_x ||
1079 hw->mac.type == ixgbe_mac_X550EM_a) {
1080 dcb_config->num_tcs.pg_tcs = 4;
1081 dcb_config->num_tcs.pfc_tcs = 4;
1086 * Ensure that all locks are released before first NVM or PHY access
1089 ixgbe_swfw_lock_reset(struct ixgbe_hw *hw)
1094 * Phy lock should not fail in this early stage. If this is the case,
1095 * it is due to an improper exit of the application.
1096 * So force the release of the faulty lock. Release of common lock
1097 * is done automatically by swfw_sync function.
1099 mask = IXGBE_GSSR_PHY0_SM << hw->bus.func;
1100 if (ixgbe_acquire_swfw_semaphore(hw, mask) < 0) {
1101 PMD_DRV_LOG(DEBUG, "SWFW phy%d lock released", hw->bus.func);
1103 ixgbe_release_swfw_semaphore(hw, mask);
1106 * These ones are more tricky since they are common to all ports; but
1107 * swfw_sync retries last long enough (1s) to be almost sure that if
1108 * lock can not be taken it is due to an improper lock of the
1111 mask = IXGBE_GSSR_EEP_SM | IXGBE_GSSR_MAC_CSR_SM | IXGBE_GSSR_SW_MNG_SM;
1112 if (ixgbe_acquire_swfw_semaphore(hw, mask) < 0) {
1113 PMD_DRV_LOG(DEBUG, "SWFW common locks released");
1115 ixgbe_release_swfw_semaphore(hw, mask);
1119 * This function is based on code in ixgbe_attach() in base/ixgbe.c.
1120 * It returns 0 on success.
1123 eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev)
1125 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
1126 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
1127 struct ixgbe_hw *hw =
1128 IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
1129 struct ixgbe_vfta *shadow_vfta =
1130 IXGBE_DEV_PRIVATE_TO_VFTA(eth_dev->data->dev_private);
1131 struct ixgbe_hwstrip *hwstrip =
1132 IXGBE_DEV_PRIVATE_TO_HWSTRIP_BITMAP(eth_dev->data->dev_private);
1133 struct ixgbe_dcb_config *dcb_config =
1134 IXGBE_DEV_PRIVATE_TO_DCB_CFG(eth_dev->data->dev_private);
1135 struct ixgbe_filter_info *filter_info =
1136 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(eth_dev->data->dev_private);
1137 struct ixgbe_bw_conf *bw_conf =
1138 IXGBE_DEV_PRIVATE_TO_BW_CONF(eth_dev->data->dev_private);
1143 PMD_INIT_FUNC_TRACE();
1145 eth_dev->dev_ops = &ixgbe_eth_dev_ops;
1146 eth_dev->rx_pkt_burst = &ixgbe_recv_pkts;
1147 eth_dev->tx_pkt_burst = &ixgbe_xmit_pkts;
1148 eth_dev->tx_pkt_prepare = &ixgbe_prep_pkts;
1151 * For secondary processes, we don't initialise any further as primary
1152 * has already done this work. Only check we don't need a different
1153 * RX and TX function.
1155 if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
1156 struct ixgbe_tx_queue *txq;
1157 /* TX queue function in primary, set by last queue initialized
1158 * Tx queue may not initialized by primary process
1160 if (eth_dev->data->tx_queues) {
1161 txq = eth_dev->data->tx_queues[eth_dev->data->nb_tx_queues-1];
1162 ixgbe_set_tx_function(eth_dev, txq);
1164 /* Use default TX function if we get here */
1165 PMD_INIT_LOG(NOTICE, "No TX queues configured yet. "
1166 "Using default TX function.");
1169 ixgbe_set_rx_function(eth_dev);
1174 #ifdef RTE_LIBRTE_SECURITY
1175 /* Initialize security_ctx only for primary process*/
1176 eth_dev->security_ctx = ixgbe_ipsec_ctx_create(eth_dev);
1177 if (eth_dev->security_ctx == NULL)
1181 rte_eth_copy_pci_info(eth_dev, pci_dev);
1183 /* Vendor and Device ID need to be set before init of shared code */
1184 hw->device_id = pci_dev->id.device_id;
1185 hw->vendor_id = pci_dev->id.vendor_id;
1186 hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
1187 hw->allow_unsupported_sfp = 1;
1189 /* Initialize the shared code (base driver) */
1190 #ifdef RTE_LIBRTE_IXGBE_BYPASS
1191 diag = ixgbe_bypass_init_shared_code(hw);
1193 diag = ixgbe_init_shared_code(hw);
1194 #endif /* RTE_LIBRTE_IXGBE_BYPASS */
1196 if (diag != IXGBE_SUCCESS) {
1197 PMD_INIT_LOG(ERR, "Shared code init failed: %d", diag);
1201 /* pick up the PCI bus settings for reporting later */
1202 ixgbe_get_bus_info(hw);
1204 /* Unlock any pending hardware semaphore */
1205 ixgbe_swfw_lock_reset(hw);
1207 /* Initialize DCB configuration*/
1208 memset(dcb_config, 0, sizeof(struct ixgbe_dcb_config));
1209 ixgbe_dcb_init(hw, dcb_config);
1210 /* Get Hardware Flow Control setting */
1211 hw->fc.requested_mode = ixgbe_fc_full;
1212 hw->fc.current_mode = ixgbe_fc_full;
1213 hw->fc.pause_time = IXGBE_FC_PAUSE;
1214 for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
1215 hw->fc.low_water[i] = IXGBE_FC_LO;
1216 hw->fc.high_water[i] = IXGBE_FC_HI;
1218 hw->fc.send_xon = 1;
1220 /* Make sure we have a good EEPROM before we read from it */
1221 diag = ixgbe_validate_eeprom_checksum(hw, &csum);
1222 if (diag != IXGBE_SUCCESS) {
1223 PMD_INIT_LOG(ERR, "The EEPROM checksum is not valid: %d", diag);
1227 #ifdef RTE_LIBRTE_IXGBE_BYPASS
1228 diag = ixgbe_bypass_init_hw(hw);
1230 diag = ixgbe_init_hw(hw);
1231 #endif /* RTE_LIBRTE_IXGBE_BYPASS */
1234 * Devices with copper phys will fail to initialise if ixgbe_init_hw()
1235 * is called too soon after the kernel driver unbinding/binding occurs.
1236 * The failure occurs in ixgbe_identify_phy_generic() for all devices,
1237 * but for non-copper devies, ixgbe_identify_sfp_module_generic() is
1238 * also called. See ixgbe_identify_phy_82599(). The reason for the
1239 * failure is not known, and only occuts when virtualisation features
1240 * are disabled in the bios. A delay of 100ms was found to be enough by
1241 * trial-and-error, and is doubled to be safe.
1243 if (diag && (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper)) {
1245 diag = ixgbe_init_hw(hw);
1248 if (diag == IXGBE_ERR_SFP_NOT_PRESENT)
1249 diag = IXGBE_SUCCESS;
1251 if (diag == IXGBE_ERR_EEPROM_VERSION) {
1252 PMD_INIT_LOG(ERR, "This device is a pre-production adapter/"
1253 "LOM. Please be aware there may be issues associated "
1254 "with your hardware.");
1255 PMD_INIT_LOG(ERR, "If you are experiencing problems "
1256 "please contact your Intel or hardware representative "
1257 "who provided you with this hardware.");
1258 } else if (diag == IXGBE_ERR_SFP_NOT_SUPPORTED)
1259 PMD_INIT_LOG(ERR, "Unsupported SFP+ Module");
1261 PMD_INIT_LOG(ERR, "Hardware Initialization Failure: %d", diag);
1265 /* Reset the hw statistics */
1266 ixgbe_dev_stats_reset(eth_dev);
1268 /* disable interrupt */
1269 ixgbe_disable_intr(hw);
1271 /* reset mappings for queue statistics hw counters*/
1272 ixgbe_reset_qstat_mappings(hw);
1274 /* Allocate memory for storing MAC addresses */
1275 eth_dev->data->mac_addrs = rte_zmalloc("ixgbe", ETHER_ADDR_LEN *
1276 hw->mac.num_rar_entries, 0);
1277 if (eth_dev->data->mac_addrs == NULL) {
1279 "Failed to allocate %u bytes needed to store "
1281 ETHER_ADDR_LEN * hw->mac.num_rar_entries);
1284 /* Copy the permanent MAC address */
1285 ether_addr_copy((struct ether_addr *) hw->mac.perm_addr,
1286 ð_dev->data->mac_addrs[0]);
1288 /* Allocate memory for storing hash filter MAC addresses */
1289 eth_dev->data->hash_mac_addrs = rte_zmalloc("ixgbe", ETHER_ADDR_LEN *
1290 IXGBE_VMDQ_NUM_UC_MAC, 0);
1291 if (eth_dev->data->hash_mac_addrs == NULL) {
1293 "Failed to allocate %d bytes needed to store MAC addresses",
1294 ETHER_ADDR_LEN * IXGBE_VMDQ_NUM_UC_MAC);
1298 /* initialize the vfta */
1299 memset(shadow_vfta, 0, sizeof(*shadow_vfta));
1301 /* initialize the hw strip bitmap*/
1302 memset(hwstrip, 0, sizeof(*hwstrip));
1304 /* initialize PF if max_vfs not zero */
1305 ixgbe_pf_host_init(eth_dev);
1307 ctrl_ext = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
1308 /* let hardware know driver is loaded */
1309 ctrl_ext |= IXGBE_CTRL_EXT_DRV_LOAD;
1310 /* Set PF Reset Done bit so PF/VF Mail Ops can work */
1311 ctrl_ext |= IXGBE_CTRL_EXT_PFRSTD;
1312 IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl_ext);
1313 IXGBE_WRITE_FLUSH(hw);
1315 if (ixgbe_is_sfp(hw) && hw->phy.sfp_type != ixgbe_sfp_type_not_present)
1316 PMD_INIT_LOG(DEBUG, "MAC: %d, PHY: %d, SFP+: %d",
1317 (int) hw->mac.type, (int) hw->phy.type,
1318 (int) hw->phy.sfp_type);
1320 PMD_INIT_LOG(DEBUG, "MAC: %d, PHY: %d",
1321 (int) hw->mac.type, (int) hw->phy.type);
1323 PMD_INIT_LOG(DEBUG, "port %d vendorID=0x%x deviceID=0x%x",
1324 eth_dev->data->port_id, pci_dev->id.vendor_id,
1325 pci_dev->id.device_id);
1327 rte_intr_callback_register(intr_handle,
1328 ixgbe_dev_interrupt_handler, eth_dev);
1330 /* enable uio/vfio intr/eventfd mapping */
1331 rte_intr_enable(intr_handle);
1333 /* enable support intr */
1334 ixgbe_enable_intr(eth_dev);
1336 /* initialize filter info */
1337 memset(filter_info, 0,
1338 sizeof(struct ixgbe_filter_info));
1340 /* initialize 5tuple filter list */
1341 TAILQ_INIT(&filter_info->fivetuple_list);
1343 /* initialize flow director filter list & hash */
1344 ixgbe_fdir_filter_init(eth_dev);
1346 /* initialize l2 tunnel filter list & hash */
1347 ixgbe_l2_tn_filter_init(eth_dev);
1349 /* initialize flow filter lists */
1350 ixgbe_filterlist_init();
1352 /* initialize bandwidth configuration info */
1353 memset(bw_conf, 0, sizeof(struct ixgbe_bw_conf));
1355 /* initialize Traffic Manager configuration */
1356 ixgbe_tm_conf_init(eth_dev);
1362 eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev)
1364 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
1365 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
1366 struct ixgbe_hw *hw;
1368 PMD_INIT_FUNC_TRACE();
1370 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
1373 hw = IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
1375 if (hw->adapter_stopped == 0)
1376 ixgbe_dev_close(eth_dev);
1378 eth_dev->dev_ops = NULL;
1379 eth_dev->rx_pkt_burst = NULL;
1380 eth_dev->tx_pkt_burst = NULL;
1382 /* Unlock any pending hardware semaphore */
1383 ixgbe_swfw_lock_reset(hw);
1385 /* disable uio intr before callback unregister */
1386 rte_intr_disable(intr_handle);
1387 rte_intr_callback_unregister(intr_handle,
1388 ixgbe_dev_interrupt_handler, eth_dev);
1390 /* uninitialize PF if max_vfs not zero */
1391 ixgbe_pf_host_uninit(eth_dev);
1393 rte_free(eth_dev->data->mac_addrs);
1394 eth_dev->data->mac_addrs = NULL;
1396 rte_free(eth_dev->data->hash_mac_addrs);
1397 eth_dev->data->hash_mac_addrs = NULL;
1399 /* remove all the fdir filters & hash */
1400 ixgbe_fdir_filter_uninit(eth_dev);
1402 /* remove all the L2 tunnel filters & hash */
1403 ixgbe_l2_tn_filter_uninit(eth_dev);
1405 /* Remove all ntuple filters of the device */
1406 ixgbe_ntuple_filter_uninit(eth_dev);
1408 /* clear all the filters list */
1409 ixgbe_filterlist_flush();
1411 /* Remove all Traffic Manager configuration */
1412 ixgbe_tm_conf_uninit(eth_dev);
1414 #ifdef RTE_LIBRTE_SECURITY
1415 rte_free(eth_dev->security_ctx);
1421 static int ixgbe_ntuple_filter_uninit(struct rte_eth_dev *eth_dev)
1423 struct ixgbe_filter_info *filter_info =
1424 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(eth_dev->data->dev_private);
1425 struct ixgbe_5tuple_filter *p_5tuple;
1427 while ((p_5tuple = TAILQ_FIRST(&filter_info->fivetuple_list))) {
1428 TAILQ_REMOVE(&filter_info->fivetuple_list,
1433 memset(filter_info->fivetuple_mask, 0,
1434 sizeof(uint32_t) * IXGBE_5TUPLE_ARRAY_SIZE);
1439 static int ixgbe_fdir_filter_uninit(struct rte_eth_dev *eth_dev)
1441 struct ixgbe_hw_fdir_info *fdir_info =
1442 IXGBE_DEV_PRIVATE_TO_FDIR_INFO(eth_dev->data->dev_private);
1443 struct ixgbe_fdir_filter *fdir_filter;
1445 if (fdir_info->hash_map)
1446 rte_free(fdir_info->hash_map);
1447 if (fdir_info->hash_handle)
1448 rte_hash_free(fdir_info->hash_handle);
1450 while ((fdir_filter = TAILQ_FIRST(&fdir_info->fdir_list))) {
1451 TAILQ_REMOVE(&fdir_info->fdir_list,
1454 rte_free(fdir_filter);
1460 static int ixgbe_l2_tn_filter_uninit(struct rte_eth_dev *eth_dev)
1462 struct ixgbe_l2_tn_info *l2_tn_info =
1463 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(eth_dev->data->dev_private);
1464 struct ixgbe_l2_tn_filter *l2_tn_filter;
1466 if (l2_tn_info->hash_map)
1467 rte_free(l2_tn_info->hash_map);
1468 if (l2_tn_info->hash_handle)
1469 rte_hash_free(l2_tn_info->hash_handle);
1471 while ((l2_tn_filter = TAILQ_FIRST(&l2_tn_info->l2_tn_list))) {
1472 TAILQ_REMOVE(&l2_tn_info->l2_tn_list,
1475 rte_free(l2_tn_filter);
1481 static int ixgbe_fdir_filter_init(struct rte_eth_dev *eth_dev)
1483 struct ixgbe_hw_fdir_info *fdir_info =
1484 IXGBE_DEV_PRIVATE_TO_FDIR_INFO(eth_dev->data->dev_private);
1485 char fdir_hash_name[RTE_HASH_NAMESIZE];
1486 struct rte_hash_parameters fdir_hash_params = {
1487 .name = fdir_hash_name,
1488 .entries = IXGBE_MAX_FDIR_FILTER_NUM,
1489 .key_len = sizeof(union ixgbe_atr_input),
1490 .hash_func = rte_hash_crc,
1491 .hash_func_init_val = 0,
1492 .socket_id = rte_socket_id(),
1495 TAILQ_INIT(&fdir_info->fdir_list);
1496 snprintf(fdir_hash_name, RTE_HASH_NAMESIZE,
1497 "fdir_%s", eth_dev->device->name);
1498 fdir_info->hash_handle = rte_hash_create(&fdir_hash_params);
1499 if (!fdir_info->hash_handle) {
1500 PMD_INIT_LOG(ERR, "Failed to create fdir hash table!");
1503 fdir_info->hash_map = rte_zmalloc("ixgbe",
1504 sizeof(struct ixgbe_fdir_filter *) *
1505 IXGBE_MAX_FDIR_FILTER_NUM,
1507 if (!fdir_info->hash_map) {
1509 "Failed to allocate memory for fdir hash map!");
1512 fdir_info->mask_added = FALSE;
1517 static int ixgbe_l2_tn_filter_init(struct rte_eth_dev *eth_dev)
1519 struct ixgbe_l2_tn_info *l2_tn_info =
1520 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(eth_dev->data->dev_private);
1521 char l2_tn_hash_name[RTE_HASH_NAMESIZE];
1522 struct rte_hash_parameters l2_tn_hash_params = {
1523 .name = l2_tn_hash_name,
1524 .entries = IXGBE_MAX_L2_TN_FILTER_NUM,
1525 .key_len = sizeof(struct ixgbe_l2_tn_key),
1526 .hash_func = rte_hash_crc,
1527 .hash_func_init_val = 0,
1528 .socket_id = rte_socket_id(),
1531 TAILQ_INIT(&l2_tn_info->l2_tn_list);
1532 snprintf(l2_tn_hash_name, RTE_HASH_NAMESIZE,
1533 "l2_tn_%s", eth_dev->device->name);
1534 l2_tn_info->hash_handle = rte_hash_create(&l2_tn_hash_params);
1535 if (!l2_tn_info->hash_handle) {
1536 PMD_INIT_LOG(ERR, "Failed to create L2 TN hash table!");
1539 l2_tn_info->hash_map = rte_zmalloc("ixgbe",
1540 sizeof(struct ixgbe_l2_tn_filter *) *
1541 IXGBE_MAX_L2_TN_FILTER_NUM,
1543 if (!l2_tn_info->hash_map) {
1545 "Failed to allocate memory for L2 TN hash map!");
1548 l2_tn_info->e_tag_en = FALSE;
1549 l2_tn_info->e_tag_fwd_en = FALSE;
1550 l2_tn_info->e_tag_ether_type = DEFAULT_ETAG_ETYPE;
1555 * Negotiate mailbox API version with the PF.
1556 * After reset API version is always set to the basic one (ixgbe_mbox_api_10).
1557 * Then we try to negotiate starting with the most recent one.
1558 * If all negotiation attempts fail, then we will proceed with
1559 * the default one (ixgbe_mbox_api_10).
1562 ixgbevf_negotiate_api(struct ixgbe_hw *hw)
1566 /* start with highest supported, proceed down */
1567 static const enum ixgbe_pfvf_api_rev sup_ver[] = {
1574 i != RTE_DIM(sup_ver) &&
1575 ixgbevf_negotiate_api_version(hw, sup_ver[i]) != 0;
1581 generate_random_mac_addr(struct ether_addr *mac_addr)
1585 /* Set Organizationally Unique Identifier (OUI) prefix. */
1586 mac_addr->addr_bytes[0] = 0x00;
1587 mac_addr->addr_bytes[1] = 0x09;
1588 mac_addr->addr_bytes[2] = 0xC0;
1589 /* Force indication of locally assigned MAC address. */
1590 mac_addr->addr_bytes[0] |= ETHER_LOCAL_ADMIN_ADDR;
1591 /* Generate the last 3 bytes of the MAC address with a random number. */
1592 random = rte_rand();
1593 memcpy(&mac_addr->addr_bytes[3], &random, 3);
1597 * Virtual Function device init
1600 eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev)
1604 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
1605 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
1606 struct ixgbe_hw *hw =
1607 IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
1608 struct ixgbe_vfta *shadow_vfta =
1609 IXGBE_DEV_PRIVATE_TO_VFTA(eth_dev->data->dev_private);
1610 struct ixgbe_hwstrip *hwstrip =
1611 IXGBE_DEV_PRIVATE_TO_HWSTRIP_BITMAP(eth_dev->data->dev_private);
1612 struct ether_addr *perm_addr = (struct ether_addr *) hw->mac.perm_addr;
1614 PMD_INIT_FUNC_TRACE();
1616 eth_dev->dev_ops = &ixgbevf_eth_dev_ops;
1617 eth_dev->rx_pkt_burst = &ixgbe_recv_pkts;
1618 eth_dev->tx_pkt_burst = &ixgbe_xmit_pkts;
1620 /* for secondary processes, we don't initialise any further as primary
1621 * has already done this work. Only check we don't need a different
1624 if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
1625 struct ixgbe_tx_queue *txq;
1626 /* TX queue function in primary, set by last queue initialized
1627 * Tx queue may not initialized by primary process
1629 if (eth_dev->data->tx_queues) {
1630 txq = eth_dev->data->tx_queues[eth_dev->data->nb_tx_queues - 1];
1631 ixgbe_set_tx_function(eth_dev, txq);
1633 /* Use default TX function if we get here */
1634 PMD_INIT_LOG(NOTICE,
1635 "No TX queues configured yet. Using default TX function.");
1638 ixgbe_set_rx_function(eth_dev);
1643 rte_eth_copy_pci_info(eth_dev, pci_dev);
1645 hw->device_id = pci_dev->id.device_id;
1646 hw->vendor_id = pci_dev->id.vendor_id;
1647 hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
1649 /* initialize the vfta */
1650 memset(shadow_vfta, 0, sizeof(*shadow_vfta));
1652 /* initialize the hw strip bitmap*/
1653 memset(hwstrip, 0, sizeof(*hwstrip));
1655 /* Initialize the shared code (base driver) */
1656 diag = ixgbe_init_shared_code(hw);
1657 if (diag != IXGBE_SUCCESS) {
1658 PMD_INIT_LOG(ERR, "Shared code init failed for ixgbevf: %d", diag);
1662 /* init_mailbox_params */
1663 hw->mbx.ops.init_params(hw);
1665 /* Reset the hw statistics */
1666 ixgbevf_dev_stats_reset(eth_dev);
1668 /* Disable the interrupts for VF */
1669 ixgbevf_intr_disable(hw);
1671 hw->mac.num_rar_entries = 128; /* The MAX of the underlying PF */
1672 diag = hw->mac.ops.reset_hw(hw);
1675 * The VF reset operation returns the IXGBE_ERR_INVALID_MAC_ADDR when
1676 * the underlying PF driver has not assigned a MAC address to the VF.
1677 * In this case, assign a random MAC address.
1679 if ((diag != IXGBE_SUCCESS) && (diag != IXGBE_ERR_INVALID_MAC_ADDR)) {
1680 PMD_INIT_LOG(ERR, "VF Initialization Failure: %d", diag);
1684 /* negotiate mailbox API version to use with the PF. */
1685 ixgbevf_negotiate_api(hw);
1687 /* Get Rx/Tx queue count via mailbox, which is ready after reset_hw */
1688 ixgbevf_get_queues(hw, &tcs, &tc);
1690 /* Allocate memory for storing MAC addresses */
1691 eth_dev->data->mac_addrs = rte_zmalloc("ixgbevf", ETHER_ADDR_LEN *
1692 hw->mac.num_rar_entries, 0);
1693 if (eth_dev->data->mac_addrs == NULL) {
1695 "Failed to allocate %u bytes needed to store "
1697 ETHER_ADDR_LEN * hw->mac.num_rar_entries);
1701 /* Generate a random MAC address, if none was assigned by PF. */
1702 if (is_zero_ether_addr(perm_addr)) {
1703 generate_random_mac_addr(perm_addr);
1704 diag = ixgbe_set_rar_vf(hw, 1, perm_addr->addr_bytes, 0, 1);
1706 rte_free(eth_dev->data->mac_addrs);
1707 eth_dev->data->mac_addrs = NULL;
1710 PMD_INIT_LOG(INFO, "\tVF MAC address not assigned by Host PF");
1711 PMD_INIT_LOG(INFO, "\tAssign randomly generated MAC address "
1712 "%02x:%02x:%02x:%02x:%02x:%02x",
1713 perm_addr->addr_bytes[0],
1714 perm_addr->addr_bytes[1],
1715 perm_addr->addr_bytes[2],
1716 perm_addr->addr_bytes[3],
1717 perm_addr->addr_bytes[4],
1718 perm_addr->addr_bytes[5]);
1721 /* Copy the permanent MAC address */
1722 ether_addr_copy(perm_addr, ð_dev->data->mac_addrs[0]);
1724 /* reset the hardware with the new settings */
1725 diag = hw->mac.ops.start_hw(hw);
1731 PMD_INIT_LOG(ERR, "VF Initialization Failure: %d", diag);
1735 rte_intr_callback_register(intr_handle,
1736 ixgbevf_dev_interrupt_handler, eth_dev);
1737 rte_intr_enable(intr_handle);
1738 ixgbevf_intr_enable(hw);
1740 PMD_INIT_LOG(DEBUG, "port %d vendorID=0x%x deviceID=0x%x mac.type=%s",
1741 eth_dev->data->port_id, pci_dev->id.vendor_id,
1742 pci_dev->id.device_id, "ixgbe_mac_82599_vf");
1747 /* Virtual Function device uninit */
1750 eth_ixgbevf_dev_uninit(struct rte_eth_dev *eth_dev)
1752 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
1753 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
1754 struct ixgbe_hw *hw;
1756 PMD_INIT_FUNC_TRACE();
1758 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
1761 hw = IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
1763 if (hw->adapter_stopped == 0)
1764 ixgbevf_dev_close(eth_dev);
1766 eth_dev->dev_ops = NULL;
1767 eth_dev->rx_pkt_burst = NULL;
1768 eth_dev->tx_pkt_burst = NULL;
1770 /* Disable the interrupts for VF */
1771 ixgbevf_intr_disable(hw);
1773 rte_free(eth_dev->data->mac_addrs);
1774 eth_dev->data->mac_addrs = NULL;
1776 rte_intr_disable(intr_handle);
1777 rte_intr_callback_unregister(intr_handle,
1778 ixgbevf_dev_interrupt_handler, eth_dev);
1783 static int eth_ixgbe_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
1784 struct rte_pci_device *pci_dev)
1786 return rte_eth_dev_pci_generic_probe(pci_dev,
1787 sizeof(struct ixgbe_adapter), eth_ixgbe_dev_init);
1790 static int eth_ixgbe_pci_remove(struct rte_pci_device *pci_dev)
1792 return rte_eth_dev_pci_generic_remove(pci_dev, eth_ixgbe_dev_uninit);
1795 static struct rte_pci_driver rte_ixgbe_pmd = {
1796 .id_table = pci_id_ixgbe_map,
1797 .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
1798 RTE_PCI_DRV_IOVA_AS_VA,
1799 .probe = eth_ixgbe_pci_probe,
1800 .remove = eth_ixgbe_pci_remove,
1803 static int eth_ixgbevf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
1804 struct rte_pci_device *pci_dev)
1806 return rte_eth_dev_pci_generic_probe(pci_dev,
1807 sizeof(struct ixgbe_adapter), eth_ixgbevf_dev_init);
1810 static int eth_ixgbevf_pci_remove(struct rte_pci_device *pci_dev)
1812 return rte_eth_dev_pci_generic_remove(pci_dev, eth_ixgbevf_dev_uninit);
1816 * virtual function driver struct
1818 static struct rte_pci_driver rte_ixgbevf_pmd = {
1819 .id_table = pci_id_ixgbevf_map,
1820 .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_IOVA_AS_VA,
1821 .probe = eth_ixgbevf_pci_probe,
1822 .remove = eth_ixgbevf_pci_remove,
1826 ixgbe_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
1828 struct ixgbe_hw *hw =
1829 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1830 struct ixgbe_vfta *shadow_vfta =
1831 IXGBE_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
1836 vid_idx = (uint32_t) ((vlan_id >> 5) & 0x7F);
1837 vid_bit = (uint32_t) (1 << (vlan_id & 0x1F));
1838 vfta = IXGBE_READ_REG(hw, IXGBE_VFTA(vid_idx));
1843 IXGBE_WRITE_REG(hw, IXGBE_VFTA(vid_idx), vfta);
1845 /* update local VFTA copy */
1846 shadow_vfta->vfta[vid_idx] = vfta;
1852 ixgbe_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue, int on)
1855 ixgbe_vlan_hw_strip_enable(dev, queue);
1857 ixgbe_vlan_hw_strip_disable(dev, queue);
1861 ixgbe_vlan_tpid_set(struct rte_eth_dev *dev,
1862 enum rte_vlan_type vlan_type,
1865 struct ixgbe_hw *hw =
1866 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1871 qinq = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
1872 qinq &= IXGBE_DMATXCTL_GDV;
1874 switch (vlan_type) {
1875 case ETH_VLAN_TYPE_INNER:
1877 reg = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
1878 reg = (reg & (~IXGBE_VLNCTRL_VET)) | (uint32_t)tpid;
1879 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, reg);
1880 reg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
1881 reg = (reg & (~IXGBE_DMATXCTL_VT_MASK))
1882 | ((uint32_t)tpid << IXGBE_DMATXCTL_VT_SHIFT);
1883 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);
1886 PMD_DRV_LOG(ERR, "Inner type is not supported"
1890 case ETH_VLAN_TYPE_OUTER:
1892 /* Only the high 16-bits is valid */
1893 IXGBE_WRITE_REG(hw, IXGBE_EXVET, (uint32_t)tpid <<
1894 IXGBE_EXVET_VET_EXT_SHIFT);
1896 reg = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
1897 reg = (reg & (~IXGBE_VLNCTRL_VET)) | (uint32_t)tpid;
1898 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, reg);
1899 reg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
1900 reg = (reg & (~IXGBE_DMATXCTL_VT_MASK))
1901 | ((uint32_t)tpid << IXGBE_DMATXCTL_VT_SHIFT);
1902 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);
1908 PMD_DRV_LOG(ERR, "Unsupported VLAN type %d", vlan_type);
1916 ixgbe_vlan_hw_filter_disable(struct rte_eth_dev *dev)
1918 struct ixgbe_hw *hw =
1919 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1922 PMD_INIT_FUNC_TRACE();
1924 /* Filter Table Disable */
1925 vlnctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
1926 vlnctrl &= ~IXGBE_VLNCTRL_VFE;
1928 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlnctrl);
1932 ixgbe_vlan_hw_filter_enable(struct rte_eth_dev *dev)
1934 struct ixgbe_hw *hw =
1935 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1936 struct ixgbe_vfta *shadow_vfta =
1937 IXGBE_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
1941 PMD_INIT_FUNC_TRACE();
1943 /* Filter Table Enable */
1944 vlnctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
1945 vlnctrl &= ~IXGBE_VLNCTRL_CFIEN;
1946 vlnctrl |= IXGBE_VLNCTRL_VFE;
1948 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlnctrl);
1950 /* write whatever is in local vfta copy */
1951 for (i = 0; i < IXGBE_VFTA_SIZE; i++)
1952 IXGBE_WRITE_REG(hw, IXGBE_VFTA(i), shadow_vfta->vfta[i]);
1956 ixgbe_vlan_hw_strip_bitmap_set(struct rte_eth_dev *dev, uint16_t queue, bool on)
1958 struct ixgbe_hwstrip *hwstrip =
1959 IXGBE_DEV_PRIVATE_TO_HWSTRIP_BITMAP(dev->data->dev_private);
1960 struct ixgbe_rx_queue *rxq;
1962 if (queue >= IXGBE_MAX_RX_QUEUE_NUM)
1966 IXGBE_SET_HWSTRIP(hwstrip, queue);
1968 IXGBE_CLEAR_HWSTRIP(hwstrip, queue);
1970 if (queue >= dev->data->nb_rx_queues)
1973 rxq = dev->data->rx_queues[queue];
1976 rxq->vlan_flags = PKT_RX_VLAN | PKT_RX_VLAN_STRIPPED;
1978 rxq->vlan_flags = PKT_RX_VLAN;
1982 ixgbe_vlan_hw_strip_disable(struct rte_eth_dev *dev, uint16_t queue)
1984 struct ixgbe_hw *hw =
1985 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1988 PMD_INIT_FUNC_TRACE();
1990 if (hw->mac.type == ixgbe_mac_82598EB) {
1991 /* No queue level support */
1992 PMD_INIT_LOG(NOTICE, "82598EB not support queue level hw strip");
1996 /* Other 10G NIC, the VLAN strip can be setup per queue in RXDCTL */
1997 ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(queue));
1998 ctrl &= ~IXGBE_RXDCTL_VME;
1999 IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(queue), ctrl);
2001 /* record those setting for HW strip per queue */
2002 ixgbe_vlan_hw_strip_bitmap_set(dev, queue, 0);
2006 ixgbe_vlan_hw_strip_enable(struct rte_eth_dev *dev, uint16_t queue)
2008 struct ixgbe_hw *hw =
2009 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2012 PMD_INIT_FUNC_TRACE();
2014 if (hw->mac.type == ixgbe_mac_82598EB) {
2015 /* No queue level supported */
2016 PMD_INIT_LOG(NOTICE, "82598EB not support queue level hw strip");
2020 /* Other 10G NIC, the VLAN strip can be setup per queue in RXDCTL */
2021 ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(queue));
2022 ctrl |= IXGBE_RXDCTL_VME;
2023 IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(queue), ctrl);
2025 /* record those setting for HW strip per queue */
2026 ixgbe_vlan_hw_strip_bitmap_set(dev, queue, 1);
2030 ixgbe_vlan_hw_strip_disable_all(struct rte_eth_dev *dev)
2032 struct ixgbe_hw *hw =
2033 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2036 struct ixgbe_rx_queue *rxq;
2038 PMD_INIT_FUNC_TRACE();
2040 if (hw->mac.type == ixgbe_mac_82598EB) {
2041 ctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
2042 ctrl &= ~IXGBE_VLNCTRL_VME;
2043 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, ctrl);
2045 /* Other 10G NIC, the VLAN strip can be setup per queue in RXDCTL */
2046 for (i = 0; i < dev->data->nb_rx_queues; i++) {
2047 rxq = dev->data->rx_queues[i];
2048 ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(rxq->reg_idx));
2049 ctrl &= ~IXGBE_RXDCTL_VME;
2050 IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(rxq->reg_idx), ctrl);
2052 /* record those setting for HW strip per queue */
2053 ixgbe_vlan_hw_strip_bitmap_set(dev, i, 0);
2059 ixgbe_vlan_hw_strip_enable_all(struct rte_eth_dev *dev)
2061 struct ixgbe_hw *hw =
2062 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2065 struct ixgbe_rx_queue *rxq;
2067 PMD_INIT_FUNC_TRACE();
2069 if (hw->mac.type == ixgbe_mac_82598EB) {
2070 ctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
2071 ctrl |= IXGBE_VLNCTRL_VME;
2072 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, ctrl);
2074 /* Other 10G NIC, the VLAN strip can be setup per queue in RXDCTL */
2075 for (i = 0; i < dev->data->nb_rx_queues; i++) {
2076 rxq = dev->data->rx_queues[i];
2077 ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(rxq->reg_idx));
2078 ctrl |= IXGBE_RXDCTL_VME;
2079 IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(rxq->reg_idx), ctrl);
2081 /* record those setting for HW strip per queue */
2082 ixgbe_vlan_hw_strip_bitmap_set(dev, i, 1);
2088 ixgbe_vlan_hw_extend_disable(struct rte_eth_dev *dev)
2090 struct ixgbe_hw *hw =
2091 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2094 PMD_INIT_FUNC_TRACE();
2096 /* DMATXCTRL: Geric Double VLAN Disable */
2097 ctrl = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
2098 ctrl &= ~IXGBE_DMATXCTL_GDV;
2099 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, ctrl);
2101 /* CTRL_EXT: Global Double VLAN Disable */
2102 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
2103 ctrl &= ~IXGBE_EXTENDED_VLAN;
2104 IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl);
2109 ixgbe_vlan_hw_extend_enable(struct rte_eth_dev *dev)
2111 struct ixgbe_hw *hw =
2112 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2115 PMD_INIT_FUNC_TRACE();
2117 /* DMATXCTRL: Geric Double VLAN Enable */
2118 ctrl = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
2119 ctrl |= IXGBE_DMATXCTL_GDV;
2120 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, ctrl);
2122 /* CTRL_EXT: Global Double VLAN Enable */
2123 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
2124 ctrl |= IXGBE_EXTENDED_VLAN;
2125 IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl);
2127 /* Clear pooling mode of PFVTCTL. It's required by X550. */
2128 if (hw->mac.type == ixgbe_mac_X550 ||
2129 hw->mac.type == ixgbe_mac_X550EM_x ||
2130 hw->mac.type == ixgbe_mac_X550EM_a) {
2131 ctrl = IXGBE_READ_REG(hw, IXGBE_VT_CTL);
2132 ctrl &= ~IXGBE_VT_CTL_POOLING_MODE_MASK;
2133 IXGBE_WRITE_REG(hw, IXGBE_VT_CTL, ctrl);
2137 * VET EXT field in the EXVET register = 0x8100 by default
2138 * So no need to change. Same to VT field of DMATXCTL register
2143 ixgbe_vlan_offload_set(struct rte_eth_dev *dev, int mask)
2145 if (mask & ETH_VLAN_STRIP_MASK) {
2146 if (dev->data->dev_conf.rxmode.hw_vlan_strip)
2147 ixgbe_vlan_hw_strip_enable_all(dev);
2149 ixgbe_vlan_hw_strip_disable_all(dev);
2152 if (mask & ETH_VLAN_FILTER_MASK) {
2153 if (dev->data->dev_conf.rxmode.hw_vlan_filter)
2154 ixgbe_vlan_hw_filter_enable(dev);
2156 ixgbe_vlan_hw_filter_disable(dev);
2159 if (mask & ETH_VLAN_EXTEND_MASK) {
2160 if (dev->data->dev_conf.rxmode.hw_vlan_extend)
2161 ixgbe_vlan_hw_extend_enable(dev);
2163 ixgbe_vlan_hw_extend_disable(dev);
2170 ixgbe_vmdq_vlan_hw_filter_enable(struct rte_eth_dev *dev)
2172 struct ixgbe_hw *hw =
2173 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2174 /* VLNCTRL: enable vlan filtering and allow all vlan tags through */
2175 uint32_t vlanctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
2177 vlanctrl |= IXGBE_VLNCTRL_VFE; /* enable vlan filters */
2178 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlanctrl);
2182 ixgbe_check_vf_rss_rxq_num(struct rte_eth_dev *dev, uint16_t nb_rx_q)
2184 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
2189 RTE_ETH_DEV_SRIOV(dev).active = ETH_64_POOLS;
2192 RTE_ETH_DEV_SRIOV(dev).active = ETH_32_POOLS;
2198 RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool = nb_rx_q;
2199 RTE_ETH_DEV_SRIOV(dev).def_pool_q_idx = pci_dev->max_vfs * nb_rx_q;
2205 ixgbe_check_mq_mode(struct rte_eth_dev *dev)
2207 struct rte_eth_conf *dev_conf = &dev->data->dev_conf;
2208 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2209 uint16_t nb_rx_q = dev->data->nb_rx_queues;
2210 uint16_t nb_tx_q = dev->data->nb_tx_queues;
2212 if (RTE_ETH_DEV_SRIOV(dev).active != 0) {
2213 /* check multi-queue mode */
2214 switch (dev_conf->rxmode.mq_mode) {
2215 case ETH_MQ_RX_VMDQ_DCB:
2216 PMD_INIT_LOG(INFO, "ETH_MQ_RX_VMDQ_DCB mode supported in SRIOV");
2218 case ETH_MQ_RX_VMDQ_DCB_RSS:
2219 /* DCB/RSS VMDQ in SRIOV mode, not implement yet */
2220 PMD_INIT_LOG(ERR, "SRIOV active,"
2221 " unsupported mq_mode rx %d.",
2222 dev_conf->rxmode.mq_mode);
2225 case ETH_MQ_RX_VMDQ_RSS:
2226 dev->data->dev_conf.rxmode.mq_mode = ETH_MQ_RX_VMDQ_RSS;
2227 if (nb_rx_q <= RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool)
2228 if (ixgbe_check_vf_rss_rxq_num(dev, nb_rx_q)) {
2229 PMD_INIT_LOG(ERR, "SRIOV is active,"
2230 " invalid queue number"
2231 " for VMDQ RSS, allowed"
2232 " value are 1, 2 or 4.");
2236 case ETH_MQ_RX_VMDQ_ONLY:
2237 case ETH_MQ_RX_NONE:
2238 /* if nothing mq mode configure, use default scheme */
2239 dev->data->dev_conf.rxmode.mq_mode = ETH_MQ_RX_VMDQ_ONLY;
2240 if (RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool > 1)
2241 RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool = 1;
2243 default: /* ETH_MQ_RX_DCB, ETH_MQ_RX_DCB_RSS or ETH_MQ_TX_DCB*/
2244 /* SRIOV only works in VMDq enable mode */
2245 PMD_INIT_LOG(ERR, "SRIOV is active,"
2246 " wrong mq_mode rx %d.",
2247 dev_conf->rxmode.mq_mode);
2251 switch (dev_conf->txmode.mq_mode) {
2252 case ETH_MQ_TX_VMDQ_DCB:
2253 PMD_INIT_LOG(INFO, "ETH_MQ_TX_VMDQ_DCB mode supported in SRIOV");
2254 dev->data->dev_conf.txmode.mq_mode = ETH_MQ_TX_VMDQ_DCB;
2256 default: /* ETH_MQ_TX_VMDQ_ONLY or ETH_MQ_TX_NONE */
2257 dev->data->dev_conf.txmode.mq_mode = ETH_MQ_TX_VMDQ_ONLY;
2261 /* check valid queue number */
2262 if ((nb_rx_q > RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool) ||
2263 (nb_tx_q > RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool)) {
2264 PMD_INIT_LOG(ERR, "SRIOV is active,"
2265 " nb_rx_q=%d nb_tx_q=%d queue number"
2266 " must be less than or equal to %d.",
2268 RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool);
2272 if (dev_conf->rxmode.mq_mode == ETH_MQ_RX_VMDQ_DCB_RSS) {
2273 PMD_INIT_LOG(ERR, "VMDQ+DCB+RSS mq_mode is"
2277 /* check configuration for vmdb+dcb mode */
2278 if (dev_conf->rxmode.mq_mode == ETH_MQ_RX_VMDQ_DCB) {
2279 const struct rte_eth_vmdq_dcb_conf *conf;
2281 if (nb_rx_q != IXGBE_VMDQ_DCB_NB_QUEUES) {
2282 PMD_INIT_LOG(ERR, "VMDQ+DCB, nb_rx_q != %d.",
2283 IXGBE_VMDQ_DCB_NB_QUEUES);
2286 conf = &dev_conf->rx_adv_conf.vmdq_dcb_conf;
2287 if (!(conf->nb_queue_pools == ETH_16_POOLS ||
2288 conf->nb_queue_pools == ETH_32_POOLS)) {
2289 PMD_INIT_LOG(ERR, "VMDQ+DCB selected,"
2290 " nb_queue_pools must be %d or %d.",
2291 ETH_16_POOLS, ETH_32_POOLS);
2295 if (dev_conf->txmode.mq_mode == ETH_MQ_TX_VMDQ_DCB) {
2296 const struct rte_eth_vmdq_dcb_tx_conf *conf;
2298 if (nb_tx_q != IXGBE_VMDQ_DCB_NB_QUEUES) {
2299 PMD_INIT_LOG(ERR, "VMDQ+DCB, nb_tx_q != %d",
2300 IXGBE_VMDQ_DCB_NB_QUEUES);
2303 conf = &dev_conf->tx_adv_conf.vmdq_dcb_tx_conf;
2304 if (!(conf->nb_queue_pools == ETH_16_POOLS ||
2305 conf->nb_queue_pools == ETH_32_POOLS)) {
2306 PMD_INIT_LOG(ERR, "VMDQ+DCB selected,"
2307 " nb_queue_pools != %d and"
2308 " nb_queue_pools != %d.",
2309 ETH_16_POOLS, ETH_32_POOLS);
2314 /* For DCB mode check our configuration before we go further */
2315 if (dev_conf->rxmode.mq_mode == ETH_MQ_RX_DCB) {
2316 const struct rte_eth_dcb_rx_conf *conf;
2318 if (nb_rx_q != IXGBE_DCB_NB_QUEUES) {
2319 PMD_INIT_LOG(ERR, "DCB selected, nb_rx_q != %d.",
2320 IXGBE_DCB_NB_QUEUES);
2323 conf = &dev_conf->rx_adv_conf.dcb_rx_conf;
2324 if (!(conf->nb_tcs == ETH_4_TCS ||
2325 conf->nb_tcs == ETH_8_TCS)) {
2326 PMD_INIT_LOG(ERR, "DCB selected, nb_tcs != %d"
2327 " and nb_tcs != %d.",
2328 ETH_4_TCS, ETH_8_TCS);
2333 if (dev_conf->txmode.mq_mode == ETH_MQ_TX_DCB) {
2334 const struct rte_eth_dcb_tx_conf *conf;
2336 if (nb_tx_q != IXGBE_DCB_NB_QUEUES) {
2337 PMD_INIT_LOG(ERR, "DCB, nb_tx_q != %d.",
2338 IXGBE_DCB_NB_QUEUES);
2341 conf = &dev_conf->tx_adv_conf.dcb_tx_conf;
2342 if (!(conf->nb_tcs == ETH_4_TCS ||
2343 conf->nb_tcs == ETH_8_TCS)) {
2344 PMD_INIT_LOG(ERR, "DCB selected, nb_tcs != %d"
2345 " and nb_tcs != %d.",
2346 ETH_4_TCS, ETH_8_TCS);
2352 * When DCB/VT is off, maximum number of queues changes,
2353 * except for 82598EB, which remains constant.
2355 if (dev_conf->txmode.mq_mode == ETH_MQ_TX_NONE &&
2356 hw->mac.type != ixgbe_mac_82598EB) {
2357 if (nb_tx_q > IXGBE_NONE_MODE_TX_NB_QUEUES) {
2359 "Neither VT nor DCB are enabled, "
2361 IXGBE_NONE_MODE_TX_NB_QUEUES);
2370 ixgbe_dev_configure(struct rte_eth_dev *dev)
2372 struct ixgbe_interrupt *intr =
2373 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
2374 struct ixgbe_adapter *adapter =
2375 (struct ixgbe_adapter *)dev->data->dev_private;
2378 PMD_INIT_FUNC_TRACE();
2379 /* multipe queue mode checking */
2380 ret = ixgbe_check_mq_mode(dev);
2382 PMD_DRV_LOG(ERR, "ixgbe_check_mq_mode fails with %d.",
2387 /* set flag to update link status after init */
2388 intr->flags |= IXGBE_FLAG_NEED_LINK_UPDATE;
2391 * Initialize to TRUE. If any of Rx queues doesn't meet the bulk
2392 * allocation or vector Rx preconditions we will reset it.
2394 adapter->rx_bulk_alloc_allowed = true;
2395 adapter->rx_vec_allowed = true;
2401 ixgbe_dev_phy_intr_setup(struct rte_eth_dev *dev)
2403 struct ixgbe_hw *hw =
2404 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2405 struct ixgbe_interrupt *intr =
2406 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
2409 /* only set up it on X550EM_X */
2410 if (hw->mac.type == ixgbe_mac_X550EM_x) {
2411 gpie = IXGBE_READ_REG(hw, IXGBE_GPIE);
2412 gpie |= IXGBE_SDP0_GPIEN_X550EM_x;
2413 IXGBE_WRITE_REG(hw, IXGBE_GPIE, gpie);
2414 if (hw->phy.type == ixgbe_phy_x550em_ext_t)
2415 intr->mask |= IXGBE_EICR_GPI_SDP0_X550EM_x;
2420 ixgbe_set_vf_rate_limit(struct rte_eth_dev *dev, uint16_t vf,
2421 uint16_t tx_rate, uint64_t q_msk)
2423 struct ixgbe_hw *hw;
2424 struct ixgbe_vf_info *vfinfo;
2425 struct rte_eth_link link;
2426 uint8_t nb_q_per_pool;
2427 uint32_t queue_stride;
2428 uint32_t queue_idx, idx = 0, vf_idx;
2430 uint16_t total_rate = 0;
2431 struct rte_pci_device *pci_dev;
2433 pci_dev = RTE_ETH_DEV_TO_PCI(dev);
2434 rte_eth_link_get_nowait(dev->data->port_id, &link);
2436 if (vf >= pci_dev->max_vfs)
2439 if (tx_rate > link.link_speed)
2445 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2446 vfinfo = *(IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private));
2447 nb_q_per_pool = RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool;
2448 queue_stride = IXGBE_MAX_RX_QUEUE_NUM / RTE_ETH_DEV_SRIOV(dev).active;
2449 queue_idx = vf * queue_stride;
2450 queue_end = queue_idx + nb_q_per_pool - 1;
2451 if (queue_end >= hw->mac.max_tx_queues)
2455 for (vf_idx = 0; vf_idx < pci_dev->max_vfs; vf_idx++) {
2458 for (idx = 0; idx < RTE_DIM(vfinfo[vf_idx].tx_rate);
2460 total_rate += vfinfo[vf_idx].tx_rate[idx];
2466 /* Store tx_rate for this vf. */
2467 for (idx = 0; idx < nb_q_per_pool; idx++) {
2468 if (((uint64_t)0x1 << idx) & q_msk) {
2469 if (vfinfo[vf].tx_rate[idx] != tx_rate)
2470 vfinfo[vf].tx_rate[idx] = tx_rate;
2471 total_rate += tx_rate;
2475 if (total_rate > dev->data->dev_link.link_speed) {
2476 /* Reset stored TX rate of the VF if it causes exceed
2479 memset(vfinfo[vf].tx_rate, 0, sizeof(vfinfo[vf].tx_rate));
2483 /* Set RTTBCNRC of each queue/pool for vf X */
2484 for (; queue_idx <= queue_end; queue_idx++) {
2486 ixgbe_set_queue_rate_limit(dev, queue_idx, tx_rate);
2494 * Configure device link speed and setup link.
2495 * It returns 0 on success.
2498 ixgbe_dev_start(struct rte_eth_dev *dev)
2500 struct ixgbe_hw *hw =
2501 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2502 struct ixgbe_vf_info *vfinfo =
2503 *IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private);
2504 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
2505 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
2506 uint32_t intr_vector = 0;
2507 int err, link_up = 0, negotiate = 0;
2512 uint32_t *link_speeds;
2513 struct ixgbe_tm_conf *tm_conf =
2514 IXGBE_DEV_PRIVATE_TO_TM_CONF(dev->data->dev_private);
2516 PMD_INIT_FUNC_TRACE();
2518 /* IXGBE devices don't support:
2519 * - half duplex (checked afterwards for valid speeds)
2520 * - fixed speed: TODO implement
2522 if (dev->data->dev_conf.link_speeds & ETH_LINK_SPEED_FIXED) {
2524 "Invalid link_speeds for port %u, fix speed not supported",
2525 dev->data->port_id);
2529 /* disable uio/vfio intr/eventfd mapping */
2530 rte_intr_disable(intr_handle);
2533 hw->adapter_stopped = 0;
2534 ixgbe_stop_adapter(hw);
2536 /* reinitialize adapter
2537 * this calls reset and start
2539 status = ixgbe_pf_reset_hw(hw);
2542 hw->mac.ops.start_hw(hw);
2543 hw->mac.get_link_status = true;
2545 /* configure PF module if SRIOV enabled */
2546 ixgbe_pf_host_configure(dev);
2548 ixgbe_dev_phy_intr_setup(dev);
2550 /* check and configure queue intr-vector mapping */
2551 if ((rte_intr_cap_multiple(intr_handle) ||
2552 !RTE_ETH_DEV_SRIOV(dev).active) &&
2553 dev->data->dev_conf.intr_conf.rxq != 0) {
2554 intr_vector = dev->data->nb_rx_queues;
2555 if (intr_vector > IXGBE_MAX_INTR_QUEUE_NUM) {
2556 PMD_INIT_LOG(ERR, "At most %d intr queues supported",
2557 IXGBE_MAX_INTR_QUEUE_NUM);
2560 if (rte_intr_efd_enable(intr_handle, intr_vector))
2564 if (rte_intr_dp_is_en(intr_handle) && !intr_handle->intr_vec) {
2565 intr_handle->intr_vec =
2566 rte_zmalloc("intr_vec",
2567 dev->data->nb_rx_queues * sizeof(int), 0);
2568 if (intr_handle->intr_vec == NULL) {
2569 PMD_INIT_LOG(ERR, "Failed to allocate %d rx_queues"
2570 " intr_vec", dev->data->nb_rx_queues);
2575 /* confiugre msix for sleep until rx interrupt */
2576 ixgbe_configure_msix(dev);
2578 /* initialize transmission unit */
2579 ixgbe_dev_tx_init(dev);
2581 /* This can fail when allocating mbufs for descriptor rings */
2582 err = ixgbe_dev_rx_init(dev);
2584 PMD_INIT_LOG(ERR, "Unable to initialize RX hardware");
2588 mask = ETH_VLAN_STRIP_MASK | ETH_VLAN_FILTER_MASK |
2589 ETH_VLAN_EXTEND_MASK;
2590 err = ixgbe_vlan_offload_set(dev, mask);
2592 PMD_INIT_LOG(ERR, "Unable to set VLAN offload");
2596 if (dev->data->dev_conf.rxmode.mq_mode == ETH_MQ_RX_VMDQ_ONLY) {
2597 /* Enable vlan filtering for VMDq */
2598 ixgbe_vmdq_vlan_hw_filter_enable(dev);
2601 /* Configure DCB hw */
2602 ixgbe_configure_dcb(dev);
2604 if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_NONE) {
2605 err = ixgbe_fdir_configure(dev);
2610 /* Restore vf rate limit */
2611 if (vfinfo != NULL) {
2612 for (vf = 0; vf < pci_dev->max_vfs; vf++)
2613 for (idx = 0; idx < IXGBE_MAX_QUEUE_NUM_PER_VF; idx++)
2614 if (vfinfo[vf].tx_rate[idx] != 0)
2615 ixgbe_set_vf_rate_limit(
2617 vfinfo[vf].tx_rate[idx],
2621 ixgbe_restore_statistics_mapping(dev);
2623 err = ixgbe_dev_rxtx_start(dev);
2625 PMD_INIT_LOG(ERR, "Unable to start rxtx queues");
2629 /* Skip link setup if loopback mode is enabled for 82599. */
2630 if (hw->mac.type == ixgbe_mac_82599EB &&
2631 dev->data->dev_conf.lpbk_mode == IXGBE_LPBK_82599_TX_RX)
2632 goto skip_link_setup;
2634 if (ixgbe_is_sfp(hw) && hw->phy.multispeed_fiber) {
2635 err = hw->mac.ops.setup_sfp(hw);
2640 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper) {
2641 /* Turn on the copper */
2642 ixgbe_set_phy_power(hw, true);
2644 /* Turn on the laser */
2645 ixgbe_enable_tx_laser(hw);
2648 err = ixgbe_check_link(hw, &speed, &link_up, 0);
2651 dev->data->dev_link.link_status = link_up;
2653 err = ixgbe_get_link_capabilities(hw, &speed, &negotiate);
2657 link_speeds = &dev->data->dev_conf.link_speeds;
2658 if (*link_speeds & ~(ETH_LINK_SPEED_100M | ETH_LINK_SPEED_1G |
2659 ETH_LINK_SPEED_10G)) {
2660 PMD_INIT_LOG(ERR, "Invalid link setting");
2665 if (*link_speeds == ETH_LINK_SPEED_AUTONEG) {
2666 switch (hw->mac.type) {
2667 case ixgbe_mac_82598EB:
2668 speed = IXGBE_LINK_SPEED_82598_AUTONEG;
2670 case ixgbe_mac_82599EB:
2671 case ixgbe_mac_X540:
2672 speed = IXGBE_LINK_SPEED_82599_AUTONEG;
2674 case ixgbe_mac_X550:
2675 case ixgbe_mac_X550EM_x:
2676 case ixgbe_mac_X550EM_a:
2677 speed = IXGBE_LINK_SPEED_X550_AUTONEG;
2680 speed = IXGBE_LINK_SPEED_82599_AUTONEG;
2683 if (*link_speeds & ETH_LINK_SPEED_10G)
2684 speed |= IXGBE_LINK_SPEED_10GB_FULL;
2685 if (*link_speeds & ETH_LINK_SPEED_1G)
2686 speed |= IXGBE_LINK_SPEED_1GB_FULL;
2687 if (*link_speeds & ETH_LINK_SPEED_100M)
2688 speed |= IXGBE_LINK_SPEED_100_FULL;
2691 err = ixgbe_setup_link(hw, speed, link_up);
2697 if (rte_intr_allow_others(intr_handle)) {
2698 /* check if lsc interrupt is enabled */
2699 if (dev->data->dev_conf.intr_conf.lsc != 0)
2700 ixgbe_dev_lsc_interrupt_setup(dev, TRUE);
2702 ixgbe_dev_lsc_interrupt_setup(dev, FALSE);
2703 ixgbe_dev_macsec_interrupt_setup(dev);
2705 rte_intr_callback_unregister(intr_handle,
2706 ixgbe_dev_interrupt_handler, dev);
2707 if (dev->data->dev_conf.intr_conf.lsc != 0)
2708 PMD_INIT_LOG(INFO, "lsc won't enable because of"
2709 " no intr multiplex");
2712 /* check if rxq interrupt is enabled */
2713 if (dev->data->dev_conf.intr_conf.rxq != 0 &&
2714 rte_intr_dp_is_en(intr_handle))
2715 ixgbe_dev_rxq_interrupt_setup(dev);
2717 /* enable uio/vfio intr/eventfd mapping */
2718 rte_intr_enable(intr_handle);
2720 /* resume enabled intr since hw reset */
2721 ixgbe_enable_intr(dev);
2722 ixgbe_l2_tunnel_conf(dev);
2723 ixgbe_filter_restore(dev);
2725 if (tm_conf->root && !tm_conf->committed)
2726 PMD_DRV_LOG(WARNING,
2727 "please call hierarchy_commit() "
2728 "before starting the port");
2733 PMD_INIT_LOG(ERR, "failure in ixgbe_dev_start(): %d", err);
2734 ixgbe_dev_clear_queues(dev);
2739 * Stop device: disable rx and tx functions to allow for reconfiguring.
2742 ixgbe_dev_stop(struct rte_eth_dev *dev)
2744 struct rte_eth_link link;
2745 struct ixgbe_hw *hw =
2746 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2747 struct ixgbe_vf_info *vfinfo =
2748 *IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private);
2749 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
2750 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
2752 struct ixgbe_tm_conf *tm_conf =
2753 IXGBE_DEV_PRIVATE_TO_TM_CONF(dev->data->dev_private);
2755 PMD_INIT_FUNC_TRACE();
2757 /* disable interrupts */
2758 ixgbe_disable_intr(hw);
2761 ixgbe_pf_reset_hw(hw);
2762 hw->adapter_stopped = 0;
2765 ixgbe_stop_adapter(hw);
2767 for (vf = 0; vfinfo != NULL && vf < pci_dev->max_vfs; vf++)
2768 vfinfo[vf].clear_to_send = false;
2770 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper) {
2771 /* Turn off the copper */
2772 ixgbe_set_phy_power(hw, false);
2774 /* Turn off the laser */
2775 ixgbe_disable_tx_laser(hw);
2778 ixgbe_dev_clear_queues(dev);
2780 /* Clear stored conf */
2781 dev->data->scattered_rx = 0;
2784 /* Clear recorded link status */
2785 memset(&link, 0, sizeof(link));
2786 rte_ixgbe_dev_atomic_write_link_status(dev, &link);
2788 if (!rte_intr_allow_others(intr_handle))
2789 /* resume to the default handler */
2790 rte_intr_callback_register(intr_handle,
2791 ixgbe_dev_interrupt_handler,
2794 /* Clean datapath event and queue/vec mapping */
2795 rte_intr_efd_disable(intr_handle);
2796 if (intr_handle->intr_vec != NULL) {
2797 rte_free(intr_handle->intr_vec);
2798 intr_handle->intr_vec = NULL;
2801 /* reset hierarchy commit */
2802 tm_conf->committed = false;
2806 * Set device link up: enable tx.
2809 ixgbe_dev_set_link_up(struct rte_eth_dev *dev)
2811 struct ixgbe_hw *hw =
2812 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2813 if (hw->mac.type == ixgbe_mac_82599EB) {
2814 #ifdef RTE_LIBRTE_IXGBE_BYPASS
2815 if (hw->device_id == IXGBE_DEV_ID_82599_BYPASS) {
2816 /* Not suported in bypass mode */
2817 PMD_INIT_LOG(ERR, "Set link up is not supported "
2818 "by device id 0x%x", hw->device_id);
2824 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper) {
2825 /* Turn on the copper */
2826 ixgbe_set_phy_power(hw, true);
2828 /* Turn on the laser */
2829 ixgbe_enable_tx_laser(hw);
2836 * Set device link down: disable tx.
2839 ixgbe_dev_set_link_down(struct rte_eth_dev *dev)
2841 struct ixgbe_hw *hw =
2842 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2843 if (hw->mac.type == ixgbe_mac_82599EB) {
2844 #ifdef RTE_LIBRTE_IXGBE_BYPASS
2845 if (hw->device_id == IXGBE_DEV_ID_82599_BYPASS) {
2846 /* Not suported in bypass mode */
2847 PMD_INIT_LOG(ERR, "Set link down is not supported "
2848 "by device id 0x%x", hw->device_id);
2854 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper) {
2855 /* Turn off the copper */
2856 ixgbe_set_phy_power(hw, false);
2858 /* Turn off the laser */
2859 ixgbe_disable_tx_laser(hw);
2866 * Reset and stop device.
2869 ixgbe_dev_close(struct rte_eth_dev *dev)
2871 struct ixgbe_hw *hw =
2872 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2874 PMD_INIT_FUNC_TRACE();
2876 ixgbe_pf_reset_hw(hw);
2878 ixgbe_dev_stop(dev);
2879 hw->adapter_stopped = 1;
2881 ixgbe_dev_free_queues(dev);
2883 ixgbe_disable_pcie_master(hw);
2885 /* reprogram the RAR[0] in case user changed it. */
2886 ixgbe_set_rar(hw, 0, hw->mac.addr, 0, IXGBE_RAH_AV);
2893 ixgbe_dev_reset(struct rte_eth_dev *dev)
2897 /* When a DPDK PMD PF begin to reset PF port, it should notify all
2898 * its VF to make them align with it. The detailed notification
2899 * mechanism is PMD specific. As to ixgbe PF, it is rather complex.
2900 * To avoid unexpected behavior in VF, currently reset of PF with
2901 * SR-IOV activation is not supported. It might be supported later.
2903 if (dev->data->sriov.active)
2906 ret = eth_ixgbe_dev_uninit(dev);
2910 ret = eth_ixgbe_dev_init(dev);
2916 ixgbe_read_stats_registers(struct ixgbe_hw *hw,
2917 struct ixgbe_hw_stats *hw_stats,
2918 struct ixgbe_macsec_stats *macsec_stats,
2919 uint64_t *total_missed_rx, uint64_t *total_qbrc,
2920 uint64_t *total_qprc, uint64_t *total_qprdc)
2922 uint32_t bprc, lxon, lxoff, total;
2923 uint32_t delta_gprc = 0;
2925 /* Workaround for RX byte count not including CRC bytes when CRC
2926 * strip is enabled. CRC bytes are removed from counters when crc_strip
2929 int crc_strip = (IXGBE_READ_REG(hw, IXGBE_HLREG0) &
2930 IXGBE_HLREG0_RXCRCSTRP);
2932 hw_stats->crcerrs += IXGBE_READ_REG(hw, IXGBE_CRCERRS);
2933 hw_stats->illerrc += IXGBE_READ_REG(hw, IXGBE_ILLERRC);
2934 hw_stats->errbc += IXGBE_READ_REG(hw, IXGBE_ERRBC);
2935 hw_stats->mspdc += IXGBE_READ_REG(hw, IXGBE_MSPDC);
2937 for (i = 0; i < 8; i++) {
2938 uint32_t mp = IXGBE_READ_REG(hw, IXGBE_MPC(i));
2940 /* global total per queue */
2941 hw_stats->mpc[i] += mp;
2942 /* Running comprehensive total for stats display */
2943 *total_missed_rx += hw_stats->mpc[i];
2944 if (hw->mac.type == ixgbe_mac_82598EB) {
2945 hw_stats->rnbc[i] +=
2946 IXGBE_READ_REG(hw, IXGBE_RNBC(i));
2947 hw_stats->pxonrxc[i] +=
2948 IXGBE_READ_REG(hw, IXGBE_PXONRXC(i));
2949 hw_stats->pxoffrxc[i] +=
2950 IXGBE_READ_REG(hw, IXGBE_PXOFFRXC(i));
2952 hw_stats->pxonrxc[i] +=
2953 IXGBE_READ_REG(hw, IXGBE_PXONRXCNT(i));
2954 hw_stats->pxoffrxc[i] +=
2955 IXGBE_READ_REG(hw, IXGBE_PXOFFRXCNT(i));
2956 hw_stats->pxon2offc[i] +=
2957 IXGBE_READ_REG(hw, IXGBE_PXON2OFFCNT(i));
2959 hw_stats->pxontxc[i] +=
2960 IXGBE_READ_REG(hw, IXGBE_PXONTXC(i));
2961 hw_stats->pxofftxc[i] +=
2962 IXGBE_READ_REG(hw, IXGBE_PXOFFTXC(i));
2964 for (i = 0; i < IXGBE_QUEUE_STAT_COUNTERS; i++) {
2965 uint32_t delta_qprc = IXGBE_READ_REG(hw, IXGBE_QPRC(i));
2966 uint32_t delta_qptc = IXGBE_READ_REG(hw, IXGBE_QPTC(i));
2967 uint32_t delta_qprdc = IXGBE_READ_REG(hw, IXGBE_QPRDC(i));
2969 delta_gprc += delta_qprc;
2971 hw_stats->qprc[i] += delta_qprc;
2972 hw_stats->qptc[i] += delta_qptc;
2974 hw_stats->qbrc[i] += IXGBE_READ_REG(hw, IXGBE_QBRC_L(i));
2975 hw_stats->qbrc[i] +=
2976 ((uint64_t)IXGBE_READ_REG(hw, IXGBE_QBRC_H(i)) << 32);
2978 hw_stats->qbrc[i] -= delta_qprc * ETHER_CRC_LEN;
2980 hw_stats->qbtc[i] += IXGBE_READ_REG(hw, IXGBE_QBTC_L(i));
2981 hw_stats->qbtc[i] +=
2982 ((uint64_t)IXGBE_READ_REG(hw, IXGBE_QBTC_H(i)) << 32);
2984 hw_stats->qprdc[i] += delta_qprdc;
2985 *total_qprdc += hw_stats->qprdc[i];
2987 *total_qprc += hw_stats->qprc[i];
2988 *total_qbrc += hw_stats->qbrc[i];
2990 hw_stats->mlfc += IXGBE_READ_REG(hw, IXGBE_MLFC);
2991 hw_stats->mrfc += IXGBE_READ_REG(hw, IXGBE_MRFC);
2992 hw_stats->rlec += IXGBE_READ_REG(hw, IXGBE_RLEC);
2995 * An errata states that gprc actually counts good + missed packets:
2996 * Workaround to set gprc to summated queue packet receives
2998 hw_stats->gprc = *total_qprc;
3000 if (hw->mac.type != ixgbe_mac_82598EB) {
3001 hw_stats->gorc += IXGBE_READ_REG(hw, IXGBE_GORCL);
3002 hw_stats->gorc += ((u64)IXGBE_READ_REG(hw, IXGBE_GORCH) << 32);
3003 hw_stats->gotc += IXGBE_READ_REG(hw, IXGBE_GOTCL);
3004 hw_stats->gotc += ((u64)IXGBE_READ_REG(hw, IXGBE_GOTCH) << 32);
3005 hw_stats->tor += IXGBE_READ_REG(hw, IXGBE_TORL);
3006 hw_stats->tor += ((u64)IXGBE_READ_REG(hw, IXGBE_TORH) << 32);
3007 hw_stats->lxonrxc += IXGBE_READ_REG(hw, IXGBE_LXONRXCNT);
3008 hw_stats->lxoffrxc += IXGBE_READ_REG(hw, IXGBE_LXOFFRXCNT);
3010 hw_stats->lxonrxc += IXGBE_READ_REG(hw, IXGBE_LXONRXC);
3011 hw_stats->lxoffrxc += IXGBE_READ_REG(hw, IXGBE_LXOFFRXC);
3012 /* 82598 only has a counter in the high register */
3013 hw_stats->gorc += IXGBE_READ_REG(hw, IXGBE_GORCH);
3014 hw_stats->gotc += IXGBE_READ_REG(hw, IXGBE_GOTCH);
3015 hw_stats->tor += IXGBE_READ_REG(hw, IXGBE_TORH);
3017 uint64_t old_tpr = hw_stats->tpr;
3019 hw_stats->tpr += IXGBE_READ_REG(hw, IXGBE_TPR);
3020 hw_stats->tpt += IXGBE_READ_REG(hw, IXGBE_TPT);
3023 hw_stats->gorc -= delta_gprc * ETHER_CRC_LEN;
3025 uint64_t delta_gptc = IXGBE_READ_REG(hw, IXGBE_GPTC);
3026 hw_stats->gptc += delta_gptc;
3027 hw_stats->gotc -= delta_gptc * ETHER_CRC_LEN;
3028 hw_stats->tor -= (hw_stats->tpr - old_tpr) * ETHER_CRC_LEN;
3031 * Workaround: mprc hardware is incorrectly counting
3032 * broadcasts, so for now we subtract those.
3034 bprc = IXGBE_READ_REG(hw, IXGBE_BPRC);
3035 hw_stats->bprc += bprc;
3036 hw_stats->mprc += IXGBE_READ_REG(hw, IXGBE_MPRC);
3037 if (hw->mac.type == ixgbe_mac_82598EB)
3038 hw_stats->mprc -= bprc;
3040 hw_stats->prc64 += IXGBE_READ_REG(hw, IXGBE_PRC64);
3041 hw_stats->prc127 += IXGBE_READ_REG(hw, IXGBE_PRC127);
3042 hw_stats->prc255 += IXGBE_READ_REG(hw, IXGBE_PRC255);
3043 hw_stats->prc511 += IXGBE_READ_REG(hw, IXGBE_PRC511);
3044 hw_stats->prc1023 += IXGBE_READ_REG(hw, IXGBE_PRC1023);
3045 hw_stats->prc1522 += IXGBE_READ_REG(hw, IXGBE_PRC1522);
3047 lxon = IXGBE_READ_REG(hw, IXGBE_LXONTXC);
3048 hw_stats->lxontxc += lxon;
3049 lxoff = IXGBE_READ_REG(hw, IXGBE_LXOFFTXC);
3050 hw_stats->lxofftxc += lxoff;
3051 total = lxon + lxoff;
3053 hw_stats->mptc += IXGBE_READ_REG(hw, IXGBE_MPTC);
3054 hw_stats->ptc64 += IXGBE_READ_REG(hw, IXGBE_PTC64);
3055 hw_stats->gptc -= total;
3056 hw_stats->mptc -= total;
3057 hw_stats->ptc64 -= total;
3058 hw_stats->gotc -= total * ETHER_MIN_LEN;
3060 hw_stats->ruc += IXGBE_READ_REG(hw, IXGBE_RUC);
3061 hw_stats->rfc += IXGBE_READ_REG(hw, IXGBE_RFC);
3062 hw_stats->roc += IXGBE_READ_REG(hw, IXGBE_ROC);
3063 hw_stats->rjc += IXGBE_READ_REG(hw, IXGBE_RJC);
3064 hw_stats->mngprc += IXGBE_READ_REG(hw, IXGBE_MNGPRC);
3065 hw_stats->mngpdc += IXGBE_READ_REG(hw, IXGBE_MNGPDC);
3066 hw_stats->mngptc += IXGBE_READ_REG(hw, IXGBE_MNGPTC);
3067 hw_stats->ptc127 += IXGBE_READ_REG(hw, IXGBE_PTC127);
3068 hw_stats->ptc255 += IXGBE_READ_REG(hw, IXGBE_PTC255);
3069 hw_stats->ptc511 += IXGBE_READ_REG(hw, IXGBE_PTC511);
3070 hw_stats->ptc1023 += IXGBE_READ_REG(hw, IXGBE_PTC1023);
3071 hw_stats->ptc1522 += IXGBE_READ_REG(hw, IXGBE_PTC1522);
3072 hw_stats->bptc += IXGBE_READ_REG(hw, IXGBE_BPTC);
3073 hw_stats->xec += IXGBE_READ_REG(hw, IXGBE_XEC);
3074 hw_stats->fccrc += IXGBE_READ_REG(hw, IXGBE_FCCRC);
3075 hw_stats->fclast += IXGBE_READ_REG(hw, IXGBE_FCLAST);
3076 /* Only read FCOE on 82599 */
3077 if (hw->mac.type != ixgbe_mac_82598EB) {
3078 hw_stats->fcoerpdc += IXGBE_READ_REG(hw, IXGBE_FCOERPDC);
3079 hw_stats->fcoeprc += IXGBE_READ_REG(hw, IXGBE_FCOEPRC);
3080 hw_stats->fcoeptc += IXGBE_READ_REG(hw, IXGBE_FCOEPTC);
3081 hw_stats->fcoedwrc += IXGBE_READ_REG(hw, IXGBE_FCOEDWRC);
3082 hw_stats->fcoedwtc += IXGBE_READ_REG(hw, IXGBE_FCOEDWTC);
3085 /* Flow Director Stats registers */
3086 hw_stats->fdirmatch += IXGBE_READ_REG(hw, IXGBE_FDIRMATCH);
3087 hw_stats->fdirmiss += IXGBE_READ_REG(hw, IXGBE_FDIRMISS);
3089 /* MACsec Stats registers */
3090 macsec_stats->out_pkts_untagged += IXGBE_READ_REG(hw, IXGBE_LSECTXUT);
3091 macsec_stats->out_pkts_encrypted +=
3092 IXGBE_READ_REG(hw, IXGBE_LSECTXPKTE);
3093 macsec_stats->out_pkts_protected +=
3094 IXGBE_READ_REG(hw, IXGBE_LSECTXPKTP);
3095 macsec_stats->out_octets_encrypted +=
3096 IXGBE_READ_REG(hw, IXGBE_LSECTXOCTE);
3097 macsec_stats->out_octets_protected +=
3098 IXGBE_READ_REG(hw, IXGBE_LSECTXOCTP);
3099 macsec_stats->in_pkts_untagged += IXGBE_READ_REG(hw, IXGBE_LSECRXUT);
3100 macsec_stats->in_pkts_badtag += IXGBE_READ_REG(hw, IXGBE_LSECRXBAD);
3101 macsec_stats->in_pkts_nosci += IXGBE_READ_REG(hw, IXGBE_LSECRXNOSCI);
3102 macsec_stats->in_pkts_unknownsci +=
3103 IXGBE_READ_REG(hw, IXGBE_LSECRXUNSCI);
3104 macsec_stats->in_octets_decrypted +=
3105 IXGBE_READ_REG(hw, IXGBE_LSECRXOCTD);
3106 macsec_stats->in_octets_validated +=
3107 IXGBE_READ_REG(hw, IXGBE_LSECRXOCTV);
3108 macsec_stats->in_pkts_unchecked += IXGBE_READ_REG(hw, IXGBE_LSECRXUNCH);
3109 macsec_stats->in_pkts_delayed += IXGBE_READ_REG(hw, IXGBE_LSECRXDELAY);
3110 macsec_stats->in_pkts_late += IXGBE_READ_REG(hw, IXGBE_LSECRXLATE);
3111 for (i = 0; i < 2; i++) {
3112 macsec_stats->in_pkts_ok +=
3113 IXGBE_READ_REG(hw, IXGBE_LSECRXOK(i));
3114 macsec_stats->in_pkts_invalid +=
3115 IXGBE_READ_REG(hw, IXGBE_LSECRXINV(i));
3116 macsec_stats->in_pkts_notvalid +=
3117 IXGBE_READ_REG(hw, IXGBE_LSECRXNV(i));
3119 macsec_stats->in_pkts_unusedsa += IXGBE_READ_REG(hw, IXGBE_LSECRXUNSA);
3120 macsec_stats->in_pkts_notusingsa +=
3121 IXGBE_READ_REG(hw, IXGBE_LSECRXNUSA);
3125 * This function is based on ixgbe_update_stats_counters() in ixgbe/ixgbe.c
3128 ixgbe_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
3130 struct ixgbe_hw *hw =
3131 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3132 struct ixgbe_hw_stats *hw_stats =
3133 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3134 struct ixgbe_macsec_stats *macsec_stats =
3135 IXGBE_DEV_PRIVATE_TO_MACSEC_STATS(
3136 dev->data->dev_private);
3137 uint64_t total_missed_rx, total_qbrc, total_qprc, total_qprdc;
3140 total_missed_rx = 0;
3145 ixgbe_read_stats_registers(hw, hw_stats, macsec_stats, &total_missed_rx,
3146 &total_qbrc, &total_qprc, &total_qprdc);
3151 /* Fill out the rte_eth_stats statistics structure */
3152 stats->ipackets = total_qprc;
3153 stats->ibytes = total_qbrc;
3154 stats->opackets = hw_stats->gptc;
3155 stats->obytes = hw_stats->gotc;
3157 for (i = 0; i < IXGBE_QUEUE_STAT_COUNTERS; i++) {
3158 stats->q_ipackets[i] = hw_stats->qprc[i];
3159 stats->q_opackets[i] = hw_stats->qptc[i];
3160 stats->q_ibytes[i] = hw_stats->qbrc[i];
3161 stats->q_obytes[i] = hw_stats->qbtc[i];
3162 stats->q_errors[i] = hw_stats->qprdc[i];
3166 stats->imissed = total_missed_rx;
3167 stats->ierrors = hw_stats->crcerrs +
3184 ixgbe_dev_stats_reset(struct rte_eth_dev *dev)
3186 struct ixgbe_hw_stats *stats =
3187 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3189 /* HW registers are cleared on read */
3190 ixgbe_dev_stats_get(dev, NULL);
3192 /* Reset software totals */
3193 memset(stats, 0, sizeof(*stats));
3196 /* This function calculates the number of xstats based on the current config */
3198 ixgbe_xstats_calc_num(void) {
3199 return IXGBE_NB_HW_STATS + IXGBE_NB_MACSEC_STATS +
3200 (IXGBE_NB_RXQ_PRIO_STATS * IXGBE_NB_RXQ_PRIO_VALUES) +
3201 (IXGBE_NB_TXQ_PRIO_STATS * IXGBE_NB_TXQ_PRIO_VALUES);
3204 static int ixgbe_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
3205 struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned int size)
3207 const unsigned cnt_stats = ixgbe_xstats_calc_num();
3208 unsigned stat, i, count;
3210 if (xstats_names != NULL) {
3213 /* Note: limit >= cnt_stats checked upstream
3214 * in rte_eth_xstats_names()
3217 /* Extended stats from ixgbe_hw_stats */
3218 for (i = 0; i < IXGBE_NB_HW_STATS; i++) {
3219 snprintf(xstats_names[count].name,
3220 sizeof(xstats_names[count].name),
3222 rte_ixgbe_stats_strings[i].name);
3227 for (i = 0; i < IXGBE_NB_MACSEC_STATS; i++) {
3228 snprintf(xstats_names[count].name,
3229 sizeof(xstats_names[count].name),
3231 rte_ixgbe_macsec_strings[i].name);
3235 /* RX Priority Stats */
3236 for (stat = 0; stat < IXGBE_NB_RXQ_PRIO_STATS; stat++) {
3237 for (i = 0; i < IXGBE_NB_RXQ_PRIO_VALUES; i++) {
3238 snprintf(xstats_names[count].name,
3239 sizeof(xstats_names[count].name),
3240 "rx_priority%u_%s", i,
3241 rte_ixgbe_rxq_strings[stat].name);
3246 /* TX Priority Stats */
3247 for (stat = 0; stat < IXGBE_NB_TXQ_PRIO_STATS; stat++) {
3248 for (i = 0; i < IXGBE_NB_TXQ_PRIO_VALUES; i++) {
3249 snprintf(xstats_names[count].name,
3250 sizeof(xstats_names[count].name),
3251 "tx_priority%u_%s", i,
3252 rte_ixgbe_txq_strings[stat].name);
3260 static int ixgbe_dev_xstats_get_names_by_id(
3261 struct rte_eth_dev *dev,
3262 struct rte_eth_xstat_name *xstats_names,
3263 const uint64_t *ids,
3267 const unsigned int cnt_stats = ixgbe_xstats_calc_num();
3268 unsigned int stat, i, count;
3270 if (xstats_names != NULL) {
3273 /* Note: limit >= cnt_stats checked upstream
3274 * in rte_eth_xstats_names()
3277 /* Extended stats from ixgbe_hw_stats */
3278 for (i = 0; i < IXGBE_NB_HW_STATS; i++) {
3279 snprintf(xstats_names[count].name,
3280 sizeof(xstats_names[count].name),
3282 rte_ixgbe_stats_strings[i].name);
3287 for (i = 0; i < IXGBE_NB_MACSEC_STATS; i++) {
3288 snprintf(xstats_names[count].name,
3289 sizeof(xstats_names[count].name),
3291 rte_ixgbe_macsec_strings[i].name);
3295 /* RX Priority Stats */
3296 for (stat = 0; stat < IXGBE_NB_RXQ_PRIO_STATS; stat++) {
3297 for (i = 0; i < IXGBE_NB_RXQ_PRIO_VALUES; i++) {
3298 snprintf(xstats_names[count].name,
3299 sizeof(xstats_names[count].name),
3300 "rx_priority%u_%s", i,
3301 rte_ixgbe_rxq_strings[stat].name);
3306 /* TX Priority Stats */
3307 for (stat = 0; stat < IXGBE_NB_TXQ_PRIO_STATS; stat++) {
3308 for (i = 0; i < IXGBE_NB_TXQ_PRIO_VALUES; i++) {
3309 snprintf(xstats_names[count].name,
3310 sizeof(xstats_names[count].name),
3311 "tx_priority%u_%s", i,
3312 rte_ixgbe_txq_strings[stat].name);
3321 uint16_t size = ixgbe_xstats_calc_num();
3322 struct rte_eth_xstat_name xstats_names_copy[size];
3324 ixgbe_dev_xstats_get_names_by_id(dev, xstats_names_copy, NULL,
3327 for (i = 0; i < limit; i++) {
3328 if (ids[i] >= size) {
3329 PMD_INIT_LOG(ERR, "id value isn't valid");
3332 strcpy(xstats_names[i].name,
3333 xstats_names_copy[ids[i]].name);
3338 static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
3339 struct rte_eth_xstat_name *xstats_names, unsigned limit)
3343 if (limit < IXGBEVF_NB_XSTATS && xstats_names != NULL)
3346 if (xstats_names != NULL)
3347 for (i = 0; i < IXGBEVF_NB_XSTATS; i++)
3348 snprintf(xstats_names[i].name,
3349 sizeof(xstats_names[i].name),
3350 "%s", rte_ixgbevf_stats_strings[i].name);
3351 return IXGBEVF_NB_XSTATS;
3355 ixgbe_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
3358 struct ixgbe_hw *hw =
3359 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3360 struct ixgbe_hw_stats *hw_stats =
3361 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3362 struct ixgbe_macsec_stats *macsec_stats =
3363 IXGBE_DEV_PRIVATE_TO_MACSEC_STATS(
3364 dev->data->dev_private);
3365 uint64_t total_missed_rx, total_qbrc, total_qprc, total_qprdc;
3366 unsigned i, stat, count = 0;
3368 count = ixgbe_xstats_calc_num();
3373 total_missed_rx = 0;
3378 ixgbe_read_stats_registers(hw, hw_stats, macsec_stats, &total_missed_rx,
3379 &total_qbrc, &total_qprc, &total_qprdc);
3381 /* If this is a reset xstats is NULL, and we have cleared the
3382 * registers by reading them.
3387 /* Extended stats from ixgbe_hw_stats */
3389 for (i = 0; i < IXGBE_NB_HW_STATS; i++) {
3390 xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
3391 rte_ixgbe_stats_strings[i].offset);
3392 xstats[count].id = count;
3397 for (i = 0; i < IXGBE_NB_MACSEC_STATS; i++) {
3398 xstats[count].value = *(uint64_t *)(((char *)macsec_stats) +
3399 rte_ixgbe_macsec_strings[i].offset);
3400 xstats[count].id = count;
3404 /* RX Priority Stats */
3405 for (stat = 0; stat < IXGBE_NB_RXQ_PRIO_STATS; stat++) {
3406 for (i = 0; i < IXGBE_NB_RXQ_PRIO_VALUES; i++) {
3407 xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
3408 rte_ixgbe_rxq_strings[stat].offset +
3409 (sizeof(uint64_t) * i));
3410 xstats[count].id = count;
3415 /* TX Priority Stats */
3416 for (stat = 0; stat < IXGBE_NB_TXQ_PRIO_STATS; stat++) {
3417 for (i = 0; i < IXGBE_NB_TXQ_PRIO_VALUES; i++) {
3418 xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
3419 rte_ixgbe_txq_strings[stat].offset +
3420 (sizeof(uint64_t) * i));
3421 xstats[count].id = count;
3429 ixgbe_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids,
3430 uint64_t *values, unsigned int n)
3433 struct ixgbe_hw *hw =
3434 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3435 struct ixgbe_hw_stats *hw_stats =
3436 IXGBE_DEV_PRIVATE_TO_STATS(
3437 dev->data->dev_private);
3438 struct ixgbe_macsec_stats *macsec_stats =
3439 IXGBE_DEV_PRIVATE_TO_MACSEC_STATS(
3440 dev->data->dev_private);
3441 uint64_t total_missed_rx, total_qbrc, total_qprc, total_qprdc;
3442 unsigned int i, stat, count = 0;
3444 count = ixgbe_xstats_calc_num();
3446 if (!ids && n < count)
3449 total_missed_rx = 0;
3454 ixgbe_read_stats_registers(hw, hw_stats, macsec_stats,
3455 &total_missed_rx, &total_qbrc, &total_qprc,
3458 /* If this is a reset xstats is NULL, and we have cleared the
3459 * registers by reading them.
3461 if (!ids && !values)
3464 /* Extended stats from ixgbe_hw_stats */
3466 for (i = 0; i < IXGBE_NB_HW_STATS; i++) {
3467 values[count] = *(uint64_t *)(((char *)hw_stats) +
3468 rte_ixgbe_stats_strings[i].offset);
3473 for (i = 0; i < IXGBE_NB_MACSEC_STATS; i++) {
3474 values[count] = *(uint64_t *)(((char *)macsec_stats) +
3475 rte_ixgbe_macsec_strings[i].offset);
3479 /* RX Priority Stats */
3480 for (stat = 0; stat < IXGBE_NB_RXQ_PRIO_STATS; stat++) {
3481 for (i = 0; i < IXGBE_NB_RXQ_PRIO_VALUES; i++) {
3483 *(uint64_t *)(((char *)hw_stats) +
3484 rte_ixgbe_rxq_strings[stat].offset +
3485 (sizeof(uint64_t) * i));
3490 /* TX Priority Stats */
3491 for (stat = 0; stat < IXGBE_NB_TXQ_PRIO_STATS; stat++) {
3492 for (i = 0; i < IXGBE_NB_TXQ_PRIO_VALUES; i++) {
3494 *(uint64_t *)(((char *)hw_stats) +
3495 rte_ixgbe_txq_strings[stat].offset +
3496 (sizeof(uint64_t) * i));
3504 uint16_t size = ixgbe_xstats_calc_num();
3505 uint64_t values_copy[size];
3507 ixgbe_dev_xstats_get_by_id(dev, NULL, values_copy, size);
3509 for (i = 0; i < n; i++) {
3510 if (ids[i] >= size) {
3511 PMD_INIT_LOG(ERR, "id value isn't valid");
3514 values[i] = values_copy[ids[i]];
3520 ixgbe_dev_xstats_reset(struct rte_eth_dev *dev)
3522 struct ixgbe_hw_stats *stats =
3523 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3524 struct ixgbe_macsec_stats *macsec_stats =
3525 IXGBE_DEV_PRIVATE_TO_MACSEC_STATS(
3526 dev->data->dev_private);
3528 unsigned count = ixgbe_xstats_calc_num();
3530 /* HW registers are cleared on read */
3531 ixgbe_dev_xstats_get(dev, NULL, count);
3533 /* Reset software totals */
3534 memset(stats, 0, sizeof(*stats));
3535 memset(macsec_stats, 0, sizeof(*macsec_stats));
3539 ixgbevf_update_stats(struct rte_eth_dev *dev)
3541 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3542 struct ixgbevf_hw_stats *hw_stats = (struct ixgbevf_hw_stats *)
3543 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3545 /* Good Rx packet, include VF loopback */
3546 UPDATE_VF_STAT(IXGBE_VFGPRC,
3547 hw_stats->last_vfgprc, hw_stats->vfgprc);
3549 /* Good Rx octets, include VF loopback */
3550 UPDATE_VF_STAT_36BIT(IXGBE_VFGORC_LSB, IXGBE_VFGORC_MSB,
3551 hw_stats->last_vfgorc, hw_stats->vfgorc);
3553 /* Good Tx packet, include VF loopback */
3554 UPDATE_VF_STAT(IXGBE_VFGPTC,
3555 hw_stats->last_vfgptc, hw_stats->vfgptc);
3557 /* Good Tx octets, include VF loopback */
3558 UPDATE_VF_STAT_36BIT(IXGBE_VFGOTC_LSB, IXGBE_VFGOTC_MSB,
3559 hw_stats->last_vfgotc, hw_stats->vfgotc);
3561 /* Rx Multicst Packet */
3562 UPDATE_VF_STAT(IXGBE_VFMPRC,
3563 hw_stats->last_vfmprc, hw_stats->vfmprc);
3567 ixgbevf_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
3570 struct ixgbevf_hw_stats *hw_stats = (struct ixgbevf_hw_stats *)
3571 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3574 if (n < IXGBEVF_NB_XSTATS)
3575 return IXGBEVF_NB_XSTATS;
3577 ixgbevf_update_stats(dev);
3582 /* Extended stats */
3583 for (i = 0; i < IXGBEVF_NB_XSTATS; i++) {
3585 xstats[i].value = *(uint64_t *)(((char *)hw_stats) +
3586 rte_ixgbevf_stats_strings[i].offset);
3589 return IXGBEVF_NB_XSTATS;
3593 ixgbevf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
3595 struct ixgbevf_hw_stats *hw_stats = (struct ixgbevf_hw_stats *)
3596 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3598 ixgbevf_update_stats(dev);
3603 stats->ipackets = hw_stats->vfgprc;
3604 stats->ibytes = hw_stats->vfgorc;
3605 stats->opackets = hw_stats->vfgptc;
3606 stats->obytes = hw_stats->vfgotc;
3611 ixgbevf_dev_stats_reset(struct rte_eth_dev *dev)
3613 struct ixgbevf_hw_stats *hw_stats = (struct ixgbevf_hw_stats *)
3614 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3616 /* Sync HW register to the last stats */
3617 ixgbevf_dev_stats_get(dev, NULL);
3619 /* reset HW current stats*/
3620 hw_stats->vfgprc = 0;
3621 hw_stats->vfgorc = 0;
3622 hw_stats->vfgptc = 0;
3623 hw_stats->vfgotc = 0;
3627 ixgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size)
3629 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3630 u16 eeprom_verh, eeprom_verl;
3634 ixgbe_read_eeprom(hw, 0x2e, &eeprom_verh);
3635 ixgbe_read_eeprom(hw, 0x2d, &eeprom_verl);
3637 etrack_id = (eeprom_verh << 16) | eeprom_verl;
3638 ret = snprintf(fw_version, fw_size, "0x%08x", etrack_id);
3640 ret += 1; /* add the size of '\0' */
3641 if (fw_size < (u32)ret)
3648 ixgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
3650 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
3651 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3652 struct rte_eth_conf *dev_conf = &dev->data->dev_conf;
3654 dev_info->pci_dev = pci_dev;
3655 dev_info->max_rx_queues = (uint16_t)hw->mac.max_rx_queues;
3656 dev_info->max_tx_queues = (uint16_t)hw->mac.max_tx_queues;
3657 if (RTE_ETH_DEV_SRIOV(dev).active == 0) {
3659 * When DCB/VT is off, maximum number of queues changes,
3660 * except for 82598EB, which remains constant.
3662 if (dev_conf->txmode.mq_mode == ETH_MQ_TX_NONE &&
3663 hw->mac.type != ixgbe_mac_82598EB)
3664 dev_info->max_tx_queues = IXGBE_NONE_MODE_TX_NB_QUEUES;
3666 dev_info->min_rx_bufsize = 1024; /* cf BSIZEPACKET in SRRCTL register */
3667 dev_info->max_rx_pktlen = 15872; /* includes CRC, cf MAXFRS register */
3668 dev_info->max_mac_addrs = hw->mac.num_rar_entries;
3669 dev_info->max_hash_mac_addrs = IXGBE_VMDQ_NUM_UC_MAC;
3670 dev_info->max_vfs = pci_dev->max_vfs;
3671 if (hw->mac.type == ixgbe_mac_82598EB)
3672 dev_info->max_vmdq_pools = ETH_16_POOLS;
3674 dev_info->max_vmdq_pools = ETH_64_POOLS;
3675 dev_info->vmdq_queue_num = dev_info->max_rx_queues;
3676 dev_info->rx_offload_capa =
3677 DEV_RX_OFFLOAD_VLAN_STRIP |
3678 DEV_RX_OFFLOAD_IPV4_CKSUM |
3679 DEV_RX_OFFLOAD_UDP_CKSUM |
3680 DEV_RX_OFFLOAD_TCP_CKSUM;
3683 * RSC is only supported by 82599 and x540 PF devices in a non-SR-IOV
3686 if ((hw->mac.type == ixgbe_mac_82599EB ||
3687 hw->mac.type == ixgbe_mac_X540) &&
3688 !RTE_ETH_DEV_SRIOV(dev).active)
3689 dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_TCP_LRO;
3691 if (hw->mac.type == ixgbe_mac_82599EB ||
3692 hw->mac.type == ixgbe_mac_X540)
3693 dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_MACSEC_STRIP;
3695 if (hw->mac.type == ixgbe_mac_X550 ||
3696 hw->mac.type == ixgbe_mac_X550EM_x ||
3697 hw->mac.type == ixgbe_mac_X550EM_a)
3698 dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM;
3700 dev_info->tx_offload_capa =
3701 DEV_TX_OFFLOAD_VLAN_INSERT |
3702 DEV_TX_OFFLOAD_IPV4_CKSUM |
3703 DEV_TX_OFFLOAD_UDP_CKSUM |
3704 DEV_TX_OFFLOAD_TCP_CKSUM |
3705 DEV_TX_OFFLOAD_SCTP_CKSUM |
3706 DEV_TX_OFFLOAD_TCP_TSO;
3708 if (hw->mac.type == ixgbe_mac_82599EB ||
3709 hw->mac.type == ixgbe_mac_X540)
3710 dev_info->tx_offload_capa |= DEV_TX_OFFLOAD_MACSEC_INSERT;
3712 if (hw->mac.type == ixgbe_mac_X550 ||
3713 hw->mac.type == ixgbe_mac_X550EM_x ||
3714 hw->mac.type == ixgbe_mac_X550EM_a)
3715 dev_info->tx_offload_capa |= DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
3717 #ifdef RTE_LIBRTE_SECURITY
3718 dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_SECURITY;
3719 dev_info->tx_offload_capa |= DEV_TX_OFFLOAD_SECURITY;
3722 dev_info->default_rxconf = (struct rte_eth_rxconf) {
3724 .pthresh = IXGBE_DEFAULT_RX_PTHRESH,
3725 .hthresh = IXGBE_DEFAULT_RX_HTHRESH,
3726 .wthresh = IXGBE_DEFAULT_RX_WTHRESH,
3728 .rx_free_thresh = IXGBE_DEFAULT_RX_FREE_THRESH,
3732 dev_info->default_txconf = (struct rte_eth_txconf) {
3734 .pthresh = IXGBE_DEFAULT_TX_PTHRESH,
3735 .hthresh = IXGBE_DEFAULT_TX_HTHRESH,
3736 .wthresh = IXGBE_DEFAULT_TX_WTHRESH,
3738 .tx_free_thresh = IXGBE_DEFAULT_TX_FREE_THRESH,
3739 .tx_rs_thresh = IXGBE_DEFAULT_TX_RSBIT_THRESH,
3740 .txq_flags = ETH_TXQ_FLAGS_NOMULTSEGS |
3741 ETH_TXQ_FLAGS_NOOFFLOADS,
3744 dev_info->rx_desc_lim = rx_desc_lim;
3745 dev_info->tx_desc_lim = tx_desc_lim;
3747 dev_info->hash_key_size = IXGBE_HKEY_MAX_INDEX * sizeof(uint32_t);
3748 dev_info->reta_size = ixgbe_reta_size_get(hw->mac.type);
3749 dev_info->flow_type_rss_offloads = IXGBE_RSS_OFFLOAD_ALL;
3751 dev_info->speed_capa = ETH_LINK_SPEED_1G | ETH_LINK_SPEED_10G;
3752 if (hw->mac.type == ixgbe_mac_X540 ||
3753 hw->mac.type == ixgbe_mac_X540_vf ||
3754 hw->mac.type == ixgbe_mac_X550 ||
3755 hw->mac.type == ixgbe_mac_X550_vf) {
3756 dev_info->speed_capa |= ETH_LINK_SPEED_100M;
3758 if (hw->mac.type == ixgbe_mac_X550) {
3759 dev_info->speed_capa |= ETH_LINK_SPEED_2_5G;
3760 dev_info->speed_capa |= ETH_LINK_SPEED_5G;
3764 static const uint32_t *
3765 ixgbe_dev_supported_ptypes_get(struct rte_eth_dev *dev)
3767 static const uint32_t ptypes[] = {
3768 /* For non-vec functions,
3769 * refers to ixgbe_rxd_pkt_info_to_pkt_type();
3770 * for vec functions,
3771 * refers to _recv_raw_pkts_vec().
3775 RTE_PTYPE_L3_IPV4_EXT,
3777 RTE_PTYPE_L3_IPV6_EXT,
3781 RTE_PTYPE_TUNNEL_IP,
3782 RTE_PTYPE_INNER_L3_IPV6,
3783 RTE_PTYPE_INNER_L3_IPV6_EXT,
3784 RTE_PTYPE_INNER_L4_TCP,
3785 RTE_PTYPE_INNER_L4_UDP,
3789 if (dev->rx_pkt_burst == ixgbe_recv_pkts ||
3790 dev->rx_pkt_burst == ixgbe_recv_pkts_lro_single_alloc ||
3791 dev->rx_pkt_burst == ixgbe_recv_pkts_lro_bulk_alloc ||
3792 dev->rx_pkt_burst == ixgbe_recv_pkts_bulk_alloc)
3795 #if defined(RTE_ARCH_X86)
3796 if (dev->rx_pkt_burst == ixgbe_recv_pkts_vec ||
3797 dev->rx_pkt_burst == ixgbe_recv_scattered_pkts_vec)
3804 ixgbevf_dev_info_get(struct rte_eth_dev *dev,
3805 struct rte_eth_dev_info *dev_info)
3807 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
3808 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3810 dev_info->pci_dev = pci_dev;
3811 dev_info->max_rx_queues = (uint16_t)hw->mac.max_rx_queues;
3812 dev_info->max_tx_queues = (uint16_t)hw->mac.max_tx_queues;
3813 dev_info->min_rx_bufsize = 1024; /* cf BSIZEPACKET in SRRCTL reg */
3814 dev_info->max_rx_pktlen = 9728; /* includes CRC, cf MAXFRS reg */
3815 dev_info->max_mac_addrs = hw->mac.num_rar_entries;
3816 dev_info->max_hash_mac_addrs = IXGBE_VMDQ_NUM_UC_MAC;
3817 dev_info->max_vfs = pci_dev->max_vfs;
3818 if (hw->mac.type == ixgbe_mac_82598EB)
3819 dev_info->max_vmdq_pools = ETH_16_POOLS;
3821 dev_info->max_vmdq_pools = ETH_64_POOLS;
3822 dev_info->rx_offload_capa = DEV_RX_OFFLOAD_VLAN_STRIP |
3823 DEV_RX_OFFLOAD_IPV4_CKSUM |
3824 DEV_RX_OFFLOAD_UDP_CKSUM |
3825 DEV_RX_OFFLOAD_TCP_CKSUM;
3826 dev_info->tx_offload_capa = DEV_TX_OFFLOAD_VLAN_INSERT |
3827 DEV_TX_OFFLOAD_IPV4_CKSUM |
3828 DEV_TX_OFFLOAD_UDP_CKSUM |
3829 DEV_TX_OFFLOAD_TCP_CKSUM |
3830 DEV_TX_OFFLOAD_SCTP_CKSUM |
3831 DEV_TX_OFFLOAD_TCP_TSO;
3833 dev_info->default_rxconf = (struct rte_eth_rxconf) {
3835 .pthresh = IXGBE_DEFAULT_RX_PTHRESH,
3836 .hthresh = IXGBE_DEFAULT_RX_HTHRESH,
3837 .wthresh = IXGBE_DEFAULT_RX_WTHRESH,
3839 .rx_free_thresh = IXGBE_DEFAULT_RX_FREE_THRESH,
3843 dev_info->default_txconf = (struct rte_eth_txconf) {
3845 .pthresh = IXGBE_DEFAULT_TX_PTHRESH,
3846 .hthresh = IXGBE_DEFAULT_TX_HTHRESH,
3847 .wthresh = IXGBE_DEFAULT_TX_WTHRESH,
3849 .tx_free_thresh = IXGBE_DEFAULT_TX_FREE_THRESH,
3850 .tx_rs_thresh = IXGBE_DEFAULT_TX_RSBIT_THRESH,
3851 .txq_flags = ETH_TXQ_FLAGS_NOMULTSEGS |
3852 ETH_TXQ_FLAGS_NOOFFLOADS,
3855 dev_info->rx_desc_lim = rx_desc_lim;
3856 dev_info->tx_desc_lim = tx_desc_lim;
3860 ixgbevf_check_link(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
3861 int *link_up, int wait_to_complete)
3864 * for a quick link status checking, wait_to_compelet == 0,
3865 * skip PF link status checking
3867 bool no_pflink_check = wait_to_complete == 0;
3868 struct ixgbe_mbx_info *mbx = &hw->mbx;
3869 struct ixgbe_mac_info *mac = &hw->mac;
3870 uint32_t links_reg, in_msg;
3873 /* If we were hit with a reset drop the link */
3874 if (!mbx->ops.check_for_rst(hw, 0) || !mbx->timeout)
3875 mac->get_link_status = true;
3877 if (!mac->get_link_status)
3880 /* if link status is down no point in checking to see if pf is up */
3881 links_reg = IXGBE_READ_REG(hw, IXGBE_VFLINKS);
3882 if (!(links_reg & IXGBE_LINKS_UP))
3885 /* for SFP+ modules and DA cables on 82599 it can take up to 500usecs
3886 * before the link status is correct
3888 if (mac->type == ixgbe_mac_82599_vf) {
3891 for (i = 0; i < 5; i++) {
3893 links_reg = IXGBE_READ_REG(hw, IXGBE_VFLINKS);
3895 if (!(links_reg & IXGBE_LINKS_UP))
3900 switch (links_reg & IXGBE_LINKS_SPEED_82599) {
3901 case IXGBE_LINKS_SPEED_10G_82599:
3902 *speed = IXGBE_LINK_SPEED_10GB_FULL;
3903 if (hw->mac.type >= ixgbe_mac_X550) {
3904 if (links_reg & IXGBE_LINKS_SPEED_NON_STD)
3905 *speed = IXGBE_LINK_SPEED_2_5GB_FULL;
3908 case IXGBE_LINKS_SPEED_1G_82599:
3909 *speed = IXGBE_LINK_SPEED_1GB_FULL;
3911 case IXGBE_LINKS_SPEED_100_82599:
3912 *speed = IXGBE_LINK_SPEED_100_FULL;
3913 if (hw->mac.type == ixgbe_mac_X550) {
3914 if (links_reg & IXGBE_LINKS_SPEED_NON_STD)
3915 *speed = IXGBE_LINK_SPEED_5GB_FULL;
3918 case IXGBE_LINKS_SPEED_10_X550EM_A:
3919 *speed = IXGBE_LINK_SPEED_UNKNOWN;
3920 /* Since Reserved in older MAC's */
3921 if (hw->mac.type >= ixgbe_mac_X550)
3922 *speed = IXGBE_LINK_SPEED_10_FULL;
3925 *speed = IXGBE_LINK_SPEED_UNKNOWN;
3928 if (no_pflink_check) {
3929 if (*speed == IXGBE_LINK_SPEED_UNKNOWN)
3930 mac->get_link_status = true;
3932 mac->get_link_status = false;
3936 /* if the read failed it could just be a mailbox collision, best wait
3937 * until we are called again and don't report an error
3939 if (mbx->ops.read(hw, &in_msg, 1, 0))
3942 if (!(in_msg & IXGBE_VT_MSGTYPE_CTS)) {
3943 /* msg is not CTS and is NACK we must have lost CTS status */
3944 if (in_msg & IXGBE_VT_MSGTYPE_NACK)
3949 /* the pf is talking, if we timed out in the past we reinit */
3950 if (!mbx->timeout) {
3955 /* if we passed all the tests above then the link is up and we no
3956 * longer need to check for link
3958 mac->get_link_status = false;
3961 *link_up = !mac->get_link_status;
3965 /* return 0 means link status changed, -1 means not changed */
3967 ixgbe_dev_link_update_share(struct rte_eth_dev *dev,
3968 int wait_to_complete, int vf)
3970 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3971 struct rte_eth_link link, old;
3972 ixgbe_link_speed link_speed = IXGBE_LINK_SPEED_UNKNOWN;
3973 struct ixgbe_interrupt *intr =
3974 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
3979 bool autoneg = false;
3981 link.link_status = ETH_LINK_DOWN;
3982 link.link_speed = 0;
3983 link.link_duplex = ETH_LINK_HALF_DUPLEX;
3984 link.link_autoneg = ETH_LINK_AUTONEG;
3985 memset(&old, 0, sizeof(old));
3986 rte_ixgbe_dev_atomic_read_link_status(dev, &old);
3988 hw->mac.get_link_status = true;
3990 if ((intr->flags & IXGBE_FLAG_NEED_LINK_CONFIG) &&
3991 ixgbe_get_media_type(hw) == ixgbe_media_type_fiber) {
3992 speed = hw->phy.autoneg_advertised;
3994 ixgbe_get_link_capabilities(hw, &speed, &autoneg);
3995 ixgbe_setup_link(hw, speed, true);
3998 /* check if it needs to wait to complete, if lsc interrupt is enabled */
3999 if (wait_to_complete == 0 || dev->data->dev_conf.intr_conf.lsc != 0)
4003 diag = ixgbevf_check_link(hw, &link_speed, &link_up, wait);
4005 diag = ixgbe_check_link(hw, &link_speed, &link_up, wait);
4008 link.link_speed = ETH_SPEED_NUM_100M;
4009 link.link_duplex = ETH_LINK_FULL_DUPLEX;
4010 rte_ixgbe_dev_atomic_write_link_status(dev, &link);
4011 if (link.link_status == old.link_status)
4017 rte_ixgbe_dev_atomic_write_link_status(dev, &link);
4018 intr->flags |= IXGBE_FLAG_NEED_LINK_CONFIG;
4019 if (link.link_status == old.link_status)
4023 intr->flags &= ~IXGBE_FLAG_NEED_LINK_CONFIG;
4024 link.link_status = ETH_LINK_UP;
4025 link.link_duplex = ETH_LINK_FULL_DUPLEX;
4027 switch (link_speed) {
4029 case IXGBE_LINK_SPEED_UNKNOWN:
4030 link.link_duplex = ETH_LINK_FULL_DUPLEX;
4031 link.link_speed = ETH_SPEED_NUM_100M;
4034 case IXGBE_LINK_SPEED_100_FULL:
4035 link.link_speed = ETH_SPEED_NUM_100M;
4038 case IXGBE_LINK_SPEED_1GB_FULL:
4039 link.link_speed = ETH_SPEED_NUM_1G;
4042 case IXGBE_LINK_SPEED_2_5GB_FULL:
4043 link.link_speed = ETH_SPEED_NUM_2_5G;
4046 case IXGBE_LINK_SPEED_5GB_FULL:
4047 link.link_speed = ETH_SPEED_NUM_5G;
4050 case IXGBE_LINK_SPEED_10GB_FULL:
4051 link.link_speed = ETH_SPEED_NUM_10G;
4054 rte_ixgbe_dev_atomic_write_link_status(dev, &link);
4056 if (link.link_status == old.link_status)
4063 ixgbe_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
4065 return ixgbe_dev_link_update_share(dev, wait_to_complete, 0);
4069 ixgbevf_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
4071 return ixgbe_dev_link_update_share(dev, wait_to_complete, 1);
4075 ixgbe_dev_promiscuous_enable(struct rte_eth_dev *dev)
4077 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4080 fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
4081 fctrl |= (IXGBE_FCTRL_UPE | IXGBE_FCTRL_MPE);
4082 IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
4086 ixgbe_dev_promiscuous_disable(struct rte_eth_dev *dev)
4088 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4091 fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
4092 fctrl &= (~IXGBE_FCTRL_UPE);
4093 if (dev->data->all_multicast == 1)
4094 fctrl |= IXGBE_FCTRL_MPE;
4096 fctrl &= (~IXGBE_FCTRL_MPE);
4097 IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
4101 ixgbe_dev_allmulticast_enable(struct rte_eth_dev *dev)
4103 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4106 fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
4107 fctrl |= IXGBE_FCTRL_MPE;
4108 IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
4112 ixgbe_dev_allmulticast_disable(struct rte_eth_dev *dev)
4114 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4117 if (dev->data->promiscuous == 1)
4118 return; /* must remain in all_multicast mode */
4120 fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
4121 fctrl &= (~IXGBE_FCTRL_MPE);
4122 IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
4126 * It clears the interrupt causes and enables the interrupt.
4127 * It will be called once only during nic initialized.
4130 * Pointer to struct rte_eth_dev.
4132 * Enable or Disable.
4135 * - On success, zero.
4136 * - On failure, a negative value.
4139 ixgbe_dev_lsc_interrupt_setup(struct rte_eth_dev *dev, uint8_t on)
4141 struct ixgbe_interrupt *intr =
4142 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
4144 ixgbe_dev_link_status_print(dev);
4146 intr->mask |= IXGBE_EICR_LSC;
4148 intr->mask &= ~IXGBE_EICR_LSC;
4154 * It clears the interrupt causes and enables the interrupt.
4155 * It will be called once only during nic initialized.
4158 * Pointer to struct rte_eth_dev.
4161 * - On success, zero.
4162 * - On failure, a negative value.
4165 ixgbe_dev_rxq_interrupt_setup(struct rte_eth_dev *dev)
4167 struct ixgbe_interrupt *intr =
4168 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
4170 intr->mask |= IXGBE_EICR_RTX_QUEUE;
4176 * It clears the interrupt causes and enables the interrupt.
4177 * It will be called once only during nic initialized.
4180 * Pointer to struct rte_eth_dev.
4183 * - On success, zero.
4184 * - On failure, a negative value.
4187 ixgbe_dev_macsec_interrupt_setup(struct rte_eth_dev *dev)
4189 struct ixgbe_interrupt *intr =
4190 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
4192 intr->mask |= IXGBE_EICR_LINKSEC;
4198 * It reads ICR and sets flag (IXGBE_EICR_LSC) for the link_update.
4201 * Pointer to struct rte_eth_dev.
4204 * - On success, zero.
4205 * - On failure, a negative value.
4208 ixgbe_dev_interrupt_get_status(struct rte_eth_dev *dev)
4211 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4212 struct ixgbe_interrupt *intr =
4213 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
4215 /* clear all cause mask */
4216 ixgbe_disable_intr(hw);
4218 /* read-on-clear nic registers here */
4219 eicr = IXGBE_READ_REG(hw, IXGBE_EICR);
4220 PMD_DRV_LOG(DEBUG, "eicr %x", eicr);
4224 /* set flag for async link update */
4225 if (eicr & IXGBE_EICR_LSC)
4226 intr->flags |= IXGBE_FLAG_NEED_LINK_UPDATE;
4228 if (eicr & IXGBE_EICR_MAILBOX)
4229 intr->flags |= IXGBE_FLAG_MAILBOX;
4231 if (eicr & IXGBE_EICR_LINKSEC)
4232 intr->flags |= IXGBE_FLAG_MACSEC;
4234 if (hw->mac.type == ixgbe_mac_X550EM_x &&
4235 hw->phy.type == ixgbe_phy_x550em_ext_t &&
4236 (eicr & IXGBE_EICR_GPI_SDP0_X550EM_x))
4237 intr->flags |= IXGBE_FLAG_PHY_INTERRUPT;
4243 * It gets and then prints the link status.
4246 * Pointer to struct rte_eth_dev.
4249 * - On success, zero.
4250 * - On failure, a negative value.
4253 ixgbe_dev_link_status_print(struct rte_eth_dev *dev)
4255 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
4256 struct rte_eth_link link;
4258 memset(&link, 0, sizeof(link));
4259 rte_ixgbe_dev_atomic_read_link_status(dev, &link);
4260 if (link.link_status) {
4261 PMD_INIT_LOG(INFO, "Port %d: Link Up - speed %u Mbps - %s",
4262 (int)(dev->data->port_id),
4263 (unsigned)link.link_speed,
4264 link.link_duplex == ETH_LINK_FULL_DUPLEX ?
4265 "full-duplex" : "half-duplex");
4267 PMD_INIT_LOG(INFO, " Port %d: Link Down",
4268 (int)(dev->data->port_id));
4270 PMD_INIT_LOG(DEBUG, "PCI Address: " PCI_PRI_FMT,
4271 pci_dev->addr.domain,
4273 pci_dev->addr.devid,
4274 pci_dev->addr.function);
4278 * It executes link_update after knowing an interrupt occurred.
4281 * Pointer to struct rte_eth_dev.
4284 * - On success, zero.
4285 * - On failure, a negative value.
4288 ixgbe_dev_interrupt_action(struct rte_eth_dev *dev,
4289 struct rte_intr_handle *intr_handle)
4291 struct ixgbe_interrupt *intr =
4292 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
4294 struct rte_eth_link link;
4295 struct ixgbe_hw *hw =
4296 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4298 PMD_DRV_LOG(DEBUG, "intr action type %d", intr->flags);
4300 if (intr->flags & IXGBE_FLAG_MAILBOX) {
4301 ixgbe_pf_mbx_process(dev);
4302 intr->flags &= ~IXGBE_FLAG_MAILBOX;
4305 if (intr->flags & IXGBE_FLAG_PHY_INTERRUPT) {
4306 ixgbe_handle_lasi(hw);
4307 intr->flags &= ~IXGBE_FLAG_PHY_INTERRUPT;
4310 if (intr->flags & IXGBE_FLAG_NEED_LINK_UPDATE) {
4311 /* get the link status before link update, for predicting later */
4312 memset(&link, 0, sizeof(link));
4313 rte_ixgbe_dev_atomic_read_link_status(dev, &link);
4315 ixgbe_dev_link_update(dev, 0);
4318 if (!link.link_status)
4319 /* handle it 1 sec later, wait it being stable */
4320 timeout = IXGBE_LINK_UP_CHECK_TIMEOUT;
4321 /* likely to down */
4323 /* handle it 4 sec later, wait it being stable */
4324 timeout = IXGBE_LINK_DOWN_CHECK_TIMEOUT;
4326 ixgbe_dev_link_status_print(dev);
4327 if (rte_eal_alarm_set(timeout * 1000,
4328 ixgbe_dev_interrupt_delayed_handler, (void *)dev) < 0)
4329 PMD_DRV_LOG(ERR, "Error setting alarm");
4331 /* remember original mask */
4332 intr->mask_original = intr->mask;
4333 /* only disable lsc interrupt */
4334 intr->mask &= ~IXGBE_EIMS_LSC;
4338 PMD_DRV_LOG(DEBUG, "enable intr immediately");
4339 ixgbe_enable_intr(dev);
4340 rte_intr_enable(intr_handle);
4346 * Interrupt handler which shall be registered for alarm callback for delayed
4347 * handling specific interrupt to wait for the stable nic state. As the
4348 * NIC interrupt state is not stable for ixgbe after link is just down,
4349 * it needs to wait 4 seconds to get the stable status.
4352 * Pointer to interrupt handle.
4354 * The address of parameter (struct rte_eth_dev *) regsitered before.
4360 ixgbe_dev_interrupt_delayed_handler(void *param)
4362 struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
4363 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
4364 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
4365 struct ixgbe_interrupt *intr =
4366 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
4367 struct ixgbe_hw *hw =
4368 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4371 ixgbe_disable_intr(hw);
4373 eicr = IXGBE_READ_REG(hw, IXGBE_EICR);
4374 if (eicr & IXGBE_EICR_MAILBOX)
4375 ixgbe_pf_mbx_process(dev);
4377 if (intr->flags & IXGBE_FLAG_PHY_INTERRUPT) {
4378 ixgbe_handle_lasi(hw);
4379 intr->flags &= ~IXGBE_FLAG_PHY_INTERRUPT;
4382 if (intr->flags & IXGBE_FLAG_NEED_LINK_UPDATE) {
4383 ixgbe_dev_link_update(dev, 0);
4384 intr->flags &= ~IXGBE_FLAG_NEED_LINK_UPDATE;
4385 ixgbe_dev_link_status_print(dev);
4386 _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC,
4390 if (intr->flags & IXGBE_FLAG_MACSEC) {
4391 _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_MACSEC,
4393 intr->flags &= ~IXGBE_FLAG_MACSEC;
4396 /* restore original mask */
4397 intr->mask = intr->mask_original;
4398 intr->mask_original = 0;
4400 PMD_DRV_LOG(DEBUG, "enable intr in delayed handler S[%08x]", eicr);
4401 ixgbe_enable_intr(dev);
4402 rte_intr_enable(intr_handle);
4406 * Interrupt handler triggered by NIC for handling
4407 * specific interrupt.
4410 * Pointer to interrupt handle.
4412 * The address of parameter (struct rte_eth_dev *) regsitered before.
4418 ixgbe_dev_interrupt_handler(void *param)
4420 struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
4422 ixgbe_dev_interrupt_get_status(dev);
4423 ixgbe_dev_interrupt_action(dev, dev->intr_handle);
4427 ixgbe_dev_led_on(struct rte_eth_dev *dev)
4429 struct ixgbe_hw *hw;
4431 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4432 return ixgbe_led_on(hw, 0) == IXGBE_SUCCESS ? 0 : -ENOTSUP;
4436 ixgbe_dev_led_off(struct rte_eth_dev *dev)
4438 struct ixgbe_hw *hw;
4440 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4441 return ixgbe_led_off(hw, 0) == IXGBE_SUCCESS ? 0 : -ENOTSUP;
4445 ixgbe_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
4447 struct ixgbe_hw *hw;
4453 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4455 fc_conf->pause_time = hw->fc.pause_time;
4456 fc_conf->high_water = hw->fc.high_water[0];
4457 fc_conf->low_water = hw->fc.low_water[0];
4458 fc_conf->send_xon = hw->fc.send_xon;
4459 fc_conf->autoneg = !hw->fc.disable_fc_autoneg;
4462 * Return rx_pause status according to actual setting of
4465 mflcn_reg = IXGBE_READ_REG(hw, IXGBE_MFLCN);
4466 if (mflcn_reg & (IXGBE_MFLCN_RPFCE | IXGBE_MFLCN_RFCE))
4472 * Return tx_pause status according to actual setting of
4475 fccfg_reg = IXGBE_READ_REG(hw, IXGBE_FCCFG);
4476 if (fccfg_reg & (IXGBE_FCCFG_TFCE_802_3X | IXGBE_FCCFG_TFCE_PRIORITY))
4481 if (rx_pause && tx_pause)
4482 fc_conf->mode = RTE_FC_FULL;
4484 fc_conf->mode = RTE_FC_RX_PAUSE;
4486 fc_conf->mode = RTE_FC_TX_PAUSE;
4488 fc_conf->mode = RTE_FC_NONE;
4494 ixgbe_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
4496 struct ixgbe_hw *hw;
4498 uint32_t rx_buf_size;
4499 uint32_t max_high_water;
4501 enum ixgbe_fc_mode rte_fcmode_2_ixgbe_fcmode[] = {
4508 PMD_INIT_FUNC_TRACE();
4510 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4511 rx_buf_size = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(0));
4512 PMD_INIT_LOG(DEBUG, "Rx packet buffer size = 0x%x", rx_buf_size);
4515 * At least reserve one Ethernet frame for watermark
4516 * high_water/low_water in kilo bytes for ixgbe
4518 max_high_water = (rx_buf_size - ETHER_MAX_LEN) >> IXGBE_RXPBSIZE_SHIFT;
4519 if ((fc_conf->high_water > max_high_water) ||
4520 (fc_conf->high_water < fc_conf->low_water)) {
4521 PMD_INIT_LOG(ERR, "Invalid high/low water setup value in KB");
4522 PMD_INIT_LOG(ERR, "High_water must <= 0x%x", max_high_water);
4526 hw->fc.requested_mode = rte_fcmode_2_ixgbe_fcmode[fc_conf->mode];
4527 hw->fc.pause_time = fc_conf->pause_time;
4528 hw->fc.high_water[0] = fc_conf->high_water;
4529 hw->fc.low_water[0] = fc_conf->low_water;
4530 hw->fc.send_xon = fc_conf->send_xon;
4531 hw->fc.disable_fc_autoneg = !fc_conf->autoneg;
4533 err = ixgbe_fc_enable(hw);
4535 /* Not negotiated is not an error case */
4536 if ((err == IXGBE_SUCCESS) || (err == IXGBE_ERR_FC_NOT_NEGOTIATED)) {
4538 /* check if we want to forward MAC frames - driver doesn't have native
4539 * capability to do that, so we'll write the registers ourselves */
4541 mflcn = IXGBE_READ_REG(hw, IXGBE_MFLCN);
4543 /* set or clear MFLCN.PMCF bit depending on configuration */
4544 if (fc_conf->mac_ctrl_frame_fwd != 0)
4545 mflcn |= IXGBE_MFLCN_PMCF;
4547 mflcn &= ~IXGBE_MFLCN_PMCF;
4549 IXGBE_WRITE_REG(hw, IXGBE_MFLCN, mflcn);
4550 IXGBE_WRITE_FLUSH(hw);
4555 PMD_INIT_LOG(ERR, "ixgbe_fc_enable = 0x%x", err);
4560 * ixgbe_pfc_enable_generic - Enable flow control
4561 * @hw: pointer to hardware structure
4562 * @tc_num: traffic class number
4563 * Enable flow control according to the current settings.
4566 ixgbe_dcb_pfc_enable_generic(struct ixgbe_hw *hw, uint8_t tc_num)
4569 uint32_t mflcn_reg, fccfg_reg;
4571 uint32_t fcrtl, fcrth;
4575 /* Validate the water mark configuration */
4576 if (!hw->fc.pause_time) {
4577 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
4581 /* Low water mark of zero causes XOFF floods */
4582 if (hw->fc.current_mode & ixgbe_fc_tx_pause) {
4583 /* High/Low water can not be 0 */
4584 if ((!hw->fc.high_water[tc_num]) || (!hw->fc.low_water[tc_num])) {
4585 PMD_INIT_LOG(ERR, "Invalid water mark configuration");
4586 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
4590 if (hw->fc.low_water[tc_num] >= hw->fc.high_water[tc_num]) {
4591 PMD_INIT_LOG(ERR, "Invalid water mark configuration");
4592 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
4596 /* Negotiate the fc mode to use */
4597 ixgbe_fc_autoneg(hw);
4599 /* Disable any previous flow control settings */
4600 mflcn_reg = IXGBE_READ_REG(hw, IXGBE_MFLCN);
4601 mflcn_reg &= ~(IXGBE_MFLCN_RPFCE_SHIFT | IXGBE_MFLCN_RFCE|IXGBE_MFLCN_RPFCE);
4603 fccfg_reg = IXGBE_READ_REG(hw, IXGBE_FCCFG);
4604 fccfg_reg &= ~(IXGBE_FCCFG_TFCE_802_3X | IXGBE_FCCFG_TFCE_PRIORITY);
4606 switch (hw->fc.current_mode) {
4609 * If the count of enabled RX Priority Flow control >1,
4610 * and the TX pause can not be disabled
4613 for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
4614 reg = IXGBE_READ_REG(hw, IXGBE_FCRTH_82599(i));
4615 if (reg & IXGBE_FCRTH_FCEN)
4619 fccfg_reg |= IXGBE_FCCFG_TFCE_PRIORITY;
4621 case ixgbe_fc_rx_pause:
4623 * Rx Flow control is enabled and Tx Flow control is
4624 * disabled by software override. Since there really
4625 * isn't a way to advertise that we are capable of RX
4626 * Pause ONLY, we will advertise that we support both
4627 * symmetric and asymmetric Rx PAUSE. Later, we will
4628 * disable the adapter's ability to send PAUSE frames.
4630 mflcn_reg |= IXGBE_MFLCN_RPFCE;
4632 * If the count of enabled RX Priority Flow control >1,
4633 * and the TX pause can not be disabled
4636 for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
4637 reg = IXGBE_READ_REG(hw, IXGBE_FCRTH_82599(i));
4638 if (reg & IXGBE_FCRTH_FCEN)
4642 fccfg_reg |= IXGBE_FCCFG_TFCE_PRIORITY;
4644 case ixgbe_fc_tx_pause:
4646 * Tx Flow control is enabled, and Rx Flow control is
4647 * disabled by software override.
4649 fccfg_reg |= IXGBE_FCCFG_TFCE_PRIORITY;
4652 /* Flow control (both Rx and Tx) is enabled by SW override. */
4653 mflcn_reg |= IXGBE_MFLCN_RPFCE;
4654 fccfg_reg |= IXGBE_FCCFG_TFCE_PRIORITY;
4657 PMD_DRV_LOG(DEBUG, "Flow control param set incorrectly");
4658 ret_val = IXGBE_ERR_CONFIG;
4662 /* Set 802.3x based flow control settings. */
4663 mflcn_reg |= IXGBE_MFLCN_DPF;
4664 IXGBE_WRITE_REG(hw, IXGBE_MFLCN, mflcn_reg);
4665 IXGBE_WRITE_REG(hw, IXGBE_FCCFG, fccfg_reg);
4667 /* Set up and enable Rx high/low water mark thresholds, enable XON. */
4668 if ((hw->fc.current_mode & ixgbe_fc_tx_pause) &&
4669 hw->fc.high_water[tc_num]) {
4670 fcrtl = (hw->fc.low_water[tc_num] << 10) | IXGBE_FCRTL_XONE;
4671 IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(tc_num), fcrtl);
4672 fcrth = (hw->fc.high_water[tc_num] << 10) | IXGBE_FCRTH_FCEN;
4674 IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(tc_num), 0);
4676 * In order to prevent Tx hangs when the internal Tx
4677 * switch is enabled we must set the high water mark
4678 * to the maximum FCRTH value. This allows the Tx
4679 * switch to function even under heavy Rx workloads.
4681 fcrth = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(tc_num)) - 32;
4683 IXGBE_WRITE_REG(hw, IXGBE_FCRTH_82599(tc_num), fcrth);
4685 /* Configure pause time (2 TCs per register) */
4686 reg = hw->fc.pause_time * 0x00010001;
4687 for (i = 0; i < (IXGBE_DCB_MAX_TRAFFIC_CLASS / 2); i++)
4688 IXGBE_WRITE_REG(hw, IXGBE_FCTTV(i), reg);
4690 /* Configure flow control refresh threshold value */
4691 IXGBE_WRITE_REG(hw, IXGBE_FCRTV, hw->fc.pause_time / 2);
4698 ixgbe_dcb_pfc_enable(struct rte_eth_dev *dev, uint8_t tc_num)
4700 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4701 int32_t ret_val = IXGBE_NOT_IMPLEMENTED;
4703 if (hw->mac.type != ixgbe_mac_82598EB) {
4704 ret_val = ixgbe_dcb_pfc_enable_generic(hw, tc_num);
4710 ixgbe_priority_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_pfc_conf *pfc_conf)
4713 uint32_t rx_buf_size;
4714 uint32_t max_high_water;
4716 uint8_t map[IXGBE_DCB_MAX_USER_PRIORITY] = { 0 };
4717 struct ixgbe_hw *hw =
4718 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4719 struct ixgbe_dcb_config *dcb_config =
4720 IXGBE_DEV_PRIVATE_TO_DCB_CFG(dev->data->dev_private);
4722 enum ixgbe_fc_mode rte_fcmode_2_ixgbe_fcmode[] = {
4729 PMD_INIT_FUNC_TRACE();
4731 ixgbe_dcb_unpack_map_cee(dcb_config, IXGBE_DCB_RX_CONFIG, map);
4732 tc_num = map[pfc_conf->priority];
4733 rx_buf_size = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(tc_num));
4734 PMD_INIT_LOG(DEBUG, "Rx packet buffer size = 0x%x", rx_buf_size);
4736 * At least reserve one Ethernet frame for watermark
4737 * high_water/low_water in kilo bytes for ixgbe
4739 max_high_water = (rx_buf_size - ETHER_MAX_LEN) >> IXGBE_RXPBSIZE_SHIFT;
4740 if ((pfc_conf->fc.high_water > max_high_water) ||
4741 (pfc_conf->fc.high_water <= pfc_conf->fc.low_water)) {
4742 PMD_INIT_LOG(ERR, "Invalid high/low water setup value in KB");
4743 PMD_INIT_LOG(ERR, "High_water must <= 0x%x", max_high_water);
4747 hw->fc.requested_mode = rte_fcmode_2_ixgbe_fcmode[pfc_conf->fc.mode];
4748 hw->fc.pause_time = pfc_conf->fc.pause_time;
4749 hw->fc.send_xon = pfc_conf->fc.send_xon;
4750 hw->fc.low_water[tc_num] = pfc_conf->fc.low_water;
4751 hw->fc.high_water[tc_num] = pfc_conf->fc.high_water;
4753 err = ixgbe_dcb_pfc_enable(dev, tc_num);
4755 /* Not negotiated is not an error case */
4756 if ((err == IXGBE_SUCCESS) || (err == IXGBE_ERR_FC_NOT_NEGOTIATED))
4759 PMD_INIT_LOG(ERR, "ixgbe_dcb_pfc_enable = 0x%x", err);
4764 ixgbe_dev_rss_reta_update(struct rte_eth_dev *dev,
4765 struct rte_eth_rss_reta_entry64 *reta_conf,
4768 uint16_t i, sp_reta_size;
4771 uint16_t idx, shift;
4772 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4775 PMD_INIT_FUNC_TRACE();
4777 if (!ixgbe_rss_update_sp(hw->mac.type)) {
4778 PMD_DRV_LOG(ERR, "RSS reta update is not supported on this "
4783 sp_reta_size = ixgbe_reta_size_get(hw->mac.type);
4784 if (reta_size != sp_reta_size) {
4785 PMD_DRV_LOG(ERR, "The size of hash lookup table configured "
4786 "(%d) doesn't match the number hardware can supported "
4787 "(%d)", reta_size, sp_reta_size);
4791 for (i = 0; i < reta_size; i += IXGBE_4_BIT_WIDTH) {
4792 idx = i / RTE_RETA_GROUP_SIZE;
4793 shift = i % RTE_RETA_GROUP_SIZE;
4794 mask = (uint8_t)((reta_conf[idx].mask >> shift) &
4798 reta_reg = ixgbe_reta_reg_get(hw->mac.type, i);
4799 if (mask == IXGBE_4_BIT_MASK)
4802 r = IXGBE_READ_REG(hw, reta_reg);
4803 for (j = 0, reta = 0; j < IXGBE_4_BIT_WIDTH; j++) {
4804 if (mask & (0x1 << j))
4805 reta |= reta_conf[idx].reta[shift + j] <<
4808 reta |= r & (IXGBE_8_BIT_MASK <<
4811 IXGBE_WRITE_REG(hw, reta_reg, reta);
4818 ixgbe_dev_rss_reta_query(struct rte_eth_dev *dev,
4819 struct rte_eth_rss_reta_entry64 *reta_conf,
4822 uint16_t i, sp_reta_size;
4825 uint16_t idx, shift;
4826 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4829 PMD_INIT_FUNC_TRACE();
4830 sp_reta_size = ixgbe_reta_size_get(hw->mac.type);
4831 if (reta_size != sp_reta_size) {
4832 PMD_DRV_LOG(ERR, "The size of hash lookup table configured "
4833 "(%d) doesn't match the number hardware can supported "
4834 "(%d)", reta_size, sp_reta_size);
4838 for (i = 0; i < reta_size; i += IXGBE_4_BIT_WIDTH) {
4839 idx = i / RTE_RETA_GROUP_SIZE;
4840 shift = i % RTE_RETA_GROUP_SIZE;
4841 mask = (uint8_t)((reta_conf[idx].mask >> shift) &
4846 reta_reg = ixgbe_reta_reg_get(hw->mac.type, i);
4847 reta = IXGBE_READ_REG(hw, reta_reg);
4848 for (j = 0; j < IXGBE_4_BIT_WIDTH; j++) {
4849 if (mask & (0x1 << j))
4850 reta_conf[idx].reta[shift + j] =
4851 ((reta >> (CHAR_BIT * j)) &
4860 ixgbe_add_rar(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
4861 uint32_t index, uint32_t pool)
4863 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4864 uint32_t enable_addr = 1;
4866 return ixgbe_set_rar(hw, index, mac_addr->addr_bytes,
4871 ixgbe_remove_rar(struct rte_eth_dev *dev, uint32_t index)
4873 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4875 ixgbe_clear_rar(hw, index);
4879 ixgbe_set_default_mac_addr(struct rte_eth_dev *dev, struct ether_addr *addr)
4881 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
4883 ixgbe_remove_rar(dev, 0);
4885 ixgbe_add_rar(dev, addr, 0, pci_dev->max_vfs);
4889 is_device_supported(struct rte_eth_dev *dev, struct rte_pci_driver *drv)
4891 if (strcmp(dev->device->driver->name, drv->driver.name))
4898 is_ixgbe_supported(struct rte_eth_dev *dev)
4900 return is_device_supported(dev, &rte_ixgbe_pmd);
4904 ixgbe_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
4908 struct ixgbe_hw *hw;
4909 struct rte_eth_dev_info dev_info;
4910 uint32_t frame_size = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
4911 struct rte_eth_dev_data *dev_data = dev->data;
4913 ixgbe_dev_info_get(dev, &dev_info);
4915 /* check that mtu is within the allowed range */
4916 if ((mtu < ETHER_MIN_MTU) || (frame_size > dev_info.max_rx_pktlen))
4919 /* If device is started, refuse mtu that requires the support of
4920 * scattered packets when this feature has not been enabled before.
4922 if (dev_data->dev_started && !dev_data->scattered_rx &&
4923 (frame_size + 2 * IXGBE_VLAN_TAG_SIZE >
4924 dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM)) {
4925 PMD_INIT_LOG(ERR, "Stop port first.");
4929 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4930 hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
4932 /* switch to jumbo mode if needed */
4933 if (frame_size > ETHER_MAX_LEN) {
4934 dev->data->dev_conf.rxmode.jumbo_frame = 1;
4935 hlreg0 |= IXGBE_HLREG0_JUMBOEN;
4937 dev->data->dev_conf.rxmode.jumbo_frame = 0;
4938 hlreg0 &= ~IXGBE_HLREG0_JUMBOEN;
4940 IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
4942 /* update max frame size */
4943 dev->data->dev_conf.rxmode.max_rx_pkt_len = frame_size;
4945 maxfrs = IXGBE_READ_REG(hw, IXGBE_MAXFRS);
4946 maxfrs &= 0x0000FFFF;
4947 maxfrs |= (dev->data->dev_conf.rxmode.max_rx_pkt_len << 16);
4948 IXGBE_WRITE_REG(hw, IXGBE_MAXFRS, maxfrs);
4954 * Virtual Function operations
4957 ixgbevf_intr_disable(struct ixgbe_hw *hw)
4959 PMD_INIT_FUNC_TRACE();
4961 /* Clear interrupt mask to stop from interrupts being generated */
4962 IXGBE_WRITE_REG(hw, IXGBE_VTEIMC, IXGBE_VF_IRQ_CLEAR_MASK);
4964 IXGBE_WRITE_FLUSH(hw);
4968 ixgbevf_intr_enable(struct ixgbe_hw *hw)
4970 PMD_INIT_FUNC_TRACE();
4972 /* VF enable interrupt autoclean */
4973 IXGBE_WRITE_REG(hw, IXGBE_VTEIAM, IXGBE_VF_IRQ_ENABLE_MASK);
4974 IXGBE_WRITE_REG(hw, IXGBE_VTEIAC, IXGBE_VF_IRQ_ENABLE_MASK);
4975 IXGBE_WRITE_REG(hw, IXGBE_VTEIMS, IXGBE_VF_IRQ_ENABLE_MASK);
4977 IXGBE_WRITE_FLUSH(hw);
4981 ixgbevf_dev_configure(struct rte_eth_dev *dev)
4983 struct rte_eth_conf *conf = &dev->data->dev_conf;
4984 struct ixgbe_adapter *adapter =
4985 (struct ixgbe_adapter *)dev->data->dev_private;
4987 PMD_INIT_LOG(DEBUG, "Configured Virtual Function port id: %d",
4988 dev->data->port_id);
4991 * VF has no ability to enable/disable HW CRC
4992 * Keep the persistent behavior the same as Host PF
4994 #ifndef RTE_LIBRTE_IXGBE_PF_DISABLE_STRIP_CRC
4995 if (!conf->rxmode.hw_strip_crc) {
4996 PMD_INIT_LOG(NOTICE, "VF can't disable HW CRC Strip");
4997 conf->rxmode.hw_strip_crc = 1;
5000 if (conf->rxmode.hw_strip_crc) {
5001 PMD_INIT_LOG(NOTICE, "VF can't enable HW CRC Strip");
5002 conf->rxmode.hw_strip_crc = 0;
5007 * Initialize to TRUE. If any of Rx queues doesn't meet the bulk
5008 * allocation or vector Rx preconditions we will reset it.
5010 adapter->rx_bulk_alloc_allowed = true;
5011 adapter->rx_vec_allowed = true;
5017 ixgbevf_dev_start(struct rte_eth_dev *dev)
5019 struct ixgbe_hw *hw =
5020 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5021 uint32_t intr_vector = 0;
5022 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
5023 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
5027 PMD_INIT_FUNC_TRACE();
5029 hw->mac.ops.reset_hw(hw);
5030 hw->mac.get_link_status = true;
5032 /* negotiate mailbox API version to use with the PF. */
5033 ixgbevf_negotiate_api(hw);
5035 ixgbevf_dev_tx_init(dev);
5037 /* This can fail when allocating mbufs for descriptor rings */
5038 err = ixgbevf_dev_rx_init(dev);
5040 PMD_INIT_LOG(ERR, "Unable to initialize RX hardware (%d)", err);
5041 ixgbe_dev_clear_queues(dev);
5046 ixgbevf_set_vfta_all(dev, 1);
5049 mask = ETH_VLAN_STRIP_MASK | ETH_VLAN_FILTER_MASK |
5050 ETH_VLAN_EXTEND_MASK;
5051 err = ixgbevf_vlan_offload_set(dev, mask);
5053 PMD_INIT_LOG(ERR, "Unable to set VLAN offload (%d)", err);
5054 ixgbe_dev_clear_queues(dev);
5058 ixgbevf_dev_rxtx_start(dev);
5060 /* check and configure queue intr-vector mapping */
5061 if (dev->data->dev_conf.intr_conf.rxq != 0) {
5062 /* According to datasheet, only vector 0/1/2 can be used,
5063 * now only one vector is used for Rx queue
5066 if (rte_intr_efd_enable(intr_handle, intr_vector))
5070 if (rte_intr_dp_is_en(intr_handle) && !intr_handle->intr_vec) {
5071 intr_handle->intr_vec =
5072 rte_zmalloc("intr_vec",
5073 dev->data->nb_rx_queues * sizeof(int), 0);
5074 if (intr_handle->intr_vec == NULL) {
5075 PMD_INIT_LOG(ERR, "Failed to allocate %d rx_queues"
5076 " intr_vec", dev->data->nb_rx_queues);
5080 ixgbevf_configure_msix(dev);
5082 /* When a VF port is bound to VFIO-PCI, only miscellaneous interrupt
5083 * is mapped to VFIO vector 0 in eth_ixgbevf_dev_init( ).
5084 * If previous VFIO interrupt mapping setting in eth_ixgbevf_dev_init( )
5085 * is not cleared, it will fail when following rte_intr_enable( ) tries
5086 * to map Rx queue interrupt to other VFIO vectors.
5087 * So clear uio/vfio intr/evevnfd first to avoid failure.
5089 rte_intr_disable(intr_handle);
5091 rte_intr_enable(intr_handle);
5093 /* Re-enable interrupt for VF */
5094 ixgbevf_intr_enable(hw);
5100 ixgbevf_dev_stop(struct rte_eth_dev *dev)
5102 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5103 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
5104 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
5106 PMD_INIT_FUNC_TRACE();
5108 ixgbevf_intr_disable(hw);
5110 hw->adapter_stopped = 1;
5111 ixgbe_stop_adapter(hw);
5114 * Clear what we set, but we still keep shadow_vfta to
5115 * restore after device starts
5117 ixgbevf_set_vfta_all(dev, 0);
5119 /* Clear stored conf */
5120 dev->data->scattered_rx = 0;
5122 ixgbe_dev_clear_queues(dev);
5124 /* Clean datapath event and queue/vec mapping */
5125 rte_intr_efd_disable(intr_handle);
5126 if (intr_handle->intr_vec != NULL) {
5127 rte_free(intr_handle->intr_vec);
5128 intr_handle->intr_vec = NULL;
5133 ixgbevf_dev_close(struct rte_eth_dev *dev)
5135 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5137 PMD_INIT_FUNC_TRACE();
5141 ixgbevf_dev_stop(dev);
5143 ixgbe_dev_free_queues(dev);
5146 * Remove the VF MAC address ro ensure
5147 * that the VF traffic goes to the PF
5148 * after stop, close and detach of the VF
5150 ixgbevf_remove_mac_addr(dev, 0);
5157 ixgbevf_dev_reset(struct rte_eth_dev *dev)
5161 ret = eth_ixgbevf_dev_uninit(dev);
5165 ret = eth_ixgbevf_dev_init(dev);
5170 static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on)
5172 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5173 struct ixgbe_vfta *shadow_vfta =
5174 IXGBE_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
5175 int i = 0, j = 0, vfta = 0, mask = 1;
5177 for (i = 0; i < IXGBE_VFTA_SIZE; i++) {
5178 vfta = shadow_vfta->vfta[i];
5181 for (j = 0; j < 32; j++) {
5183 ixgbe_set_vfta(hw, (i<<5)+j, 0,
5193 ixgbevf_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
5195 struct ixgbe_hw *hw =
5196 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5197 struct ixgbe_vfta *shadow_vfta =
5198 IXGBE_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
5199 uint32_t vid_idx = 0;
5200 uint32_t vid_bit = 0;
5203 PMD_INIT_FUNC_TRACE();
5205 /* vind is not used in VF driver, set to 0, check ixgbe_set_vfta_vf */
5206 ret = ixgbe_set_vfta(hw, vlan_id, 0, !!on, false);
5208 PMD_INIT_LOG(ERR, "Unable to set VF vlan");
5211 vid_idx = (uint32_t) ((vlan_id >> 5) & 0x7F);
5212 vid_bit = (uint32_t) (1 << (vlan_id & 0x1F));
5214 /* Save what we set and retore it after device reset */
5216 shadow_vfta->vfta[vid_idx] |= vid_bit;
5218 shadow_vfta->vfta[vid_idx] &= ~vid_bit;
5224 ixgbevf_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue, int on)
5226 struct ixgbe_hw *hw =
5227 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5230 PMD_INIT_FUNC_TRACE();
5232 if (queue >= hw->mac.max_rx_queues)
5235 ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(queue));
5237 ctrl |= IXGBE_RXDCTL_VME;
5239 ctrl &= ~IXGBE_RXDCTL_VME;
5240 IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(queue), ctrl);
5242 ixgbe_vlan_hw_strip_bitmap_set(dev, queue, on);
5246 ixgbevf_vlan_offload_set(struct rte_eth_dev *dev, int mask)
5248 struct ixgbe_hw *hw =
5249 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5253 /* VF function only support hw strip feature, others are not support */
5254 if (mask & ETH_VLAN_STRIP_MASK) {
5255 on = !!(dev->data->dev_conf.rxmode.hw_vlan_strip);
5257 for (i = 0; i < hw->mac.max_rx_queues; i++)
5258 ixgbevf_vlan_strip_queue_set(dev, i, on);
5265 ixgbe_vt_check(struct ixgbe_hw *hw)
5269 /* if Virtualization Technology is enabled */
5270 reg_val = IXGBE_READ_REG(hw, IXGBE_VT_CTL);
5271 if (!(reg_val & IXGBE_VT_CTL_VT_ENABLE)) {
5272 PMD_INIT_LOG(ERR, "VT must be enabled for this setting");
5280 ixgbe_uta_vector(struct ixgbe_hw *hw, struct ether_addr *uc_addr)
5282 uint32_t vector = 0;
5284 switch (hw->mac.mc_filter_type) {
5285 case 0: /* use bits [47:36] of the address */
5286 vector = ((uc_addr->addr_bytes[4] >> 4) |
5287 (((uint16_t)uc_addr->addr_bytes[5]) << 4));
5289 case 1: /* use bits [46:35] of the address */
5290 vector = ((uc_addr->addr_bytes[4] >> 3) |
5291 (((uint16_t)uc_addr->addr_bytes[5]) << 5));
5293 case 2: /* use bits [45:34] of the address */
5294 vector = ((uc_addr->addr_bytes[4] >> 2) |
5295 (((uint16_t)uc_addr->addr_bytes[5]) << 6));
5297 case 3: /* use bits [43:32] of the address */
5298 vector = ((uc_addr->addr_bytes[4]) |
5299 (((uint16_t)uc_addr->addr_bytes[5]) << 8));
5301 default: /* Invalid mc_filter_type */
5305 /* vector can only be 12-bits or boundary will be exceeded */
5311 ixgbe_uc_hash_table_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
5319 const uint32_t ixgbe_uta_idx_mask = 0x7F;
5320 const uint32_t ixgbe_uta_bit_shift = 5;
5321 const uint32_t ixgbe_uta_bit_mask = (0x1 << ixgbe_uta_bit_shift) - 1;
5322 const uint32_t bit1 = 0x1;
5324 struct ixgbe_hw *hw =
5325 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5326 struct ixgbe_uta_info *uta_info =
5327 IXGBE_DEV_PRIVATE_TO_UTA(dev->data->dev_private);
5329 /* The UTA table only exists on 82599 hardware and newer */
5330 if (hw->mac.type < ixgbe_mac_82599EB)
5333 vector = ixgbe_uta_vector(hw, mac_addr);
5334 uta_idx = (vector >> ixgbe_uta_bit_shift) & ixgbe_uta_idx_mask;
5335 uta_shift = vector & ixgbe_uta_bit_mask;
5337 rc = ((uta_info->uta_shadow[uta_idx] >> uta_shift & bit1) != 0);
5341 reg_val = IXGBE_READ_REG(hw, IXGBE_UTA(uta_idx));
5343 uta_info->uta_in_use++;
5344 reg_val |= (bit1 << uta_shift);
5345 uta_info->uta_shadow[uta_idx] |= (bit1 << uta_shift);
5347 uta_info->uta_in_use--;
5348 reg_val &= ~(bit1 << uta_shift);
5349 uta_info->uta_shadow[uta_idx] &= ~(bit1 << uta_shift);
5352 IXGBE_WRITE_REG(hw, IXGBE_UTA(uta_idx), reg_val);
5354 if (uta_info->uta_in_use > 0)
5355 IXGBE_WRITE_REG(hw, IXGBE_MCSTCTRL,
5356 IXGBE_MCSTCTRL_MFE | hw->mac.mc_filter_type);
5358 IXGBE_WRITE_REG(hw, IXGBE_MCSTCTRL, hw->mac.mc_filter_type);
5364 ixgbe_uc_all_hash_table_set(struct rte_eth_dev *dev, uint8_t on)
5367 struct ixgbe_hw *hw =
5368 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5369 struct ixgbe_uta_info *uta_info =
5370 IXGBE_DEV_PRIVATE_TO_UTA(dev->data->dev_private);
5372 /* The UTA table only exists on 82599 hardware and newer */
5373 if (hw->mac.type < ixgbe_mac_82599EB)
5377 for (i = 0; i < ETH_VMDQ_NUM_UC_HASH_ARRAY; i++) {
5378 uta_info->uta_shadow[i] = ~0;
5379 IXGBE_WRITE_REG(hw, IXGBE_UTA(i), ~0);
5382 for (i = 0; i < ETH_VMDQ_NUM_UC_HASH_ARRAY; i++) {
5383 uta_info->uta_shadow[i] = 0;
5384 IXGBE_WRITE_REG(hw, IXGBE_UTA(i), 0);
5392 ixgbe_convert_vm_rx_mask_to_val(uint16_t rx_mask, uint32_t orig_val)
5394 uint32_t new_val = orig_val;
5396 if (rx_mask & ETH_VMDQ_ACCEPT_UNTAG)
5397 new_val |= IXGBE_VMOLR_AUPE;
5398 if (rx_mask & ETH_VMDQ_ACCEPT_HASH_MC)
5399 new_val |= IXGBE_VMOLR_ROMPE;
5400 if (rx_mask & ETH_VMDQ_ACCEPT_HASH_UC)
5401 new_val |= IXGBE_VMOLR_ROPE;
5402 if (rx_mask & ETH_VMDQ_ACCEPT_BROADCAST)
5403 new_val |= IXGBE_VMOLR_BAM;
5404 if (rx_mask & ETH_VMDQ_ACCEPT_MULTICAST)
5405 new_val |= IXGBE_VMOLR_MPE;
5410 #define IXGBE_MRCTL_VPME 0x01 /* Virtual Pool Mirroring. */
5411 #define IXGBE_MRCTL_UPME 0x02 /* Uplink Port Mirroring. */
5412 #define IXGBE_MRCTL_DPME 0x04 /* Downlink Port Mirroring. */
5413 #define IXGBE_MRCTL_VLME 0x08 /* VLAN Mirroring. */
5414 #define IXGBE_INVALID_MIRROR_TYPE(mirror_type) \
5415 ((mirror_type) & ~(uint8_t)(ETH_MIRROR_VIRTUAL_POOL_UP | \
5416 ETH_MIRROR_UPLINK_PORT | ETH_MIRROR_DOWNLINK_PORT | ETH_MIRROR_VLAN))
5419 ixgbe_mirror_rule_set(struct rte_eth_dev *dev,
5420 struct rte_eth_mirror_conf *mirror_conf,
5421 uint8_t rule_id, uint8_t on)
5423 uint32_t mr_ctl, vlvf;
5424 uint32_t mp_lsb = 0;
5425 uint32_t mv_msb = 0;
5426 uint32_t mv_lsb = 0;
5427 uint32_t mp_msb = 0;
5430 uint64_t vlan_mask = 0;
5432 const uint8_t pool_mask_offset = 32;
5433 const uint8_t vlan_mask_offset = 32;
5434 const uint8_t dst_pool_offset = 8;
5435 const uint8_t rule_mr_offset = 4;
5436 const uint8_t mirror_rule_mask = 0x0F;
5438 struct ixgbe_mirror_info *mr_info =
5439 (IXGBE_DEV_PRIVATE_TO_PFDATA(dev->data->dev_private));
5440 struct ixgbe_hw *hw =
5441 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5442 uint8_t mirror_type = 0;
5444 if (ixgbe_vt_check(hw) < 0)
5447 if (rule_id >= IXGBE_MAX_MIRROR_RULES)
5450 if (IXGBE_INVALID_MIRROR_TYPE(mirror_conf->rule_type)) {
5451 PMD_DRV_LOG(ERR, "unsupported mirror type 0x%x.",
5452 mirror_conf->rule_type);
5456 if (mirror_conf->rule_type & ETH_MIRROR_VLAN) {
5457 mirror_type |= IXGBE_MRCTL_VLME;
5458 /* Check if vlan id is valid and find conresponding VLAN ID
5461 for (i = 0; i < IXGBE_VLVF_ENTRIES; i++) {
5462 if (mirror_conf->vlan.vlan_mask & (1ULL << i)) {
5463 /* search vlan id related pool vlan filter
5466 reg_index = ixgbe_find_vlvf_slot(
5468 mirror_conf->vlan.vlan_id[i],
5472 vlvf = IXGBE_READ_REG(hw,
5473 IXGBE_VLVF(reg_index));
5474 if ((vlvf & IXGBE_VLVF_VIEN) &&
5475 ((vlvf & IXGBE_VLVF_VLANID_MASK) ==
5476 mirror_conf->vlan.vlan_id[i]))
5477 vlan_mask |= (1ULL << reg_index);
5484 mv_lsb = vlan_mask & 0xFFFFFFFF;
5485 mv_msb = vlan_mask >> vlan_mask_offset;
5487 mr_info->mr_conf[rule_id].vlan.vlan_mask =
5488 mirror_conf->vlan.vlan_mask;
5489 for (i = 0; i < ETH_VMDQ_MAX_VLAN_FILTERS; i++) {
5490 if (mirror_conf->vlan.vlan_mask & (1ULL << i))
5491 mr_info->mr_conf[rule_id].vlan.vlan_id[i] =
5492 mirror_conf->vlan.vlan_id[i];
5497 mr_info->mr_conf[rule_id].vlan.vlan_mask = 0;
5498 for (i = 0; i < ETH_VMDQ_MAX_VLAN_FILTERS; i++)
5499 mr_info->mr_conf[rule_id].vlan.vlan_id[i] = 0;
5504 * if enable pool mirror, write related pool mask register,if disable
5505 * pool mirror, clear PFMRVM register
5507 if (mirror_conf->rule_type & ETH_MIRROR_VIRTUAL_POOL_UP) {
5508 mirror_type |= IXGBE_MRCTL_VPME;
5510 mp_lsb = mirror_conf->pool_mask & 0xFFFFFFFF;
5511 mp_msb = mirror_conf->pool_mask >> pool_mask_offset;
5512 mr_info->mr_conf[rule_id].pool_mask =
5513 mirror_conf->pool_mask;
5518 mr_info->mr_conf[rule_id].pool_mask = 0;
5521 if (mirror_conf->rule_type & ETH_MIRROR_UPLINK_PORT)
5522 mirror_type |= IXGBE_MRCTL_UPME;
5523 if (mirror_conf->rule_type & ETH_MIRROR_DOWNLINK_PORT)
5524 mirror_type |= IXGBE_MRCTL_DPME;
5526 /* read mirror control register and recalculate it */
5527 mr_ctl = IXGBE_READ_REG(hw, IXGBE_MRCTL(rule_id));
5530 mr_ctl |= mirror_type;
5531 mr_ctl &= mirror_rule_mask;
5532 mr_ctl |= mirror_conf->dst_pool << dst_pool_offset;
5534 mr_ctl &= ~(mirror_conf->rule_type & mirror_rule_mask);
5537 mr_info->mr_conf[rule_id].rule_type = mirror_conf->rule_type;
5538 mr_info->mr_conf[rule_id].dst_pool = mirror_conf->dst_pool;
5540 /* write mirrror control register */
5541 IXGBE_WRITE_REG(hw, IXGBE_MRCTL(rule_id), mr_ctl);
5543 /* write pool mirrror control register */
5544 if (mirror_conf->rule_type & ETH_MIRROR_VIRTUAL_POOL_UP) {
5545 IXGBE_WRITE_REG(hw, IXGBE_VMRVM(rule_id), mp_lsb);
5546 IXGBE_WRITE_REG(hw, IXGBE_VMRVM(rule_id + rule_mr_offset),
5549 /* write VLAN mirrror control register */
5550 if (mirror_conf->rule_type & ETH_MIRROR_VLAN) {
5551 IXGBE_WRITE_REG(hw, IXGBE_VMRVLAN(rule_id), mv_lsb);
5552 IXGBE_WRITE_REG(hw, IXGBE_VMRVLAN(rule_id + rule_mr_offset),
5560 ixgbe_mirror_rule_reset(struct rte_eth_dev *dev, uint8_t rule_id)
5563 uint32_t lsb_val = 0;
5564 uint32_t msb_val = 0;
5565 const uint8_t rule_mr_offset = 4;
5567 struct ixgbe_hw *hw =
5568 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5569 struct ixgbe_mirror_info *mr_info =
5570 (IXGBE_DEV_PRIVATE_TO_PFDATA(dev->data->dev_private));
5572 if (ixgbe_vt_check(hw) < 0)
5575 if (rule_id >= IXGBE_MAX_MIRROR_RULES)
5578 memset(&mr_info->mr_conf[rule_id], 0,
5579 sizeof(struct rte_eth_mirror_conf));
5581 /* clear PFVMCTL register */
5582 IXGBE_WRITE_REG(hw, IXGBE_MRCTL(rule_id), mr_ctl);
5584 /* clear pool mask register */
5585 IXGBE_WRITE_REG(hw, IXGBE_VMRVM(rule_id), lsb_val);
5586 IXGBE_WRITE_REG(hw, IXGBE_VMRVM(rule_id + rule_mr_offset), msb_val);
5588 /* clear vlan mask register */
5589 IXGBE_WRITE_REG(hw, IXGBE_VMRVLAN(rule_id), lsb_val);
5590 IXGBE_WRITE_REG(hw, IXGBE_VMRVLAN(rule_id + rule_mr_offset), msb_val);
5596 ixgbevf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
5598 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
5599 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
5601 struct ixgbe_hw *hw =
5602 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5603 uint32_t vec = IXGBE_MISC_VEC_ID;
5605 mask = IXGBE_READ_REG(hw, IXGBE_VTEIMS);
5606 if (rte_intr_allow_others(intr_handle))
5607 vec = IXGBE_RX_VEC_START;
5609 RTE_SET_USED(queue_id);
5610 IXGBE_WRITE_REG(hw, IXGBE_VTEIMS, mask);
5612 rte_intr_enable(intr_handle);
5618 ixgbevf_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id)
5621 struct ixgbe_hw *hw =
5622 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5623 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
5624 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
5625 uint32_t vec = IXGBE_MISC_VEC_ID;
5627 mask = IXGBE_READ_REG(hw, IXGBE_VTEIMS);
5628 if (rte_intr_allow_others(intr_handle))
5629 vec = IXGBE_RX_VEC_START;
5630 mask &= ~(1 << vec);
5631 RTE_SET_USED(queue_id);
5632 IXGBE_WRITE_REG(hw, IXGBE_VTEIMS, mask);
5638 ixgbe_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
5640 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
5641 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
5643 struct ixgbe_hw *hw =
5644 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5645 struct ixgbe_interrupt *intr =
5646 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
5648 if (queue_id < 16) {
5649 ixgbe_disable_intr(hw);
5650 intr->mask |= (1 << queue_id);
5651 ixgbe_enable_intr(dev);
5652 } else if (queue_id < 32) {
5653 mask = IXGBE_READ_REG(hw, IXGBE_EIMS_EX(0));
5654 mask &= (1 << queue_id);
5655 IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(0), mask);
5656 } else if (queue_id < 64) {
5657 mask = IXGBE_READ_REG(hw, IXGBE_EIMS_EX(1));
5658 mask &= (1 << (queue_id - 32));
5659 IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(1), mask);
5661 rte_intr_enable(intr_handle);
5667 ixgbe_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id)
5670 struct ixgbe_hw *hw =
5671 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5672 struct ixgbe_interrupt *intr =
5673 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
5675 if (queue_id < 16) {
5676 ixgbe_disable_intr(hw);
5677 intr->mask &= ~(1 << queue_id);
5678 ixgbe_enable_intr(dev);
5679 } else if (queue_id < 32) {
5680 mask = IXGBE_READ_REG(hw, IXGBE_EIMS_EX(0));
5681 mask &= ~(1 << queue_id);
5682 IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(0), mask);
5683 } else if (queue_id < 64) {
5684 mask = IXGBE_READ_REG(hw, IXGBE_EIMS_EX(1));
5685 mask &= ~(1 << (queue_id - 32));
5686 IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(1), mask);
5693 ixgbevf_set_ivar_map(struct ixgbe_hw *hw, int8_t direction,
5694 uint8_t queue, uint8_t msix_vector)
5698 if (direction == -1) {
5700 msix_vector |= IXGBE_IVAR_ALLOC_VAL;
5701 tmp = IXGBE_READ_REG(hw, IXGBE_VTIVAR_MISC);
5704 IXGBE_WRITE_REG(hw, IXGBE_VTIVAR_MISC, tmp);
5706 /* rx or tx cause */
5707 msix_vector |= IXGBE_IVAR_ALLOC_VAL;
5708 idx = ((16 * (queue & 1)) + (8 * direction));
5709 tmp = IXGBE_READ_REG(hw, IXGBE_VTIVAR(queue >> 1));
5710 tmp &= ~(0xFF << idx);
5711 tmp |= (msix_vector << idx);
5712 IXGBE_WRITE_REG(hw, IXGBE_VTIVAR(queue >> 1), tmp);
5717 * set the IVAR registers, mapping interrupt causes to vectors
5719 * pointer to ixgbe_hw struct
5721 * 0 for Rx, 1 for Tx, -1 for other causes
5723 * queue to map the corresponding interrupt to
5725 * the vector to map to the corresponding queue
5728 ixgbe_set_ivar_map(struct ixgbe_hw *hw, int8_t direction,
5729 uint8_t queue, uint8_t msix_vector)
5733 msix_vector |= IXGBE_IVAR_ALLOC_VAL;
5734 if (hw->mac.type == ixgbe_mac_82598EB) {
5735 if (direction == -1)
5737 idx = (((direction * 64) + queue) >> 2) & 0x1F;
5738 tmp = IXGBE_READ_REG(hw, IXGBE_IVAR(idx));
5739 tmp &= ~(0xFF << (8 * (queue & 0x3)));
5740 tmp |= (msix_vector << (8 * (queue & 0x3)));
5741 IXGBE_WRITE_REG(hw, IXGBE_IVAR(idx), tmp);
5742 } else if ((hw->mac.type == ixgbe_mac_82599EB) ||
5743 (hw->mac.type == ixgbe_mac_X540) ||
5744 (hw->mac.type == ixgbe_mac_X550)) {
5745 if (direction == -1) {
5747 idx = ((queue & 1) * 8);
5748 tmp = IXGBE_READ_REG(hw, IXGBE_IVAR_MISC);
5749 tmp &= ~(0xFF << idx);
5750 tmp |= (msix_vector << idx);
5751 IXGBE_WRITE_REG(hw, IXGBE_IVAR_MISC, tmp);
5753 /* rx or tx causes */
5754 idx = ((16 * (queue & 1)) + (8 * direction));
5755 tmp = IXGBE_READ_REG(hw, IXGBE_IVAR(queue >> 1));
5756 tmp &= ~(0xFF << idx);
5757 tmp |= (msix_vector << idx);
5758 IXGBE_WRITE_REG(hw, IXGBE_IVAR(queue >> 1), tmp);
5764 ixgbevf_configure_msix(struct rte_eth_dev *dev)
5766 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
5767 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
5768 struct ixgbe_hw *hw =
5769 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5771 uint32_t vector_idx = IXGBE_MISC_VEC_ID;
5772 uint32_t base = IXGBE_MISC_VEC_ID;
5774 /* Configure VF other cause ivar */
5775 ixgbevf_set_ivar_map(hw, -1, 1, vector_idx);
5777 /* won't configure msix register if no mapping is done
5778 * between intr vector and event fd.
5780 if (!rte_intr_dp_is_en(intr_handle))
5783 if (rte_intr_allow_others(intr_handle)) {
5784 base = IXGBE_RX_VEC_START;
5785 vector_idx = IXGBE_RX_VEC_START;
5788 /* Configure all RX queues of VF */
5789 for (q_idx = 0; q_idx < dev->data->nb_rx_queues; q_idx++) {
5790 /* Force all queue use vector 0,
5791 * as IXGBE_VF_MAXMSIVECOTR = 1
5793 ixgbevf_set_ivar_map(hw, 0, q_idx, vector_idx);
5794 intr_handle->intr_vec[q_idx] = vector_idx;
5795 if (vector_idx < base + intr_handle->nb_efd - 1)
5801 * Sets up the hardware to properly generate MSI-X interrupts
5803 * board private structure
5806 ixgbe_configure_msix(struct rte_eth_dev *dev)
5808 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
5809 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
5810 struct ixgbe_hw *hw =
5811 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5812 uint32_t queue_id, base = IXGBE_MISC_VEC_ID;
5813 uint32_t vec = IXGBE_MISC_VEC_ID;
5817 /* won't configure msix register if no mapping is done
5818 * between intr vector and event fd
5820 if (!rte_intr_dp_is_en(intr_handle))
5823 if (rte_intr_allow_others(intr_handle))
5824 vec = base = IXGBE_RX_VEC_START;
5826 /* setup GPIE for MSI-x mode */
5827 gpie = IXGBE_READ_REG(hw, IXGBE_GPIE);
5828 gpie |= IXGBE_GPIE_MSIX_MODE | IXGBE_GPIE_PBA_SUPPORT |
5829 IXGBE_GPIE_OCD | IXGBE_GPIE_EIAME;
5830 /* auto clearing and auto setting corresponding bits in EIMS
5831 * when MSI-X interrupt is triggered
5833 if (hw->mac.type == ixgbe_mac_82598EB) {
5834 IXGBE_WRITE_REG(hw, IXGBE_EIAM, IXGBE_EICS_RTX_QUEUE);
5836 IXGBE_WRITE_REG(hw, IXGBE_EIAM_EX(0), 0xFFFFFFFF);
5837 IXGBE_WRITE_REG(hw, IXGBE_EIAM_EX(1), 0xFFFFFFFF);
5839 IXGBE_WRITE_REG(hw, IXGBE_GPIE, gpie);
5841 /* Populate the IVAR table and set the ITR values to the
5842 * corresponding register.
5844 for (queue_id = 0; queue_id < dev->data->nb_rx_queues;
5846 /* by default, 1:1 mapping */
5847 ixgbe_set_ivar_map(hw, 0, queue_id, vec);
5848 intr_handle->intr_vec[queue_id] = vec;
5849 if (vec < base + intr_handle->nb_efd - 1)
5853 switch (hw->mac.type) {
5854 case ixgbe_mac_82598EB:
5855 ixgbe_set_ivar_map(hw, -1, IXGBE_IVAR_OTHER_CAUSES_INDEX,
5858 case ixgbe_mac_82599EB:
5859 case ixgbe_mac_X540:
5860 case ixgbe_mac_X550:
5861 ixgbe_set_ivar_map(hw, -1, 1, IXGBE_MISC_VEC_ID);
5866 IXGBE_WRITE_REG(hw, IXGBE_EITR(IXGBE_MISC_VEC_ID),
5867 IXGBE_MIN_INTER_INTERRUPT_INTERVAL_DEFAULT & 0xFFF);
5869 /* set up to autoclear timer, and the vectors */
5870 mask = IXGBE_EIMS_ENABLE_MASK;
5871 mask &= ~(IXGBE_EIMS_OTHER |
5872 IXGBE_EIMS_MAILBOX |
5875 IXGBE_WRITE_REG(hw, IXGBE_EIAC, mask);
5879 ixgbe_set_queue_rate_limit(struct rte_eth_dev *dev,
5880 uint16_t queue_idx, uint16_t tx_rate)
5882 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5883 uint32_t rf_dec, rf_int;
5885 uint16_t link_speed = dev->data->dev_link.link_speed;
5887 if (queue_idx >= hw->mac.max_tx_queues)
5891 /* Calculate the rate factor values to set */
5892 rf_int = (uint32_t)link_speed / (uint32_t)tx_rate;
5893 rf_dec = (uint32_t)link_speed % (uint32_t)tx_rate;
5894 rf_dec = (rf_dec << IXGBE_RTTBCNRC_RF_INT_SHIFT) / tx_rate;
5896 bcnrc_val = IXGBE_RTTBCNRC_RS_ENA;
5897 bcnrc_val |= ((rf_int << IXGBE_RTTBCNRC_RF_INT_SHIFT) &
5898 IXGBE_RTTBCNRC_RF_INT_MASK_M);
5899 bcnrc_val |= (rf_dec & IXGBE_RTTBCNRC_RF_DEC_MASK);
5905 * Set global transmit compensation time to the MMW_SIZE in RTTBCNRM
5906 * register. MMW_SIZE=0x014 if 9728-byte jumbo is supported, otherwise
5909 if ((dev->data->dev_conf.rxmode.jumbo_frame == 1) &&
5910 (dev->data->dev_conf.rxmode.max_rx_pkt_len >=
5911 IXGBE_MAX_JUMBO_FRAME_SIZE))
5912 IXGBE_WRITE_REG(hw, IXGBE_RTTBCNRM,
5913 IXGBE_MMW_SIZE_JUMBO_FRAME);
5915 IXGBE_WRITE_REG(hw, IXGBE_RTTBCNRM,
5916 IXGBE_MMW_SIZE_DEFAULT);
5918 /* Set RTTBCNRC of queue X */
5919 IXGBE_WRITE_REG(hw, IXGBE_RTTDQSEL, queue_idx);
5920 IXGBE_WRITE_REG(hw, IXGBE_RTTBCNRC, bcnrc_val);
5921 IXGBE_WRITE_FLUSH(hw);
5927 ixgbevf_add_mac_addr(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
5928 __attribute__((unused)) uint32_t index,
5929 __attribute__((unused)) uint32_t pool)
5931 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5935 * On a 82599 VF, adding again the same MAC addr is not an idempotent
5936 * operation. Trap this case to avoid exhausting the [very limited]
5937 * set of PF resources used to store VF MAC addresses.
5939 if (memcmp(hw->mac.perm_addr, mac_addr, sizeof(struct ether_addr)) == 0)
5941 diag = ixgbevf_set_uc_addr_vf(hw, 2, mac_addr->addr_bytes);
5943 PMD_DRV_LOG(ERR, "Unable to add MAC address "
5944 "%02x:%02x:%02x:%02x:%02x:%02x - diag=%d",
5945 mac_addr->addr_bytes[0],
5946 mac_addr->addr_bytes[1],
5947 mac_addr->addr_bytes[2],
5948 mac_addr->addr_bytes[3],
5949 mac_addr->addr_bytes[4],
5950 mac_addr->addr_bytes[5],
5956 ixgbevf_remove_mac_addr(struct rte_eth_dev *dev, uint32_t index)
5958 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5959 struct ether_addr *perm_addr = (struct ether_addr *) hw->mac.perm_addr;
5960 struct ether_addr *mac_addr;
5965 * The IXGBE_VF_SET_MACVLAN command of the ixgbe-pf driver does
5966 * not support the deletion of a given MAC address.
5967 * Instead, it imposes to delete all MAC addresses, then to add again
5968 * all MAC addresses with the exception of the one to be deleted.
5970 (void) ixgbevf_set_uc_addr_vf(hw, 0, NULL);
5973 * Add again all MAC addresses, with the exception of the deleted one
5974 * and of the permanent MAC address.
5976 for (i = 0, mac_addr = dev->data->mac_addrs;
5977 i < hw->mac.num_rar_entries; i++, mac_addr++) {
5978 /* Skip the deleted MAC address */
5981 /* Skip NULL MAC addresses */
5982 if (is_zero_ether_addr(mac_addr))
5984 /* Skip the permanent MAC address */
5985 if (memcmp(perm_addr, mac_addr, sizeof(struct ether_addr)) == 0)
5987 diag = ixgbevf_set_uc_addr_vf(hw, 2, mac_addr->addr_bytes);
5990 "Adding again MAC address "
5991 "%02x:%02x:%02x:%02x:%02x:%02x failed "
5993 mac_addr->addr_bytes[0],
5994 mac_addr->addr_bytes[1],
5995 mac_addr->addr_bytes[2],
5996 mac_addr->addr_bytes[3],
5997 mac_addr->addr_bytes[4],
5998 mac_addr->addr_bytes[5],
6004 ixgbevf_set_default_mac_addr(struct rte_eth_dev *dev, struct ether_addr *addr)
6006 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6008 hw->mac.ops.set_rar(hw, 0, (void *)addr, 0, 0);
6012 ixgbe_syn_filter_set(struct rte_eth_dev *dev,
6013 struct rte_eth_syn_filter *filter,
6016 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6017 struct ixgbe_filter_info *filter_info =
6018 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6022 if (filter->queue >= IXGBE_MAX_RX_QUEUE_NUM)
6025 syn_info = filter_info->syn_info;
6028 if (syn_info & IXGBE_SYN_FILTER_ENABLE)
6030 synqf = (uint32_t)(((filter->queue << IXGBE_SYN_FILTER_QUEUE_SHIFT) &
6031 IXGBE_SYN_FILTER_QUEUE) | IXGBE_SYN_FILTER_ENABLE);
6033 if (filter->hig_pri)
6034 synqf |= IXGBE_SYN_FILTER_SYNQFP;
6036 synqf &= ~IXGBE_SYN_FILTER_SYNQFP;
6038 synqf = IXGBE_READ_REG(hw, IXGBE_SYNQF);
6039 if (!(syn_info & IXGBE_SYN_FILTER_ENABLE))
6041 synqf &= ~(IXGBE_SYN_FILTER_QUEUE | IXGBE_SYN_FILTER_ENABLE);
6044 filter_info->syn_info = synqf;
6045 IXGBE_WRITE_REG(hw, IXGBE_SYNQF, synqf);
6046 IXGBE_WRITE_FLUSH(hw);
6051 ixgbe_syn_filter_get(struct rte_eth_dev *dev,
6052 struct rte_eth_syn_filter *filter)
6054 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6055 uint32_t synqf = IXGBE_READ_REG(hw, IXGBE_SYNQF);
6057 if (synqf & IXGBE_SYN_FILTER_ENABLE) {
6058 filter->hig_pri = (synqf & IXGBE_SYN_FILTER_SYNQFP) ? 1 : 0;
6059 filter->queue = (uint16_t)((synqf & IXGBE_SYN_FILTER_QUEUE) >> 1);
6066 ixgbe_syn_filter_handle(struct rte_eth_dev *dev,
6067 enum rte_filter_op filter_op,
6070 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6073 MAC_TYPE_FILTER_SUP(hw->mac.type);
6075 if (filter_op == RTE_ETH_FILTER_NOP)
6079 PMD_DRV_LOG(ERR, "arg shouldn't be NULL for operation %u",
6084 switch (filter_op) {
6085 case RTE_ETH_FILTER_ADD:
6086 ret = ixgbe_syn_filter_set(dev,
6087 (struct rte_eth_syn_filter *)arg,
6090 case RTE_ETH_FILTER_DELETE:
6091 ret = ixgbe_syn_filter_set(dev,
6092 (struct rte_eth_syn_filter *)arg,
6095 case RTE_ETH_FILTER_GET:
6096 ret = ixgbe_syn_filter_get(dev,
6097 (struct rte_eth_syn_filter *)arg);
6100 PMD_DRV_LOG(ERR, "unsupported operation %u", filter_op);
6109 static inline enum ixgbe_5tuple_protocol
6110 convert_protocol_type(uint8_t protocol_value)
6112 if (protocol_value == IPPROTO_TCP)
6113 return IXGBE_FILTER_PROTOCOL_TCP;
6114 else if (protocol_value == IPPROTO_UDP)
6115 return IXGBE_FILTER_PROTOCOL_UDP;
6116 else if (protocol_value == IPPROTO_SCTP)
6117 return IXGBE_FILTER_PROTOCOL_SCTP;
6119 return IXGBE_FILTER_PROTOCOL_NONE;
6122 /* inject a 5-tuple filter to HW */
6124 ixgbe_inject_5tuple_filter(struct rte_eth_dev *dev,
6125 struct ixgbe_5tuple_filter *filter)
6127 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6129 uint32_t ftqf, sdpqf;
6130 uint32_t l34timir = 0;
6131 uint8_t mask = 0xff;
6135 sdpqf = (uint32_t)(filter->filter_info.dst_port <<
6136 IXGBE_SDPQF_DSTPORT_SHIFT);
6137 sdpqf = sdpqf | (filter->filter_info.src_port & IXGBE_SDPQF_SRCPORT);
6139 ftqf = (uint32_t)(filter->filter_info.proto &
6140 IXGBE_FTQF_PROTOCOL_MASK);
6141 ftqf |= (uint32_t)((filter->filter_info.priority &
6142 IXGBE_FTQF_PRIORITY_MASK) << IXGBE_FTQF_PRIORITY_SHIFT);
6143 if (filter->filter_info.src_ip_mask == 0) /* 0 means compare. */
6144 mask &= IXGBE_FTQF_SOURCE_ADDR_MASK;
6145 if (filter->filter_info.dst_ip_mask == 0)
6146 mask &= IXGBE_FTQF_DEST_ADDR_MASK;
6147 if (filter->filter_info.src_port_mask == 0)
6148 mask &= IXGBE_FTQF_SOURCE_PORT_MASK;
6149 if (filter->filter_info.dst_port_mask == 0)
6150 mask &= IXGBE_FTQF_DEST_PORT_MASK;
6151 if (filter->filter_info.proto_mask == 0)
6152 mask &= IXGBE_FTQF_PROTOCOL_COMP_MASK;
6153 ftqf |= mask << IXGBE_FTQF_5TUPLE_MASK_SHIFT;
6154 ftqf |= IXGBE_FTQF_POOL_MASK_EN;
6155 ftqf |= IXGBE_FTQF_QUEUE_ENABLE;
6157 IXGBE_WRITE_REG(hw, IXGBE_DAQF(i), filter->filter_info.dst_ip);
6158 IXGBE_WRITE_REG(hw, IXGBE_SAQF(i), filter->filter_info.src_ip);
6159 IXGBE_WRITE_REG(hw, IXGBE_SDPQF(i), sdpqf);
6160 IXGBE_WRITE_REG(hw, IXGBE_FTQF(i), ftqf);
6162 l34timir |= IXGBE_L34T_IMIR_RESERVE;
6163 l34timir |= (uint32_t)(filter->queue <<
6164 IXGBE_L34T_IMIR_QUEUE_SHIFT);
6165 IXGBE_WRITE_REG(hw, IXGBE_L34T_IMIR(i), l34timir);
6169 * add a 5tuple filter
6172 * dev: Pointer to struct rte_eth_dev.
6173 * index: the index the filter allocates.
6174 * filter: ponter to the filter that will be added.
6175 * rx_queue: the queue id the filter assigned to.
6178 * - On success, zero.
6179 * - On failure, a negative value.
6182 ixgbe_add_5tuple_filter(struct rte_eth_dev *dev,
6183 struct ixgbe_5tuple_filter *filter)
6185 struct ixgbe_filter_info *filter_info =
6186 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6190 * look for an unused 5tuple filter index,
6191 * and insert the filter to list.
6193 for (i = 0; i < IXGBE_MAX_FTQF_FILTERS; i++) {
6194 idx = i / (sizeof(uint32_t) * NBBY);
6195 shift = i % (sizeof(uint32_t) * NBBY);
6196 if (!(filter_info->fivetuple_mask[idx] & (1 << shift))) {
6197 filter_info->fivetuple_mask[idx] |= 1 << shift;
6199 TAILQ_INSERT_TAIL(&filter_info->fivetuple_list,
6205 if (i >= IXGBE_MAX_FTQF_FILTERS) {
6206 PMD_DRV_LOG(ERR, "5tuple filters are full.");
6210 ixgbe_inject_5tuple_filter(dev, filter);
6216 * remove a 5tuple filter
6219 * dev: Pointer to struct rte_eth_dev.
6220 * filter: the pointer of the filter will be removed.
6223 ixgbe_remove_5tuple_filter(struct rte_eth_dev *dev,
6224 struct ixgbe_5tuple_filter *filter)
6226 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6227 struct ixgbe_filter_info *filter_info =
6228 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6229 uint16_t index = filter->index;
6231 filter_info->fivetuple_mask[index / (sizeof(uint32_t) * NBBY)] &=
6232 ~(1 << (index % (sizeof(uint32_t) * NBBY)));
6233 TAILQ_REMOVE(&filter_info->fivetuple_list, filter, entries);
6236 IXGBE_WRITE_REG(hw, IXGBE_DAQF(index), 0);
6237 IXGBE_WRITE_REG(hw, IXGBE_SAQF(index), 0);
6238 IXGBE_WRITE_REG(hw, IXGBE_SDPQF(index), 0);
6239 IXGBE_WRITE_REG(hw, IXGBE_FTQF(index), 0);
6240 IXGBE_WRITE_REG(hw, IXGBE_L34T_IMIR(index), 0);
6244 ixgbevf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
6246 struct ixgbe_hw *hw;
6247 uint32_t max_frame = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
6248 struct rte_eth_rxmode *rx_conf = &dev->data->dev_conf.rxmode;
6250 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6252 if ((mtu < ETHER_MIN_MTU) || (max_frame > ETHER_MAX_JUMBO_FRAME_LEN))
6255 /* refuse mtu that requires the support of scattered packets when this
6256 * feature has not been enabled before.
6258 if (!rx_conf->enable_scatter &&
6259 (max_frame + 2 * IXGBE_VLAN_TAG_SIZE >
6260 dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM))
6264 * When supported by the underlying PF driver, use the IXGBE_VF_SET_MTU
6265 * request of the version 2.0 of the mailbox API.
6266 * For now, use the IXGBE_VF_SET_LPE request of the version 1.0
6267 * of the mailbox API.
6268 * This call to IXGBE_SET_LPE action won't work with ixgbe pf drivers
6269 * prior to 3.11.33 which contains the following change:
6270 * "ixgbe: Enable jumbo frames support w/ SR-IOV"
6272 ixgbevf_rlpml_set_vf(hw, max_frame);
6274 /* update max frame size */
6275 dev->data->dev_conf.rxmode.max_rx_pkt_len = max_frame;
6279 static inline struct ixgbe_5tuple_filter *
6280 ixgbe_5tuple_filter_lookup(struct ixgbe_5tuple_filter_list *filter_list,
6281 struct ixgbe_5tuple_filter_info *key)
6283 struct ixgbe_5tuple_filter *it;
6285 TAILQ_FOREACH(it, filter_list, entries) {
6286 if (memcmp(key, &it->filter_info,
6287 sizeof(struct ixgbe_5tuple_filter_info)) == 0) {
6294 /* translate elements in struct rte_eth_ntuple_filter to struct ixgbe_5tuple_filter_info*/
6296 ntuple_filter_to_5tuple(struct rte_eth_ntuple_filter *filter,
6297 struct ixgbe_5tuple_filter_info *filter_info)
6299 if (filter->queue >= IXGBE_MAX_RX_QUEUE_NUM ||
6300 filter->priority > IXGBE_5TUPLE_MAX_PRI ||
6301 filter->priority < IXGBE_5TUPLE_MIN_PRI)
6304 switch (filter->dst_ip_mask) {
6306 filter_info->dst_ip_mask = 0;
6307 filter_info->dst_ip = filter->dst_ip;
6310 filter_info->dst_ip_mask = 1;
6313 PMD_DRV_LOG(ERR, "invalid dst_ip mask.");
6317 switch (filter->src_ip_mask) {
6319 filter_info->src_ip_mask = 0;
6320 filter_info->src_ip = filter->src_ip;
6323 filter_info->src_ip_mask = 1;
6326 PMD_DRV_LOG(ERR, "invalid src_ip mask.");
6330 switch (filter->dst_port_mask) {
6332 filter_info->dst_port_mask = 0;
6333 filter_info->dst_port = filter->dst_port;
6336 filter_info->dst_port_mask = 1;
6339 PMD_DRV_LOG(ERR, "invalid dst_port mask.");
6343 switch (filter->src_port_mask) {
6345 filter_info->src_port_mask = 0;
6346 filter_info->src_port = filter->src_port;
6349 filter_info->src_port_mask = 1;
6352 PMD_DRV_LOG(ERR, "invalid src_port mask.");
6356 switch (filter->proto_mask) {
6358 filter_info->proto_mask = 0;
6359 filter_info->proto =
6360 convert_protocol_type(filter->proto);
6363 filter_info->proto_mask = 1;
6366 PMD_DRV_LOG(ERR, "invalid protocol mask.");
6370 filter_info->priority = (uint8_t)filter->priority;
6375 * add or delete a ntuple filter
6378 * dev: Pointer to struct rte_eth_dev.
6379 * ntuple_filter: Pointer to struct rte_eth_ntuple_filter
6380 * add: if true, add filter, if false, remove filter
6383 * - On success, zero.
6384 * - On failure, a negative value.
6387 ixgbe_add_del_ntuple_filter(struct rte_eth_dev *dev,
6388 struct rte_eth_ntuple_filter *ntuple_filter,
6391 struct ixgbe_filter_info *filter_info =
6392 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6393 struct ixgbe_5tuple_filter_info filter_5tuple;
6394 struct ixgbe_5tuple_filter *filter;
6397 if (ntuple_filter->flags != RTE_5TUPLE_FLAGS) {
6398 PMD_DRV_LOG(ERR, "only 5tuple is supported.");
6402 memset(&filter_5tuple, 0, sizeof(struct ixgbe_5tuple_filter_info));
6403 ret = ntuple_filter_to_5tuple(ntuple_filter, &filter_5tuple);
6407 filter = ixgbe_5tuple_filter_lookup(&filter_info->fivetuple_list,
6409 if (filter != NULL && add) {
6410 PMD_DRV_LOG(ERR, "filter exists.");
6413 if (filter == NULL && !add) {
6414 PMD_DRV_LOG(ERR, "filter doesn't exist.");
6419 filter = rte_zmalloc("ixgbe_5tuple_filter",
6420 sizeof(struct ixgbe_5tuple_filter), 0);
6423 rte_memcpy(&filter->filter_info,
6425 sizeof(struct ixgbe_5tuple_filter_info));
6426 filter->queue = ntuple_filter->queue;
6427 ret = ixgbe_add_5tuple_filter(dev, filter);
6433 ixgbe_remove_5tuple_filter(dev, filter);
6439 * get a ntuple filter
6442 * dev: Pointer to struct rte_eth_dev.
6443 * ntuple_filter: Pointer to struct rte_eth_ntuple_filter
6446 * - On success, zero.
6447 * - On failure, a negative value.
6450 ixgbe_get_ntuple_filter(struct rte_eth_dev *dev,
6451 struct rte_eth_ntuple_filter *ntuple_filter)
6453 struct ixgbe_filter_info *filter_info =
6454 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6455 struct ixgbe_5tuple_filter_info filter_5tuple;
6456 struct ixgbe_5tuple_filter *filter;
6459 if (ntuple_filter->flags != RTE_5TUPLE_FLAGS) {
6460 PMD_DRV_LOG(ERR, "only 5tuple is supported.");
6464 memset(&filter_5tuple, 0, sizeof(struct ixgbe_5tuple_filter_info));
6465 ret = ntuple_filter_to_5tuple(ntuple_filter, &filter_5tuple);
6469 filter = ixgbe_5tuple_filter_lookup(&filter_info->fivetuple_list,
6471 if (filter == NULL) {
6472 PMD_DRV_LOG(ERR, "filter doesn't exist.");
6475 ntuple_filter->queue = filter->queue;
6480 * ixgbe_ntuple_filter_handle - Handle operations for ntuple filter.
6481 * @dev: pointer to rte_eth_dev structure
6482 * @filter_op:operation will be taken.
6483 * @arg: a pointer to specific structure corresponding to the filter_op
6486 * - On success, zero.
6487 * - On failure, a negative value.
6490 ixgbe_ntuple_filter_handle(struct rte_eth_dev *dev,
6491 enum rte_filter_op filter_op,
6494 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6497 MAC_TYPE_FILTER_SUP_EXT(hw->mac.type);
6499 if (filter_op == RTE_ETH_FILTER_NOP)
6503 PMD_DRV_LOG(ERR, "arg shouldn't be NULL for operation %u.",
6508 switch (filter_op) {
6509 case RTE_ETH_FILTER_ADD:
6510 ret = ixgbe_add_del_ntuple_filter(dev,
6511 (struct rte_eth_ntuple_filter *)arg,
6514 case RTE_ETH_FILTER_DELETE:
6515 ret = ixgbe_add_del_ntuple_filter(dev,
6516 (struct rte_eth_ntuple_filter *)arg,
6519 case RTE_ETH_FILTER_GET:
6520 ret = ixgbe_get_ntuple_filter(dev,
6521 (struct rte_eth_ntuple_filter *)arg);
6524 PMD_DRV_LOG(ERR, "unsupported operation %u.", filter_op);
6532 ixgbe_add_del_ethertype_filter(struct rte_eth_dev *dev,
6533 struct rte_eth_ethertype_filter *filter,
6536 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6537 struct ixgbe_filter_info *filter_info =
6538 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6542 struct ixgbe_ethertype_filter ethertype_filter;
6544 if (filter->queue >= IXGBE_MAX_RX_QUEUE_NUM)
6547 if (filter->ether_type == ETHER_TYPE_IPv4 ||
6548 filter->ether_type == ETHER_TYPE_IPv6) {
6549 PMD_DRV_LOG(ERR, "unsupported ether_type(0x%04x) in"
6550 " ethertype filter.", filter->ether_type);
6554 if (filter->flags & RTE_ETHTYPE_FLAGS_MAC) {
6555 PMD_DRV_LOG(ERR, "mac compare is unsupported.");
6558 if (filter->flags & RTE_ETHTYPE_FLAGS_DROP) {
6559 PMD_DRV_LOG(ERR, "drop option is unsupported.");
6563 ret = ixgbe_ethertype_filter_lookup(filter_info, filter->ether_type);
6564 if (ret >= 0 && add) {
6565 PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter exists.",
6566 filter->ether_type);
6569 if (ret < 0 && !add) {
6570 PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter doesn't exist.",
6571 filter->ether_type);
6576 etqf = IXGBE_ETQF_FILTER_EN;
6577 etqf |= (uint32_t)filter->ether_type;
6578 etqs |= (uint32_t)((filter->queue <<
6579 IXGBE_ETQS_RX_QUEUE_SHIFT) &
6580 IXGBE_ETQS_RX_QUEUE);
6581 etqs |= IXGBE_ETQS_QUEUE_EN;
6583 ethertype_filter.ethertype = filter->ether_type;
6584 ethertype_filter.etqf = etqf;
6585 ethertype_filter.etqs = etqs;
6586 ethertype_filter.conf = FALSE;
6587 ret = ixgbe_ethertype_filter_insert(filter_info,
6590 PMD_DRV_LOG(ERR, "ethertype filters are full.");
6594 ret = ixgbe_ethertype_filter_remove(filter_info, (uint8_t)ret);
6598 IXGBE_WRITE_REG(hw, IXGBE_ETQF(ret), etqf);
6599 IXGBE_WRITE_REG(hw, IXGBE_ETQS(ret), etqs);
6600 IXGBE_WRITE_FLUSH(hw);
6606 ixgbe_get_ethertype_filter(struct rte_eth_dev *dev,
6607 struct rte_eth_ethertype_filter *filter)
6609 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6610 struct ixgbe_filter_info *filter_info =
6611 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6612 uint32_t etqf, etqs;
6615 ret = ixgbe_ethertype_filter_lookup(filter_info, filter->ether_type);
6617 PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter doesn't exist.",
6618 filter->ether_type);
6622 etqf = IXGBE_READ_REG(hw, IXGBE_ETQF(ret));
6623 if (etqf & IXGBE_ETQF_FILTER_EN) {
6624 etqs = IXGBE_READ_REG(hw, IXGBE_ETQS(ret));
6625 filter->ether_type = etqf & IXGBE_ETQF_ETHERTYPE;
6627 filter->queue = (etqs & IXGBE_ETQS_RX_QUEUE) >>
6628 IXGBE_ETQS_RX_QUEUE_SHIFT;
6635 * ixgbe_ethertype_filter_handle - Handle operations for ethertype filter.
6636 * @dev: pointer to rte_eth_dev structure
6637 * @filter_op:operation will be taken.
6638 * @arg: a pointer to specific structure corresponding to the filter_op
6641 ixgbe_ethertype_filter_handle(struct rte_eth_dev *dev,
6642 enum rte_filter_op filter_op,
6645 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6648 MAC_TYPE_FILTER_SUP(hw->mac.type);
6650 if (filter_op == RTE_ETH_FILTER_NOP)
6654 PMD_DRV_LOG(ERR, "arg shouldn't be NULL for operation %u.",
6659 switch (filter_op) {
6660 case RTE_ETH_FILTER_ADD:
6661 ret = ixgbe_add_del_ethertype_filter(dev,
6662 (struct rte_eth_ethertype_filter *)arg,
6665 case RTE_ETH_FILTER_DELETE:
6666 ret = ixgbe_add_del_ethertype_filter(dev,
6667 (struct rte_eth_ethertype_filter *)arg,
6670 case RTE_ETH_FILTER_GET:
6671 ret = ixgbe_get_ethertype_filter(dev,
6672 (struct rte_eth_ethertype_filter *)arg);
6675 PMD_DRV_LOG(ERR, "unsupported operation %u.", filter_op);
6683 ixgbe_dev_filter_ctrl(struct rte_eth_dev *dev,
6684 enum rte_filter_type filter_type,
6685 enum rte_filter_op filter_op,
6690 switch (filter_type) {
6691 case RTE_ETH_FILTER_NTUPLE:
6692 ret = ixgbe_ntuple_filter_handle(dev, filter_op, arg);
6694 case RTE_ETH_FILTER_ETHERTYPE:
6695 ret = ixgbe_ethertype_filter_handle(dev, filter_op, arg);
6697 case RTE_ETH_FILTER_SYN:
6698 ret = ixgbe_syn_filter_handle(dev, filter_op, arg);
6700 case RTE_ETH_FILTER_FDIR:
6701 ret = ixgbe_fdir_ctrl_func(dev, filter_op, arg);
6703 case RTE_ETH_FILTER_L2_TUNNEL:
6704 ret = ixgbe_dev_l2_tunnel_filter_handle(dev, filter_op, arg);
6706 case RTE_ETH_FILTER_GENERIC:
6707 if (filter_op != RTE_ETH_FILTER_GET)
6709 *(const void **)arg = &ixgbe_flow_ops;
6712 PMD_DRV_LOG(WARNING, "Filter type (%d) not supported",
6722 ixgbe_dev_addr_list_itr(__attribute__((unused)) struct ixgbe_hw *hw,
6723 u8 **mc_addr_ptr, u32 *vmdq)
6728 mc_addr = *mc_addr_ptr;
6729 *mc_addr_ptr = (mc_addr + sizeof(struct ether_addr));
6734 ixgbe_dev_set_mc_addr_list(struct rte_eth_dev *dev,
6735 struct ether_addr *mc_addr_set,
6736 uint32_t nb_mc_addr)
6738 struct ixgbe_hw *hw;
6741 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6742 mc_addr_list = (u8 *)mc_addr_set;
6743 return ixgbe_update_mc_addr_list(hw, mc_addr_list, nb_mc_addr,
6744 ixgbe_dev_addr_list_itr, TRUE);
6748 ixgbe_read_systime_cyclecounter(struct rte_eth_dev *dev)
6750 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6751 uint64_t systime_cycles;
6753 switch (hw->mac.type) {
6754 case ixgbe_mac_X550:
6755 case ixgbe_mac_X550EM_x:
6756 case ixgbe_mac_X550EM_a:
6757 /* SYSTIMEL stores ns and SYSTIMEH stores seconds. */
6758 systime_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_SYSTIML);
6759 systime_cycles += (uint64_t)IXGBE_READ_REG(hw, IXGBE_SYSTIMH)
6763 systime_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_SYSTIML);
6764 systime_cycles |= (uint64_t)IXGBE_READ_REG(hw, IXGBE_SYSTIMH)
6768 return systime_cycles;
6772 ixgbe_read_rx_tstamp_cyclecounter(struct rte_eth_dev *dev)
6774 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6775 uint64_t rx_tstamp_cycles;
6777 switch (hw->mac.type) {
6778 case ixgbe_mac_X550:
6779 case ixgbe_mac_X550EM_x:
6780 case ixgbe_mac_X550EM_a:
6781 /* RXSTMPL stores ns and RXSTMPH stores seconds. */
6782 rx_tstamp_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_RXSTMPL);
6783 rx_tstamp_cycles += (uint64_t)IXGBE_READ_REG(hw, IXGBE_RXSTMPH)
6787 /* RXSTMPL stores ns and RXSTMPH stores seconds. */
6788 rx_tstamp_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_RXSTMPL);
6789 rx_tstamp_cycles |= (uint64_t)IXGBE_READ_REG(hw, IXGBE_RXSTMPH)
6793 return rx_tstamp_cycles;
6797 ixgbe_read_tx_tstamp_cyclecounter(struct rte_eth_dev *dev)
6799 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6800 uint64_t tx_tstamp_cycles;
6802 switch (hw->mac.type) {
6803 case ixgbe_mac_X550:
6804 case ixgbe_mac_X550EM_x:
6805 case ixgbe_mac_X550EM_a:
6806 /* TXSTMPL stores ns and TXSTMPH stores seconds. */
6807 tx_tstamp_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_TXSTMPL);
6808 tx_tstamp_cycles += (uint64_t)IXGBE_READ_REG(hw, IXGBE_TXSTMPH)
6812 /* TXSTMPL stores ns and TXSTMPH stores seconds. */
6813 tx_tstamp_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_TXSTMPL);
6814 tx_tstamp_cycles |= (uint64_t)IXGBE_READ_REG(hw, IXGBE_TXSTMPH)
6818 return tx_tstamp_cycles;
6822 ixgbe_start_timecounters(struct rte_eth_dev *dev)
6824 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6825 struct ixgbe_adapter *adapter =
6826 (struct ixgbe_adapter *)dev->data->dev_private;
6827 struct rte_eth_link link;
6828 uint32_t incval = 0;
6831 /* Get current link speed. */
6832 memset(&link, 0, sizeof(link));
6833 ixgbe_dev_link_update(dev, 1);
6834 rte_ixgbe_dev_atomic_read_link_status(dev, &link);
6836 switch (link.link_speed) {
6837 case ETH_SPEED_NUM_100M:
6838 incval = IXGBE_INCVAL_100;
6839 shift = IXGBE_INCVAL_SHIFT_100;
6841 case ETH_SPEED_NUM_1G:
6842 incval = IXGBE_INCVAL_1GB;
6843 shift = IXGBE_INCVAL_SHIFT_1GB;
6845 case ETH_SPEED_NUM_10G:
6847 incval = IXGBE_INCVAL_10GB;
6848 shift = IXGBE_INCVAL_SHIFT_10GB;
6852 switch (hw->mac.type) {
6853 case ixgbe_mac_X550:
6854 case ixgbe_mac_X550EM_x:
6855 case ixgbe_mac_X550EM_a:
6856 /* Independent of link speed. */
6858 /* Cycles read will be interpreted as ns. */
6861 case ixgbe_mac_X540:
6862 IXGBE_WRITE_REG(hw, IXGBE_TIMINCA, incval);
6864 case ixgbe_mac_82599EB:
6865 incval >>= IXGBE_INCVAL_SHIFT_82599;
6866 shift -= IXGBE_INCVAL_SHIFT_82599;
6867 IXGBE_WRITE_REG(hw, IXGBE_TIMINCA,
6868 (1 << IXGBE_INCPER_SHIFT_82599) | incval);
6871 /* Not supported. */
6875 memset(&adapter->systime_tc, 0, sizeof(struct rte_timecounter));
6876 memset(&adapter->rx_tstamp_tc, 0, sizeof(struct rte_timecounter));
6877 memset(&adapter->tx_tstamp_tc, 0, sizeof(struct rte_timecounter));
6879 adapter->systime_tc.cc_mask = IXGBE_CYCLECOUNTER_MASK;
6880 adapter->systime_tc.cc_shift = shift;
6881 adapter->systime_tc.nsec_mask = (1ULL << shift) - 1;
6883 adapter->rx_tstamp_tc.cc_mask = IXGBE_CYCLECOUNTER_MASK;
6884 adapter->rx_tstamp_tc.cc_shift = shift;
6885 adapter->rx_tstamp_tc.nsec_mask = (1ULL << shift) - 1;
6887 adapter->tx_tstamp_tc.cc_mask = IXGBE_CYCLECOUNTER_MASK;
6888 adapter->tx_tstamp_tc.cc_shift = shift;
6889 adapter->tx_tstamp_tc.nsec_mask = (1ULL << shift) - 1;
6893 ixgbe_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta)
6895 struct ixgbe_adapter *adapter =
6896 (struct ixgbe_adapter *)dev->data->dev_private;
6898 adapter->systime_tc.nsec += delta;
6899 adapter->rx_tstamp_tc.nsec += delta;
6900 adapter->tx_tstamp_tc.nsec += delta;
6906 ixgbe_timesync_write_time(struct rte_eth_dev *dev, const struct timespec *ts)
6909 struct ixgbe_adapter *adapter =
6910 (struct ixgbe_adapter *)dev->data->dev_private;
6912 ns = rte_timespec_to_ns(ts);
6913 /* Set the timecounters to a new value. */
6914 adapter->systime_tc.nsec = ns;
6915 adapter->rx_tstamp_tc.nsec = ns;
6916 adapter->tx_tstamp_tc.nsec = ns;
6922 ixgbe_timesync_read_time(struct rte_eth_dev *dev, struct timespec *ts)
6924 uint64_t ns, systime_cycles;
6925 struct ixgbe_adapter *adapter =
6926 (struct ixgbe_adapter *)dev->data->dev_private;
6928 systime_cycles = ixgbe_read_systime_cyclecounter(dev);
6929 ns = rte_timecounter_update(&adapter->systime_tc, systime_cycles);
6930 *ts = rte_ns_to_timespec(ns);
6936 ixgbe_timesync_enable(struct rte_eth_dev *dev)
6938 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6942 /* Stop the timesync system time. */
6943 IXGBE_WRITE_REG(hw, IXGBE_TIMINCA, 0x0);
6944 /* Reset the timesync system time value. */
6945 IXGBE_WRITE_REG(hw, IXGBE_SYSTIML, 0x0);
6946 IXGBE_WRITE_REG(hw, IXGBE_SYSTIMH, 0x0);
6948 /* Enable system time for platforms where it isn't on by default. */
6949 tsauxc = IXGBE_READ_REG(hw, IXGBE_TSAUXC);
6950 tsauxc &= ~IXGBE_TSAUXC_DISABLE_SYSTIME;
6951 IXGBE_WRITE_REG(hw, IXGBE_TSAUXC, tsauxc);
6953 ixgbe_start_timecounters(dev);
6955 /* Enable L2 filtering of IEEE1588/802.1AS Ethernet frame types. */
6956 IXGBE_WRITE_REG(hw, IXGBE_ETQF(IXGBE_ETQF_FILTER_1588),
6958 IXGBE_ETQF_FILTER_EN |
6961 /* Enable timestamping of received PTP packets. */
6962 tsync_ctl = IXGBE_READ_REG(hw, IXGBE_TSYNCRXCTL);
6963 tsync_ctl |= IXGBE_TSYNCRXCTL_ENABLED;
6964 IXGBE_WRITE_REG(hw, IXGBE_TSYNCRXCTL, tsync_ctl);
6966 /* Enable timestamping of transmitted PTP packets. */
6967 tsync_ctl = IXGBE_READ_REG(hw, IXGBE_TSYNCTXCTL);
6968 tsync_ctl |= IXGBE_TSYNCTXCTL_ENABLED;
6969 IXGBE_WRITE_REG(hw, IXGBE_TSYNCTXCTL, tsync_ctl);
6971 IXGBE_WRITE_FLUSH(hw);
6977 ixgbe_timesync_disable(struct rte_eth_dev *dev)
6979 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6982 /* Disable timestamping of transmitted PTP packets. */
6983 tsync_ctl = IXGBE_READ_REG(hw, IXGBE_TSYNCTXCTL);
6984 tsync_ctl &= ~IXGBE_TSYNCTXCTL_ENABLED;
6985 IXGBE_WRITE_REG(hw, IXGBE_TSYNCTXCTL, tsync_ctl);
6987 /* Disable timestamping of received PTP packets. */
6988 tsync_ctl = IXGBE_READ_REG(hw, IXGBE_TSYNCRXCTL);
6989 tsync_ctl &= ~IXGBE_TSYNCRXCTL_ENABLED;
6990 IXGBE_WRITE_REG(hw, IXGBE_TSYNCRXCTL, tsync_ctl);
6992 /* Disable L2 filtering of IEEE1588/802.1AS Ethernet frame types. */
6993 IXGBE_WRITE_REG(hw, IXGBE_ETQF(IXGBE_ETQF_FILTER_1588), 0);
6995 /* Stop incrementating the System Time registers. */
6996 IXGBE_WRITE_REG(hw, IXGBE_TIMINCA, 0);
7002 ixgbe_timesync_read_rx_timestamp(struct rte_eth_dev *dev,
7003 struct timespec *timestamp,
7004 uint32_t flags __rte_unused)
7006 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7007 struct ixgbe_adapter *adapter =
7008 (struct ixgbe_adapter *)dev->data->dev_private;
7009 uint32_t tsync_rxctl;
7010 uint64_t rx_tstamp_cycles;
7013 tsync_rxctl = IXGBE_READ_REG(hw, IXGBE_TSYNCRXCTL);
7014 if ((tsync_rxctl & IXGBE_TSYNCRXCTL_VALID) == 0)
7017 rx_tstamp_cycles = ixgbe_read_rx_tstamp_cyclecounter(dev);
7018 ns = rte_timecounter_update(&adapter->rx_tstamp_tc, rx_tstamp_cycles);
7019 *timestamp = rte_ns_to_timespec(ns);
7025 ixgbe_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
7026 struct timespec *timestamp)
7028 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7029 struct ixgbe_adapter *adapter =
7030 (struct ixgbe_adapter *)dev->data->dev_private;
7031 uint32_t tsync_txctl;
7032 uint64_t tx_tstamp_cycles;
7035 tsync_txctl = IXGBE_READ_REG(hw, IXGBE_TSYNCTXCTL);
7036 if ((tsync_txctl & IXGBE_TSYNCTXCTL_VALID) == 0)
7039 tx_tstamp_cycles = ixgbe_read_tx_tstamp_cyclecounter(dev);
7040 ns = rte_timecounter_update(&adapter->tx_tstamp_tc, tx_tstamp_cycles);
7041 *timestamp = rte_ns_to_timespec(ns);
7047 ixgbe_get_reg_length(struct rte_eth_dev *dev)
7049 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7052 const struct reg_info *reg_group;
7053 const struct reg_info **reg_set = (hw->mac.type == ixgbe_mac_82598EB) ?
7054 ixgbe_regs_mac_82598EB : ixgbe_regs_others;
7056 while ((reg_group = reg_set[g_ind++]))
7057 count += ixgbe_regs_group_count(reg_group);
7063 ixgbevf_get_reg_length(struct rte_eth_dev *dev __rte_unused)
7067 const struct reg_info *reg_group;
7069 while ((reg_group = ixgbevf_regs[g_ind++]))
7070 count += ixgbe_regs_group_count(reg_group);
7076 ixgbe_get_regs(struct rte_eth_dev *dev,
7077 struct rte_dev_reg_info *regs)
7079 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7080 uint32_t *data = regs->data;
7083 const struct reg_info *reg_group;
7084 const struct reg_info **reg_set = (hw->mac.type == ixgbe_mac_82598EB) ?
7085 ixgbe_regs_mac_82598EB : ixgbe_regs_others;
7088 regs->length = ixgbe_get_reg_length(dev);
7089 regs->width = sizeof(uint32_t);
7093 /* Support only full register dump */
7094 if ((regs->length == 0) ||
7095 (regs->length == (uint32_t)ixgbe_get_reg_length(dev))) {
7096 regs->version = hw->mac.type << 24 | hw->revision_id << 16 |
7098 while ((reg_group = reg_set[g_ind++]))
7099 count += ixgbe_read_regs_group(dev, &data[count],
7108 ixgbevf_get_regs(struct rte_eth_dev *dev,
7109 struct rte_dev_reg_info *regs)
7111 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7112 uint32_t *data = regs->data;
7115 const struct reg_info *reg_group;
7118 regs->length = ixgbevf_get_reg_length(dev);
7119 regs->width = sizeof(uint32_t);
7123 /* Support only full register dump */
7124 if ((regs->length == 0) ||
7125 (regs->length == (uint32_t)ixgbevf_get_reg_length(dev))) {
7126 regs->version = hw->mac.type << 24 | hw->revision_id << 16 |
7128 while ((reg_group = ixgbevf_regs[g_ind++]))
7129 count += ixgbe_read_regs_group(dev, &data[count],
7138 ixgbe_get_eeprom_length(struct rte_eth_dev *dev)
7140 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7142 /* Return unit is byte count */
7143 return hw->eeprom.word_size * 2;
7147 ixgbe_get_eeprom(struct rte_eth_dev *dev,
7148 struct rte_dev_eeprom_info *in_eeprom)
7150 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7151 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
7152 uint16_t *data = in_eeprom->data;
7155 first = in_eeprom->offset >> 1;
7156 length = in_eeprom->length >> 1;
7157 if ((first > hw->eeprom.word_size) ||
7158 ((first + length) > hw->eeprom.word_size))
7161 in_eeprom->magic = hw->vendor_id | (hw->device_id << 16);
7163 return eeprom->ops.read_buffer(hw, first, length, data);
7167 ixgbe_set_eeprom(struct rte_eth_dev *dev,
7168 struct rte_dev_eeprom_info *in_eeprom)
7170 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7171 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
7172 uint16_t *data = in_eeprom->data;
7175 first = in_eeprom->offset >> 1;
7176 length = in_eeprom->length >> 1;
7177 if ((first > hw->eeprom.word_size) ||
7178 ((first + length) > hw->eeprom.word_size))
7181 in_eeprom->magic = hw->vendor_id | (hw->device_id << 16);
7183 return eeprom->ops.write_buffer(hw, first, length, data);
7187 ixgbe_reta_size_get(enum ixgbe_mac_type mac_type) {
7189 case ixgbe_mac_X550:
7190 case ixgbe_mac_X550EM_x:
7191 case ixgbe_mac_X550EM_a:
7192 return ETH_RSS_RETA_SIZE_512;
7193 case ixgbe_mac_X550_vf:
7194 case ixgbe_mac_X550EM_x_vf:
7195 case ixgbe_mac_X550EM_a_vf:
7196 return ETH_RSS_RETA_SIZE_64;
7198 return ETH_RSS_RETA_SIZE_128;
7203 ixgbe_reta_reg_get(enum ixgbe_mac_type mac_type, uint16_t reta_idx) {
7205 case ixgbe_mac_X550:
7206 case ixgbe_mac_X550EM_x:
7207 case ixgbe_mac_X550EM_a:
7208 if (reta_idx < ETH_RSS_RETA_SIZE_128)
7209 return IXGBE_RETA(reta_idx >> 2);
7211 return IXGBE_ERETA((reta_idx - ETH_RSS_RETA_SIZE_128) >> 2);
7212 case ixgbe_mac_X550_vf:
7213 case ixgbe_mac_X550EM_x_vf:
7214 case ixgbe_mac_X550EM_a_vf:
7215 return IXGBE_VFRETA(reta_idx >> 2);
7217 return IXGBE_RETA(reta_idx >> 2);
7222 ixgbe_mrqc_reg_get(enum ixgbe_mac_type mac_type) {
7224 case ixgbe_mac_X550_vf:
7225 case ixgbe_mac_X550EM_x_vf:
7226 case ixgbe_mac_X550EM_a_vf:
7227 return IXGBE_VFMRQC;
7234 ixgbe_rssrk_reg_get(enum ixgbe_mac_type mac_type, uint8_t i) {
7236 case ixgbe_mac_X550_vf:
7237 case ixgbe_mac_X550EM_x_vf:
7238 case ixgbe_mac_X550EM_a_vf:
7239 return IXGBE_VFRSSRK(i);
7241 return IXGBE_RSSRK(i);
7246 ixgbe_rss_update_sp(enum ixgbe_mac_type mac_type) {
7248 case ixgbe_mac_82599_vf:
7249 case ixgbe_mac_X540_vf:
7257 ixgbe_dev_get_dcb_info(struct rte_eth_dev *dev,
7258 struct rte_eth_dcb_info *dcb_info)
7260 struct ixgbe_dcb_config *dcb_config =
7261 IXGBE_DEV_PRIVATE_TO_DCB_CFG(dev->data->dev_private);
7262 struct ixgbe_dcb_tc_config *tc;
7263 struct rte_eth_dcb_tc_queue_mapping *tc_queue;
7267 if (dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_DCB_FLAG)
7268 dcb_info->nb_tcs = dcb_config->num_tcs.pg_tcs;
7270 dcb_info->nb_tcs = 1;
7272 tc_queue = &dcb_info->tc_queue;
7273 nb_tcs = dcb_info->nb_tcs;
7275 if (dcb_config->vt_mode) { /* vt is enabled*/
7276 struct rte_eth_vmdq_dcb_conf *vmdq_rx_conf =
7277 &dev->data->dev_conf.rx_adv_conf.vmdq_dcb_conf;
7278 for (i = 0; i < ETH_DCB_NUM_USER_PRIORITIES; i++)
7279 dcb_info->prio_tc[i] = vmdq_rx_conf->dcb_tc[i];
7280 if (RTE_ETH_DEV_SRIOV(dev).active > 0) {
7281 for (j = 0; j < nb_tcs; j++) {
7282 tc_queue->tc_rxq[0][j].base = j;
7283 tc_queue->tc_rxq[0][j].nb_queue = 1;
7284 tc_queue->tc_txq[0][j].base = j;
7285 tc_queue->tc_txq[0][j].nb_queue = 1;
7288 for (i = 0; i < vmdq_rx_conf->nb_queue_pools; i++) {
7289 for (j = 0; j < nb_tcs; j++) {
7290 tc_queue->tc_rxq[i][j].base =
7292 tc_queue->tc_rxq[i][j].nb_queue = 1;
7293 tc_queue->tc_txq[i][j].base =
7295 tc_queue->tc_txq[i][j].nb_queue = 1;
7299 } else { /* vt is disabled*/
7300 struct rte_eth_dcb_rx_conf *rx_conf =
7301 &dev->data->dev_conf.rx_adv_conf.dcb_rx_conf;
7302 for (i = 0; i < ETH_DCB_NUM_USER_PRIORITIES; i++)
7303 dcb_info->prio_tc[i] = rx_conf->dcb_tc[i];
7304 if (dcb_info->nb_tcs == ETH_4_TCS) {
7305 for (i = 0; i < dcb_info->nb_tcs; i++) {
7306 dcb_info->tc_queue.tc_rxq[0][i].base = i * 32;
7307 dcb_info->tc_queue.tc_rxq[0][i].nb_queue = 16;
7309 dcb_info->tc_queue.tc_txq[0][0].base = 0;
7310 dcb_info->tc_queue.tc_txq[0][1].base = 64;
7311 dcb_info->tc_queue.tc_txq[0][2].base = 96;
7312 dcb_info->tc_queue.tc_txq[0][3].base = 112;
7313 dcb_info->tc_queue.tc_txq[0][0].nb_queue = 64;
7314 dcb_info->tc_queue.tc_txq[0][1].nb_queue = 32;
7315 dcb_info->tc_queue.tc_txq[0][2].nb_queue = 16;
7316 dcb_info->tc_queue.tc_txq[0][3].nb_queue = 16;
7317 } else if (dcb_info->nb_tcs == ETH_8_TCS) {
7318 for (i = 0; i < dcb_info->nb_tcs; i++) {
7319 dcb_info->tc_queue.tc_rxq[0][i].base = i * 16;
7320 dcb_info->tc_queue.tc_rxq[0][i].nb_queue = 16;
7322 dcb_info->tc_queue.tc_txq[0][0].base = 0;
7323 dcb_info->tc_queue.tc_txq[0][1].base = 32;
7324 dcb_info->tc_queue.tc_txq[0][2].base = 64;
7325 dcb_info->tc_queue.tc_txq[0][3].base = 80;
7326 dcb_info->tc_queue.tc_txq[0][4].base = 96;
7327 dcb_info->tc_queue.tc_txq[0][5].base = 104;
7328 dcb_info->tc_queue.tc_txq[0][6].base = 112;
7329 dcb_info->tc_queue.tc_txq[0][7].base = 120;
7330 dcb_info->tc_queue.tc_txq[0][0].nb_queue = 32;
7331 dcb_info->tc_queue.tc_txq[0][1].nb_queue = 32;
7332 dcb_info->tc_queue.tc_txq[0][2].nb_queue = 16;
7333 dcb_info->tc_queue.tc_txq[0][3].nb_queue = 16;
7334 dcb_info->tc_queue.tc_txq[0][4].nb_queue = 8;
7335 dcb_info->tc_queue.tc_txq[0][5].nb_queue = 8;
7336 dcb_info->tc_queue.tc_txq[0][6].nb_queue = 8;
7337 dcb_info->tc_queue.tc_txq[0][7].nb_queue = 8;
7340 for (i = 0; i < dcb_info->nb_tcs; i++) {
7341 tc = &dcb_config->tc_config[i];
7342 dcb_info->tc_bws[i] = tc->path[IXGBE_DCB_TX_CONFIG].bwg_percent;
7347 /* Update e-tag ether type */
7349 ixgbe_update_e_tag_eth_type(struct ixgbe_hw *hw,
7350 uint16_t ether_type)
7352 uint32_t etag_etype;
7354 if (hw->mac.type != ixgbe_mac_X550 &&
7355 hw->mac.type != ixgbe_mac_X550EM_x &&
7356 hw->mac.type != ixgbe_mac_X550EM_a) {
7360 etag_etype = IXGBE_READ_REG(hw, IXGBE_ETAG_ETYPE);
7361 etag_etype &= ~IXGBE_ETAG_ETYPE_MASK;
7362 etag_etype |= ether_type;
7363 IXGBE_WRITE_REG(hw, IXGBE_ETAG_ETYPE, etag_etype);
7364 IXGBE_WRITE_FLUSH(hw);
7369 /* Config l2 tunnel ether type */
7371 ixgbe_dev_l2_tunnel_eth_type_conf(struct rte_eth_dev *dev,
7372 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7375 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7376 struct ixgbe_l2_tn_info *l2_tn_info =
7377 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
7379 if (l2_tunnel == NULL)
7382 switch (l2_tunnel->l2_tunnel_type) {
7383 case RTE_L2_TUNNEL_TYPE_E_TAG:
7384 l2_tn_info->e_tag_ether_type = l2_tunnel->ether_type;
7385 ret = ixgbe_update_e_tag_eth_type(hw, l2_tunnel->ether_type);
7388 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7396 /* Enable e-tag tunnel */
7398 ixgbe_e_tag_enable(struct ixgbe_hw *hw)
7400 uint32_t etag_etype;
7402 if (hw->mac.type != ixgbe_mac_X550 &&
7403 hw->mac.type != ixgbe_mac_X550EM_x &&
7404 hw->mac.type != ixgbe_mac_X550EM_a) {
7408 etag_etype = IXGBE_READ_REG(hw, IXGBE_ETAG_ETYPE);
7409 etag_etype |= IXGBE_ETAG_ETYPE_VALID;
7410 IXGBE_WRITE_REG(hw, IXGBE_ETAG_ETYPE, etag_etype);
7411 IXGBE_WRITE_FLUSH(hw);
7416 /* Enable l2 tunnel */
7418 ixgbe_dev_l2_tunnel_enable(struct rte_eth_dev *dev,
7419 enum rte_eth_tunnel_type l2_tunnel_type)
7422 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7423 struct ixgbe_l2_tn_info *l2_tn_info =
7424 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
7426 switch (l2_tunnel_type) {
7427 case RTE_L2_TUNNEL_TYPE_E_TAG:
7428 l2_tn_info->e_tag_en = TRUE;
7429 ret = ixgbe_e_tag_enable(hw);
7432 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7440 /* Disable e-tag tunnel */
7442 ixgbe_e_tag_disable(struct ixgbe_hw *hw)
7444 uint32_t etag_etype;
7446 if (hw->mac.type != ixgbe_mac_X550 &&
7447 hw->mac.type != ixgbe_mac_X550EM_x &&
7448 hw->mac.type != ixgbe_mac_X550EM_a) {
7452 etag_etype = IXGBE_READ_REG(hw, IXGBE_ETAG_ETYPE);
7453 etag_etype &= ~IXGBE_ETAG_ETYPE_VALID;
7454 IXGBE_WRITE_REG(hw, IXGBE_ETAG_ETYPE, etag_etype);
7455 IXGBE_WRITE_FLUSH(hw);
7460 /* Disable l2 tunnel */
7462 ixgbe_dev_l2_tunnel_disable(struct rte_eth_dev *dev,
7463 enum rte_eth_tunnel_type l2_tunnel_type)
7466 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7467 struct ixgbe_l2_tn_info *l2_tn_info =
7468 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
7470 switch (l2_tunnel_type) {
7471 case RTE_L2_TUNNEL_TYPE_E_TAG:
7472 l2_tn_info->e_tag_en = FALSE;
7473 ret = ixgbe_e_tag_disable(hw);
7476 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7485 ixgbe_e_tag_filter_del(struct rte_eth_dev *dev,
7486 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7489 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7490 uint32_t i, rar_entries;
7491 uint32_t rar_low, rar_high;
7493 if (hw->mac.type != ixgbe_mac_X550 &&
7494 hw->mac.type != ixgbe_mac_X550EM_x &&
7495 hw->mac.type != ixgbe_mac_X550EM_a) {
7499 rar_entries = ixgbe_get_num_rx_addrs(hw);
7501 for (i = 1; i < rar_entries; i++) {
7502 rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(i));
7503 rar_low = IXGBE_READ_REG(hw, IXGBE_RAL(i));
7504 if ((rar_high & IXGBE_RAH_AV) &&
7505 (rar_high & IXGBE_RAH_ADTYPE) &&
7506 ((rar_low & IXGBE_RAL_ETAG_FILTER_MASK) ==
7507 l2_tunnel->tunnel_id)) {
7508 IXGBE_WRITE_REG(hw, IXGBE_RAL(i), 0);
7509 IXGBE_WRITE_REG(hw, IXGBE_RAH(i), 0);
7511 ixgbe_clear_vmdq(hw, i, IXGBE_CLEAR_VMDQ_ALL);
7521 ixgbe_e_tag_filter_add(struct rte_eth_dev *dev,
7522 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7525 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7526 uint32_t i, rar_entries;
7527 uint32_t rar_low, rar_high;
7529 if (hw->mac.type != ixgbe_mac_X550 &&
7530 hw->mac.type != ixgbe_mac_X550EM_x &&
7531 hw->mac.type != ixgbe_mac_X550EM_a) {
7535 /* One entry for one tunnel. Try to remove potential existing entry. */
7536 ixgbe_e_tag_filter_del(dev, l2_tunnel);
7538 rar_entries = ixgbe_get_num_rx_addrs(hw);
7540 for (i = 1; i < rar_entries; i++) {
7541 rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(i));
7542 if (rar_high & IXGBE_RAH_AV) {
7545 ixgbe_set_vmdq(hw, i, l2_tunnel->pool);
7546 rar_high = IXGBE_RAH_AV | IXGBE_RAH_ADTYPE;
7547 rar_low = l2_tunnel->tunnel_id;
7549 IXGBE_WRITE_REG(hw, IXGBE_RAL(i), rar_low);
7550 IXGBE_WRITE_REG(hw, IXGBE_RAH(i), rar_high);
7556 PMD_INIT_LOG(NOTICE, "The table of E-tag forwarding rule is full."
7557 " Please remove a rule before adding a new one.");
7561 static inline struct ixgbe_l2_tn_filter *
7562 ixgbe_l2_tn_filter_lookup(struct ixgbe_l2_tn_info *l2_tn_info,
7563 struct ixgbe_l2_tn_key *key)
7567 ret = rte_hash_lookup(l2_tn_info->hash_handle, (const void *)key);
7571 return l2_tn_info->hash_map[ret];
7575 ixgbe_insert_l2_tn_filter(struct ixgbe_l2_tn_info *l2_tn_info,
7576 struct ixgbe_l2_tn_filter *l2_tn_filter)
7580 ret = rte_hash_add_key(l2_tn_info->hash_handle,
7581 &l2_tn_filter->key);
7585 "Failed to insert L2 tunnel filter"
7586 " to hash table %d!",
7591 l2_tn_info->hash_map[ret] = l2_tn_filter;
7593 TAILQ_INSERT_TAIL(&l2_tn_info->l2_tn_list, l2_tn_filter, entries);
7599 ixgbe_remove_l2_tn_filter(struct ixgbe_l2_tn_info *l2_tn_info,
7600 struct ixgbe_l2_tn_key *key)
7603 struct ixgbe_l2_tn_filter *l2_tn_filter;
7605 ret = rte_hash_del_key(l2_tn_info->hash_handle, key);
7609 "No such L2 tunnel filter to delete %d!",
7614 l2_tn_filter = l2_tn_info->hash_map[ret];
7615 l2_tn_info->hash_map[ret] = NULL;
7617 TAILQ_REMOVE(&l2_tn_info->l2_tn_list, l2_tn_filter, entries);
7618 rte_free(l2_tn_filter);
7623 /* Add l2 tunnel filter */
7625 ixgbe_dev_l2_tunnel_filter_add(struct rte_eth_dev *dev,
7626 struct rte_eth_l2_tunnel_conf *l2_tunnel,
7630 struct ixgbe_l2_tn_info *l2_tn_info =
7631 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
7632 struct ixgbe_l2_tn_key key;
7633 struct ixgbe_l2_tn_filter *node;
7636 key.l2_tn_type = l2_tunnel->l2_tunnel_type;
7637 key.tn_id = l2_tunnel->tunnel_id;
7639 node = ixgbe_l2_tn_filter_lookup(l2_tn_info, &key);
7643 "The L2 tunnel filter already exists!");
7647 node = rte_zmalloc("ixgbe_l2_tn",
7648 sizeof(struct ixgbe_l2_tn_filter),
7653 rte_memcpy(&node->key,
7655 sizeof(struct ixgbe_l2_tn_key));
7656 node->pool = l2_tunnel->pool;
7657 ret = ixgbe_insert_l2_tn_filter(l2_tn_info, node);
7664 switch (l2_tunnel->l2_tunnel_type) {
7665 case RTE_L2_TUNNEL_TYPE_E_TAG:
7666 ret = ixgbe_e_tag_filter_add(dev, l2_tunnel);
7669 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7674 if ((!restore) && (ret < 0))
7675 (void)ixgbe_remove_l2_tn_filter(l2_tn_info, &key);
7680 /* Delete l2 tunnel filter */
7682 ixgbe_dev_l2_tunnel_filter_del(struct rte_eth_dev *dev,
7683 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7686 struct ixgbe_l2_tn_info *l2_tn_info =
7687 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
7688 struct ixgbe_l2_tn_key key;
7690 key.l2_tn_type = l2_tunnel->l2_tunnel_type;
7691 key.tn_id = l2_tunnel->tunnel_id;
7692 ret = ixgbe_remove_l2_tn_filter(l2_tn_info, &key);
7696 switch (l2_tunnel->l2_tunnel_type) {
7697 case RTE_L2_TUNNEL_TYPE_E_TAG:
7698 ret = ixgbe_e_tag_filter_del(dev, l2_tunnel);
7701 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7710 * ixgbe_dev_l2_tunnel_filter_handle - Handle operations for l2 tunnel filter.
7711 * @dev: pointer to rte_eth_dev structure
7712 * @filter_op:operation will be taken.
7713 * @arg: a pointer to specific structure corresponding to the filter_op
7716 ixgbe_dev_l2_tunnel_filter_handle(struct rte_eth_dev *dev,
7717 enum rte_filter_op filter_op,
7722 if (filter_op == RTE_ETH_FILTER_NOP)
7726 PMD_DRV_LOG(ERR, "arg shouldn't be NULL for operation %u.",
7731 switch (filter_op) {
7732 case RTE_ETH_FILTER_ADD:
7733 ret = ixgbe_dev_l2_tunnel_filter_add
7735 (struct rte_eth_l2_tunnel_conf *)arg,
7738 case RTE_ETH_FILTER_DELETE:
7739 ret = ixgbe_dev_l2_tunnel_filter_del
7741 (struct rte_eth_l2_tunnel_conf *)arg);
7744 PMD_DRV_LOG(ERR, "unsupported operation %u.", filter_op);
7752 ixgbe_e_tag_forwarding_en_dis(struct rte_eth_dev *dev, bool en)
7756 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7758 if (hw->mac.type != ixgbe_mac_X550 &&
7759 hw->mac.type != ixgbe_mac_X550EM_x &&
7760 hw->mac.type != ixgbe_mac_X550EM_a) {
7764 ctrl = IXGBE_READ_REG(hw, IXGBE_VT_CTL);
7765 ctrl &= ~IXGBE_VT_CTL_POOLING_MODE_MASK;
7767 ctrl |= IXGBE_VT_CTL_POOLING_MODE_ETAG;
7768 IXGBE_WRITE_REG(hw, IXGBE_VT_CTL, ctrl);
7773 /* Enable l2 tunnel forwarding */
7775 ixgbe_dev_l2_tunnel_forwarding_enable
7776 (struct rte_eth_dev *dev,
7777 enum rte_eth_tunnel_type l2_tunnel_type)
7779 struct ixgbe_l2_tn_info *l2_tn_info =
7780 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
7783 switch (l2_tunnel_type) {
7784 case RTE_L2_TUNNEL_TYPE_E_TAG:
7785 l2_tn_info->e_tag_fwd_en = TRUE;
7786 ret = ixgbe_e_tag_forwarding_en_dis(dev, 1);
7789 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7797 /* Disable l2 tunnel forwarding */
7799 ixgbe_dev_l2_tunnel_forwarding_disable
7800 (struct rte_eth_dev *dev,
7801 enum rte_eth_tunnel_type l2_tunnel_type)
7803 struct ixgbe_l2_tn_info *l2_tn_info =
7804 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
7807 switch (l2_tunnel_type) {
7808 case RTE_L2_TUNNEL_TYPE_E_TAG:
7809 l2_tn_info->e_tag_fwd_en = FALSE;
7810 ret = ixgbe_e_tag_forwarding_en_dis(dev, 0);
7813 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7822 ixgbe_e_tag_insertion_en_dis(struct rte_eth_dev *dev,
7823 struct rte_eth_l2_tunnel_conf *l2_tunnel,
7826 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
7828 uint32_t vmtir, vmvir;
7829 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7831 if (l2_tunnel->vf_id >= pci_dev->max_vfs) {
7833 "VF id %u should be less than %u",
7839 if (hw->mac.type != ixgbe_mac_X550 &&
7840 hw->mac.type != ixgbe_mac_X550EM_x &&
7841 hw->mac.type != ixgbe_mac_X550EM_a) {
7846 vmtir = l2_tunnel->tunnel_id;
7850 IXGBE_WRITE_REG(hw, IXGBE_VMTIR(l2_tunnel->vf_id), vmtir);
7852 vmvir = IXGBE_READ_REG(hw, IXGBE_VMVIR(l2_tunnel->vf_id));
7853 vmvir &= ~IXGBE_VMVIR_TAGA_MASK;
7855 vmvir |= IXGBE_VMVIR_TAGA_ETAG_INSERT;
7856 IXGBE_WRITE_REG(hw, IXGBE_VMVIR(l2_tunnel->vf_id), vmvir);
7861 /* Enable l2 tunnel tag insertion */
7863 ixgbe_dev_l2_tunnel_insertion_enable(struct rte_eth_dev *dev,
7864 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7868 switch (l2_tunnel->l2_tunnel_type) {
7869 case RTE_L2_TUNNEL_TYPE_E_TAG:
7870 ret = ixgbe_e_tag_insertion_en_dis(dev, l2_tunnel, 1);
7873 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7881 /* Disable l2 tunnel tag insertion */
7883 ixgbe_dev_l2_tunnel_insertion_disable
7884 (struct rte_eth_dev *dev,
7885 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7889 switch (l2_tunnel->l2_tunnel_type) {
7890 case RTE_L2_TUNNEL_TYPE_E_TAG:
7891 ret = ixgbe_e_tag_insertion_en_dis(dev, l2_tunnel, 0);
7894 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7903 ixgbe_e_tag_stripping_en_dis(struct rte_eth_dev *dev,
7908 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7910 if (hw->mac.type != ixgbe_mac_X550 &&
7911 hw->mac.type != ixgbe_mac_X550EM_x &&
7912 hw->mac.type != ixgbe_mac_X550EM_a) {
7916 qde = IXGBE_READ_REG(hw, IXGBE_QDE);
7918 qde |= IXGBE_QDE_STRIP_TAG;
7920 qde &= ~IXGBE_QDE_STRIP_TAG;
7921 qde &= ~IXGBE_QDE_READ;
7922 qde |= IXGBE_QDE_WRITE;
7923 IXGBE_WRITE_REG(hw, IXGBE_QDE, qde);
7928 /* Enable l2 tunnel tag stripping */
7930 ixgbe_dev_l2_tunnel_stripping_enable
7931 (struct rte_eth_dev *dev,
7932 enum rte_eth_tunnel_type l2_tunnel_type)
7936 switch (l2_tunnel_type) {
7937 case RTE_L2_TUNNEL_TYPE_E_TAG:
7938 ret = ixgbe_e_tag_stripping_en_dis(dev, 1);
7941 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7949 /* Disable l2 tunnel tag stripping */
7951 ixgbe_dev_l2_tunnel_stripping_disable
7952 (struct rte_eth_dev *dev,
7953 enum rte_eth_tunnel_type l2_tunnel_type)
7957 switch (l2_tunnel_type) {
7958 case RTE_L2_TUNNEL_TYPE_E_TAG:
7959 ret = ixgbe_e_tag_stripping_en_dis(dev, 0);
7962 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7970 /* Enable/disable l2 tunnel offload functions */
7972 ixgbe_dev_l2_tunnel_offload_set
7973 (struct rte_eth_dev *dev,
7974 struct rte_eth_l2_tunnel_conf *l2_tunnel,
7980 if (l2_tunnel == NULL)
7984 if (mask & ETH_L2_TUNNEL_ENABLE_MASK) {
7986 ret = ixgbe_dev_l2_tunnel_enable(
7988 l2_tunnel->l2_tunnel_type);
7990 ret = ixgbe_dev_l2_tunnel_disable(
7992 l2_tunnel->l2_tunnel_type);
7995 if (mask & ETH_L2_TUNNEL_INSERTION_MASK) {
7997 ret = ixgbe_dev_l2_tunnel_insertion_enable(
8001 ret = ixgbe_dev_l2_tunnel_insertion_disable(
8006 if (mask & ETH_L2_TUNNEL_STRIPPING_MASK) {
8008 ret = ixgbe_dev_l2_tunnel_stripping_enable(
8010 l2_tunnel->l2_tunnel_type);
8012 ret = ixgbe_dev_l2_tunnel_stripping_disable(
8014 l2_tunnel->l2_tunnel_type);
8017 if (mask & ETH_L2_TUNNEL_FORWARDING_MASK) {
8019 ret = ixgbe_dev_l2_tunnel_forwarding_enable(
8021 l2_tunnel->l2_tunnel_type);
8023 ret = ixgbe_dev_l2_tunnel_forwarding_disable(
8025 l2_tunnel->l2_tunnel_type);
8032 ixgbe_update_vxlan_port(struct ixgbe_hw *hw,
8035 IXGBE_WRITE_REG(hw, IXGBE_VXLANCTRL, port);
8036 IXGBE_WRITE_FLUSH(hw);
8041 /* There's only one register for VxLAN UDP port.
8042 * So, we cannot add several ports. Will update it.
8045 ixgbe_add_vxlan_port(struct ixgbe_hw *hw,
8049 PMD_DRV_LOG(ERR, "Add VxLAN port 0 is not allowed.");
8053 return ixgbe_update_vxlan_port(hw, port);
8056 /* We cannot delete the VxLAN port. For there's a register for VxLAN
8057 * UDP port, it must have a value.
8058 * So, will reset it to the original value 0.
8061 ixgbe_del_vxlan_port(struct ixgbe_hw *hw,
8066 cur_port = (uint16_t)IXGBE_READ_REG(hw, IXGBE_VXLANCTRL);
8068 if (cur_port != port) {
8069 PMD_DRV_LOG(ERR, "Port %u does not exist.", port);
8073 return ixgbe_update_vxlan_port(hw, 0);
8076 /* Add UDP tunneling port */
8078 ixgbe_dev_udp_tunnel_port_add(struct rte_eth_dev *dev,
8079 struct rte_eth_udp_tunnel *udp_tunnel)
8082 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8084 if (hw->mac.type != ixgbe_mac_X550 &&
8085 hw->mac.type != ixgbe_mac_X550EM_x &&
8086 hw->mac.type != ixgbe_mac_X550EM_a) {
8090 if (udp_tunnel == NULL)
8093 switch (udp_tunnel->prot_type) {
8094 case RTE_TUNNEL_TYPE_VXLAN:
8095 ret = ixgbe_add_vxlan_port(hw, udp_tunnel->udp_port);
8098 case RTE_TUNNEL_TYPE_GENEVE:
8099 case RTE_TUNNEL_TYPE_TEREDO:
8100 PMD_DRV_LOG(ERR, "Tunnel type is not supported now.");
8105 PMD_DRV_LOG(ERR, "Invalid tunnel type");
8113 /* Remove UDP tunneling port */
8115 ixgbe_dev_udp_tunnel_port_del(struct rte_eth_dev *dev,
8116 struct rte_eth_udp_tunnel *udp_tunnel)
8119 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8121 if (hw->mac.type != ixgbe_mac_X550 &&
8122 hw->mac.type != ixgbe_mac_X550EM_x &&
8123 hw->mac.type != ixgbe_mac_X550EM_a) {
8127 if (udp_tunnel == NULL)
8130 switch (udp_tunnel->prot_type) {
8131 case RTE_TUNNEL_TYPE_VXLAN:
8132 ret = ixgbe_del_vxlan_port(hw, udp_tunnel->udp_port);
8134 case RTE_TUNNEL_TYPE_GENEVE:
8135 case RTE_TUNNEL_TYPE_TEREDO:
8136 PMD_DRV_LOG(ERR, "Tunnel type is not supported now.");
8140 PMD_DRV_LOG(ERR, "Invalid tunnel type");
8149 ixgbevf_dev_allmulticast_enable(struct rte_eth_dev *dev)
8151 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8153 hw->mac.ops.update_xcast_mode(hw, IXGBEVF_XCAST_MODE_ALLMULTI);
8157 ixgbevf_dev_allmulticast_disable(struct rte_eth_dev *dev)
8159 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8161 hw->mac.ops.update_xcast_mode(hw, IXGBEVF_XCAST_MODE_MULTI);
8164 static void ixgbevf_mbx_process(struct rte_eth_dev *dev)
8166 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8169 if (ixgbe_read_mbx(hw, &in_msg, 1, 0))
8172 /* PF reset VF event */
8173 if (in_msg == IXGBE_PF_CONTROL_MSG)
8174 _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RESET,
8179 ixgbevf_dev_interrupt_get_status(struct rte_eth_dev *dev)
8182 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8183 struct ixgbe_interrupt *intr =
8184 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
8185 ixgbevf_intr_disable(hw);
8187 /* read-on-clear nic registers here */
8188 eicr = IXGBE_READ_REG(hw, IXGBE_VTEICR);
8191 /* only one misc vector supported - mailbox */
8192 eicr &= IXGBE_VTEICR_MASK;
8193 if (eicr == IXGBE_MISC_VEC_ID)
8194 intr->flags |= IXGBE_FLAG_MAILBOX;
8200 ixgbevf_dev_interrupt_action(struct rte_eth_dev *dev)
8202 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8203 struct ixgbe_interrupt *intr =
8204 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
8206 if (intr->flags & IXGBE_FLAG_MAILBOX) {
8207 ixgbevf_mbx_process(dev);
8208 intr->flags &= ~IXGBE_FLAG_MAILBOX;
8211 ixgbevf_intr_enable(hw);
8217 ixgbevf_dev_interrupt_handler(void *param)
8219 struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
8221 ixgbevf_dev_interrupt_get_status(dev);
8222 ixgbevf_dev_interrupt_action(dev);
8226 * ixgbe_disable_sec_tx_path_generic - Stops the transmit data path
8227 * @hw: pointer to hardware structure
8229 * Stops the transmit data path and waits for the HW to internally empty
8230 * the Tx security block
8232 int ixgbe_disable_sec_tx_path_generic(struct ixgbe_hw *hw)
8234 #define IXGBE_MAX_SECTX_POLL 40
8239 sectxreg = IXGBE_READ_REG(hw, IXGBE_SECTXCTRL);
8240 sectxreg |= IXGBE_SECTXCTRL_TX_DIS;
8241 IXGBE_WRITE_REG(hw, IXGBE_SECTXCTRL, sectxreg);
8242 for (i = 0; i < IXGBE_MAX_SECTX_POLL; i++) {
8243 sectxreg = IXGBE_READ_REG(hw, IXGBE_SECTXSTAT);
8244 if (sectxreg & IXGBE_SECTXSTAT_SECTX_RDY)
8246 /* Use interrupt-safe sleep just in case */
8250 /* For informational purposes only */
8251 if (i >= IXGBE_MAX_SECTX_POLL)
8252 PMD_DRV_LOG(DEBUG, "Tx unit being enabled before security "
8253 "path fully disabled. Continuing with init.");
8255 return IXGBE_SUCCESS;
8259 * ixgbe_enable_sec_tx_path_generic - Enables the transmit data path
8260 * @hw: pointer to hardware structure
8262 * Enables the transmit data path.
8264 int ixgbe_enable_sec_tx_path_generic(struct ixgbe_hw *hw)
8268 sectxreg = IXGBE_READ_REG(hw, IXGBE_SECTXCTRL);
8269 sectxreg &= ~IXGBE_SECTXCTRL_TX_DIS;
8270 IXGBE_WRITE_REG(hw, IXGBE_SECTXCTRL, sectxreg);
8271 IXGBE_WRITE_FLUSH(hw);
8273 return IXGBE_SUCCESS;
8276 /* restore n-tuple filter */
8278 ixgbe_ntuple_filter_restore(struct rte_eth_dev *dev)
8280 struct ixgbe_filter_info *filter_info =
8281 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
8282 struct ixgbe_5tuple_filter *node;
8284 TAILQ_FOREACH(node, &filter_info->fivetuple_list, entries) {
8285 ixgbe_inject_5tuple_filter(dev, node);
8289 /* restore ethernet type filter */
8291 ixgbe_ethertype_filter_restore(struct rte_eth_dev *dev)
8293 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8294 struct ixgbe_filter_info *filter_info =
8295 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
8298 for (i = 0; i < IXGBE_MAX_ETQF_FILTERS; i++) {
8299 if (filter_info->ethertype_mask & (1 << i)) {
8300 IXGBE_WRITE_REG(hw, IXGBE_ETQF(i),
8301 filter_info->ethertype_filters[i].etqf);
8302 IXGBE_WRITE_REG(hw, IXGBE_ETQS(i),
8303 filter_info->ethertype_filters[i].etqs);
8304 IXGBE_WRITE_FLUSH(hw);
8309 /* restore SYN filter */
8311 ixgbe_syn_filter_restore(struct rte_eth_dev *dev)
8313 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8314 struct ixgbe_filter_info *filter_info =
8315 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
8318 synqf = filter_info->syn_info;
8320 if (synqf & IXGBE_SYN_FILTER_ENABLE) {
8321 IXGBE_WRITE_REG(hw, IXGBE_SYNQF, synqf);
8322 IXGBE_WRITE_FLUSH(hw);
8326 /* restore L2 tunnel filter */
8328 ixgbe_l2_tn_filter_restore(struct rte_eth_dev *dev)
8330 struct ixgbe_l2_tn_info *l2_tn_info =
8331 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
8332 struct ixgbe_l2_tn_filter *node;
8333 struct rte_eth_l2_tunnel_conf l2_tn_conf;
8335 TAILQ_FOREACH(node, &l2_tn_info->l2_tn_list, entries) {
8336 l2_tn_conf.l2_tunnel_type = node->key.l2_tn_type;
8337 l2_tn_conf.tunnel_id = node->key.tn_id;
8338 l2_tn_conf.pool = node->pool;
8339 (void)ixgbe_dev_l2_tunnel_filter_add(dev, &l2_tn_conf, TRUE);
8344 ixgbe_filter_restore(struct rte_eth_dev *dev)
8346 ixgbe_ntuple_filter_restore(dev);
8347 ixgbe_ethertype_filter_restore(dev);
8348 ixgbe_syn_filter_restore(dev);
8349 ixgbe_fdir_filter_restore(dev);
8350 ixgbe_l2_tn_filter_restore(dev);
8356 ixgbe_l2_tunnel_conf(struct rte_eth_dev *dev)
8358 struct ixgbe_l2_tn_info *l2_tn_info =
8359 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
8360 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8362 if (l2_tn_info->e_tag_en)
8363 (void)ixgbe_e_tag_enable(hw);
8365 if (l2_tn_info->e_tag_fwd_en)
8366 (void)ixgbe_e_tag_forwarding_en_dis(dev, 1);
8368 (void)ixgbe_update_e_tag_eth_type(hw, l2_tn_info->e_tag_ether_type);
8371 /* remove all the n-tuple filters */
8373 ixgbe_clear_all_ntuple_filter(struct rte_eth_dev *dev)
8375 struct ixgbe_filter_info *filter_info =
8376 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
8377 struct ixgbe_5tuple_filter *p_5tuple;
8379 while ((p_5tuple = TAILQ_FIRST(&filter_info->fivetuple_list)))
8380 ixgbe_remove_5tuple_filter(dev, p_5tuple);
8383 /* remove all the ether type filters */
8385 ixgbe_clear_all_ethertype_filter(struct rte_eth_dev *dev)
8387 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8388 struct ixgbe_filter_info *filter_info =
8389 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
8392 for (i = 0; i < IXGBE_MAX_ETQF_FILTERS; i++) {
8393 if (filter_info->ethertype_mask & (1 << i) &&
8394 !filter_info->ethertype_filters[i].conf) {
8395 (void)ixgbe_ethertype_filter_remove(filter_info,
8397 IXGBE_WRITE_REG(hw, IXGBE_ETQF(i), 0);
8398 IXGBE_WRITE_REG(hw, IXGBE_ETQS(i), 0);
8399 IXGBE_WRITE_FLUSH(hw);
8404 /* remove the SYN filter */
8406 ixgbe_clear_syn_filter(struct rte_eth_dev *dev)
8408 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8409 struct ixgbe_filter_info *filter_info =
8410 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
8412 if (filter_info->syn_info & IXGBE_SYN_FILTER_ENABLE) {
8413 filter_info->syn_info = 0;
8415 IXGBE_WRITE_REG(hw, IXGBE_SYNQF, 0);
8416 IXGBE_WRITE_FLUSH(hw);
8420 /* remove all the L2 tunnel filters */
8422 ixgbe_clear_all_l2_tn_filter(struct rte_eth_dev *dev)
8424 struct ixgbe_l2_tn_info *l2_tn_info =
8425 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
8426 struct ixgbe_l2_tn_filter *l2_tn_filter;
8427 struct rte_eth_l2_tunnel_conf l2_tn_conf;
8430 while ((l2_tn_filter = TAILQ_FIRST(&l2_tn_info->l2_tn_list))) {
8431 l2_tn_conf.l2_tunnel_type = l2_tn_filter->key.l2_tn_type;
8432 l2_tn_conf.tunnel_id = l2_tn_filter->key.tn_id;
8433 l2_tn_conf.pool = l2_tn_filter->pool;
8434 ret = ixgbe_dev_l2_tunnel_filter_del(dev, &l2_tn_conf);
8442 RTE_PMD_REGISTER_PCI(net_ixgbe, rte_ixgbe_pmd);
8443 RTE_PMD_REGISTER_PCI_TABLE(net_ixgbe, pci_id_ixgbe_map);
8444 RTE_PMD_REGISTER_KMOD_DEP(net_ixgbe, "* igb_uio | uio_pci_generic | vfio-pci");
8445 RTE_PMD_REGISTER_PCI(net_ixgbe_vf, rte_ixgbevf_pmd);
8446 RTE_PMD_REGISTER_PCI_TABLE(net_ixgbe_vf, pci_id_ixgbevf_map);
8447 RTE_PMD_REGISTER_KMOD_DEP(net_ixgbe_vf, "* igb_uio | vfio-pci");