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>
56 #include <rte_alarm.h>
57 #include <rte_ether.h>
58 #include <rte_ethdev.h>
59 #include <rte_ethdev_pci.h>
60 #include <rte_malloc.h>
61 #include <rte_random.h>
63 #include <rte_hash_crc.h>
64 #ifdef RTE_LIBRTE_SECURITY
65 #include <rte_security_driver.h>
68 #include "ixgbe_logs.h"
69 #include "base/ixgbe_api.h"
70 #include "base/ixgbe_vf.h"
71 #include "base/ixgbe_common.h"
72 #include "ixgbe_ethdev.h"
73 #include "ixgbe_bypass.h"
74 #include "ixgbe_rxtx.h"
75 #include "base/ixgbe_type.h"
76 #include "base/ixgbe_phy.h"
77 #include "ixgbe_regs.h"
80 * High threshold controlling when to start sending XOFF frames. Must be at
81 * least 8 bytes less than receive packet buffer size. This value is in units
84 #define IXGBE_FC_HI 0x80
87 * Low threshold controlling when to start sending XON frames. This value is
88 * in units of 1024 bytes.
90 #define IXGBE_FC_LO 0x40
92 /* Default minimum inter-interrupt interval for EITR configuration */
93 #define IXGBE_MIN_INTER_INTERRUPT_INTERVAL_DEFAULT 0x79E
95 /* Timer value included in XOFF frames. */
96 #define IXGBE_FC_PAUSE 0x680
98 /*Default value of Max Rx Queue*/
99 #define IXGBE_MAX_RX_QUEUE_NUM 128
101 #define IXGBE_LINK_DOWN_CHECK_TIMEOUT 4000 /* ms */
102 #define IXGBE_LINK_UP_CHECK_TIMEOUT 1000 /* ms */
103 #define IXGBE_VMDQ_NUM_UC_MAC 4096 /* Maximum nb. of UC MAC addr. */
105 #define IXGBE_MMW_SIZE_DEFAULT 0x4
106 #define IXGBE_MMW_SIZE_JUMBO_FRAME 0x14
107 #define IXGBE_MAX_RING_DESC 4096 /* replicate define from rxtx */
110 * Default values for RX/TX configuration
112 #define IXGBE_DEFAULT_RX_FREE_THRESH 32
113 #define IXGBE_DEFAULT_RX_PTHRESH 8
114 #define IXGBE_DEFAULT_RX_HTHRESH 8
115 #define IXGBE_DEFAULT_RX_WTHRESH 0
117 #define IXGBE_DEFAULT_TX_FREE_THRESH 32
118 #define IXGBE_DEFAULT_TX_PTHRESH 32
119 #define IXGBE_DEFAULT_TX_HTHRESH 0
120 #define IXGBE_DEFAULT_TX_WTHRESH 0
121 #define IXGBE_DEFAULT_TX_RSBIT_THRESH 32
123 /* Bit shift and mask */
124 #define IXGBE_4_BIT_WIDTH (CHAR_BIT / 2)
125 #define IXGBE_4_BIT_MASK RTE_LEN2MASK(IXGBE_4_BIT_WIDTH, uint8_t)
126 #define IXGBE_8_BIT_WIDTH CHAR_BIT
127 #define IXGBE_8_BIT_MASK UINT8_MAX
129 #define IXGBEVF_PMD_NAME "rte_ixgbevf_pmd" /* PMD name */
131 #define IXGBE_QUEUE_STAT_COUNTERS (sizeof(hw_stats->qprc) / sizeof(hw_stats->qprc[0]))
133 #define IXGBE_HKEY_MAX_INDEX 10
135 /* Additional timesync values. */
136 #define NSEC_PER_SEC 1000000000L
137 #define IXGBE_INCVAL_10GB 0x66666666
138 #define IXGBE_INCVAL_1GB 0x40000000
139 #define IXGBE_INCVAL_100 0x50000000
140 #define IXGBE_INCVAL_SHIFT_10GB 28
141 #define IXGBE_INCVAL_SHIFT_1GB 24
142 #define IXGBE_INCVAL_SHIFT_100 21
143 #define IXGBE_INCVAL_SHIFT_82599 7
144 #define IXGBE_INCPER_SHIFT_82599 24
146 #define IXGBE_CYCLECOUNTER_MASK 0xffffffffffffffffULL
148 #define IXGBE_VT_CTL_POOLING_MODE_MASK 0x00030000
149 #define IXGBE_VT_CTL_POOLING_MODE_ETAG 0x00010000
150 #define DEFAULT_ETAG_ETYPE 0x893f
151 #define IXGBE_ETAG_ETYPE 0x00005084
152 #define IXGBE_ETAG_ETYPE_MASK 0x0000ffff
153 #define IXGBE_ETAG_ETYPE_VALID 0x80000000
154 #define IXGBE_RAH_ADTYPE 0x40000000
155 #define IXGBE_RAL_ETAG_FILTER_MASK 0x00003fff
156 #define IXGBE_VMVIR_TAGA_MASK 0x18000000
157 #define IXGBE_VMVIR_TAGA_ETAG_INSERT 0x08000000
158 #define IXGBE_VMTIR(_i) (0x00017000 + ((_i) * 4)) /* 64 of these (0-63) */
159 #define IXGBE_QDE_STRIP_TAG 0x00000004
160 #define IXGBE_VTEICR_MASK 0x07
162 #define IXGBE_EXVET_VET_EXT_SHIFT 16
163 #define IXGBE_DMATXCTL_VT_MASK 0xFFFF0000
165 static int eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev);
166 static int eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev);
167 static int ixgbe_fdir_filter_init(struct rte_eth_dev *eth_dev);
168 static int ixgbe_fdir_filter_uninit(struct rte_eth_dev *eth_dev);
169 static int ixgbe_l2_tn_filter_init(struct rte_eth_dev *eth_dev);
170 static int ixgbe_l2_tn_filter_uninit(struct rte_eth_dev *eth_dev);
171 static int ixgbe_ntuple_filter_uninit(struct rte_eth_dev *eth_dev);
172 static int ixgbe_dev_configure(struct rte_eth_dev *dev);
173 static int ixgbe_dev_start(struct rte_eth_dev *dev);
174 static void ixgbe_dev_stop(struct rte_eth_dev *dev);
175 static int ixgbe_dev_set_link_up(struct rte_eth_dev *dev);
176 static int ixgbe_dev_set_link_down(struct rte_eth_dev *dev);
177 static void ixgbe_dev_close(struct rte_eth_dev *dev);
178 static int ixgbe_dev_reset(struct rte_eth_dev *dev);
179 static void ixgbe_dev_promiscuous_enable(struct rte_eth_dev *dev);
180 static void ixgbe_dev_promiscuous_disable(struct rte_eth_dev *dev);
181 static void ixgbe_dev_allmulticast_enable(struct rte_eth_dev *dev);
182 static void ixgbe_dev_allmulticast_disable(struct rte_eth_dev *dev);
183 static int ixgbe_dev_link_update(struct rte_eth_dev *dev,
184 int wait_to_complete);
185 static int ixgbe_dev_stats_get(struct rte_eth_dev *dev,
186 struct rte_eth_stats *stats);
187 static int ixgbe_dev_xstats_get(struct rte_eth_dev *dev,
188 struct rte_eth_xstat *xstats, unsigned n);
189 static int ixgbevf_dev_xstats_get(struct rte_eth_dev *dev,
190 struct rte_eth_xstat *xstats, unsigned n);
192 ixgbe_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids,
193 uint64_t *values, unsigned int n);
194 static void ixgbe_dev_stats_reset(struct rte_eth_dev *dev);
195 static void ixgbe_dev_xstats_reset(struct rte_eth_dev *dev);
196 static int ixgbe_dev_xstats_get_names(struct rte_eth_dev *dev,
197 struct rte_eth_xstat_name *xstats_names,
199 static int ixgbevf_dev_xstats_get_names(struct rte_eth_dev *dev,
200 struct rte_eth_xstat_name *xstats_names, unsigned limit);
201 static int ixgbe_dev_xstats_get_names_by_id(
202 struct rte_eth_dev *dev,
203 struct rte_eth_xstat_name *xstats_names,
206 static int ixgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
210 static int ixgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
212 static void ixgbe_dev_info_get(struct rte_eth_dev *dev,
213 struct rte_eth_dev_info *dev_info);
214 static const uint32_t *ixgbe_dev_supported_ptypes_get(struct rte_eth_dev *dev);
215 static void ixgbevf_dev_info_get(struct rte_eth_dev *dev,
216 struct rte_eth_dev_info *dev_info);
217 static int ixgbe_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
219 static int ixgbe_vlan_filter_set(struct rte_eth_dev *dev,
220 uint16_t vlan_id, int on);
221 static int ixgbe_vlan_tpid_set(struct rte_eth_dev *dev,
222 enum rte_vlan_type vlan_type,
224 static void ixgbe_vlan_hw_strip_bitmap_set(struct rte_eth_dev *dev,
225 uint16_t queue, bool on);
226 static void ixgbe_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue,
228 static int ixgbe_vlan_offload_set(struct rte_eth_dev *dev, int mask);
229 static void ixgbe_vlan_hw_strip_enable(struct rte_eth_dev *dev, uint16_t queue);
230 static void ixgbe_vlan_hw_strip_disable(struct rte_eth_dev *dev, uint16_t queue);
231 static void ixgbe_vlan_hw_extend_enable(struct rte_eth_dev *dev);
232 static void ixgbe_vlan_hw_extend_disable(struct rte_eth_dev *dev);
234 static int ixgbe_dev_led_on(struct rte_eth_dev *dev);
235 static int ixgbe_dev_led_off(struct rte_eth_dev *dev);
236 static int ixgbe_flow_ctrl_get(struct rte_eth_dev *dev,
237 struct rte_eth_fc_conf *fc_conf);
238 static int ixgbe_flow_ctrl_set(struct rte_eth_dev *dev,
239 struct rte_eth_fc_conf *fc_conf);
240 static int ixgbe_priority_flow_ctrl_set(struct rte_eth_dev *dev,
241 struct rte_eth_pfc_conf *pfc_conf);
242 static int ixgbe_dev_rss_reta_update(struct rte_eth_dev *dev,
243 struct rte_eth_rss_reta_entry64 *reta_conf,
245 static int ixgbe_dev_rss_reta_query(struct rte_eth_dev *dev,
246 struct rte_eth_rss_reta_entry64 *reta_conf,
248 static void ixgbe_dev_link_status_print(struct rte_eth_dev *dev);
249 static int ixgbe_dev_lsc_interrupt_setup(struct rte_eth_dev *dev, uint8_t on);
250 static int ixgbe_dev_macsec_interrupt_setup(struct rte_eth_dev *dev);
251 static int ixgbe_dev_rxq_interrupt_setup(struct rte_eth_dev *dev);
252 static int ixgbe_dev_interrupt_get_status(struct rte_eth_dev *dev);
253 static int ixgbe_dev_interrupt_action(struct rte_eth_dev *dev,
254 struct rte_intr_handle *handle);
255 static void ixgbe_dev_interrupt_handler(void *param);
256 static void ixgbe_dev_interrupt_delayed_handler(void *param);
257 static int ixgbe_add_rar(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
258 uint32_t index, uint32_t pool);
259 static void ixgbe_remove_rar(struct rte_eth_dev *dev, uint32_t index);
260 static void ixgbe_set_default_mac_addr(struct rte_eth_dev *dev,
261 struct ether_addr *mac_addr);
262 static void ixgbe_dcb_init(struct ixgbe_hw *hw, struct ixgbe_dcb_config *dcb_config);
263 static bool is_device_supported(struct rte_eth_dev *dev,
264 struct rte_pci_driver *drv);
266 /* For Virtual Function support */
267 static int eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev);
268 static int eth_ixgbevf_dev_uninit(struct rte_eth_dev *eth_dev);
269 static int ixgbevf_dev_configure(struct rte_eth_dev *dev);
270 static int ixgbevf_dev_start(struct rte_eth_dev *dev);
271 static int ixgbevf_dev_link_update(struct rte_eth_dev *dev,
272 int wait_to_complete);
273 static void ixgbevf_dev_stop(struct rte_eth_dev *dev);
274 static void ixgbevf_dev_close(struct rte_eth_dev *dev);
275 static int ixgbevf_dev_reset(struct rte_eth_dev *dev);
276 static void ixgbevf_intr_disable(struct ixgbe_hw *hw);
277 static void ixgbevf_intr_enable(struct ixgbe_hw *hw);
278 static int ixgbevf_dev_stats_get(struct rte_eth_dev *dev,
279 struct rte_eth_stats *stats);
280 static void ixgbevf_dev_stats_reset(struct rte_eth_dev *dev);
281 static int ixgbevf_vlan_filter_set(struct rte_eth_dev *dev,
282 uint16_t vlan_id, int on);
283 static void ixgbevf_vlan_strip_queue_set(struct rte_eth_dev *dev,
284 uint16_t queue, int on);
285 static int ixgbevf_vlan_offload_set(struct rte_eth_dev *dev, int mask);
286 static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on);
287 static int ixgbevf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev,
289 static int ixgbevf_dev_rx_queue_intr_disable(struct rte_eth_dev *dev,
291 static void ixgbevf_set_ivar_map(struct ixgbe_hw *hw, int8_t direction,
292 uint8_t queue, uint8_t msix_vector);
293 static void ixgbevf_configure_msix(struct rte_eth_dev *dev);
294 static void ixgbevf_dev_allmulticast_enable(struct rte_eth_dev *dev);
295 static void ixgbevf_dev_allmulticast_disable(struct rte_eth_dev *dev);
297 /* For Eth VMDQ APIs support */
298 static int ixgbe_uc_hash_table_set(struct rte_eth_dev *dev, struct
299 ether_addr * mac_addr, uint8_t on);
300 static int ixgbe_uc_all_hash_table_set(struct rte_eth_dev *dev, uint8_t on);
301 static int ixgbe_mirror_rule_set(struct rte_eth_dev *dev,
302 struct rte_eth_mirror_conf *mirror_conf,
303 uint8_t rule_id, uint8_t on);
304 static int ixgbe_mirror_rule_reset(struct rte_eth_dev *dev,
306 static int ixgbe_dev_rx_queue_intr_enable(struct rte_eth_dev *dev,
308 static int ixgbe_dev_rx_queue_intr_disable(struct rte_eth_dev *dev,
310 static void ixgbe_set_ivar_map(struct ixgbe_hw *hw, int8_t direction,
311 uint8_t queue, uint8_t msix_vector);
312 static void ixgbe_configure_msix(struct rte_eth_dev *dev);
314 static int ixgbevf_add_mac_addr(struct rte_eth_dev *dev,
315 struct ether_addr *mac_addr,
316 uint32_t index, uint32_t pool);
317 static void ixgbevf_remove_mac_addr(struct rte_eth_dev *dev, uint32_t index);
318 static void ixgbevf_set_default_mac_addr(struct rte_eth_dev *dev,
319 struct ether_addr *mac_addr);
320 static int ixgbe_syn_filter_get(struct rte_eth_dev *dev,
321 struct rte_eth_syn_filter *filter);
322 static int ixgbe_syn_filter_handle(struct rte_eth_dev *dev,
323 enum rte_filter_op filter_op,
325 static int ixgbe_add_5tuple_filter(struct rte_eth_dev *dev,
326 struct ixgbe_5tuple_filter *filter);
327 static void ixgbe_remove_5tuple_filter(struct rte_eth_dev *dev,
328 struct ixgbe_5tuple_filter *filter);
329 static int ixgbe_ntuple_filter_handle(struct rte_eth_dev *dev,
330 enum rte_filter_op filter_op,
332 static int ixgbe_get_ntuple_filter(struct rte_eth_dev *dev,
333 struct rte_eth_ntuple_filter *filter);
334 static int ixgbe_ethertype_filter_handle(struct rte_eth_dev *dev,
335 enum rte_filter_op filter_op,
337 static int ixgbe_get_ethertype_filter(struct rte_eth_dev *dev,
338 struct rte_eth_ethertype_filter *filter);
339 static int ixgbe_dev_filter_ctrl(struct rte_eth_dev *dev,
340 enum rte_filter_type filter_type,
341 enum rte_filter_op filter_op,
343 static int ixgbevf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu);
345 static int ixgbe_dev_set_mc_addr_list(struct rte_eth_dev *dev,
346 struct ether_addr *mc_addr_set,
347 uint32_t nb_mc_addr);
348 static int ixgbe_dev_get_dcb_info(struct rte_eth_dev *dev,
349 struct rte_eth_dcb_info *dcb_info);
351 static int ixgbe_get_reg_length(struct rte_eth_dev *dev);
352 static int ixgbe_get_regs(struct rte_eth_dev *dev,
353 struct rte_dev_reg_info *regs);
354 static int ixgbe_get_eeprom_length(struct rte_eth_dev *dev);
355 static int ixgbe_get_eeprom(struct rte_eth_dev *dev,
356 struct rte_dev_eeprom_info *eeprom);
357 static int ixgbe_set_eeprom(struct rte_eth_dev *dev,
358 struct rte_dev_eeprom_info *eeprom);
360 static int ixgbevf_get_reg_length(struct rte_eth_dev *dev);
361 static int ixgbevf_get_regs(struct rte_eth_dev *dev,
362 struct rte_dev_reg_info *regs);
364 static int ixgbe_timesync_enable(struct rte_eth_dev *dev);
365 static int ixgbe_timesync_disable(struct rte_eth_dev *dev);
366 static int ixgbe_timesync_read_rx_timestamp(struct rte_eth_dev *dev,
367 struct timespec *timestamp,
369 static int ixgbe_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
370 struct timespec *timestamp);
371 static int ixgbe_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta);
372 static int ixgbe_timesync_read_time(struct rte_eth_dev *dev,
373 struct timespec *timestamp);
374 static int ixgbe_timesync_write_time(struct rte_eth_dev *dev,
375 const struct timespec *timestamp);
376 static void ixgbevf_dev_interrupt_handler(void *param);
378 static int ixgbe_dev_l2_tunnel_eth_type_conf
379 (struct rte_eth_dev *dev, struct rte_eth_l2_tunnel_conf *l2_tunnel);
380 static int ixgbe_dev_l2_tunnel_offload_set
381 (struct rte_eth_dev *dev,
382 struct rte_eth_l2_tunnel_conf *l2_tunnel,
385 static int ixgbe_dev_l2_tunnel_filter_handle(struct rte_eth_dev *dev,
386 enum rte_filter_op filter_op,
389 static int ixgbe_dev_udp_tunnel_port_add(struct rte_eth_dev *dev,
390 struct rte_eth_udp_tunnel *udp_tunnel);
391 static int ixgbe_dev_udp_tunnel_port_del(struct rte_eth_dev *dev,
392 struct rte_eth_udp_tunnel *udp_tunnel);
393 static int ixgbe_filter_restore(struct rte_eth_dev *dev);
394 static void ixgbe_l2_tunnel_conf(struct rte_eth_dev *dev);
397 * Define VF Stats MACRO for Non "cleared on read" register
399 #define UPDATE_VF_STAT(reg, last, cur) \
401 uint32_t latest = IXGBE_READ_REG(hw, reg); \
402 cur += (latest - last) & UINT_MAX; \
406 #define UPDATE_VF_STAT_36BIT(lsb, msb, last, cur) \
408 u64 new_lsb = IXGBE_READ_REG(hw, lsb); \
409 u64 new_msb = IXGBE_READ_REG(hw, msb); \
410 u64 latest = ((new_msb << 32) | new_lsb); \
411 cur += (0x1000000000LL + latest - last) & 0xFFFFFFFFFLL; \
415 #define IXGBE_SET_HWSTRIP(h, q) do {\
416 uint32_t idx = (q) / (sizeof((h)->bitmap[0]) * NBBY); \
417 uint32_t bit = (q) % (sizeof((h)->bitmap[0]) * NBBY); \
418 (h)->bitmap[idx] |= 1 << bit;\
421 #define IXGBE_CLEAR_HWSTRIP(h, q) do {\
422 uint32_t idx = (q) / (sizeof((h)->bitmap[0]) * NBBY); \
423 uint32_t bit = (q) % (sizeof((h)->bitmap[0]) * NBBY); \
424 (h)->bitmap[idx] &= ~(1 << bit);\
427 #define IXGBE_GET_HWSTRIP(h, q, r) do {\
428 uint32_t idx = (q) / (sizeof((h)->bitmap[0]) * NBBY); \
429 uint32_t bit = (q) % (sizeof((h)->bitmap[0]) * NBBY); \
430 (r) = (h)->bitmap[idx] >> bit & 1;\
434 * The set of PCI devices this driver supports
436 static const struct rte_pci_id pci_id_ixgbe_map[] = {
437 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598) },
438 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598_BX) },
439 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AF_DUAL_PORT) },
440 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AF_SINGLE_PORT) },
441 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AT) },
442 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AT2) },
443 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598EB_SFP_LOM) },
444 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598EB_CX4) },
445 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598_CX4_DUAL_PORT) },
446 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598_DA_DUAL_PORT) },
447 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM) },
448 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598EB_XF_LR) },
449 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_KX4) },
450 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_KX4_MEZZ) },
451 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_KR) },
452 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_COMBO_BACKPLANE) },
453 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_CX4) },
454 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP) },
455 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_BACKPLANE_FCOE) },
456 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP_FCOE) },
457 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP_EM) },
458 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP_SF2) },
459 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP_SF_QP) },
460 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_QSFP_SF_QP) },
461 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599EN_SFP) },
462 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_XAUI_LOM) },
463 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_T3_LOM) },
464 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_LS) },
465 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X540T) },
466 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X540T1) },
467 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_SFP) },
468 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_10G_T) },
469 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_1G_T) },
470 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550T) },
471 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550T1) },
472 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_KR) },
473 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_KR_L) },
474 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_SFP_N) },
475 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_SGMII) },
476 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_SGMII_L) },
477 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_10G_T) },
478 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_QSFP) },
479 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_QSFP_N) },
480 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_SFP) },
481 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_1G_T) },
482 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_1G_T_L) },
483 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_KX4) },
484 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_KR) },
485 #ifdef RTE_LIBRTE_IXGBE_BYPASS
486 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_BYPASS) },
488 { .vendor_id = 0, /* sentinel */ },
492 * The set of PCI devices this driver supports (for 82599 VF)
494 static const struct rte_pci_id pci_id_ixgbevf_map[] = {
495 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_VF) },
496 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_VF_HV) },
497 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X540_VF) },
498 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X540_VF_HV) },
499 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550_VF_HV) },
500 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550_VF) },
501 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_VF) },
502 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_VF_HV) },
503 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_VF) },
504 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_VF_HV) },
505 { .vendor_id = 0, /* sentinel */ },
508 static const struct rte_eth_desc_lim rx_desc_lim = {
509 .nb_max = IXGBE_MAX_RING_DESC,
510 .nb_min = IXGBE_MIN_RING_DESC,
511 .nb_align = IXGBE_RXD_ALIGN,
514 static const struct rte_eth_desc_lim tx_desc_lim = {
515 .nb_max = IXGBE_MAX_RING_DESC,
516 .nb_min = IXGBE_MIN_RING_DESC,
517 .nb_align = IXGBE_TXD_ALIGN,
518 .nb_seg_max = IXGBE_TX_MAX_SEG,
519 .nb_mtu_seg_max = IXGBE_TX_MAX_SEG,
522 static const struct eth_dev_ops ixgbe_eth_dev_ops = {
523 .dev_configure = ixgbe_dev_configure,
524 .dev_start = ixgbe_dev_start,
525 .dev_stop = ixgbe_dev_stop,
526 .dev_set_link_up = ixgbe_dev_set_link_up,
527 .dev_set_link_down = ixgbe_dev_set_link_down,
528 .dev_close = ixgbe_dev_close,
529 .dev_reset = ixgbe_dev_reset,
530 .promiscuous_enable = ixgbe_dev_promiscuous_enable,
531 .promiscuous_disable = ixgbe_dev_promiscuous_disable,
532 .allmulticast_enable = ixgbe_dev_allmulticast_enable,
533 .allmulticast_disable = ixgbe_dev_allmulticast_disable,
534 .link_update = ixgbe_dev_link_update,
535 .stats_get = ixgbe_dev_stats_get,
536 .xstats_get = ixgbe_dev_xstats_get,
537 .xstats_get_by_id = ixgbe_dev_xstats_get_by_id,
538 .stats_reset = ixgbe_dev_stats_reset,
539 .xstats_reset = ixgbe_dev_xstats_reset,
540 .xstats_get_names = ixgbe_dev_xstats_get_names,
541 .xstats_get_names_by_id = ixgbe_dev_xstats_get_names_by_id,
542 .queue_stats_mapping_set = ixgbe_dev_queue_stats_mapping_set,
543 .fw_version_get = ixgbe_fw_version_get,
544 .dev_infos_get = ixgbe_dev_info_get,
545 .dev_supported_ptypes_get = ixgbe_dev_supported_ptypes_get,
546 .mtu_set = ixgbe_dev_mtu_set,
547 .vlan_filter_set = ixgbe_vlan_filter_set,
548 .vlan_tpid_set = ixgbe_vlan_tpid_set,
549 .vlan_offload_set = ixgbe_vlan_offload_set,
550 .vlan_strip_queue_set = ixgbe_vlan_strip_queue_set,
551 .rx_queue_start = ixgbe_dev_rx_queue_start,
552 .rx_queue_stop = ixgbe_dev_rx_queue_stop,
553 .tx_queue_start = ixgbe_dev_tx_queue_start,
554 .tx_queue_stop = ixgbe_dev_tx_queue_stop,
555 .rx_queue_setup = ixgbe_dev_rx_queue_setup,
556 .rx_queue_intr_enable = ixgbe_dev_rx_queue_intr_enable,
557 .rx_queue_intr_disable = ixgbe_dev_rx_queue_intr_disable,
558 .rx_queue_release = ixgbe_dev_rx_queue_release,
559 .rx_queue_count = ixgbe_dev_rx_queue_count,
560 .rx_descriptor_done = ixgbe_dev_rx_descriptor_done,
561 .rx_descriptor_status = ixgbe_dev_rx_descriptor_status,
562 .tx_descriptor_status = ixgbe_dev_tx_descriptor_status,
563 .tx_queue_setup = ixgbe_dev_tx_queue_setup,
564 .tx_queue_release = ixgbe_dev_tx_queue_release,
565 .dev_led_on = ixgbe_dev_led_on,
566 .dev_led_off = ixgbe_dev_led_off,
567 .flow_ctrl_get = ixgbe_flow_ctrl_get,
568 .flow_ctrl_set = ixgbe_flow_ctrl_set,
569 .priority_flow_ctrl_set = ixgbe_priority_flow_ctrl_set,
570 .mac_addr_add = ixgbe_add_rar,
571 .mac_addr_remove = ixgbe_remove_rar,
572 .mac_addr_set = ixgbe_set_default_mac_addr,
573 .uc_hash_table_set = ixgbe_uc_hash_table_set,
574 .uc_all_hash_table_set = ixgbe_uc_all_hash_table_set,
575 .mirror_rule_set = ixgbe_mirror_rule_set,
576 .mirror_rule_reset = ixgbe_mirror_rule_reset,
577 .set_queue_rate_limit = ixgbe_set_queue_rate_limit,
578 .reta_update = ixgbe_dev_rss_reta_update,
579 .reta_query = ixgbe_dev_rss_reta_query,
580 .rss_hash_update = ixgbe_dev_rss_hash_update,
581 .rss_hash_conf_get = ixgbe_dev_rss_hash_conf_get,
582 .filter_ctrl = ixgbe_dev_filter_ctrl,
583 .set_mc_addr_list = ixgbe_dev_set_mc_addr_list,
584 .rxq_info_get = ixgbe_rxq_info_get,
585 .txq_info_get = ixgbe_txq_info_get,
586 .timesync_enable = ixgbe_timesync_enable,
587 .timesync_disable = ixgbe_timesync_disable,
588 .timesync_read_rx_timestamp = ixgbe_timesync_read_rx_timestamp,
589 .timesync_read_tx_timestamp = ixgbe_timesync_read_tx_timestamp,
590 .get_reg = ixgbe_get_regs,
591 .get_eeprom_length = ixgbe_get_eeprom_length,
592 .get_eeprom = ixgbe_get_eeprom,
593 .set_eeprom = ixgbe_set_eeprom,
594 .get_dcb_info = ixgbe_dev_get_dcb_info,
595 .timesync_adjust_time = ixgbe_timesync_adjust_time,
596 .timesync_read_time = ixgbe_timesync_read_time,
597 .timesync_write_time = ixgbe_timesync_write_time,
598 .l2_tunnel_eth_type_conf = ixgbe_dev_l2_tunnel_eth_type_conf,
599 .l2_tunnel_offload_set = ixgbe_dev_l2_tunnel_offload_set,
600 .udp_tunnel_port_add = ixgbe_dev_udp_tunnel_port_add,
601 .udp_tunnel_port_del = ixgbe_dev_udp_tunnel_port_del,
602 .tm_ops_get = ixgbe_tm_ops_get,
606 * dev_ops for virtual function, bare necessities for basic vf
607 * operation have been implemented
609 static const struct eth_dev_ops ixgbevf_eth_dev_ops = {
610 .dev_configure = ixgbevf_dev_configure,
611 .dev_start = ixgbevf_dev_start,
612 .dev_stop = ixgbevf_dev_stop,
613 .link_update = ixgbevf_dev_link_update,
614 .stats_get = ixgbevf_dev_stats_get,
615 .xstats_get = ixgbevf_dev_xstats_get,
616 .stats_reset = ixgbevf_dev_stats_reset,
617 .xstats_reset = ixgbevf_dev_stats_reset,
618 .xstats_get_names = ixgbevf_dev_xstats_get_names,
619 .dev_close = ixgbevf_dev_close,
620 .dev_reset = ixgbevf_dev_reset,
621 .allmulticast_enable = ixgbevf_dev_allmulticast_enable,
622 .allmulticast_disable = ixgbevf_dev_allmulticast_disable,
623 .dev_infos_get = ixgbevf_dev_info_get,
624 .dev_supported_ptypes_get = ixgbe_dev_supported_ptypes_get,
625 .mtu_set = ixgbevf_dev_set_mtu,
626 .vlan_filter_set = ixgbevf_vlan_filter_set,
627 .vlan_strip_queue_set = ixgbevf_vlan_strip_queue_set,
628 .vlan_offload_set = ixgbevf_vlan_offload_set,
629 .rx_queue_setup = ixgbe_dev_rx_queue_setup,
630 .rx_queue_release = ixgbe_dev_rx_queue_release,
631 .rx_descriptor_done = ixgbe_dev_rx_descriptor_done,
632 .rx_descriptor_status = ixgbe_dev_rx_descriptor_status,
633 .tx_descriptor_status = ixgbe_dev_tx_descriptor_status,
634 .tx_queue_setup = ixgbe_dev_tx_queue_setup,
635 .tx_queue_release = ixgbe_dev_tx_queue_release,
636 .rx_queue_intr_enable = ixgbevf_dev_rx_queue_intr_enable,
637 .rx_queue_intr_disable = ixgbevf_dev_rx_queue_intr_disable,
638 .mac_addr_add = ixgbevf_add_mac_addr,
639 .mac_addr_remove = ixgbevf_remove_mac_addr,
640 .set_mc_addr_list = ixgbe_dev_set_mc_addr_list,
641 .rxq_info_get = ixgbe_rxq_info_get,
642 .txq_info_get = ixgbe_txq_info_get,
643 .mac_addr_set = ixgbevf_set_default_mac_addr,
644 .get_reg = ixgbevf_get_regs,
645 .reta_update = ixgbe_dev_rss_reta_update,
646 .reta_query = ixgbe_dev_rss_reta_query,
647 .rss_hash_update = ixgbe_dev_rss_hash_update,
648 .rss_hash_conf_get = ixgbe_dev_rss_hash_conf_get,
651 /* store statistics names and its offset in stats structure */
652 struct rte_ixgbe_xstats_name_off {
653 char name[RTE_ETH_XSTATS_NAME_SIZE];
657 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_stats_strings[] = {
658 {"rx_crc_errors", offsetof(struct ixgbe_hw_stats, crcerrs)},
659 {"rx_illegal_byte_errors", offsetof(struct ixgbe_hw_stats, illerrc)},
660 {"rx_error_bytes", offsetof(struct ixgbe_hw_stats, errbc)},
661 {"mac_local_errors", offsetof(struct ixgbe_hw_stats, mlfc)},
662 {"mac_remote_errors", offsetof(struct ixgbe_hw_stats, mrfc)},
663 {"rx_length_errors", offsetof(struct ixgbe_hw_stats, rlec)},
664 {"tx_xon_packets", offsetof(struct ixgbe_hw_stats, lxontxc)},
665 {"rx_xon_packets", offsetof(struct ixgbe_hw_stats, lxonrxc)},
666 {"tx_xoff_packets", offsetof(struct ixgbe_hw_stats, lxofftxc)},
667 {"rx_xoff_packets", offsetof(struct ixgbe_hw_stats, lxoffrxc)},
668 {"rx_size_64_packets", offsetof(struct ixgbe_hw_stats, prc64)},
669 {"rx_size_65_to_127_packets", offsetof(struct ixgbe_hw_stats, prc127)},
670 {"rx_size_128_to_255_packets", offsetof(struct ixgbe_hw_stats, prc255)},
671 {"rx_size_256_to_511_packets", offsetof(struct ixgbe_hw_stats, prc511)},
672 {"rx_size_512_to_1023_packets", offsetof(struct ixgbe_hw_stats,
674 {"rx_size_1024_to_max_packets", offsetof(struct ixgbe_hw_stats,
676 {"rx_broadcast_packets", offsetof(struct ixgbe_hw_stats, bprc)},
677 {"rx_multicast_packets", offsetof(struct ixgbe_hw_stats, mprc)},
678 {"rx_fragment_errors", offsetof(struct ixgbe_hw_stats, rfc)},
679 {"rx_undersize_errors", offsetof(struct ixgbe_hw_stats, ruc)},
680 {"rx_oversize_errors", offsetof(struct ixgbe_hw_stats, roc)},
681 {"rx_jabber_errors", offsetof(struct ixgbe_hw_stats, rjc)},
682 {"rx_management_packets", offsetof(struct ixgbe_hw_stats, mngprc)},
683 {"rx_management_dropped", offsetof(struct ixgbe_hw_stats, mngpdc)},
684 {"tx_management_packets", offsetof(struct ixgbe_hw_stats, mngptc)},
685 {"rx_total_packets", offsetof(struct ixgbe_hw_stats, tpr)},
686 {"rx_total_bytes", offsetof(struct ixgbe_hw_stats, tor)},
687 {"tx_total_packets", offsetof(struct ixgbe_hw_stats, tpt)},
688 {"tx_size_64_packets", offsetof(struct ixgbe_hw_stats, ptc64)},
689 {"tx_size_65_to_127_packets", offsetof(struct ixgbe_hw_stats, ptc127)},
690 {"tx_size_128_to_255_packets", offsetof(struct ixgbe_hw_stats, ptc255)},
691 {"tx_size_256_to_511_packets", offsetof(struct ixgbe_hw_stats, ptc511)},
692 {"tx_size_512_to_1023_packets", offsetof(struct ixgbe_hw_stats,
694 {"tx_size_1024_to_max_packets", offsetof(struct ixgbe_hw_stats,
696 {"tx_multicast_packets", offsetof(struct ixgbe_hw_stats, mptc)},
697 {"tx_broadcast_packets", offsetof(struct ixgbe_hw_stats, bptc)},
698 {"rx_mac_short_packet_dropped", offsetof(struct ixgbe_hw_stats, mspdc)},
699 {"rx_l3_l4_xsum_error", offsetof(struct ixgbe_hw_stats, xec)},
701 {"flow_director_added_filters", offsetof(struct ixgbe_hw_stats,
703 {"flow_director_removed_filters", offsetof(struct ixgbe_hw_stats,
705 {"flow_director_filter_add_errors", offsetof(struct ixgbe_hw_stats,
707 {"flow_director_filter_remove_errors", offsetof(struct ixgbe_hw_stats,
709 {"flow_director_matched_filters", offsetof(struct ixgbe_hw_stats,
711 {"flow_director_missed_filters", offsetof(struct ixgbe_hw_stats,
714 {"rx_fcoe_crc_errors", offsetof(struct ixgbe_hw_stats, fccrc)},
715 {"rx_fcoe_dropped", offsetof(struct ixgbe_hw_stats, fcoerpdc)},
716 {"rx_fcoe_mbuf_allocation_errors", offsetof(struct ixgbe_hw_stats,
718 {"rx_fcoe_packets", offsetof(struct ixgbe_hw_stats, fcoeprc)},
719 {"tx_fcoe_packets", offsetof(struct ixgbe_hw_stats, fcoeptc)},
720 {"rx_fcoe_bytes", offsetof(struct ixgbe_hw_stats, fcoedwrc)},
721 {"tx_fcoe_bytes", offsetof(struct ixgbe_hw_stats, fcoedwtc)},
722 {"rx_fcoe_no_direct_data_placement", offsetof(struct ixgbe_hw_stats,
724 {"rx_fcoe_no_direct_data_placement_ext_buff",
725 offsetof(struct ixgbe_hw_stats, fcoe_noddp_ext_buff)},
727 {"tx_flow_control_xon_packets", offsetof(struct ixgbe_hw_stats,
729 {"rx_flow_control_xon_packets", offsetof(struct ixgbe_hw_stats,
731 {"tx_flow_control_xoff_packets", offsetof(struct ixgbe_hw_stats,
733 {"rx_flow_control_xoff_packets", offsetof(struct ixgbe_hw_stats,
735 {"rx_total_missed_packets", offsetof(struct ixgbe_hw_stats, mpctotal)},
738 #define IXGBE_NB_HW_STATS (sizeof(rte_ixgbe_stats_strings) / \
739 sizeof(rte_ixgbe_stats_strings[0]))
741 /* MACsec statistics */
742 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_macsec_strings[] = {
743 {"out_pkts_untagged", offsetof(struct ixgbe_macsec_stats,
745 {"out_pkts_encrypted", offsetof(struct ixgbe_macsec_stats,
746 out_pkts_encrypted)},
747 {"out_pkts_protected", offsetof(struct ixgbe_macsec_stats,
748 out_pkts_protected)},
749 {"out_octets_encrypted", offsetof(struct ixgbe_macsec_stats,
750 out_octets_encrypted)},
751 {"out_octets_protected", offsetof(struct ixgbe_macsec_stats,
752 out_octets_protected)},
753 {"in_pkts_untagged", offsetof(struct ixgbe_macsec_stats,
755 {"in_pkts_badtag", offsetof(struct ixgbe_macsec_stats,
757 {"in_pkts_nosci", offsetof(struct ixgbe_macsec_stats,
759 {"in_pkts_unknownsci", offsetof(struct ixgbe_macsec_stats,
760 in_pkts_unknownsci)},
761 {"in_octets_decrypted", offsetof(struct ixgbe_macsec_stats,
762 in_octets_decrypted)},
763 {"in_octets_validated", offsetof(struct ixgbe_macsec_stats,
764 in_octets_validated)},
765 {"in_pkts_unchecked", offsetof(struct ixgbe_macsec_stats,
767 {"in_pkts_delayed", offsetof(struct ixgbe_macsec_stats,
769 {"in_pkts_late", offsetof(struct ixgbe_macsec_stats,
771 {"in_pkts_ok", offsetof(struct ixgbe_macsec_stats,
773 {"in_pkts_invalid", offsetof(struct ixgbe_macsec_stats,
775 {"in_pkts_notvalid", offsetof(struct ixgbe_macsec_stats,
777 {"in_pkts_unusedsa", offsetof(struct ixgbe_macsec_stats,
779 {"in_pkts_notusingsa", offsetof(struct ixgbe_macsec_stats,
780 in_pkts_notusingsa)},
783 #define IXGBE_NB_MACSEC_STATS (sizeof(rte_ixgbe_macsec_strings) / \
784 sizeof(rte_ixgbe_macsec_strings[0]))
786 /* Per-queue statistics */
787 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_rxq_strings[] = {
788 {"mbuf_allocation_errors", offsetof(struct ixgbe_hw_stats, rnbc)},
789 {"dropped", offsetof(struct ixgbe_hw_stats, mpc)},
790 {"xon_packets", offsetof(struct ixgbe_hw_stats, pxonrxc)},
791 {"xoff_packets", offsetof(struct ixgbe_hw_stats, pxoffrxc)},
794 #define IXGBE_NB_RXQ_PRIO_STATS (sizeof(rte_ixgbe_rxq_strings) / \
795 sizeof(rte_ixgbe_rxq_strings[0]))
796 #define IXGBE_NB_RXQ_PRIO_VALUES 8
798 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_txq_strings[] = {
799 {"xon_packets", offsetof(struct ixgbe_hw_stats, pxontxc)},
800 {"xoff_packets", offsetof(struct ixgbe_hw_stats, pxofftxc)},
801 {"xon_to_xoff_packets", offsetof(struct ixgbe_hw_stats,
805 #define IXGBE_NB_TXQ_PRIO_STATS (sizeof(rte_ixgbe_txq_strings) / \
806 sizeof(rte_ixgbe_txq_strings[0]))
807 #define IXGBE_NB_TXQ_PRIO_VALUES 8
809 static const struct rte_ixgbe_xstats_name_off rte_ixgbevf_stats_strings[] = {
810 {"rx_multicast_packets", offsetof(struct ixgbevf_hw_stats, vfmprc)},
813 #define IXGBEVF_NB_XSTATS (sizeof(rte_ixgbevf_stats_strings) / \
814 sizeof(rte_ixgbevf_stats_strings[0]))
817 * Atomically reads the link status information from global
818 * structure rte_eth_dev.
821 * - Pointer to the structure rte_eth_dev to read from.
822 * - Pointer to the buffer to be saved with the link status.
825 * - On success, zero.
826 * - On failure, negative value.
829 rte_ixgbe_dev_atomic_read_link_status(struct rte_eth_dev *dev,
830 struct rte_eth_link *link)
832 struct rte_eth_link *dst = link;
833 struct rte_eth_link *src = &(dev->data->dev_link);
835 if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
836 *(uint64_t *)src) == 0)
843 * Atomically writes the link status information into global
844 * structure rte_eth_dev.
847 * - Pointer to the structure rte_eth_dev to read from.
848 * - Pointer to the buffer to be saved with the link status.
851 * - On success, zero.
852 * - On failure, negative value.
855 rte_ixgbe_dev_atomic_write_link_status(struct rte_eth_dev *dev,
856 struct rte_eth_link *link)
858 struct rte_eth_link *dst = &(dev->data->dev_link);
859 struct rte_eth_link *src = link;
861 if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
862 *(uint64_t *)src) == 0)
869 * This function is the same as ixgbe_is_sfp() in base/ixgbe.h.
872 ixgbe_is_sfp(struct ixgbe_hw *hw)
874 switch (hw->phy.type) {
875 case ixgbe_phy_sfp_avago:
876 case ixgbe_phy_sfp_ftl:
877 case ixgbe_phy_sfp_intel:
878 case ixgbe_phy_sfp_unknown:
879 case ixgbe_phy_sfp_passive_tyco:
880 case ixgbe_phy_sfp_passive_unknown:
887 static inline int32_t
888 ixgbe_pf_reset_hw(struct ixgbe_hw *hw)
893 status = ixgbe_reset_hw(hw);
895 ctrl_ext = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
896 /* Set PF Reset Done bit so PF/VF Mail Ops can work */
897 ctrl_ext |= IXGBE_CTRL_EXT_PFRSTD;
898 IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl_ext);
899 IXGBE_WRITE_FLUSH(hw);
901 if (status == IXGBE_ERR_SFP_NOT_PRESENT)
902 status = IXGBE_SUCCESS;
907 ixgbe_enable_intr(struct rte_eth_dev *dev)
909 struct ixgbe_interrupt *intr =
910 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
911 struct ixgbe_hw *hw =
912 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
914 IXGBE_WRITE_REG(hw, IXGBE_EIMS, intr->mask);
915 IXGBE_WRITE_FLUSH(hw);
919 * This function is based on ixgbe_disable_intr() in base/ixgbe.h.
922 ixgbe_disable_intr(struct ixgbe_hw *hw)
924 PMD_INIT_FUNC_TRACE();
926 if (hw->mac.type == ixgbe_mac_82598EB) {
927 IXGBE_WRITE_REG(hw, IXGBE_EIMC, ~0);
929 IXGBE_WRITE_REG(hw, IXGBE_EIMC, 0xFFFF0000);
930 IXGBE_WRITE_REG(hw, IXGBE_EIMC_EX(0), ~0);
931 IXGBE_WRITE_REG(hw, IXGBE_EIMC_EX(1), ~0);
933 IXGBE_WRITE_FLUSH(hw);
937 * This function resets queue statistics mapping registers.
938 * From Niantic datasheet, Initialization of Statistics section:
939 * "...if software requires the queue counters, the RQSMR and TQSM registers
940 * must be re-programmed following a device reset.
943 ixgbe_reset_qstat_mappings(struct ixgbe_hw *hw)
947 for (i = 0; i != IXGBE_NB_STAT_MAPPING_REGS; i++) {
948 IXGBE_WRITE_REG(hw, IXGBE_RQSMR(i), 0);
949 IXGBE_WRITE_REG(hw, IXGBE_TQSM(i), 0);
955 ixgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
960 #define QSM_REG_NB_BITS_PER_QMAP_FIELD 8
961 #define NB_QMAP_FIELDS_PER_QSM_REG 4
962 #define QMAP_FIELD_RESERVED_BITS_MASK 0x0f
964 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
965 struct ixgbe_stat_mapping_registers *stat_mappings =
966 IXGBE_DEV_PRIVATE_TO_STAT_MAPPINGS(eth_dev->data->dev_private);
967 uint32_t qsmr_mask = 0;
968 uint32_t clearing_mask = QMAP_FIELD_RESERVED_BITS_MASK;
972 if ((hw->mac.type != ixgbe_mac_82599EB) &&
973 (hw->mac.type != ixgbe_mac_X540) &&
974 (hw->mac.type != ixgbe_mac_X550) &&
975 (hw->mac.type != ixgbe_mac_X550EM_x) &&
976 (hw->mac.type != ixgbe_mac_X550EM_a))
979 PMD_INIT_LOG(DEBUG, "Setting port %d, %s queue_id %d to stat index %d",
980 (int)(eth_dev->data->port_id), is_rx ? "RX" : "TX",
983 n = (uint8_t)(queue_id / NB_QMAP_FIELDS_PER_QSM_REG);
984 if (n >= IXGBE_NB_STAT_MAPPING_REGS) {
985 PMD_INIT_LOG(ERR, "Nb of stat mapping registers exceeded");
988 offset = (uint8_t)(queue_id % NB_QMAP_FIELDS_PER_QSM_REG);
990 /* Now clear any previous stat_idx set */
991 clearing_mask <<= (QSM_REG_NB_BITS_PER_QMAP_FIELD * offset);
993 stat_mappings->tqsm[n] &= ~clearing_mask;
995 stat_mappings->rqsmr[n] &= ~clearing_mask;
997 q_map = (uint32_t)stat_idx;
998 q_map &= QMAP_FIELD_RESERVED_BITS_MASK;
999 qsmr_mask = q_map << (QSM_REG_NB_BITS_PER_QMAP_FIELD * offset);
1001 stat_mappings->tqsm[n] |= qsmr_mask;
1003 stat_mappings->rqsmr[n] |= qsmr_mask;
1005 PMD_INIT_LOG(DEBUG, "Set port %d, %s queue_id %d to stat index %d",
1006 (int)(eth_dev->data->port_id), is_rx ? "RX" : "TX",
1007 queue_id, stat_idx);
1008 PMD_INIT_LOG(DEBUG, "%s[%d] = 0x%08x", is_rx ? "RQSMR" : "TQSM", n,
1009 is_rx ? stat_mappings->rqsmr[n] : stat_mappings->tqsm[n]);
1011 /* Now write the mapping in the appropriate register */
1013 PMD_INIT_LOG(DEBUG, "Write 0x%x to RX IXGBE stat mapping reg:%d",
1014 stat_mappings->rqsmr[n], n);
1015 IXGBE_WRITE_REG(hw, IXGBE_RQSMR(n), stat_mappings->rqsmr[n]);
1017 PMD_INIT_LOG(DEBUG, "Write 0x%x to TX IXGBE stat mapping reg:%d",
1018 stat_mappings->tqsm[n], n);
1019 IXGBE_WRITE_REG(hw, IXGBE_TQSM(n), stat_mappings->tqsm[n]);
1025 ixgbe_restore_statistics_mapping(struct rte_eth_dev *dev)
1027 struct ixgbe_stat_mapping_registers *stat_mappings =
1028 IXGBE_DEV_PRIVATE_TO_STAT_MAPPINGS(dev->data->dev_private);
1029 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1032 /* write whatever was in stat mapping table to the NIC */
1033 for (i = 0; i < IXGBE_NB_STAT_MAPPING_REGS; i++) {
1035 IXGBE_WRITE_REG(hw, IXGBE_RQSMR(i), stat_mappings->rqsmr[i]);
1038 IXGBE_WRITE_REG(hw, IXGBE_TQSM(i), stat_mappings->tqsm[i]);
1043 ixgbe_dcb_init(struct ixgbe_hw *hw, struct ixgbe_dcb_config *dcb_config)
1046 struct ixgbe_dcb_tc_config *tc;
1047 uint8_t dcb_max_tc = IXGBE_DCB_MAX_TRAFFIC_CLASS;
1049 dcb_config->num_tcs.pg_tcs = dcb_max_tc;
1050 dcb_config->num_tcs.pfc_tcs = dcb_max_tc;
1051 for (i = 0; i < dcb_max_tc; i++) {
1052 tc = &dcb_config->tc_config[i];
1053 tc->path[IXGBE_DCB_TX_CONFIG].bwg_id = i;
1054 tc->path[IXGBE_DCB_TX_CONFIG].bwg_percent =
1055 (uint8_t)(100/dcb_max_tc + (i & 1));
1056 tc->path[IXGBE_DCB_RX_CONFIG].bwg_id = i;
1057 tc->path[IXGBE_DCB_RX_CONFIG].bwg_percent =
1058 (uint8_t)(100/dcb_max_tc + (i & 1));
1059 tc->pfc = ixgbe_dcb_pfc_disabled;
1062 /* Initialize default user to priority mapping, UPx->TC0 */
1063 tc = &dcb_config->tc_config[0];
1064 tc->path[IXGBE_DCB_TX_CONFIG].up_to_tc_bitmap = 0xFF;
1065 tc->path[IXGBE_DCB_RX_CONFIG].up_to_tc_bitmap = 0xFF;
1066 for (i = 0; i < IXGBE_DCB_MAX_BW_GROUP; i++) {
1067 dcb_config->bw_percentage[IXGBE_DCB_TX_CONFIG][i] = 100;
1068 dcb_config->bw_percentage[IXGBE_DCB_RX_CONFIG][i] = 100;
1070 dcb_config->rx_pba_cfg = ixgbe_dcb_pba_equal;
1071 dcb_config->pfc_mode_enable = false;
1072 dcb_config->vt_mode = true;
1073 dcb_config->round_robin_enable = false;
1074 /* support all DCB capabilities in 82599 */
1075 dcb_config->support.capabilities = 0xFF;
1077 /*we only support 4 Tcs for X540, X550 */
1078 if (hw->mac.type == ixgbe_mac_X540 ||
1079 hw->mac.type == ixgbe_mac_X550 ||
1080 hw->mac.type == ixgbe_mac_X550EM_x ||
1081 hw->mac.type == ixgbe_mac_X550EM_a) {
1082 dcb_config->num_tcs.pg_tcs = 4;
1083 dcb_config->num_tcs.pfc_tcs = 4;
1088 * Ensure that all locks are released before first NVM or PHY access
1091 ixgbe_swfw_lock_reset(struct ixgbe_hw *hw)
1096 * Phy lock should not fail in this early stage. If this is the case,
1097 * it is due to an improper exit of the application.
1098 * So force the release of the faulty lock. Release of common lock
1099 * is done automatically by swfw_sync function.
1101 mask = IXGBE_GSSR_PHY0_SM << hw->bus.func;
1102 if (ixgbe_acquire_swfw_semaphore(hw, mask) < 0) {
1103 PMD_DRV_LOG(DEBUG, "SWFW phy%d lock released", hw->bus.func);
1105 ixgbe_release_swfw_semaphore(hw, mask);
1108 * These ones are more tricky since they are common to all ports; but
1109 * swfw_sync retries last long enough (1s) to be almost sure that if
1110 * lock can not be taken it is due to an improper lock of the
1113 mask = IXGBE_GSSR_EEP_SM | IXGBE_GSSR_MAC_CSR_SM | IXGBE_GSSR_SW_MNG_SM;
1114 if (ixgbe_acquire_swfw_semaphore(hw, mask) < 0) {
1115 PMD_DRV_LOG(DEBUG, "SWFW common locks released");
1117 ixgbe_release_swfw_semaphore(hw, mask);
1121 * This function is based on code in ixgbe_attach() in base/ixgbe.c.
1122 * It returns 0 on success.
1125 eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev)
1127 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
1128 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
1129 struct ixgbe_hw *hw =
1130 IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
1131 struct ixgbe_vfta *shadow_vfta =
1132 IXGBE_DEV_PRIVATE_TO_VFTA(eth_dev->data->dev_private);
1133 struct ixgbe_hwstrip *hwstrip =
1134 IXGBE_DEV_PRIVATE_TO_HWSTRIP_BITMAP(eth_dev->data->dev_private);
1135 struct ixgbe_dcb_config *dcb_config =
1136 IXGBE_DEV_PRIVATE_TO_DCB_CFG(eth_dev->data->dev_private);
1137 struct ixgbe_filter_info *filter_info =
1138 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(eth_dev->data->dev_private);
1139 struct ixgbe_bw_conf *bw_conf =
1140 IXGBE_DEV_PRIVATE_TO_BW_CONF(eth_dev->data->dev_private);
1145 PMD_INIT_FUNC_TRACE();
1147 eth_dev->dev_ops = &ixgbe_eth_dev_ops;
1148 eth_dev->rx_pkt_burst = &ixgbe_recv_pkts;
1149 eth_dev->tx_pkt_burst = &ixgbe_xmit_pkts;
1150 eth_dev->tx_pkt_prepare = &ixgbe_prep_pkts;
1153 * For secondary processes, we don't initialise any further as primary
1154 * has already done this work. Only check we don't need a different
1155 * RX and TX function.
1157 if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
1158 struct ixgbe_tx_queue *txq;
1159 /* TX queue function in primary, set by last queue initialized
1160 * Tx queue may not initialized by primary process
1162 if (eth_dev->data->tx_queues) {
1163 txq = eth_dev->data->tx_queues[eth_dev->data->nb_tx_queues-1];
1164 ixgbe_set_tx_function(eth_dev, txq);
1166 /* Use default TX function if we get here */
1167 PMD_INIT_LOG(NOTICE, "No TX queues configured yet. "
1168 "Using default TX function.");
1171 ixgbe_set_rx_function(eth_dev);
1176 #ifdef RTE_LIBRTE_SECURITY
1177 /* Initialize security_ctx only for primary process*/
1178 eth_dev->security_ctx = ixgbe_ipsec_ctx_create(eth_dev);
1179 if (eth_dev->security_ctx == NULL)
1183 rte_eth_copy_pci_info(eth_dev, pci_dev);
1185 /* Vendor and Device ID need to be set before init of shared code */
1186 hw->device_id = pci_dev->id.device_id;
1187 hw->vendor_id = pci_dev->id.vendor_id;
1188 hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
1189 hw->allow_unsupported_sfp = 1;
1191 /* Initialize the shared code (base driver) */
1192 #ifdef RTE_LIBRTE_IXGBE_BYPASS
1193 diag = ixgbe_bypass_init_shared_code(hw);
1195 diag = ixgbe_init_shared_code(hw);
1196 #endif /* RTE_LIBRTE_IXGBE_BYPASS */
1198 if (diag != IXGBE_SUCCESS) {
1199 PMD_INIT_LOG(ERR, "Shared code init failed: %d", diag);
1203 /* pick up the PCI bus settings for reporting later */
1204 ixgbe_get_bus_info(hw);
1206 /* Unlock any pending hardware semaphore */
1207 ixgbe_swfw_lock_reset(hw);
1209 /* Initialize DCB configuration*/
1210 memset(dcb_config, 0, sizeof(struct ixgbe_dcb_config));
1211 ixgbe_dcb_init(hw, dcb_config);
1212 /* Get Hardware Flow Control setting */
1213 hw->fc.requested_mode = ixgbe_fc_full;
1214 hw->fc.current_mode = ixgbe_fc_full;
1215 hw->fc.pause_time = IXGBE_FC_PAUSE;
1216 for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
1217 hw->fc.low_water[i] = IXGBE_FC_LO;
1218 hw->fc.high_water[i] = IXGBE_FC_HI;
1220 hw->fc.send_xon = 1;
1222 /* Make sure we have a good EEPROM before we read from it */
1223 diag = ixgbe_validate_eeprom_checksum(hw, &csum);
1224 if (diag != IXGBE_SUCCESS) {
1225 PMD_INIT_LOG(ERR, "The EEPROM checksum is not valid: %d", diag);
1229 #ifdef RTE_LIBRTE_IXGBE_BYPASS
1230 diag = ixgbe_bypass_init_hw(hw);
1232 diag = ixgbe_init_hw(hw);
1233 #endif /* RTE_LIBRTE_IXGBE_BYPASS */
1236 * Devices with copper phys will fail to initialise if ixgbe_init_hw()
1237 * is called too soon after the kernel driver unbinding/binding occurs.
1238 * The failure occurs in ixgbe_identify_phy_generic() for all devices,
1239 * but for non-copper devies, ixgbe_identify_sfp_module_generic() is
1240 * also called. See ixgbe_identify_phy_82599(). The reason for the
1241 * failure is not known, and only occuts when virtualisation features
1242 * are disabled in the bios. A delay of 100ms was found to be enough by
1243 * trial-and-error, and is doubled to be safe.
1245 if (diag && (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper)) {
1247 diag = ixgbe_init_hw(hw);
1250 if (diag == IXGBE_ERR_SFP_NOT_PRESENT)
1251 diag = IXGBE_SUCCESS;
1253 if (diag == IXGBE_ERR_EEPROM_VERSION) {
1254 PMD_INIT_LOG(ERR, "This device is a pre-production adapter/"
1255 "LOM. Please be aware there may be issues associated "
1256 "with your hardware.");
1257 PMD_INIT_LOG(ERR, "If you are experiencing problems "
1258 "please contact your Intel or hardware representative "
1259 "who provided you with this hardware.");
1260 } else if (diag == IXGBE_ERR_SFP_NOT_SUPPORTED)
1261 PMD_INIT_LOG(ERR, "Unsupported SFP+ Module");
1263 PMD_INIT_LOG(ERR, "Hardware Initialization Failure: %d", diag);
1267 /* Reset the hw statistics */
1268 ixgbe_dev_stats_reset(eth_dev);
1270 /* disable interrupt */
1271 ixgbe_disable_intr(hw);
1273 /* reset mappings for queue statistics hw counters*/
1274 ixgbe_reset_qstat_mappings(hw);
1276 /* Allocate memory for storing MAC addresses */
1277 eth_dev->data->mac_addrs = rte_zmalloc("ixgbe", ETHER_ADDR_LEN *
1278 hw->mac.num_rar_entries, 0);
1279 if (eth_dev->data->mac_addrs == NULL) {
1281 "Failed to allocate %u bytes needed to store "
1283 ETHER_ADDR_LEN * hw->mac.num_rar_entries);
1286 /* Copy the permanent MAC address */
1287 ether_addr_copy((struct ether_addr *) hw->mac.perm_addr,
1288 ð_dev->data->mac_addrs[0]);
1290 /* Allocate memory for storing hash filter MAC addresses */
1291 eth_dev->data->hash_mac_addrs = rte_zmalloc("ixgbe", ETHER_ADDR_LEN *
1292 IXGBE_VMDQ_NUM_UC_MAC, 0);
1293 if (eth_dev->data->hash_mac_addrs == NULL) {
1295 "Failed to allocate %d bytes needed to store MAC addresses",
1296 ETHER_ADDR_LEN * IXGBE_VMDQ_NUM_UC_MAC);
1300 /* initialize the vfta */
1301 memset(shadow_vfta, 0, sizeof(*shadow_vfta));
1303 /* initialize the hw strip bitmap*/
1304 memset(hwstrip, 0, sizeof(*hwstrip));
1306 /* initialize PF if max_vfs not zero */
1307 ixgbe_pf_host_init(eth_dev);
1309 ctrl_ext = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
1310 /* let hardware know driver is loaded */
1311 ctrl_ext |= IXGBE_CTRL_EXT_DRV_LOAD;
1312 /* Set PF Reset Done bit so PF/VF Mail Ops can work */
1313 ctrl_ext |= IXGBE_CTRL_EXT_PFRSTD;
1314 IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl_ext);
1315 IXGBE_WRITE_FLUSH(hw);
1317 if (ixgbe_is_sfp(hw) && hw->phy.sfp_type != ixgbe_sfp_type_not_present)
1318 PMD_INIT_LOG(DEBUG, "MAC: %d, PHY: %d, SFP+: %d",
1319 (int) hw->mac.type, (int) hw->phy.type,
1320 (int) hw->phy.sfp_type);
1322 PMD_INIT_LOG(DEBUG, "MAC: %d, PHY: %d",
1323 (int) hw->mac.type, (int) hw->phy.type);
1325 PMD_INIT_LOG(DEBUG, "port %d vendorID=0x%x deviceID=0x%x",
1326 eth_dev->data->port_id, pci_dev->id.vendor_id,
1327 pci_dev->id.device_id);
1329 rte_intr_callback_register(intr_handle,
1330 ixgbe_dev_interrupt_handler, eth_dev);
1332 /* enable uio/vfio intr/eventfd mapping */
1333 rte_intr_enable(intr_handle);
1335 /* enable support intr */
1336 ixgbe_enable_intr(eth_dev);
1338 /* initialize filter info */
1339 memset(filter_info, 0,
1340 sizeof(struct ixgbe_filter_info));
1342 /* initialize 5tuple filter list */
1343 TAILQ_INIT(&filter_info->fivetuple_list);
1345 /* initialize flow director filter list & hash */
1346 ixgbe_fdir_filter_init(eth_dev);
1348 /* initialize l2 tunnel filter list & hash */
1349 ixgbe_l2_tn_filter_init(eth_dev);
1351 /* initialize flow filter lists */
1352 ixgbe_filterlist_init();
1354 /* initialize bandwidth configuration info */
1355 memset(bw_conf, 0, sizeof(struct ixgbe_bw_conf));
1357 /* initialize Traffic Manager configuration */
1358 ixgbe_tm_conf_init(eth_dev);
1364 eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev)
1366 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
1367 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
1368 struct ixgbe_hw *hw;
1372 PMD_INIT_FUNC_TRACE();
1374 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
1377 hw = IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
1379 if (hw->adapter_stopped == 0)
1380 ixgbe_dev_close(eth_dev);
1382 eth_dev->dev_ops = NULL;
1383 eth_dev->rx_pkt_burst = NULL;
1384 eth_dev->tx_pkt_burst = NULL;
1386 /* Unlock any pending hardware semaphore */
1387 ixgbe_swfw_lock_reset(hw);
1389 /* disable uio intr before callback unregister */
1390 rte_intr_disable(intr_handle);
1393 ret = rte_intr_callback_unregister(intr_handle,
1394 ixgbe_dev_interrupt_handler, eth_dev);
1397 } else if (ret != -EAGAIN) {
1399 "intr callback unregister failed: %d",
1404 } while (retries++ < (10 + IXGBE_LINK_UP_TIME));
1406 /* uninitialize PF if max_vfs not zero */
1407 ixgbe_pf_host_uninit(eth_dev);
1409 rte_free(eth_dev->data->mac_addrs);
1410 eth_dev->data->mac_addrs = NULL;
1412 rte_free(eth_dev->data->hash_mac_addrs);
1413 eth_dev->data->hash_mac_addrs = NULL;
1415 /* remove all the fdir filters & hash */
1416 ixgbe_fdir_filter_uninit(eth_dev);
1418 /* remove all the L2 tunnel filters & hash */
1419 ixgbe_l2_tn_filter_uninit(eth_dev);
1421 /* Remove all ntuple filters of the device */
1422 ixgbe_ntuple_filter_uninit(eth_dev);
1424 /* clear all the filters list */
1425 ixgbe_filterlist_flush();
1427 /* Remove all Traffic Manager configuration */
1428 ixgbe_tm_conf_uninit(eth_dev);
1430 #ifdef RTE_LIBRTE_SECURITY
1431 rte_free(eth_dev->security_ctx);
1437 static int ixgbe_ntuple_filter_uninit(struct rte_eth_dev *eth_dev)
1439 struct ixgbe_filter_info *filter_info =
1440 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(eth_dev->data->dev_private);
1441 struct ixgbe_5tuple_filter *p_5tuple;
1443 while ((p_5tuple = TAILQ_FIRST(&filter_info->fivetuple_list))) {
1444 TAILQ_REMOVE(&filter_info->fivetuple_list,
1449 memset(filter_info->fivetuple_mask, 0,
1450 sizeof(uint32_t) * IXGBE_5TUPLE_ARRAY_SIZE);
1455 static int ixgbe_fdir_filter_uninit(struct rte_eth_dev *eth_dev)
1457 struct ixgbe_hw_fdir_info *fdir_info =
1458 IXGBE_DEV_PRIVATE_TO_FDIR_INFO(eth_dev->data->dev_private);
1459 struct ixgbe_fdir_filter *fdir_filter;
1461 if (fdir_info->hash_map)
1462 rte_free(fdir_info->hash_map);
1463 if (fdir_info->hash_handle)
1464 rte_hash_free(fdir_info->hash_handle);
1466 while ((fdir_filter = TAILQ_FIRST(&fdir_info->fdir_list))) {
1467 TAILQ_REMOVE(&fdir_info->fdir_list,
1470 rte_free(fdir_filter);
1476 static int ixgbe_l2_tn_filter_uninit(struct rte_eth_dev *eth_dev)
1478 struct ixgbe_l2_tn_info *l2_tn_info =
1479 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(eth_dev->data->dev_private);
1480 struct ixgbe_l2_tn_filter *l2_tn_filter;
1482 if (l2_tn_info->hash_map)
1483 rte_free(l2_tn_info->hash_map);
1484 if (l2_tn_info->hash_handle)
1485 rte_hash_free(l2_tn_info->hash_handle);
1487 while ((l2_tn_filter = TAILQ_FIRST(&l2_tn_info->l2_tn_list))) {
1488 TAILQ_REMOVE(&l2_tn_info->l2_tn_list,
1491 rte_free(l2_tn_filter);
1497 static int ixgbe_fdir_filter_init(struct rte_eth_dev *eth_dev)
1499 struct ixgbe_hw_fdir_info *fdir_info =
1500 IXGBE_DEV_PRIVATE_TO_FDIR_INFO(eth_dev->data->dev_private);
1501 char fdir_hash_name[RTE_HASH_NAMESIZE];
1502 struct rte_hash_parameters fdir_hash_params = {
1503 .name = fdir_hash_name,
1504 .entries = IXGBE_MAX_FDIR_FILTER_NUM,
1505 .key_len = sizeof(union ixgbe_atr_input),
1506 .hash_func = rte_hash_crc,
1507 .hash_func_init_val = 0,
1508 .socket_id = rte_socket_id(),
1511 TAILQ_INIT(&fdir_info->fdir_list);
1512 snprintf(fdir_hash_name, RTE_HASH_NAMESIZE,
1513 "fdir_%s", eth_dev->device->name);
1514 fdir_info->hash_handle = rte_hash_create(&fdir_hash_params);
1515 if (!fdir_info->hash_handle) {
1516 PMD_INIT_LOG(ERR, "Failed to create fdir hash table!");
1519 fdir_info->hash_map = rte_zmalloc("ixgbe",
1520 sizeof(struct ixgbe_fdir_filter *) *
1521 IXGBE_MAX_FDIR_FILTER_NUM,
1523 if (!fdir_info->hash_map) {
1525 "Failed to allocate memory for fdir hash map!");
1528 fdir_info->mask_added = FALSE;
1533 static int ixgbe_l2_tn_filter_init(struct rte_eth_dev *eth_dev)
1535 struct ixgbe_l2_tn_info *l2_tn_info =
1536 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(eth_dev->data->dev_private);
1537 char l2_tn_hash_name[RTE_HASH_NAMESIZE];
1538 struct rte_hash_parameters l2_tn_hash_params = {
1539 .name = l2_tn_hash_name,
1540 .entries = IXGBE_MAX_L2_TN_FILTER_NUM,
1541 .key_len = sizeof(struct ixgbe_l2_tn_key),
1542 .hash_func = rte_hash_crc,
1543 .hash_func_init_val = 0,
1544 .socket_id = rte_socket_id(),
1547 TAILQ_INIT(&l2_tn_info->l2_tn_list);
1548 snprintf(l2_tn_hash_name, RTE_HASH_NAMESIZE,
1549 "l2_tn_%s", eth_dev->device->name);
1550 l2_tn_info->hash_handle = rte_hash_create(&l2_tn_hash_params);
1551 if (!l2_tn_info->hash_handle) {
1552 PMD_INIT_LOG(ERR, "Failed to create L2 TN hash table!");
1555 l2_tn_info->hash_map = rte_zmalloc("ixgbe",
1556 sizeof(struct ixgbe_l2_tn_filter *) *
1557 IXGBE_MAX_L2_TN_FILTER_NUM,
1559 if (!l2_tn_info->hash_map) {
1561 "Failed to allocate memory for L2 TN hash map!");
1564 l2_tn_info->e_tag_en = FALSE;
1565 l2_tn_info->e_tag_fwd_en = FALSE;
1566 l2_tn_info->e_tag_ether_type = DEFAULT_ETAG_ETYPE;
1571 * Negotiate mailbox API version with the PF.
1572 * After reset API version is always set to the basic one (ixgbe_mbox_api_10).
1573 * Then we try to negotiate starting with the most recent one.
1574 * If all negotiation attempts fail, then we will proceed with
1575 * the default one (ixgbe_mbox_api_10).
1578 ixgbevf_negotiate_api(struct ixgbe_hw *hw)
1582 /* start with highest supported, proceed down */
1583 static const enum ixgbe_pfvf_api_rev sup_ver[] = {
1590 i != RTE_DIM(sup_ver) &&
1591 ixgbevf_negotiate_api_version(hw, sup_ver[i]) != 0;
1597 generate_random_mac_addr(struct ether_addr *mac_addr)
1601 /* Set Organizationally Unique Identifier (OUI) prefix. */
1602 mac_addr->addr_bytes[0] = 0x00;
1603 mac_addr->addr_bytes[1] = 0x09;
1604 mac_addr->addr_bytes[2] = 0xC0;
1605 /* Force indication of locally assigned MAC address. */
1606 mac_addr->addr_bytes[0] |= ETHER_LOCAL_ADMIN_ADDR;
1607 /* Generate the last 3 bytes of the MAC address with a random number. */
1608 random = rte_rand();
1609 memcpy(&mac_addr->addr_bytes[3], &random, 3);
1613 * Virtual Function device init
1616 eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev)
1620 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
1621 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
1622 struct ixgbe_hw *hw =
1623 IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
1624 struct ixgbe_vfta *shadow_vfta =
1625 IXGBE_DEV_PRIVATE_TO_VFTA(eth_dev->data->dev_private);
1626 struct ixgbe_hwstrip *hwstrip =
1627 IXGBE_DEV_PRIVATE_TO_HWSTRIP_BITMAP(eth_dev->data->dev_private);
1628 struct ether_addr *perm_addr = (struct ether_addr *) hw->mac.perm_addr;
1630 PMD_INIT_FUNC_TRACE();
1632 eth_dev->dev_ops = &ixgbevf_eth_dev_ops;
1633 eth_dev->rx_pkt_burst = &ixgbe_recv_pkts;
1634 eth_dev->tx_pkt_burst = &ixgbe_xmit_pkts;
1636 /* for secondary processes, we don't initialise any further as primary
1637 * has already done this work. Only check we don't need a different
1640 if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
1641 struct ixgbe_tx_queue *txq;
1642 /* TX queue function in primary, set by last queue initialized
1643 * Tx queue may not initialized by primary process
1645 if (eth_dev->data->tx_queues) {
1646 txq = eth_dev->data->tx_queues[eth_dev->data->nb_tx_queues - 1];
1647 ixgbe_set_tx_function(eth_dev, txq);
1649 /* Use default TX function if we get here */
1650 PMD_INIT_LOG(NOTICE,
1651 "No TX queues configured yet. Using default TX function.");
1654 ixgbe_set_rx_function(eth_dev);
1659 rte_eth_copy_pci_info(eth_dev, pci_dev);
1661 hw->device_id = pci_dev->id.device_id;
1662 hw->vendor_id = pci_dev->id.vendor_id;
1663 hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
1665 /* initialize the vfta */
1666 memset(shadow_vfta, 0, sizeof(*shadow_vfta));
1668 /* initialize the hw strip bitmap*/
1669 memset(hwstrip, 0, sizeof(*hwstrip));
1671 /* Initialize the shared code (base driver) */
1672 diag = ixgbe_init_shared_code(hw);
1673 if (diag != IXGBE_SUCCESS) {
1674 PMD_INIT_LOG(ERR, "Shared code init failed for ixgbevf: %d", diag);
1678 /* init_mailbox_params */
1679 hw->mbx.ops.init_params(hw);
1681 /* Reset the hw statistics */
1682 ixgbevf_dev_stats_reset(eth_dev);
1684 /* Disable the interrupts for VF */
1685 ixgbevf_intr_disable(hw);
1687 hw->mac.num_rar_entries = 128; /* The MAX of the underlying PF */
1688 diag = hw->mac.ops.reset_hw(hw);
1691 * The VF reset operation returns the IXGBE_ERR_INVALID_MAC_ADDR when
1692 * the underlying PF driver has not assigned a MAC address to the VF.
1693 * In this case, assign a random MAC address.
1695 if ((diag != IXGBE_SUCCESS) && (diag != IXGBE_ERR_INVALID_MAC_ADDR)) {
1696 PMD_INIT_LOG(ERR, "VF Initialization Failure: %d", diag);
1700 /* negotiate mailbox API version to use with the PF. */
1701 ixgbevf_negotiate_api(hw);
1703 /* Get Rx/Tx queue count via mailbox, which is ready after reset_hw */
1704 ixgbevf_get_queues(hw, &tcs, &tc);
1706 /* Allocate memory for storing MAC addresses */
1707 eth_dev->data->mac_addrs = rte_zmalloc("ixgbevf", ETHER_ADDR_LEN *
1708 hw->mac.num_rar_entries, 0);
1709 if (eth_dev->data->mac_addrs == NULL) {
1711 "Failed to allocate %u bytes needed to store "
1713 ETHER_ADDR_LEN * hw->mac.num_rar_entries);
1717 /* Generate a random MAC address, if none was assigned by PF. */
1718 if (is_zero_ether_addr(perm_addr)) {
1719 generate_random_mac_addr(perm_addr);
1720 diag = ixgbe_set_rar_vf(hw, 1, perm_addr->addr_bytes, 0, 1);
1722 rte_free(eth_dev->data->mac_addrs);
1723 eth_dev->data->mac_addrs = NULL;
1726 PMD_INIT_LOG(INFO, "\tVF MAC address not assigned by Host PF");
1727 PMD_INIT_LOG(INFO, "\tAssign randomly generated MAC address "
1728 "%02x:%02x:%02x:%02x:%02x:%02x",
1729 perm_addr->addr_bytes[0],
1730 perm_addr->addr_bytes[1],
1731 perm_addr->addr_bytes[2],
1732 perm_addr->addr_bytes[3],
1733 perm_addr->addr_bytes[4],
1734 perm_addr->addr_bytes[5]);
1737 /* Copy the permanent MAC address */
1738 ether_addr_copy(perm_addr, ð_dev->data->mac_addrs[0]);
1740 /* reset the hardware with the new settings */
1741 diag = hw->mac.ops.start_hw(hw);
1747 PMD_INIT_LOG(ERR, "VF Initialization Failure: %d", diag);
1751 rte_intr_callback_register(intr_handle,
1752 ixgbevf_dev_interrupt_handler, eth_dev);
1753 rte_intr_enable(intr_handle);
1754 ixgbevf_intr_enable(hw);
1756 PMD_INIT_LOG(DEBUG, "port %d vendorID=0x%x deviceID=0x%x mac.type=%s",
1757 eth_dev->data->port_id, pci_dev->id.vendor_id,
1758 pci_dev->id.device_id, "ixgbe_mac_82599_vf");
1763 /* Virtual Function device uninit */
1766 eth_ixgbevf_dev_uninit(struct rte_eth_dev *eth_dev)
1768 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
1769 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
1770 struct ixgbe_hw *hw;
1772 PMD_INIT_FUNC_TRACE();
1774 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
1777 hw = IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
1779 if (hw->adapter_stopped == 0)
1780 ixgbevf_dev_close(eth_dev);
1782 eth_dev->dev_ops = NULL;
1783 eth_dev->rx_pkt_burst = NULL;
1784 eth_dev->tx_pkt_burst = NULL;
1786 /* Disable the interrupts for VF */
1787 ixgbevf_intr_disable(hw);
1789 rte_free(eth_dev->data->mac_addrs);
1790 eth_dev->data->mac_addrs = NULL;
1792 rte_intr_disable(intr_handle);
1793 rte_intr_callback_unregister(intr_handle,
1794 ixgbevf_dev_interrupt_handler, eth_dev);
1799 static int eth_ixgbe_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
1800 struct rte_pci_device *pci_dev)
1802 return rte_eth_dev_pci_generic_probe(pci_dev,
1803 sizeof(struct ixgbe_adapter), eth_ixgbe_dev_init);
1806 static int eth_ixgbe_pci_remove(struct rte_pci_device *pci_dev)
1808 return rte_eth_dev_pci_generic_remove(pci_dev, eth_ixgbe_dev_uninit);
1811 static struct rte_pci_driver rte_ixgbe_pmd = {
1812 .id_table = pci_id_ixgbe_map,
1813 .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
1814 RTE_PCI_DRV_IOVA_AS_VA,
1815 .probe = eth_ixgbe_pci_probe,
1816 .remove = eth_ixgbe_pci_remove,
1819 static int eth_ixgbevf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
1820 struct rte_pci_device *pci_dev)
1822 return rte_eth_dev_pci_generic_probe(pci_dev,
1823 sizeof(struct ixgbe_adapter), eth_ixgbevf_dev_init);
1826 static int eth_ixgbevf_pci_remove(struct rte_pci_device *pci_dev)
1828 return rte_eth_dev_pci_generic_remove(pci_dev, eth_ixgbevf_dev_uninit);
1832 * virtual function driver struct
1834 static struct rte_pci_driver rte_ixgbevf_pmd = {
1835 .id_table = pci_id_ixgbevf_map,
1836 .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_IOVA_AS_VA,
1837 .probe = eth_ixgbevf_pci_probe,
1838 .remove = eth_ixgbevf_pci_remove,
1842 ixgbe_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
1844 struct ixgbe_hw *hw =
1845 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1846 struct ixgbe_vfta *shadow_vfta =
1847 IXGBE_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
1852 vid_idx = (uint32_t) ((vlan_id >> 5) & 0x7F);
1853 vid_bit = (uint32_t) (1 << (vlan_id & 0x1F));
1854 vfta = IXGBE_READ_REG(hw, IXGBE_VFTA(vid_idx));
1859 IXGBE_WRITE_REG(hw, IXGBE_VFTA(vid_idx), vfta);
1861 /* update local VFTA copy */
1862 shadow_vfta->vfta[vid_idx] = vfta;
1868 ixgbe_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue, int on)
1871 ixgbe_vlan_hw_strip_enable(dev, queue);
1873 ixgbe_vlan_hw_strip_disable(dev, queue);
1877 ixgbe_vlan_tpid_set(struct rte_eth_dev *dev,
1878 enum rte_vlan_type vlan_type,
1881 struct ixgbe_hw *hw =
1882 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1887 qinq = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
1888 qinq &= IXGBE_DMATXCTL_GDV;
1890 switch (vlan_type) {
1891 case ETH_VLAN_TYPE_INNER:
1893 reg = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
1894 reg = (reg & (~IXGBE_VLNCTRL_VET)) | (uint32_t)tpid;
1895 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, reg);
1896 reg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
1897 reg = (reg & (~IXGBE_DMATXCTL_VT_MASK))
1898 | ((uint32_t)tpid << IXGBE_DMATXCTL_VT_SHIFT);
1899 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);
1902 PMD_DRV_LOG(ERR, "Inner type is not supported"
1906 case ETH_VLAN_TYPE_OUTER:
1908 /* Only the high 16-bits is valid */
1909 IXGBE_WRITE_REG(hw, IXGBE_EXVET, (uint32_t)tpid <<
1910 IXGBE_EXVET_VET_EXT_SHIFT);
1912 reg = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
1913 reg = (reg & (~IXGBE_VLNCTRL_VET)) | (uint32_t)tpid;
1914 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, reg);
1915 reg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
1916 reg = (reg & (~IXGBE_DMATXCTL_VT_MASK))
1917 | ((uint32_t)tpid << IXGBE_DMATXCTL_VT_SHIFT);
1918 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);
1924 PMD_DRV_LOG(ERR, "Unsupported VLAN type %d", vlan_type);
1932 ixgbe_vlan_hw_filter_disable(struct rte_eth_dev *dev)
1934 struct ixgbe_hw *hw =
1935 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1938 PMD_INIT_FUNC_TRACE();
1940 /* Filter Table Disable */
1941 vlnctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
1942 vlnctrl &= ~IXGBE_VLNCTRL_VFE;
1944 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlnctrl);
1948 ixgbe_vlan_hw_filter_enable(struct rte_eth_dev *dev)
1950 struct ixgbe_hw *hw =
1951 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1952 struct ixgbe_vfta *shadow_vfta =
1953 IXGBE_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
1957 PMD_INIT_FUNC_TRACE();
1959 /* Filter Table Enable */
1960 vlnctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
1961 vlnctrl &= ~IXGBE_VLNCTRL_CFIEN;
1962 vlnctrl |= IXGBE_VLNCTRL_VFE;
1964 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlnctrl);
1966 /* write whatever is in local vfta copy */
1967 for (i = 0; i < IXGBE_VFTA_SIZE; i++)
1968 IXGBE_WRITE_REG(hw, IXGBE_VFTA(i), shadow_vfta->vfta[i]);
1972 ixgbe_vlan_hw_strip_bitmap_set(struct rte_eth_dev *dev, uint16_t queue, bool on)
1974 struct ixgbe_hwstrip *hwstrip =
1975 IXGBE_DEV_PRIVATE_TO_HWSTRIP_BITMAP(dev->data->dev_private);
1976 struct ixgbe_rx_queue *rxq;
1978 if (queue >= IXGBE_MAX_RX_QUEUE_NUM)
1982 IXGBE_SET_HWSTRIP(hwstrip, queue);
1984 IXGBE_CLEAR_HWSTRIP(hwstrip, queue);
1986 if (queue >= dev->data->nb_rx_queues)
1989 rxq = dev->data->rx_queues[queue];
1992 rxq->vlan_flags = PKT_RX_VLAN | PKT_RX_VLAN_STRIPPED;
1994 rxq->vlan_flags = PKT_RX_VLAN;
1998 ixgbe_vlan_hw_strip_disable(struct rte_eth_dev *dev, uint16_t queue)
2000 struct ixgbe_hw *hw =
2001 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2004 PMD_INIT_FUNC_TRACE();
2006 if (hw->mac.type == ixgbe_mac_82598EB) {
2007 /* No queue level support */
2008 PMD_INIT_LOG(NOTICE, "82598EB not support queue level hw strip");
2012 /* Other 10G NIC, the VLAN strip can be setup per queue in RXDCTL */
2013 ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(queue));
2014 ctrl &= ~IXGBE_RXDCTL_VME;
2015 IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(queue), ctrl);
2017 /* record those setting for HW strip per queue */
2018 ixgbe_vlan_hw_strip_bitmap_set(dev, queue, 0);
2022 ixgbe_vlan_hw_strip_enable(struct rte_eth_dev *dev, uint16_t queue)
2024 struct ixgbe_hw *hw =
2025 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2028 PMD_INIT_FUNC_TRACE();
2030 if (hw->mac.type == ixgbe_mac_82598EB) {
2031 /* No queue level supported */
2032 PMD_INIT_LOG(NOTICE, "82598EB not support queue level hw strip");
2036 /* Other 10G NIC, the VLAN strip can be setup per queue in RXDCTL */
2037 ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(queue));
2038 ctrl |= IXGBE_RXDCTL_VME;
2039 IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(queue), ctrl);
2041 /* record those setting for HW strip per queue */
2042 ixgbe_vlan_hw_strip_bitmap_set(dev, queue, 1);
2046 ixgbe_vlan_hw_strip_disable_all(struct rte_eth_dev *dev)
2048 struct ixgbe_hw *hw =
2049 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2052 struct ixgbe_rx_queue *rxq;
2054 PMD_INIT_FUNC_TRACE();
2056 if (hw->mac.type == ixgbe_mac_82598EB) {
2057 ctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
2058 ctrl &= ~IXGBE_VLNCTRL_VME;
2059 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, ctrl);
2061 /* Other 10G NIC, the VLAN strip can be setup per queue in RXDCTL */
2062 for (i = 0; i < dev->data->nb_rx_queues; i++) {
2063 rxq = dev->data->rx_queues[i];
2064 ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(rxq->reg_idx));
2065 ctrl &= ~IXGBE_RXDCTL_VME;
2066 IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(rxq->reg_idx), ctrl);
2068 /* record those setting for HW strip per queue */
2069 ixgbe_vlan_hw_strip_bitmap_set(dev, i, 0);
2075 ixgbe_vlan_hw_strip_enable_all(struct rte_eth_dev *dev)
2077 struct ixgbe_hw *hw =
2078 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2081 struct ixgbe_rx_queue *rxq;
2083 PMD_INIT_FUNC_TRACE();
2085 if (hw->mac.type == ixgbe_mac_82598EB) {
2086 ctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
2087 ctrl |= IXGBE_VLNCTRL_VME;
2088 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, ctrl);
2090 /* Other 10G NIC, the VLAN strip can be setup per queue in RXDCTL */
2091 for (i = 0; i < dev->data->nb_rx_queues; i++) {
2092 rxq = dev->data->rx_queues[i];
2093 ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(rxq->reg_idx));
2094 ctrl |= IXGBE_RXDCTL_VME;
2095 IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(rxq->reg_idx), ctrl);
2097 /* record those setting for HW strip per queue */
2098 ixgbe_vlan_hw_strip_bitmap_set(dev, i, 1);
2104 ixgbe_vlan_hw_extend_disable(struct rte_eth_dev *dev)
2106 struct ixgbe_hw *hw =
2107 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2110 PMD_INIT_FUNC_TRACE();
2112 /* DMATXCTRL: Geric Double VLAN Disable */
2113 ctrl = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
2114 ctrl &= ~IXGBE_DMATXCTL_GDV;
2115 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, ctrl);
2117 /* CTRL_EXT: Global Double VLAN Disable */
2118 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
2119 ctrl &= ~IXGBE_EXTENDED_VLAN;
2120 IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl);
2125 ixgbe_vlan_hw_extend_enable(struct rte_eth_dev *dev)
2127 struct ixgbe_hw *hw =
2128 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2131 PMD_INIT_FUNC_TRACE();
2133 /* DMATXCTRL: Geric Double VLAN Enable */
2134 ctrl = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
2135 ctrl |= IXGBE_DMATXCTL_GDV;
2136 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, ctrl);
2138 /* CTRL_EXT: Global Double VLAN Enable */
2139 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
2140 ctrl |= IXGBE_EXTENDED_VLAN;
2141 IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl);
2143 /* Clear pooling mode of PFVTCTL. It's required by X550. */
2144 if (hw->mac.type == ixgbe_mac_X550 ||
2145 hw->mac.type == ixgbe_mac_X550EM_x ||
2146 hw->mac.type == ixgbe_mac_X550EM_a) {
2147 ctrl = IXGBE_READ_REG(hw, IXGBE_VT_CTL);
2148 ctrl &= ~IXGBE_VT_CTL_POOLING_MODE_MASK;
2149 IXGBE_WRITE_REG(hw, IXGBE_VT_CTL, ctrl);
2153 * VET EXT field in the EXVET register = 0x8100 by default
2154 * So no need to change. Same to VT field of DMATXCTL register
2159 ixgbe_vlan_offload_set(struct rte_eth_dev *dev, int mask)
2161 if (mask & ETH_VLAN_STRIP_MASK) {
2162 if (dev->data->dev_conf.rxmode.hw_vlan_strip)
2163 ixgbe_vlan_hw_strip_enable_all(dev);
2165 ixgbe_vlan_hw_strip_disable_all(dev);
2168 if (mask & ETH_VLAN_FILTER_MASK) {
2169 if (dev->data->dev_conf.rxmode.hw_vlan_filter)
2170 ixgbe_vlan_hw_filter_enable(dev);
2172 ixgbe_vlan_hw_filter_disable(dev);
2175 if (mask & ETH_VLAN_EXTEND_MASK) {
2176 if (dev->data->dev_conf.rxmode.hw_vlan_extend)
2177 ixgbe_vlan_hw_extend_enable(dev);
2179 ixgbe_vlan_hw_extend_disable(dev);
2186 ixgbe_vmdq_vlan_hw_filter_enable(struct rte_eth_dev *dev)
2188 struct ixgbe_hw *hw =
2189 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2190 /* VLNCTRL: enable vlan filtering and allow all vlan tags through */
2191 uint32_t vlanctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
2193 vlanctrl |= IXGBE_VLNCTRL_VFE; /* enable vlan filters */
2194 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlanctrl);
2198 ixgbe_check_vf_rss_rxq_num(struct rte_eth_dev *dev, uint16_t nb_rx_q)
2200 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
2205 RTE_ETH_DEV_SRIOV(dev).active = ETH_64_POOLS;
2208 RTE_ETH_DEV_SRIOV(dev).active = ETH_32_POOLS;
2214 RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool =
2215 IXGBE_MAX_RX_QUEUE_NUM / RTE_ETH_DEV_SRIOV(dev).active;
2216 RTE_ETH_DEV_SRIOV(dev).def_pool_q_idx =
2217 pci_dev->max_vfs * RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool;
2222 ixgbe_check_mq_mode(struct rte_eth_dev *dev)
2224 struct rte_eth_conf *dev_conf = &dev->data->dev_conf;
2225 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2226 uint16_t nb_rx_q = dev->data->nb_rx_queues;
2227 uint16_t nb_tx_q = dev->data->nb_tx_queues;
2229 if (RTE_ETH_DEV_SRIOV(dev).active != 0) {
2230 /* check multi-queue mode */
2231 switch (dev_conf->rxmode.mq_mode) {
2232 case ETH_MQ_RX_VMDQ_DCB:
2233 PMD_INIT_LOG(INFO, "ETH_MQ_RX_VMDQ_DCB mode supported in SRIOV");
2235 case ETH_MQ_RX_VMDQ_DCB_RSS:
2236 /* DCB/RSS VMDQ in SRIOV mode, not implement yet */
2237 PMD_INIT_LOG(ERR, "SRIOV active,"
2238 " unsupported mq_mode rx %d.",
2239 dev_conf->rxmode.mq_mode);
2242 case ETH_MQ_RX_VMDQ_RSS:
2243 dev->data->dev_conf.rxmode.mq_mode = ETH_MQ_RX_VMDQ_RSS;
2244 if (nb_rx_q <= RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool)
2245 if (ixgbe_check_vf_rss_rxq_num(dev, nb_rx_q)) {
2246 PMD_INIT_LOG(ERR, "SRIOV is active,"
2247 " invalid queue number"
2248 " for VMDQ RSS, allowed"
2249 " value are 1, 2 or 4.");
2253 case ETH_MQ_RX_VMDQ_ONLY:
2254 case ETH_MQ_RX_NONE:
2255 /* if nothing mq mode configure, use default scheme */
2256 dev->data->dev_conf.rxmode.mq_mode = ETH_MQ_RX_VMDQ_ONLY;
2258 default: /* ETH_MQ_RX_DCB, ETH_MQ_RX_DCB_RSS or ETH_MQ_TX_DCB*/
2259 /* SRIOV only works in VMDq enable mode */
2260 PMD_INIT_LOG(ERR, "SRIOV is active,"
2261 " wrong mq_mode rx %d.",
2262 dev_conf->rxmode.mq_mode);
2266 switch (dev_conf->txmode.mq_mode) {
2267 case ETH_MQ_TX_VMDQ_DCB:
2268 PMD_INIT_LOG(INFO, "ETH_MQ_TX_VMDQ_DCB mode supported in SRIOV");
2269 dev->data->dev_conf.txmode.mq_mode = ETH_MQ_TX_VMDQ_DCB;
2271 default: /* ETH_MQ_TX_VMDQ_ONLY or ETH_MQ_TX_NONE */
2272 dev->data->dev_conf.txmode.mq_mode = ETH_MQ_TX_VMDQ_ONLY;
2276 /* check valid queue number */
2277 if ((nb_rx_q > RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool) ||
2278 (nb_tx_q > RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool)) {
2279 PMD_INIT_LOG(ERR, "SRIOV is active,"
2280 " nb_rx_q=%d nb_tx_q=%d queue number"
2281 " must be less than or equal to %d.",
2283 RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool);
2287 if (dev_conf->rxmode.mq_mode == ETH_MQ_RX_VMDQ_DCB_RSS) {
2288 PMD_INIT_LOG(ERR, "VMDQ+DCB+RSS mq_mode is"
2292 /* check configuration for vmdb+dcb mode */
2293 if (dev_conf->rxmode.mq_mode == ETH_MQ_RX_VMDQ_DCB) {
2294 const struct rte_eth_vmdq_dcb_conf *conf;
2296 if (nb_rx_q != IXGBE_VMDQ_DCB_NB_QUEUES) {
2297 PMD_INIT_LOG(ERR, "VMDQ+DCB, nb_rx_q != %d.",
2298 IXGBE_VMDQ_DCB_NB_QUEUES);
2301 conf = &dev_conf->rx_adv_conf.vmdq_dcb_conf;
2302 if (!(conf->nb_queue_pools == ETH_16_POOLS ||
2303 conf->nb_queue_pools == ETH_32_POOLS)) {
2304 PMD_INIT_LOG(ERR, "VMDQ+DCB selected,"
2305 " nb_queue_pools must be %d or %d.",
2306 ETH_16_POOLS, ETH_32_POOLS);
2310 if (dev_conf->txmode.mq_mode == ETH_MQ_TX_VMDQ_DCB) {
2311 const struct rte_eth_vmdq_dcb_tx_conf *conf;
2313 if (nb_tx_q != IXGBE_VMDQ_DCB_NB_QUEUES) {
2314 PMD_INIT_LOG(ERR, "VMDQ+DCB, nb_tx_q != %d",
2315 IXGBE_VMDQ_DCB_NB_QUEUES);
2318 conf = &dev_conf->tx_adv_conf.vmdq_dcb_tx_conf;
2319 if (!(conf->nb_queue_pools == ETH_16_POOLS ||
2320 conf->nb_queue_pools == ETH_32_POOLS)) {
2321 PMD_INIT_LOG(ERR, "VMDQ+DCB selected,"
2322 " nb_queue_pools != %d and"
2323 " nb_queue_pools != %d.",
2324 ETH_16_POOLS, ETH_32_POOLS);
2329 /* For DCB mode check our configuration before we go further */
2330 if (dev_conf->rxmode.mq_mode == ETH_MQ_RX_DCB) {
2331 const struct rte_eth_dcb_rx_conf *conf;
2333 conf = &dev_conf->rx_adv_conf.dcb_rx_conf;
2334 if (!(conf->nb_tcs == ETH_4_TCS ||
2335 conf->nb_tcs == ETH_8_TCS)) {
2336 PMD_INIT_LOG(ERR, "DCB selected, nb_tcs != %d"
2337 " and nb_tcs != %d.",
2338 ETH_4_TCS, ETH_8_TCS);
2343 if (dev_conf->txmode.mq_mode == ETH_MQ_TX_DCB) {
2344 const struct rte_eth_dcb_tx_conf *conf;
2346 conf = &dev_conf->tx_adv_conf.dcb_tx_conf;
2347 if (!(conf->nb_tcs == ETH_4_TCS ||
2348 conf->nb_tcs == ETH_8_TCS)) {
2349 PMD_INIT_LOG(ERR, "DCB selected, nb_tcs != %d"
2350 " and nb_tcs != %d.",
2351 ETH_4_TCS, ETH_8_TCS);
2357 * When DCB/VT is off, maximum number of queues changes,
2358 * except for 82598EB, which remains constant.
2360 if (dev_conf->txmode.mq_mode == ETH_MQ_TX_NONE &&
2361 hw->mac.type != ixgbe_mac_82598EB) {
2362 if (nb_tx_q > IXGBE_NONE_MODE_TX_NB_QUEUES) {
2364 "Neither VT nor DCB are enabled, "
2366 IXGBE_NONE_MODE_TX_NB_QUEUES);
2375 ixgbe_dev_configure(struct rte_eth_dev *dev)
2377 struct ixgbe_interrupt *intr =
2378 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
2379 struct ixgbe_adapter *adapter =
2380 (struct ixgbe_adapter *)dev->data->dev_private;
2383 PMD_INIT_FUNC_TRACE();
2384 /* multipe queue mode checking */
2385 ret = ixgbe_check_mq_mode(dev);
2387 PMD_DRV_LOG(ERR, "ixgbe_check_mq_mode fails with %d.",
2392 /* set flag to update link status after init */
2393 intr->flags |= IXGBE_FLAG_NEED_LINK_UPDATE;
2396 * Initialize to TRUE. If any of Rx queues doesn't meet the bulk
2397 * allocation or vector Rx preconditions we will reset it.
2399 adapter->rx_bulk_alloc_allowed = true;
2400 adapter->rx_vec_allowed = true;
2406 ixgbe_dev_phy_intr_setup(struct rte_eth_dev *dev)
2408 struct ixgbe_hw *hw =
2409 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2410 struct ixgbe_interrupt *intr =
2411 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
2414 /* only set up it on X550EM_X */
2415 if (hw->mac.type == ixgbe_mac_X550EM_x) {
2416 gpie = IXGBE_READ_REG(hw, IXGBE_GPIE);
2417 gpie |= IXGBE_SDP0_GPIEN_X550EM_x;
2418 IXGBE_WRITE_REG(hw, IXGBE_GPIE, gpie);
2419 if (hw->phy.type == ixgbe_phy_x550em_ext_t)
2420 intr->mask |= IXGBE_EICR_GPI_SDP0_X550EM_x;
2425 ixgbe_set_vf_rate_limit(struct rte_eth_dev *dev, uint16_t vf,
2426 uint16_t tx_rate, uint64_t q_msk)
2428 struct ixgbe_hw *hw;
2429 struct ixgbe_vf_info *vfinfo;
2430 struct rte_eth_link link;
2431 uint8_t nb_q_per_pool;
2432 uint32_t queue_stride;
2433 uint32_t queue_idx, idx = 0, vf_idx;
2435 uint16_t total_rate = 0;
2436 struct rte_pci_device *pci_dev;
2438 pci_dev = RTE_ETH_DEV_TO_PCI(dev);
2439 rte_eth_link_get_nowait(dev->data->port_id, &link);
2441 if (vf >= pci_dev->max_vfs)
2444 if (tx_rate > link.link_speed)
2450 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2451 vfinfo = *(IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private));
2452 nb_q_per_pool = RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool;
2453 queue_stride = IXGBE_MAX_RX_QUEUE_NUM / RTE_ETH_DEV_SRIOV(dev).active;
2454 queue_idx = vf * queue_stride;
2455 queue_end = queue_idx + nb_q_per_pool - 1;
2456 if (queue_end >= hw->mac.max_tx_queues)
2460 for (vf_idx = 0; vf_idx < pci_dev->max_vfs; vf_idx++) {
2463 for (idx = 0; idx < RTE_DIM(vfinfo[vf_idx].tx_rate);
2465 total_rate += vfinfo[vf_idx].tx_rate[idx];
2471 /* Store tx_rate for this vf. */
2472 for (idx = 0; idx < nb_q_per_pool; idx++) {
2473 if (((uint64_t)0x1 << idx) & q_msk) {
2474 if (vfinfo[vf].tx_rate[idx] != tx_rate)
2475 vfinfo[vf].tx_rate[idx] = tx_rate;
2476 total_rate += tx_rate;
2480 if (total_rate > dev->data->dev_link.link_speed) {
2481 /* Reset stored TX rate of the VF if it causes exceed
2484 memset(vfinfo[vf].tx_rate, 0, sizeof(vfinfo[vf].tx_rate));
2488 /* Set RTTBCNRC of each queue/pool for vf X */
2489 for (; queue_idx <= queue_end; queue_idx++) {
2491 ixgbe_set_queue_rate_limit(dev, queue_idx, tx_rate);
2499 * Configure device link speed and setup link.
2500 * It returns 0 on success.
2503 ixgbe_dev_start(struct rte_eth_dev *dev)
2505 struct ixgbe_hw *hw =
2506 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2507 struct ixgbe_vf_info *vfinfo =
2508 *IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private);
2509 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
2510 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
2511 uint32_t intr_vector = 0;
2512 int err, link_up = 0, negotiate = 0;
2517 uint32_t *link_speeds;
2518 struct ixgbe_tm_conf *tm_conf =
2519 IXGBE_DEV_PRIVATE_TO_TM_CONF(dev->data->dev_private);
2521 PMD_INIT_FUNC_TRACE();
2523 /* IXGBE devices don't support:
2524 * - half duplex (checked afterwards for valid speeds)
2525 * - fixed speed: TODO implement
2527 if (dev->data->dev_conf.link_speeds & ETH_LINK_SPEED_FIXED) {
2529 "Invalid link_speeds for port %u, fix speed not supported",
2530 dev->data->port_id);
2534 /* disable uio/vfio intr/eventfd mapping */
2535 rte_intr_disable(intr_handle);
2538 hw->adapter_stopped = 0;
2539 ixgbe_stop_adapter(hw);
2541 /* reinitialize adapter
2542 * this calls reset and start
2544 status = ixgbe_pf_reset_hw(hw);
2547 hw->mac.ops.start_hw(hw);
2548 hw->mac.get_link_status = true;
2550 /* configure PF module if SRIOV enabled */
2551 ixgbe_pf_host_configure(dev);
2553 ixgbe_dev_phy_intr_setup(dev);
2555 /* check and configure queue intr-vector mapping */
2556 if ((rte_intr_cap_multiple(intr_handle) ||
2557 !RTE_ETH_DEV_SRIOV(dev).active) &&
2558 dev->data->dev_conf.intr_conf.rxq != 0) {
2559 intr_vector = dev->data->nb_rx_queues;
2560 if (intr_vector > IXGBE_MAX_INTR_QUEUE_NUM) {
2561 PMD_INIT_LOG(ERR, "At most %d intr queues supported",
2562 IXGBE_MAX_INTR_QUEUE_NUM);
2565 if (rte_intr_efd_enable(intr_handle, intr_vector))
2569 if (rte_intr_dp_is_en(intr_handle) && !intr_handle->intr_vec) {
2570 intr_handle->intr_vec =
2571 rte_zmalloc("intr_vec",
2572 dev->data->nb_rx_queues * sizeof(int), 0);
2573 if (intr_handle->intr_vec == NULL) {
2574 PMD_INIT_LOG(ERR, "Failed to allocate %d rx_queues"
2575 " intr_vec", dev->data->nb_rx_queues);
2580 /* confiugre msix for sleep until rx interrupt */
2581 ixgbe_configure_msix(dev);
2583 /* initialize transmission unit */
2584 ixgbe_dev_tx_init(dev);
2586 /* This can fail when allocating mbufs for descriptor rings */
2587 err = ixgbe_dev_rx_init(dev);
2589 PMD_INIT_LOG(ERR, "Unable to initialize RX hardware");
2593 mask = ETH_VLAN_STRIP_MASK | ETH_VLAN_FILTER_MASK |
2594 ETH_VLAN_EXTEND_MASK;
2595 err = ixgbe_vlan_offload_set(dev, mask);
2597 PMD_INIT_LOG(ERR, "Unable to set VLAN offload");
2601 if (dev->data->dev_conf.rxmode.mq_mode == ETH_MQ_RX_VMDQ_ONLY) {
2602 /* Enable vlan filtering for VMDq */
2603 ixgbe_vmdq_vlan_hw_filter_enable(dev);
2606 /* Configure DCB hw */
2607 ixgbe_configure_dcb(dev);
2609 if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_NONE) {
2610 err = ixgbe_fdir_configure(dev);
2615 /* Restore vf rate limit */
2616 if (vfinfo != NULL) {
2617 for (vf = 0; vf < pci_dev->max_vfs; vf++)
2618 for (idx = 0; idx < IXGBE_MAX_QUEUE_NUM_PER_VF; idx++)
2619 if (vfinfo[vf].tx_rate[idx] != 0)
2620 ixgbe_set_vf_rate_limit(
2622 vfinfo[vf].tx_rate[idx],
2626 ixgbe_restore_statistics_mapping(dev);
2628 err = ixgbe_dev_rxtx_start(dev);
2630 PMD_INIT_LOG(ERR, "Unable to start rxtx queues");
2634 /* Skip link setup if loopback mode is enabled for 82599. */
2635 if (hw->mac.type == ixgbe_mac_82599EB &&
2636 dev->data->dev_conf.lpbk_mode == IXGBE_LPBK_82599_TX_RX)
2637 goto skip_link_setup;
2639 if (ixgbe_is_sfp(hw) && hw->phy.multispeed_fiber) {
2640 err = hw->mac.ops.setup_sfp(hw);
2645 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper) {
2646 /* Turn on the copper */
2647 ixgbe_set_phy_power(hw, true);
2649 /* Turn on the laser */
2650 ixgbe_enable_tx_laser(hw);
2653 err = ixgbe_check_link(hw, &speed, &link_up, 0);
2656 dev->data->dev_link.link_status = link_up;
2658 err = ixgbe_get_link_capabilities(hw, &speed, &negotiate);
2662 link_speeds = &dev->data->dev_conf.link_speeds;
2663 if (*link_speeds & ~(ETH_LINK_SPEED_100M | ETH_LINK_SPEED_1G |
2664 ETH_LINK_SPEED_10G)) {
2665 PMD_INIT_LOG(ERR, "Invalid link setting");
2670 if (*link_speeds == ETH_LINK_SPEED_AUTONEG) {
2671 switch (hw->mac.type) {
2672 case ixgbe_mac_82598EB:
2673 speed = IXGBE_LINK_SPEED_82598_AUTONEG;
2675 case ixgbe_mac_82599EB:
2676 case ixgbe_mac_X540:
2677 speed = IXGBE_LINK_SPEED_82599_AUTONEG;
2679 case ixgbe_mac_X550:
2680 case ixgbe_mac_X550EM_x:
2681 case ixgbe_mac_X550EM_a:
2682 speed = IXGBE_LINK_SPEED_X550_AUTONEG;
2685 speed = IXGBE_LINK_SPEED_82599_AUTONEG;
2688 if (*link_speeds & ETH_LINK_SPEED_10G)
2689 speed |= IXGBE_LINK_SPEED_10GB_FULL;
2690 if (*link_speeds & ETH_LINK_SPEED_1G)
2691 speed |= IXGBE_LINK_SPEED_1GB_FULL;
2692 if (*link_speeds & ETH_LINK_SPEED_100M)
2693 speed |= IXGBE_LINK_SPEED_100_FULL;
2696 err = ixgbe_setup_link(hw, speed, link_up);
2702 if (rte_intr_allow_others(intr_handle)) {
2703 /* check if lsc interrupt is enabled */
2704 if (dev->data->dev_conf.intr_conf.lsc != 0)
2705 ixgbe_dev_lsc_interrupt_setup(dev, TRUE);
2707 ixgbe_dev_lsc_interrupt_setup(dev, FALSE);
2708 ixgbe_dev_macsec_interrupt_setup(dev);
2710 rte_intr_callback_unregister(intr_handle,
2711 ixgbe_dev_interrupt_handler, dev);
2712 if (dev->data->dev_conf.intr_conf.lsc != 0)
2713 PMD_INIT_LOG(INFO, "lsc won't enable because of"
2714 " no intr multiplex");
2717 /* check if rxq interrupt is enabled */
2718 if (dev->data->dev_conf.intr_conf.rxq != 0 &&
2719 rte_intr_dp_is_en(intr_handle))
2720 ixgbe_dev_rxq_interrupt_setup(dev);
2722 /* enable uio/vfio intr/eventfd mapping */
2723 rte_intr_enable(intr_handle);
2725 /* resume enabled intr since hw reset */
2726 ixgbe_enable_intr(dev);
2727 ixgbe_l2_tunnel_conf(dev);
2728 ixgbe_filter_restore(dev);
2730 if (tm_conf->root && !tm_conf->committed)
2731 PMD_DRV_LOG(WARNING,
2732 "please call hierarchy_commit() "
2733 "before starting the port");
2738 PMD_INIT_LOG(ERR, "failure in ixgbe_dev_start(): %d", err);
2739 ixgbe_dev_clear_queues(dev);
2744 * Stop device: disable rx and tx functions to allow for reconfiguring.
2747 ixgbe_dev_stop(struct rte_eth_dev *dev)
2749 struct rte_eth_link link;
2750 struct ixgbe_hw *hw =
2751 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2752 struct ixgbe_vf_info *vfinfo =
2753 *IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private);
2754 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
2755 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
2757 struct ixgbe_tm_conf *tm_conf =
2758 IXGBE_DEV_PRIVATE_TO_TM_CONF(dev->data->dev_private);
2760 PMD_INIT_FUNC_TRACE();
2762 /* disable interrupts */
2763 ixgbe_disable_intr(hw);
2766 ixgbe_pf_reset_hw(hw);
2767 hw->adapter_stopped = 0;
2770 ixgbe_stop_adapter(hw);
2772 for (vf = 0; vfinfo != NULL && vf < pci_dev->max_vfs; vf++)
2773 vfinfo[vf].clear_to_send = false;
2775 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper) {
2776 /* Turn off the copper */
2777 ixgbe_set_phy_power(hw, false);
2779 /* Turn off the laser */
2780 ixgbe_disable_tx_laser(hw);
2783 ixgbe_dev_clear_queues(dev);
2785 /* Clear stored conf */
2786 dev->data->scattered_rx = 0;
2789 /* Clear recorded link status */
2790 memset(&link, 0, sizeof(link));
2791 rte_ixgbe_dev_atomic_write_link_status(dev, &link);
2793 if (!rte_intr_allow_others(intr_handle))
2794 /* resume to the default handler */
2795 rte_intr_callback_register(intr_handle,
2796 ixgbe_dev_interrupt_handler,
2799 /* Clean datapath event and queue/vec mapping */
2800 rte_intr_efd_disable(intr_handle);
2801 if (intr_handle->intr_vec != NULL) {
2802 rte_free(intr_handle->intr_vec);
2803 intr_handle->intr_vec = NULL;
2806 /* reset hierarchy commit */
2807 tm_conf->committed = false;
2811 * Set device link up: enable tx.
2814 ixgbe_dev_set_link_up(struct rte_eth_dev *dev)
2816 struct ixgbe_hw *hw =
2817 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2818 if (hw->mac.type == ixgbe_mac_82599EB) {
2819 #ifdef RTE_LIBRTE_IXGBE_BYPASS
2820 if (hw->device_id == IXGBE_DEV_ID_82599_BYPASS) {
2821 /* Not suported in bypass mode */
2822 PMD_INIT_LOG(ERR, "Set link up is not supported "
2823 "by device id 0x%x", hw->device_id);
2829 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper) {
2830 /* Turn on the copper */
2831 ixgbe_set_phy_power(hw, true);
2833 /* Turn on the laser */
2834 ixgbe_enable_tx_laser(hw);
2841 * Set device link down: disable tx.
2844 ixgbe_dev_set_link_down(struct rte_eth_dev *dev)
2846 struct ixgbe_hw *hw =
2847 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2848 if (hw->mac.type == ixgbe_mac_82599EB) {
2849 #ifdef RTE_LIBRTE_IXGBE_BYPASS
2850 if (hw->device_id == IXGBE_DEV_ID_82599_BYPASS) {
2851 /* Not suported in bypass mode */
2852 PMD_INIT_LOG(ERR, "Set link down is not supported "
2853 "by device id 0x%x", hw->device_id);
2859 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper) {
2860 /* Turn off the copper */
2861 ixgbe_set_phy_power(hw, false);
2863 /* Turn off the laser */
2864 ixgbe_disable_tx_laser(hw);
2871 * Reset and stop device.
2874 ixgbe_dev_close(struct rte_eth_dev *dev)
2876 struct ixgbe_hw *hw =
2877 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2879 PMD_INIT_FUNC_TRACE();
2881 ixgbe_pf_reset_hw(hw);
2883 ixgbe_dev_stop(dev);
2884 hw->adapter_stopped = 1;
2886 ixgbe_dev_free_queues(dev);
2888 ixgbe_disable_pcie_master(hw);
2890 /* reprogram the RAR[0] in case user changed it. */
2891 ixgbe_set_rar(hw, 0, hw->mac.addr, 0, IXGBE_RAH_AV);
2898 ixgbe_dev_reset(struct rte_eth_dev *dev)
2902 /* When a DPDK PMD PF begin to reset PF port, it should notify all
2903 * its VF to make them align with it. The detailed notification
2904 * mechanism is PMD specific. As to ixgbe PF, it is rather complex.
2905 * To avoid unexpected behavior in VF, currently reset of PF with
2906 * SR-IOV activation is not supported. It might be supported later.
2908 if (dev->data->sriov.active)
2911 ret = eth_ixgbe_dev_uninit(dev);
2915 ret = eth_ixgbe_dev_init(dev);
2921 ixgbe_read_stats_registers(struct ixgbe_hw *hw,
2922 struct ixgbe_hw_stats *hw_stats,
2923 struct ixgbe_macsec_stats *macsec_stats,
2924 uint64_t *total_missed_rx, uint64_t *total_qbrc,
2925 uint64_t *total_qprc, uint64_t *total_qprdc)
2927 uint32_t bprc, lxon, lxoff, total;
2928 uint32_t delta_gprc = 0;
2930 /* Workaround for RX byte count not including CRC bytes when CRC
2931 * strip is enabled. CRC bytes are removed from counters when crc_strip
2934 int crc_strip = (IXGBE_READ_REG(hw, IXGBE_HLREG0) &
2935 IXGBE_HLREG0_RXCRCSTRP);
2937 hw_stats->crcerrs += IXGBE_READ_REG(hw, IXGBE_CRCERRS);
2938 hw_stats->illerrc += IXGBE_READ_REG(hw, IXGBE_ILLERRC);
2939 hw_stats->errbc += IXGBE_READ_REG(hw, IXGBE_ERRBC);
2940 hw_stats->mspdc += IXGBE_READ_REG(hw, IXGBE_MSPDC);
2942 for (i = 0; i < 8; i++) {
2943 uint32_t mp = IXGBE_READ_REG(hw, IXGBE_MPC(i));
2945 /* global total per queue */
2946 hw_stats->mpc[i] += mp;
2947 /* Running comprehensive total for stats display */
2948 *total_missed_rx += hw_stats->mpc[i];
2949 if (hw->mac.type == ixgbe_mac_82598EB) {
2950 hw_stats->rnbc[i] +=
2951 IXGBE_READ_REG(hw, IXGBE_RNBC(i));
2952 hw_stats->pxonrxc[i] +=
2953 IXGBE_READ_REG(hw, IXGBE_PXONRXC(i));
2954 hw_stats->pxoffrxc[i] +=
2955 IXGBE_READ_REG(hw, IXGBE_PXOFFRXC(i));
2957 hw_stats->pxonrxc[i] +=
2958 IXGBE_READ_REG(hw, IXGBE_PXONRXCNT(i));
2959 hw_stats->pxoffrxc[i] +=
2960 IXGBE_READ_REG(hw, IXGBE_PXOFFRXCNT(i));
2961 hw_stats->pxon2offc[i] +=
2962 IXGBE_READ_REG(hw, IXGBE_PXON2OFFCNT(i));
2964 hw_stats->pxontxc[i] +=
2965 IXGBE_READ_REG(hw, IXGBE_PXONTXC(i));
2966 hw_stats->pxofftxc[i] +=
2967 IXGBE_READ_REG(hw, IXGBE_PXOFFTXC(i));
2969 for (i = 0; i < IXGBE_QUEUE_STAT_COUNTERS; i++) {
2970 uint32_t delta_qprc = IXGBE_READ_REG(hw, IXGBE_QPRC(i));
2971 uint32_t delta_qptc = IXGBE_READ_REG(hw, IXGBE_QPTC(i));
2972 uint32_t delta_qprdc = IXGBE_READ_REG(hw, IXGBE_QPRDC(i));
2974 delta_gprc += delta_qprc;
2976 hw_stats->qprc[i] += delta_qprc;
2977 hw_stats->qptc[i] += delta_qptc;
2979 hw_stats->qbrc[i] += IXGBE_READ_REG(hw, IXGBE_QBRC_L(i));
2980 hw_stats->qbrc[i] +=
2981 ((uint64_t)IXGBE_READ_REG(hw, IXGBE_QBRC_H(i)) << 32);
2983 hw_stats->qbrc[i] -= delta_qprc * ETHER_CRC_LEN;
2985 hw_stats->qbtc[i] += IXGBE_READ_REG(hw, IXGBE_QBTC_L(i));
2986 hw_stats->qbtc[i] +=
2987 ((uint64_t)IXGBE_READ_REG(hw, IXGBE_QBTC_H(i)) << 32);
2989 hw_stats->qprdc[i] += delta_qprdc;
2990 *total_qprdc += hw_stats->qprdc[i];
2992 *total_qprc += hw_stats->qprc[i];
2993 *total_qbrc += hw_stats->qbrc[i];
2995 hw_stats->mlfc += IXGBE_READ_REG(hw, IXGBE_MLFC);
2996 hw_stats->mrfc += IXGBE_READ_REG(hw, IXGBE_MRFC);
2997 hw_stats->rlec += IXGBE_READ_REG(hw, IXGBE_RLEC);
3000 * An errata states that gprc actually counts good + missed packets:
3001 * Workaround to set gprc to summated queue packet receives
3003 hw_stats->gprc = *total_qprc;
3005 if (hw->mac.type != ixgbe_mac_82598EB) {
3006 hw_stats->gorc += IXGBE_READ_REG(hw, IXGBE_GORCL);
3007 hw_stats->gorc += ((u64)IXGBE_READ_REG(hw, IXGBE_GORCH) << 32);
3008 hw_stats->gotc += IXGBE_READ_REG(hw, IXGBE_GOTCL);
3009 hw_stats->gotc += ((u64)IXGBE_READ_REG(hw, IXGBE_GOTCH) << 32);
3010 hw_stats->tor += IXGBE_READ_REG(hw, IXGBE_TORL);
3011 hw_stats->tor += ((u64)IXGBE_READ_REG(hw, IXGBE_TORH) << 32);
3012 hw_stats->lxonrxc += IXGBE_READ_REG(hw, IXGBE_LXONRXCNT);
3013 hw_stats->lxoffrxc += IXGBE_READ_REG(hw, IXGBE_LXOFFRXCNT);
3015 hw_stats->lxonrxc += IXGBE_READ_REG(hw, IXGBE_LXONRXC);
3016 hw_stats->lxoffrxc += IXGBE_READ_REG(hw, IXGBE_LXOFFRXC);
3017 /* 82598 only has a counter in the high register */
3018 hw_stats->gorc += IXGBE_READ_REG(hw, IXGBE_GORCH);
3019 hw_stats->gotc += IXGBE_READ_REG(hw, IXGBE_GOTCH);
3020 hw_stats->tor += IXGBE_READ_REG(hw, IXGBE_TORH);
3022 uint64_t old_tpr = hw_stats->tpr;
3024 hw_stats->tpr += IXGBE_READ_REG(hw, IXGBE_TPR);
3025 hw_stats->tpt += IXGBE_READ_REG(hw, IXGBE_TPT);
3028 hw_stats->gorc -= delta_gprc * ETHER_CRC_LEN;
3030 uint64_t delta_gptc = IXGBE_READ_REG(hw, IXGBE_GPTC);
3031 hw_stats->gptc += delta_gptc;
3032 hw_stats->gotc -= delta_gptc * ETHER_CRC_LEN;
3033 hw_stats->tor -= (hw_stats->tpr - old_tpr) * ETHER_CRC_LEN;
3036 * Workaround: mprc hardware is incorrectly counting
3037 * broadcasts, so for now we subtract those.
3039 bprc = IXGBE_READ_REG(hw, IXGBE_BPRC);
3040 hw_stats->bprc += bprc;
3041 hw_stats->mprc += IXGBE_READ_REG(hw, IXGBE_MPRC);
3042 if (hw->mac.type == ixgbe_mac_82598EB)
3043 hw_stats->mprc -= bprc;
3045 hw_stats->prc64 += IXGBE_READ_REG(hw, IXGBE_PRC64);
3046 hw_stats->prc127 += IXGBE_READ_REG(hw, IXGBE_PRC127);
3047 hw_stats->prc255 += IXGBE_READ_REG(hw, IXGBE_PRC255);
3048 hw_stats->prc511 += IXGBE_READ_REG(hw, IXGBE_PRC511);
3049 hw_stats->prc1023 += IXGBE_READ_REG(hw, IXGBE_PRC1023);
3050 hw_stats->prc1522 += IXGBE_READ_REG(hw, IXGBE_PRC1522);
3052 lxon = IXGBE_READ_REG(hw, IXGBE_LXONTXC);
3053 hw_stats->lxontxc += lxon;
3054 lxoff = IXGBE_READ_REG(hw, IXGBE_LXOFFTXC);
3055 hw_stats->lxofftxc += lxoff;
3056 total = lxon + lxoff;
3058 hw_stats->mptc += IXGBE_READ_REG(hw, IXGBE_MPTC);
3059 hw_stats->ptc64 += IXGBE_READ_REG(hw, IXGBE_PTC64);
3060 hw_stats->gptc -= total;
3061 hw_stats->mptc -= total;
3062 hw_stats->ptc64 -= total;
3063 hw_stats->gotc -= total * ETHER_MIN_LEN;
3065 hw_stats->ruc += IXGBE_READ_REG(hw, IXGBE_RUC);
3066 hw_stats->rfc += IXGBE_READ_REG(hw, IXGBE_RFC);
3067 hw_stats->roc += IXGBE_READ_REG(hw, IXGBE_ROC);
3068 hw_stats->rjc += IXGBE_READ_REG(hw, IXGBE_RJC);
3069 hw_stats->mngprc += IXGBE_READ_REG(hw, IXGBE_MNGPRC);
3070 hw_stats->mngpdc += IXGBE_READ_REG(hw, IXGBE_MNGPDC);
3071 hw_stats->mngptc += IXGBE_READ_REG(hw, IXGBE_MNGPTC);
3072 hw_stats->ptc127 += IXGBE_READ_REG(hw, IXGBE_PTC127);
3073 hw_stats->ptc255 += IXGBE_READ_REG(hw, IXGBE_PTC255);
3074 hw_stats->ptc511 += IXGBE_READ_REG(hw, IXGBE_PTC511);
3075 hw_stats->ptc1023 += IXGBE_READ_REG(hw, IXGBE_PTC1023);
3076 hw_stats->ptc1522 += IXGBE_READ_REG(hw, IXGBE_PTC1522);
3077 hw_stats->bptc += IXGBE_READ_REG(hw, IXGBE_BPTC);
3078 hw_stats->xec += IXGBE_READ_REG(hw, IXGBE_XEC);
3079 hw_stats->fccrc += IXGBE_READ_REG(hw, IXGBE_FCCRC);
3080 hw_stats->fclast += IXGBE_READ_REG(hw, IXGBE_FCLAST);
3081 /* Only read FCOE on 82599 */
3082 if (hw->mac.type != ixgbe_mac_82598EB) {
3083 hw_stats->fcoerpdc += IXGBE_READ_REG(hw, IXGBE_FCOERPDC);
3084 hw_stats->fcoeprc += IXGBE_READ_REG(hw, IXGBE_FCOEPRC);
3085 hw_stats->fcoeptc += IXGBE_READ_REG(hw, IXGBE_FCOEPTC);
3086 hw_stats->fcoedwrc += IXGBE_READ_REG(hw, IXGBE_FCOEDWRC);
3087 hw_stats->fcoedwtc += IXGBE_READ_REG(hw, IXGBE_FCOEDWTC);
3090 /* Flow Director Stats registers */
3091 hw_stats->fdirmatch += IXGBE_READ_REG(hw, IXGBE_FDIRMATCH);
3092 hw_stats->fdirmiss += IXGBE_READ_REG(hw, IXGBE_FDIRMISS);
3094 /* MACsec Stats registers */
3095 macsec_stats->out_pkts_untagged += IXGBE_READ_REG(hw, IXGBE_LSECTXUT);
3096 macsec_stats->out_pkts_encrypted +=
3097 IXGBE_READ_REG(hw, IXGBE_LSECTXPKTE);
3098 macsec_stats->out_pkts_protected +=
3099 IXGBE_READ_REG(hw, IXGBE_LSECTXPKTP);
3100 macsec_stats->out_octets_encrypted +=
3101 IXGBE_READ_REG(hw, IXGBE_LSECTXOCTE);
3102 macsec_stats->out_octets_protected +=
3103 IXGBE_READ_REG(hw, IXGBE_LSECTXOCTP);
3104 macsec_stats->in_pkts_untagged += IXGBE_READ_REG(hw, IXGBE_LSECRXUT);
3105 macsec_stats->in_pkts_badtag += IXGBE_READ_REG(hw, IXGBE_LSECRXBAD);
3106 macsec_stats->in_pkts_nosci += IXGBE_READ_REG(hw, IXGBE_LSECRXNOSCI);
3107 macsec_stats->in_pkts_unknownsci +=
3108 IXGBE_READ_REG(hw, IXGBE_LSECRXUNSCI);
3109 macsec_stats->in_octets_decrypted +=
3110 IXGBE_READ_REG(hw, IXGBE_LSECRXOCTD);
3111 macsec_stats->in_octets_validated +=
3112 IXGBE_READ_REG(hw, IXGBE_LSECRXOCTV);
3113 macsec_stats->in_pkts_unchecked += IXGBE_READ_REG(hw, IXGBE_LSECRXUNCH);
3114 macsec_stats->in_pkts_delayed += IXGBE_READ_REG(hw, IXGBE_LSECRXDELAY);
3115 macsec_stats->in_pkts_late += IXGBE_READ_REG(hw, IXGBE_LSECRXLATE);
3116 for (i = 0; i < 2; i++) {
3117 macsec_stats->in_pkts_ok +=
3118 IXGBE_READ_REG(hw, IXGBE_LSECRXOK(i));
3119 macsec_stats->in_pkts_invalid +=
3120 IXGBE_READ_REG(hw, IXGBE_LSECRXINV(i));
3121 macsec_stats->in_pkts_notvalid +=
3122 IXGBE_READ_REG(hw, IXGBE_LSECRXNV(i));
3124 macsec_stats->in_pkts_unusedsa += IXGBE_READ_REG(hw, IXGBE_LSECRXUNSA);
3125 macsec_stats->in_pkts_notusingsa +=
3126 IXGBE_READ_REG(hw, IXGBE_LSECRXNUSA);
3130 * This function is based on ixgbe_update_stats_counters() in ixgbe/ixgbe.c
3133 ixgbe_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
3135 struct ixgbe_hw *hw =
3136 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3137 struct ixgbe_hw_stats *hw_stats =
3138 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3139 struct ixgbe_macsec_stats *macsec_stats =
3140 IXGBE_DEV_PRIVATE_TO_MACSEC_STATS(
3141 dev->data->dev_private);
3142 uint64_t total_missed_rx, total_qbrc, total_qprc, total_qprdc;
3145 total_missed_rx = 0;
3150 ixgbe_read_stats_registers(hw, hw_stats, macsec_stats, &total_missed_rx,
3151 &total_qbrc, &total_qprc, &total_qprdc);
3156 /* Fill out the rte_eth_stats statistics structure */
3157 stats->ipackets = total_qprc;
3158 stats->ibytes = total_qbrc;
3159 stats->opackets = hw_stats->gptc;
3160 stats->obytes = hw_stats->gotc;
3162 for (i = 0; i < IXGBE_QUEUE_STAT_COUNTERS; i++) {
3163 stats->q_ipackets[i] = hw_stats->qprc[i];
3164 stats->q_opackets[i] = hw_stats->qptc[i];
3165 stats->q_ibytes[i] = hw_stats->qbrc[i];
3166 stats->q_obytes[i] = hw_stats->qbtc[i];
3167 stats->q_errors[i] = hw_stats->qprdc[i];
3171 stats->imissed = total_missed_rx;
3172 stats->ierrors = hw_stats->crcerrs +
3189 ixgbe_dev_stats_reset(struct rte_eth_dev *dev)
3191 struct ixgbe_hw_stats *stats =
3192 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3194 /* HW registers are cleared on read */
3195 ixgbe_dev_stats_get(dev, NULL);
3197 /* Reset software totals */
3198 memset(stats, 0, sizeof(*stats));
3201 /* This function calculates the number of xstats based on the current config */
3203 ixgbe_xstats_calc_num(void) {
3204 return IXGBE_NB_HW_STATS + IXGBE_NB_MACSEC_STATS +
3205 (IXGBE_NB_RXQ_PRIO_STATS * IXGBE_NB_RXQ_PRIO_VALUES) +
3206 (IXGBE_NB_TXQ_PRIO_STATS * IXGBE_NB_TXQ_PRIO_VALUES);
3209 static int ixgbe_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
3210 struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned int size)
3212 const unsigned cnt_stats = ixgbe_xstats_calc_num();
3213 unsigned stat, i, count;
3215 if (xstats_names != NULL) {
3218 /* Note: limit >= cnt_stats checked upstream
3219 * in rte_eth_xstats_names()
3222 /* Extended stats from ixgbe_hw_stats */
3223 for (i = 0; i < IXGBE_NB_HW_STATS; i++) {
3224 snprintf(xstats_names[count].name,
3225 sizeof(xstats_names[count].name),
3227 rte_ixgbe_stats_strings[i].name);
3232 for (i = 0; i < IXGBE_NB_MACSEC_STATS; i++) {
3233 snprintf(xstats_names[count].name,
3234 sizeof(xstats_names[count].name),
3236 rte_ixgbe_macsec_strings[i].name);
3240 /* RX Priority Stats */
3241 for (stat = 0; stat < IXGBE_NB_RXQ_PRIO_STATS; stat++) {
3242 for (i = 0; i < IXGBE_NB_RXQ_PRIO_VALUES; i++) {
3243 snprintf(xstats_names[count].name,
3244 sizeof(xstats_names[count].name),
3245 "rx_priority%u_%s", i,
3246 rte_ixgbe_rxq_strings[stat].name);
3251 /* TX Priority Stats */
3252 for (stat = 0; stat < IXGBE_NB_TXQ_PRIO_STATS; stat++) {
3253 for (i = 0; i < IXGBE_NB_TXQ_PRIO_VALUES; i++) {
3254 snprintf(xstats_names[count].name,
3255 sizeof(xstats_names[count].name),
3256 "tx_priority%u_%s", i,
3257 rte_ixgbe_txq_strings[stat].name);
3265 static int ixgbe_dev_xstats_get_names_by_id(
3266 struct rte_eth_dev *dev,
3267 struct rte_eth_xstat_name *xstats_names,
3268 const uint64_t *ids,
3272 const unsigned int cnt_stats = ixgbe_xstats_calc_num();
3273 unsigned int stat, i, count;
3275 if (xstats_names != NULL) {
3278 /* Note: limit >= cnt_stats checked upstream
3279 * in rte_eth_xstats_names()
3282 /* Extended stats from ixgbe_hw_stats */
3283 for (i = 0; i < IXGBE_NB_HW_STATS; i++) {
3284 snprintf(xstats_names[count].name,
3285 sizeof(xstats_names[count].name),
3287 rte_ixgbe_stats_strings[i].name);
3292 for (i = 0; i < IXGBE_NB_MACSEC_STATS; i++) {
3293 snprintf(xstats_names[count].name,
3294 sizeof(xstats_names[count].name),
3296 rte_ixgbe_macsec_strings[i].name);
3300 /* RX Priority Stats */
3301 for (stat = 0; stat < IXGBE_NB_RXQ_PRIO_STATS; stat++) {
3302 for (i = 0; i < IXGBE_NB_RXQ_PRIO_VALUES; i++) {
3303 snprintf(xstats_names[count].name,
3304 sizeof(xstats_names[count].name),
3305 "rx_priority%u_%s", i,
3306 rte_ixgbe_rxq_strings[stat].name);
3311 /* TX Priority Stats */
3312 for (stat = 0; stat < IXGBE_NB_TXQ_PRIO_STATS; stat++) {
3313 for (i = 0; i < IXGBE_NB_TXQ_PRIO_VALUES; i++) {
3314 snprintf(xstats_names[count].name,
3315 sizeof(xstats_names[count].name),
3316 "tx_priority%u_%s", i,
3317 rte_ixgbe_txq_strings[stat].name);
3326 uint16_t size = ixgbe_xstats_calc_num();
3327 struct rte_eth_xstat_name xstats_names_copy[size];
3329 ixgbe_dev_xstats_get_names_by_id(dev, xstats_names_copy, NULL,
3332 for (i = 0; i < limit; i++) {
3333 if (ids[i] >= size) {
3334 PMD_INIT_LOG(ERR, "id value isn't valid");
3337 strcpy(xstats_names[i].name,
3338 xstats_names_copy[ids[i]].name);
3343 static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
3344 struct rte_eth_xstat_name *xstats_names, unsigned limit)
3348 if (limit < IXGBEVF_NB_XSTATS && xstats_names != NULL)
3351 if (xstats_names != NULL)
3352 for (i = 0; i < IXGBEVF_NB_XSTATS; i++)
3353 snprintf(xstats_names[i].name,
3354 sizeof(xstats_names[i].name),
3355 "%s", rte_ixgbevf_stats_strings[i].name);
3356 return IXGBEVF_NB_XSTATS;
3360 ixgbe_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
3363 struct ixgbe_hw *hw =
3364 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3365 struct ixgbe_hw_stats *hw_stats =
3366 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3367 struct ixgbe_macsec_stats *macsec_stats =
3368 IXGBE_DEV_PRIVATE_TO_MACSEC_STATS(
3369 dev->data->dev_private);
3370 uint64_t total_missed_rx, total_qbrc, total_qprc, total_qprdc;
3371 unsigned i, stat, count = 0;
3373 count = ixgbe_xstats_calc_num();
3378 total_missed_rx = 0;
3383 ixgbe_read_stats_registers(hw, hw_stats, macsec_stats, &total_missed_rx,
3384 &total_qbrc, &total_qprc, &total_qprdc);
3386 /* If this is a reset xstats is NULL, and we have cleared the
3387 * registers by reading them.
3392 /* Extended stats from ixgbe_hw_stats */
3394 for (i = 0; i < IXGBE_NB_HW_STATS; i++) {
3395 xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
3396 rte_ixgbe_stats_strings[i].offset);
3397 xstats[count].id = count;
3402 for (i = 0; i < IXGBE_NB_MACSEC_STATS; i++) {
3403 xstats[count].value = *(uint64_t *)(((char *)macsec_stats) +
3404 rte_ixgbe_macsec_strings[i].offset);
3405 xstats[count].id = count;
3409 /* RX Priority Stats */
3410 for (stat = 0; stat < IXGBE_NB_RXQ_PRIO_STATS; stat++) {
3411 for (i = 0; i < IXGBE_NB_RXQ_PRIO_VALUES; i++) {
3412 xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
3413 rte_ixgbe_rxq_strings[stat].offset +
3414 (sizeof(uint64_t) * i));
3415 xstats[count].id = count;
3420 /* TX Priority Stats */
3421 for (stat = 0; stat < IXGBE_NB_TXQ_PRIO_STATS; stat++) {
3422 for (i = 0; i < IXGBE_NB_TXQ_PRIO_VALUES; i++) {
3423 xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
3424 rte_ixgbe_txq_strings[stat].offset +
3425 (sizeof(uint64_t) * i));
3426 xstats[count].id = count;
3434 ixgbe_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids,
3435 uint64_t *values, unsigned int n)
3438 struct ixgbe_hw *hw =
3439 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3440 struct ixgbe_hw_stats *hw_stats =
3441 IXGBE_DEV_PRIVATE_TO_STATS(
3442 dev->data->dev_private);
3443 struct ixgbe_macsec_stats *macsec_stats =
3444 IXGBE_DEV_PRIVATE_TO_MACSEC_STATS(
3445 dev->data->dev_private);
3446 uint64_t total_missed_rx, total_qbrc, total_qprc, total_qprdc;
3447 unsigned int i, stat, count = 0;
3449 count = ixgbe_xstats_calc_num();
3451 if (!ids && n < count)
3454 total_missed_rx = 0;
3459 ixgbe_read_stats_registers(hw, hw_stats, macsec_stats,
3460 &total_missed_rx, &total_qbrc, &total_qprc,
3463 /* If this is a reset xstats is NULL, and we have cleared the
3464 * registers by reading them.
3466 if (!ids && !values)
3469 /* Extended stats from ixgbe_hw_stats */
3471 for (i = 0; i < IXGBE_NB_HW_STATS; i++) {
3472 values[count] = *(uint64_t *)(((char *)hw_stats) +
3473 rte_ixgbe_stats_strings[i].offset);
3478 for (i = 0; i < IXGBE_NB_MACSEC_STATS; i++) {
3479 values[count] = *(uint64_t *)(((char *)macsec_stats) +
3480 rte_ixgbe_macsec_strings[i].offset);
3484 /* RX Priority Stats */
3485 for (stat = 0; stat < IXGBE_NB_RXQ_PRIO_STATS; stat++) {
3486 for (i = 0; i < IXGBE_NB_RXQ_PRIO_VALUES; i++) {
3488 *(uint64_t *)(((char *)hw_stats) +
3489 rte_ixgbe_rxq_strings[stat].offset +
3490 (sizeof(uint64_t) * i));
3495 /* TX Priority Stats */
3496 for (stat = 0; stat < IXGBE_NB_TXQ_PRIO_STATS; stat++) {
3497 for (i = 0; i < IXGBE_NB_TXQ_PRIO_VALUES; i++) {
3499 *(uint64_t *)(((char *)hw_stats) +
3500 rte_ixgbe_txq_strings[stat].offset +
3501 (sizeof(uint64_t) * i));
3509 uint16_t size = ixgbe_xstats_calc_num();
3510 uint64_t values_copy[size];
3512 ixgbe_dev_xstats_get_by_id(dev, NULL, values_copy, size);
3514 for (i = 0; i < n; i++) {
3515 if (ids[i] >= size) {
3516 PMD_INIT_LOG(ERR, "id value isn't valid");
3519 values[i] = values_copy[ids[i]];
3525 ixgbe_dev_xstats_reset(struct rte_eth_dev *dev)
3527 struct ixgbe_hw_stats *stats =
3528 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3529 struct ixgbe_macsec_stats *macsec_stats =
3530 IXGBE_DEV_PRIVATE_TO_MACSEC_STATS(
3531 dev->data->dev_private);
3533 unsigned count = ixgbe_xstats_calc_num();
3535 /* HW registers are cleared on read */
3536 ixgbe_dev_xstats_get(dev, NULL, count);
3538 /* Reset software totals */
3539 memset(stats, 0, sizeof(*stats));
3540 memset(macsec_stats, 0, sizeof(*macsec_stats));
3544 ixgbevf_update_stats(struct rte_eth_dev *dev)
3546 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3547 struct ixgbevf_hw_stats *hw_stats = (struct ixgbevf_hw_stats *)
3548 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3550 /* Good Rx packet, include VF loopback */
3551 UPDATE_VF_STAT(IXGBE_VFGPRC,
3552 hw_stats->last_vfgprc, hw_stats->vfgprc);
3554 /* Good Rx octets, include VF loopback */
3555 UPDATE_VF_STAT_36BIT(IXGBE_VFGORC_LSB, IXGBE_VFGORC_MSB,
3556 hw_stats->last_vfgorc, hw_stats->vfgorc);
3558 /* Good Tx packet, include VF loopback */
3559 UPDATE_VF_STAT(IXGBE_VFGPTC,
3560 hw_stats->last_vfgptc, hw_stats->vfgptc);
3562 /* Good Tx octets, include VF loopback */
3563 UPDATE_VF_STAT_36BIT(IXGBE_VFGOTC_LSB, IXGBE_VFGOTC_MSB,
3564 hw_stats->last_vfgotc, hw_stats->vfgotc);
3566 /* Rx Multicst Packet */
3567 UPDATE_VF_STAT(IXGBE_VFMPRC,
3568 hw_stats->last_vfmprc, hw_stats->vfmprc);
3572 ixgbevf_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
3575 struct ixgbevf_hw_stats *hw_stats = (struct ixgbevf_hw_stats *)
3576 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3579 if (n < IXGBEVF_NB_XSTATS)
3580 return IXGBEVF_NB_XSTATS;
3582 ixgbevf_update_stats(dev);
3587 /* Extended stats */
3588 for (i = 0; i < IXGBEVF_NB_XSTATS; i++) {
3590 xstats[i].value = *(uint64_t *)(((char *)hw_stats) +
3591 rte_ixgbevf_stats_strings[i].offset);
3594 return IXGBEVF_NB_XSTATS;
3598 ixgbevf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
3600 struct ixgbevf_hw_stats *hw_stats = (struct ixgbevf_hw_stats *)
3601 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3603 ixgbevf_update_stats(dev);
3608 stats->ipackets = hw_stats->vfgprc;
3609 stats->ibytes = hw_stats->vfgorc;
3610 stats->opackets = hw_stats->vfgptc;
3611 stats->obytes = hw_stats->vfgotc;
3616 ixgbevf_dev_stats_reset(struct rte_eth_dev *dev)
3618 struct ixgbevf_hw_stats *hw_stats = (struct ixgbevf_hw_stats *)
3619 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3621 /* Sync HW register to the last stats */
3622 ixgbevf_dev_stats_get(dev, NULL);
3624 /* reset HW current stats*/
3625 hw_stats->vfgprc = 0;
3626 hw_stats->vfgorc = 0;
3627 hw_stats->vfgptc = 0;
3628 hw_stats->vfgotc = 0;
3632 ixgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size)
3634 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3635 u16 eeprom_verh, eeprom_verl;
3639 ixgbe_read_eeprom(hw, 0x2e, &eeprom_verh);
3640 ixgbe_read_eeprom(hw, 0x2d, &eeprom_verl);
3642 etrack_id = (eeprom_verh << 16) | eeprom_verl;
3643 ret = snprintf(fw_version, fw_size, "0x%08x", etrack_id);
3645 ret += 1; /* add the size of '\0' */
3646 if (fw_size < (u32)ret)
3653 ixgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
3655 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
3656 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3657 struct rte_eth_conf *dev_conf = &dev->data->dev_conf;
3659 dev_info->pci_dev = pci_dev;
3660 dev_info->max_rx_queues = (uint16_t)hw->mac.max_rx_queues;
3661 dev_info->max_tx_queues = (uint16_t)hw->mac.max_tx_queues;
3662 if (RTE_ETH_DEV_SRIOV(dev).active == 0) {
3664 * When DCB/VT is off, maximum number of queues changes,
3665 * except for 82598EB, which remains constant.
3667 if (dev_conf->txmode.mq_mode == ETH_MQ_TX_NONE &&
3668 hw->mac.type != ixgbe_mac_82598EB)
3669 dev_info->max_tx_queues = IXGBE_NONE_MODE_TX_NB_QUEUES;
3671 dev_info->min_rx_bufsize = 1024; /* cf BSIZEPACKET in SRRCTL register */
3672 dev_info->max_rx_pktlen = 15872; /* includes CRC, cf MAXFRS register */
3673 dev_info->max_mac_addrs = hw->mac.num_rar_entries;
3674 dev_info->max_hash_mac_addrs = IXGBE_VMDQ_NUM_UC_MAC;
3675 dev_info->max_vfs = pci_dev->max_vfs;
3676 if (hw->mac.type == ixgbe_mac_82598EB)
3677 dev_info->max_vmdq_pools = ETH_16_POOLS;
3679 dev_info->max_vmdq_pools = ETH_64_POOLS;
3680 dev_info->vmdq_queue_num = dev_info->max_rx_queues;
3681 dev_info->rx_offload_capa =
3682 DEV_RX_OFFLOAD_VLAN_STRIP |
3683 DEV_RX_OFFLOAD_IPV4_CKSUM |
3684 DEV_RX_OFFLOAD_UDP_CKSUM |
3685 DEV_RX_OFFLOAD_TCP_CKSUM;
3688 * RSC is only supported by 82599 and x540 PF devices in a non-SR-IOV
3691 if ((hw->mac.type == ixgbe_mac_82599EB ||
3692 hw->mac.type == ixgbe_mac_X540) &&
3693 !RTE_ETH_DEV_SRIOV(dev).active)
3694 dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_TCP_LRO;
3696 if (hw->mac.type == ixgbe_mac_82599EB ||
3697 hw->mac.type == ixgbe_mac_X540)
3698 dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_MACSEC_STRIP;
3700 if (hw->mac.type == ixgbe_mac_X550 ||
3701 hw->mac.type == ixgbe_mac_X550EM_x ||
3702 hw->mac.type == ixgbe_mac_X550EM_a)
3703 dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM;
3705 dev_info->tx_offload_capa =
3706 DEV_TX_OFFLOAD_VLAN_INSERT |
3707 DEV_TX_OFFLOAD_IPV4_CKSUM |
3708 DEV_TX_OFFLOAD_UDP_CKSUM |
3709 DEV_TX_OFFLOAD_TCP_CKSUM |
3710 DEV_TX_OFFLOAD_SCTP_CKSUM |
3711 DEV_TX_OFFLOAD_TCP_TSO;
3713 if (hw->mac.type == ixgbe_mac_82599EB ||
3714 hw->mac.type == ixgbe_mac_X540)
3715 dev_info->tx_offload_capa |= DEV_TX_OFFLOAD_MACSEC_INSERT;
3717 if (hw->mac.type == ixgbe_mac_X550 ||
3718 hw->mac.type == ixgbe_mac_X550EM_x ||
3719 hw->mac.type == ixgbe_mac_X550EM_a)
3720 dev_info->tx_offload_capa |= DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
3722 #ifdef RTE_LIBRTE_SECURITY
3723 dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_SECURITY;
3724 dev_info->tx_offload_capa |= DEV_TX_OFFLOAD_SECURITY;
3727 dev_info->default_rxconf = (struct rte_eth_rxconf) {
3729 .pthresh = IXGBE_DEFAULT_RX_PTHRESH,
3730 .hthresh = IXGBE_DEFAULT_RX_HTHRESH,
3731 .wthresh = IXGBE_DEFAULT_RX_WTHRESH,
3733 .rx_free_thresh = IXGBE_DEFAULT_RX_FREE_THRESH,
3737 dev_info->default_txconf = (struct rte_eth_txconf) {
3739 .pthresh = IXGBE_DEFAULT_TX_PTHRESH,
3740 .hthresh = IXGBE_DEFAULT_TX_HTHRESH,
3741 .wthresh = IXGBE_DEFAULT_TX_WTHRESH,
3743 .tx_free_thresh = IXGBE_DEFAULT_TX_FREE_THRESH,
3744 .tx_rs_thresh = IXGBE_DEFAULT_TX_RSBIT_THRESH,
3745 .txq_flags = ETH_TXQ_FLAGS_NOMULTSEGS |
3746 ETH_TXQ_FLAGS_NOOFFLOADS,
3749 dev_info->rx_desc_lim = rx_desc_lim;
3750 dev_info->tx_desc_lim = tx_desc_lim;
3752 dev_info->hash_key_size = IXGBE_HKEY_MAX_INDEX * sizeof(uint32_t);
3753 dev_info->reta_size = ixgbe_reta_size_get(hw->mac.type);
3754 dev_info->flow_type_rss_offloads = IXGBE_RSS_OFFLOAD_ALL;
3756 dev_info->speed_capa = ETH_LINK_SPEED_1G | ETH_LINK_SPEED_10G;
3757 if (hw->mac.type == ixgbe_mac_X540 ||
3758 hw->mac.type == ixgbe_mac_X540_vf ||
3759 hw->mac.type == ixgbe_mac_X550 ||
3760 hw->mac.type == ixgbe_mac_X550_vf) {
3761 dev_info->speed_capa |= ETH_LINK_SPEED_100M;
3763 if (hw->mac.type == ixgbe_mac_X550) {
3764 dev_info->speed_capa |= ETH_LINK_SPEED_2_5G;
3765 dev_info->speed_capa |= ETH_LINK_SPEED_5G;
3769 static const uint32_t *
3770 ixgbe_dev_supported_ptypes_get(struct rte_eth_dev *dev)
3772 static const uint32_t ptypes[] = {
3773 /* For non-vec functions,
3774 * refers to ixgbe_rxd_pkt_info_to_pkt_type();
3775 * for vec functions,
3776 * refers to _recv_raw_pkts_vec().
3780 RTE_PTYPE_L3_IPV4_EXT,
3782 RTE_PTYPE_L3_IPV6_EXT,
3786 RTE_PTYPE_TUNNEL_IP,
3787 RTE_PTYPE_INNER_L3_IPV6,
3788 RTE_PTYPE_INNER_L3_IPV6_EXT,
3789 RTE_PTYPE_INNER_L4_TCP,
3790 RTE_PTYPE_INNER_L4_UDP,
3794 if (dev->rx_pkt_burst == ixgbe_recv_pkts ||
3795 dev->rx_pkt_burst == ixgbe_recv_pkts_lro_single_alloc ||
3796 dev->rx_pkt_burst == ixgbe_recv_pkts_lro_bulk_alloc ||
3797 dev->rx_pkt_burst == ixgbe_recv_pkts_bulk_alloc)
3800 #if defined(RTE_ARCH_X86)
3801 if (dev->rx_pkt_burst == ixgbe_recv_pkts_vec ||
3802 dev->rx_pkt_burst == ixgbe_recv_scattered_pkts_vec)
3809 ixgbevf_dev_info_get(struct rte_eth_dev *dev,
3810 struct rte_eth_dev_info *dev_info)
3812 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
3813 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3815 dev_info->pci_dev = pci_dev;
3816 dev_info->max_rx_queues = (uint16_t)hw->mac.max_rx_queues;
3817 dev_info->max_tx_queues = (uint16_t)hw->mac.max_tx_queues;
3818 dev_info->min_rx_bufsize = 1024; /* cf BSIZEPACKET in SRRCTL reg */
3819 dev_info->max_rx_pktlen = 9728; /* includes CRC, cf MAXFRS reg */
3820 dev_info->max_mac_addrs = hw->mac.num_rar_entries;
3821 dev_info->max_hash_mac_addrs = IXGBE_VMDQ_NUM_UC_MAC;
3822 dev_info->max_vfs = pci_dev->max_vfs;
3823 if (hw->mac.type == ixgbe_mac_82598EB)
3824 dev_info->max_vmdq_pools = ETH_16_POOLS;
3826 dev_info->max_vmdq_pools = ETH_64_POOLS;
3827 dev_info->rx_offload_capa = DEV_RX_OFFLOAD_VLAN_STRIP |
3828 DEV_RX_OFFLOAD_IPV4_CKSUM |
3829 DEV_RX_OFFLOAD_UDP_CKSUM |
3830 DEV_RX_OFFLOAD_TCP_CKSUM;
3831 dev_info->tx_offload_capa = DEV_TX_OFFLOAD_VLAN_INSERT |
3832 DEV_TX_OFFLOAD_IPV4_CKSUM |
3833 DEV_TX_OFFLOAD_UDP_CKSUM |
3834 DEV_TX_OFFLOAD_TCP_CKSUM |
3835 DEV_TX_OFFLOAD_SCTP_CKSUM |
3836 DEV_TX_OFFLOAD_TCP_TSO;
3838 dev_info->default_rxconf = (struct rte_eth_rxconf) {
3840 .pthresh = IXGBE_DEFAULT_RX_PTHRESH,
3841 .hthresh = IXGBE_DEFAULT_RX_HTHRESH,
3842 .wthresh = IXGBE_DEFAULT_RX_WTHRESH,
3844 .rx_free_thresh = IXGBE_DEFAULT_RX_FREE_THRESH,
3848 dev_info->default_txconf = (struct rte_eth_txconf) {
3850 .pthresh = IXGBE_DEFAULT_TX_PTHRESH,
3851 .hthresh = IXGBE_DEFAULT_TX_HTHRESH,
3852 .wthresh = IXGBE_DEFAULT_TX_WTHRESH,
3854 .tx_free_thresh = IXGBE_DEFAULT_TX_FREE_THRESH,
3855 .tx_rs_thresh = IXGBE_DEFAULT_TX_RSBIT_THRESH,
3856 .txq_flags = ETH_TXQ_FLAGS_NOMULTSEGS |
3857 ETH_TXQ_FLAGS_NOOFFLOADS,
3860 dev_info->rx_desc_lim = rx_desc_lim;
3861 dev_info->tx_desc_lim = tx_desc_lim;
3865 ixgbevf_check_link(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
3866 int *link_up, int wait_to_complete)
3869 * for a quick link status checking, wait_to_compelet == 0,
3870 * skip PF link status checking
3872 bool no_pflink_check = wait_to_complete == 0;
3873 struct ixgbe_mbx_info *mbx = &hw->mbx;
3874 struct ixgbe_mac_info *mac = &hw->mac;
3875 uint32_t links_reg, in_msg;
3878 /* If we were hit with a reset drop the link */
3879 if (!mbx->ops.check_for_rst(hw, 0) || !mbx->timeout)
3880 mac->get_link_status = true;
3882 if (!mac->get_link_status)
3885 /* if link status is down no point in checking to see if pf is up */
3886 links_reg = IXGBE_READ_REG(hw, IXGBE_VFLINKS);
3887 if (!(links_reg & IXGBE_LINKS_UP))
3890 /* for SFP+ modules and DA cables on 82599 it can take up to 500usecs
3891 * before the link status is correct
3893 if (mac->type == ixgbe_mac_82599_vf && wait_to_complete) {
3896 for (i = 0; i < 5; i++) {
3898 links_reg = IXGBE_READ_REG(hw, IXGBE_VFLINKS);
3900 if (!(links_reg & IXGBE_LINKS_UP))
3905 switch (links_reg & IXGBE_LINKS_SPEED_82599) {
3906 case IXGBE_LINKS_SPEED_10G_82599:
3907 *speed = IXGBE_LINK_SPEED_10GB_FULL;
3908 if (hw->mac.type >= ixgbe_mac_X550) {
3909 if (links_reg & IXGBE_LINKS_SPEED_NON_STD)
3910 *speed = IXGBE_LINK_SPEED_2_5GB_FULL;
3913 case IXGBE_LINKS_SPEED_1G_82599:
3914 *speed = IXGBE_LINK_SPEED_1GB_FULL;
3916 case IXGBE_LINKS_SPEED_100_82599:
3917 *speed = IXGBE_LINK_SPEED_100_FULL;
3918 if (hw->mac.type == ixgbe_mac_X550) {
3919 if (links_reg & IXGBE_LINKS_SPEED_NON_STD)
3920 *speed = IXGBE_LINK_SPEED_5GB_FULL;
3923 case IXGBE_LINKS_SPEED_10_X550EM_A:
3924 *speed = IXGBE_LINK_SPEED_UNKNOWN;
3925 /* Since Reserved in older MAC's */
3926 if (hw->mac.type >= ixgbe_mac_X550)
3927 *speed = IXGBE_LINK_SPEED_10_FULL;
3930 *speed = IXGBE_LINK_SPEED_UNKNOWN;
3933 if (no_pflink_check) {
3934 if (*speed == IXGBE_LINK_SPEED_UNKNOWN)
3935 mac->get_link_status = true;
3937 mac->get_link_status = false;
3941 /* if the read failed it could just be a mailbox collision, best wait
3942 * until we are called again and don't report an error
3944 if (mbx->ops.read(hw, &in_msg, 1, 0))
3947 if (!(in_msg & IXGBE_VT_MSGTYPE_CTS)) {
3948 /* msg is not CTS and is NACK we must have lost CTS status */
3949 if (in_msg & IXGBE_VT_MSGTYPE_NACK)
3954 /* the pf is talking, if we timed out in the past we reinit */
3955 if (!mbx->timeout) {
3960 /* if we passed all the tests above then the link is up and we no
3961 * longer need to check for link
3963 mac->get_link_status = false;
3966 *link_up = !mac->get_link_status;
3970 /* return 0 means link status changed, -1 means not changed */
3972 ixgbe_dev_link_update_share(struct rte_eth_dev *dev,
3973 int wait_to_complete, int vf)
3975 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3976 struct rte_eth_link link, old;
3977 ixgbe_link_speed link_speed = IXGBE_LINK_SPEED_UNKNOWN;
3978 struct ixgbe_interrupt *intr =
3979 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
3984 bool autoneg = false;
3986 link.link_status = ETH_LINK_DOWN;
3987 link.link_speed = 0;
3988 link.link_duplex = ETH_LINK_HALF_DUPLEX;
3989 link.link_autoneg = ETH_LINK_AUTONEG;
3990 memset(&old, 0, sizeof(old));
3991 rte_ixgbe_dev_atomic_read_link_status(dev, &old);
3993 hw->mac.get_link_status = true;
3995 if ((intr->flags & IXGBE_FLAG_NEED_LINK_CONFIG) &&
3996 ixgbe_get_media_type(hw) == ixgbe_media_type_fiber) {
3997 speed = hw->phy.autoneg_advertised;
3999 ixgbe_get_link_capabilities(hw, &speed, &autoneg);
4000 ixgbe_setup_link(hw, speed, true);
4003 /* check if it needs to wait to complete, if lsc interrupt is enabled */
4004 if (wait_to_complete == 0 || dev->data->dev_conf.intr_conf.lsc != 0)
4008 diag = ixgbevf_check_link(hw, &link_speed, &link_up, wait);
4010 diag = ixgbe_check_link(hw, &link_speed, &link_up, wait);
4013 link.link_speed = ETH_SPEED_NUM_100M;
4014 link.link_duplex = ETH_LINK_FULL_DUPLEX;
4015 rte_ixgbe_dev_atomic_write_link_status(dev, &link);
4016 if (link.link_status == old.link_status)
4022 rte_ixgbe_dev_atomic_write_link_status(dev, &link);
4023 intr->flags |= IXGBE_FLAG_NEED_LINK_CONFIG;
4024 if (link.link_status == old.link_status)
4028 intr->flags &= ~IXGBE_FLAG_NEED_LINK_CONFIG;
4029 link.link_status = ETH_LINK_UP;
4030 link.link_duplex = ETH_LINK_FULL_DUPLEX;
4032 switch (link_speed) {
4034 case IXGBE_LINK_SPEED_UNKNOWN:
4035 link.link_duplex = ETH_LINK_FULL_DUPLEX;
4036 link.link_speed = ETH_SPEED_NUM_100M;
4039 case IXGBE_LINK_SPEED_100_FULL:
4040 link.link_speed = ETH_SPEED_NUM_100M;
4043 case IXGBE_LINK_SPEED_1GB_FULL:
4044 link.link_speed = ETH_SPEED_NUM_1G;
4047 case IXGBE_LINK_SPEED_2_5GB_FULL:
4048 link.link_speed = ETH_SPEED_NUM_2_5G;
4051 case IXGBE_LINK_SPEED_5GB_FULL:
4052 link.link_speed = ETH_SPEED_NUM_5G;
4055 case IXGBE_LINK_SPEED_10GB_FULL:
4056 link.link_speed = ETH_SPEED_NUM_10G;
4059 rte_ixgbe_dev_atomic_write_link_status(dev, &link);
4061 if (link.link_status == old.link_status)
4068 ixgbe_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
4070 return ixgbe_dev_link_update_share(dev, wait_to_complete, 0);
4074 ixgbevf_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
4076 return ixgbe_dev_link_update_share(dev, wait_to_complete, 1);
4080 ixgbe_dev_promiscuous_enable(struct rte_eth_dev *dev)
4082 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4085 fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
4086 fctrl |= (IXGBE_FCTRL_UPE | IXGBE_FCTRL_MPE);
4087 IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
4091 ixgbe_dev_promiscuous_disable(struct rte_eth_dev *dev)
4093 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4096 fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
4097 fctrl &= (~IXGBE_FCTRL_UPE);
4098 if (dev->data->all_multicast == 1)
4099 fctrl |= IXGBE_FCTRL_MPE;
4101 fctrl &= (~IXGBE_FCTRL_MPE);
4102 IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
4106 ixgbe_dev_allmulticast_enable(struct rte_eth_dev *dev)
4108 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4111 fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
4112 fctrl |= IXGBE_FCTRL_MPE;
4113 IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
4117 ixgbe_dev_allmulticast_disable(struct rte_eth_dev *dev)
4119 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4122 if (dev->data->promiscuous == 1)
4123 return; /* must remain in all_multicast mode */
4125 fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
4126 fctrl &= (~IXGBE_FCTRL_MPE);
4127 IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
4131 * It clears the interrupt causes and enables the interrupt.
4132 * It will be called once only during nic initialized.
4135 * Pointer to struct rte_eth_dev.
4137 * Enable or Disable.
4140 * - On success, zero.
4141 * - On failure, a negative value.
4144 ixgbe_dev_lsc_interrupt_setup(struct rte_eth_dev *dev, uint8_t on)
4146 struct ixgbe_interrupt *intr =
4147 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
4149 ixgbe_dev_link_status_print(dev);
4151 intr->mask |= IXGBE_EICR_LSC;
4153 intr->mask &= ~IXGBE_EICR_LSC;
4159 * It clears the interrupt causes and enables the interrupt.
4160 * It will be called once only during nic initialized.
4163 * Pointer to struct rte_eth_dev.
4166 * - On success, zero.
4167 * - On failure, a negative value.
4170 ixgbe_dev_rxq_interrupt_setup(struct rte_eth_dev *dev)
4172 struct ixgbe_interrupt *intr =
4173 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
4175 intr->mask |= IXGBE_EICR_RTX_QUEUE;
4181 * It clears the interrupt causes and enables the interrupt.
4182 * It will be called once only during nic initialized.
4185 * Pointer to struct rte_eth_dev.
4188 * - On success, zero.
4189 * - On failure, a negative value.
4192 ixgbe_dev_macsec_interrupt_setup(struct rte_eth_dev *dev)
4194 struct ixgbe_interrupt *intr =
4195 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
4197 intr->mask |= IXGBE_EICR_LINKSEC;
4203 * It reads ICR and sets flag (IXGBE_EICR_LSC) for the link_update.
4206 * Pointer to struct rte_eth_dev.
4209 * - On success, zero.
4210 * - On failure, a negative value.
4213 ixgbe_dev_interrupt_get_status(struct rte_eth_dev *dev)
4216 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4217 struct ixgbe_interrupt *intr =
4218 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
4220 /* clear all cause mask */
4221 ixgbe_disable_intr(hw);
4223 /* read-on-clear nic registers here */
4224 eicr = IXGBE_READ_REG(hw, IXGBE_EICR);
4225 PMD_DRV_LOG(DEBUG, "eicr %x", eicr);
4229 /* set flag for async link update */
4230 if (eicr & IXGBE_EICR_LSC)
4231 intr->flags |= IXGBE_FLAG_NEED_LINK_UPDATE;
4233 if (eicr & IXGBE_EICR_MAILBOX)
4234 intr->flags |= IXGBE_FLAG_MAILBOX;
4236 if (eicr & IXGBE_EICR_LINKSEC)
4237 intr->flags |= IXGBE_FLAG_MACSEC;
4239 if (hw->mac.type == ixgbe_mac_X550EM_x &&
4240 hw->phy.type == ixgbe_phy_x550em_ext_t &&
4241 (eicr & IXGBE_EICR_GPI_SDP0_X550EM_x))
4242 intr->flags |= IXGBE_FLAG_PHY_INTERRUPT;
4248 * It gets and then prints the link status.
4251 * Pointer to struct rte_eth_dev.
4254 * - On success, zero.
4255 * - On failure, a negative value.
4258 ixgbe_dev_link_status_print(struct rte_eth_dev *dev)
4260 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
4261 struct rte_eth_link link;
4263 memset(&link, 0, sizeof(link));
4264 rte_ixgbe_dev_atomic_read_link_status(dev, &link);
4265 if (link.link_status) {
4266 PMD_INIT_LOG(INFO, "Port %d: Link Up - speed %u Mbps - %s",
4267 (int)(dev->data->port_id),
4268 (unsigned)link.link_speed,
4269 link.link_duplex == ETH_LINK_FULL_DUPLEX ?
4270 "full-duplex" : "half-duplex");
4272 PMD_INIT_LOG(INFO, " Port %d: Link Down",
4273 (int)(dev->data->port_id));
4275 PMD_INIT_LOG(DEBUG, "PCI Address: " PCI_PRI_FMT,
4276 pci_dev->addr.domain,
4278 pci_dev->addr.devid,
4279 pci_dev->addr.function);
4283 * It executes link_update after knowing an interrupt occurred.
4286 * Pointer to struct rte_eth_dev.
4289 * - On success, zero.
4290 * - On failure, a negative value.
4293 ixgbe_dev_interrupt_action(struct rte_eth_dev *dev,
4294 struct rte_intr_handle *intr_handle)
4296 struct ixgbe_interrupt *intr =
4297 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
4299 struct rte_eth_link link;
4300 struct ixgbe_hw *hw =
4301 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4303 PMD_DRV_LOG(DEBUG, "intr action type %d", intr->flags);
4305 if (intr->flags & IXGBE_FLAG_MAILBOX) {
4306 ixgbe_pf_mbx_process(dev);
4307 intr->flags &= ~IXGBE_FLAG_MAILBOX;
4310 if (intr->flags & IXGBE_FLAG_PHY_INTERRUPT) {
4311 ixgbe_handle_lasi(hw);
4312 intr->flags &= ~IXGBE_FLAG_PHY_INTERRUPT;
4315 if (intr->flags & IXGBE_FLAG_NEED_LINK_UPDATE) {
4316 /* get the link status before link update, for predicting later */
4317 memset(&link, 0, sizeof(link));
4318 rte_ixgbe_dev_atomic_read_link_status(dev, &link);
4320 ixgbe_dev_link_update(dev, 0);
4323 if (!link.link_status)
4324 /* handle it 1 sec later, wait it being stable */
4325 timeout = IXGBE_LINK_UP_CHECK_TIMEOUT;
4326 /* likely to down */
4328 /* handle it 4 sec later, wait it being stable */
4329 timeout = IXGBE_LINK_DOWN_CHECK_TIMEOUT;
4331 ixgbe_dev_link_status_print(dev);
4332 if (rte_eal_alarm_set(timeout * 1000,
4333 ixgbe_dev_interrupt_delayed_handler, (void *)dev) < 0)
4334 PMD_DRV_LOG(ERR, "Error setting alarm");
4336 /* remember original mask */
4337 intr->mask_original = intr->mask;
4338 /* only disable lsc interrupt */
4339 intr->mask &= ~IXGBE_EIMS_LSC;
4343 PMD_DRV_LOG(DEBUG, "enable intr immediately");
4344 ixgbe_enable_intr(dev);
4345 rte_intr_enable(intr_handle);
4351 * Interrupt handler which shall be registered for alarm callback for delayed
4352 * handling specific interrupt to wait for the stable nic state. As the
4353 * NIC interrupt state is not stable for ixgbe after link is just down,
4354 * it needs to wait 4 seconds to get the stable status.
4357 * Pointer to interrupt handle.
4359 * The address of parameter (struct rte_eth_dev *) regsitered before.
4365 ixgbe_dev_interrupt_delayed_handler(void *param)
4367 struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
4368 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
4369 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
4370 struct ixgbe_interrupt *intr =
4371 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
4372 struct ixgbe_hw *hw =
4373 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4376 ixgbe_disable_intr(hw);
4378 eicr = IXGBE_READ_REG(hw, IXGBE_EICR);
4379 if (eicr & IXGBE_EICR_MAILBOX)
4380 ixgbe_pf_mbx_process(dev);
4382 if (intr->flags & IXGBE_FLAG_PHY_INTERRUPT) {
4383 ixgbe_handle_lasi(hw);
4384 intr->flags &= ~IXGBE_FLAG_PHY_INTERRUPT;
4387 if (intr->flags & IXGBE_FLAG_NEED_LINK_UPDATE) {
4388 ixgbe_dev_link_update(dev, 0);
4389 intr->flags &= ~IXGBE_FLAG_NEED_LINK_UPDATE;
4390 ixgbe_dev_link_status_print(dev);
4391 _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC,
4395 if (intr->flags & IXGBE_FLAG_MACSEC) {
4396 _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_MACSEC,
4398 intr->flags &= ~IXGBE_FLAG_MACSEC;
4401 /* restore original mask */
4402 intr->mask = intr->mask_original;
4403 intr->mask_original = 0;
4405 PMD_DRV_LOG(DEBUG, "enable intr in delayed handler S[%08x]", eicr);
4406 ixgbe_enable_intr(dev);
4407 rte_intr_enable(intr_handle);
4411 * Interrupt handler triggered by NIC for handling
4412 * specific interrupt.
4415 * Pointer to interrupt handle.
4417 * The address of parameter (struct rte_eth_dev *) regsitered before.
4423 ixgbe_dev_interrupt_handler(void *param)
4425 struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
4427 ixgbe_dev_interrupt_get_status(dev);
4428 ixgbe_dev_interrupt_action(dev, dev->intr_handle);
4432 ixgbe_dev_led_on(struct rte_eth_dev *dev)
4434 struct ixgbe_hw *hw;
4436 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4437 return ixgbe_led_on(hw, 0) == IXGBE_SUCCESS ? 0 : -ENOTSUP;
4441 ixgbe_dev_led_off(struct rte_eth_dev *dev)
4443 struct ixgbe_hw *hw;
4445 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4446 return ixgbe_led_off(hw, 0) == IXGBE_SUCCESS ? 0 : -ENOTSUP;
4450 ixgbe_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
4452 struct ixgbe_hw *hw;
4458 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4460 fc_conf->pause_time = hw->fc.pause_time;
4461 fc_conf->high_water = hw->fc.high_water[0];
4462 fc_conf->low_water = hw->fc.low_water[0];
4463 fc_conf->send_xon = hw->fc.send_xon;
4464 fc_conf->autoneg = !hw->fc.disable_fc_autoneg;
4467 * Return rx_pause status according to actual setting of
4470 mflcn_reg = IXGBE_READ_REG(hw, IXGBE_MFLCN);
4471 if (mflcn_reg & (IXGBE_MFLCN_RPFCE | IXGBE_MFLCN_RFCE))
4477 * Return tx_pause status according to actual setting of
4480 fccfg_reg = IXGBE_READ_REG(hw, IXGBE_FCCFG);
4481 if (fccfg_reg & (IXGBE_FCCFG_TFCE_802_3X | IXGBE_FCCFG_TFCE_PRIORITY))
4486 if (rx_pause && tx_pause)
4487 fc_conf->mode = RTE_FC_FULL;
4489 fc_conf->mode = RTE_FC_RX_PAUSE;
4491 fc_conf->mode = RTE_FC_TX_PAUSE;
4493 fc_conf->mode = RTE_FC_NONE;
4499 ixgbe_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
4501 struct ixgbe_hw *hw;
4503 uint32_t rx_buf_size;
4504 uint32_t max_high_water;
4506 enum ixgbe_fc_mode rte_fcmode_2_ixgbe_fcmode[] = {
4513 PMD_INIT_FUNC_TRACE();
4515 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4516 rx_buf_size = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(0));
4517 PMD_INIT_LOG(DEBUG, "Rx packet buffer size = 0x%x", rx_buf_size);
4520 * At least reserve one Ethernet frame for watermark
4521 * high_water/low_water in kilo bytes for ixgbe
4523 max_high_water = (rx_buf_size - ETHER_MAX_LEN) >> IXGBE_RXPBSIZE_SHIFT;
4524 if ((fc_conf->high_water > max_high_water) ||
4525 (fc_conf->high_water < fc_conf->low_water)) {
4526 PMD_INIT_LOG(ERR, "Invalid high/low water setup value in KB");
4527 PMD_INIT_LOG(ERR, "High_water must <= 0x%x", max_high_water);
4531 hw->fc.requested_mode = rte_fcmode_2_ixgbe_fcmode[fc_conf->mode];
4532 hw->fc.pause_time = fc_conf->pause_time;
4533 hw->fc.high_water[0] = fc_conf->high_water;
4534 hw->fc.low_water[0] = fc_conf->low_water;
4535 hw->fc.send_xon = fc_conf->send_xon;
4536 hw->fc.disable_fc_autoneg = !fc_conf->autoneg;
4538 err = ixgbe_fc_enable(hw);
4540 /* Not negotiated is not an error case */
4541 if ((err == IXGBE_SUCCESS) || (err == IXGBE_ERR_FC_NOT_NEGOTIATED)) {
4543 /* check if we want to forward MAC frames - driver doesn't have native
4544 * capability to do that, so we'll write the registers ourselves */
4546 mflcn = IXGBE_READ_REG(hw, IXGBE_MFLCN);
4548 /* set or clear MFLCN.PMCF bit depending on configuration */
4549 if (fc_conf->mac_ctrl_frame_fwd != 0)
4550 mflcn |= IXGBE_MFLCN_PMCF;
4552 mflcn &= ~IXGBE_MFLCN_PMCF;
4554 IXGBE_WRITE_REG(hw, IXGBE_MFLCN, mflcn);
4555 IXGBE_WRITE_FLUSH(hw);
4560 PMD_INIT_LOG(ERR, "ixgbe_fc_enable = 0x%x", err);
4565 * ixgbe_pfc_enable_generic - Enable flow control
4566 * @hw: pointer to hardware structure
4567 * @tc_num: traffic class number
4568 * Enable flow control according to the current settings.
4571 ixgbe_dcb_pfc_enable_generic(struct ixgbe_hw *hw, uint8_t tc_num)
4574 uint32_t mflcn_reg, fccfg_reg;
4576 uint32_t fcrtl, fcrth;
4580 /* Validate the water mark configuration */
4581 if (!hw->fc.pause_time) {
4582 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
4586 /* Low water mark of zero causes XOFF floods */
4587 if (hw->fc.current_mode & ixgbe_fc_tx_pause) {
4588 /* High/Low water can not be 0 */
4589 if ((!hw->fc.high_water[tc_num]) || (!hw->fc.low_water[tc_num])) {
4590 PMD_INIT_LOG(ERR, "Invalid water mark configuration");
4591 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
4595 if (hw->fc.low_water[tc_num] >= hw->fc.high_water[tc_num]) {
4596 PMD_INIT_LOG(ERR, "Invalid water mark configuration");
4597 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
4601 /* Negotiate the fc mode to use */
4602 ixgbe_fc_autoneg(hw);
4604 /* Disable any previous flow control settings */
4605 mflcn_reg = IXGBE_READ_REG(hw, IXGBE_MFLCN);
4606 mflcn_reg &= ~(IXGBE_MFLCN_RPFCE_SHIFT | IXGBE_MFLCN_RFCE|IXGBE_MFLCN_RPFCE);
4608 fccfg_reg = IXGBE_READ_REG(hw, IXGBE_FCCFG);
4609 fccfg_reg &= ~(IXGBE_FCCFG_TFCE_802_3X | IXGBE_FCCFG_TFCE_PRIORITY);
4611 switch (hw->fc.current_mode) {
4614 * If the count of enabled RX Priority Flow control >1,
4615 * and the TX pause can not be disabled
4618 for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
4619 reg = IXGBE_READ_REG(hw, IXGBE_FCRTH_82599(i));
4620 if (reg & IXGBE_FCRTH_FCEN)
4624 fccfg_reg |= IXGBE_FCCFG_TFCE_PRIORITY;
4626 case ixgbe_fc_rx_pause:
4628 * Rx Flow control is enabled and Tx Flow control is
4629 * disabled by software override. Since there really
4630 * isn't a way to advertise that we are capable of RX
4631 * Pause ONLY, we will advertise that we support both
4632 * symmetric and asymmetric Rx PAUSE. Later, we will
4633 * disable the adapter's ability to send PAUSE frames.
4635 mflcn_reg |= IXGBE_MFLCN_RPFCE;
4637 * If the count of enabled RX Priority Flow control >1,
4638 * and the TX pause can not be disabled
4641 for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
4642 reg = IXGBE_READ_REG(hw, IXGBE_FCRTH_82599(i));
4643 if (reg & IXGBE_FCRTH_FCEN)
4647 fccfg_reg |= IXGBE_FCCFG_TFCE_PRIORITY;
4649 case ixgbe_fc_tx_pause:
4651 * Tx Flow control is enabled, and Rx Flow control is
4652 * disabled by software override.
4654 fccfg_reg |= IXGBE_FCCFG_TFCE_PRIORITY;
4657 /* Flow control (both Rx and Tx) is enabled by SW override. */
4658 mflcn_reg |= IXGBE_MFLCN_RPFCE;
4659 fccfg_reg |= IXGBE_FCCFG_TFCE_PRIORITY;
4662 PMD_DRV_LOG(DEBUG, "Flow control param set incorrectly");
4663 ret_val = IXGBE_ERR_CONFIG;
4667 /* Set 802.3x based flow control settings. */
4668 mflcn_reg |= IXGBE_MFLCN_DPF;
4669 IXGBE_WRITE_REG(hw, IXGBE_MFLCN, mflcn_reg);
4670 IXGBE_WRITE_REG(hw, IXGBE_FCCFG, fccfg_reg);
4672 /* Set up and enable Rx high/low water mark thresholds, enable XON. */
4673 if ((hw->fc.current_mode & ixgbe_fc_tx_pause) &&
4674 hw->fc.high_water[tc_num]) {
4675 fcrtl = (hw->fc.low_water[tc_num] << 10) | IXGBE_FCRTL_XONE;
4676 IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(tc_num), fcrtl);
4677 fcrth = (hw->fc.high_water[tc_num] << 10) | IXGBE_FCRTH_FCEN;
4679 IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(tc_num), 0);
4681 * In order to prevent Tx hangs when the internal Tx
4682 * switch is enabled we must set the high water mark
4683 * to the maximum FCRTH value. This allows the Tx
4684 * switch to function even under heavy Rx workloads.
4686 fcrth = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(tc_num)) - 32;
4688 IXGBE_WRITE_REG(hw, IXGBE_FCRTH_82599(tc_num), fcrth);
4690 /* Configure pause time (2 TCs per register) */
4691 reg = hw->fc.pause_time * 0x00010001;
4692 for (i = 0; i < (IXGBE_DCB_MAX_TRAFFIC_CLASS / 2); i++)
4693 IXGBE_WRITE_REG(hw, IXGBE_FCTTV(i), reg);
4695 /* Configure flow control refresh threshold value */
4696 IXGBE_WRITE_REG(hw, IXGBE_FCRTV, hw->fc.pause_time / 2);
4703 ixgbe_dcb_pfc_enable(struct rte_eth_dev *dev, uint8_t tc_num)
4705 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4706 int32_t ret_val = IXGBE_NOT_IMPLEMENTED;
4708 if (hw->mac.type != ixgbe_mac_82598EB) {
4709 ret_val = ixgbe_dcb_pfc_enable_generic(hw, tc_num);
4715 ixgbe_priority_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_pfc_conf *pfc_conf)
4718 uint32_t rx_buf_size;
4719 uint32_t max_high_water;
4721 uint8_t map[IXGBE_DCB_MAX_USER_PRIORITY] = { 0 };
4722 struct ixgbe_hw *hw =
4723 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4724 struct ixgbe_dcb_config *dcb_config =
4725 IXGBE_DEV_PRIVATE_TO_DCB_CFG(dev->data->dev_private);
4727 enum ixgbe_fc_mode rte_fcmode_2_ixgbe_fcmode[] = {
4734 PMD_INIT_FUNC_TRACE();
4736 ixgbe_dcb_unpack_map_cee(dcb_config, IXGBE_DCB_RX_CONFIG, map);
4737 tc_num = map[pfc_conf->priority];
4738 rx_buf_size = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(tc_num));
4739 PMD_INIT_LOG(DEBUG, "Rx packet buffer size = 0x%x", rx_buf_size);
4741 * At least reserve one Ethernet frame for watermark
4742 * high_water/low_water in kilo bytes for ixgbe
4744 max_high_water = (rx_buf_size - ETHER_MAX_LEN) >> IXGBE_RXPBSIZE_SHIFT;
4745 if ((pfc_conf->fc.high_water > max_high_water) ||
4746 (pfc_conf->fc.high_water <= pfc_conf->fc.low_water)) {
4747 PMD_INIT_LOG(ERR, "Invalid high/low water setup value in KB");
4748 PMD_INIT_LOG(ERR, "High_water must <= 0x%x", max_high_water);
4752 hw->fc.requested_mode = rte_fcmode_2_ixgbe_fcmode[pfc_conf->fc.mode];
4753 hw->fc.pause_time = pfc_conf->fc.pause_time;
4754 hw->fc.send_xon = pfc_conf->fc.send_xon;
4755 hw->fc.low_water[tc_num] = pfc_conf->fc.low_water;
4756 hw->fc.high_water[tc_num] = pfc_conf->fc.high_water;
4758 err = ixgbe_dcb_pfc_enable(dev, tc_num);
4760 /* Not negotiated is not an error case */
4761 if ((err == IXGBE_SUCCESS) || (err == IXGBE_ERR_FC_NOT_NEGOTIATED))
4764 PMD_INIT_LOG(ERR, "ixgbe_dcb_pfc_enable = 0x%x", err);
4769 ixgbe_dev_rss_reta_update(struct rte_eth_dev *dev,
4770 struct rte_eth_rss_reta_entry64 *reta_conf,
4773 uint16_t i, sp_reta_size;
4776 uint16_t idx, shift;
4777 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4780 PMD_INIT_FUNC_TRACE();
4782 if (!ixgbe_rss_update_sp(hw->mac.type)) {
4783 PMD_DRV_LOG(ERR, "RSS reta update is not supported on this "
4788 sp_reta_size = ixgbe_reta_size_get(hw->mac.type);
4789 if (reta_size != sp_reta_size) {
4790 PMD_DRV_LOG(ERR, "The size of hash lookup table configured "
4791 "(%d) doesn't match the number hardware can supported "
4792 "(%d)", reta_size, sp_reta_size);
4796 for (i = 0; i < reta_size; i += IXGBE_4_BIT_WIDTH) {
4797 idx = i / RTE_RETA_GROUP_SIZE;
4798 shift = i % RTE_RETA_GROUP_SIZE;
4799 mask = (uint8_t)((reta_conf[idx].mask >> shift) &
4803 reta_reg = ixgbe_reta_reg_get(hw->mac.type, i);
4804 if (mask == IXGBE_4_BIT_MASK)
4807 r = IXGBE_READ_REG(hw, reta_reg);
4808 for (j = 0, reta = 0; j < IXGBE_4_BIT_WIDTH; j++) {
4809 if (mask & (0x1 << j))
4810 reta |= reta_conf[idx].reta[shift + j] <<
4813 reta |= r & (IXGBE_8_BIT_MASK <<
4816 IXGBE_WRITE_REG(hw, reta_reg, reta);
4823 ixgbe_dev_rss_reta_query(struct rte_eth_dev *dev,
4824 struct rte_eth_rss_reta_entry64 *reta_conf,
4827 uint16_t i, sp_reta_size;
4830 uint16_t idx, shift;
4831 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4834 PMD_INIT_FUNC_TRACE();
4835 sp_reta_size = ixgbe_reta_size_get(hw->mac.type);
4836 if (reta_size != sp_reta_size) {
4837 PMD_DRV_LOG(ERR, "The size of hash lookup table configured "
4838 "(%d) doesn't match the number hardware can supported "
4839 "(%d)", reta_size, sp_reta_size);
4843 for (i = 0; i < reta_size; i += IXGBE_4_BIT_WIDTH) {
4844 idx = i / RTE_RETA_GROUP_SIZE;
4845 shift = i % RTE_RETA_GROUP_SIZE;
4846 mask = (uint8_t)((reta_conf[idx].mask >> shift) &
4851 reta_reg = ixgbe_reta_reg_get(hw->mac.type, i);
4852 reta = IXGBE_READ_REG(hw, reta_reg);
4853 for (j = 0; j < IXGBE_4_BIT_WIDTH; j++) {
4854 if (mask & (0x1 << j))
4855 reta_conf[idx].reta[shift + j] =
4856 ((reta >> (CHAR_BIT * j)) &
4865 ixgbe_add_rar(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
4866 uint32_t index, uint32_t pool)
4868 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4869 uint32_t enable_addr = 1;
4871 return ixgbe_set_rar(hw, index, mac_addr->addr_bytes,
4876 ixgbe_remove_rar(struct rte_eth_dev *dev, uint32_t index)
4878 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4880 ixgbe_clear_rar(hw, index);
4884 ixgbe_set_default_mac_addr(struct rte_eth_dev *dev, struct ether_addr *addr)
4886 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
4888 ixgbe_remove_rar(dev, 0);
4890 ixgbe_add_rar(dev, addr, 0, pci_dev->max_vfs);
4894 is_device_supported(struct rte_eth_dev *dev, struct rte_pci_driver *drv)
4896 if (strcmp(dev->device->driver->name, drv->driver.name))
4903 is_ixgbe_supported(struct rte_eth_dev *dev)
4905 return is_device_supported(dev, &rte_ixgbe_pmd);
4909 ixgbe_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
4913 struct ixgbe_hw *hw;
4914 struct rte_eth_dev_info dev_info;
4915 uint32_t frame_size = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
4916 struct rte_eth_dev_data *dev_data = dev->data;
4918 ixgbe_dev_info_get(dev, &dev_info);
4920 /* check that mtu is within the allowed range */
4921 if ((mtu < ETHER_MIN_MTU) || (frame_size > dev_info.max_rx_pktlen))
4924 /* If device is started, refuse mtu that requires the support of
4925 * scattered packets when this feature has not been enabled before.
4927 if (dev_data->dev_started && !dev_data->scattered_rx &&
4928 (frame_size + 2 * IXGBE_VLAN_TAG_SIZE >
4929 dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM)) {
4930 PMD_INIT_LOG(ERR, "Stop port first.");
4934 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4935 hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
4937 /* switch to jumbo mode if needed */
4938 if (frame_size > ETHER_MAX_LEN) {
4939 dev->data->dev_conf.rxmode.jumbo_frame = 1;
4940 hlreg0 |= IXGBE_HLREG0_JUMBOEN;
4942 dev->data->dev_conf.rxmode.jumbo_frame = 0;
4943 hlreg0 &= ~IXGBE_HLREG0_JUMBOEN;
4945 IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
4947 /* update max frame size */
4948 dev->data->dev_conf.rxmode.max_rx_pkt_len = frame_size;
4950 maxfrs = IXGBE_READ_REG(hw, IXGBE_MAXFRS);
4951 maxfrs &= 0x0000FFFF;
4952 maxfrs |= (dev->data->dev_conf.rxmode.max_rx_pkt_len << 16);
4953 IXGBE_WRITE_REG(hw, IXGBE_MAXFRS, maxfrs);
4959 * Virtual Function operations
4962 ixgbevf_intr_disable(struct ixgbe_hw *hw)
4964 PMD_INIT_FUNC_TRACE();
4966 /* Clear interrupt mask to stop from interrupts being generated */
4967 IXGBE_WRITE_REG(hw, IXGBE_VTEIMC, IXGBE_VF_IRQ_CLEAR_MASK);
4969 IXGBE_WRITE_FLUSH(hw);
4973 ixgbevf_intr_enable(struct ixgbe_hw *hw)
4975 PMD_INIT_FUNC_TRACE();
4977 /* VF enable interrupt autoclean */
4978 IXGBE_WRITE_REG(hw, IXGBE_VTEIAM, IXGBE_VF_IRQ_ENABLE_MASK);
4979 IXGBE_WRITE_REG(hw, IXGBE_VTEIAC, IXGBE_VF_IRQ_ENABLE_MASK);
4980 IXGBE_WRITE_REG(hw, IXGBE_VTEIMS, IXGBE_VF_IRQ_ENABLE_MASK);
4982 IXGBE_WRITE_FLUSH(hw);
4986 ixgbevf_dev_configure(struct rte_eth_dev *dev)
4988 struct rte_eth_conf *conf = &dev->data->dev_conf;
4989 struct ixgbe_adapter *adapter =
4990 (struct ixgbe_adapter *)dev->data->dev_private;
4992 PMD_INIT_LOG(DEBUG, "Configured Virtual Function port id: %d",
4993 dev->data->port_id);
4996 * VF has no ability to enable/disable HW CRC
4997 * Keep the persistent behavior the same as Host PF
4999 #ifndef RTE_LIBRTE_IXGBE_PF_DISABLE_STRIP_CRC
5000 if (!conf->rxmode.hw_strip_crc) {
5001 PMD_INIT_LOG(NOTICE, "VF can't disable HW CRC Strip");
5002 conf->rxmode.hw_strip_crc = 1;
5005 if (conf->rxmode.hw_strip_crc) {
5006 PMD_INIT_LOG(NOTICE, "VF can't enable HW CRC Strip");
5007 conf->rxmode.hw_strip_crc = 0;
5012 * Initialize to TRUE. If any of Rx queues doesn't meet the bulk
5013 * allocation or vector Rx preconditions we will reset it.
5015 adapter->rx_bulk_alloc_allowed = true;
5016 adapter->rx_vec_allowed = true;
5022 ixgbevf_dev_start(struct rte_eth_dev *dev)
5024 struct ixgbe_hw *hw =
5025 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5026 uint32_t intr_vector = 0;
5027 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
5028 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
5032 PMD_INIT_FUNC_TRACE();
5034 err = hw->mac.ops.reset_hw(hw);
5036 PMD_INIT_LOG(ERR, "Unable to reset vf hardware (%d)", err);
5039 hw->mac.get_link_status = true;
5041 /* negotiate mailbox API version to use with the PF. */
5042 ixgbevf_negotiate_api(hw);
5044 ixgbevf_dev_tx_init(dev);
5046 /* This can fail when allocating mbufs for descriptor rings */
5047 err = ixgbevf_dev_rx_init(dev);
5049 PMD_INIT_LOG(ERR, "Unable to initialize RX hardware (%d)", err);
5050 ixgbe_dev_clear_queues(dev);
5055 ixgbevf_set_vfta_all(dev, 1);
5058 mask = ETH_VLAN_STRIP_MASK | ETH_VLAN_FILTER_MASK |
5059 ETH_VLAN_EXTEND_MASK;
5060 err = ixgbevf_vlan_offload_set(dev, mask);
5062 PMD_INIT_LOG(ERR, "Unable to set VLAN offload (%d)", err);
5063 ixgbe_dev_clear_queues(dev);
5067 ixgbevf_dev_rxtx_start(dev);
5069 /* check and configure queue intr-vector mapping */
5070 if (rte_intr_cap_multiple(intr_handle) &&
5071 dev->data->dev_conf.intr_conf.rxq) {
5072 /* According to datasheet, only vector 0/1/2 can be used,
5073 * now only one vector is used for Rx queue
5076 if (rte_intr_efd_enable(intr_handle, intr_vector))
5080 if (rte_intr_dp_is_en(intr_handle) && !intr_handle->intr_vec) {
5081 intr_handle->intr_vec =
5082 rte_zmalloc("intr_vec",
5083 dev->data->nb_rx_queues * sizeof(int), 0);
5084 if (intr_handle->intr_vec == NULL) {
5085 PMD_INIT_LOG(ERR, "Failed to allocate %d rx_queues"
5086 " intr_vec", dev->data->nb_rx_queues);
5090 ixgbevf_configure_msix(dev);
5092 /* When a VF port is bound to VFIO-PCI, only miscellaneous interrupt
5093 * is mapped to VFIO vector 0 in eth_ixgbevf_dev_init( ).
5094 * If previous VFIO interrupt mapping setting in eth_ixgbevf_dev_init( )
5095 * is not cleared, it will fail when following rte_intr_enable( ) tries
5096 * to map Rx queue interrupt to other VFIO vectors.
5097 * So clear uio/vfio intr/evevnfd first to avoid failure.
5099 rte_intr_disable(intr_handle);
5101 rte_intr_enable(intr_handle);
5103 /* Re-enable interrupt for VF */
5104 ixgbevf_intr_enable(hw);
5110 ixgbevf_dev_stop(struct rte_eth_dev *dev)
5112 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5113 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
5114 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
5116 PMD_INIT_FUNC_TRACE();
5118 ixgbevf_intr_disable(hw);
5120 hw->adapter_stopped = 1;
5121 ixgbe_stop_adapter(hw);
5124 * Clear what we set, but we still keep shadow_vfta to
5125 * restore after device starts
5127 ixgbevf_set_vfta_all(dev, 0);
5129 /* Clear stored conf */
5130 dev->data->scattered_rx = 0;
5132 ixgbe_dev_clear_queues(dev);
5134 /* Clean datapath event and queue/vec mapping */
5135 rte_intr_efd_disable(intr_handle);
5136 if (intr_handle->intr_vec != NULL) {
5137 rte_free(intr_handle->intr_vec);
5138 intr_handle->intr_vec = NULL;
5143 ixgbevf_dev_close(struct rte_eth_dev *dev)
5145 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5147 PMD_INIT_FUNC_TRACE();
5151 ixgbevf_dev_stop(dev);
5153 ixgbe_dev_free_queues(dev);
5156 * Remove the VF MAC address ro ensure
5157 * that the VF traffic goes to the PF
5158 * after stop, close and detach of the VF
5160 ixgbevf_remove_mac_addr(dev, 0);
5167 ixgbevf_dev_reset(struct rte_eth_dev *dev)
5171 ret = eth_ixgbevf_dev_uninit(dev);
5175 ret = eth_ixgbevf_dev_init(dev);
5180 static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on)
5182 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5183 struct ixgbe_vfta *shadow_vfta =
5184 IXGBE_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
5185 int i = 0, j = 0, vfta = 0, mask = 1;
5187 for (i = 0; i < IXGBE_VFTA_SIZE; i++) {
5188 vfta = shadow_vfta->vfta[i];
5191 for (j = 0; j < 32; j++) {
5193 ixgbe_set_vfta(hw, (i<<5)+j, 0,
5203 ixgbevf_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
5205 struct ixgbe_hw *hw =
5206 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5207 struct ixgbe_vfta *shadow_vfta =
5208 IXGBE_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
5209 uint32_t vid_idx = 0;
5210 uint32_t vid_bit = 0;
5213 PMD_INIT_FUNC_TRACE();
5215 /* vind is not used in VF driver, set to 0, check ixgbe_set_vfta_vf */
5216 ret = ixgbe_set_vfta(hw, vlan_id, 0, !!on, false);
5218 PMD_INIT_LOG(ERR, "Unable to set VF vlan");
5221 vid_idx = (uint32_t) ((vlan_id >> 5) & 0x7F);
5222 vid_bit = (uint32_t) (1 << (vlan_id & 0x1F));
5224 /* Save what we set and retore it after device reset */
5226 shadow_vfta->vfta[vid_idx] |= vid_bit;
5228 shadow_vfta->vfta[vid_idx] &= ~vid_bit;
5234 ixgbevf_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue, int on)
5236 struct ixgbe_hw *hw =
5237 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5240 PMD_INIT_FUNC_TRACE();
5242 if (queue >= hw->mac.max_rx_queues)
5245 ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(queue));
5247 ctrl |= IXGBE_RXDCTL_VME;
5249 ctrl &= ~IXGBE_RXDCTL_VME;
5250 IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(queue), ctrl);
5252 ixgbe_vlan_hw_strip_bitmap_set(dev, queue, on);
5256 ixgbevf_vlan_offload_set(struct rte_eth_dev *dev, int mask)
5258 struct ixgbe_hw *hw =
5259 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5263 /* VF function only support hw strip feature, others are not support */
5264 if (mask & ETH_VLAN_STRIP_MASK) {
5265 on = !!(dev->data->dev_conf.rxmode.hw_vlan_strip);
5267 for (i = 0; i < hw->mac.max_rx_queues; i++)
5268 ixgbevf_vlan_strip_queue_set(dev, i, on);
5275 ixgbe_vt_check(struct ixgbe_hw *hw)
5279 /* if Virtualization Technology is enabled */
5280 reg_val = IXGBE_READ_REG(hw, IXGBE_VT_CTL);
5281 if (!(reg_val & IXGBE_VT_CTL_VT_ENABLE)) {
5282 PMD_INIT_LOG(ERR, "VT must be enabled for this setting");
5290 ixgbe_uta_vector(struct ixgbe_hw *hw, struct ether_addr *uc_addr)
5292 uint32_t vector = 0;
5294 switch (hw->mac.mc_filter_type) {
5295 case 0: /* use bits [47:36] of the address */
5296 vector = ((uc_addr->addr_bytes[4] >> 4) |
5297 (((uint16_t)uc_addr->addr_bytes[5]) << 4));
5299 case 1: /* use bits [46:35] of the address */
5300 vector = ((uc_addr->addr_bytes[4] >> 3) |
5301 (((uint16_t)uc_addr->addr_bytes[5]) << 5));
5303 case 2: /* use bits [45:34] of the address */
5304 vector = ((uc_addr->addr_bytes[4] >> 2) |
5305 (((uint16_t)uc_addr->addr_bytes[5]) << 6));
5307 case 3: /* use bits [43:32] of the address */
5308 vector = ((uc_addr->addr_bytes[4]) |
5309 (((uint16_t)uc_addr->addr_bytes[5]) << 8));
5311 default: /* Invalid mc_filter_type */
5315 /* vector can only be 12-bits or boundary will be exceeded */
5321 ixgbe_uc_hash_table_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
5329 const uint32_t ixgbe_uta_idx_mask = 0x7F;
5330 const uint32_t ixgbe_uta_bit_shift = 5;
5331 const uint32_t ixgbe_uta_bit_mask = (0x1 << ixgbe_uta_bit_shift) - 1;
5332 const uint32_t bit1 = 0x1;
5334 struct ixgbe_hw *hw =
5335 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5336 struct ixgbe_uta_info *uta_info =
5337 IXGBE_DEV_PRIVATE_TO_UTA(dev->data->dev_private);
5339 /* The UTA table only exists on 82599 hardware and newer */
5340 if (hw->mac.type < ixgbe_mac_82599EB)
5343 vector = ixgbe_uta_vector(hw, mac_addr);
5344 uta_idx = (vector >> ixgbe_uta_bit_shift) & ixgbe_uta_idx_mask;
5345 uta_shift = vector & ixgbe_uta_bit_mask;
5347 rc = ((uta_info->uta_shadow[uta_idx] >> uta_shift & bit1) != 0);
5351 reg_val = IXGBE_READ_REG(hw, IXGBE_UTA(uta_idx));
5353 uta_info->uta_in_use++;
5354 reg_val |= (bit1 << uta_shift);
5355 uta_info->uta_shadow[uta_idx] |= (bit1 << uta_shift);
5357 uta_info->uta_in_use--;
5358 reg_val &= ~(bit1 << uta_shift);
5359 uta_info->uta_shadow[uta_idx] &= ~(bit1 << uta_shift);
5362 IXGBE_WRITE_REG(hw, IXGBE_UTA(uta_idx), reg_val);
5364 if (uta_info->uta_in_use > 0)
5365 IXGBE_WRITE_REG(hw, IXGBE_MCSTCTRL,
5366 IXGBE_MCSTCTRL_MFE | hw->mac.mc_filter_type);
5368 IXGBE_WRITE_REG(hw, IXGBE_MCSTCTRL, hw->mac.mc_filter_type);
5374 ixgbe_uc_all_hash_table_set(struct rte_eth_dev *dev, uint8_t on)
5377 struct ixgbe_hw *hw =
5378 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5379 struct ixgbe_uta_info *uta_info =
5380 IXGBE_DEV_PRIVATE_TO_UTA(dev->data->dev_private);
5382 /* The UTA table only exists on 82599 hardware and newer */
5383 if (hw->mac.type < ixgbe_mac_82599EB)
5387 for (i = 0; i < ETH_VMDQ_NUM_UC_HASH_ARRAY; i++) {
5388 uta_info->uta_shadow[i] = ~0;
5389 IXGBE_WRITE_REG(hw, IXGBE_UTA(i), ~0);
5392 for (i = 0; i < ETH_VMDQ_NUM_UC_HASH_ARRAY; i++) {
5393 uta_info->uta_shadow[i] = 0;
5394 IXGBE_WRITE_REG(hw, IXGBE_UTA(i), 0);
5402 ixgbe_convert_vm_rx_mask_to_val(uint16_t rx_mask, uint32_t orig_val)
5404 uint32_t new_val = orig_val;
5406 if (rx_mask & ETH_VMDQ_ACCEPT_UNTAG)
5407 new_val |= IXGBE_VMOLR_AUPE;
5408 if (rx_mask & ETH_VMDQ_ACCEPT_HASH_MC)
5409 new_val |= IXGBE_VMOLR_ROMPE;
5410 if (rx_mask & ETH_VMDQ_ACCEPT_HASH_UC)
5411 new_val |= IXGBE_VMOLR_ROPE;
5412 if (rx_mask & ETH_VMDQ_ACCEPT_BROADCAST)
5413 new_val |= IXGBE_VMOLR_BAM;
5414 if (rx_mask & ETH_VMDQ_ACCEPT_MULTICAST)
5415 new_val |= IXGBE_VMOLR_MPE;
5420 #define IXGBE_MRCTL_VPME 0x01 /* Virtual Pool Mirroring. */
5421 #define IXGBE_MRCTL_UPME 0x02 /* Uplink Port Mirroring. */
5422 #define IXGBE_MRCTL_DPME 0x04 /* Downlink Port Mirroring. */
5423 #define IXGBE_MRCTL_VLME 0x08 /* VLAN Mirroring. */
5424 #define IXGBE_INVALID_MIRROR_TYPE(mirror_type) \
5425 ((mirror_type) & ~(uint8_t)(ETH_MIRROR_VIRTUAL_POOL_UP | \
5426 ETH_MIRROR_UPLINK_PORT | ETH_MIRROR_DOWNLINK_PORT | ETH_MIRROR_VLAN))
5429 ixgbe_mirror_rule_set(struct rte_eth_dev *dev,
5430 struct rte_eth_mirror_conf *mirror_conf,
5431 uint8_t rule_id, uint8_t on)
5433 uint32_t mr_ctl, vlvf;
5434 uint32_t mp_lsb = 0;
5435 uint32_t mv_msb = 0;
5436 uint32_t mv_lsb = 0;
5437 uint32_t mp_msb = 0;
5440 uint64_t vlan_mask = 0;
5442 const uint8_t pool_mask_offset = 32;
5443 const uint8_t vlan_mask_offset = 32;
5444 const uint8_t dst_pool_offset = 8;
5445 const uint8_t rule_mr_offset = 4;
5446 const uint8_t mirror_rule_mask = 0x0F;
5448 struct ixgbe_mirror_info *mr_info =
5449 (IXGBE_DEV_PRIVATE_TO_PFDATA(dev->data->dev_private));
5450 struct ixgbe_hw *hw =
5451 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5452 uint8_t mirror_type = 0;
5454 if (ixgbe_vt_check(hw) < 0)
5457 if (rule_id >= IXGBE_MAX_MIRROR_RULES)
5460 if (IXGBE_INVALID_MIRROR_TYPE(mirror_conf->rule_type)) {
5461 PMD_DRV_LOG(ERR, "unsupported mirror type 0x%x.",
5462 mirror_conf->rule_type);
5466 if (mirror_conf->rule_type & ETH_MIRROR_VLAN) {
5467 mirror_type |= IXGBE_MRCTL_VLME;
5468 /* Check if vlan id is valid and find conresponding VLAN ID
5471 for (i = 0; i < IXGBE_VLVF_ENTRIES; i++) {
5472 if (mirror_conf->vlan.vlan_mask & (1ULL << i)) {
5473 /* search vlan id related pool vlan filter
5476 reg_index = ixgbe_find_vlvf_slot(
5478 mirror_conf->vlan.vlan_id[i],
5482 vlvf = IXGBE_READ_REG(hw,
5483 IXGBE_VLVF(reg_index));
5484 if ((vlvf & IXGBE_VLVF_VIEN) &&
5485 ((vlvf & IXGBE_VLVF_VLANID_MASK) ==
5486 mirror_conf->vlan.vlan_id[i]))
5487 vlan_mask |= (1ULL << reg_index);
5494 mv_lsb = vlan_mask & 0xFFFFFFFF;
5495 mv_msb = vlan_mask >> vlan_mask_offset;
5497 mr_info->mr_conf[rule_id].vlan.vlan_mask =
5498 mirror_conf->vlan.vlan_mask;
5499 for (i = 0; i < ETH_VMDQ_MAX_VLAN_FILTERS; i++) {
5500 if (mirror_conf->vlan.vlan_mask & (1ULL << i))
5501 mr_info->mr_conf[rule_id].vlan.vlan_id[i] =
5502 mirror_conf->vlan.vlan_id[i];
5507 mr_info->mr_conf[rule_id].vlan.vlan_mask = 0;
5508 for (i = 0; i < ETH_VMDQ_MAX_VLAN_FILTERS; i++)
5509 mr_info->mr_conf[rule_id].vlan.vlan_id[i] = 0;
5514 * if enable pool mirror, write related pool mask register,if disable
5515 * pool mirror, clear PFMRVM register
5517 if (mirror_conf->rule_type & ETH_MIRROR_VIRTUAL_POOL_UP) {
5518 mirror_type |= IXGBE_MRCTL_VPME;
5520 mp_lsb = mirror_conf->pool_mask & 0xFFFFFFFF;
5521 mp_msb = mirror_conf->pool_mask >> pool_mask_offset;
5522 mr_info->mr_conf[rule_id].pool_mask =
5523 mirror_conf->pool_mask;
5528 mr_info->mr_conf[rule_id].pool_mask = 0;
5531 if (mirror_conf->rule_type & ETH_MIRROR_UPLINK_PORT)
5532 mirror_type |= IXGBE_MRCTL_UPME;
5533 if (mirror_conf->rule_type & ETH_MIRROR_DOWNLINK_PORT)
5534 mirror_type |= IXGBE_MRCTL_DPME;
5536 /* read mirror control register and recalculate it */
5537 mr_ctl = IXGBE_READ_REG(hw, IXGBE_MRCTL(rule_id));
5540 mr_ctl |= mirror_type;
5541 mr_ctl &= mirror_rule_mask;
5542 mr_ctl |= mirror_conf->dst_pool << dst_pool_offset;
5544 mr_ctl &= ~(mirror_conf->rule_type & mirror_rule_mask);
5547 mr_info->mr_conf[rule_id].rule_type = mirror_conf->rule_type;
5548 mr_info->mr_conf[rule_id].dst_pool = mirror_conf->dst_pool;
5550 /* write mirrror control register */
5551 IXGBE_WRITE_REG(hw, IXGBE_MRCTL(rule_id), mr_ctl);
5553 /* write pool mirrror control register */
5554 if (mirror_conf->rule_type & ETH_MIRROR_VIRTUAL_POOL_UP) {
5555 IXGBE_WRITE_REG(hw, IXGBE_VMRVM(rule_id), mp_lsb);
5556 IXGBE_WRITE_REG(hw, IXGBE_VMRVM(rule_id + rule_mr_offset),
5559 /* write VLAN mirrror control register */
5560 if (mirror_conf->rule_type & ETH_MIRROR_VLAN) {
5561 IXGBE_WRITE_REG(hw, IXGBE_VMRVLAN(rule_id), mv_lsb);
5562 IXGBE_WRITE_REG(hw, IXGBE_VMRVLAN(rule_id + rule_mr_offset),
5570 ixgbe_mirror_rule_reset(struct rte_eth_dev *dev, uint8_t rule_id)
5573 uint32_t lsb_val = 0;
5574 uint32_t msb_val = 0;
5575 const uint8_t rule_mr_offset = 4;
5577 struct ixgbe_hw *hw =
5578 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5579 struct ixgbe_mirror_info *mr_info =
5580 (IXGBE_DEV_PRIVATE_TO_PFDATA(dev->data->dev_private));
5582 if (ixgbe_vt_check(hw) < 0)
5585 if (rule_id >= IXGBE_MAX_MIRROR_RULES)
5588 memset(&mr_info->mr_conf[rule_id], 0,
5589 sizeof(struct rte_eth_mirror_conf));
5591 /* clear PFVMCTL register */
5592 IXGBE_WRITE_REG(hw, IXGBE_MRCTL(rule_id), mr_ctl);
5594 /* clear pool mask register */
5595 IXGBE_WRITE_REG(hw, IXGBE_VMRVM(rule_id), lsb_val);
5596 IXGBE_WRITE_REG(hw, IXGBE_VMRVM(rule_id + rule_mr_offset), msb_val);
5598 /* clear vlan mask register */
5599 IXGBE_WRITE_REG(hw, IXGBE_VMRVLAN(rule_id), lsb_val);
5600 IXGBE_WRITE_REG(hw, IXGBE_VMRVLAN(rule_id + rule_mr_offset), msb_val);
5606 ixgbevf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
5608 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
5609 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
5611 struct ixgbe_hw *hw =
5612 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5613 uint32_t vec = IXGBE_MISC_VEC_ID;
5615 mask = IXGBE_READ_REG(hw, IXGBE_VTEIMS);
5616 if (rte_intr_allow_others(intr_handle))
5617 vec = IXGBE_RX_VEC_START;
5619 RTE_SET_USED(queue_id);
5620 IXGBE_WRITE_REG(hw, IXGBE_VTEIMS, mask);
5622 rte_intr_enable(intr_handle);
5628 ixgbevf_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id)
5631 struct ixgbe_hw *hw =
5632 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5633 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
5634 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
5635 uint32_t vec = IXGBE_MISC_VEC_ID;
5637 mask = IXGBE_READ_REG(hw, IXGBE_VTEIMS);
5638 if (rte_intr_allow_others(intr_handle))
5639 vec = IXGBE_RX_VEC_START;
5640 mask &= ~(1 << vec);
5641 RTE_SET_USED(queue_id);
5642 IXGBE_WRITE_REG(hw, IXGBE_VTEIMS, mask);
5648 ixgbe_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
5650 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
5651 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
5653 struct ixgbe_hw *hw =
5654 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5655 struct ixgbe_interrupt *intr =
5656 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
5658 if (queue_id < 16) {
5659 ixgbe_disable_intr(hw);
5660 intr->mask |= (1 << queue_id);
5661 ixgbe_enable_intr(dev);
5662 } else if (queue_id < 32) {
5663 mask = IXGBE_READ_REG(hw, IXGBE_EIMS_EX(0));
5664 mask &= (1 << queue_id);
5665 IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(0), mask);
5666 } else if (queue_id < 64) {
5667 mask = IXGBE_READ_REG(hw, IXGBE_EIMS_EX(1));
5668 mask &= (1 << (queue_id - 32));
5669 IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(1), mask);
5671 rte_intr_enable(intr_handle);
5677 ixgbe_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id)
5680 struct ixgbe_hw *hw =
5681 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5682 struct ixgbe_interrupt *intr =
5683 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
5685 if (queue_id < 16) {
5686 ixgbe_disable_intr(hw);
5687 intr->mask &= ~(1 << queue_id);
5688 ixgbe_enable_intr(dev);
5689 } else if (queue_id < 32) {
5690 mask = IXGBE_READ_REG(hw, IXGBE_EIMS_EX(0));
5691 mask &= ~(1 << queue_id);
5692 IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(0), mask);
5693 } else if (queue_id < 64) {
5694 mask = IXGBE_READ_REG(hw, IXGBE_EIMS_EX(1));
5695 mask &= ~(1 << (queue_id - 32));
5696 IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(1), mask);
5703 ixgbevf_set_ivar_map(struct ixgbe_hw *hw, int8_t direction,
5704 uint8_t queue, uint8_t msix_vector)
5708 if (direction == -1) {
5710 msix_vector |= IXGBE_IVAR_ALLOC_VAL;
5711 tmp = IXGBE_READ_REG(hw, IXGBE_VTIVAR_MISC);
5714 IXGBE_WRITE_REG(hw, IXGBE_VTIVAR_MISC, tmp);
5716 /* rx or tx cause */
5717 msix_vector |= IXGBE_IVAR_ALLOC_VAL;
5718 idx = ((16 * (queue & 1)) + (8 * direction));
5719 tmp = IXGBE_READ_REG(hw, IXGBE_VTIVAR(queue >> 1));
5720 tmp &= ~(0xFF << idx);
5721 tmp |= (msix_vector << idx);
5722 IXGBE_WRITE_REG(hw, IXGBE_VTIVAR(queue >> 1), tmp);
5727 * set the IVAR registers, mapping interrupt causes to vectors
5729 * pointer to ixgbe_hw struct
5731 * 0 for Rx, 1 for Tx, -1 for other causes
5733 * queue to map the corresponding interrupt to
5735 * the vector to map to the corresponding queue
5738 ixgbe_set_ivar_map(struct ixgbe_hw *hw, int8_t direction,
5739 uint8_t queue, uint8_t msix_vector)
5743 msix_vector |= IXGBE_IVAR_ALLOC_VAL;
5744 if (hw->mac.type == ixgbe_mac_82598EB) {
5745 if (direction == -1)
5747 idx = (((direction * 64) + queue) >> 2) & 0x1F;
5748 tmp = IXGBE_READ_REG(hw, IXGBE_IVAR(idx));
5749 tmp &= ~(0xFF << (8 * (queue & 0x3)));
5750 tmp |= (msix_vector << (8 * (queue & 0x3)));
5751 IXGBE_WRITE_REG(hw, IXGBE_IVAR(idx), tmp);
5752 } else if ((hw->mac.type == ixgbe_mac_82599EB) ||
5753 (hw->mac.type == ixgbe_mac_X540) ||
5754 (hw->mac.type == ixgbe_mac_X550)) {
5755 if (direction == -1) {
5757 idx = ((queue & 1) * 8);
5758 tmp = IXGBE_READ_REG(hw, IXGBE_IVAR_MISC);
5759 tmp &= ~(0xFF << idx);
5760 tmp |= (msix_vector << idx);
5761 IXGBE_WRITE_REG(hw, IXGBE_IVAR_MISC, tmp);
5763 /* rx or tx causes */
5764 idx = ((16 * (queue & 1)) + (8 * direction));
5765 tmp = IXGBE_READ_REG(hw, IXGBE_IVAR(queue >> 1));
5766 tmp &= ~(0xFF << idx);
5767 tmp |= (msix_vector << idx);
5768 IXGBE_WRITE_REG(hw, IXGBE_IVAR(queue >> 1), tmp);
5774 ixgbevf_configure_msix(struct rte_eth_dev *dev)
5776 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
5777 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
5778 struct ixgbe_hw *hw =
5779 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5781 uint32_t vector_idx = IXGBE_MISC_VEC_ID;
5782 uint32_t base = IXGBE_MISC_VEC_ID;
5784 /* Configure VF other cause ivar */
5785 ixgbevf_set_ivar_map(hw, -1, 1, vector_idx);
5787 /* won't configure msix register if no mapping is done
5788 * between intr vector and event fd.
5790 if (!rte_intr_dp_is_en(intr_handle))
5793 if (rte_intr_allow_others(intr_handle)) {
5794 base = IXGBE_RX_VEC_START;
5795 vector_idx = IXGBE_RX_VEC_START;
5798 /* Configure all RX queues of VF */
5799 for (q_idx = 0; q_idx < dev->data->nb_rx_queues; q_idx++) {
5800 /* Force all queue use vector 0,
5801 * as IXGBE_VF_MAXMSIVECOTR = 1
5803 ixgbevf_set_ivar_map(hw, 0, q_idx, vector_idx);
5804 intr_handle->intr_vec[q_idx] = vector_idx;
5805 if (vector_idx < base + intr_handle->nb_efd - 1)
5811 * Sets up the hardware to properly generate MSI-X interrupts
5813 * board private structure
5816 ixgbe_configure_msix(struct rte_eth_dev *dev)
5818 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
5819 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
5820 struct ixgbe_hw *hw =
5821 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5822 uint32_t queue_id, base = IXGBE_MISC_VEC_ID;
5823 uint32_t vec = IXGBE_MISC_VEC_ID;
5827 /* won't configure msix register if no mapping is done
5828 * between intr vector and event fd
5829 * but if misx has been enabled already, need to configure
5830 * auto clean, auto mask and throttling.
5832 gpie = IXGBE_READ_REG(hw, IXGBE_GPIE);
5833 if (!rte_intr_dp_is_en(intr_handle) &&
5834 !(gpie & (IXGBE_GPIE_MSIX_MODE | IXGBE_GPIE_PBA_SUPPORT)))
5837 if (rte_intr_allow_others(intr_handle))
5838 vec = base = IXGBE_RX_VEC_START;
5840 /* setup GPIE for MSI-x mode */
5841 gpie = IXGBE_READ_REG(hw, IXGBE_GPIE);
5842 gpie |= IXGBE_GPIE_MSIX_MODE | IXGBE_GPIE_PBA_SUPPORT |
5843 IXGBE_GPIE_OCD | IXGBE_GPIE_EIAME;
5844 /* auto clearing and auto setting corresponding bits in EIMS
5845 * when MSI-X interrupt is triggered
5847 if (hw->mac.type == ixgbe_mac_82598EB) {
5848 IXGBE_WRITE_REG(hw, IXGBE_EIAM, IXGBE_EICS_RTX_QUEUE);
5850 IXGBE_WRITE_REG(hw, IXGBE_EIAM_EX(0), 0xFFFFFFFF);
5851 IXGBE_WRITE_REG(hw, IXGBE_EIAM_EX(1), 0xFFFFFFFF);
5853 IXGBE_WRITE_REG(hw, IXGBE_GPIE, gpie);
5855 /* Populate the IVAR table and set the ITR values to the
5856 * corresponding register.
5858 if (rte_intr_dp_is_en(intr_handle)) {
5859 for (queue_id = 0; queue_id < dev->data->nb_rx_queues;
5861 /* by default, 1:1 mapping */
5862 ixgbe_set_ivar_map(hw, 0, queue_id, vec);
5863 intr_handle->intr_vec[queue_id] = vec;
5864 if (vec < base + intr_handle->nb_efd - 1)
5868 switch (hw->mac.type) {
5869 case ixgbe_mac_82598EB:
5870 ixgbe_set_ivar_map(hw, -1,
5871 IXGBE_IVAR_OTHER_CAUSES_INDEX,
5874 case ixgbe_mac_82599EB:
5875 case ixgbe_mac_X540:
5876 case ixgbe_mac_X550:
5877 ixgbe_set_ivar_map(hw, -1, 1, IXGBE_MISC_VEC_ID);
5883 IXGBE_WRITE_REG(hw, IXGBE_EITR(IXGBE_MISC_VEC_ID),
5884 IXGBE_MIN_INTER_INTERRUPT_INTERVAL_DEFAULT & 0xFFF);
5886 /* set up to autoclear timer, and the vectors */
5887 mask = IXGBE_EIMS_ENABLE_MASK;
5888 mask &= ~(IXGBE_EIMS_OTHER |
5889 IXGBE_EIMS_MAILBOX |
5892 IXGBE_WRITE_REG(hw, IXGBE_EIAC, mask);
5896 ixgbe_set_queue_rate_limit(struct rte_eth_dev *dev,
5897 uint16_t queue_idx, uint16_t tx_rate)
5899 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5900 uint32_t rf_dec, rf_int;
5902 uint16_t link_speed = dev->data->dev_link.link_speed;
5904 if (queue_idx >= hw->mac.max_tx_queues)
5908 /* Calculate the rate factor values to set */
5909 rf_int = (uint32_t)link_speed / (uint32_t)tx_rate;
5910 rf_dec = (uint32_t)link_speed % (uint32_t)tx_rate;
5911 rf_dec = (rf_dec << IXGBE_RTTBCNRC_RF_INT_SHIFT) / tx_rate;
5913 bcnrc_val = IXGBE_RTTBCNRC_RS_ENA;
5914 bcnrc_val |= ((rf_int << IXGBE_RTTBCNRC_RF_INT_SHIFT) &
5915 IXGBE_RTTBCNRC_RF_INT_MASK_M);
5916 bcnrc_val |= (rf_dec & IXGBE_RTTBCNRC_RF_DEC_MASK);
5922 * Set global transmit compensation time to the MMW_SIZE in RTTBCNRM
5923 * register. MMW_SIZE=0x014 if 9728-byte jumbo is supported, otherwise
5926 if ((dev->data->dev_conf.rxmode.jumbo_frame == 1) &&
5927 (dev->data->dev_conf.rxmode.max_rx_pkt_len >=
5928 IXGBE_MAX_JUMBO_FRAME_SIZE))
5929 IXGBE_WRITE_REG(hw, IXGBE_RTTBCNRM,
5930 IXGBE_MMW_SIZE_JUMBO_FRAME);
5932 IXGBE_WRITE_REG(hw, IXGBE_RTTBCNRM,
5933 IXGBE_MMW_SIZE_DEFAULT);
5935 /* Set RTTBCNRC of queue X */
5936 IXGBE_WRITE_REG(hw, IXGBE_RTTDQSEL, queue_idx);
5937 IXGBE_WRITE_REG(hw, IXGBE_RTTBCNRC, bcnrc_val);
5938 IXGBE_WRITE_FLUSH(hw);
5944 ixgbevf_add_mac_addr(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
5945 __attribute__((unused)) uint32_t index,
5946 __attribute__((unused)) uint32_t pool)
5948 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5952 * On a 82599 VF, adding again the same MAC addr is not an idempotent
5953 * operation. Trap this case to avoid exhausting the [very limited]
5954 * set of PF resources used to store VF MAC addresses.
5956 if (memcmp(hw->mac.perm_addr, mac_addr, sizeof(struct ether_addr)) == 0)
5958 diag = ixgbevf_set_uc_addr_vf(hw, 2, mac_addr->addr_bytes);
5960 PMD_DRV_LOG(ERR, "Unable to add MAC address "
5961 "%02x:%02x:%02x:%02x:%02x:%02x - diag=%d",
5962 mac_addr->addr_bytes[0],
5963 mac_addr->addr_bytes[1],
5964 mac_addr->addr_bytes[2],
5965 mac_addr->addr_bytes[3],
5966 mac_addr->addr_bytes[4],
5967 mac_addr->addr_bytes[5],
5973 ixgbevf_remove_mac_addr(struct rte_eth_dev *dev, uint32_t index)
5975 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5976 struct ether_addr *perm_addr = (struct ether_addr *) hw->mac.perm_addr;
5977 struct ether_addr *mac_addr;
5982 * The IXGBE_VF_SET_MACVLAN command of the ixgbe-pf driver does
5983 * not support the deletion of a given MAC address.
5984 * Instead, it imposes to delete all MAC addresses, then to add again
5985 * all MAC addresses with the exception of the one to be deleted.
5987 (void) ixgbevf_set_uc_addr_vf(hw, 0, NULL);
5990 * Add again all MAC addresses, with the exception of the deleted one
5991 * and of the permanent MAC address.
5993 for (i = 0, mac_addr = dev->data->mac_addrs;
5994 i < hw->mac.num_rar_entries; i++, mac_addr++) {
5995 /* Skip the deleted MAC address */
5998 /* Skip NULL MAC addresses */
5999 if (is_zero_ether_addr(mac_addr))
6001 /* Skip the permanent MAC address */
6002 if (memcmp(perm_addr, mac_addr, sizeof(struct ether_addr)) == 0)
6004 diag = ixgbevf_set_uc_addr_vf(hw, 2, mac_addr->addr_bytes);
6007 "Adding again MAC address "
6008 "%02x:%02x:%02x:%02x:%02x:%02x failed "
6010 mac_addr->addr_bytes[0],
6011 mac_addr->addr_bytes[1],
6012 mac_addr->addr_bytes[2],
6013 mac_addr->addr_bytes[3],
6014 mac_addr->addr_bytes[4],
6015 mac_addr->addr_bytes[5],
6021 ixgbevf_set_default_mac_addr(struct rte_eth_dev *dev, struct ether_addr *addr)
6023 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6025 hw->mac.ops.set_rar(hw, 0, (void *)addr, 0, 0);
6029 ixgbe_syn_filter_set(struct rte_eth_dev *dev,
6030 struct rte_eth_syn_filter *filter,
6033 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6034 struct ixgbe_filter_info *filter_info =
6035 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6039 if (filter->queue >= IXGBE_MAX_RX_QUEUE_NUM)
6042 syn_info = filter_info->syn_info;
6045 if (syn_info & IXGBE_SYN_FILTER_ENABLE)
6047 synqf = (uint32_t)(((filter->queue << IXGBE_SYN_FILTER_QUEUE_SHIFT) &
6048 IXGBE_SYN_FILTER_QUEUE) | IXGBE_SYN_FILTER_ENABLE);
6050 if (filter->hig_pri)
6051 synqf |= IXGBE_SYN_FILTER_SYNQFP;
6053 synqf &= ~IXGBE_SYN_FILTER_SYNQFP;
6055 synqf = IXGBE_READ_REG(hw, IXGBE_SYNQF);
6056 if (!(syn_info & IXGBE_SYN_FILTER_ENABLE))
6058 synqf &= ~(IXGBE_SYN_FILTER_QUEUE | IXGBE_SYN_FILTER_ENABLE);
6061 filter_info->syn_info = synqf;
6062 IXGBE_WRITE_REG(hw, IXGBE_SYNQF, synqf);
6063 IXGBE_WRITE_FLUSH(hw);
6068 ixgbe_syn_filter_get(struct rte_eth_dev *dev,
6069 struct rte_eth_syn_filter *filter)
6071 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6072 uint32_t synqf = IXGBE_READ_REG(hw, IXGBE_SYNQF);
6074 if (synqf & IXGBE_SYN_FILTER_ENABLE) {
6075 filter->hig_pri = (synqf & IXGBE_SYN_FILTER_SYNQFP) ? 1 : 0;
6076 filter->queue = (uint16_t)((synqf & IXGBE_SYN_FILTER_QUEUE) >> 1);
6083 ixgbe_syn_filter_handle(struct rte_eth_dev *dev,
6084 enum rte_filter_op filter_op,
6087 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6090 MAC_TYPE_FILTER_SUP(hw->mac.type);
6092 if (filter_op == RTE_ETH_FILTER_NOP)
6096 PMD_DRV_LOG(ERR, "arg shouldn't be NULL for operation %u",
6101 switch (filter_op) {
6102 case RTE_ETH_FILTER_ADD:
6103 ret = ixgbe_syn_filter_set(dev,
6104 (struct rte_eth_syn_filter *)arg,
6107 case RTE_ETH_FILTER_DELETE:
6108 ret = ixgbe_syn_filter_set(dev,
6109 (struct rte_eth_syn_filter *)arg,
6112 case RTE_ETH_FILTER_GET:
6113 ret = ixgbe_syn_filter_get(dev,
6114 (struct rte_eth_syn_filter *)arg);
6117 PMD_DRV_LOG(ERR, "unsupported operation %u", filter_op);
6126 static inline enum ixgbe_5tuple_protocol
6127 convert_protocol_type(uint8_t protocol_value)
6129 if (protocol_value == IPPROTO_TCP)
6130 return IXGBE_FILTER_PROTOCOL_TCP;
6131 else if (protocol_value == IPPROTO_UDP)
6132 return IXGBE_FILTER_PROTOCOL_UDP;
6133 else if (protocol_value == IPPROTO_SCTP)
6134 return IXGBE_FILTER_PROTOCOL_SCTP;
6136 return IXGBE_FILTER_PROTOCOL_NONE;
6139 /* inject a 5-tuple filter to HW */
6141 ixgbe_inject_5tuple_filter(struct rte_eth_dev *dev,
6142 struct ixgbe_5tuple_filter *filter)
6144 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6146 uint32_t ftqf, sdpqf;
6147 uint32_t l34timir = 0;
6148 uint8_t mask = 0xff;
6152 sdpqf = (uint32_t)(filter->filter_info.dst_port <<
6153 IXGBE_SDPQF_DSTPORT_SHIFT);
6154 sdpqf = sdpqf | (filter->filter_info.src_port & IXGBE_SDPQF_SRCPORT);
6156 ftqf = (uint32_t)(filter->filter_info.proto &
6157 IXGBE_FTQF_PROTOCOL_MASK);
6158 ftqf |= (uint32_t)((filter->filter_info.priority &
6159 IXGBE_FTQF_PRIORITY_MASK) << IXGBE_FTQF_PRIORITY_SHIFT);
6160 if (filter->filter_info.src_ip_mask == 0) /* 0 means compare. */
6161 mask &= IXGBE_FTQF_SOURCE_ADDR_MASK;
6162 if (filter->filter_info.dst_ip_mask == 0)
6163 mask &= IXGBE_FTQF_DEST_ADDR_MASK;
6164 if (filter->filter_info.src_port_mask == 0)
6165 mask &= IXGBE_FTQF_SOURCE_PORT_MASK;
6166 if (filter->filter_info.dst_port_mask == 0)
6167 mask &= IXGBE_FTQF_DEST_PORT_MASK;
6168 if (filter->filter_info.proto_mask == 0)
6169 mask &= IXGBE_FTQF_PROTOCOL_COMP_MASK;
6170 ftqf |= mask << IXGBE_FTQF_5TUPLE_MASK_SHIFT;
6171 ftqf |= IXGBE_FTQF_POOL_MASK_EN;
6172 ftqf |= IXGBE_FTQF_QUEUE_ENABLE;
6174 IXGBE_WRITE_REG(hw, IXGBE_DAQF(i), filter->filter_info.dst_ip);
6175 IXGBE_WRITE_REG(hw, IXGBE_SAQF(i), filter->filter_info.src_ip);
6176 IXGBE_WRITE_REG(hw, IXGBE_SDPQF(i), sdpqf);
6177 IXGBE_WRITE_REG(hw, IXGBE_FTQF(i), ftqf);
6179 l34timir |= IXGBE_L34T_IMIR_RESERVE;
6180 l34timir |= (uint32_t)(filter->queue <<
6181 IXGBE_L34T_IMIR_QUEUE_SHIFT);
6182 IXGBE_WRITE_REG(hw, IXGBE_L34T_IMIR(i), l34timir);
6186 * add a 5tuple filter
6189 * dev: Pointer to struct rte_eth_dev.
6190 * index: the index the filter allocates.
6191 * filter: ponter to the filter that will be added.
6192 * rx_queue: the queue id the filter assigned to.
6195 * - On success, zero.
6196 * - On failure, a negative value.
6199 ixgbe_add_5tuple_filter(struct rte_eth_dev *dev,
6200 struct ixgbe_5tuple_filter *filter)
6202 struct ixgbe_filter_info *filter_info =
6203 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6207 * look for an unused 5tuple filter index,
6208 * and insert the filter to list.
6210 for (i = 0; i < IXGBE_MAX_FTQF_FILTERS; i++) {
6211 idx = i / (sizeof(uint32_t) * NBBY);
6212 shift = i % (sizeof(uint32_t) * NBBY);
6213 if (!(filter_info->fivetuple_mask[idx] & (1 << shift))) {
6214 filter_info->fivetuple_mask[idx] |= 1 << shift;
6216 TAILQ_INSERT_TAIL(&filter_info->fivetuple_list,
6222 if (i >= IXGBE_MAX_FTQF_FILTERS) {
6223 PMD_DRV_LOG(ERR, "5tuple filters are full.");
6227 ixgbe_inject_5tuple_filter(dev, filter);
6233 * remove a 5tuple filter
6236 * dev: Pointer to struct rte_eth_dev.
6237 * filter: the pointer of the filter will be removed.
6240 ixgbe_remove_5tuple_filter(struct rte_eth_dev *dev,
6241 struct ixgbe_5tuple_filter *filter)
6243 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6244 struct ixgbe_filter_info *filter_info =
6245 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6246 uint16_t index = filter->index;
6248 filter_info->fivetuple_mask[index / (sizeof(uint32_t) * NBBY)] &=
6249 ~(1 << (index % (sizeof(uint32_t) * NBBY)));
6250 TAILQ_REMOVE(&filter_info->fivetuple_list, filter, entries);
6253 IXGBE_WRITE_REG(hw, IXGBE_DAQF(index), 0);
6254 IXGBE_WRITE_REG(hw, IXGBE_SAQF(index), 0);
6255 IXGBE_WRITE_REG(hw, IXGBE_SDPQF(index), 0);
6256 IXGBE_WRITE_REG(hw, IXGBE_FTQF(index), 0);
6257 IXGBE_WRITE_REG(hw, IXGBE_L34T_IMIR(index), 0);
6261 ixgbevf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
6263 struct ixgbe_hw *hw;
6264 uint32_t max_frame = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
6265 struct rte_eth_rxmode *rx_conf = &dev->data->dev_conf.rxmode;
6267 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6269 if ((mtu < ETHER_MIN_MTU) || (max_frame > ETHER_MAX_JUMBO_FRAME_LEN))
6272 /* refuse mtu that requires the support of scattered packets when this
6273 * feature has not been enabled before.
6275 if (!rx_conf->enable_scatter &&
6276 (max_frame + 2 * IXGBE_VLAN_TAG_SIZE >
6277 dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM))
6281 * When supported by the underlying PF driver, use the IXGBE_VF_SET_MTU
6282 * request of the version 2.0 of the mailbox API.
6283 * For now, use the IXGBE_VF_SET_LPE request of the version 1.0
6284 * of the mailbox API.
6285 * This call to IXGBE_SET_LPE action won't work with ixgbe pf drivers
6286 * prior to 3.11.33 which contains the following change:
6287 * "ixgbe: Enable jumbo frames support w/ SR-IOV"
6289 ixgbevf_rlpml_set_vf(hw, max_frame);
6291 /* update max frame size */
6292 dev->data->dev_conf.rxmode.max_rx_pkt_len = max_frame;
6296 static inline struct ixgbe_5tuple_filter *
6297 ixgbe_5tuple_filter_lookup(struct ixgbe_5tuple_filter_list *filter_list,
6298 struct ixgbe_5tuple_filter_info *key)
6300 struct ixgbe_5tuple_filter *it;
6302 TAILQ_FOREACH(it, filter_list, entries) {
6303 if (memcmp(key, &it->filter_info,
6304 sizeof(struct ixgbe_5tuple_filter_info)) == 0) {
6311 /* translate elements in struct rte_eth_ntuple_filter to struct ixgbe_5tuple_filter_info*/
6313 ntuple_filter_to_5tuple(struct rte_eth_ntuple_filter *filter,
6314 struct ixgbe_5tuple_filter_info *filter_info)
6316 if (filter->queue >= IXGBE_MAX_RX_QUEUE_NUM ||
6317 filter->priority > IXGBE_5TUPLE_MAX_PRI ||
6318 filter->priority < IXGBE_5TUPLE_MIN_PRI)
6321 switch (filter->dst_ip_mask) {
6323 filter_info->dst_ip_mask = 0;
6324 filter_info->dst_ip = filter->dst_ip;
6327 filter_info->dst_ip_mask = 1;
6330 PMD_DRV_LOG(ERR, "invalid dst_ip mask.");
6334 switch (filter->src_ip_mask) {
6336 filter_info->src_ip_mask = 0;
6337 filter_info->src_ip = filter->src_ip;
6340 filter_info->src_ip_mask = 1;
6343 PMD_DRV_LOG(ERR, "invalid src_ip mask.");
6347 switch (filter->dst_port_mask) {
6349 filter_info->dst_port_mask = 0;
6350 filter_info->dst_port = filter->dst_port;
6353 filter_info->dst_port_mask = 1;
6356 PMD_DRV_LOG(ERR, "invalid dst_port mask.");
6360 switch (filter->src_port_mask) {
6362 filter_info->src_port_mask = 0;
6363 filter_info->src_port = filter->src_port;
6366 filter_info->src_port_mask = 1;
6369 PMD_DRV_LOG(ERR, "invalid src_port mask.");
6373 switch (filter->proto_mask) {
6375 filter_info->proto_mask = 0;
6376 filter_info->proto =
6377 convert_protocol_type(filter->proto);
6380 filter_info->proto_mask = 1;
6383 PMD_DRV_LOG(ERR, "invalid protocol mask.");
6387 filter_info->priority = (uint8_t)filter->priority;
6392 * add or delete a ntuple filter
6395 * dev: Pointer to struct rte_eth_dev.
6396 * ntuple_filter: Pointer to struct rte_eth_ntuple_filter
6397 * add: if true, add filter, if false, remove filter
6400 * - On success, zero.
6401 * - On failure, a negative value.
6404 ixgbe_add_del_ntuple_filter(struct rte_eth_dev *dev,
6405 struct rte_eth_ntuple_filter *ntuple_filter,
6408 struct ixgbe_filter_info *filter_info =
6409 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6410 struct ixgbe_5tuple_filter_info filter_5tuple;
6411 struct ixgbe_5tuple_filter *filter;
6414 if (ntuple_filter->flags != RTE_5TUPLE_FLAGS) {
6415 PMD_DRV_LOG(ERR, "only 5tuple is supported.");
6419 memset(&filter_5tuple, 0, sizeof(struct ixgbe_5tuple_filter_info));
6420 ret = ntuple_filter_to_5tuple(ntuple_filter, &filter_5tuple);
6424 filter = ixgbe_5tuple_filter_lookup(&filter_info->fivetuple_list,
6426 if (filter != NULL && add) {
6427 PMD_DRV_LOG(ERR, "filter exists.");
6430 if (filter == NULL && !add) {
6431 PMD_DRV_LOG(ERR, "filter doesn't exist.");
6436 filter = rte_zmalloc("ixgbe_5tuple_filter",
6437 sizeof(struct ixgbe_5tuple_filter), 0);
6440 rte_memcpy(&filter->filter_info,
6442 sizeof(struct ixgbe_5tuple_filter_info));
6443 filter->queue = ntuple_filter->queue;
6444 ret = ixgbe_add_5tuple_filter(dev, filter);
6450 ixgbe_remove_5tuple_filter(dev, filter);
6456 * get a ntuple filter
6459 * dev: Pointer to struct rte_eth_dev.
6460 * ntuple_filter: Pointer to struct rte_eth_ntuple_filter
6463 * - On success, zero.
6464 * - On failure, a negative value.
6467 ixgbe_get_ntuple_filter(struct rte_eth_dev *dev,
6468 struct rte_eth_ntuple_filter *ntuple_filter)
6470 struct ixgbe_filter_info *filter_info =
6471 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6472 struct ixgbe_5tuple_filter_info filter_5tuple;
6473 struct ixgbe_5tuple_filter *filter;
6476 if (ntuple_filter->flags != RTE_5TUPLE_FLAGS) {
6477 PMD_DRV_LOG(ERR, "only 5tuple is supported.");
6481 memset(&filter_5tuple, 0, sizeof(struct ixgbe_5tuple_filter_info));
6482 ret = ntuple_filter_to_5tuple(ntuple_filter, &filter_5tuple);
6486 filter = ixgbe_5tuple_filter_lookup(&filter_info->fivetuple_list,
6488 if (filter == NULL) {
6489 PMD_DRV_LOG(ERR, "filter doesn't exist.");
6492 ntuple_filter->queue = filter->queue;
6497 * ixgbe_ntuple_filter_handle - Handle operations for ntuple filter.
6498 * @dev: pointer to rte_eth_dev structure
6499 * @filter_op:operation will be taken.
6500 * @arg: a pointer to specific structure corresponding to the filter_op
6503 * - On success, zero.
6504 * - On failure, a negative value.
6507 ixgbe_ntuple_filter_handle(struct rte_eth_dev *dev,
6508 enum rte_filter_op filter_op,
6511 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6514 MAC_TYPE_FILTER_SUP_EXT(hw->mac.type);
6516 if (filter_op == RTE_ETH_FILTER_NOP)
6520 PMD_DRV_LOG(ERR, "arg shouldn't be NULL for operation %u.",
6525 switch (filter_op) {
6526 case RTE_ETH_FILTER_ADD:
6527 ret = ixgbe_add_del_ntuple_filter(dev,
6528 (struct rte_eth_ntuple_filter *)arg,
6531 case RTE_ETH_FILTER_DELETE:
6532 ret = ixgbe_add_del_ntuple_filter(dev,
6533 (struct rte_eth_ntuple_filter *)arg,
6536 case RTE_ETH_FILTER_GET:
6537 ret = ixgbe_get_ntuple_filter(dev,
6538 (struct rte_eth_ntuple_filter *)arg);
6541 PMD_DRV_LOG(ERR, "unsupported operation %u.", filter_op);
6549 ixgbe_add_del_ethertype_filter(struct rte_eth_dev *dev,
6550 struct rte_eth_ethertype_filter *filter,
6553 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6554 struct ixgbe_filter_info *filter_info =
6555 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6559 struct ixgbe_ethertype_filter ethertype_filter;
6561 if (filter->queue >= IXGBE_MAX_RX_QUEUE_NUM)
6564 if (filter->ether_type == ETHER_TYPE_IPv4 ||
6565 filter->ether_type == ETHER_TYPE_IPv6) {
6566 PMD_DRV_LOG(ERR, "unsupported ether_type(0x%04x) in"
6567 " ethertype filter.", filter->ether_type);
6571 if (filter->flags & RTE_ETHTYPE_FLAGS_MAC) {
6572 PMD_DRV_LOG(ERR, "mac compare is unsupported.");
6575 if (filter->flags & RTE_ETHTYPE_FLAGS_DROP) {
6576 PMD_DRV_LOG(ERR, "drop option is unsupported.");
6580 ret = ixgbe_ethertype_filter_lookup(filter_info, filter->ether_type);
6581 if (ret >= 0 && add) {
6582 PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter exists.",
6583 filter->ether_type);
6586 if (ret < 0 && !add) {
6587 PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter doesn't exist.",
6588 filter->ether_type);
6593 etqf = IXGBE_ETQF_FILTER_EN;
6594 etqf |= (uint32_t)filter->ether_type;
6595 etqs |= (uint32_t)((filter->queue <<
6596 IXGBE_ETQS_RX_QUEUE_SHIFT) &
6597 IXGBE_ETQS_RX_QUEUE);
6598 etqs |= IXGBE_ETQS_QUEUE_EN;
6600 ethertype_filter.ethertype = filter->ether_type;
6601 ethertype_filter.etqf = etqf;
6602 ethertype_filter.etqs = etqs;
6603 ethertype_filter.conf = FALSE;
6604 ret = ixgbe_ethertype_filter_insert(filter_info,
6607 PMD_DRV_LOG(ERR, "ethertype filters are full.");
6611 ret = ixgbe_ethertype_filter_remove(filter_info, (uint8_t)ret);
6615 IXGBE_WRITE_REG(hw, IXGBE_ETQF(ret), etqf);
6616 IXGBE_WRITE_REG(hw, IXGBE_ETQS(ret), etqs);
6617 IXGBE_WRITE_FLUSH(hw);
6623 ixgbe_get_ethertype_filter(struct rte_eth_dev *dev,
6624 struct rte_eth_ethertype_filter *filter)
6626 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6627 struct ixgbe_filter_info *filter_info =
6628 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6629 uint32_t etqf, etqs;
6632 ret = ixgbe_ethertype_filter_lookup(filter_info, filter->ether_type);
6634 PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter doesn't exist.",
6635 filter->ether_type);
6639 etqf = IXGBE_READ_REG(hw, IXGBE_ETQF(ret));
6640 if (etqf & IXGBE_ETQF_FILTER_EN) {
6641 etqs = IXGBE_READ_REG(hw, IXGBE_ETQS(ret));
6642 filter->ether_type = etqf & IXGBE_ETQF_ETHERTYPE;
6644 filter->queue = (etqs & IXGBE_ETQS_RX_QUEUE) >>
6645 IXGBE_ETQS_RX_QUEUE_SHIFT;
6652 * ixgbe_ethertype_filter_handle - Handle operations for ethertype filter.
6653 * @dev: pointer to rte_eth_dev structure
6654 * @filter_op:operation will be taken.
6655 * @arg: a pointer to specific structure corresponding to the filter_op
6658 ixgbe_ethertype_filter_handle(struct rte_eth_dev *dev,
6659 enum rte_filter_op filter_op,
6662 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6665 MAC_TYPE_FILTER_SUP(hw->mac.type);
6667 if (filter_op == RTE_ETH_FILTER_NOP)
6671 PMD_DRV_LOG(ERR, "arg shouldn't be NULL for operation %u.",
6676 switch (filter_op) {
6677 case RTE_ETH_FILTER_ADD:
6678 ret = ixgbe_add_del_ethertype_filter(dev,
6679 (struct rte_eth_ethertype_filter *)arg,
6682 case RTE_ETH_FILTER_DELETE:
6683 ret = ixgbe_add_del_ethertype_filter(dev,
6684 (struct rte_eth_ethertype_filter *)arg,
6687 case RTE_ETH_FILTER_GET:
6688 ret = ixgbe_get_ethertype_filter(dev,
6689 (struct rte_eth_ethertype_filter *)arg);
6692 PMD_DRV_LOG(ERR, "unsupported operation %u.", filter_op);
6700 ixgbe_dev_filter_ctrl(struct rte_eth_dev *dev,
6701 enum rte_filter_type filter_type,
6702 enum rte_filter_op filter_op,
6707 switch (filter_type) {
6708 case RTE_ETH_FILTER_NTUPLE:
6709 ret = ixgbe_ntuple_filter_handle(dev, filter_op, arg);
6711 case RTE_ETH_FILTER_ETHERTYPE:
6712 ret = ixgbe_ethertype_filter_handle(dev, filter_op, arg);
6714 case RTE_ETH_FILTER_SYN:
6715 ret = ixgbe_syn_filter_handle(dev, filter_op, arg);
6717 case RTE_ETH_FILTER_FDIR:
6718 ret = ixgbe_fdir_ctrl_func(dev, filter_op, arg);
6720 case RTE_ETH_FILTER_L2_TUNNEL:
6721 ret = ixgbe_dev_l2_tunnel_filter_handle(dev, filter_op, arg);
6723 case RTE_ETH_FILTER_GENERIC:
6724 if (filter_op != RTE_ETH_FILTER_GET)
6726 *(const void **)arg = &ixgbe_flow_ops;
6729 PMD_DRV_LOG(WARNING, "Filter type (%d) not supported",
6739 ixgbe_dev_addr_list_itr(__attribute__((unused)) struct ixgbe_hw *hw,
6740 u8 **mc_addr_ptr, u32 *vmdq)
6745 mc_addr = *mc_addr_ptr;
6746 *mc_addr_ptr = (mc_addr + sizeof(struct ether_addr));
6751 ixgbe_dev_set_mc_addr_list(struct rte_eth_dev *dev,
6752 struct ether_addr *mc_addr_set,
6753 uint32_t nb_mc_addr)
6755 struct ixgbe_hw *hw;
6758 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6759 mc_addr_list = (u8 *)mc_addr_set;
6760 return ixgbe_update_mc_addr_list(hw, mc_addr_list, nb_mc_addr,
6761 ixgbe_dev_addr_list_itr, TRUE);
6765 ixgbe_read_systime_cyclecounter(struct rte_eth_dev *dev)
6767 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6768 uint64_t systime_cycles;
6770 switch (hw->mac.type) {
6771 case ixgbe_mac_X550:
6772 case ixgbe_mac_X550EM_x:
6773 case ixgbe_mac_X550EM_a:
6774 /* SYSTIMEL stores ns and SYSTIMEH stores seconds. */
6775 systime_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_SYSTIML);
6776 systime_cycles += (uint64_t)IXGBE_READ_REG(hw, IXGBE_SYSTIMH)
6780 systime_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_SYSTIML);
6781 systime_cycles |= (uint64_t)IXGBE_READ_REG(hw, IXGBE_SYSTIMH)
6785 return systime_cycles;
6789 ixgbe_read_rx_tstamp_cyclecounter(struct rte_eth_dev *dev)
6791 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6792 uint64_t rx_tstamp_cycles;
6794 switch (hw->mac.type) {
6795 case ixgbe_mac_X550:
6796 case ixgbe_mac_X550EM_x:
6797 case ixgbe_mac_X550EM_a:
6798 /* RXSTMPL stores ns and RXSTMPH stores seconds. */
6799 rx_tstamp_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_RXSTMPL);
6800 rx_tstamp_cycles += (uint64_t)IXGBE_READ_REG(hw, IXGBE_RXSTMPH)
6804 /* RXSTMPL stores ns and RXSTMPH stores seconds. */
6805 rx_tstamp_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_RXSTMPL);
6806 rx_tstamp_cycles |= (uint64_t)IXGBE_READ_REG(hw, IXGBE_RXSTMPH)
6810 return rx_tstamp_cycles;
6814 ixgbe_read_tx_tstamp_cyclecounter(struct rte_eth_dev *dev)
6816 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6817 uint64_t tx_tstamp_cycles;
6819 switch (hw->mac.type) {
6820 case ixgbe_mac_X550:
6821 case ixgbe_mac_X550EM_x:
6822 case ixgbe_mac_X550EM_a:
6823 /* TXSTMPL stores ns and TXSTMPH stores seconds. */
6824 tx_tstamp_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_TXSTMPL);
6825 tx_tstamp_cycles += (uint64_t)IXGBE_READ_REG(hw, IXGBE_TXSTMPH)
6829 /* TXSTMPL stores ns and TXSTMPH stores seconds. */
6830 tx_tstamp_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_TXSTMPL);
6831 tx_tstamp_cycles |= (uint64_t)IXGBE_READ_REG(hw, IXGBE_TXSTMPH)
6835 return tx_tstamp_cycles;
6839 ixgbe_start_timecounters(struct rte_eth_dev *dev)
6841 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6842 struct ixgbe_adapter *adapter =
6843 (struct ixgbe_adapter *)dev->data->dev_private;
6844 struct rte_eth_link link;
6845 uint32_t incval = 0;
6848 /* Get current link speed. */
6849 memset(&link, 0, sizeof(link));
6850 ixgbe_dev_link_update(dev, 1);
6851 rte_ixgbe_dev_atomic_read_link_status(dev, &link);
6853 switch (link.link_speed) {
6854 case ETH_SPEED_NUM_100M:
6855 incval = IXGBE_INCVAL_100;
6856 shift = IXGBE_INCVAL_SHIFT_100;
6858 case ETH_SPEED_NUM_1G:
6859 incval = IXGBE_INCVAL_1GB;
6860 shift = IXGBE_INCVAL_SHIFT_1GB;
6862 case ETH_SPEED_NUM_10G:
6864 incval = IXGBE_INCVAL_10GB;
6865 shift = IXGBE_INCVAL_SHIFT_10GB;
6869 switch (hw->mac.type) {
6870 case ixgbe_mac_X550:
6871 case ixgbe_mac_X550EM_x:
6872 case ixgbe_mac_X550EM_a:
6873 /* Independent of link speed. */
6875 /* Cycles read will be interpreted as ns. */
6878 case ixgbe_mac_X540:
6879 IXGBE_WRITE_REG(hw, IXGBE_TIMINCA, incval);
6881 case ixgbe_mac_82599EB:
6882 incval >>= IXGBE_INCVAL_SHIFT_82599;
6883 shift -= IXGBE_INCVAL_SHIFT_82599;
6884 IXGBE_WRITE_REG(hw, IXGBE_TIMINCA,
6885 (1 << IXGBE_INCPER_SHIFT_82599) | incval);
6888 /* Not supported. */
6892 memset(&adapter->systime_tc, 0, sizeof(struct rte_timecounter));
6893 memset(&adapter->rx_tstamp_tc, 0, sizeof(struct rte_timecounter));
6894 memset(&adapter->tx_tstamp_tc, 0, sizeof(struct rte_timecounter));
6896 adapter->systime_tc.cc_mask = IXGBE_CYCLECOUNTER_MASK;
6897 adapter->systime_tc.cc_shift = shift;
6898 adapter->systime_tc.nsec_mask = (1ULL << shift) - 1;
6900 adapter->rx_tstamp_tc.cc_mask = IXGBE_CYCLECOUNTER_MASK;
6901 adapter->rx_tstamp_tc.cc_shift = shift;
6902 adapter->rx_tstamp_tc.nsec_mask = (1ULL << shift) - 1;
6904 adapter->tx_tstamp_tc.cc_mask = IXGBE_CYCLECOUNTER_MASK;
6905 adapter->tx_tstamp_tc.cc_shift = shift;
6906 adapter->tx_tstamp_tc.nsec_mask = (1ULL << shift) - 1;
6910 ixgbe_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta)
6912 struct ixgbe_adapter *adapter =
6913 (struct ixgbe_adapter *)dev->data->dev_private;
6915 adapter->systime_tc.nsec += delta;
6916 adapter->rx_tstamp_tc.nsec += delta;
6917 adapter->tx_tstamp_tc.nsec += delta;
6923 ixgbe_timesync_write_time(struct rte_eth_dev *dev, const struct timespec *ts)
6926 struct ixgbe_adapter *adapter =
6927 (struct ixgbe_adapter *)dev->data->dev_private;
6929 ns = rte_timespec_to_ns(ts);
6930 /* Set the timecounters to a new value. */
6931 adapter->systime_tc.nsec = ns;
6932 adapter->rx_tstamp_tc.nsec = ns;
6933 adapter->tx_tstamp_tc.nsec = ns;
6939 ixgbe_timesync_read_time(struct rte_eth_dev *dev, struct timespec *ts)
6941 uint64_t ns, systime_cycles;
6942 struct ixgbe_adapter *adapter =
6943 (struct ixgbe_adapter *)dev->data->dev_private;
6945 systime_cycles = ixgbe_read_systime_cyclecounter(dev);
6946 ns = rte_timecounter_update(&adapter->systime_tc, systime_cycles);
6947 *ts = rte_ns_to_timespec(ns);
6953 ixgbe_timesync_enable(struct rte_eth_dev *dev)
6955 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6959 /* Stop the timesync system time. */
6960 IXGBE_WRITE_REG(hw, IXGBE_TIMINCA, 0x0);
6961 /* Reset the timesync system time value. */
6962 IXGBE_WRITE_REG(hw, IXGBE_SYSTIML, 0x0);
6963 IXGBE_WRITE_REG(hw, IXGBE_SYSTIMH, 0x0);
6965 /* Enable system time for platforms where it isn't on by default. */
6966 tsauxc = IXGBE_READ_REG(hw, IXGBE_TSAUXC);
6967 tsauxc &= ~IXGBE_TSAUXC_DISABLE_SYSTIME;
6968 IXGBE_WRITE_REG(hw, IXGBE_TSAUXC, tsauxc);
6970 ixgbe_start_timecounters(dev);
6972 /* Enable L2 filtering of IEEE1588/802.1AS Ethernet frame types. */
6973 IXGBE_WRITE_REG(hw, IXGBE_ETQF(IXGBE_ETQF_FILTER_1588),
6975 IXGBE_ETQF_FILTER_EN |
6978 /* Enable timestamping of received PTP packets. */
6979 tsync_ctl = IXGBE_READ_REG(hw, IXGBE_TSYNCRXCTL);
6980 tsync_ctl |= IXGBE_TSYNCRXCTL_ENABLED;
6981 IXGBE_WRITE_REG(hw, IXGBE_TSYNCRXCTL, tsync_ctl);
6983 /* Enable timestamping of transmitted PTP packets. */
6984 tsync_ctl = IXGBE_READ_REG(hw, IXGBE_TSYNCTXCTL);
6985 tsync_ctl |= IXGBE_TSYNCTXCTL_ENABLED;
6986 IXGBE_WRITE_REG(hw, IXGBE_TSYNCTXCTL, tsync_ctl);
6988 IXGBE_WRITE_FLUSH(hw);
6994 ixgbe_timesync_disable(struct rte_eth_dev *dev)
6996 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6999 /* Disable timestamping of transmitted PTP packets. */
7000 tsync_ctl = IXGBE_READ_REG(hw, IXGBE_TSYNCTXCTL);
7001 tsync_ctl &= ~IXGBE_TSYNCTXCTL_ENABLED;
7002 IXGBE_WRITE_REG(hw, IXGBE_TSYNCTXCTL, tsync_ctl);
7004 /* Disable timestamping of received PTP packets. */
7005 tsync_ctl = IXGBE_READ_REG(hw, IXGBE_TSYNCRXCTL);
7006 tsync_ctl &= ~IXGBE_TSYNCRXCTL_ENABLED;
7007 IXGBE_WRITE_REG(hw, IXGBE_TSYNCRXCTL, tsync_ctl);
7009 /* Disable L2 filtering of IEEE1588/802.1AS Ethernet frame types. */
7010 IXGBE_WRITE_REG(hw, IXGBE_ETQF(IXGBE_ETQF_FILTER_1588), 0);
7012 /* Stop incrementating the System Time registers. */
7013 IXGBE_WRITE_REG(hw, IXGBE_TIMINCA, 0);
7019 ixgbe_timesync_read_rx_timestamp(struct rte_eth_dev *dev,
7020 struct timespec *timestamp,
7021 uint32_t flags __rte_unused)
7023 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7024 struct ixgbe_adapter *adapter =
7025 (struct ixgbe_adapter *)dev->data->dev_private;
7026 uint32_t tsync_rxctl;
7027 uint64_t rx_tstamp_cycles;
7030 tsync_rxctl = IXGBE_READ_REG(hw, IXGBE_TSYNCRXCTL);
7031 if ((tsync_rxctl & IXGBE_TSYNCRXCTL_VALID) == 0)
7034 rx_tstamp_cycles = ixgbe_read_rx_tstamp_cyclecounter(dev);
7035 ns = rte_timecounter_update(&adapter->rx_tstamp_tc, rx_tstamp_cycles);
7036 *timestamp = rte_ns_to_timespec(ns);
7042 ixgbe_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
7043 struct timespec *timestamp)
7045 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7046 struct ixgbe_adapter *adapter =
7047 (struct ixgbe_adapter *)dev->data->dev_private;
7048 uint32_t tsync_txctl;
7049 uint64_t tx_tstamp_cycles;
7052 tsync_txctl = IXGBE_READ_REG(hw, IXGBE_TSYNCTXCTL);
7053 if ((tsync_txctl & IXGBE_TSYNCTXCTL_VALID) == 0)
7056 tx_tstamp_cycles = ixgbe_read_tx_tstamp_cyclecounter(dev);
7057 ns = rte_timecounter_update(&adapter->tx_tstamp_tc, tx_tstamp_cycles);
7058 *timestamp = rte_ns_to_timespec(ns);
7064 ixgbe_get_reg_length(struct rte_eth_dev *dev)
7066 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7069 const struct reg_info *reg_group;
7070 const struct reg_info **reg_set = (hw->mac.type == ixgbe_mac_82598EB) ?
7071 ixgbe_regs_mac_82598EB : ixgbe_regs_others;
7073 while ((reg_group = reg_set[g_ind++]))
7074 count += ixgbe_regs_group_count(reg_group);
7080 ixgbevf_get_reg_length(struct rte_eth_dev *dev __rte_unused)
7084 const struct reg_info *reg_group;
7086 while ((reg_group = ixgbevf_regs[g_ind++]))
7087 count += ixgbe_regs_group_count(reg_group);
7093 ixgbe_get_regs(struct rte_eth_dev *dev,
7094 struct rte_dev_reg_info *regs)
7096 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7097 uint32_t *data = regs->data;
7100 const struct reg_info *reg_group;
7101 const struct reg_info **reg_set = (hw->mac.type == ixgbe_mac_82598EB) ?
7102 ixgbe_regs_mac_82598EB : ixgbe_regs_others;
7105 regs->length = ixgbe_get_reg_length(dev);
7106 regs->width = sizeof(uint32_t);
7110 /* Support only full register dump */
7111 if ((regs->length == 0) ||
7112 (regs->length == (uint32_t)ixgbe_get_reg_length(dev))) {
7113 regs->version = hw->mac.type << 24 | hw->revision_id << 16 |
7115 while ((reg_group = reg_set[g_ind++]))
7116 count += ixgbe_read_regs_group(dev, &data[count],
7125 ixgbevf_get_regs(struct rte_eth_dev *dev,
7126 struct rte_dev_reg_info *regs)
7128 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7129 uint32_t *data = regs->data;
7132 const struct reg_info *reg_group;
7135 regs->length = ixgbevf_get_reg_length(dev);
7136 regs->width = sizeof(uint32_t);
7140 /* Support only full register dump */
7141 if ((regs->length == 0) ||
7142 (regs->length == (uint32_t)ixgbevf_get_reg_length(dev))) {
7143 regs->version = hw->mac.type << 24 | hw->revision_id << 16 |
7145 while ((reg_group = ixgbevf_regs[g_ind++]))
7146 count += ixgbe_read_regs_group(dev, &data[count],
7155 ixgbe_get_eeprom_length(struct rte_eth_dev *dev)
7157 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7159 /* Return unit is byte count */
7160 return hw->eeprom.word_size * 2;
7164 ixgbe_get_eeprom(struct rte_eth_dev *dev,
7165 struct rte_dev_eeprom_info *in_eeprom)
7167 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7168 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
7169 uint16_t *data = in_eeprom->data;
7172 first = in_eeprom->offset >> 1;
7173 length = in_eeprom->length >> 1;
7174 if ((first > hw->eeprom.word_size) ||
7175 ((first + length) > hw->eeprom.word_size))
7178 in_eeprom->magic = hw->vendor_id | (hw->device_id << 16);
7180 return eeprom->ops.read_buffer(hw, first, length, data);
7184 ixgbe_set_eeprom(struct rte_eth_dev *dev,
7185 struct rte_dev_eeprom_info *in_eeprom)
7187 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7188 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
7189 uint16_t *data = in_eeprom->data;
7192 first = in_eeprom->offset >> 1;
7193 length = in_eeprom->length >> 1;
7194 if ((first > hw->eeprom.word_size) ||
7195 ((first + length) > hw->eeprom.word_size))
7198 in_eeprom->magic = hw->vendor_id | (hw->device_id << 16);
7200 return eeprom->ops.write_buffer(hw, first, length, data);
7204 ixgbe_reta_size_get(enum ixgbe_mac_type mac_type) {
7206 case ixgbe_mac_X550:
7207 case ixgbe_mac_X550EM_x:
7208 case ixgbe_mac_X550EM_a:
7209 return ETH_RSS_RETA_SIZE_512;
7210 case ixgbe_mac_X550_vf:
7211 case ixgbe_mac_X550EM_x_vf:
7212 case ixgbe_mac_X550EM_a_vf:
7213 return ETH_RSS_RETA_SIZE_64;
7215 return ETH_RSS_RETA_SIZE_128;
7220 ixgbe_reta_reg_get(enum ixgbe_mac_type mac_type, uint16_t reta_idx) {
7222 case ixgbe_mac_X550:
7223 case ixgbe_mac_X550EM_x:
7224 case ixgbe_mac_X550EM_a:
7225 if (reta_idx < ETH_RSS_RETA_SIZE_128)
7226 return IXGBE_RETA(reta_idx >> 2);
7228 return IXGBE_ERETA((reta_idx - ETH_RSS_RETA_SIZE_128) >> 2);
7229 case ixgbe_mac_X550_vf:
7230 case ixgbe_mac_X550EM_x_vf:
7231 case ixgbe_mac_X550EM_a_vf:
7232 return IXGBE_VFRETA(reta_idx >> 2);
7234 return IXGBE_RETA(reta_idx >> 2);
7239 ixgbe_mrqc_reg_get(enum ixgbe_mac_type mac_type) {
7241 case ixgbe_mac_X550_vf:
7242 case ixgbe_mac_X550EM_x_vf:
7243 case ixgbe_mac_X550EM_a_vf:
7244 return IXGBE_VFMRQC;
7251 ixgbe_rssrk_reg_get(enum ixgbe_mac_type mac_type, uint8_t i) {
7253 case ixgbe_mac_X550_vf:
7254 case ixgbe_mac_X550EM_x_vf:
7255 case ixgbe_mac_X550EM_a_vf:
7256 return IXGBE_VFRSSRK(i);
7258 return IXGBE_RSSRK(i);
7263 ixgbe_rss_update_sp(enum ixgbe_mac_type mac_type) {
7265 case ixgbe_mac_82599_vf:
7266 case ixgbe_mac_X540_vf:
7274 ixgbe_dev_get_dcb_info(struct rte_eth_dev *dev,
7275 struct rte_eth_dcb_info *dcb_info)
7277 struct ixgbe_dcb_config *dcb_config =
7278 IXGBE_DEV_PRIVATE_TO_DCB_CFG(dev->data->dev_private);
7279 struct ixgbe_dcb_tc_config *tc;
7280 struct rte_eth_dcb_tc_queue_mapping *tc_queue;
7284 if (dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_DCB_FLAG)
7285 dcb_info->nb_tcs = dcb_config->num_tcs.pg_tcs;
7287 dcb_info->nb_tcs = 1;
7289 tc_queue = &dcb_info->tc_queue;
7290 nb_tcs = dcb_info->nb_tcs;
7292 if (dcb_config->vt_mode) { /* vt is enabled*/
7293 struct rte_eth_vmdq_dcb_conf *vmdq_rx_conf =
7294 &dev->data->dev_conf.rx_adv_conf.vmdq_dcb_conf;
7295 for (i = 0; i < ETH_DCB_NUM_USER_PRIORITIES; i++)
7296 dcb_info->prio_tc[i] = vmdq_rx_conf->dcb_tc[i];
7297 if (RTE_ETH_DEV_SRIOV(dev).active > 0) {
7298 for (j = 0; j < nb_tcs; j++) {
7299 tc_queue->tc_rxq[0][j].base = j;
7300 tc_queue->tc_rxq[0][j].nb_queue = 1;
7301 tc_queue->tc_txq[0][j].base = j;
7302 tc_queue->tc_txq[0][j].nb_queue = 1;
7305 for (i = 0; i < vmdq_rx_conf->nb_queue_pools; i++) {
7306 for (j = 0; j < nb_tcs; j++) {
7307 tc_queue->tc_rxq[i][j].base =
7309 tc_queue->tc_rxq[i][j].nb_queue = 1;
7310 tc_queue->tc_txq[i][j].base =
7312 tc_queue->tc_txq[i][j].nb_queue = 1;
7316 } else { /* vt is disabled*/
7317 struct rte_eth_dcb_rx_conf *rx_conf =
7318 &dev->data->dev_conf.rx_adv_conf.dcb_rx_conf;
7319 for (i = 0; i < ETH_DCB_NUM_USER_PRIORITIES; i++)
7320 dcb_info->prio_tc[i] = rx_conf->dcb_tc[i];
7321 if (dcb_info->nb_tcs == ETH_4_TCS) {
7322 for (i = 0; i < dcb_info->nb_tcs; i++) {
7323 dcb_info->tc_queue.tc_rxq[0][i].base = i * 32;
7324 dcb_info->tc_queue.tc_rxq[0][i].nb_queue = 16;
7326 dcb_info->tc_queue.tc_txq[0][0].base = 0;
7327 dcb_info->tc_queue.tc_txq[0][1].base = 64;
7328 dcb_info->tc_queue.tc_txq[0][2].base = 96;
7329 dcb_info->tc_queue.tc_txq[0][3].base = 112;
7330 dcb_info->tc_queue.tc_txq[0][0].nb_queue = 64;
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 } else if (dcb_info->nb_tcs == ETH_8_TCS) {
7335 for (i = 0; i < dcb_info->nb_tcs; i++) {
7336 dcb_info->tc_queue.tc_rxq[0][i].base = i * 16;
7337 dcb_info->tc_queue.tc_rxq[0][i].nb_queue = 16;
7339 dcb_info->tc_queue.tc_txq[0][0].base = 0;
7340 dcb_info->tc_queue.tc_txq[0][1].base = 32;
7341 dcb_info->tc_queue.tc_txq[0][2].base = 64;
7342 dcb_info->tc_queue.tc_txq[0][3].base = 80;
7343 dcb_info->tc_queue.tc_txq[0][4].base = 96;
7344 dcb_info->tc_queue.tc_txq[0][5].base = 104;
7345 dcb_info->tc_queue.tc_txq[0][6].base = 112;
7346 dcb_info->tc_queue.tc_txq[0][7].base = 120;
7347 dcb_info->tc_queue.tc_txq[0][0].nb_queue = 32;
7348 dcb_info->tc_queue.tc_txq[0][1].nb_queue = 32;
7349 dcb_info->tc_queue.tc_txq[0][2].nb_queue = 16;
7350 dcb_info->tc_queue.tc_txq[0][3].nb_queue = 16;
7351 dcb_info->tc_queue.tc_txq[0][4].nb_queue = 8;
7352 dcb_info->tc_queue.tc_txq[0][5].nb_queue = 8;
7353 dcb_info->tc_queue.tc_txq[0][6].nb_queue = 8;
7354 dcb_info->tc_queue.tc_txq[0][7].nb_queue = 8;
7357 for (i = 0; i < dcb_info->nb_tcs; i++) {
7358 tc = &dcb_config->tc_config[i];
7359 dcb_info->tc_bws[i] = tc->path[IXGBE_DCB_TX_CONFIG].bwg_percent;
7364 /* Update e-tag ether type */
7366 ixgbe_update_e_tag_eth_type(struct ixgbe_hw *hw,
7367 uint16_t ether_type)
7369 uint32_t etag_etype;
7371 if (hw->mac.type != ixgbe_mac_X550 &&
7372 hw->mac.type != ixgbe_mac_X550EM_x &&
7373 hw->mac.type != ixgbe_mac_X550EM_a) {
7377 etag_etype = IXGBE_READ_REG(hw, IXGBE_ETAG_ETYPE);
7378 etag_etype &= ~IXGBE_ETAG_ETYPE_MASK;
7379 etag_etype |= ether_type;
7380 IXGBE_WRITE_REG(hw, IXGBE_ETAG_ETYPE, etag_etype);
7381 IXGBE_WRITE_FLUSH(hw);
7386 /* Config l2 tunnel ether type */
7388 ixgbe_dev_l2_tunnel_eth_type_conf(struct rte_eth_dev *dev,
7389 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7392 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7393 struct ixgbe_l2_tn_info *l2_tn_info =
7394 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
7396 if (l2_tunnel == NULL)
7399 switch (l2_tunnel->l2_tunnel_type) {
7400 case RTE_L2_TUNNEL_TYPE_E_TAG:
7401 l2_tn_info->e_tag_ether_type = l2_tunnel->ether_type;
7402 ret = ixgbe_update_e_tag_eth_type(hw, l2_tunnel->ether_type);
7405 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7413 /* Enable e-tag tunnel */
7415 ixgbe_e_tag_enable(struct ixgbe_hw *hw)
7417 uint32_t etag_etype;
7419 if (hw->mac.type != ixgbe_mac_X550 &&
7420 hw->mac.type != ixgbe_mac_X550EM_x &&
7421 hw->mac.type != ixgbe_mac_X550EM_a) {
7425 etag_etype = IXGBE_READ_REG(hw, IXGBE_ETAG_ETYPE);
7426 etag_etype |= IXGBE_ETAG_ETYPE_VALID;
7427 IXGBE_WRITE_REG(hw, IXGBE_ETAG_ETYPE, etag_etype);
7428 IXGBE_WRITE_FLUSH(hw);
7433 /* Enable l2 tunnel */
7435 ixgbe_dev_l2_tunnel_enable(struct rte_eth_dev *dev,
7436 enum rte_eth_tunnel_type l2_tunnel_type)
7439 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7440 struct ixgbe_l2_tn_info *l2_tn_info =
7441 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
7443 switch (l2_tunnel_type) {
7444 case RTE_L2_TUNNEL_TYPE_E_TAG:
7445 l2_tn_info->e_tag_en = TRUE;
7446 ret = ixgbe_e_tag_enable(hw);
7449 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7457 /* Disable e-tag tunnel */
7459 ixgbe_e_tag_disable(struct ixgbe_hw *hw)
7461 uint32_t etag_etype;
7463 if (hw->mac.type != ixgbe_mac_X550 &&
7464 hw->mac.type != ixgbe_mac_X550EM_x &&
7465 hw->mac.type != ixgbe_mac_X550EM_a) {
7469 etag_etype = IXGBE_READ_REG(hw, IXGBE_ETAG_ETYPE);
7470 etag_etype &= ~IXGBE_ETAG_ETYPE_VALID;
7471 IXGBE_WRITE_REG(hw, IXGBE_ETAG_ETYPE, etag_etype);
7472 IXGBE_WRITE_FLUSH(hw);
7477 /* Disable l2 tunnel */
7479 ixgbe_dev_l2_tunnel_disable(struct rte_eth_dev *dev,
7480 enum rte_eth_tunnel_type l2_tunnel_type)
7483 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7484 struct ixgbe_l2_tn_info *l2_tn_info =
7485 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
7487 switch (l2_tunnel_type) {
7488 case RTE_L2_TUNNEL_TYPE_E_TAG:
7489 l2_tn_info->e_tag_en = FALSE;
7490 ret = ixgbe_e_tag_disable(hw);
7493 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7502 ixgbe_e_tag_filter_del(struct rte_eth_dev *dev,
7503 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7506 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7507 uint32_t i, rar_entries;
7508 uint32_t rar_low, rar_high;
7510 if (hw->mac.type != ixgbe_mac_X550 &&
7511 hw->mac.type != ixgbe_mac_X550EM_x &&
7512 hw->mac.type != ixgbe_mac_X550EM_a) {
7516 rar_entries = ixgbe_get_num_rx_addrs(hw);
7518 for (i = 1; i < rar_entries; i++) {
7519 rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(i));
7520 rar_low = IXGBE_READ_REG(hw, IXGBE_RAL(i));
7521 if ((rar_high & IXGBE_RAH_AV) &&
7522 (rar_high & IXGBE_RAH_ADTYPE) &&
7523 ((rar_low & IXGBE_RAL_ETAG_FILTER_MASK) ==
7524 l2_tunnel->tunnel_id)) {
7525 IXGBE_WRITE_REG(hw, IXGBE_RAL(i), 0);
7526 IXGBE_WRITE_REG(hw, IXGBE_RAH(i), 0);
7528 ixgbe_clear_vmdq(hw, i, IXGBE_CLEAR_VMDQ_ALL);
7538 ixgbe_e_tag_filter_add(struct rte_eth_dev *dev,
7539 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7542 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7543 uint32_t i, rar_entries;
7544 uint32_t rar_low, rar_high;
7546 if (hw->mac.type != ixgbe_mac_X550 &&
7547 hw->mac.type != ixgbe_mac_X550EM_x &&
7548 hw->mac.type != ixgbe_mac_X550EM_a) {
7552 /* One entry for one tunnel. Try to remove potential existing entry. */
7553 ixgbe_e_tag_filter_del(dev, l2_tunnel);
7555 rar_entries = ixgbe_get_num_rx_addrs(hw);
7557 for (i = 1; i < rar_entries; i++) {
7558 rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(i));
7559 if (rar_high & IXGBE_RAH_AV) {
7562 ixgbe_set_vmdq(hw, i, l2_tunnel->pool);
7563 rar_high = IXGBE_RAH_AV | IXGBE_RAH_ADTYPE;
7564 rar_low = l2_tunnel->tunnel_id;
7566 IXGBE_WRITE_REG(hw, IXGBE_RAL(i), rar_low);
7567 IXGBE_WRITE_REG(hw, IXGBE_RAH(i), rar_high);
7573 PMD_INIT_LOG(NOTICE, "The table of E-tag forwarding rule is full."
7574 " Please remove a rule before adding a new one.");
7578 static inline struct ixgbe_l2_tn_filter *
7579 ixgbe_l2_tn_filter_lookup(struct ixgbe_l2_tn_info *l2_tn_info,
7580 struct ixgbe_l2_tn_key *key)
7584 ret = rte_hash_lookup(l2_tn_info->hash_handle, (const void *)key);
7588 return l2_tn_info->hash_map[ret];
7592 ixgbe_insert_l2_tn_filter(struct ixgbe_l2_tn_info *l2_tn_info,
7593 struct ixgbe_l2_tn_filter *l2_tn_filter)
7597 ret = rte_hash_add_key(l2_tn_info->hash_handle,
7598 &l2_tn_filter->key);
7602 "Failed to insert L2 tunnel filter"
7603 " to hash table %d!",
7608 l2_tn_info->hash_map[ret] = l2_tn_filter;
7610 TAILQ_INSERT_TAIL(&l2_tn_info->l2_tn_list, l2_tn_filter, entries);
7616 ixgbe_remove_l2_tn_filter(struct ixgbe_l2_tn_info *l2_tn_info,
7617 struct ixgbe_l2_tn_key *key)
7620 struct ixgbe_l2_tn_filter *l2_tn_filter;
7622 ret = rte_hash_del_key(l2_tn_info->hash_handle, key);
7626 "No such L2 tunnel filter to delete %d!",
7631 l2_tn_filter = l2_tn_info->hash_map[ret];
7632 l2_tn_info->hash_map[ret] = NULL;
7634 TAILQ_REMOVE(&l2_tn_info->l2_tn_list, l2_tn_filter, entries);
7635 rte_free(l2_tn_filter);
7640 /* Add l2 tunnel filter */
7642 ixgbe_dev_l2_tunnel_filter_add(struct rte_eth_dev *dev,
7643 struct rte_eth_l2_tunnel_conf *l2_tunnel,
7647 struct ixgbe_l2_tn_info *l2_tn_info =
7648 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
7649 struct ixgbe_l2_tn_key key;
7650 struct ixgbe_l2_tn_filter *node;
7653 key.l2_tn_type = l2_tunnel->l2_tunnel_type;
7654 key.tn_id = l2_tunnel->tunnel_id;
7656 node = ixgbe_l2_tn_filter_lookup(l2_tn_info, &key);
7660 "The L2 tunnel filter already exists!");
7664 node = rte_zmalloc("ixgbe_l2_tn",
7665 sizeof(struct ixgbe_l2_tn_filter),
7670 rte_memcpy(&node->key,
7672 sizeof(struct ixgbe_l2_tn_key));
7673 node->pool = l2_tunnel->pool;
7674 ret = ixgbe_insert_l2_tn_filter(l2_tn_info, node);
7681 switch (l2_tunnel->l2_tunnel_type) {
7682 case RTE_L2_TUNNEL_TYPE_E_TAG:
7683 ret = ixgbe_e_tag_filter_add(dev, l2_tunnel);
7686 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7691 if ((!restore) && (ret < 0))
7692 (void)ixgbe_remove_l2_tn_filter(l2_tn_info, &key);
7697 /* Delete l2 tunnel filter */
7699 ixgbe_dev_l2_tunnel_filter_del(struct rte_eth_dev *dev,
7700 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7703 struct ixgbe_l2_tn_info *l2_tn_info =
7704 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
7705 struct ixgbe_l2_tn_key key;
7707 key.l2_tn_type = l2_tunnel->l2_tunnel_type;
7708 key.tn_id = l2_tunnel->tunnel_id;
7709 ret = ixgbe_remove_l2_tn_filter(l2_tn_info, &key);
7713 switch (l2_tunnel->l2_tunnel_type) {
7714 case RTE_L2_TUNNEL_TYPE_E_TAG:
7715 ret = ixgbe_e_tag_filter_del(dev, l2_tunnel);
7718 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7727 * ixgbe_dev_l2_tunnel_filter_handle - Handle operations for l2 tunnel filter.
7728 * @dev: pointer to rte_eth_dev structure
7729 * @filter_op:operation will be taken.
7730 * @arg: a pointer to specific structure corresponding to the filter_op
7733 ixgbe_dev_l2_tunnel_filter_handle(struct rte_eth_dev *dev,
7734 enum rte_filter_op filter_op,
7739 if (filter_op == RTE_ETH_FILTER_NOP)
7743 PMD_DRV_LOG(ERR, "arg shouldn't be NULL for operation %u.",
7748 switch (filter_op) {
7749 case RTE_ETH_FILTER_ADD:
7750 ret = ixgbe_dev_l2_tunnel_filter_add
7752 (struct rte_eth_l2_tunnel_conf *)arg,
7755 case RTE_ETH_FILTER_DELETE:
7756 ret = ixgbe_dev_l2_tunnel_filter_del
7758 (struct rte_eth_l2_tunnel_conf *)arg);
7761 PMD_DRV_LOG(ERR, "unsupported operation %u.", filter_op);
7769 ixgbe_e_tag_forwarding_en_dis(struct rte_eth_dev *dev, bool en)
7773 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7775 if (hw->mac.type != ixgbe_mac_X550 &&
7776 hw->mac.type != ixgbe_mac_X550EM_x &&
7777 hw->mac.type != ixgbe_mac_X550EM_a) {
7781 ctrl = IXGBE_READ_REG(hw, IXGBE_VT_CTL);
7782 ctrl &= ~IXGBE_VT_CTL_POOLING_MODE_MASK;
7784 ctrl |= IXGBE_VT_CTL_POOLING_MODE_ETAG;
7785 IXGBE_WRITE_REG(hw, IXGBE_VT_CTL, ctrl);
7790 /* Enable l2 tunnel forwarding */
7792 ixgbe_dev_l2_tunnel_forwarding_enable
7793 (struct rte_eth_dev *dev,
7794 enum rte_eth_tunnel_type l2_tunnel_type)
7796 struct ixgbe_l2_tn_info *l2_tn_info =
7797 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
7800 switch (l2_tunnel_type) {
7801 case RTE_L2_TUNNEL_TYPE_E_TAG:
7802 l2_tn_info->e_tag_fwd_en = TRUE;
7803 ret = ixgbe_e_tag_forwarding_en_dis(dev, 1);
7806 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7814 /* Disable l2 tunnel forwarding */
7816 ixgbe_dev_l2_tunnel_forwarding_disable
7817 (struct rte_eth_dev *dev,
7818 enum rte_eth_tunnel_type l2_tunnel_type)
7820 struct ixgbe_l2_tn_info *l2_tn_info =
7821 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
7824 switch (l2_tunnel_type) {
7825 case RTE_L2_TUNNEL_TYPE_E_TAG:
7826 l2_tn_info->e_tag_fwd_en = FALSE;
7827 ret = ixgbe_e_tag_forwarding_en_dis(dev, 0);
7830 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7839 ixgbe_e_tag_insertion_en_dis(struct rte_eth_dev *dev,
7840 struct rte_eth_l2_tunnel_conf *l2_tunnel,
7843 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
7845 uint32_t vmtir, vmvir;
7846 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7848 if (l2_tunnel->vf_id >= pci_dev->max_vfs) {
7850 "VF id %u should be less than %u",
7856 if (hw->mac.type != ixgbe_mac_X550 &&
7857 hw->mac.type != ixgbe_mac_X550EM_x &&
7858 hw->mac.type != ixgbe_mac_X550EM_a) {
7863 vmtir = l2_tunnel->tunnel_id;
7867 IXGBE_WRITE_REG(hw, IXGBE_VMTIR(l2_tunnel->vf_id), vmtir);
7869 vmvir = IXGBE_READ_REG(hw, IXGBE_VMVIR(l2_tunnel->vf_id));
7870 vmvir &= ~IXGBE_VMVIR_TAGA_MASK;
7872 vmvir |= IXGBE_VMVIR_TAGA_ETAG_INSERT;
7873 IXGBE_WRITE_REG(hw, IXGBE_VMVIR(l2_tunnel->vf_id), vmvir);
7878 /* Enable l2 tunnel tag insertion */
7880 ixgbe_dev_l2_tunnel_insertion_enable(struct rte_eth_dev *dev,
7881 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7885 switch (l2_tunnel->l2_tunnel_type) {
7886 case RTE_L2_TUNNEL_TYPE_E_TAG:
7887 ret = ixgbe_e_tag_insertion_en_dis(dev, l2_tunnel, 1);
7890 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7898 /* Disable l2 tunnel tag insertion */
7900 ixgbe_dev_l2_tunnel_insertion_disable
7901 (struct rte_eth_dev *dev,
7902 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7906 switch (l2_tunnel->l2_tunnel_type) {
7907 case RTE_L2_TUNNEL_TYPE_E_TAG:
7908 ret = ixgbe_e_tag_insertion_en_dis(dev, l2_tunnel, 0);
7911 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7920 ixgbe_e_tag_stripping_en_dis(struct rte_eth_dev *dev,
7925 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7927 if (hw->mac.type != ixgbe_mac_X550 &&
7928 hw->mac.type != ixgbe_mac_X550EM_x &&
7929 hw->mac.type != ixgbe_mac_X550EM_a) {
7933 qde = IXGBE_READ_REG(hw, IXGBE_QDE);
7935 qde |= IXGBE_QDE_STRIP_TAG;
7937 qde &= ~IXGBE_QDE_STRIP_TAG;
7938 qde &= ~IXGBE_QDE_READ;
7939 qde |= IXGBE_QDE_WRITE;
7940 IXGBE_WRITE_REG(hw, IXGBE_QDE, qde);
7945 /* Enable l2 tunnel tag stripping */
7947 ixgbe_dev_l2_tunnel_stripping_enable
7948 (struct rte_eth_dev *dev,
7949 enum rte_eth_tunnel_type l2_tunnel_type)
7953 switch (l2_tunnel_type) {
7954 case RTE_L2_TUNNEL_TYPE_E_TAG:
7955 ret = ixgbe_e_tag_stripping_en_dis(dev, 1);
7958 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7966 /* Disable l2 tunnel tag stripping */
7968 ixgbe_dev_l2_tunnel_stripping_disable
7969 (struct rte_eth_dev *dev,
7970 enum rte_eth_tunnel_type l2_tunnel_type)
7974 switch (l2_tunnel_type) {
7975 case RTE_L2_TUNNEL_TYPE_E_TAG:
7976 ret = ixgbe_e_tag_stripping_en_dis(dev, 0);
7979 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7987 /* Enable/disable l2 tunnel offload functions */
7989 ixgbe_dev_l2_tunnel_offload_set
7990 (struct rte_eth_dev *dev,
7991 struct rte_eth_l2_tunnel_conf *l2_tunnel,
7997 if (l2_tunnel == NULL)
8001 if (mask & ETH_L2_TUNNEL_ENABLE_MASK) {
8003 ret = ixgbe_dev_l2_tunnel_enable(
8005 l2_tunnel->l2_tunnel_type);
8007 ret = ixgbe_dev_l2_tunnel_disable(
8009 l2_tunnel->l2_tunnel_type);
8012 if (mask & ETH_L2_TUNNEL_INSERTION_MASK) {
8014 ret = ixgbe_dev_l2_tunnel_insertion_enable(
8018 ret = ixgbe_dev_l2_tunnel_insertion_disable(
8023 if (mask & ETH_L2_TUNNEL_STRIPPING_MASK) {
8025 ret = ixgbe_dev_l2_tunnel_stripping_enable(
8027 l2_tunnel->l2_tunnel_type);
8029 ret = ixgbe_dev_l2_tunnel_stripping_disable(
8031 l2_tunnel->l2_tunnel_type);
8034 if (mask & ETH_L2_TUNNEL_FORWARDING_MASK) {
8036 ret = ixgbe_dev_l2_tunnel_forwarding_enable(
8038 l2_tunnel->l2_tunnel_type);
8040 ret = ixgbe_dev_l2_tunnel_forwarding_disable(
8042 l2_tunnel->l2_tunnel_type);
8049 ixgbe_update_vxlan_port(struct ixgbe_hw *hw,
8052 IXGBE_WRITE_REG(hw, IXGBE_VXLANCTRL, port);
8053 IXGBE_WRITE_FLUSH(hw);
8058 /* There's only one register for VxLAN UDP port.
8059 * So, we cannot add several ports. Will update it.
8062 ixgbe_add_vxlan_port(struct ixgbe_hw *hw,
8066 PMD_DRV_LOG(ERR, "Add VxLAN port 0 is not allowed.");
8070 return ixgbe_update_vxlan_port(hw, port);
8073 /* We cannot delete the VxLAN port. For there's a register for VxLAN
8074 * UDP port, it must have a value.
8075 * So, will reset it to the original value 0.
8078 ixgbe_del_vxlan_port(struct ixgbe_hw *hw,
8083 cur_port = (uint16_t)IXGBE_READ_REG(hw, IXGBE_VXLANCTRL);
8085 if (cur_port != port) {
8086 PMD_DRV_LOG(ERR, "Port %u does not exist.", port);
8090 return ixgbe_update_vxlan_port(hw, 0);
8093 /* Add UDP tunneling port */
8095 ixgbe_dev_udp_tunnel_port_add(struct rte_eth_dev *dev,
8096 struct rte_eth_udp_tunnel *udp_tunnel)
8099 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8101 if (hw->mac.type != ixgbe_mac_X550 &&
8102 hw->mac.type != ixgbe_mac_X550EM_x &&
8103 hw->mac.type != ixgbe_mac_X550EM_a) {
8107 if (udp_tunnel == NULL)
8110 switch (udp_tunnel->prot_type) {
8111 case RTE_TUNNEL_TYPE_VXLAN:
8112 ret = ixgbe_add_vxlan_port(hw, udp_tunnel->udp_port);
8115 case RTE_TUNNEL_TYPE_GENEVE:
8116 case RTE_TUNNEL_TYPE_TEREDO:
8117 PMD_DRV_LOG(ERR, "Tunnel type is not supported now.");
8122 PMD_DRV_LOG(ERR, "Invalid tunnel type");
8130 /* Remove UDP tunneling port */
8132 ixgbe_dev_udp_tunnel_port_del(struct rte_eth_dev *dev,
8133 struct rte_eth_udp_tunnel *udp_tunnel)
8136 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8138 if (hw->mac.type != ixgbe_mac_X550 &&
8139 hw->mac.type != ixgbe_mac_X550EM_x &&
8140 hw->mac.type != ixgbe_mac_X550EM_a) {
8144 if (udp_tunnel == NULL)
8147 switch (udp_tunnel->prot_type) {
8148 case RTE_TUNNEL_TYPE_VXLAN:
8149 ret = ixgbe_del_vxlan_port(hw, udp_tunnel->udp_port);
8151 case RTE_TUNNEL_TYPE_GENEVE:
8152 case RTE_TUNNEL_TYPE_TEREDO:
8153 PMD_DRV_LOG(ERR, "Tunnel type is not supported now.");
8157 PMD_DRV_LOG(ERR, "Invalid tunnel type");
8166 ixgbevf_dev_allmulticast_enable(struct rte_eth_dev *dev)
8168 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8170 hw->mac.ops.update_xcast_mode(hw, IXGBEVF_XCAST_MODE_ALLMULTI);
8174 ixgbevf_dev_allmulticast_disable(struct rte_eth_dev *dev)
8176 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8178 hw->mac.ops.update_xcast_mode(hw, IXGBEVF_XCAST_MODE_MULTI);
8181 static void ixgbevf_mbx_process(struct rte_eth_dev *dev)
8183 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8186 if (ixgbe_read_mbx(hw, &in_msg, 1, 0))
8189 /* PF reset VF event */
8190 if (in_msg == IXGBE_PF_CONTROL_MSG)
8191 _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RESET,
8196 ixgbevf_dev_interrupt_get_status(struct rte_eth_dev *dev)
8199 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8200 struct ixgbe_interrupt *intr =
8201 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
8202 ixgbevf_intr_disable(hw);
8204 /* read-on-clear nic registers here */
8205 eicr = IXGBE_READ_REG(hw, IXGBE_VTEICR);
8208 /* only one misc vector supported - mailbox */
8209 eicr &= IXGBE_VTEICR_MASK;
8210 if (eicr == IXGBE_MISC_VEC_ID)
8211 intr->flags |= IXGBE_FLAG_MAILBOX;
8217 ixgbevf_dev_interrupt_action(struct rte_eth_dev *dev)
8219 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8220 struct ixgbe_interrupt *intr =
8221 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
8223 if (intr->flags & IXGBE_FLAG_MAILBOX) {
8224 ixgbevf_mbx_process(dev);
8225 intr->flags &= ~IXGBE_FLAG_MAILBOX;
8228 ixgbevf_intr_enable(hw);
8234 ixgbevf_dev_interrupt_handler(void *param)
8236 struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
8238 ixgbevf_dev_interrupt_get_status(dev);
8239 ixgbevf_dev_interrupt_action(dev);
8243 * ixgbe_disable_sec_tx_path_generic - Stops the transmit data path
8244 * @hw: pointer to hardware structure
8246 * Stops the transmit data path and waits for the HW to internally empty
8247 * the Tx security block
8249 int ixgbe_disable_sec_tx_path_generic(struct ixgbe_hw *hw)
8251 #define IXGBE_MAX_SECTX_POLL 40
8256 sectxreg = IXGBE_READ_REG(hw, IXGBE_SECTXCTRL);
8257 sectxreg |= IXGBE_SECTXCTRL_TX_DIS;
8258 IXGBE_WRITE_REG(hw, IXGBE_SECTXCTRL, sectxreg);
8259 for (i = 0; i < IXGBE_MAX_SECTX_POLL; i++) {
8260 sectxreg = IXGBE_READ_REG(hw, IXGBE_SECTXSTAT);
8261 if (sectxreg & IXGBE_SECTXSTAT_SECTX_RDY)
8263 /* Use interrupt-safe sleep just in case */
8267 /* For informational purposes only */
8268 if (i >= IXGBE_MAX_SECTX_POLL)
8269 PMD_DRV_LOG(DEBUG, "Tx unit being enabled before security "
8270 "path fully disabled. Continuing with init.");
8272 return IXGBE_SUCCESS;
8276 * ixgbe_enable_sec_tx_path_generic - Enables the transmit data path
8277 * @hw: pointer to hardware structure
8279 * Enables the transmit data path.
8281 int ixgbe_enable_sec_tx_path_generic(struct ixgbe_hw *hw)
8285 sectxreg = IXGBE_READ_REG(hw, IXGBE_SECTXCTRL);
8286 sectxreg &= ~IXGBE_SECTXCTRL_TX_DIS;
8287 IXGBE_WRITE_REG(hw, IXGBE_SECTXCTRL, sectxreg);
8288 IXGBE_WRITE_FLUSH(hw);
8290 return IXGBE_SUCCESS;
8293 /* restore n-tuple filter */
8295 ixgbe_ntuple_filter_restore(struct rte_eth_dev *dev)
8297 struct ixgbe_filter_info *filter_info =
8298 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
8299 struct ixgbe_5tuple_filter *node;
8301 TAILQ_FOREACH(node, &filter_info->fivetuple_list, entries) {
8302 ixgbe_inject_5tuple_filter(dev, node);
8306 /* restore ethernet type filter */
8308 ixgbe_ethertype_filter_restore(struct rte_eth_dev *dev)
8310 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8311 struct ixgbe_filter_info *filter_info =
8312 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
8315 for (i = 0; i < IXGBE_MAX_ETQF_FILTERS; i++) {
8316 if (filter_info->ethertype_mask & (1 << i)) {
8317 IXGBE_WRITE_REG(hw, IXGBE_ETQF(i),
8318 filter_info->ethertype_filters[i].etqf);
8319 IXGBE_WRITE_REG(hw, IXGBE_ETQS(i),
8320 filter_info->ethertype_filters[i].etqs);
8321 IXGBE_WRITE_FLUSH(hw);
8326 /* restore SYN filter */
8328 ixgbe_syn_filter_restore(struct rte_eth_dev *dev)
8330 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8331 struct ixgbe_filter_info *filter_info =
8332 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
8335 synqf = filter_info->syn_info;
8337 if (synqf & IXGBE_SYN_FILTER_ENABLE) {
8338 IXGBE_WRITE_REG(hw, IXGBE_SYNQF, synqf);
8339 IXGBE_WRITE_FLUSH(hw);
8343 /* restore L2 tunnel filter */
8345 ixgbe_l2_tn_filter_restore(struct rte_eth_dev *dev)
8347 struct ixgbe_l2_tn_info *l2_tn_info =
8348 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
8349 struct ixgbe_l2_tn_filter *node;
8350 struct rte_eth_l2_tunnel_conf l2_tn_conf;
8352 TAILQ_FOREACH(node, &l2_tn_info->l2_tn_list, entries) {
8353 l2_tn_conf.l2_tunnel_type = node->key.l2_tn_type;
8354 l2_tn_conf.tunnel_id = node->key.tn_id;
8355 l2_tn_conf.pool = node->pool;
8356 (void)ixgbe_dev_l2_tunnel_filter_add(dev, &l2_tn_conf, TRUE);
8361 ixgbe_filter_restore(struct rte_eth_dev *dev)
8363 ixgbe_ntuple_filter_restore(dev);
8364 ixgbe_ethertype_filter_restore(dev);
8365 ixgbe_syn_filter_restore(dev);
8366 ixgbe_fdir_filter_restore(dev);
8367 ixgbe_l2_tn_filter_restore(dev);
8373 ixgbe_l2_tunnel_conf(struct rte_eth_dev *dev)
8375 struct ixgbe_l2_tn_info *l2_tn_info =
8376 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
8377 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8379 if (l2_tn_info->e_tag_en)
8380 (void)ixgbe_e_tag_enable(hw);
8382 if (l2_tn_info->e_tag_fwd_en)
8383 (void)ixgbe_e_tag_forwarding_en_dis(dev, 1);
8385 (void)ixgbe_update_e_tag_eth_type(hw, l2_tn_info->e_tag_ether_type);
8388 /* remove all the n-tuple filters */
8390 ixgbe_clear_all_ntuple_filter(struct rte_eth_dev *dev)
8392 struct ixgbe_filter_info *filter_info =
8393 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
8394 struct ixgbe_5tuple_filter *p_5tuple;
8396 while ((p_5tuple = TAILQ_FIRST(&filter_info->fivetuple_list)))
8397 ixgbe_remove_5tuple_filter(dev, p_5tuple);
8400 /* remove all the ether type filters */
8402 ixgbe_clear_all_ethertype_filter(struct rte_eth_dev *dev)
8404 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8405 struct ixgbe_filter_info *filter_info =
8406 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
8409 for (i = 0; i < IXGBE_MAX_ETQF_FILTERS; i++) {
8410 if (filter_info->ethertype_mask & (1 << i) &&
8411 !filter_info->ethertype_filters[i].conf) {
8412 (void)ixgbe_ethertype_filter_remove(filter_info,
8414 IXGBE_WRITE_REG(hw, IXGBE_ETQF(i), 0);
8415 IXGBE_WRITE_REG(hw, IXGBE_ETQS(i), 0);
8416 IXGBE_WRITE_FLUSH(hw);
8421 /* remove the SYN filter */
8423 ixgbe_clear_syn_filter(struct rte_eth_dev *dev)
8425 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8426 struct ixgbe_filter_info *filter_info =
8427 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
8429 if (filter_info->syn_info & IXGBE_SYN_FILTER_ENABLE) {
8430 filter_info->syn_info = 0;
8432 IXGBE_WRITE_REG(hw, IXGBE_SYNQF, 0);
8433 IXGBE_WRITE_FLUSH(hw);
8437 /* remove all the L2 tunnel filters */
8439 ixgbe_clear_all_l2_tn_filter(struct rte_eth_dev *dev)
8441 struct ixgbe_l2_tn_info *l2_tn_info =
8442 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
8443 struct ixgbe_l2_tn_filter *l2_tn_filter;
8444 struct rte_eth_l2_tunnel_conf l2_tn_conf;
8447 while ((l2_tn_filter = TAILQ_FIRST(&l2_tn_info->l2_tn_list))) {
8448 l2_tn_conf.l2_tunnel_type = l2_tn_filter->key.l2_tn_type;
8449 l2_tn_conf.tunnel_id = l2_tn_filter->key.tn_id;
8450 l2_tn_conf.pool = l2_tn_filter->pool;
8451 ret = ixgbe_dev_l2_tunnel_filter_del(dev, &l2_tn_conf);
8459 RTE_PMD_REGISTER_PCI(net_ixgbe, rte_ixgbe_pmd);
8460 RTE_PMD_REGISTER_PCI_TABLE(net_ixgbe, pci_id_ixgbe_map);
8461 RTE_PMD_REGISTER_KMOD_DEP(net_ixgbe, "* igb_uio | uio_pci_generic | vfio-pci");
8462 RTE_PMD_REGISTER_PCI(net_ixgbe_vf, rte_ixgbevf_pmd);
8463 RTE_PMD_REGISTER_PCI_TABLE(net_ixgbe_vf, pci_id_ixgbevf_map);
8464 RTE_PMD_REGISTER_KMOD_DEP(net_ixgbe_vf, "* igb_uio | vfio-pci");