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_atomic.h>
52 #include <rte_branch_prediction.h>
53 #include <rte_memory.h>
54 #include <rte_memzone.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_atomic.h>
61 #include <rte_malloc.h>
62 #include <rte_random.h>
64 #include <rte_hash_crc.h>
66 #include "ixgbe_logs.h"
67 #include "base/ixgbe_api.h"
68 #include "base/ixgbe_vf.h"
69 #include "base/ixgbe_common.h"
70 #include "ixgbe_ethdev.h"
71 #include "ixgbe_bypass.h"
72 #include "ixgbe_rxtx.h"
73 #include "base/ixgbe_type.h"
74 #include "base/ixgbe_phy.h"
75 #include "ixgbe_regs.h"
78 * High threshold controlling when to start sending XOFF frames. Must be at
79 * least 8 bytes less than receive packet buffer size. This value is in units
82 #define IXGBE_FC_HI 0x80
85 * Low threshold controlling when to start sending XON frames. This value is
86 * in units of 1024 bytes.
88 #define IXGBE_FC_LO 0x40
90 /* Default minimum inter-interrupt interval for EITR configuration */
91 #define IXGBE_MIN_INTER_INTERRUPT_INTERVAL_DEFAULT 0x79E
93 /* Timer value included in XOFF frames. */
94 #define IXGBE_FC_PAUSE 0x680
96 #define IXGBE_LINK_DOWN_CHECK_TIMEOUT 4000 /* ms */
97 #define IXGBE_LINK_UP_CHECK_TIMEOUT 1000 /* ms */
98 #define IXGBE_VMDQ_NUM_UC_MAC 4096 /* Maximum nb. of UC MAC addr. */
100 #define IXGBE_MMW_SIZE_DEFAULT 0x4
101 #define IXGBE_MMW_SIZE_JUMBO_FRAME 0x14
102 #define IXGBE_MAX_RING_DESC 4096 /* replicate define from rxtx */
105 * Default values for RX/TX configuration
107 #define IXGBE_DEFAULT_RX_FREE_THRESH 32
108 #define IXGBE_DEFAULT_RX_PTHRESH 8
109 #define IXGBE_DEFAULT_RX_HTHRESH 8
110 #define IXGBE_DEFAULT_RX_WTHRESH 0
112 #define IXGBE_DEFAULT_TX_FREE_THRESH 32
113 #define IXGBE_DEFAULT_TX_PTHRESH 32
114 #define IXGBE_DEFAULT_TX_HTHRESH 0
115 #define IXGBE_DEFAULT_TX_WTHRESH 0
116 #define IXGBE_DEFAULT_TX_RSBIT_THRESH 32
118 /* Bit shift and mask */
119 #define IXGBE_4_BIT_WIDTH (CHAR_BIT / 2)
120 #define IXGBE_4_BIT_MASK RTE_LEN2MASK(IXGBE_4_BIT_WIDTH, uint8_t)
121 #define IXGBE_8_BIT_WIDTH CHAR_BIT
122 #define IXGBE_8_BIT_MASK UINT8_MAX
124 #define IXGBEVF_PMD_NAME "rte_ixgbevf_pmd" /* PMD name */
126 #define IXGBE_QUEUE_STAT_COUNTERS (sizeof(hw_stats->qprc) / sizeof(hw_stats->qprc[0]))
128 #define IXGBE_HKEY_MAX_INDEX 10
130 /* Additional timesync values. */
131 #define NSEC_PER_SEC 1000000000L
132 #define IXGBE_INCVAL_10GB 0x66666666
133 #define IXGBE_INCVAL_1GB 0x40000000
134 #define IXGBE_INCVAL_100 0x50000000
135 #define IXGBE_INCVAL_SHIFT_10GB 28
136 #define IXGBE_INCVAL_SHIFT_1GB 24
137 #define IXGBE_INCVAL_SHIFT_100 21
138 #define IXGBE_INCVAL_SHIFT_82599 7
139 #define IXGBE_INCPER_SHIFT_82599 24
141 #define IXGBE_CYCLECOUNTER_MASK 0xffffffffffffffffULL
143 #define IXGBE_VT_CTL_POOLING_MODE_MASK 0x00030000
144 #define IXGBE_VT_CTL_POOLING_MODE_ETAG 0x00010000
145 #define DEFAULT_ETAG_ETYPE 0x893f
146 #define IXGBE_ETAG_ETYPE 0x00005084
147 #define IXGBE_ETAG_ETYPE_MASK 0x0000ffff
148 #define IXGBE_ETAG_ETYPE_VALID 0x80000000
149 #define IXGBE_RAH_ADTYPE 0x40000000
150 #define IXGBE_RAL_ETAG_FILTER_MASK 0x00003fff
151 #define IXGBE_VMVIR_TAGA_MASK 0x18000000
152 #define IXGBE_VMVIR_TAGA_ETAG_INSERT 0x08000000
153 #define IXGBE_VMTIR(_i) (0x00017000 + ((_i) * 4)) /* 64 of these (0-63) */
154 #define IXGBE_QDE_STRIP_TAG 0x00000004
155 #define IXGBE_VTEICR_MASK 0x07
157 #define IXGBE_EXVET_VET_EXT_SHIFT 16
158 #define IXGBE_DMATXCTL_VT_MASK 0xFFFF0000
160 static int eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev);
161 static int eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev);
162 static int ixgbe_fdir_filter_init(struct rte_eth_dev *eth_dev);
163 static int ixgbe_fdir_filter_uninit(struct rte_eth_dev *eth_dev);
164 static int ixgbe_l2_tn_filter_init(struct rte_eth_dev *eth_dev);
165 static int ixgbe_l2_tn_filter_uninit(struct rte_eth_dev *eth_dev);
166 static int ixgbe_ntuple_filter_uninit(struct rte_eth_dev *eth_dev);
167 static int ixgbe_dev_configure(struct rte_eth_dev *dev);
168 static int ixgbe_dev_start(struct rte_eth_dev *dev);
169 static void ixgbe_dev_stop(struct rte_eth_dev *dev);
170 static int ixgbe_dev_set_link_up(struct rte_eth_dev *dev);
171 static int ixgbe_dev_set_link_down(struct rte_eth_dev *dev);
172 static void ixgbe_dev_close(struct rte_eth_dev *dev);
173 static void ixgbe_dev_promiscuous_enable(struct rte_eth_dev *dev);
174 static void ixgbe_dev_promiscuous_disable(struct rte_eth_dev *dev);
175 static void ixgbe_dev_allmulticast_enable(struct rte_eth_dev *dev);
176 static void ixgbe_dev_allmulticast_disable(struct rte_eth_dev *dev);
177 static int ixgbe_dev_link_update(struct rte_eth_dev *dev,
178 int wait_to_complete);
179 static void ixgbe_dev_stats_get(struct rte_eth_dev *dev,
180 struct rte_eth_stats *stats);
181 static int ixgbe_dev_xstats_get(struct rte_eth_dev *dev,
182 struct rte_eth_xstat *xstats, unsigned n);
183 static int ixgbevf_dev_xstats_get(struct rte_eth_dev *dev,
184 struct rte_eth_xstat *xstats, unsigned n);
186 ixgbe_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids,
187 uint64_t *values, unsigned int n);
188 static void ixgbe_dev_stats_reset(struct rte_eth_dev *dev);
189 static void ixgbe_dev_xstats_reset(struct rte_eth_dev *dev);
190 static int ixgbe_dev_xstats_get_names(struct rte_eth_dev *dev,
191 struct rte_eth_xstat_name *xstats_names,
193 static int ixgbevf_dev_xstats_get_names(struct rte_eth_dev *dev,
194 struct rte_eth_xstat_name *xstats_names, unsigned limit);
195 static int ixgbe_dev_xstats_get_names_by_id(
196 struct rte_eth_dev *dev,
197 struct rte_eth_xstat_name *xstats_names,
200 static int ixgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
204 static int ixgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
206 static void ixgbe_dev_info_get(struct rte_eth_dev *dev,
207 struct rte_eth_dev_info *dev_info);
208 static const uint32_t *ixgbe_dev_supported_ptypes_get(struct rte_eth_dev *dev);
209 static void ixgbevf_dev_info_get(struct rte_eth_dev *dev,
210 struct rte_eth_dev_info *dev_info);
211 static int ixgbe_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
213 static int ixgbe_vlan_filter_set(struct rte_eth_dev *dev,
214 uint16_t vlan_id, int on);
215 static int ixgbe_vlan_tpid_set(struct rte_eth_dev *dev,
216 enum rte_vlan_type vlan_type,
218 static void ixgbe_vlan_hw_strip_bitmap_set(struct rte_eth_dev *dev,
219 uint16_t queue, bool on);
220 static void ixgbe_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue,
222 static void ixgbe_vlan_offload_set(struct rte_eth_dev *dev, int mask);
223 static void ixgbe_vlan_hw_strip_enable(struct rte_eth_dev *dev, uint16_t queue);
224 static void ixgbe_vlan_hw_strip_disable(struct rte_eth_dev *dev, uint16_t queue);
225 static void ixgbe_vlan_hw_extend_enable(struct rte_eth_dev *dev);
226 static void ixgbe_vlan_hw_extend_disable(struct rte_eth_dev *dev);
228 static int ixgbe_dev_led_on(struct rte_eth_dev *dev);
229 static int ixgbe_dev_led_off(struct rte_eth_dev *dev);
230 static int ixgbe_flow_ctrl_get(struct rte_eth_dev *dev,
231 struct rte_eth_fc_conf *fc_conf);
232 static int ixgbe_flow_ctrl_set(struct rte_eth_dev *dev,
233 struct rte_eth_fc_conf *fc_conf);
234 static int ixgbe_priority_flow_ctrl_set(struct rte_eth_dev *dev,
235 struct rte_eth_pfc_conf *pfc_conf);
236 static int ixgbe_dev_rss_reta_update(struct rte_eth_dev *dev,
237 struct rte_eth_rss_reta_entry64 *reta_conf,
239 static int ixgbe_dev_rss_reta_query(struct rte_eth_dev *dev,
240 struct rte_eth_rss_reta_entry64 *reta_conf,
242 static void ixgbe_dev_link_status_print(struct rte_eth_dev *dev);
243 static int ixgbe_dev_lsc_interrupt_setup(struct rte_eth_dev *dev);
244 static int ixgbe_dev_macsec_interrupt_setup(struct rte_eth_dev *dev);
245 static int ixgbe_dev_rxq_interrupt_setup(struct rte_eth_dev *dev);
246 static int ixgbe_dev_interrupt_get_status(struct rte_eth_dev *dev);
247 static int ixgbe_dev_interrupt_action(struct rte_eth_dev *dev,
248 struct rte_intr_handle *handle);
249 static void ixgbe_dev_interrupt_handler(void *param);
250 static void ixgbe_dev_interrupt_delayed_handler(void *param);
251 static int ixgbe_add_rar(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
252 uint32_t index, uint32_t pool);
253 static void ixgbe_remove_rar(struct rte_eth_dev *dev, uint32_t index);
254 static void ixgbe_set_default_mac_addr(struct rte_eth_dev *dev,
255 struct ether_addr *mac_addr);
256 static void ixgbe_dcb_init(struct ixgbe_hw *hw, struct ixgbe_dcb_config *dcb_config);
257 static bool is_device_supported(struct rte_eth_dev *dev,
258 struct rte_pci_driver *drv);
260 /* For Virtual Function support */
261 static int eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev);
262 static int eth_ixgbevf_dev_uninit(struct rte_eth_dev *eth_dev);
263 static int ixgbevf_dev_configure(struct rte_eth_dev *dev);
264 static int ixgbevf_dev_start(struct rte_eth_dev *dev);
265 static int ixgbevf_dev_link_update(struct rte_eth_dev *dev,
266 int wait_to_complete);
267 static void ixgbevf_dev_stop(struct rte_eth_dev *dev);
268 static void ixgbevf_dev_close(struct rte_eth_dev *dev);
269 static void ixgbevf_intr_disable(struct ixgbe_hw *hw);
270 static void ixgbevf_intr_enable(struct ixgbe_hw *hw);
271 static void ixgbevf_dev_stats_get(struct rte_eth_dev *dev,
272 struct rte_eth_stats *stats);
273 static void ixgbevf_dev_stats_reset(struct rte_eth_dev *dev);
274 static int ixgbevf_vlan_filter_set(struct rte_eth_dev *dev,
275 uint16_t vlan_id, int on);
276 static void ixgbevf_vlan_strip_queue_set(struct rte_eth_dev *dev,
277 uint16_t queue, int on);
278 static void ixgbevf_vlan_offload_set(struct rte_eth_dev *dev, int mask);
279 static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on);
280 static int ixgbevf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev,
282 static int ixgbevf_dev_rx_queue_intr_disable(struct rte_eth_dev *dev,
284 static void ixgbevf_set_ivar_map(struct ixgbe_hw *hw, int8_t direction,
285 uint8_t queue, uint8_t msix_vector);
286 static void ixgbevf_configure_msix(struct rte_eth_dev *dev);
287 static void ixgbevf_dev_allmulticast_enable(struct rte_eth_dev *dev);
288 static void ixgbevf_dev_allmulticast_disable(struct rte_eth_dev *dev);
290 /* For Eth VMDQ APIs support */
291 static int ixgbe_uc_hash_table_set(struct rte_eth_dev *dev, struct
292 ether_addr * mac_addr, uint8_t on);
293 static int ixgbe_uc_all_hash_table_set(struct rte_eth_dev *dev, uint8_t on);
294 static int ixgbe_mirror_rule_set(struct rte_eth_dev *dev,
295 struct rte_eth_mirror_conf *mirror_conf,
296 uint8_t rule_id, uint8_t on);
297 static int ixgbe_mirror_rule_reset(struct rte_eth_dev *dev,
299 static int ixgbe_dev_rx_queue_intr_enable(struct rte_eth_dev *dev,
301 static int ixgbe_dev_rx_queue_intr_disable(struct rte_eth_dev *dev,
303 static void ixgbe_set_ivar_map(struct ixgbe_hw *hw, int8_t direction,
304 uint8_t queue, uint8_t msix_vector);
305 static void ixgbe_configure_msix(struct rte_eth_dev *dev);
307 static int ixgbevf_add_mac_addr(struct rte_eth_dev *dev,
308 struct ether_addr *mac_addr,
309 uint32_t index, uint32_t pool);
310 static void ixgbevf_remove_mac_addr(struct rte_eth_dev *dev, uint32_t index);
311 static void ixgbevf_set_default_mac_addr(struct rte_eth_dev *dev,
312 struct ether_addr *mac_addr);
313 static int ixgbe_syn_filter_get(struct rte_eth_dev *dev,
314 struct rte_eth_syn_filter *filter);
315 static int ixgbe_syn_filter_handle(struct rte_eth_dev *dev,
316 enum rte_filter_op filter_op,
318 static int ixgbe_add_5tuple_filter(struct rte_eth_dev *dev,
319 struct ixgbe_5tuple_filter *filter);
320 static void ixgbe_remove_5tuple_filter(struct rte_eth_dev *dev,
321 struct ixgbe_5tuple_filter *filter);
322 static int ixgbe_ntuple_filter_handle(struct rte_eth_dev *dev,
323 enum rte_filter_op filter_op,
325 static int ixgbe_get_ntuple_filter(struct rte_eth_dev *dev,
326 struct rte_eth_ntuple_filter *filter);
327 static int ixgbe_ethertype_filter_handle(struct rte_eth_dev *dev,
328 enum rte_filter_op filter_op,
330 static int ixgbe_get_ethertype_filter(struct rte_eth_dev *dev,
331 struct rte_eth_ethertype_filter *filter);
332 static int ixgbe_dev_filter_ctrl(struct rte_eth_dev *dev,
333 enum rte_filter_type filter_type,
334 enum rte_filter_op filter_op,
336 static int ixgbevf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu);
338 static int ixgbe_dev_set_mc_addr_list(struct rte_eth_dev *dev,
339 struct ether_addr *mc_addr_set,
340 uint32_t nb_mc_addr);
341 static int ixgbe_dev_get_dcb_info(struct rte_eth_dev *dev,
342 struct rte_eth_dcb_info *dcb_info);
344 static int ixgbe_get_reg_length(struct rte_eth_dev *dev);
345 static int ixgbe_get_regs(struct rte_eth_dev *dev,
346 struct rte_dev_reg_info *regs);
347 static int ixgbe_get_eeprom_length(struct rte_eth_dev *dev);
348 static int ixgbe_get_eeprom(struct rte_eth_dev *dev,
349 struct rte_dev_eeprom_info *eeprom);
350 static int ixgbe_set_eeprom(struct rte_eth_dev *dev,
351 struct rte_dev_eeprom_info *eeprom);
353 static int ixgbevf_get_reg_length(struct rte_eth_dev *dev);
354 static int ixgbevf_get_regs(struct rte_eth_dev *dev,
355 struct rte_dev_reg_info *regs);
357 static int ixgbe_timesync_enable(struct rte_eth_dev *dev);
358 static int ixgbe_timesync_disable(struct rte_eth_dev *dev);
359 static int ixgbe_timesync_read_rx_timestamp(struct rte_eth_dev *dev,
360 struct timespec *timestamp,
362 static int ixgbe_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
363 struct timespec *timestamp);
364 static int ixgbe_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta);
365 static int ixgbe_timesync_read_time(struct rte_eth_dev *dev,
366 struct timespec *timestamp);
367 static int ixgbe_timesync_write_time(struct rte_eth_dev *dev,
368 const struct timespec *timestamp);
369 static void ixgbevf_dev_interrupt_handler(void *param);
371 static int ixgbe_dev_l2_tunnel_eth_type_conf
372 (struct rte_eth_dev *dev, struct rte_eth_l2_tunnel_conf *l2_tunnel);
373 static int ixgbe_dev_l2_tunnel_offload_set
374 (struct rte_eth_dev *dev,
375 struct rte_eth_l2_tunnel_conf *l2_tunnel,
378 static int ixgbe_dev_l2_tunnel_filter_handle(struct rte_eth_dev *dev,
379 enum rte_filter_op filter_op,
382 static int ixgbe_dev_udp_tunnel_port_add(struct rte_eth_dev *dev,
383 struct rte_eth_udp_tunnel *udp_tunnel);
384 static int ixgbe_dev_udp_tunnel_port_del(struct rte_eth_dev *dev,
385 struct rte_eth_udp_tunnel *udp_tunnel);
386 static int ixgbe_filter_restore(struct rte_eth_dev *dev);
387 static void ixgbe_l2_tunnel_conf(struct rte_eth_dev *dev);
390 * Define VF Stats MACRO for Non "cleared on read" register
392 #define UPDATE_VF_STAT(reg, last, cur) \
394 uint32_t latest = IXGBE_READ_REG(hw, reg); \
395 cur += (latest - last) & UINT_MAX; \
399 #define UPDATE_VF_STAT_36BIT(lsb, msb, last, cur) \
401 u64 new_lsb = IXGBE_READ_REG(hw, lsb); \
402 u64 new_msb = IXGBE_READ_REG(hw, msb); \
403 u64 latest = ((new_msb << 32) | new_lsb); \
404 cur += (0x1000000000LL + latest - last) & 0xFFFFFFFFFLL; \
408 #define IXGBE_SET_HWSTRIP(h, q) do {\
409 uint32_t idx = (q) / (sizeof((h)->bitmap[0]) * NBBY); \
410 uint32_t bit = (q) % (sizeof((h)->bitmap[0]) * NBBY); \
411 (h)->bitmap[idx] |= 1 << bit;\
414 #define IXGBE_CLEAR_HWSTRIP(h, q) do {\
415 uint32_t idx = (q) / (sizeof((h)->bitmap[0]) * NBBY); \
416 uint32_t bit = (q) % (sizeof((h)->bitmap[0]) * NBBY); \
417 (h)->bitmap[idx] &= ~(1 << bit);\
420 #define IXGBE_GET_HWSTRIP(h, q, r) do {\
421 uint32_t idx = (q) / (sizeof((h)->bitmap[0]) * NBBY); \
422 uint32_t bit = (q) % (sizeof((h)->bitmap[0]) * NBBY); \
423 (r) = (h)->bitmap[idx] >> bit & 1;\
427 * The set of PCI devices this driver supports
429 static const struct rte_pci_id pci_id_ixgbe_map[] = {
430 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598) },
431 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598_BX) },
432 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AF_DUAL_PORT) },
433 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AF_SINGLE_PORT) },
434 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AT) },
435 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AT2) },
436 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598EB_SFP_LOM) },
437 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598EB_CX4) },
438 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598_CX4_DUAL_PORT) },
439 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598_DA_DUAL_PORT) },
440 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM) },
441 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598EB_XF_LR) },
442 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_KX4) },
443 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_KX4_MEZZ) },
444 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_KR) },
445 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_COMBO_BACKPLANE) },
446 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_SUBDEV_ID_82599_KX4_KR_MEZZ) },
447 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_CX4) },
448 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP) },
449 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_SUBDEV_ID_82599_SFP) },
450 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_SUBDEV_ID_82599_RNDC) },
451 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_SUBDEV_ID_82599_560FLR) },
452 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_SUBDEV_ID_82599_ECNA_DP) },
453 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_BACKPLANE_FCOE) },
454 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP_FCOE) },
455 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP_EM) },
456 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP_SF2) },
457 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP_SF_QP) },
458 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_QSFP_SF_QP) },
459 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599EN_SFP) },
460 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_XAUI_LOM) },
461 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_T3_LOM) },
462 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_LS) },
463 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X540T) },
464 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X540T1) },
465 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_SFP) },
466 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_10G_T) },
467 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_1G_T) },
468 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550T) },
469 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550T1) },
470 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_KR) },
471 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_KR_L) },
472 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_SFP_N) },
473 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_SGMII) },
474 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_SGMII_L) },
475 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_10G_T) },
476 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_QSFP) },
477 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_QSFP_N) },
478 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_SFP) },
479 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_1G_T) },
480 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_1G_T_L) },
481 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_KX4) },
482 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_KR) },
483 #ifdef RTE_LIBRTE_IXGBE_BYPASS
484 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_BYPASS) },
486 { .vendor_id = 0, /* sentinel */ },
490 * The set of PCI devices this driver supports (for 82599 VF)
492 static const struct rte_pci_id pci_id_ixgbevf_map[] = {
493 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_VF) },
494 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_VF_HV) },
495 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X540_VF) },
496 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X540_VF_HV) },
497 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550_VF_HV) },
498 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550_VF) },
499 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_VF) },
500 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_VF_HV) },
501 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_VF) },
502 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_VF_HV) },
503 { .vendor_id = 0, /* sentinel */ },
506 static const struct rte_eth_desc_lim rx_desc_lim = {
507 .nb_max = IXGBE_MAX_RING_DESC,
508 .nb_min = IXGBE_MIN_RING_DESC,
509 .nb_align = IXGBE_RXD_ALIGN,
512 static const struct rte_eth_desc_lim tx_desc_lim = {
513 .nb_max = IXGBE_MAX_RING_DESC,
514 .nb_min = IXGBE_MIN_RING_DESC,
515 .nb_align = IXGBE_TXD_ALIGN,
516 .nb_seg_max = IXGBE_TX_MAX_SEG,
517 .nb_mtu_seg_max = IXGBE_TX_MAX_SEG,
520 static const struct eth_dev_ops ixgbe_eth_dev_ops = {
521 .dev_configure = ixgbe_dev_configure,
522 .dev_start = ixgbe_dev_start,
523 .dev_stop = ixgbe_dev_stop,
524 .dev_set_link_up = ixgbe_dev_set_link_up,
525 .dev_set_link_down = ixgbe_dev_set_link_down,
526 .dev_close = ixgbe_dev_close,
527 .promiscuous_enable = ixgbe_dev_promiscuous_enable,
528 .promiscuous_disable = ixgbe_dev_promiscuous_disable,
529 .allmulticast_enable = ixgbe_dev_allmulticast_enable,
530 .allmulticast_disable = ixgbe_dev_allmulticast_disable,
531 .link_update = ixgbe_dev_link_update,
532 .stats_get = ixgbe_dev_stats_get,
533 .xstats_get = ixgbe_dev_xstats_get,
534 .xstats_get_by_id = ixgbe_dev_xstats_get_by_id,
535 .stats_reset = ixgbe_dev_stats_reset,
536 .xstats_reset = ixgbe_dev_xstats_reset,
537 .xstats_get_names = ixgbe_dev_xstats_get_names,
538 .xstats_get_names_by_id = ixgbe_dev_xstats_get_names_by_id,
539 .queue_stats_mapping_set = ixgbe_dev_queue_stats_mapping_set,
540 .fw_version_get = ixgbe_fw_version_get,
541 .dev_infos_get = ixgbe_dev_info_get,
542 .dev_supported_ptypes_get = ixgbe_dev_supported_ptypes_get,
543 .mtu_set = ixgbe_dev_mtu_set,
544 .vlan_filter_set = ixgbe_vlan_filter_set,
545 .vlan_tpid_set = ixgbe_vlan_tpid_set,
546 .vlan_offload_set = ixgbe_vlan_offload_set,
547 .vlan_strip_queue_set = ixgbe_vlan_strip_queue_set,
548 .rx_queue_start = ixgbe_dev_rx_queue_start,
549 .rx_queue_stop = ixgbe_dev_rx_queue_stop,
550 .tx_queue_start = ixgbe_dev_tx_queue_start,
551 .tx_queue_stop = ixgbe_dev_tx_queue_stop,
552 .rx_queue_setup = ixgbe_dev_rx_queue_setup,
553 .rx_queue_intr_enable = ixgbe_dev_rx_queue_intr_enable,
554 .rx_queue_intr_disable = ixgbe_dev_rx_queue_intr_disable,
555 .rx_queue_release = ixgbe_dev_rx_queue_release,
556 .rx_queue_count = ixgbe_dev_rx_queue_count,
557 .rx_descriptor_done = ixgbe_dev_rx_descriptor_done,
558 .rx_descriptor_status = ixgbe_dev_rx_descriptor_status,
559 .tx_descriptor_status = ixgbe_dev_tx_descriptor_status,
560 .tx_queue_setup = ixgbe_dev_tx_queue_setup,
561 .tx_queue_release = ixgbe_dev_tx_queue_release,
562 .dev_led_on = ixgbe_dev_led_on,
563 .dev_led_off = ixgbe_dev_led_off,
564 .flow_ctrl_get = ixgbe_flow_ctrl_get,
565 .flow_ctrl_set = ixgbe_flow_ctrl_set,
566 .priority_flow_ctrl_set = ixgbe_priority_flow_ctrl_set,
567 .mac_addr_add = ixgbe_add_rar,
568 .mac_addr_remove = ixgbe_remove_rar,
569 .mac_addr_set = ixgbe_set_default_mac_addr,
570 .uc_hash_table_set = ixgbe_uc_hash_table_set,
571 .uc_all_hash_table_set = ixgbe_uc_all_hash_table_set,
572 .mirror_rule_set = ixgbe_mirror_rule_set,
573 .mirror_rule_reset = ixgbe_mirror_rule_reset,
574 .set_queue_rate_limit = ixgbe_set_queue_rate_limit,
575 .reta_update = ixgbe_dev_rss_reta_update,
576 .reta_query = ixgbe_dev_rss_reta_query,
577 .rss_hash_update = ixgbe_dev_rss_hash_update,
578 .rss_hash_conf_get = ixgbe_dev_rss_hash_conf_get,
579 .filter_ctrl = ixgbe_dev_filter_ctrl,
580 .set_mc_addr_list = ixgbe_dev_set_mc_addr_list,
581 .rxq_info_get = ixgbe_rxq_info_get,
582 .txq_info_get = ixgbe_txq_info_get,
583 .timesync_enable = ixgbe_timesync_enable,
584 .timesync_disable = ixgbe_timesync_disable,
585 .timesync_read_rx_timestamp = ixgbe_timesync_read_rx_timestamp,
586 .timesync_read_tx_timestamp = ixgbe_timesync_read_tx_timestamp,
587 .get_reg = ixgbe_get_regs,
588 .get_eeprom_length = ixgbe_get_eeprom_length,
589 .get_eeprom = ixgbe_get_eeprom,
590 .set_eeprom = ixgbe_set_eeprom,
591 .get_dcb_info = ixgbe_dev_get_dcb_info,
592 .timesync_adjust_time = ixgbe_timesync_adjust_time,
593 .timesync_read_time = ixgbe_timesync_read_time,
594 .timesync_write_time = ixgbe_timesync_write_time,
595 .l2_tunnel_eth_type_conf = ixgbe_dev_l2_tunnel_eth_type_conf,
596 .l2_tunnel_offload_set = ixgbe_dev_l2_tunnel_offload_set,
597 .udp_tunnel_port_add = ixgbe_dev_udp_tunnel_port_add,
598 .udp_tunnel_port_del = ixgbe_dev_udp_tunnel_port_del,
599 .tm_ops_get = ixgbe_tm_ops_get,
603 * dev_ops for virtual function, bare necessities for basic vf
604 * operation have been implemented
606 static const struct eth_dev_ops ixgbevf_eth_dev_ops = {
607 .dev_configure = ixgbevf_dev_configure,
608 .dev_start = ixgbevf_dev_start,
609 .dev_stop = ixgbevf_dev_stop,
610 .link_update = ixgbevf_dev_link_update,
611 .stats_get = ixgbevf_dev_stats_get,
612 .xstats_get = ixgbevf_dev_xstats_get,
613 .stats_reset = ixgbevf_dev_stats_reset,
614 .xstats_reset = ixgbevf_dev_stats_reset,
615 .xstats_get_names = ixgbevf_dev_xstats_get_names,
616 .dev_close = ixgbevf_dev_close,
617 .allmulticast_enable = ixgbevf_dev_allmulticast_enable,
618 .allmulticast_disable = ixgbevf_dev_allmulticast_disable,
619 .dev_infos_get = ixgbevf_dev_info_get,
620 .dev_supported_ptypes_get = ixgbe_dev_supported_ptypes_get,
621 .mtu_set = ixgbevf_dev_set_mtu,
622 .vlan_filter_set = ixgbevf_vlan_filter_set,
623 .vlan_strip_queue_set = ixgbevf_vlan_strip_queue_set,
624 .vlan_offload_set = ixgbevf_vlan_offload_set,
625 .rx_queue_setup = ixgbe_dev_rx_queue_setup,
626 .rx_queue_release = ixgbe_dev_rx_queue_release,
627 .rx_descriptor_done = ixgbe_dev_rx_descriptor_done,
628 .rx_descriptor_status = ixgbe_dev_rx_descriptor_status,
629 .tx_descriptor_status = ixgbe_dev_tx_descriptor_status,
630 .tx_queue_setup = ixgbe_dev_tx_queue_setup,
631 .tx_queue_release = ixgbe_dev_tx_queue_release,
632 .rx_queue_intr_enable = ixgbevf_dev_rx_queue_intr_enable,
633 .rx_queue_intr_disable = ixgbevf_dev_rx_queue_intr_disable,
634 .mac_addr_add = ixgbevf_add_mac_addr,
635 .mac_addr_remove = ixgbevf_remove_mac_addr,
636 .set_mc_addr_list = ixgbe_dev_set_mc_addr_list,
637 .rxq_info_get = ixgbe_rxq_info_get,
638 .txq_info_get = ixgbe_txq_info_get,
639 .mac_addr_set = ixgbevf_set_default_mac_addr,
640 .get_reg = ixgbevf_get_regs,
641 .reta_update = ixgbe_dev_rss_reta_update,
642 .reta_query = ixgbe_dev_rss_reta_query,
643 .rss_hash_update = ixgbe_dev_rss_hash_update,
644 .rss_hash_conf_get = ixgbe_dev_rss_hash_conf_get,
647 /* store statistics names and its offset in stats structure */
648 struct rte_ixgbe_xstats_name_off {
649 char name[RTE_ETH_XSTATS_NAME_SIZE];
653 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_stats_strings[] = {
654 {"rx_crc_errors", offsetof(struct ixgbe_hw_stats, crcerrs)},
655 {"rx_illegal_byte_errors", offsetof(struct ixgbe_hw_stats, illerrc)},
656 {"rx_error_bytes", offsetof(struct ixgbe_hw_stats, errbc)},
657 {"mac_local_errors", offsetof(struct ixgbe_hw_stats, mlfc)},
658 {"mac_remote_errors", offsetof(struct ixgbe_hw_stats, mrfc)},
659 {"rx_length_errors", offsetof(struct ixgbe_hw_stats, rlec)},
660 {"tx_xon_packets", offsetof(struct ixgbe_hw_stats, lxontxc)},
661 {"rx_xon_packets", offsetof(struct ixgbe_hw_stats, lxonrxc)},
662 {"tx_xoff_packets", offsetof(struct ixgbe_hw_stats, lxofftxc)},
663 {"rx_xoff_packets", offsetof(struct ixgbe_hw_stats, lxoffrxc)},
664 {"rx_size_64_packets", offsetof(struct ixgbe_hw_stats, prc64)},
665 {"rx_size_65_to_127_packets", offsetof(struct ixgbe_hw_stats, prc127)},
666 {"rx_size_128_to_255_packets", offsetof(struct ixgbe_hw_stats, prc255)},
667 {"rx_size_256_to_511_packets", offsetof(struct ixgbe_hw_stats, prc511)},
668 {"rx_size_512_to_1023_packets", offsetof(struct ixgbe_hw_stats,
670 {"rx_size_1024_to_max_packets", offsetof(struct ixgbe_hw_stats,
672 {"rx_broadcast_packets", offsetof(struct ixgbe_hw_stats, bprc)},
673 {"rx_multicast_packets", offsetof(struct ixgbe_hw_stats, mprc)},
674 {"rx_fragment_errors", offsetof(struct ixgbe_hw_stats, rfc)},
675 {"rx_undersize_errors", offsetof(struct ixgbe_hw_stats, ruc)},
676 {"rx_oversize_errors", offsetof(struct ixgbe_hw_stats, roc)},
677 {"rx_jabber_errors", offsetof(struct ixgbe_hw_stats, rjc)},
678 {"rx_management_packets", offsetof(struct ixgbe_hw_stats, mngprc)},
679 {"rx_management_dropped", offsetof(struct ixgbe_hw_stats, mngpdc)},
680 {"tx_management_packets", offsetof(struct ixgbe_hw_stats, mngptc)},
681 {"rx_total_packets", offsetof(struct ixgbe_hw_stats, tpr)},
682 {"rx_total_bytes", offsetof(struct ixgbe_hw_stats, tor)},
683 {"tx_total_packets", offsetof(struct ixgbe_hw_stats, tpt)},
684 {"tx_size_64_packets", offsetof(struct ixgbe_hw_stats, ptc64)},
685 {"tx_size_65_to_127_packets", offsetof(struct ixgbe_hw_stats, ptc127)},
686 {"tx_size_128_to_255_packets", offsetof(struct ixgbe_hw_stats, ptc255)},
687 {"tx_size_256_to_511_packets", offsetof(struct ixgbe_hw_stats, ptc511)},
688 {"tx_size_512_to_1023_packets", offsetof(struct ixgbe_hw_stats,
690 {"tx_size_1024_to_max_packets", offsetof(struct ixgbe_hw_stats,
692 {"tx_multicast_packets", offsetof(struct ixgbe_hw_stats, mptc)},
693 {"tx_broadcast_packets", offsetof(struct ixgbe_hw_stats, bptc)},
694 {"rx_mac_short_packet_dropped", offsetof(struct ixgbe_hw_stats, mspdc)},
695 {"rx_l3_l4_xsum_error", offsetof(struct ixgbe_hw_stats, xec)},
697 {"flow_director_added_filters", offsetof(struct ixgbe_hw_stats,
699 {"flow_director_removed_filters", offsetof(struct ixgbe_hw_stats,
701 {"flow_director_filter_add_errors", offsetof(struct ixgbe_hw_stats,
703 {"flow_director_filter_remove_errors", offsetof(struct ixgbe_hw_stats,
705 {"flow_director_matched_filters", offsetof(struct ixgbe_hw_stats,
707 {"flow_director_missed_filters", offsetof(struct ixgbe_hw_stats,
710 {"rx_fcoe_crc_errors", offsetof(struct ixgbe_hw_stats, fccrc)},
711 {"rx_fcoe_dropped", offsetof(struct ixgbe_hw_stats, fcoerpdc)},
712 {"rx_fcoe_mbuf_allocation_errors", offsetof(struct ixgbe_hw_stats,
714 {"rx_fcoe_packets", offsetof(struct ixgbe_hw_stats, fcoeprc)},
715 {"tx_fcoe_packets", offsetof(struct ixgbe_hw_stats, fcoeptc)},
716 {"rx_fcoe_bytes", offsetof(struct ixgbe_hw_stats, fcoedwrc)},
717 {"tx_fcoe_bytes", offsetof(struct ixgbe_hw_stats, fcoedwtc)},
718 {"rx_fcoe_no_direct_data_placement", offsetof(struct ixgbe_hw_stats,
720 {"rx_fcoe_no_direct_data_placement_ext_buff",
721 offsetof(struct ixgbe_hw_stats, fcoe_noddp_ext_buff)},
723 {"tx_flow_control_xon_packets", offsetof(struct ixgbe_hw_stats,
725 {"rx_flow_control_xon_packets", offsetof(struct ixgbe_hw_stats,
727 {"tx_flow_control_xoff_packets", offsetof(struct ixgbe_hw_stats,
729 {"rx_flow_control_xoff_packets", offsetof(struct ixgbe_hw_stats,
731 {"rx_total_missed_packets", offsetof(struct ixgbe_hw_stats, mpctotal)},
734 #define IXGBE_NB_HW_STATS (sizeof(rte_ixgbe_stats_strings) / \
735 sizeof(rte_ixgbe_stats_strings[0]))
737 /* MACsec statistics */
738 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_macsec_strings[] = {
739 {"out_pkts_untagged", offsetof(struct ixgbe_macsec_stats,
741 {"out_pkts_encrypted", offsetof(struct ixgbe_macsec_stats,
742 out_pkts_encrypted)},
743 {"out_pkts_protected", offsetof(struct ixgbe_macsec_stats,
744 out_pkts_protected)},
745 {"out_octets_encrypted", offsetof(struct ixgbe_macsec_stats,
746 out_octets_encrypted)},
747 {"out_octets_protected", offsetof(struct ixgbe_macsec_stats,
748 out_octets_protected)},
749 {"in_pkts_untagged", offsetof(struct ixgbe_macsec_stats,
751 {"in_pkts_badtag", offsetof(struct ixgbe_macsec_stats,
753 {"in_pkts_nosci", offsetof(struct ixgbe_macsec_stats,
755 {"in_pkts_unknownsci", offsetof(struct ixgbe_macsec_stats,
756 in_pkts_unknownsci)},
757 {"in_octets_decrypted", offsetof(struct ixgbe_macsec_stats,
758 in_octets_decrypted)},
759 {"in_octets_validated", offsetof(struct ixgbe_macsec_stats,
760 in_octets_validated)},
761 {"in_pkts_unchecked", offsetof(struct ixgbe_macsec_stats,
763 {"in_pkts_delayed", offsetof(struct ixgbe_macsec_stats,
765 {"in_pkts_late", offsetof(struct ixgbe_macsec_stats,
767 {"in_pkts_ok", offsetof(struct ixgbe_macsec_stats,
769 {"in_pkts_invalid", offsetof(struct ixgbe_macsec_stats,
771 {"in_pkts_notvalid", offsetof(struct ixgbe_macsec_stats,
773 {"in_pkts_unusedsa", offsetof(struct ixgbe_macsec_stats,
775 {"in_pkts_notusingsa", offsetof(struct ixgbe_macsec_stats,
776 in_pkts_notusingsa)},
779 #define IXGBE_NB_MACSEC_STATS (sizeof(rte_ixgbe_macsec_strings) / \
780 sizeof(rte_ixgbe_macsec_strings[0]))
782 /* Per-queue statistics */
783 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_rxq_strings[] = {
784 {"mbuf_allocation_errors", offsetof(struct ixgbe_hw_stats, rnbc)},
785 {"dropped", offsetof(struct ixgbe_hw_stats, mpc)},
786 {"xon_packets", offsetof(struct ixgbe_hw_stats, pxonrxc)},
787 {"xoff_packets", offsetof(struct ixgbe_hw_stats, pxoffrxc)},
790 #define IXGBE_NB_RXQ_PRIO_STATS (sizeof(rte_ixgbe_rxq_strings) / \
791 sizeof(rte_ixgbe_rxq_strings[0]))
792 #define IXGBE_NB_RXQ_PRIO_VALUES 8
794 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_txq_strings[] = {
795 {"xon_packets", offsetof(struct ixgbe_hw_stats, pxontxc)},
796 {"xoff_packets", offsetof(struct ixgbe_hw_stats, pxofftxc)},
797 {"xon_to_xoff_packets", offsetof(struct ixgbe_hw_stats,
801 #define IXGBE_NB_TXQ_PRIO_STATS (sizeof(rte_ixgbe_txq_strings) / \
802 sizeof(rte_ixgbe_txq_strings[0]))
803 #define IXGBE_NB_TXQ_PRIO_VALUES 8
805 static const struct rte_ixgbe_xstats_name_off rte_ixgbevf_stats_strings[] = {
806 {"rx_multicast_packets", offsetof(struct ixgbevf_hw_stats, vfmprc)},
809 #define IXGBEVF_NB_XSTATS (sizeof(rte_ixgbevf_stats_strings) / \
810 sizeof(rte_ixgbevf_stats_strings[0]))
813 * Atomically reads the link status information from global
814 * structure rte_eth_dev.
817 * - Pointer to the structure rte_eth_dev to read from.
818 * - Pointer to the buffer to be saved with the link status.
821 * - On success, zero.
822 * - On failure, negative value.
825 rte_ixgbe_dev_atomic_read_link_status(struct rte_eth_dev *dev,
826 struct rte_eth_link *link)
828 struct rte_eth_link *dst = link;
829 struct rte_eth_link *src = &(dev->data->dev_link);
831 if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
832 *(uint64_t *)src) == 0)
839 * Atomically writes the link status information into global
840 * structure rte_eth_dev.
843 * - Pointer to the structure rte_eth_dev to read from.
844 * - Pointer to the buffer to be saved with the link status.
847 * - On success, zero.
848 * - On failure, negative value.
851 rte_ixgbe_dev_atomic_write_link_status(struct rte_eth_dev *dev,
852 struct rte_eth_link *link)
854 struct rte_eth_link *dst = &(dev->data->dev_link);
855 struct rte_eth_link *src = link;
857 if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
858 *(uint64_t *)src) == 0)
865 * This function is the same as ixgbe_is_sfp() in base/ixgbe.h.
868 ixgbe_is_sfp(struct ixgbe_hw *hw)
870 switch (hw->phy.type) {
871 case ixgbe_phy_sfp_avago:
872 case ixgbe_phy_sfp_ftl:
873 case ixgbe_phy_sfp_intel:
874 case ixgbe_phy_sfp_unknown:
875 case ixgbe_phy_sfp_passive_tyco:
876 case ixgbe_phy_sfp_passive_unknown:
883 static inline int32_t
884 ixgbe_pf_reset_hw(struct ixgbe_hw *hw)
889 status = ixgbe_reset_hw(hw);
891 ctrl_ext = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
892 /* Set PF Reset Done bit so PF/VF Mail Ops can work */
893 ctrl_ext |= IXGBE_CTRL_EXT_PFRSTD;
894 IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl_ext);
895 IXGBE_WRITE_FLUSH(hw);
897 if (status == IXGBE_ERR_SFP_NOT_PRESENT)
898 status = IXGBE_SUCCESS;
903 ixgbe_enable_intr(struct rte_eth_dev *dev)
905 struct ixgbe_interrupt *intr =
906 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
907 struct ixgbe_hw *hw =
908 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
910 IXGBE_WRITE_REG(hw, IXGBE_EIMS, intr->mask);
911 IXGBE_WRITE_FLUSH(hw);
915 * This function is based on ixgbe_disable_intr() in base/ixgbe.h.
918 ixgbe_disable_intr(struct ixgbe_hw *hw)
920 PMD_INIT_FUNC_TRACE();
922 if (hw->mac.type == ixgbe_mac_82598EB) {
923 IXGBE_WRITE_REG(hw, IXGBE_EIMC, ~0);
925 IXGBE_WRITE_REG(hw, IXGBE_EIMC, 0xFFFF0000);
926 IXGBE_WRITE_REG(hw, IXGBE_EIMC_EX(0), ~0);
927 IXGBE_WRITE_REG(hw, IXGBE_EIMC_EX(1), ~0);
929 IXGBE_WRITE_FLUSH(hw);
933 * This function resets queue statistics mapping registers.
934 * From Niantic datasheet, Initialization of Statistics section:
935 * "...if software requires the queue counters, the RQSMR and TQSM registers
936 * must be re-programmed following a device reset.
939 ixgbe_reset_qstat_mappings(struct ixgbe_hw *hw)
943 for (i = 0; i != IXGBE_NB_STAT_MAPPING_REGS; i++) {
944 IXGBE_WRITE_REG(hw, IXGBE_RQSMR(i), 0);
945 IXGBE_WRITE_REG(hw, IXGBE_TQSM(i), 0);
951 ixgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
956 #define QSM_REG_NB_BITS_PER_QMAP_FIELD 8
957 #define NB_QMAP_FIELDS_PER_QSM_REG 4
958 #define QMAP_FIELD_RESERVED_BITS_MASK 0x0f
960 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
961 struct ixgbe_stat_mapping_registers *stat_mappings =
962 IXGBE_DEV_PRIVATE_TO_STAT_MAPPINGS(eth_dev->data->dev_private);
963 uint32_t qsmr_mask = 0;
964 uint32_t clearing_mask = QMAP_FIELD_RESERVED_BITS_MASK;
968 if ((hw->mac.type != ixgbe_mac_82599EB) &&
969 (hw->mac.type != ixgbe_mac_X540) &&
970 (hw->mac.type != ixgbe_mac_X550) &&
971 (hw->mac.type != ixgbe_mac_X550EM_x) &&
972 (hw->mac.type != ixgbe_mac_X550EM_a))
975 PMD_INIT_LOG(DEBUG, "Setting port %d, %s queue_id %d to stat index %d",
976 (int)(eth_dev->data->port_id), is_rx ? "RX" : "TX",
979 n = (uint8_t)(queue_id / NB_QMAP_FIELDS_PER_QSM_REG);
980 if (n >= IXGBE_NB_STAT_MAPPING_REGS) {
981 PMD_INIT_LOG(ERR, "Nb of stat mapping registers exceeded");
984 offset = (uint8_t)(queue_id % NB_QMAP_FIELDS_PER_QSM_REG);
986 /* Now clear any previous stat_idx set */
987 clearing_mask <<= (QSM_REG_NB_BITS_PER_QMAP_FIELD * offset);
989 stat_mappings->tqsm[n] &= ~clearing_mask;
991 stat_mappings->rqsmr[n] &= ~clearing_mask;
993 q_map = (uint32_t)stat_idx;
994 q_map &= QMAP_FIELD_RESERVED_BITS_MASK;
995 qsmr_mask = q_map << (QSM_REG_NB_BITS_PER_QMAP_FIELD * offset);
997 stat_mappings->tqsm[n] |= qsmr_mask;
999 stat_mappings->rqsmr[n] |= qsmr_mask;
1001 PMD_INIT_LOG(DEBUG, "Set port %d, %s queue_id %d to stat index %d",
1002 (int)(eth_dev->data->port_id), is_rx ? "RX" : "TX",
1003 queue_id, stat_idx);
1004 PMD_INIT_LOG(DEBUG, "%s[%d] = 0x%08x", is_rx ? "RQSMR" : "TQSM", n,
1005 is_rx ? stat_mappings->rqsmr[n] : stat_mappings->tqsm[n]);
1007 /* Now write the mapping in the appropriate register */
1009 PMD_INIT_LOG(DEBUG, "Write 0x%x to RX IXGBE stat mapping reg:%d",
1010 stat_mappings->rqsmr[n], n);
1011 IXGBE_WRITE_REG(hw, IXGBE_RQSMR(n), stat_mappings->rqsmr[n]);
1013 PMD_INIT_LOG(DEBUG, "Write 0x%x to TX IXGBE stat mapping reg:%d",
1014 stat_mappings->tqsm[n], n);
1015 IXGBE_WRITE_REG(hw, IXGBE_TQSM(n), stat_mappings->tqsm[n]);
1021 ixgbe_restore_statistics_mapping(struct rte_eth_dev *dev)
1023 struct ixgbe_stat_mapping_registers *stat_mappings =
1024 IXGBE_DEV_PRIVATE_TO_STAT_MAPPINGS(dev->data->dev_private);
1025 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1028 /* write whatever was in stat mapping table to the NIC */
1029 for (i = 0; i < IXGBE_NB_STAT_MAPPING_REGS; i++) {
1031 IXGBE_WRITE_REG(hw, IXGBE_RQSMR(i), stat_mappings->rqsmr[i]);
1034 IXGBE_WRITE_REG(hw, IXGBE_TQSM(i), stat_mappings->tqsm[i]);
1039 ixgbe_dcb_init(struct ixgbe_hw *hw, struct ixgbe_dcb_config *dcb_config)
1042 struct ixgbe_dcb_tc_config *tc;
1043 uint8_t dcb_max_tc = IXGBE_DCB_MAX_TRAFFIC_CLASS;
1045 dcb_config->num_tcs.pg_tcs = dcb_max_tc;
1046 dcb_config->num_tcs.pfc_tcs = dcb_max_tc;
1047 for (i = 0; i < dcb_max_tc; i++) {
1048 tc = &dcb_config->tc_config[i];
1049 tc->path[IXGBE_DCB_TX_CONFIG].bwg_id = i;
1050 tc->path[IXGBE_DCB_TX_CONFIG].bwg_percent =
1051 (uint8_t)(100/dcb_max_tc + (i & 1));
1052 tc->path[IXGBE_DCB_RX_CONFIG].bwg_id = i;
1053 tc->path[IXGBE_DCB_RX_CONFIG].bwg_percent =
1054 (uint8_t)(100/dcb_max_tc + (i & 1));
1055 tc->pfc = ixgbe_dcb_pfc_disabled;
1058 /* Initialize default user to priority mapping, UPx->TC0 */
1059 tc = &dcb_config->tc_config[0];
1060 tc->path[IXGBE_DCB_TX_CONFIG].up_to_tc_bitmap = 0xFF;
1061 tc->path[IXGBE_DCB_RX_CONFIG].up_to_tc_bitmap = 0xFF;
1062 for (i = 0; i < IXGBE_DCB_MAX_BW_GROUP; i++) {
1063 dcb_config->bw_percentage[IXGBE_DCB_TX_CONFIG][i] = 100;
1064 dcb_config->bw_percentage[IXGBE_DCB_RX_CONFIG][i] = 100;
1066 dcb_config->rx_pba_cfg = ixgbe_dcb_pba_equal;
1067 dcb_config->pfc_mode_enable = false;
1068 dcb_config->vt_mode = true;
1069 dcb_config->round_robin_enable = false;
1070 /* support all DCB capabilities in 82599 */
1071 dcb_config->support.capabilities = 0xFF;
1073 /*we only support 4 Tcs for X540, X550 */
1074 if (hw->mac.type == ixgbe_mac_X540 ||
1075 hw->mac.type == ixgbe_mac_X550 ||
1076 hw->mac.type == ixgbe_mac_X550EM_x ||
1077 hw->mac.type == ixgbe_mac_X550EM_a) {
1078 dcb_config->num_tcs.pg_tcs = 4;
1079 dcb_config->num_tcs.pfc_tcs = 4;
1084 * Ensure that all locks are released before first NVM or PHY access
1087 ixgbe_swfw_lock_reset(struct ixgbe_hw *hw)
1092 * Phy lock should not fail in this early stage. If this is the case,
1093 * it is due to an improper exit of the application.
1094 * So force the release of the faulty lock. Release of common lock
1095 * is done automatically by swfw_sync function.
1097 mask = IXGBE_GSSR_PHY0_SM << hw->bus.func;
1098 if (ixgbe_acquire_swfw_semaphore(hw, mask) < 0) {
1099 PMD_DRV_LOG(DEBUG, "SWFW phy%d lock released", hw->bus.func);
1101 ixgbe_release_swfw_semaphore(hw, mask);
1104 * These ones are more tricky since they are common to all ports; but
1105 * swfw_sync retries last long enough (1s) to be almost sure that if
1106 * lock can not be taken it is due to an improper lock of the
1109 mask = IXGBE_GSSR_EEP_SM | IXGBE_GSSR_MAC_CSR_SM | IXGBE_GSSR_SW_MNG_SM;
1110 if (ixgbe_acquire_swfw_semaphore(hw, mask) < 0) {
1111 PMD_DRV_LOG(DEBUG, "SWFW common locks released");
1113 ixgbe_release_swfw_semaphore(hw, mask);
1117 * This function is based on code in ixgbe_attach() in base/ixgbe.c.
1118 * It returns 0 on success.
1121 eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev)
1123 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
1124 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
1125 struct ixgbe_hw *hw =
1126 IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
1127 struct ixgbe_vfta *shadow_vfta =
1128 IXGBE_DEV_PRIVATE_TO_VFTA(eth_dev->data->dev_private);
1129 struct ixgbe_hwstrip *hwstrip =
1130 IXGBE_DEV_PRIVATE_TO_HWSTRIP_BITMAP(eth_dev->data->dev_private);
1131 struct ixgbe_dcb_config *dcb_config =
1132 IXGBE_DEV_PRIVATE_TO_DCB_CFG(eth_dev->data->dev_private);
1133 struct ixgbe_filter_info *filter_info =
1134 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(eth_dev->data->dev_private);
1135 struct ixgbe_bw_conf *bw_conf =
1136 IXGBE_DEV_PRIVATE_TO_BW_CONF(eth_dev->data->dev_private);
1141 PMD_INIT_FUNC_TRACE();
1143 eth_dev->dev_ops = &ixgbe_eth_dev_ops;
1144 eth_dev->rx_pkt_burst = &ixgbe_recv_pkts;
1145 eth_dev->tx_pkt_burst = &ixgbe_xmit_pkts;
1146 eth_dev->tx_pkt_prepare = &ixgbe_prep_pkts;
1149 * For secondary processes, we don't initialise any further as primary
1150 * has already done this work. Only check we don't need a different
1151 * RX and TX function.
1153 if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
1154 struct ixgbe_tx_queue *txq;
1155 /* TX queue function in primary, set by last queue initialized
1156 * Tx queue may not initialized by primary process
1158 if (eth_dev->data->tx_queues) {
1159 txq = eth_dev->data->tx_queues[eth_dev->data->nb_tx_queues-1];
1160 ixgbe_set_tx_function(eth_dev, txq);
1162 /* Use default TX function if we get here */
1163 PMD_INIT_LOG(NOTICE, "No TX queues configured yet. "
1164 "Using default TX function.");
1167 ixgbe_set_rx_function(eth_dev);
1172 rte_eth_copy_pci_info(eth_dev, pci_dev);
1173 eth_dev->data->dev_flags |= RTE_ETH_DEV_DETACHABLE;
1175 /* Vendor and Device ID need to be set before init of shared code */
1176 hw->device_id = pci_dev->id.device_id;
1177 hw->vendor_id = pci_dev->id.vendor_id;
1178 hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
1179 hw->allow_unsupported_sfp = 1;
1181 /* Initialize the shared code (base driver) */
1182 #ifdef RTE_LIBRTE_IXGBE_BYPASS
1183 diag = ixgbe_bypass_init_shared_code(hw);
1185 diag = ixgbe_init_shared_code(hw);
1186 #endif /* RTE_LIBRTE_IXGBE_BYPASS */
1188 if (diag != IXGBE_SUCCESS) {
1189 PMD_INIT_LOG(ERR, "Shared code init failed: %d", diag);
1193 /* pick up the PCI bus settings for reporting later */
1194 ixgbe_get_bus_info(hw);
1196 /* Unlock any pending hardware semaphore */
1197 ixgbe_swfw_lock_reset(hw);
1199 /* Initialize DCB configuration*/
1200 memset(dcb_config, 0, sizeof(struct ixgbe_dcb_config));
1201 ixgbe_dcb_init(hw, dcb_config);
1202 /* Get Hardware Flow Control setting */
1203 hw->fc.requested_mode = ixgbe_fc_full;
1204 hw->fc.current_mode = ixgbe_fc_full;
1205 hw->fc.pause_time = IXGBE_FC_PAUSE;
1206 for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
1207 hw->fc.low_water[i] = IXGBE_FC_LO;
1208 hw->fc.high_water[i] = IXGBE_FC_HI;
1210 hw->fc.send_xon = 1;
1212 /* Make sure we have a good EEPROM before we read from it */
1213 diag = ixgbe_validate_eeprom_checksum(hw, &csum);
1214 if (diag != IXGBE_SUCCESS) {
1215 PMD_INIT_LOG(ERR, "The EEPROM checksum is not valid: %d", diag);
1219 #ifdef RTE_LIBRTE_IXGBE_BYPASS
1220 diag = ixgbe_bypass_init_hw(hw);
1222 diag = ixgbe_init_hw(hw);
1223 #endif /* RTE_LIBRTE_IXGBE_BYPASS */
1226 * Devices with copper phys will fail to initialise if ixgbe_init_hw()
1227 * is called too soon after the kernel driver unbinding/binding occurs.
1228 * The failure occurs in ixgbe_identify_phy_generic() for all devices,
1229 * but for non-copper devies, ixgbe_identify_sfp_module_generic() is
1230 * also called. See ixgbe_identify_phy_82599(). The reason for the
1231 * failure is not known, and only occuts when virtualisation features
1232 * are disabled in the bios. A delay of 100ms was found to be enough by
1233 * trial-and-error, and is doubled to be safe.
1235 if (diag && (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper)) {
1237 diag = ixgbe_init_hw(hw);
1240 if (diag == IXGBE_ERR_SFP_NOT_PRESENT)
1241 diag = IXGBE_SUCCESS;
1243 if (diag == IXGBE_ERR_EEPROM_VERSION) {
1244 PMD_INIT_LOG(ERR, "This device is a pre-production adapter/"
1245 "LOM. Please be aware there may be issues associated "
1246 "with your hardware.");
1247 PMD_INIT_LOG(ERR, "If you are experiencing problems "
1248 "please contact your Intel or hardware representative "
1249 "who provided you with this hardware.");
1250 } else if (diag == IXGBE_ERR_SFP_NOT_SUPPORTED)
1251 PMD_INIT_LOG(ERR, "Unsupported SFP+ Module");
1253 PMD_INIT_LOG(ERR, "Hardware Initialization Failure: %d", diag);
1257 /* Reset the hw statistics */
1258 ixgbe_dev_stats_reset(eth_dev);
1260 /* disable interrupt */
1261 ixgbe_disable_intr(hw);
1263 /* reset mappings for queue statistics hw counters*/
1264 ixgbe_reset_qstat_mappings(hw);
1266 /* Allocate memory for storing MAC addresses */
1267 eth_dev->data->mac_addrs = rte_zmalloc("ixgbe", ETHER_ADDR_LEN *
1268 hw->mac.num_rar_entries, 0);
1269 if (eth_dev->data->mac_addrs == NULL) {
1271 "Failed to allocate %u bytes needed to store "
1273 ETHER_ADDR_LEN * hw->mac.num_rar_entries);
1276 /* Copy the permanent MAC address */
1277 ether_addr_copy((struct ether_addr *) hw->mac.perm_addr,
1278 ð_dev->data->mac_addrs[0]);
1280 /* Allocate memory for storing hash filter MAC addresses */
1281 eth_dev->data->hash_mac_addrs = rte_zmalloc("ixgbe", ETHER_ADDR_LEN *
1282 IXGBE_VMDQ_NUM_UC_MAC, 0);
1283 if (eth_dev->data->hash_mac_addrs == NULL) {
1285 "Failed to allocate %d bytes needed to store MAC addresses",
1286 ETHER_ADDR_LEN * IXGBE_VMDQ_NUM_UC_MAC);
1290 /* initialize the vfta */
1291 memset(shadow_vfta, 0, sizeof(*shadow_vfta));
1293 /* initialize the hw strip bitmap*/
1294 memset(hwstrip, 0, sizeof(*hwstrip));
1296 /* initialize PF if max_vfs not zero */
1297 ixgbe_pf_host_init(eth_dev);
1299 ctrl_ext = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
1300 /* let hardware know driver is loaded */
1301 ctrl_ext |= IXGBE_CTRL_EXT_DRV_LOAD;
1302 /* Set PF Reset Done bit so PF/VF Mail Ops can work */
1303 ctrl_ext |= IXGBE_CTRL_EXT_PFRSTD;
1304 IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl_ext);
1305 IXGBE_WRITE_FLUSH(hw);
1307 if (ixgbe_is_sfp(hw) && hw->phy.sfp_type != ixgbe_sfp_type_not_present)
1308 PMD_INIT_LOG(DEBUG, "MAC: %d, PHY: %d, SFP+: %d",
1309 (int) hw->mac.type, (int) hw->phy.type,
1310 (int) hw->phy.sfp_type);
1312 PMD_INIT_LOG(DEBUG, "MAC: %d, PHY: %d",
1313 (int) hw->mac.type, (int) hw->phy.type);
1315 PMD_INIT_LOG(DEBUG, "port %d vendorID=0x%x deviceID=0x%x",
1316 eth_dev->data->port_id, pci_dev->id.vendor_id,
1317 pci_dev->id.device_id);
1319 rte_intr_callback_register(intr_handle,
1320 ixgbe_dev_interrupt_handler, eth_dev);
1322 /* enable uio/vfio intr/eventfd mapping */
1323 rte_intr_enable(intr_handle);
1325 /* enable support intr */
1326 ixgbe_enable_intr(eth_dev);
1328 /* initialize filter info */
1329 memset(filter_info, 0,
1330 sizeof(struct ixgbe_filter_info));
1332 /* initialize 5tuple filter list */
1333 TAILQ_INIT(&filter_info->fivetuple_list);
1335 /* initialize flow director filter list & hash */
1336 ixgbe_fdir_filter_init(eth_dev);
1338 /* initialize l2 tunnel filter list & hash */
1339 ixgbe_l2_tn_filter_init(eth_dev);
1341 TAILQ_INIT(&filter_ntuple_list);
1342 TAILQ_INIT(&filter_ethertype_list);
1343 TAILQ_INIT(&filter_syn_list);
1344 TAILQ_INIT(&filter_fdir_list);
1345 TAILQ_INIT(&filter_l2_tunnel_list);
1346 TAILQ_INIT(&ixgbe_flow_list);
1348 /* initialize bandwidth configuration info */
1349 memset(bw_conf, 0, sizeof(struct ixgbe_bw_conf));
1351 /* initialize Traffic Manager configuration */
1352 ixgbe_tm_conf_init(eth_dev);
1358 eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev)
1360 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
1361 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
1362 struct ixgbe_hw *hw;
1364 PMD_INIT_FUNC_TRACE();
1366 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
1369 hw = IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
1371 if (hw->adapter_stopped == 0)
1372 ixgbe_dev_close(eth_dev);
1374 eth_dev->dev_ops = NULL;
1375 eth_dev->rx_pkt_burst = NULL;
1376 eth_dev->tx_pkt_burst = NULL;
1378 /* Unlock any pending hardware semaphore */
1379 ixgbe_swfw_lock_reset(hw);
1381 /* disable uio intr before callback unregister */
1382 rte_intr_disable(intr_handle);
1383 rte_intr_callback_unregister(intr_handle,
1384 ixgbe_dev_interrupt_handler, eth_dev);
1386 /* uninitialize PF if max_vfs not zero */
1387 ixgbe_pf_host_uninit(eth_dev);
1389 rte_free(eth_dev->data->mac_addrs);
1390 eth_dev->data->mac_addrs = NULL;
1392 rte_free(eth_dev->data->hash_mac_addrs);
1393 eth_dev->data->hash_mac_addrs = NULL;
1395 /* remove all the fdir filters & hash */
1396 ixgbe_fdir_filter_uninit(eth_dev);
1398 /* remove all the L2 tunnel filters & hash */
1399 ixgbe_l2_tn_filter_uninit(eth_dev);
1401 /* Remove all ntuple filters of the device */
1402 ixgbe_ntuple_filter_uninit(eth_dev);
1404 /* clear all the filters list */
1405 ixgbe_filterlist_flush();
1407 /* Remove all Traffic Manager configuration */
1408 ixgbe_tm_conf_uninit(eth_dev);
1413 static int ixgbe_ntuple_filter_uninit(struct rte_eth_dev *eth_dev)
1415 struct ixgbe_filter_info *filter_info =
1416 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(eth_dev->data->dev_private);
1417 struct ixgbe_5tuple_filter *p_5tuple;
1419 while ((p_5tuple = TAILQ_FIRST(&filter_info->fivetuple_list))) {
1420 TAILQ_REMOVE(&filter_info->fivetuple_list,
1425 memset(filter_info->fivetuple_mask, 0,
1426 sizeof(uint32_t) * IXGBE_5TUPLE_ARRAY_SIZE);
1431 static int ixgbe_fdir_filter_uninit(struct rte_eth_dev *eth_dev)
1433 struct ixgbe_hw_fdir_info *fdir_info =
1434 IXGBE_DEV_PRIVATE_TO_FDIR_INFO(eth_dev->data->dev_private);
1435 struct ixgbe_fdir_filter *fdir_filter;
1437 if (fdir_info->hash_map)
1438 rte_free(fdir_info->hash_map);
1439 if (fdir_info->hash_handle)
1440 rte_hash_free(fdir_info->hash_handle);
1442 while ((fdir_filter = TAILQ_FIRST(&fdir_info->fdir_list))) {
1443 TAILQ_REMOVE(&fdir_info->fdir_list,
1446 rte_free(fdir_filter);
1452 static int ixgbe_l2_tn_filter_uninit(struct rte_eth_dev *eth_dev)
1454 struct ixgbe_l2_tn_info *l2_tn_info =
1455 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(eth_dev->data->dev_private);
1456 struct ixgbe_l2_tn_filter *l2_tn_filter;
1458 if (l2_tn_info->hash_map)
1459 rte_free(l2_tn_info->hash_map);
1460 if (l2_tn_info->hash_handle)
1461 rte_hash_free(l2_tn_info->hash_handle);
1463 while ((l2_tn_filter = TAILQ_FIRST(&l2_tn_info->l2_tn_list))) {
1464 TAILQ_REMOVE(&l2_tn_info->l2_tn_list,
1467 rte_free(l2_tn_filter);
1473 static int ixgbe_fdir_filter_init(struct rte_eth_dev *eth_dev)
1475 struct ixgbe_hw_fdir_info *fdir_info =
1476 IXGBE_DEV_PRIVATE_TO_FDIR_INFO(eth_dev->data->dev_private);
1477 char fdir_hash_name[RTE_HASH_NAMESIZE];
1478 struct rte_hash_parameters fdir_hash_params = {
1479 .name = fdir_hash_name,
1480 .entries = IXGBE_MAX_FDIR_FILTER_NUM,
1481 .key_len = sizeof(union ixgbe_atr_input),
1482 .hash_func = rte_hash_crc,
1483 .hash_func_init_val = 0,
1484 .socket_id = rte_socket_id(),
1487 TAILQ_INIT(&fdir_info->fdir_list);
1488 snprintf(fdir_hash_name, RTE_HASH_NAMESIZE,
1489 "fdir_%s", eth_dev->device->name);
1490 fdir_info->hash_handle = rte_hash_create(&fdir_hash_params);
1491 if (!fdir_info->hash_handle) {
1492 PMD_INIT_LOG(ERR, "Failed to create fdir hash table!");
1495 fdir_info->hash_map = rte_zmalloc("ixgbe",
1496 sizeof(struct ixgbe_fdir_filter *) *
1497 IXGBE_MAX_FDIR_FILTER_NUM,
1499 if (!fdir_info->hash_map) {
1501 "Failed to allocate memory for fdir hash map!");
1504 fdir_info->mask_added = FALSE;
1509 static int ixgbe_l2_tn_filter_init(struct rte_eth_dev *eth_dev)
1511 struct ixgbe_l2_tn_info *l2_tn_info =
1512 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(eth_dev->data->dev_private);
1513 char l2_tn_hash_name[RTE_HASH_NAMESIZE];
1514 struct rte_hash_parameters l2_tn_hash_params = {
1515 .name = l2_tn_hash_name,
1516 .entries = IXGBE_MAX_L2_TN_FILTER_NUM,
1517 .key_len = sizeof(struct ixgbe_l2_tn_key),
1518 .hash_func = rte_hash_crc,
1519 .hash_func_init_val = 0,
1520 .socket_id = rte_socket_id(),
1523 TAILQ_INIT(&l2_tn_info->l2_tn_list);
1524 snprintf(l2_tn_hash_name, RTE_HASH_NAMESIZE,
1525 "l2_tn_%s", eth_dev->device->name);
1526 l2_tn_info->hash_handle = rte_hash_create(&l2_tn_hash_params);
1527 if (!l2_tn_info->hash_handle) {
1528 PMD_INIT_LOG(ERR, "Failed to create L2 TN hash table!");
1531 l2_tn_info->hash_map = rte_zmalloc("ixgbe",
1532 sizeof(struct ixgbe_l2_tn_filter *) *
1533 IXGBE_MAX_L2_TN_FILTER_NUM,
1535 if (!l2_tn_info->hash_map) {
1537 "Failed to allocate memory for L2 TN hash map!");
1540 l2_tn_info->e_tag_en = FALSE;
1541 l2_tn_info->e_tag_fwd_en = FALSE;
1542 l2_tn_info->e_tag_ether_type = DEFAULT_ETAG_ETYPE;
1547 * Negotiate mailbox API version with the PF.
1548 * After reset API version is always set to the basic one (ixgbe_mbox_api_10).
1549 * Then we try to negotiate starting with the most recent one.
1550 * If all negotiation attempts fail, then we will proceed with
1551 * the default one (ixgbe_mbox_api_10).
1554 ixgbevf_negotiate_api(struct ixgbe_hw *hw)
1558 /* start with highest supported, proceed down */
1559 static const enum ixgbe_pfvf_api_rev sup_ver[] = {
1566 i != RTE_DIM(sup_ver) &&
1567 ixgbevf_negotiate_api_version(hw, sup_ver[i]) != 0;
1573 generate_random_mac_addr(struct ether_addr *mac_addr)
1577 /* Set Organizationally Unique Identifier (OUI) prefix. */
1578 mac_addr->addr_bytes[0] = 0x00;
1579 mac_addr->addr_bytes[1] = 0x09;
1580 mac_addr->addr_bytes[2] = 0xC0;
1581 /* Force indication of locally assigned MAC address. */
1582 mac_addr->addr_bytes[0] |= ETHER_LOCAL_ADMIN_ADDR;
1583 /* Generate the last 3 bytes of the MAC address with a random number. */
1584 random = rte_rand();
1585 memcpy(&mac_addr->addr_bytes[3], &random, 3);
1589 * Virtual Function device init
1592 eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev)
1596 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
1597 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
1598 struct ixgbe_hw *hw =
1599 IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
1600 struct ixgbe_vfta *shadow_vfta =
1601 IXGBE_DEV_PRIVATE_TO_VFTA(eth_dev->data->dev_private);
1602 struct ixgbe_hwstrip *hwstrip =
1603 IXGBE_DEV_PRIVATE_TO_HWSTRIP_BITMAP(eth_dev->data->dev_private);
1604 struct ether_addr *perm_addr = (struct ether_addr *) hw->mac.perm_addr;
1606 PMD_INIT_FUNC_TRACE();
1608 eth_dev->dev_ops = &ixgbevf_eth_dev_ops;
1609 eth_dev->rx_pkt_burst = &ixgbe_recv_pkts;
1610 eth_dev->tx_pkt_burst = &ixgbe_xmit_pkts;
1612 /* for secondary processes, we don't initialise any further as primary
1613 * has already done this work. Only check we don't need a different
1616 if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
1617 struct ixgbe_tx_queue *txq;
1618 /* TX queue function in primary, set by last queue initialized
1619 * Tx queue may not initialized by primary process
1621 if (eth_dev->data->tx_queues) {
1622 txq = eth_dev->data->tx_queues[eth_dev->data->nb_tx_queues - 1];
1623 ixgbe_set_tx_function(eth_dev, txq);
1625 /* Use default TX function if we get here */
1626 PMD_INIT_LOG(NOTICE,
1627 "No TX queues configured yet. Using default TX function.");
1630 ixgbe_set_rx_function(eth_dev);
1635 rte_eth_copy_pci_info(eth_dev, pci_dev);
1636 eth_dev->data->dev_flags |= RTE_ETH_DEV_DETACHABLE;
1638 hw->device_id = pci_dev->id.device_id;
1639 hw->vendor_id = pci_dev->id.vendor_id;
1640 hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
1642 /* initialize the vfta */
1643 memset(shadow_vfta, 0, sizeof(*shadow_vfta));
1645 /* initialize the hw strip bitmap*/
1646 memset(hwstrip, 0, sizeof(*hwstrip));
1648 /* Initialize the shared code (base driver) */
1649 diag = ixgbe_init_shared_code(hw);
1650 if (diag != IXGBE_SUCCESS) {
1651 PMD_INIT_LOG(ERR, "Shared code init failed for ixgbevf: %d", diag);
1655 /* init_mailbox_params */
1656 hw->mbx.ops.init_params(hw);
1658 /* Reset the hw statistics */
1659 ixgbevf_dev_stats_reset(eth_dev);
1661 /* Disable the interrupts for VF */
1662 ixgbevf_intr_disable(hw);
1664 hw->mac.num_rar_entries = 128; /* The MAX of the underlying PF */
1665 diag = hw->mac.ops.reset_hw(hw);
1668 * The VF reset operation returns the IXGBE_ERR_INVALID_MAC_ADDR when
1669 * the underlying PF driver has not assigned a MAC address to the VF.
1670 * In this case, assign a random MAC address.
1672 if ((diag != IXGBE_SUCCESS) && (diag != IXGBE_ERR_INVALID_MAC_ADDR)) {
1673 PMD_INIT_LOG(ERR, "VF Initialization Failure: %d", diag);
1677 /* negotiate mailbox API version to use with the PF. */
1678 ixgbevf_negotiate_api(hw);
1680 /* Get Rx/Tx queue count via mailbox, which is ready after reset_hw */
1681 ixgbevf_get_queues(hw, &tcs, &tc);
1683 /* Allocate memory for storing MAC addresses */
1684 eth_dev->data->mac_addrs = rte_zmalloc("ixgbevf", ETHER_ADDR_LEN *
1685 hw->mac.num_rar_entries, 0);
1686 if (eth_dev->data->mac_addrs == NULL) {
1688 "Failed to allocate %u bytes needed to store "
1690 ETHER_ADDR_LEN * hw->mac.num_rar_entries);
1694 /* Generate a random MAC address, if none was assigned by PF. */
1695 if (is_zero_ether_addr(perm_addr)) {
1696 generate_random_mac_addr(perm_addr);
1697 diag = ixgbe_set_rar_vf(hw, 1, perm_addr->addr_bytes, 0, 1);
1699 rte_free(eth_dev->data->mac_addrs);
1700 eth_dev->data->mac_addrs = NULL;
1703 PMD_INIT_LOG(INFO, "\tVF MAC address not assigned by Host PF");
1704 PMD_INIT_LOG(INFO, "\tAssign randomly generated MAC address "
1705 "%02x:%02x:%02x:%02x:%02x:%02x",
1706 perm_addr->addr_bytes[0],
1707 perm_addr->addr_bytes[1],
1708 perm_addr->addr_bytes[2],
1709 perm_addr->addr_bytes[3],
1710 perm_addr->addr_bytes[4],
1711 perm_addr->addr_bytes[5]);
1714 /* Copy the permanent MAC address */
1715 ether_addr_copy(perm_addr, ð_dev->data->mac_addrs[0]);
1717 /* reset the hardware with the new settings */
1718 diag = hw->mac.ops.start_hw(hw);
1724 PMD_INIT_LOG(ERR, "VF Initialization Failure: %d", diag);
1728 rte_intr_callback_register(intr_handle,
1729 ixgbevf_dev_interrupt_handler, eth_dev);
1730 rte_intr_enable(intr_handle);
1731 ixgbevf_intr_enable(hw);
1733 PMD_INIT_LOG(DEBUG, "port %d vendorID=0x%x deviceID=0x%x mac.type=%s",
1734 eth_dev->data->port_id, pci_dev->id.vendor_id,
1735 pci_dev->id.device_id, "ixgbe_mac_82599_vf");
1740 /* Virtual Function device uninit */
1743 eth_ixgbevf_dev_uninit(struct rte_eth_dev *eth_dev)
1745 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
1746 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
1747 struct ixgbe_hw *hw;
1749 PMD_INIT_FUNC_TRACE();
1751 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
1754 hw = IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
1756 if (hw->adapter_stopped == 0)
1757 ixgbevf_dev_close(eth_dev);
1759 eth_dev->dev_ops = NULL;
1760 eth_dev->rx_pkt_burst = NULL;
1761 eth_dev->tx_pkt_burst = NULL;
1763 /* Disable the interrupts for VF */
1764 ixgbevf_intr_disable(hw);
1766 rte_free(eth_dev->data->mac_addrs);
1767 eth_dev->data->mac_addrs = NULL;
1769 rte_intr_disable(intr_handle);
1770 rte_intr_callback_unregister(intr_handle,
1771 ixgbevf_dev_interrupt_handler, eth_dev);
1776 static int eth_ixgbe_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
1777 struct rte_pci_device *pci_dev)
1779 return rte_eth_dev_pci_generic_probe(pci_dev,
1780 sizeof(struct ixgbe_adapter), eth_ixgbe_dev_init);
1783 static int eth_ixgbe_pci_remove(struct rte_pci_device *pci_dev)
1785 return rte_eth_dev_pci_generic_remove(pci_dev, eth_ixgbe_dev_uninit);
1788 static struct rte_pci_driver rte_ixgbe_pmd = {
1789 .id_table = pci_id_ixgbe_map,
1790 .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
1791 .probe = eth_ixgbe_pci_probe,
1792 .remove = eth_ixgbe_pci_remove,
1795 static int eth_ixgbevf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
1796 struct rte_pci_device *pci_dev)
1798 return rte_eth_dev_pci_generic_probe(pci_dev,
1799 sizeof(struct ixgbe_adapter), eth_ixgbevf_dev_init);
1802 static int eth_ixgbevf_pci_remove(struct rte_pci_device *pci_dev)
1804 return rte_eth_dev_pci_generic_remove(pci_dev, eth_ixgbevf_dev_uninit);
1808 * virtual function driver struct
1810 static struct rte_pci_driver rte_ixgbevf_pmd = {
1811 .id_table = pci_id_ixgbevf_map,
1812 .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
1813 .probe = eth_ixgbevf_pci_probe,
1814 .remove = eth_ixgbevf_pci_remove,
1818 ixgbe_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
1820 struct ixgbe_hw *hw =
1821 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1822 struct ixgbe_vfta *shadow_vfta =
1823 IXGBE_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
1828 vid_idx = (uint32_t) ((vlan_id >> 5) & 0x7F);
1829 vid_bit = (uint32_t) (1 << (vlan_id & 0x1F));
1830 vfta = IXGBE_READ_REG(hw, IXGBE_VFTA(vid_idx));
1835 IXGBE_WRITE_REG(hw, IXGBE_VFTA(vid_idx), vfta);
1837 /* update local VFTA copy */
1838 shadow_vfta->vfta[vid_idx] = vfta;
1844 ixgbe_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue, int on)
1847 ixgbe_vlan_hw_strip_enable(dev, queue);
1849 ixgbe_vlan_hw_strip_disable(dev, queue);
1853 ixgbe_vlan_tpid_set(struct rte_eth_dev *dev,
1854 enum rte_vlan_type vlan_type,
1857 struct ixgbe_hw *hw =
1858 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1863 qinq = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
1864 qinq &= IXGBE_DMATXCTL_GDV;
1866 switch (vlan_type) {
1867 case ETH_VLAN_TYPE_INNER:
1869 reg = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
1870 reg = (reg & (~IXGBE_VLNCTRL_VET)) | (uint32_t)tpid;
1871 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, reg);
1872 reg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
1873 reg = (reg & (~IXGBE_DMATXCTL_VT_MASK))
1874 | ((uint32_t)tpid << IXGBE_DMATXCTL_VT_SHIFT);
1875 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);
1878 PMD_DRV_LOG(ERR, "Inner type is not supported"
1882 case ETH_VLAN_TYPE_OUTER:
1884 /* Only the high 16-bits is valid */
1885 IXGBE_WRITE_REG(hw, IXGBE_EXVET, (uint32_t)tpid <<
1886 IXGBE_EXVET_VET_EXT_SHIFT);
1888 reg = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
1889 reg = (reg & (~IXGBE_VLNCTRL_VET)) | (uint32_t)tpid;
1890 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, reg);
1891 reg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
1892 reg = (reg & (~IXGBE_DMATXCTL_VT_MASK))
1893 | ((uint32_t)tpid << IXGBE_DMATXCTL_VT_SHIFT);
1894 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);
1900 PMD_DRV_LOG(ERR, "Unsupported VLAN type %d", vlan_type);
1908 ixgbe_vlan_hw_filter_disable(struct rte_eth_dev *dev)
1910 struct ixgbe_hw *hw =
1911 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1914 PMD_INIT_FUNC_TRACE();
1916 /* Filter Table Disable */
1917 vlnctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
1918 vlnctrl &= ~IXGBE_VLNCTRL_VFE;
1920 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlnctrl);
1924 ixgbe_vlan_hw_filter_enable(struct rte_eth_dev *dev)
1926 struct ixgbe_hw *hw =
1927 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1928 struct ixgbe_vfta *shadow_vfta =
1929 IXGBE_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
1933 PMD_INIT_FUNC_TRACE();
1935 /* Filter Table Enable */
1936 vlnctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
1937 vlnctrl &= ~IXGBE_VLNCTRL_CFIEN;
1938 vlnctrl |= IXGBE_VLNCTRL_VFE;
1940 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlnctrl);
1942 /* write whatever is in local vfta copy */
1943 for (i = 0; i < IXGBE_VFTA_SIZE; i++)
1944 IXGBE_WRITE_REG(hw, IXGBE_VFTA(i), shadow_vfta->vfta[i]);
1948 ixgbe_vlan_hw_strip_bitmap_set(struct rte_eth_dev *dev, uint16_t queue, bool on)
1950 struct ixgbe_hwstrip *hwstrip =
1951 IXGBE_DEV_PRIVATE_TO_HWSTRIP_BITMAP(dev->data->dev_private);
1952 struct ixgbe_rx_queue *rxq;
1954 if (queue >= IXGBE_MAX_RX_QUEUE_NUM)
1958 IXGBE_SET_HWSTRIP(hwstrip, queue);
1960 IXGBE_CLEAR_HWSTRIP(hwstrip, queue);
1962 if (queue >= dev->data->nb_rx_queues)
1965 rxq = dev->data->rx_queues[queue];
1968 rxq->vlan_flags = PKT_RX_VLAN_PKT | PKT_RX_VLAN_STRIPPED;
1970 rxq->vlan_flags = PKT_RX_VLAN_PKT;
1974 ixgbe_vlan_hw_strip_disable(struct rte_eth_dev *dev, uint16_t queue)
1976 struct ixgbe_hw *hw =
1977 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1980 PMD_INIT_FUNC_TRACE();
1982 if (hw->mac.type == ixgbe_mac_82598EB) {
1983 /* No queue level support */
1984 PMD_INIT_LOG(NOTICE, "82598EB not support queue level hw strip");
1988 /* Other 10G NIC, the VLAN strip can be setup per queue in RXDCTL */
1989 ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(queue));
1990 ctrl &= ~IXGBE_RXDCTL_VME;
1991 IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(queue), ctrl);
1993 /* record those setting for HW strip per queue */
1994 ixgbe_vlan_hw_strip_bitmap_set(dev, queue, 0);
1998 ixgbe_vlan_hw_strip_enable(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 supported */
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, 1);
2022 ixgbe_vlan_hw_strip_disable_all(struct rte_eth_dev *dev)
2024 struct ixgbe_hw *hw =
2025 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2028 struct ixgbe_rx_queue *rxq;
2030 PMD_INIT_FUNC_TRACE();
2032 if (hw->mac.type == ixgbe_mac_82598EB) {
2033 ctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
2034 ctrl &= ~IXGBE_VLNCTRL_VME;
2035 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, ctrl);
2037 /* Other 10G NIC, the VLAN strip can be setup per queue in RXDCTL */
2038 for (i = 0; i < dev->data->nb_rx_queues; i++) {
2039 rxq = dev->data->rx_queues[i];
2040 ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(rxq->reg_idx));
2041 ctrl &= ~IXGBE_RXDCTL_VME;
2042 IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(rxq->reg_idx), ctrl);
2044 /* record those setting for HW strip per queue */
2045 ixgbe_vlan_hw_strip_bitmap_set(dev, i, 0);
2051 ixgbe_vlan_hw_strip_enable_all(struct rte_eth_dev *dev)
2053 struct ixgbe_hw *hw =
2054 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2057 struct ixgbe_rx_queue *rxq;
2059 PMD_INIT_FUNC_TRACE();
2061 if (hw->mac.type == ixgbe_mac_82598EB) {
2062 ctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
2063 ctrl |= IXGBE_VLNCTRL_VME;
2064 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, ctrl);
2066 /* Other 10G NIC, the VLAN strip can be setup per queue in RXDCTL */
2067 for (i = 0; i < dev->data->nb_rx_queues; i++) {
2068 rxq = dev->data->rx_queues[i];
2069 ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(rxq->reg_idx));
2070 ctrl |= IXGBE_RXDCTL_VME;
2071 IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(rxq->reg_idx), ctrl);
2073 /* record those setting for HW strip per queue */
2074 ixgbe_vlan_hw_strip_bitmap_set(dev, i, 1);
2080 ixgbe_vlan_hw_extend_disable(struct rte_eth_dev *dev)
2082 struct ixgbe_hw *hw =
2083 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2086 PMD_INIT_FUNC_TRACE();
2088 /* DMATXCTRL: Geric Double VLAN Disable */
2089 ctrl = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
2090 ctrl &= ~IXGBE_DMATXCTL_GDV;
2091 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, ctrl);
2093 /* CTRL_EXT: Global Double VLAN Disable */
2094 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
2095 ctrl &= ~IXGBE_EXTENDED_VLAN;
2096 IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl);
2101 ixgbe_vlan_hw_extend_enable(struct rte_eth_dev *dev)
2103 struct ixgbe_hw *hw =
2104 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2107 PMD_INIT_FUNC_TRACE();
2109 /* DMATXCTRL: Geric Double VLAN Enable */
2110 ctrl = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
2111 ctrl |= IXGBE_DMATXCTL_GDV;
2112 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, ctrl);
2114 /* CTRL_EXT: Global Double VLAN Enable */
2115 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
2116 ctrl |= IXGBE_EXTENDED_VLAN;
2117 IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl);
2119 /* Clear pooling mode of PFVTCTL. It's required by X550. */
2120 if (hw->mac.type == ixgbe_mac_X550 ||
2121 hw->mac.type == ixgbe_mac_X550EM_x ||
2122 hw->mac.type == ixgbe_mac_X550EM_a) {
2123 ctrl = IXGBE_READ_REG(hw, IXGBE_VT_CTL);
2124 ctrl &= ~IXGBE_VT_CTL_POOLING_MODE_MASK;
2125 IXGBE_WRITE_REG(hw, IXGBE_VT_CTL, ctrl);
2129 * VET EXT field in the EXVET register = 0x8100 by default
2130 * So no need to change. Same to VT field of DMATXCTL register
2135 ixgbe_vlan_offload_set(struct rte_eth_dev *dev, int mask)
2137 if (mask & ETH_VLAN_STRIP_MASK) {
2138 if (dev->data->dev_conf.rxmode.hw_vlan_strip)
2139 ixgbe_vlan_hw_strip_enable_all(dev);
2141 ixgbe_vlan_hw_strip_disable_all(dev);
2144 if (mask & ETH_VLAN_FILTER_MASK) {
2145 if (dev->data->dev_conf.rxmode.hw_vlan_filter)
2146 ixgbe_vlan_hw_filter_enable(dev);
2148 ixgbe_vlan_hw_filter_disable(dev);
2151 if (mask & ETH_VLAN_EXTEND_MASK) {
2152 if (dev->data->dev_conf.rxmode.hw_vlan_extend)
2153 ixgbe_vlan_hw_extend_enable(dev);
2155 ixgbe_vlan_hw_extend_disable(dev);
2160 ixgbe_vmdq_vlan_hw_filter_enable(struct rte_eth_dev *dev)
2162 struct ixgbe_hw *hw =
2163 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2164 /* VLNCTRL: enable vlan filtering and allow all vlan tags through */
2165 uint32_t vlanctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
2167 vlanctrl |= IXGBE_VLNCTRL_VFE; /* enable vlan filters */
2168 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlanctrl);
2172 ixgbe_check_vf_rss_rxq_num(struct rte_eth_dev *dev, uint16_t nb_rx_q)
2174 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
2179 RTE_ETH_DEV_SRIOV(dev).active = ETH_64_POOLS;
2182 RTE_ETH_DEV_SRIOV(dev).active = ETH_32_POOLS;
2188 RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool = nb_rx_q;
2189 RTE_ETH_DEV_SRIOV(dev).def_pool_q_idx = pci_dev->max_vfs * nb_rx_q;
2195 ixgbe_check_mq_mode(struct rte_eth_dev *dev)
2197 struct rte_eth_conf *dev_conf = &dev->data->dev_conf;
2198 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2199 uint16_t nb_rx_q = dev->data->nb_rx_queues;
2200 uint16_t nb_tx_q = dev->data->nb_tx_queues;
2202 if (RTE_ETH_DEV_SRIOV(dev).active != 0) {
2203 /* check multi-queue mode */
2204 switch (dev_conf->rxmode.mq_mode) {
2205 case ETH_MQ_RX_VMDQ_DCB:
2206 PMD_INIT_LOG(INFO, "ETH_MQ_RX_VMDQ_DCB mode supported in SRIOV");
2208 case ETH_MQ_RX_VMDQ_DCB_RSS:
2209 /* DCB/RSS VMDQ in SRIOV mode, not implement yet */
2210 PMD_INIT_LOG(ERR, "SRIOV active,"
2211 " unsupported mq_mode rx %d.",
2212 dev_conf->rxmode.mq_mode);
2215 case ETH_MQ_RX_VMDQ_RSS:
2216 dev->data->dev_conf.rxmode.mq_mode = ETH_MQ_RX_VMDQ_RSS;
2217 if (nb_rx_q <= RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool)
2218 if (ixgbe_check_vf_rss_rxq_num(dev, nb_rx_q)) {
2219 PMD_INIT_LOG(ERR, "SRIOV is active,"
2220 " invalid queue number"
2221 " for VMDQ RSS, allowed"
2222 " value are 1, 2 or 4.");
2226 case ETH_MQ_RX_VMDQ_ONLY:
2227 case ETH_MQ_RX_NONE:
2228 /* if nothing mq mode configure, use default scheme */
2229 dev->data->dev_conf.rxmode.mq_mode = ETH_MQ_RX_VMDQ_ONLY;
2230 if (RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool > 1)
2231 RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool = 1;
2233 default: /* ETH_MQ_RX_DCB, ETH_MQ_RX_DCB_RSS or ETH_MQ_TX_DCB*/
2234 /* SRIOV only works in VMDq enable mode */
2235 PMD_INIT_LOG(ERR, "SRIOV is active,"
2236 " wrong mq_mode rx %d.",
2237 dev_conf->rxmode.mq_mode);
2241 switch (dev_conf->txmode.mq_mode) {
2242 case ETH_MQ_TX_VMDQ_DCB:
2243 PMD_INIT_LOG(INFO, "ETH_MQ_TX_VMDQ_DCB mode supported in SRIOV");
2244 dev->data->dev_conf.txmode.mq_mode = ETH_MQ_TX_VMDQ_DCB;
2246 default: /* ETH_MQ_TX_VMDQ_ONLY or ETH_MQ_TX_NONE */
2247 dev->data->dev_conf.txmode.mq_mode = ETH_MQ_TX_VMDQ_ONLY;
2251 /* check valid queue number */
2252 if ((nb_rx_q > RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool) ||
2253 (nb_tx_q > RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool)) {
2254 PMD_INIT_LOG(ERR, "SRIOV is active,"
2255 " nb_rx_q=%d nb_tx_q=%d queue number"
2256 " must be less than or equal to %d.",
2258 RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool);
2262 if (dev_conf->rxmode.mq_mode == ETH_MQ_RX_VMDQ_DCB_RSS) {
2263 PMD_INIT_LOG(ERR, "VMDQ+DCB+RSS mq_mode is"
2267 /* check configuration for vmdb+dcb mode */
2268 if (dev_conf->rxmode.mq_mode == ETH_MQ_RX_VMDQ_DCB) {
2269 const struct rte_eth_vmdq_dcb_conf *conf;
2271 if (nb_rx_q != IXGBE_VMDQ_DCB_NB_QUEUES) {
2272 PMD_INIT_LOG(ERR, "VMDQ+DCB, nb_rx_q != %d.",
2273 IXGBE_VMDQ_DCB_NB_QUEUES);
2276 conf = &dev_conf->rx_adv_conf.vmdq_dcb_conf;
2277 if (!(conf->nb_queue_pools == ETH_16_POOLS ||
2278 conf->nb_queue_pools == ETH_32_POOLS)) {
2279 PMD_INIT_LOG(ERR, "VMDQ+DCB selected,"
2280 " nb_queue_pools must be %d or %d.",
2281 ETH_16_POOLS, ETH_32_POOLS);
2285 if (dev_conf->txmode.mq_mode == ETH_MQ_TX_VMDQ_DCB) {
2286 const struct rte_eth_vmdq_dcb_tx_conf *conf;
2288 if (nb_tx_q != IXGBE_VMDQ_DCB_NB_QUEUES) {
2289 PMD_INIT_LOG(ERR, "VMDQ+DCB, nb_tx_q != %d",
2290 IXGBE_VMDQ_DCB_NB_QUEUES);
2293 conf = &dev_conf->tx_adv_conf.vmdq_dcb_tx_conf;
2294 if (!(conf->nb_queue_pools == ETH_16_POOLS ||
2295 conf->nb_queue_pools == ETH_32_POOLS)) {
2296 PMD_INIT_LOG(ERR, "VMDQ+DCB selected,"
2297 " nb_queue_pools != %d and"
2298 " nb_queue_pools != %d.",
2299 ETH_16_POOLS, ETH_32_POOLS);
2304 /* For DCB mode check our configuration before we go further */
2305 if (dev_conf->rxmode.mq_mode == ETH_MQ_RX_DCB) {
2306 const struct rte_eth_dcb_rx_conf *conf;
2308 if (nb_rx_q != IXGBE_DCB_NB_QUEUES) {
2309 PMD_INIT_LOG(ERR, "DCB selected, nb_rx_q != %d.",
2310 IXGBE_DCB_NB_QUEUES);
2313 conf = &dev_conf->rx_adv_conf.dcb_rx_conf;
2314 if (!(conf->nb_tcs == ETH_4_TCS ||
2315 conf->nb_tcs == ETH_8_TCS)) {
2316 PMD_INIT_LOG(ERR, "DCB selected, nb_tcs != %d"
2317 " and nb_tcs != %d.",
2318 ETH_4_TCS, ETH_8_TCS);
2323 if (dev_conf->txmode.mq_mode == ETH_MQ_TX_DCB) {
2324 const struct rte_eth_dcb_tx_conf *conf;
2326 if (nb_tx_q != IXGBE_DCB_NB_QUEUES) {
2327 PMD_INIT_LOG(ERR, "DCB, nb_tx_q != %d.",
2328 IXGBE_DCB_NB_QUEUES);
2331 conf = &dev_conf->tx_adv_conf.dcb_tx_conf;
2332 if (!(conf->nb_tcs == ETH_4_TCS ||
2333 conf->nb_tcs == ETH_8_TCS)) {
2334 PMD_INIT_LOG(ERR, "DCB selected, nb_tcs != %d"
2335 " and nb_tcs != %d.",
2336 ETH_4_TCS, ETH_8_TCS);
2342 * When DCB/VT is off, maximum number of queues changes,
2343 * except for 82598EB, which remains constant.
2345 if (dev_conf->txmode.mq_mode == ETH_MQ_TX_NONE &&
2346 hw->mac.type != ixgbe_mac_82598EB) {
2347 if (nb_tx_q > IXGBE_NONE_MODE_TX_NB_QUEUES) {
2349 "Neither VT nor DCB are enabled, "
2351 IXGBE_NONE_MODE_TX_NB_QUEUES);
2360 ixgbe_dev_configure(struct rte_eth_dev *dev)
2362 struct ixgbe_interrupt *intr =
2363 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
2364 struct ixgbe_adapter *adapter =
2365 (struct ixgbe_adapter *)dev->data->dev_private;
2368 PMD_INIT_FUNC_TRACE();
2369 /* multipe queue mode checking */
2370 ret = ixgbe_check_mq_mode(dev);
2372 PMD_DRV_LOG(ERR, "ixgbe_check_mq_mode fails with %d.",
2377 /* set flag to update link status after init */
2378 intr->flags |= IXGBE_FLAG_NEED_LINK_UPDATE;
2381 * Initialize to TRUE. If any of Rx queues doesn't meet the bulk
2382 * allocation or vector Rx preconditions we will reset it.
2384 adapter->rx_bulk_alloc_allowed = true;
2385 adapter->rx_vec_allowed = true;
2391 ixgbe_dev_phy_intr_setup(struct rte_eth_dev *dev)
2393 struct ixgbe_hw *hw =
2394 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2395 struct ixgbe_interrupt *intr =
2396 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
2399 /* only set up it on X550EM_X */
2400 if (hw->mac.type == ixgbe_mac_X550EM_x) {
2401 gpie = IXGBE_READ_REG(hw, IXGBE_GPIE);
2402 gpie |= IXGBE_SDP0_GPIEN_X550EM_x;
2403 IXGBE_WRITE_REG(hw, IXGBE_GPIE, gpie);
2404 if (hw->phy.type == ixgbe_phy_x550em_ext_t)
2405 intr->mask |= IXGBE_EICR_GPI_SDP0_X550EM_x;
2410 ixgbe_set_vf_rate_limit(struct rte_eth_dev *dev, uint16_t vf,
2411 uint16_t tx_rate, uint64_t q_msk)
2413 struct ixgbe_hw *hw;
2414 struct ixgbe_vf_info *vfinfo;
2415 struct rte_eth_link link;
2416 uint8_t nb_q_per_pool;
2417 uint32_t queue_stride;
2418 uint32_t queue_idx, idx = 0, vf_idx;
2420 uint16_t total_rate = 0;
2421 struct rte_pci_device *pci_dev;
2423 pci_dev = RTE_ETH_DEV_TO_PCI(dev);
2424 rte_eth_link_get_nowait(dev->data->port_id, &link);
2426 if (vf >= pci_dev->max_vfs)
2429 if (tx_rate > link.link_speed)
2435 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2436 vfinfo = *(IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private));
2437 nb_q_per_pool = RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool;
2438 queue_stride = IXGBE_MAX_RX_QUEUE_NUM / RTE_ETH_DEV_SRIOV(dev).active;
2439 queue_idx = vf * queue_stride;
2440 queue_end = queue_idx + nb_q_per_pool - 1;
2441 if (queue_end >= hw->mac.max_tx_queues)
2445 for (vf_idx = 0; vf_idx < pci_dev->max_vfs; vf_idx++) {
2448 for (idx = 0; idx < RTE_DIM(vfinfo[vf_idx].tx_rate);
2450 total_rate += vfinfo[vf_idx].tx_rate[idx];
2456 /* Store tx_rate for this vf. */
2457 for (idx = 0; idx < nb_q_per_pool; idx++) {
2458 if (((uint64_t)0x1 << idx) & q_msk) {
2459 if (vfinfo[vf].tx_rate[idx] != tx_rate)
2460 vfinfo[vf].tx_rate[idx] = tx_rate;
2461 total_rate += tx_rate;
2465 if (total_rate > dev->data->dev_link.link_speed) {
2466 /* Reset stored TX rate of the VF if it causes exceed
2469 memset(vfinfo[vf].tx_rate, 0, sizeof(vfinfo[vf].tx_rate));
2473 /* Set RTTBCNRC of each queue/pool for vf X */
2474 for (; queue_idx <= queue_end; queue_idx++) {
2476 ixgbe_set_queue_rate_limit(dev, queue_idx, tx_rate);
2484 * Configure device link speed and setup link.
2485 * It returns 0 on success.
2488 ixgbe_dev_start(struct rte_eth_dev *dev)
2490 struct ixgbe_hw *hw =
2491 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2492 struct ixgbe_vf_info *vfinfo =
2493 *IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private);
2494 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
2495 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
2496 uint32_t intr_vector = 0;
2497 int err, link_up = 0, negotiate = 0;
2502 uint32_t *link_speeds;
2503 struct ixgbe_tm_conf *tm_conf =
2504 IXGBE_DEV_PRIVATE_TO_TM_CONF(dev->data->dev_private);
2506 PMD_INIT_FUNC_TRACE();
2508 /* IXGBE devices don't support:
2509 * - half duplex (checked afterwards for valid speeds)
2510 * - fixed speed: TODO implement
2512 if (dev->data->dev_conf.link_speeds & ETH_LINK_SPEED_FIXED) {
2513 PMD_INIT_LOG(ERR, "Invalid link_speeds for port %hhu; fix speed not supported",
2514 dev->data->port_id);
2518 /* disable uio/vfio intr/eventfd mapping */
2519 rte_intr_disable(intr_handle);
2522 hw->adapter_stopped = 0;
2523 ixgbe_stop_adapter(hw);
2525 /* reinitialize adapter
2526 * this calls reset and start
2528 status = ixgbe_pf_reset_hw(hw);
2531 hw->mac.ops.start_hw(hw);
2532 hw->mac.get_link_status = true;
2534 /* configure PF module if SRIOV enabled */
2535 ixgbe_pf_host_configure(dev);
2537 ixgbe_dev_phy_intr_setup(dev);
2539 /* check and configure queue intr-vector mapping */
2540 if ((rte_intr_cap_multiple(intr_handle) ||
2541 !RTE_ETH_DEV_SRIOV(dev).active) &&
2542 dev->data->dev_conf.intr_conf.rxq != 0) {
2543 intr_vector = dev->data->nb_rx_queues;
2544 if (intr_vector > IXGBE_MAX_INTR_QUEUE_NUM) {
2545 PMD_INIT_LOG(ERR, "At most %d intr queues supported",
2546 IXGBE_MAX_INTR_QUEUE_NUM);
2549 if (rte_intr_efd_enable(intr_handle, intr_vector))
2553 if (rte_intr_dp_is_en(intr_handle) && !intr_handle->intr_vec) {
2554 intr_handle->intr_vec =
2555 rte_zmalloc("intr_vec",
2556 dev->data->nb_rx_queues * sizeof(int), 0);
2557 if (intr_handle->intr_vec == NULL) {
2558 PMD_INIT_LOG(ERR, "Failed to allocate %d rx_queues"
2559 " intr_vec", dev->data->nb_rx_queues);
2564 /* confiugre msix for sleep until rx interrupt */
2565 ixgbe_configure_msix(dev);
2567 /* initialize transmission unit */
2568 ixgbe_dev_tx_init(dev);
2570 /* This can fail when allocating mbufs for descriptor rings */
2571 err = ixgbe_dev_rx_init(dev);
2573 PMD_INIT_LOG(ERR, "Unable to initialize RX hardware");
2577 mask = ETH_VLAN_STRIP_MASK | ETH_VLAN_FILTER_MASK |
2578 ETH_VLAN_EXTEND_MASK;
2579 ixgbe_vlan_offload_set(dev, mask);
2581 if (dev->data->dev_conf.rxmode.mq_mode == ETH_MQ_RX_VMDQ_ONLY) {
2582 /* Enable vlan filtering for VMDq */
2583 ixgbe_vmdq_vlan_hw_filter_enable(dev);
2586 /* Configure DCB hw */
2587 ixgbe_configure_dcb(dev);
2589 if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_NONE) {
2590 err = ixgbe_fdir_configure(dev);
2595 /* Restore vf rate limit */
2596 if (vfinfo != NULL) {
2597 for (vf = 0; vf < pci_dev->max_vfs; vf++)
2598 for (idx = 0; idx < IXGBE_MAX_QUEUE_NUM_PER_VF; idx++)
2599 if (vfinfo[vf].tx_rate[idx] != 0)
2600 ixgbe_set_vf_rate_limit(
2602 vfinfo[vf].tx_rate[idx],
2606 ixgbe_restore_statistics_mapping(dev);
2608 err = ixgbe_dev_rxtx_start(dev);
2610 PMD_INIT_LOG(ERR, "Unable to start rxtx queues");
2614 /* Skip link setup if loopback mode is enabled for 82599. */
2615 if (hw->mac.type == ixgbe_mac_82599EB &&
2616 dev->data->dev_conf.lpbk_mode == IXGBE_LPBK_82599_TX_RX)
2617 goto skip_link_setup;
2619 if (ixgbe_is_sfp(hw) && hw->phy.multispeed_fiber) {
2620 err = hw->mac.ops.setup_sfp(hw);
2625 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper) {
2626 /* Turn on the copper */
2627 ixgbe_set_phy_power(hw, true);
2629 /* Turn on the laser */
2630 ixgbe_enable_tx_laser(hw);
2633 err = ixgbe_check_link(hw, &speed, &link_up, 0);
2636 dev->data->dev_link.link_status = link_up;
2638 err = ixgbe_get_link_capabilities(hw, &speed, &negotiate);
2642 link_speeds = &dev->data->dev_conf.link_speeds;
2643 if (*link_speeds & ~(ETH_LINK_SPEED_100M | ETH_LINK_SPEED_1G |
2644 ETH_LINK_SPEED_10G)) {
2645 PMD_INIT_LOG(ERR, "Invalid link setting");
2650 if (*link_speeds == ETH_LINK_SPEED_AUTONEG) {
2651 speed = (hw->mac.type != ixgbe_mac_82598EB) ?
2652 IXGBE_LINK_SPEED_82599_AUTONEG :
2653 IXGBE_LINK_SPEED_82598_AUTONEG;
2655 if (*link_speeds & ETH_LINK_SPEED_10G)
2656 speed |= IXGBE_LINK_SPEED_10GB_FULL;
2657 if (*link_speeds & ETH_LINK_SPEED_1G)
2658 speed |= IXGBE_LINK_SPEED_1GB_FULL;
2659 if (*link_speeds & ETH_LINK_SPEED_100M)
2660 speed |= IXGBE_LINK_SPEED_100_FULL;
2663 err = ixgbe_setup_link(hw, speed, link_up);
2669 if (rte_intr_allow_others(intr_handle)) {
2670 /* check if lsc interrupt is enabled */
2671 if (dev->data->dev_conf.intr_conf.lsc != 0)
2672 ixgbe_dev_lsc_interrupt_setup(dev);
2673 ixgbe_dev_macsec_interrupt_setup(dev);
2675 rte_intr_callback_unregister(intr_handle,
2676 ixgbe_dev_interrupt_handler, dev);
2677 if (dev->data->dev_conf.intr_conf.lsc != 0)
2678 PMD_INIT_LOG(INFO, "lsc won't enable because of"
2679 " no intr multiplex");
2682 /* check if rxq interrupt is enabled */
2683 if (dev->data->dev_conf.intr_conf.rxq != 0 &&
2684 rte_intr_dp_is_en(intr_handle))
2685 ixgbe_dev_rxq_interrupt_setup(dev);
2687 /* enable uio/vfio intr/eventfd mapping */
2688 rte_intr_enable(intr_handle);
2690 /* resume enabled intr since hw reset */
2691 ixgbe_enable_intr(dev);
2692 ixgbe_l2_tunnel_conf(dev);
2693 ixgbe_filter_restore(dev);
2695 if (!tm_conf->committed)
2696 PMD_DRV_LOG(WARNING,
2697 "please call hierarchy_commit() "
2698 "before starting the port");
2703 PMD_INIT_LOG(ERR, "failure in ixgbe_dev_start(): %d", err);
2704 ixgbe_dev_clear_queues(dev);
2709 * Stop device: disable rx and tx functions to allow for reconfiguring.
2712 ixgbe_dev_stop(struct rte_eth_dev *dev)
2714 struct rte_eth_link link;
2715 struct ixgbe_hw *hw =
2716 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2717 struct ixgbe_vf_info *vfinfo =
2718 *IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private);
2719 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
2720 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
2722 struct ixgbe_tm_conf *tm_conf =
2723 IXGBE_DEV_PRIVATE_TO_TM_CONF(dev->data->dev_private);
2725 PMD_INIT_FUNC_TRACE();
2727 /* disable interrupts */
2728 ixgbe_disable_intr(hw);
2731 ixgbe_pf_reset_hw(hw);
2732 hw->adapter_stopped = 0;
2735 ixgbe_stop_adapter(hw);
2737 for (vf = 0; vfinfo != NULL && vf < pci_dev->max_vfs; vf++)
2738 vfinfo[vf].clear_to_send = false;
2740 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper) {
2741 /* Turn off the copper */
2742 ixgbe_set_phy_power(hw, false);
2744 /* Turn off the laser */
2745 ixgbe_disable_tx_laser(hw);
2748 ixgbe_dev_clear_queues(dev);
2750 /* Clear stored conf */
2751 dev->data->scattered_rx = 0;
2754 /* Clear recorded link status */
2755 memset(&link, 0, sizeof(link));
2756 rte_ixgbe_dev_atomic_write_link_status(dev, &link);
2758 if (!rte_intr_allow_others(intr_handle))
2759 /* resume to the default handler */
2760 rte_intr_callback_register(intr_handle,
2761 ixgbe_dev_interrupt_handler,
2764 /* Clean datapath event and queue/vec mapping */
2765 rte_intr_efd_disable(intr_handle);
2766 if (intr_handle->intr_vec != NULL) {
2767 rte_free(intr_handle->intr_vec);
2768 intr_handle->intr_vec = NULL;
2771 /* reset hierarchy commit */
2772 tm_conf->committed = false;
2776 * Set device link up: enable tx.
2779 ixgbe_dev_set_link_up(struct rte_eth_dev *dev)
2781 struct ixgbe_hw *hw =
2782 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2783 if (hw->mac.type == ixgbe_mac_82599EB) {
2784 #ifdef RTE_LIBRTE_IXGBE_BYPASS
2785 if (hw->device_id == IXGBE_DEV_ID_82599_BYPASS) {
2786 /* Not suported in bypass mode */
2787 PMD_INIT_LOG(ERR, "Set link up is not supported "
2788 "by device id 0x%x", hw->device_id);
2794 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper) {
2795 /* Turn on the copper */
2796 ixgbe_set_phy_power(hw, true);
2798 /* Turn on the laser */
2799 ixgbe_enable_tx_laser(hw);
2806 * Set device link down: disable tx.
2809 ixgbe_dev_set_link_down(struct rte_eth_dev *dev)
2811 struct ixgbe_hw *hw =
2812 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2813 if (hw->mac.type == ixgbe_mac_82599EB) {
2814 #ifdef RTE_LIBRTE_IXGBE_BYPASS
2815 if (hw->device_id == IXGBE_DEV_ID_82599_BYPASS) {
2816 /* Not suported in bypass mode */
2817 PMD_INIT_LOG(ERR, "Set link down is not supported "
2818 "by device id 0x%x", hw->device_id);
2824 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper) {
2825 /* Turn off the copper */
2826 ixgbe_set_phy_power(hw, false);
2828 /* Turn off the laser */
2829 ixgbe_disable_tx_laser(hw);
2836 * Reest and stop device.
2839 ixgbe_dev_close(struct rte_eth_dev *dev)
2841 struct ixgbe_hw *hw =
2842 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2844 PMD_INIT_FUNC_TRACE();
2846 ixgbe_pf_reset_hw(hw);
2848 ixgbe_dev_stop(dev);
2849 hw->adapter_stopped = 1;
2851 ixgbe_dev_free_queues(dev);
2853 ixgbe_disable_pcie_master(hw);
2855 /* reprogram the RAR[0] in case user changed it. */
2856 ixgbe_set_rar(hw, 0, hw->mac.addr, 0, IXGBE_RAH_AV);
2860 ixgbe_read_stats_registers(struct ixgbe_hw *hw,
2861 struct ixgbe_hw_stats *hw_stats,
2862 struct ixgbe_macsec_stats *macsec_stats,
2863 uint64_t *total_missed_rx, uint64_t *total_qbrc,
2864 uint64_t *total_qprc, uint64_t *total_qprdc)
2866 uint32_t bprc, lxon, lxoff, total;
2867 uint32_t delta_gprc = 0;
2869 /* Workaround for RX byte count not including CRC bytes when CRC
2870 * strip is enabled. CRC bytes are removed from counters when crc_strip
2873 int crc_strip = (IXGBE_READ_REG(hw, IXGBE_HLREG0) &
2874 IXGBE_HLREG0_RXCRCSTRP);
2876 hw_stats->crcerrs += IXGBE_READ_REG(hw, IXGBE_CRCERRS);
2877 hw_stats->illerrc += IXGBE_READ_REG(hw, IXGBE_ILLERRC);
2878 hw_stats->errbc += IXGBE_READ_REG(hw, IXGBE_ERRBC);
2879 hw_stats->mspdc += IXGBE_READ_REG(hw, IXGBE_MSPDC);
2881 for (i = 0; i < 8; i++) {
2882 uint32_t mp = IXGBE_READ_REG(hw, IXGBE_MPC(i));
2884 /* global total per queue */
2885 hw_stats->mpc[i] += mp;
2886 /* Running comprehensive total for stats display */
2887 *total_missed_rx += hw_stats->mpc[i];
2888 if (hw->mac.type == ixgbe_mac_82598EB) {
2889 hw_stats->rnbc[i] +=
2890 IXGBE_READ_REG(hw, IXGBE_RNBC(i));
2891 hw_stats->pxonrxc[i] +=
2892 IXGBE_READ_REG(hw, IXGBE_PXONRXC(i));
2893 hw_stats->pxoffrxc[i] +=
2894 IXGBE_READ_REG(hw, IXGBE_PXOFFRXC(i));
2896 hw_stats->pxonrxc[i] +=
2897 IXGBE_READ_REG(hw, IXGBE_PXONRXCNT(i));
2898 hw_stats->pxoffrxc[i] +=
2899 IXGBE_READ_REG(hw, IXGBE_PXOFFRXCNT(i));
2900 hw_stats->pxon2offc[i] +=
2901 IXGBE_READ_REG(hw, IXGBE_PXON2OFFCNT(i));
2903 hw_stats->pxontxc[i] +=
2904 IXGBE_READ_REG(hw, IXGBE_PXONTXC(i));
2905 hw_stats->pxofftxc[i] +=
2906 IXGBE_READ_REG(hw, IXGBE_PXOFFTXC(i));
2908 for (i = 0; i < IXGBE_QUEUE_STAT_COUNTERS; i++) {
2909 uint32_t delta_qprc = IXGBE_READ_REG(hw, IXGBE_QPRC(i));
2910 uint32_t delta_qptc = IXGBE_READ_REG(hw, IXGBE_QPTC(i));
2911 uint32_t delta_qprdc = IXGBE_READ_REG(hw, IXGBE_QPRDC(i));
2913 delta_gprc += delta_qprc;
2915 hw_stats->qprc[i] += delta_qprc;
2916 hw_stats->qptc[i] += delta_qptc;
2918 hw_stats->qbrc[i] += IXGBE_READ_REG(hw, IXGBE_QBRC_L(i));
2919 hw_stats->qbrc[i] +=
2920 ((uint64_t)IXGBE_READ_REG(hw, IXGBE_QBRC_H(i)) << 32);
2922 hw_stats->qbrc[i] -= delta_qprc * ETHER_CRC_LEN;
2924 hw_stats->qbtc[i] += IXGBE_READ_REG(hw, IXGBE_QBTC_L(i));
2925 hw_stats->qbtc[i] +=
2926 ((uint64_t)IXGBE_READ_REG(hw, IXGBE_QBTC_H(i)) << 32);
2928 hw_stats->qprdc[i] += delta_qprdc;
2929 *total_qprdc += hw_stats->qprdc[i];
2931 *total_qprc += hw_stats->qprc[i];
2932 *total_qbrc += hw_stats->qbrc[i];
2934 hw_stats->mlfc += IXGBE_READ_REG(hw, IXGBE_MLFC);
2935 hw_stats->mrfc += IXGBE_READ_REG(hw, IXGBE_MRFC);
2936 hw_stats->rlec += IXGBE_READ_REG(hw, IXGBE_RLEC);
2939 * An errata states that gprc actually counts good + missed packets:
2940 * Workaround to set gprc to summated queue packet receives
2942 hw_stats->gprc = *total_qprc;
2944 if (hw->mac.type != ixgbe_mac_82598EB) {
2945 hw_stats->gorc += IXGBE_READ_REG(hw, IXGBE_GORCL);
2946 hw_stats->gorc += ((u64)IXGBE_READ_REG(hw, IXGBE_GORCH) << 32);
2947 hw_stats->gotc += IXGBE_READ_REG(hw, IXGBE_GOTCL);
2948 hw_stats->gotc += ((u64)IXGBE_READ_REG(hw, IXGBE_GOTCH) << 32);
2949 hw_stats->tor += IXGBE_READ_REG(hw, IXGBE_TORL);
2950 hw_stats->tor += ((u64)IXGBE_READ_REG(hw, IXGBE_TORH) << 32);
2951 hw_stats->lxonrxc += IXGBE_READ_REG(hw, IXGBE_LXONRXCNT);
2952 hw_stats->lxoffrxc += IXGBE_READ_REG(hw, IXGBE_LXOFFRXCNT);
2954 hw_stats->lxonrxc += IXGBE_READ_REG(hw, IXGBE_LXONRXC);
2955 hw_stats->lxoffrxc += IXGBE_READ_REG(hw, IXGBE_LXOFFRXC);
2956 /* 82598 only has a counter in the high register */
2957 hw_stats->gorc += IXGBE_READ_REG(hw, IXGBE_GORCH);
2958 hw_stats->gotc += IXGBE_READ_REG(hw, IXGBE_GOTCH);
2959 hw_stats->tor += IXGBE_READ_REG(hw, IXGBE_TORH);
2961 uint64_t old_tpr = hw_stats->tpr;
2963 hw_stats->tpr += IXGBE_READ_REG(hw, IXGBE_TPR);
2964 hw_stats->tpt += IXGBE_READ_REG(hw, IXGBE_TPT);
2967 hw_stats->gorc -= delta_gprc * ETHER_CRC_LEN;
2969 uint64_t delta_gptc = IXGBE_READ_REG(hw, IXGBE_GPTC);
2970 hw_stats->gptc += delta_gptc;
2971 hw_stats->gotc -= delta_gptc * ETHER_CRC_LEN;
2972 hw_stats->tor -= (hw_stats->tpr - old_tpr) * ETHER_CRC_LEN;
2975 * Workaround: mprc hardware is incorrectly counting
2976 * broadcasts, so for now we subtract those.
2978 bprc = IXGBE_READ_REG(hw, IXGBE_BPRC);
2979 hw_stats->bprc += bprc;
2980 hw_stats->mprc += IXGBE_READ_REG(hw, IXGBE_MPRC);
2981 if (hw->mac.type == ixgbe_mac_82598EB)
2982 hw_stats->mprc -= bprc;
2984 hw_stats->prc64 += IXGBE_READ_REG(hw, IXGBE_PRC64);
2985 hw_stats->prc127 += IXGBE_READ_REG(hw, IXGBE_PRC127);
2986 hw_stats->prc255 += IXGBE_READ_REG(hw, IXGBE_PRC255);
2987 hw_stats->prc511 += IXGBE_READ_REG(hw, IXGBE_PRC511);
2988 hw_stats->prc1023 += IXGBE_READ_REG(hw, IXGBE_PRC1023);
2989 hw_stats->prc1522 += IXGBE_READ_REG(hw, IXGBE_PRC1522);
2991 lxon = IXGBE_READ_REG(hw, IXGBE_LXONTXC);
2992 hw_stats->lxontxc += lxon;
2993 lxoff = IXGBE_READ_REG(hw, IXGBE_LXOFFTXC);
2994 hw_stats->lxofftxc += lxoff;
2995 total = lxon + lxoff;
2997 hw_stats->mptc += IXGBE_READ_REG(hw, IXGBE_MPTC);
2998 hw_stats->ptc64 += IXGBE_READ_REG(hw, IXGBE_PTC64);
2999 hw_stats->gptc -= total;
3000 hw_stats->mptc -= total;
3001 hw_stats->ptc64 -= total;
3002 hw_stats->gotc -= total * ETHER_MIN_LEN;
3004 hw_stats->ruc += IXGBE_READ_REG(hw, IXGBE_RUC);
3005 hw_stats->rfc += IXGBE_READ_REG(hw, IXGBE_RFC);
3006 hw_stats->roc += IXGBE_READ_REG(hw, IXGBE_ROC);
3007 hw_stats->rjc += IXGBE_READ_REG(hw, IXGBE_RJC);
3008 hw_stats->mngprc += IXGBE_READ_REG(hw, IXGBE_MNGPRC);
3009 hw_stats->mngpdc += IXGBE_READ_REG(hw, IXGBE_MNGPDC);
3010 hw_stats->mngptc += IXGBE_READ_REG(hw, IXGBE_MNGPTC);
3011 hw_stats->ptc127 += IXGBE_READ_REG(hw, IXGBE_PTC127);
3012 hw_stats->ptc255 += IXGBE_READ_REG(hw, IXGBE_PTC255);
3013 hw_stats->ptc511 += IXGBE_READ_REG(hw, IXGBE_PTC511);
3014 hw_stats->ptc1023 += IXGBE_READ_REG(hw, IXGBE_PTC1023);
3015 hw_stats->ptc1522 += IXGBE_READ_REG(hw, IXGBE_PTC1522);
3016 hw_stats->bptc += IXGBE_READ_REG(hw, IXGBE_BPTC);
3017 hw_stats->xec += IXGBE_READ_REG(hw, IXGBE_XEC);
3018 hw_stats->fccrc += IXGBE_READ_REG(hw, IXGBE_FCCRC);
3019 hw_stats->fclast += IXGBE_READ_REG(hw, IXGBE_FCLAST);
3020 /* Only read FCOE on 82599 */
3021 if (hw->mac.type != ixgbe_mac_82598EB) {
3022 hw_stats->fcoerpdc += IXGBE_READ_REG(hw, IXGBE_FCOERPDC);
3023 hw_stats->fcoeprc += IXGBE_READ_REG(hw, IXGBE_FCOEPRC);
3024 hw_stats->fcoeptc += IXGBE_READ_REG(hw, IXGBE_FCOEPTC);
3025 hw_stats->fcoedwrc += IXGBE_READ_REG(hw, IXGBE_FCOEDWRC);
3026 hw_stats->fcoedwtc += IXGBE_READ_REG(hw, IXGBE_FCOEDWTC);
3029 /* Flow Director Stats registers */
3030 hw_stats->fdirmatch += IXGBE_READ_REG(hw, IXGBE_FDIRMATCH);
3031 hw_stats->fdirmiss += IXGBE_READ_REG(hw, IXGBE_FDIRMISS);
3033 /* MACsec Stats registers */
3034 macsec_stats->out_pkts_untagged += IXGBE_READ_REG(hw, IXGBE_LSECTXUT);
3035 macsec_stats->out_pkts_encrypted +=
3036 IXGBE_READ_REG(hw, IXGBE_LSECTXPKTE);
3037 macsec_stats->out_pkts_protected +=
3038 IXGBE_READ_REG(hw, IXGBE_LSECTXPKTP);
3039 macsec_stats->out_octets_encrypted +=
3040 IXGBE_READ_REG(hw, IXGBE_LSECTXOCTE);
3041 macsec_stats->out_octets_protected +=
3042 IXGBE_READ_REG(hw, IXGBE_LSECTXOCTP);
3043 macsec_stats->in_pkts_untagged += IXGBE_READ_REG(hw, IXGBE_LSECRXUT);
3044 macsec_stats->in_pkts_badtag += IXGBE_READ_REG(hw, IXGBE_LSECRXBAD);
3045 macsec_stats->in_pkts_nosci += IXGBE_READ_REG(hw, IXGBE_LSECRXNOSCI);
3046 macsec_stats->in_pkts_unknownsci +=
3047 IXGBE_READ_REG(hw, IXGBE_LSECRXUNSCI);
3048 macsec_stats->in_octets_decrypted +=
3049 IXGBE_READ_REG(hw, IXGBE_LSECRXOCTD);
3050 macsec_stats->in_octets_validated +=
3051 IXGBE_READ_REG(hw, IXGBE_LSECRXOCTV);
3052 macsec_stats->in_pkts_unchecked += IXGBE_READ_REG(hw, IXGBE_LSECRXUNCH);
3053 macsec_stats->in_pkts_delayed += IXGBE_READ_REG(hw, IXGBE_LSECRXDELAY);
3054 macsec_stats->in_pkts_late += IXGBE_READ_REG(hw, IXGBE_LSECRXLATE);
3055 for (i = 0; i < 2; i++) {
3056 macsec_stats->in_pkts_ok +=
3057 IXGBE_READ_REG(hw, IXGBE_LSECRXOK(i));
3058 macsec_stats->in_pkts_invalid +=
3059 IXGBE_READ_REG(hw, IXGBE_LSECRXINV(i));
3060 macsec_stats->in_pkts_notvalid +=
3061 IXGBE_READ_REG(hw, IXGBE_LSECRXNV(i));
3063 macsec_stats->in_pkts_unusedsa += IXGBE_READ_REG(hw, IXGBE_LSECRXUNSA);
3064 macsec_stats->in_pkts_notusingsa +=
3065 IXGBE_READ_REG(hw, IXGBE_LSECRXNUSA);
3069 * This function is based on ixgbe_update_stats_counters() in ixgbe/ixgbe.c
3072 ixgbe_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
3074 struct ixgbe_hw *hw =
3075 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3076 struct ixgbe_hw_stats *hw_stats =
3077 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3078 struct ixgbe_macsec_stats *macsec_stats =
3079 IXGBE_DEV_PRIVATE_TO_MACSEC_STATS(
3080 dev->data->dev_private);
3081 uint64_t total_missed_rx, total_qbrc, total_qprc, total_qprdc;
3084 total_missed_rx = 0;
3089 ixgbe_read_stats_registers(hw, hw_stats, macsec_stats, &total_missed_rx,
3090 &total_qbrc, &total_qprc, &total_qprdc);
3095 /* Fill out the rte_eth_stats statistics structure */
3096 stats->ipackets = total_qprc;
3097 stats->ibytes = total_qbrc;
3098 stats->opackets = hw_stats->gptc;
3099 stats->obytes = hw_stats->gotc;
3101 for (i = 0; i < IXGBE_QUEUE_STAT_COUNTERS; i++) {
3102 stats->q_ipackets[i] = hw_stats->qprc[i];
3103 stats->q_opackets[i] = hw_stats->qptc[i];
3104 stats->q_ibytes[i] = hw_stats->qbrc[i];
3105 stats->q_obytes[i] = hw_stats->qbtc[i];
3106 stats->q_errors[i] = hw_stats->qprdc[i];
3110 stats->imissed = total_missed_rx;
3111 stats->ierrors = hw_stats->crcerrs +
3127 ixgbe_dev_stats_reset(struct rte_eth_dev *dev)
3129 struct ixgbe_hw_stats *stats =
3130 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3132 /* HW registers are cleared on read */
3133 ixgbe_dev_stats_get(dev, NULL);
3135 /* Reset software totals */
3136 memset(stats, 0, sizeof(*stats));
3139 /* This function calculates the number of xstats based on the current config */
3141 ixgbe_xstats_calc_num(void) {
3142 return IXGBE_NB_HW_STATS + IXGBE_NB_MACSEC_STATS +
3143 (IXGBE_NB_RXQ_PRIO_STATS * IXGBE_NB_RXQ_PRIO_VALUES) +
3144 (IXGBE_NB_TXQ_PRIO_STATS * IXGBE_NB_TXQ_PRIO_VALUES);
3147 static int ixgbe_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
3148 struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned int size)
3150 const unsigned cnt_stats = ixgbe_xstats_calc_num();
3151 unsigned stat, i, count;
3153 if (xstats_names != NULL) {
3156 /* Note: limit >= cnt_stats checked upstream
3157 * in rte_eth_xstats_names()
3160 /* Extended stats from ixgbe_hw_stats */
3161 for (i = 0; i < IXGBE_NB_HW_STATS; i++) {
3162 snprintf(xstats_names[count].name,
3163 sizeof(xstats_names[count].name),
3165 rte_ixgbe_stats_strings[i].name);
3170 for (i = 0; i < IXGBE_NB_MACSEC_STATS; i++) {
3171 snprintf(xstats_names[count].name,
3172 sizeof(xstats_names[count].name),
3174 rte_ixgbe_macsec_strings[i].name);
3178 /* RX Priority Stats */
3179 for (stat = 0; stat < IXGBE_NB_RXQ_PRIO_STATS; stat++) {
3180 for (i = 0; i < IXGBE_NB_RXQ_PRIO_VALUES; i++) {
3181 snprintf(xstats_names[count].name,
3182 sizeof(xstats_names[count].name),
3183 "rx_priority%u_%s", i,
3184 rte_ixgbe_rxq_strings[stat].name);
3189 /* TX Priority Stats */
3190 for (stat = 0; stat < IXGBE_NB_TXQ_PRIO_STATS; stat++) {
3191 for (i = 0; i < IXGBE_NB_TXQ_PRIO_VALUES; i++) {
3192 snprintf(xstats_names[count].name,
3193 sizeof(xstats_names[count].name),
3194 "tx_priority%u_%s", i,
3195 rte_ixgbe_txq_strings[stat].name);
3203 static int ixgbe_dev_xstats_get_names_by_id(
3204 struct rte_eth_dev *dev,
3205 struct rte_eth_xstat_name *xstats_names,
3206 const uint64_t *ids,
3210 const unsigned int cnt_stats = ixgbe_xstats_calc_num();
3211 unsigned int stat, i, count;
3213 if (xstats_names != NULL) {
3216 /* Note: limit >= cnt_stats checked upstream
3217 * in rte_eth_xstats_names()
3220 /* Extended stats from ixgbe_hw_stats */
3221 for (i = 0; i < IXGBE_NB_HW_STATS; i++) {
3222 snprintf(xstats_names[count].name,
3223 sizeof(xstats_names[count].name),
3225 rte_ixgbe_stats_strings[i].name);
3230 for (i = 0; i < IXGBE_NB_MACSEC_STATS; i++) {
3231 snprintf(xstats_names[count].name,
3232 sizeof(xstats_names[count].name),
3234 rte_ixgbe_macsec_strings[i].name);
3238 /* RX Priority Stats */
3239 for (stat = 0; stat < IXGBE_NB_RXQ_PRIO_STATS; stat++) {
3240 for (i = 0; i < IXGBE_NB_RXQ_PRIO_VALUES; i++) {
3241 snprintf(xstats_names[count].name,
3242 sizeof(xstats_names[count].name),
3243 "rx_priority%u_%s", i,
3244 rte_ixgbe_rxq_strings[stat].name);
3249 /* TX Priority Stats */
3250 for (stat = 0; stat < IXGBE_NB_TXQ_PRIO_STATS; stat++) {
3251 for (i = 0; i < IXGBE_NB_TXQ_PRIO_VALUES; i++) {
3252 snprintf(xstats_names[count].name,
3253 sizeof(xstats_names[count].name),
3254 "tx_priority%u_%s", i,
3255 rte_ixgbe_txq_strings[stat].name);
3264 uint16_t size = ixgbe_xstats_calc_num();
3265 struct rte_eth_xstat_name xstats_names_copy[size];
3267 ixgbe_dev_xstats_get_names_by_id(dev, xstats_names_copy, NULL,
3270 for (i = 0; i < limit; i++) {
3271 if (ids[i] >= size) {
3272 PMD_INIT_LOG(ERR, "id value isn't valid");
3275 strcpy(xstats_names[i].name,
3276 xstats_names_copy[ids[i]].name);
3281 static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
3282 struct rte_eth_xstat_name *xstats_names, unsigned limit)
3286 if (limit < IXGBEVF_NB_XSTATS && xstats_names != NULL)
3289 if (xstats_names != NULL)
3290 for (i = 0; i < IXGBEVF_NB_XSTATS; i++)
3291 snprintf(xstats_names[i].name,
3292 sizeof(xstats_names[i].name),
3293 "%s", rte_ixgbevf_stats_strings[i].name);
3294 return IXGBEVF_NB_XSTATS;
3298 ixgbe_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
3301 struct ixgbe_hw *hw =
3302 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3303 struct ixgbe_hw_stats *hw_stats =
3304 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3305 struct ixgbe_macsec_stats *macsec_stats =
3306 IXGBE_DEV_PRIVATE_TO_MACSEC_STATS(
3307 dev->data->dev_private);
3308 uint64_t total_missed_rx, total_qbrc, total_qprc, total_qprdc;
3309 unsigned i, stat, count = 0;
3311 count = ixgbe_xstats_calc_num();
3316 total_missed_rx = 0;
3321 ixgbe_read_stats_registers(hw, hw_stats, macsec_stats, &total_missed_rx,
3322 &total_qbrc, &total_qprc, &total_qprdc);
3324 /* If this is a reset xstats is NULL, and we have cleared the
3325 * registers by reading them.
3330 /* Extended stats from ixgbe_hw_stats */
3332 for (i = 0; i < IXGBE_NB_HW_STATS; i++) {
3333 xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
3334 rte_ixgbe_stats_strings[i].offset);
3335 xstats[count].id = count;
3340 for (i = 0; i < IXGBE_NB_MACSEC_STATS; i++) {
3341 xstats[count].value = *(uint64_t *)(((char *)macsec_stats) +
3342 rte_ixgbe_macsec_strings[i].offset);
3343 xstats[count].id = count;
3347 /* RX Priority Stats */
3348 for (stat = 0; stat < IXGBE_NB_RXQ_PRIO_STATS; stat++) {
3349 for (i = 0; i < IXGBE_NB_RXQ_PRIO_VALUES; i++) {
3350 xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
3351 rte_ixgbe_rxq_strings[stat].offset +
3352 (sizeof(uint64_t) * i));
3353 xstats[count].id = count;
3358 /* TX Priority Stats */
3359 for (stat = 0; stat < IXGBE_NB_TXQ_PRIO_STATS; stat++) {
3360 for (i = 0; i < IXGBE_NB_TXQ_PRIO_VALUES; i++) {
3361 xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
3362 rte_ixgbe_txq_strings[stat].offset +
3363 (sizeof(uint64_t) * i));
3364 xstats[count].id = count;
3372 ixgbe_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids,
3373 uint64_t *values, unsigned int n)
3376 struct ixgbe_hw *hw =
3377 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3378 struct ixgbe_hw_stats *hw_stats =
3379 IXGBE_DEV_PRIVATE_TO_STATS(
3380 dev->data->dev_private);
3381 struct ixgbe_macsec_stats *macsec_stats =
3382 IXGBE_DEV_PRIVATE_TO_MACSEC_STATS(
3383 dev->data->dev_private);
3384 uint64_t total_missed_rx, total_qbrc, total_qprc, total_qprdc;
3385 unsigned int i, stat, count = 0;
3387 count = ixgbe_xstats_calc_num();
3389 if (!ids && n < count)
3392 total_missed_rx = 0;
3397 ixgbe_read_stats_registers(hw, hw_stats, macsec_stats,
3398 &total_missed_rx, &total_qbrc, &total_qprc,
3401 /* If this is a reset xstats is NULL, and we have cleared the
3402 * registers by reading them.
3404 if (!ids && !values)
3407 /* Extended stats from ixgbe_hw_stats */
3409 for (i = 0; i < IXGBE_NB_HW_STATS; i++) {
3410 values[count] = *(uint64_t *)(((char *)hw_stats) +
3411 rte_ixgbe_stats_strings[i].offset);
3416 for (i = 0; i < IXGBE_NB_MACSEC_STATS; i++) {
3417 values[count] = *(uint64_t *)(((char *)macsec_stats) +
3418 rte_ixgbe_macsec_strings[i].offset);
3422 /* RX Priority Stats */
3423 for (stat = 0; stat < IXGBE_NB_RXQ_PRIO_STATS; stat++) {
3424 for (i = 0; i < IXGBE_NB_RXQ_PRIO_VALUES; i++) {
3426 *(uint64_t *)(((char *)hw_stats) +
3427 rte_ixgbe_rxq_strings[stat].offset +
3428 (sizeof(uint64_t) * i));
3433 /* TX Priority Stats */
3434 for (stat = 0; stat < IXGBE_NB_TXQ_PRIO_STATS; stat++) {
3435 for (i = 0; i < IXGBE_NB_TXQ_PRIO_VALUES; i++) {
3437 *(uint64_t *)(((char *)hw_stats) +
3438 rte_ixgbe_txq_strings[stat].offset +
3439 (sizeof(uint64_t) * i));
3447 uint16_t size = ixgbe_xstats_calc_num();
3448 uint64_t values_copy[size];
3450 ixgbe_dev_xstats_get_by_id(dev, NULL, values_copy, size);
3452 for (i = 0; i < n; i++) {
3453 if (ids[i] >= size) {
3454 PMD_INIT_LOG(ERR, "id value isn't valid");
3457 values[i] = values_copy[ids[i]];
3463 ixgbe_dev_xstats_reset(struct rte_eth_dev *dev)
3465 struct ixgbe_hw_stats *stats =
3466 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3467 struct ixgbe_macsec_stats *macsec_stats =
3468 IXGBE_DEV_PRIVATE_TO_MACSEC_STATS(
3469 dev->data->dev_private);
3471 unsigned count = ixgbe_xstats_calc_num();
3473 /* HW registers are cleared on read */
3474 ixgbe_dev_xstats_get(dev, NULL, count);
3476 /* Reset software totals */
3477 memset(stats, 0, sizeof(*stats));
3478 memset(macsec_stats, 0, sizeof(*macsec_stats));
3482 ixgbevf_update_stats(struct rte_eth_dev *dev)
3484 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3485 struct ixgbevf_hw_stats *hw_stats = (struct ixgbevf_hw_stats *)
3486 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3488 /* Good Rx packet, include VF loopback */
3489 UPDATE_VF_STAT(IXGBE_VFGPRC,
3490 hw_stats->last_vfgprc, hw_stats->vfgprc);
3492 /* Good Rx octets, include VF loopback */
3493 UPDATE_VF_STAT_36BIT(IXGBE_VFGORC_LSB, IXGBE_VFGORC_MSB,
3494 hw_stats->last_vfgorc, hw_stats->vfgorc);
3496 /* Good Tx packet, include VF loopback */
3497 UPDATE_VF_STAT(IXGBE_VFGPTC,
3498 hw_stats->last_vfgptc, hw_stats->vfgptc);
3500 /* Good Tx octets, include VF loopback */
3501 UPDATE_VF_STAT_36BIT(IXGBE_VFGOTC_LSB, IXGBE_VFGOTC_MSB,
3502 hw_stats->last_vfgotc, hw_stats->vfgotc);
3504 /* Rx Multicst Packet */
3505 UPDATE_VF_STAT(IXGBE_VFMPRC,
3506 hw_stats->last_vfmprc, hw_stats->vfmprc);
3510 ixgbevf_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
3513 struct ixgbevf_hw_stats *hw_stats = (struct ixgbevf_hw_stats *)
3514 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3517 if (n < IXGBEVF_NB_XSTATS)
3518 return IXGBEVF_NB_XSTATS;
3520 ixgbevf_update_stats(dev);
3525 /* Extended stats */
3526 for (i = 0; i < IXGBEVF_NB_XSTATS; i++) {
3528 xstats[i].value = *(uint64_t *)(((char *)hw_stats) +
3529 rte_ixgbevf_stats_strings[i].offset);
3532 return IXGBEVF_NB_XSTATS;
3536 ixgbevf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
3538 struct ixgbevf_hw_stats *hw_stats = (struct ixgbevf_hw_stats *)
3539 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3541 ixgbevf_update_stats(dev);
3546 stats->ipackets = hw_stats->vfgprc;
3547 stats->ibytes = hw_stats->vfgorc;
3548 stats->opackets = hw_stats->vfgptc;
3549 stats->obytes = hw_stats->vfgotc;
3553 ixgbevf_dev_stats_reset(struct rte_eth_dev *dev)
3555 struct ixgbevf_hw_stats *hw_stats = (struct ixgbevf_hw_stats *)
3556 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3558 /* Sync HW register to the last stats */
3559 ixgbevf_dev_stats_get(dev, NULL);
3561 /* reset HW current stats*/
3562 hw_stats->vfgprc = 0;
3563 hw_stats->vfgorc = 0;
3564 hw_stats->vfgptc = 0;
3565 hw_stats->vfgotc = 0;
3569 ixgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size)
3571 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3572 u16 eeprom_verh, eeprom_verl;
3576 ixgbe_read_eeprom(hw, 0x2e, &eeprom_verh);
3577 ixgbe_read_eeprom(hw, 0x2d, &eeprom_verl);
3579 etrack_id = (eeprom_verh << 16) | eeprom_verl;
3580 ret = snprintf(fw_version, fw_size, "0x%08x", etrack_id);
3582 ret += 1; /* add the size of '\0' */
3583 if (fw_size < (u32)ret)
3590 ixgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
3592 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
3593 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3594 struct rte_eth_conf *dev_conf = &dev->data->dev_conf;
3596 dev_info->pci_dev = pci_dev;
3597 dev_info->max_rx_queues = (uint16_t)hw->mac.max_rx_queues;
3598 dev_info->max_tx_queues = (uint16_t)hw->mac.max_tx_queues;
3599 if (RTE_ETH_DEV_SRIOV(dev).active == 0) {
3601 * When DCB/VT is off, maximum number of queues changes,
3602 * except for 82598EB, which remains constant.
3604 if (dev_conf->txmode.mq_mode == ETH_MQ_TX_NONE &&
3605 hw->mac.type != ixgbe_mac_82598EB)
3606 dev_info->max_tx_queues = IXGBE_NONE_MODE_TX_NB_QUEUES;
3608 dev_info->min_rx_bufsize = 1024; /* cf BSIZEPACKET in SRRCTL register */
3609 dev_info->max_rx_pktlen = 15872; /* includes CRC, cf MAXFRS register */
3610 dev_info->max_mac_addrs = hw->mac.num_rar_entries;
3611 dev_info->max_hash_mac_addrs = IXGBE_VMDQ_NUM_UC_MAC;
3612 dev_info->max_vfs = pci_dev->max_vfs;
3613 if (hw->mac.type == ixgbe_mac_82598EB)
3614 dev_info->max_vmdq_pools = ETH_16_POOLS;
3616 dev_info->max_vmdq_pools = ETH_64_POOLS;
3617 dev_info->vmdq_queue_num = dev_info->max_rx_queues;
3618 dev_info->rx_offload_capa =
3619 DEV_RX_OFFLOAD_VLAN_STRIP |
3620 DEV_RX_OFFLOAD_IPV4_CKSUM |
3621 DEV_RX_OFFLOAD_UDP_CKSUM |
3622 DEV_RX_OFFLOAD_TCP_CKSUM;
3625 * RSC is only supported by 82599 and x540 PF devices in a non-SR-IOV
3628 if ((hw->mac.type == ixgbe_mac_82599EB ||
3629 hw->mac.type == ixgbe_mac_X540) &&
3630 !RTE_ETH_DEV_SRIOV(dev).active)
3631 dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_TCP_LRO;
3633 if (hw->mac.type == ixgbe_mac_82599EB ||
3634 hw->mac.type == ixgbe_mac_X540)
3635 dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_MACSEC_STRIP;
3637 if (hw->mac.type == ixgbe_mac_X550 ||
3638 hw->mac.type == ixgbe_mac_X550EM_x ||
3639 hw->mac.type == ixgbe_mac_X550EM_a)
3640 dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM;
3642 dev_info->tx_offload_capa =
3643 DEV_TX_OFFLOAD_VLAN_INSERT |
3644 DEV_TX_OFFLOAD_IPV4_CKSUM |
3645 DEV_TX_OFFLOAD_UDP_CKSUM |
3646 DEV_TX_OFFLOAD_TCP_CKSUM |
3647 DEV_TX_OFFLOAD_SCTP_CKSUM |
3648 DEV_TX_OFFLOAD_TCP_TSO;
3650 if (hw->mac.type == ixgbe_mac_82599EB ||
3651 hw->mac.type == ixgbe_mac_X540)
3652 dev_info->tx_offload_capa |= DEV_TX_OFFLOAD_MACSEC_INSERT;
3654 if (hw->mac.type == ixgbe_mac_X550 ||
3655 hw->mac.type == ixgbe_mac_X550EM_x ||
3656 hw->mac.type == ixgbe_mac_X550EM_a)
3657 dev_info->tx_offload_capa |= DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
3659 dev_info->default_rxconf = (struct rte_eth_rxconf) {
3661 .pthresh = IXGBE_DEFAULT_RX_PTHRESH,
3662 .hthresh = IXGBE_DEFAULT_RX_HTHRESH,
3663 .wthresh = IXGBE_DEFAULT_RX_WTHRESH,
3665 .rx_free_thresh = IXGBE_DEFAULT_RX_FREE_THRESH,
3669 dev_info->default_txconf = (struct rte_eth_txconf) {
3671 .pthresh = IXGBE_DEFAULT_TX_PTHRESH,
3672 .hthresh = IXGBE_DEFAULT_TX_HTHRESH,
3673 .wthresh = IXGBE_DEFAULT_TX_WTHRESH,
3675 .tx_free_thresh = IXGBE_DEFAULT_TX_FREE_THRESH,
3676 .tx_rs_thresh = IXGBE_DEFAULT_TX_RSBIT_THRESH,
3677 .txq_flags = ETH_TXQ_FLAGS_NOMULTSEGS |
3678 ETH_TXQ_FLAGS_NOOFFLOADS,
3681 dev_info->rx_desc_lim = rx_desc_lim;
3682 dev_info->tx_desc_lim = tx_desc_lim;
3684 dev_info->hash_key_size = IXGBE_HKEY_MAX_INDEX * sizeof(uint32_t);
3685 dev_info->reta_size = ixgbe_reta_size_get(hw->mac.type);
3686 dev_info->flow_type_rss_offloads = IXGBE_RSS_OFFLOAD_ALL;
3688 dev_info->speed_capa = ETH_LINK_SPEED_1G | ETH_LINK_SPEED_10G;
3689 if (hw->mac.type == ixgbe_mac_X540 ||
3690 hw->mac.type == ixgbe_mac_X540_vf ||
3691 hw->mac.type == ixgbe_mac_X550 ||
3692 hw->mac.type == ixgbe_mac_X550_vf) {
3693 dev_info->speed_capa |= ETH_LINK_SPEED_100M;
3697 static const uint32_t *
3698 ixgbe_dev_supported_ptypes_get(struct rte_eth_dev *dev)
3700 static const uint32_t ptypes[] = {
3701 /* For non-vec functions,
3702 * refers to ixgbe_rxd_pkt_info_to_pkt_type();
3703 * for vec functions,
3704 * refers to _recv_raw_pkts_vec().
3708 RTE_PTYPE_L3_IPV4_EXT,
3710 RTE_PTYPE_L3_IPV6_EXT,
3714 RTE_PTYPE_TUNNEL_IP,
3715 RTE_PTYPE_INNER_L3_IPV6,
3716 RTE_PTYPE_INNER_L3_IPV6_EXT,
3717 RTE_PTYPE_INNER_L4_TCP,
3718 RTE_PTYPE_INNER_L4_UDP,
3722 if (dev->rx_pkt_burst == ixgbe_recv_pkts ||
3723 dev->rx_pkt_burst == ixgbe_recv_pkts_lro_single_alloc ||
3724 dev->rx_pkt_burst == ixgbe_recv_pkts_lro_bulk_alloc ||
3725 dev->rx_pkt_burst == ixgbe_recv_pkts_bulk_alloc)
3728 #if defined(RTE_ARCH_X86)
3729 if (dev->rx_pkt_burst == ixgbe_recv_pkts_vec ||
3730 dev->rx_pkt_burst == ixgbe_recv_scattered_pkts_vec)
3737 ixgbevf_dev_info_get(struct rte_eth_dev *dev,
3738 struct rte_eth_dev_info *dev_info)
3740 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
3741 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3743 dev_info->pci_dev = pci_dev;
3744 dev_info->max_rx_queues = (uint16_t)hw->mac.max_rx_queues;
3745 dev_info->max_tx_queues = (uint16_t)hw->mac.max_tx_queues;
3746 dev_info->min_rx_bufsize = 1024; /* cf BSIZEPACKET in SRRCTL reg */
3747 dev_info->max_rx_pktlen = 9728; /* includes CRC, cf MAXFRS reg */
3748 dev_info->max_mac_addrs = hw->mac.num_rar_entries;
3749 dev_info->max_hash_mac_addrs = IXGBE_VMDQ_NUM_UC_MAC;
3750 dev_info->max_vfs = pci_dev->max_vfs;
3751 if (hw->mac.type == ixgbe_mac_82598EB)
3752 dev_info->max_vmdq_pools = ETH_16_POOLS;
3754 dev_info->max_vmdq_pools = ETH_64_POOLS;
3755 dev_info->rx_offload_capa = DEV_RX_OFFLOAD_VLAN_STRIP |
3756 DEV_RX_OFFLOAD_IPV4_CKSUM |
3757 DEV_RX_OFFLOAD_UDP_CKSUM |
3758 DEV_RX_OFFLOAD_TCP_CKSUM;
3759 dev_info->tx_offload_capa = DEV_TX_OFFLOAD_VLAN_INSERT |
3760 DEV_TX_OFFLOAD_IPV4_CKSUM |
3761 DEV_TX_OFFLOAD_UDP_CKSUM |
3762 DEV_TX_OFFLOAD_TCP_CKSUM |
3763 DEV_TX_OFFLOAD_SCTP_CKSUM |
3764 DEV_TX_OFFLOAD_TCP_TSO;
3766 dev_info->default_rxconf = (struct rte_eth_rxconf) {
3768 .pthresh = IXGBE_DEFAULT_RX_PTHRESH,
3769 .hthresh = IXGBE_DEFAULT_RX_HTHRESH,
3770 .wthresh = IXGBE_DEFAULT_RX_WTHRESH,
3772 .rx_free_thresh = IXGBE_DEFAULT_RX_FREE_THRESH,
3776 dev_info->default_txconf = (struct rte_eth_txconf) {
3778 .pthresh = IXGBE_DEFAULT_TX_PTHRESH,
3779 .hthresh = IXGBE_DEFAULT_TX_HTHRESH,
3780 .wthresh = IXGBE_DEFAULT_TX_WTHRESH,
3782 .tx_free_thresh = IXGBE_DEFAULT_TX_FREE_THRESH,
3783 .tx_rs_thresh = IXGBE_DEFAULT_TX_RSBIT_THRESH,
3784 .txq_flags = ETH_TXQ_FLAGS_NOMULTSEGS |
3785 ETH_TXQ_FLAGS_NOOFFLOADS,
3788 dev_info->rx_desc_lim = rx_desc_lim;
3789 dev_info->tx_desc_lim = tx_desc_lim;
3793 ixgbevf_check_link(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
3794 int *link_up, int wait_to_complete)
3797 * for a quick link status checking, wait_to_compelet == 0,
3798 * skip PF link status checking
3800 bool no_pflink_check = wait_to_complete == 0;
3801 struct ixgbe_mbx_info *mbx = &hw->mbx;
3802 struct ixgbe_mac_info *mac = &hw->mac;
3803 uint32_t links_reg, in_msg;
3806 /* If we were hit with a reset drop the link */
3807 if (!mbx->ops.check_for_rst(hw, 0) || !mbx->timeout)
3808 mac->get_link_status = true;
3810 if (!mac->get_link_status)
3813 /* if link status is down no point in checking to see if pf is up */
3814 links_reg = IXGBE_READ_REG(hw, IXGBE_VFLINKS);
3815 if (!(links_reg & IXGBE_LINKS_UP))
3818 /* for SFP+ modules and DA cables on 82599 it can take up to 500usecs
3819 * before the link status is correct
3821 if (mac->type == ixgbe_mac_82599_vf) {
3824 for (i = 0; i < 5; i++) {
3826 links_reg = IXGBE_READ_REG(hw, IXGBE_VFLINKS);
3828 if (!(links_reg & IXGBE_LINKS_UP))
3833 switch (links_reg & IXGBE_LINKS_SPEED_82599) {
3834 case IXGBE_LINKS_SPEED_10G_82599:
3835 *speed = IXGBE_LINK_SPEED_10GB_FULL;
3836 if (hw->mac.type >= ixgbe_mac_X550) {
3837 if (links_reg & IXGBE_LINKS_SPEED_NON_STD)
3838 *speed = IXGBE_LINK_SPEED_2_5GB_FULL;
3841 case IXGBE_LINKS_SPEED_1G_82599:
3842 *speed = IXGBE_LINK_SPEED_1GB_FULL;
3844 case IXGBE_LINKS_SPEED_100_82599:
3845 *speed = IXGBE_LINK_SPEED_100_FULL;
3846 if (hw->mac.type == ixgbe_mac_X550) {
3847 if (links_reg & IXGBE_LINKS_SPEED_NON_STD)
3848 *speed = IXGBE_LINK_SPEED_5GB_FULL;
3851 case IXGBE_LINKS_SPEED_10_X550EM_A:
3852 *speed = IXGBE_LINK_SPEED_UNKNOWN;
3853 /* Since Reserved in older MAC's */
3854 if (hw->mac.type >= ixgbe_mac_X550)
3855 *speed = IXGBE_LINK_SPEED_10_FULL;
3858 *speed = IXGBE_LINK_SPEED_UNKNOWN;
3861 if (no_pflink_check) {
3862 if (*speed == IXGBE_LINK_SPEED_UNKNOWN)
3863 mac->get_link_status = true;
3865 mac->get_link_status = false;
3869 /* if the read failed it could just be a mailbox collision, best wait
3870 * until we are called again and don't report an error
3872 if (mbx->ops.read(hw, &in_msg, 1, 0))
3875 if (!(in_msg & IXGBE_VT_MSGTYPE_CTS)) {
3876 /* msg is not CTS and is NACK we must have lost CTS status */
3877 if (in_msg & IXGBE_VT_MSGTYPE_NACK)
3882 /* the pf is talking, if we timed out in the past we reinit */
3883 if (!mbx->timeout) {
3888 /* if we passed all the tests above then the link is up and we no
3889 * longer need to check for link
3891 mac->get_link_status = false;
3894 *link_up = !mac->get_link_status;
3898 /* return 0 means link status changed, -1 means not changed */
3900 ixgbe_dev_link_update_share(struct rte_eth_dev *dev,
3901 int wait_to_complete, int vf)
3903 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3904 struct rte_eth_link link, old;
3905 ixgbe_link_speed link_speed = IXGBE_LINK_SPEED_UNKNOWN;
3906 struct ixgbe_interrupt *intr =
3907 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
3912 bool autoneg = false;
3914 link.link_status = ETH_LINK_DOWN;
3915 link.link_speed = 0;
3916 link.link_duplex = ETH_LINK_HALF_DUPLEX;
3917 memset(&old, 0, sizeof(old));
3918 rte_ixgbe_dev_atomic_read_link_status(dev, &old);
3920 hw->mac.get_link_status = true;
3922 if ((intr->flags & IXGBE_FLAG_NEED_LINK_CONFIG) &&
3923 ixgbe_get_media_type(hw) == ixgbe_media_type_fiber) {
3924 speed = hw->phy.autoneg_advertised;
3926 ixgbe_get_link_capabilities(hw, &speed, &autoneg);
3927 ixgbe_setup_link(hw, speed, true);
3930 /* check if it needs to wait to complete, if lsc interrupt is enabled */
3931 if (wait_to_complete == 0 || dev->data->dev_conf.intr_conf.lsc != 0)
3935 diag = ixgbevf_check_link(hw, &link_speed, &link_up, wait);
3937 diag = ixgbe_check_link(hw, &link_speed, &link_up, wait);
3940 link.link_speed = ETH_SPEED_NUM_100M;
3941 link.link_duplex = ETH_LINK_FULL_DUPLEX;
3942 rte_ixgbe_dev_atomic_write_link_status(dev, &link);
3943 if (link.link_status == old.link_status)
3949 rte_ixgbe_dev_atomic_write_link_status(dev, &link);
3950 intr->flags |= IXGBE_FLAG_NEED_LINK_CONFIG;
3951 if (link.link_status == old.link_status)
3955 intr->flags &= ~IXGBE_FLAG_NEED_LINK_CONFIG;
3956 link.link_status = ETH_LINK_UP;
3957 link.link_duplex = ETH_LINK_FULL_DUPLEX;
3959 switch (link_speed) {
3961 case IXGBE_LINK_SPEED_UNKNOWN:
3962 link.link_duplex = ETH_LINK_FULL_DUPLEX;
3963 link.link_speed = ETH_SPEED_NUM_100M;
3966 case IXGBE_LINK_SPEED_100_FULL:
3967 link.link_speed = ETH_SPEED_NUM_100M;
3970 case IXGBE_LINK_SPEED_1GB_FULL:
3971 link.link_speed = ETH_SPEED_NUM_1G;
3974 case IXGBE_LINK_SPEED_10GB_FULL:
3975 link.link_speed = ETH_SPEED_NUM_10G;
3978 rte_ixgbe_dev_atomic_write_link_status(dev, &link);
3980 if (link.link_status == old.link_status)
3987 ixgbe_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
3989 return ixgbe_dev_link_update_share(dev, wait_to_complete, 0);
3993 ixgbevf_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
3995 return ixgbe_dev_link_update_share(dev, wait_to_complete, 1);
3999 ixgbe_dev_promiscuous_enable(struct rte_eth_dev *dev)
4001 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4004 fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
4005 fctrl |= (IXGBE_FCTRL_UPE | IXGBE_FCTRL_MPE);
4006 IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
4010 ixgbe_dev_promiscuous_disable(struct rte_eth_dev *dev)
4012 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4015 fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
4016 fctrl &= (~IXGBE_FCTRL_UPE);
4017 if (dev->data->all_multicast == 1)
4018 fctrl |= IXGBE_FCTRL_MPE;
4020 fctrl &= (~IXGBE_FCTRL_MPE);
4021 IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
4025 ixgbe_dev_allmulticast_enable(struct rte_eth_dev *dev)
4027 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4030 fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
4031 fctrl |= IXGBE_FCTRL_MPE;
4032 IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
4036 ixgbe_dev_allmulticast_disable(struct rte_eth_dev *dev)
4038 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4041 if (dev->data->promiscuous == 1)
4042 return; /* must remain in all_multicast mode */
4044 fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
4045 fctrl &= (~IXGBE_FCTRL_MPE);
4046 IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
4050 * It clears the interrupt causes and enables the interrupt.
4051 * It will be called once only during nic initialized.
4054 * Pointer to struct rte_eth_dev.
4057 * - On success, zero.
4058 * - On failure, a negative value.
4061 ixgbe_dev_lsc_interrupt_setup(struct rte_eth_dev *dev)
4063 struct ixgbe_interrupt *intr =
4064 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
4066 ixgbe_dev_link_status_print(dev);
4067 intr->mask |= IXGBE_EICR_LSC;
4073 * It clears the interrupt causes and enables the interrupt.
4074 * It will be called once only during nic initialized.
4077 * Pointer to struct rte_eth_dev.
4080 * - On success, zero.
4081 * - On failure, a negative value.
4084 ixgbe_dev_rxq_interrupt_setup(struct rte_eth_dev *dev)
4086 struct ixgbe_interrupt *intr =
4087 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
4089 intr->mask |= IXGBE_EICR_RTX_QUEUE;
4095 * It clears the interrupt causes and enables the interrupt.
4096 * It will be called once only during nic initialized.
4099 * Pointer to struct rte_eth_dev.
4102 * - On success, zero.
4103 * - On failure, a negative value.
4106 ixgbe_dev_macsec_interrupt_setup(struct rte_eth_dev *dev)
4108 struct ixgbe_interrupt *intr =
4109 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
4111 intr->mask |= IXGBE_EICR_LINKSEC;
4117 * It reads ICR and sets flag (IXGBE_EICR_LSC) for the link_update.
4120 * Pointer to struct rte_eth_dev.
4123 * - On success, zero.
4124 * - On failure, a negative value.
4127 ixgbe_dev_interrupt_get_status(struct rte_eth_dev *dev)
4130 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4131 struct ixgbe_interrupt *intr =
4132 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
4134 /* clear all cause mask */
4135 ixgbe_disable_intr(hw);
4137 /* read-on-clear nic registers here */
4138 eicr = IXGBE_READ_REG(hw, IXGBE_EICR);
4139 PMD_DRV_LOG(DEBUG, "eicr %x", eicr);
4143 /* set flag for async link update */
4144 if (eicr & IXGBE_EICR_LSC)
4145 intr->flags |= IXGBE_FLAG_NEED_LINK_UPDATE;
4147 if (eicr & IXGBE_EICR_MAILBOX)
4148 intr->flags |= IXGBE_FLAG_MAILBOX;
4150 if (eicr & IXGBE_EICR_LINKSEC)
4151 intr->flags |= IXGBE_FLAG_MACSEC;
4153 if (hw->mac.type == ixgbe_mac_X550EM_x &&
4154 hw->phy.type == ixgbe_phy_x550em_ext_t &&
4155 (eicr & IXGBE_EICR_GPI_SDP0_X550EM_x))
4156 intr->flags |= IXGBE_FLAG_PHY_INTERRUPT;
4162 * It gets and then prints the link status.
4165 * Pointer to struct rte_eth_dev.
4168 * - On success, zero.
4169 * - On failure, a negative value.
4172 ixgbe_dev_link_status_print(struct rte_eth_dev *dev)
4174 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
4175 struct rte_eth_link link;
4177 memset(&link, 0, sizeof(link));
4178 rte_ixgbe_dev_atomic_read_link_status(dev, &link);
4179 if (link.link_status) {
4180 PMD_INIT_LOG(INFO, "Port %d: Link Up - speed %u Mbps - %s",
4181 (int)(dev->data->port_id),
4182 (unsigned)link.link_speed,
4183 link.link_duplex == ETH_LINK_FULL_DUPLEX ?
4184 "full-duplex" : "half-duplex");
4186 PMD_INIT_LOG(INFO, " Port %d: Link Down",
4187 (int)(dev->data->port_id));
4189 PMD_INIT_LOG(DEBUG, "PCI Address: " PCI_PRI_FMT,
4190 pci_dev->addr.domain,
4192 pci_dev->addr.devid,
4193 pci_dev->addr.function);
4197 * It executes link_update after knowing an interrupt occurred.
4200 * Pointer to struct rte_eth_dev.
4203 * - On success, zero.
4204 * - On failure, a negative value.
4207 ixgbe_dev_interrupt_action(struct rte_eth_dev *dev,
4208 struct rte_intr_handle *intr_handle)
4210 struct ixgbe_interrupt *intr =
4211 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
4213 struct rte_eth_link link;
4214 struct ixgbe_hw *hw =
4215 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4217 PMD_DRV_LOG(DEBUG, "intr action type %d", intr->flags);
4219 if (intr->flags & IXGBE_FLAG_MAILBOX) {
4220 ixgbe_pf_mbx_process(dev);
4221 intr->flags &= ~IXGBE_FLAG_MAILBOX;
4224 if (intr->flags & IXGBE_FLAG_PHY_INTERRUPT) {
4225 ixgbe_handle_lasi(hw);
4226 intr->flags &= ~IXGBE_FLAG_PHY_INTERRUPT;
4229 if (intr->flags & IXGBE_FLAG_NEED_LINK_UPDATE) {
4230 /* get the link status before link update, for predicting later */
4231 memset(&link, 0, sizeof(link));
4232 rte_ixgbe_dev_atomic_read_link_status(dev, &link);
4234 ixgbe_dev_link_update(dev, 0);
4237 if (!link.link_status)
4238 /* handle it 1 sec later, wait it being stable */
4239 timeout = IXGBE_LINK_UP_CHECK_TIMEOUT;
4240 /* likely to down */
4242 /* handle it 4 sec later, wait it being stable */
4243 timeout = IXGBE_LINK_DOWN_CHECK_TIMEOUT;
4245 ixgbe_dev_link_status_print(dev);
4246 if (rte_eal_alarm_set(timeout * 1000,
4247 ixgbe_dev_interrupt_delayed_handler, (void *)dev) < 0)
4248 PMD_DRV_LOG(ERR, "Error setting alarm");
4250 /* remember original mask */
4251 intr->mask_original = intr->mask;
4252 /* only disable lsc interrupt */
4253 intr->mask &= ~IXGBE_EIMS_LSC;
4257 PMD_DRV_LOG(DEBUG, "enable intr immediately");
4258 ixgbe_enable_intr(dev);
4259 rte_intr_enable(intr_handle);
4265 * Interrupt handler which shall be registered for alarm callback for delayed
4266 * handling specific interrupt to wait for the stable nic state. As the
4267 * NIC interrupt state is not stable for ixgbe after link is just down,
4268 * it needs to wait 4 seconds to get the stable status.
4271 * Pointer to interrupt handle.
4273 * The address of parameter (struct rte_eth_dev *) regsitered before.
4279 ixgbe_dev_interrupt_delayed_handler(void *param)
4281 struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
4282 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
4283 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
4284 struct ixgbe_interrupt *intr =
4285 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
4286 struct ixgbe_hw *hw =
4287 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4290 ixgbe_disable_intr(hw);
4292 eicr = IXGBE_READ_REG(hw, IXGBE_EICR);
4293 if (eicr & IXGBE_EICR_MAILBOX)
4294 ixgbe_pf_mbx_process(dev);
4296 if (intr->flags & IXGBE_FLAG_PHY_INTERRUPT) {
4297 ixgbe_handle_lasi(hw);
4298 intr->flags &= ~IXGBE_FLAG_PHY_INTERRUPT;
4301 if (intr->flags & IXGBE_FLAG_NEED_LINK_UPDATE) {
4302 ixgbe_dev_link_update(dev, 0);
4303 intr->flags &= ~IXGBE_FLAG_NEED_LINK_UPDATE;
4304 ixgbe_dev_link_status_print(dev);
4305 _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC,
4309 if (intr->flags & IXGBE_FLAG_MACSEC) {
4310 _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_MACSEC,
4312 intr->flags &= ~IXGBE_FLAG_MACSEC;
4315 /* restore original mask */
4316 intr->mask = intr->mask_original;
4317 intr->mask_original = 0;
4319 PMD_DRV_LOG(DEBUG, "enable intr in delayed handler S[%08x]", eicr);
4320 ixgbe_enable_intr(dev);
4321 rte_intr_enable(intr_handle);
4325 * Interrupt handler triggered by NIC for handling
4326 * specific interrupt.
4329 * Pointer to interrupt handle.
4331 * The address of parameter (struct rte_eth_dev *) regsitered before.
4337 ixgbe_dev_interrupt_handler(void *param)
4339 struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
4341 ixgbe_dev_interrupt_get_status(dev);
4342 ixgbe_dev_interrupt_action(dev, dev->intr_handle);
4346 ixgbe_dev_led_on(struct rte_eth_dev *dev)
4348 struct ixgbe_hw *hw;
4350 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4351 return ixgbe_led_on(hw, 0) == IXGBE_SUCCESS ? 0 : -ENOTSUP;
4355 ixgbe_dev_led_off(struct rte_eth_dev *dev)
4357 struct ixgbe_hw *hw;
4359 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4360 return ixgbe_led_off(hw, 0) == IXGBE_SUCCESS ? 0 : -ENOTSUP;
4364 ixgbe_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
4366 struct ixgbe_hw *hw;
4372 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4374 fc_conf->pause_time = hw->fc.pause_time;
4375 fc_conf->high_water = hw->fc.high_water[0];
4376 fc_conf->low_water = hw->fc.low_water[0];
4377 fc_conf->send_xon = hw->fc.send_xon;
4378 fc_conf->autoneg = !hw->fc.disable_fc_autoneg;
4381 * Return rx_pause status according to actual setting of
4384 mflcn_reg = IXGBE_READ_REG(hw, IXGBE_MFLCN);
4385 if (mflcn_reg & (IXGBE_MFLCN_RPFCE | IXGBE_MFLCN_RFCE))
4391 * Return tx_pause status according to actual setting of
4394 fccfg_reg = IXGBE_READ_REG(hw, IXGBE_FCCFG);
4395 if (fccfg_reg & (IXGBE_FCCFG_TFCE_802_3X | IXGBE_FCCFG_TFCE_PRIORITY))
4400 if (rx_pause && tx_pause)
4401 fc_conf->mode = RTE_FC_FULL;
4403 fc_conf->mode = RTE_FC_RX_PAUSE;
4405 fc_conf->mode = RTE_FC_TX_PAUSE;
4407 fc_conf->mode = RTE_FC_NONE;
4413 ixgbe_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
4415 struct ixgbe_hw *hw;
4417 uint32_t rx_buf_size;
4418 uint32_t max_high_water;
4420 enum ixgbe_fc_mode rte_fcmode_2_ixgbe_fcmode[] = {
4427 PMD_INIT_FUNC_TRACE();
4429 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4430 rx_buf_size = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(0));
4431 PMD_INIT_LOG(DEBUG, "Rx packet buffer size = 0x%x", rx_buf_size);
4434 * At least reserve one Ethernet frame for watermark
4435 * high_water/low_water in kilo bytes for ixgbe
4437 max_high_water = (rx_buf_size - ETHER_MAX_LEN) >> IXGBE_RXPBSIZE_SHIFT;
4438 if ((fc_conf->high_water > max_high_water) ||
4439 (fc_conf->high_water < fc_conf->low_water)) {
4440 PMD_INIT_LOG(ERR, "Invalid high/low water setup value in KB");
4441 PMD_INIT_LOG(ERR, "High_water must <= 0x%x", max_high_water);
4445 hw->fc.requested_mode = rte_fcmode_2_ixgbe_fcmode[fc_conf->mode];
4446 hw->fc.pause_time = fc_conf->pause_time;
4447 hw->fc.high_water[0] = fc_conf->high_water;
4448 hw->fc.low_water[0] = fc_conf->low_water;
4449 hw->fc.send_xon = fc_conf->send_xon;
4450 hw->fc.disable_fc_autoneg = !fc_conf->autoneg;
4452 err = ixgbe_fc_enable(hw);
4454 /* Not negotiated is not an error case */
4455 if ((err == IXGBE_SUCCESS) || (err == IXGBE_ERR_FC_NOT_NEGOTIATED)) {
4457 /* check if we want to forward MAC frames - driver doesn't have native
4458 * capability to do that, so we'll write the registers ourselves */
4460 mflcn = IXGBE_READ_REG(hw, IXGBE_MFLCN);
4462 /* set or clear MFLCN.PMCF bit depending on configuration */
4463 if (fc_conf->mac_ctrl_frame_fwd != 0)
4464 mflcn |= IXGBE_MFLCN_PMCF;
4466 mflcn &= ~IXGBE_MFLCN_PMCF;
4468 IXGBE_WRITE_REG(hw, IXGBE_MFLCN, mflcn);
4469 IXGBE_WRITE_FLUSH(hw);
4474 PMD_INIT_LOG(ERR, "ixgbe_fc_enable = 0x%x", err);
4479 * ixgbe_pfc_enable_generic - Enable flow control
4480 * @hw: pointer to hardware structure
4481 * @tc_num: traffic class number
4482 * Enable flow control according to the current settings.
4485 ixgbe_dcb_pfc_enable_generic(struct ixgbe_hw *hw, uint8_t tc_num)
4488 uint32_t mflcn_reg, fccfg_reg;
4490 uint32_t fcrtl, fcrth;
4494 /* Validate the water mark configuration */
4495 if (!hw->fc.pause_time) {
4496 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
4500 /* Low water mark of zero causes XOFF floods */
4501 if (hw->fc.current_mode & ixgbe_fc_tx_pause) {
4502 /* High/Low water can not be 0 */
4503 if ((!hw->fc.high_water[tc_num]) || (!hw->fc.low_water[tc_num])) {
4504 PMD_INIT_LOG(ERR, "Invalid water mark configuration");
4505 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
4509 if (hw->fc.low_water[tc_num] >= hw->fc.high_water[tc_num]) {
4510 PMD_INIT_LOG(ERR, "Invalid water mark configuration");
4511 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
4515 /* Negotiate the fc mode to use */
4516 ixgbe_fc_autoneg(hw);
4518 /* Disable any previous flow control settings */
4519 mflcn_reg = IXGBE_READ_REG(hw, IXGBE_MFLCN);
4520 mflcn_reg &= ~(IXGBE_MFLCN_RPFCE_SHIFT | IXGBE_MFLCN_RFCE|IXGBE_MFLCN_RPFCE);
4522 fccfg_reg = IXGBE_READ_REG(hw, IXGBE_FCCFG);
4523 fccfg_reg &= ~(IXGBE_FCCFG_TFCE_802_3X | IXGBE_FCCFG_TFCE_PRIORITY);
4525 switch (hw->fc.current_mode) {
4528 * If the count of enabled RX Priority Flow control >1,
4529 * and the TX pause can not be disabled
4532 for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
4533 reg = IXGBE_READ_REG(hw, IXGBE_FCRTH_82599(i));
4534 if (reg & IXGBE_FCRTH_FCEN)
4538 fccfg_reg |= IXGBE_FCCFG_TFCE_PRIORITY;
4540 case ixgbe_fc_rx_pause:
4542 * Rx Flow control is enabled and Tx Flow control is
4543 * disabled by software override. Since there really
4544 * isn't a way to advertise that we are capable of RX
4545 * Pause ONLY, we will advertise that we support both
4546 * symmetric and asymmetric Rx PAUSE. Later, we will
4547 * disable the adapter's ability to send PAUSE frames.
4549 mflcn_reg |= IXGBE_MFLCN_RPFCE;
4551 * If the count of enabled RX Priority Flow control >1,
4552 * and the TX pause can not be disabled
4555 for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
4556 reg = IXGBE_READ_REG(hw, IXGBE_FCRTH_82599(i));
4557 if (reg & IXGBE_FCRTH_FCEN)
4561 fccfg_reg |= IXGBE_FCCFG_TFCE_PRIORITY;
4563 case ixgbe_fc_tx_pause:
4565 * Tx Flow control is enabled, and Rx Flow control is
4566 * disabled by software override.
4568 fccfg_reg |= IXGBE_FCCFG_TFCE_PRIORITY;
4571 /* Flow control (both Rx and Tx) is enabled by SW override. */
4572 mflcn_reg |= IXGBE_MFLCN_RPFCE;
4573 fccfg_reg |= IXGBE_FCCFG_TFCE_PRIORITY;
4576 PMD_DRV_LOG(DEBUG, "Flow control param set incorrectly");
4577 ret_val = IXGBE_ERR_CONFIG;
4581 /* Set 802.3x based flow control settings. */
4582 mflcn_reg |= IXGBE_MFLCN_DPF;
4583 IXGBE_WRITE_REG(hw, IXGBE_MFLCN, mflcn_reg);
4584 IXGBE_WRITE_REG(hw, IXGBE_FCCFG, fccfg_reg);
4586 /* Set up and enable Rx high/low water mark thresholds, enable XON. */
4587 if ((hw->fc.current_mode & ixgbe_fc_tx_pause) &&
4588 hw->fc.high_water[tc_num]) {
4589 fcrtl = (hw->fc.low_water[tc_num] << 10) | IXGBE_FCRTL_XONE;
4590 IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(tc_num), fcrtl);
4591 fcrth = (hw->fc.high_water[tc_num] << 10) | IXGBE_FCRTH_FCEN;
4593 IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(tc_num), 0);
4595 * In order to prevent Tx hangs when the internal Tx
4596 * switch is enabled we must set the high water mark
4597 * to the maximum FCRTH value. This allows the Tx
4598 * switch to function even under heavy Rx workloads.
4600 fcrth = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(tc_num)) - 32;
4602 IXGBE_WRITE_REG(hw, IXGBE_FCRTH_82599(tc_num), fcrth);
4604 /* Configure pause time (2 TCs per register) */
4605 reg = hw->fc.pause_time * 0x00010001;
4606 for (i = 0; i < (IXGBE_DCB_MAX_TRAFFIC_CLASS / 2); i++)
4607 IXGBE_WRITE_REG(hw, IXGBE_FCTTV(i), reg);
4609 /* Configure flow control refresh threshold value */
4610 IXGBE_WRITE_REG(hw, IXGBE_FCRTV, hw->fc.pause_time / 2);
4617 ixgbe_dcb_pfc_enable(struct rte_eth_dev *dev, uint8_t tc_num)
4619 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4620 int32_t ret_val = IXGBE_NOT_IMPLEMENTED;
4622 if (hw->mac.type != ixgbe_mac_82598EB) {
4623 ret_val = ixgbe_dcb_pfc_enable_generic(hw, tc_num);
4629 ixgbe_priority_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_pfc_conf *pfc_conf)
4632 uint32_t rx_buf_size;
4633 uint32_t max_high_water;
4635 uint8_t map[IXGBE_DCB_MAX_USER_PRIORITY] = { 0 };
4636 struct ixgbe_hw *hw =
4637 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4638 struct ixgbe_dcb_config *dcb_config =
4639 IXGBE_DEV_PRIVATE_TO_DCB_CFG(dev->data->dev_private);
4641 enum ixgbe_fc_mode rte_fcmode_2_ixgbe_fcmode[] = {
4648 PMD_INIT_FUNC_TRACE();
4650 ixgbe_dcb_unpack_map_cee(dcb_config, IXGBE_DCB_RX_CONFIG, map);
4651 tc_num = map[pfc_conf->priority];
4652 rx_buf_size = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(tc_num));
4653 PMD_INIT_LOG(DEBUG, "Rx packet buffer size = 0x%x", rx_buf_size);
4655 * At least reserve one Ethernet frame for watermark
4656 * high_water/low_water in kilo bytes for ixgbe
4658 max_high_water = (rx_buf_size - ETHER_MAX_LEN) >> IXGBE_RXPBSIZE_SHIFT;
4659 if ((pfc_conf->fc.high_water > max_high_water) ||
4660 (pfc_conf->fc.high_water <= pfc_conf->fc.low_water)) {
4661 PMD_INIT_LOG(ERR, "Invalid high/low water setup value in KB");
4662 PMD_INIT_LOG(ERR, "High_water must <= 0x%x", max_high_water);
4666 hw->fc.requested_mode = rte_fcmode_2_ixgbe_fcmode[pfc_conf->fc.mode];
4667 hw->fc.pause_time = pfc_conf->fc.pause_time;
4668 hw->fc.send_xon = pfc_conf->fc.send_xon;
4669 hw->fc.low_water[tc_num] = pfc_conf->fc.low_water;
4670 hw->fc.high_water[tc_num] = pfc_conf->fc.high_water;
4672 err = ixgbe_dcb_pfc_enable(dev, tc_num);
4674 /* Not negotiated is not an error case */
4675 if ((err == IXGBE_SUCCESS) || (err == IXGBE_ERR_FC_NOT_NEGOTIATED))
4678 PMD_INIT_LOG(ERR, "ixgbe_dcb_pfc_enable = 0x%x", err);
4683 ixgbe_dev_rss_reta_update(struct rte_eth_dev *dev,
4684 struct rte_eth_rss_reta_entry64 *reta_conf,
4687 uint16_t i, sp_reta_size;
4690 uint16_t idx, shift;
4691 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4694 PMD_INIT_FUNC_TRACE();
4696 if (!ixgbe_rss_update_sp(hw->mac.type)) {
4697 PMD_DRV_LOG(ERR, "RSS reta update is not supported on this "
4702 sp_reta_size = ixgbe_reta_size_get(hw->mac.type);
4703 if (reta_size != sp_reta_size) {
4704 PMD_DRV_LOG(ERR, "The size of hash lookup table configured "
4705 "(%d) doesn't match the number hardware can supported "
4706 "(%d)", reta_size, sp_reta_size);
4710 for (i = 0; i < reta_size; i += IXGBE_4_BIT_WIDTH) {
4711 idx = i / RTE_RETA_GROUP_SIZE;
4712 shift = i % RTE_RETA_GROUP_SIZE;
4713 mask = (uint8_t)((reta_conf[idx].mask >> shift) &
4717 reta_reg = ixgbe_reta_reg_get(hw->mac.type, i);
4718 if (mask == IXGBE_4_BIT_MASK)
4721 r = IXGBE_READ_REG(hw, reta_reg);
4722 for (j = 0, reta = 0; j < IXGBE_4_BIT_WIDTH; j++) {
4723 if (mask & (0x1 << j))
4724 reta |= reta_conf[idx].reta[shift + j] <<
4727 reta |= r & (IXGBE_8_BIT_MASK <<
4730 IXGBE_WRITE_REG(hw, reta_reg, reta);
4737 ixgbe_dev_rss_reta_query(struct rte_eth_dev *dev,
4738 struct rte_eth_rss_reta_entry64 *reta_conf,
4741 uint16_t i, sp_reta_size;
4744 uint16_t idx, shift;
4745 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4748 PMD_INIT_FUNC_TRACE();
4749 sp_reta_size = ixgbe_reta_size_get(hw->mac.type);
4750 if (reta_size != sp_reta_size) {
4751 PMD_DRV_LOG(ERR, "The size of hash lookup table configured "
4752 "(%d) doesn't match the number hardware can supported "
4753 "(%d)", reta_size, sp_reta_size);
4757 for (i = 0; i < reta_size; i += IXGBE_4_BIT_WIDTH) {
4758 idx = i / RTE_RETA_GROUP_SIZE;
4759 shift = i % RTE_RETA_GROUP_SIZE;
4760 mask = (uint8_t)((reta_conf[idx].mask >> shift) &
4765 reta_reg = ixgbe_reta_reg_get(hw->mac.type, i);
4766 reta = IXGBE_READ_REG(hw, reta_reg);
4767 for (j = 0; j < IXGBE_4_BIT_WIDTH; j++) {
4768 if (mask & (0x1 << j))
4769 reta_conf[idx].reta[shift + j] =
4770 ((reta >> (CHAR_BIT * j)) &
4779 ixgbe_add_rar(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
4780 uint32_t index, uint32_t pool)
4782 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4783 uint32_t enable_addr = 1;
4785 return ixgbe_set_rar(hw, index, mac_addr->addr_bytes,
4790 ixgbe_remove_rar(struct rte_eth_dev *dev, uint32_t index)
4792 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4794 ixgbe_clear_rar(hw, index);
4798 ixgbe_set_default_mac_addr(struct rte_eth_dev *dev, struct ether_addr *addr)
4800 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
4802 ixgbe_remove_rar(dev, 0);
4804 ixgbe_add_rar(dev, addr, 0, pci_dev->max_vfs);
4808 is_device_supported(struct rte_eth_dev *dev, struct rte_pci_driver *drv)
4810 if (strcmp(dev->device->driver->name, drv->driver.name))
4817 is_ixgbe_supported(struct rte_eth_dev *dev)
4819 return is_device_supported(dev, &rte_ixgbe_pmd);
4823 ixgbe_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
4827 struct ixgbe_hw *hw;
4828 struct rte_eth_dev_info dev_info;
4829 uint32_t frame_size = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
4830 struct rte_eth_dev_data *dev_data = dev->data;
4832 ixgbe_dev_info_get(dev, &dev_info);
4834 /* check that mtu is within the allowed range */
4835 if ((mtu < ETHER_MIN_MTU) || (frame_size > dev_info.max_rx_pktlen))
4838 /* If device is started, refuse mtu that requires the support of
4839 * scattered packets when this feature has not been enabled before.
4841 if (dev_data->dev_started && !dev_data->scattered_rx &&
4842 (frame_size + 2 * IXGBE_VLAN_TAG_SIZE >
4843 dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM)) {
4844 PMD_INIT_LOG(ERR, "Stop port first.");
4848 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4849 hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
4851 /* switch to jumbo mode if needed */
4852 if (frame_size > ETHER_MAX_LEN) {
4853 dev->data->dev_conf.rxmode.jumbo_frame = 1;
4854 hlreg0 |= IXGBE_HLREG0_JUMBOEN;
4856 dev->data->dev_conf.rxmode.jumbo_frame = 0;
4857 hlreg0 &= ~IXGBE_HLREG0_JUMBOEN;
4859 IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
4861 /* update max frame size */
4862 dev->data->dev_conf.rxmode.max_rx_pkt_len = frame_size;
4864 maxfrs = IXGBE_READ_REG(hw, IXGBE_MAXFRS);
4865 maxfrs &= 0x0000FFFF;
4866 maxfrs |= (dev->data->dev_conf.rxmode.max_rx_pkt_len << 16);
4867 IXGBE_WRITE_REG(hw, IXGBE_MAXFRS, maxfrs);
4873 * Virtual Function operations
4876 ixgbevf_intr_disable(struct ixgbe_hw *hw)
4878 PMD_INIT_FUNC_TRACE();
4880 /* Clear interrupt mask to stop from interrupts being generated */
4881 IXGBE_WRITE_REG(hw, IXGBE_VTEIMC, IXGBE_VF_IRQ_CLEAR_MASK);
4883 IXGBE_WRITE_FLUSH(hw);
4887 ixgbevf_intr_enable(struct ixgbe_hw *hw)
4889 PMD_INIT_FUNC_TRACE();
4891 /* VF enable interrupt autoclean */
4892 IXGBE_WRITE_REG(hw, IXGBE_VTEIAM, IXGBE_VF_IRQ_ENABLE_MASK);
4893 IXGBE_WRITE_REG(hw, IXGBE_VTEIAC, IXGBE_VF_IRQ_ENABLE_MASK);
4894 IXGBE_WRITE_REG(hw, IXGBE_VTEIMS, IXGBE_VF_IRQ_ENABLE_MASK);
4896 IXGBE_WRITE_FLUSH(hw);
4900 ixgbevf_dev_configure(struct rte_eth_dev *dev)
4902 struct rte_eth_conf *conf = &dev->data->dev_conf;
4903 struct ixgbe_adapter *adapter =
4904 (struct ixgbe_adapter *)dev->data->dev_private;
4906 PMD_INIT_LOG(DEBUG, "Configured Virtual Function port id: %d",
4907 dev->data->port_id);
4910 * VF has no ability to enable/disable HW CRC
4911 * Keep the persistent behavior the same as Host PF
4913 #ifndef RTE_LIBRTE_IXGBE_PF_DISABLE_STRIP_CRC
4914 if (!conf->rxmode.hw_strip_crc) {
4915 PMD_INIT_LOG(NOTICE, "VF can't disable HW CRC Strip");
4916 conf->rxmode.hw_strip_crc = 1;
4919 if (conf->rxmode.hw_strip_crc) {
4920 PMD_INIT_LOG(NOTICE, "VF can't enable HW CRC Strip");
4921 conf->rxmode.hw_strip_crc = 0;
4926 * Initialize to TRUE. If any of Rx queues doesn't meet the bulk
4927 * allocation or vector Rx preconditions we will reset it.
4929 adapter->rx_bulk_alloc_allowed = true;
4930 adapter->rx_vec_allowed = true;
4936 ixgbevf_dev_start(struct rte_eth_dev *dev)
4938 struct ixgbe_hw *hw =
4939 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4940 uint32_t intr_vector = 0;
4941 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
4942 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
4946 PMD_INIT_FUNC_TRACE();
4948 hw->mac.ops.reset_hw(hw);
4949 hw->mac.get_link_status = true;
4951 /* negotiate mailbox API version to use with the PF. */
4952 ixgbevf_negotiate_api(hw);
4954 ixgbevf_dev_tx_init(dev);
4956 /* This can fail when allocating mbufs for descriptor rings */
4957 err = ixgbevf_dev_rx_init(dev);
4959 PMD_INIT_LOG(ERR, "Unable to initialize RX hardware (%d)", err);
4960 ixgbe_dev_clear_queues(dev);
4965 ixgbevf_set_vfta_all(dev, 1);
4968 mask = ETH_VLAN_STRIP_MASK | ETH_VLAN_FILTER_MASK |
4969 ETH_VLAN_EXTEND_MASK;
4970 ixgbevf_vlan_offload_set(dev, mask);
4972 ixgbevf_dev_rxtx_start(dev);
4974 /* check and configure queue intr-vector mapping */
4975 if (dev->data->dev_conf.intr_conf.rxq != 0) {
4976 intr_vector = dev->data->nb_rx_queues;
4977 if (rte_intr_efd_enable(intr_handle, intr_vector))
4981 if (rte_intr_dp_is_en(intr_handle) && !intr_handle->intr_vec) {
4982 intr_handle->intr_vec =
4983 rte_zmalloc("intr_vec",
4984 dev->data->nb_rx_queues * sizeof(int), 0);
4985 if (intr_handle->intr_vec == NULL) {
4986 PMD_INIT_LOG(ERR, "Failed to allocate %d rx_queues"
4987 " intr_vec", dev->data->nb_rx_queues);
4991 ixgbevf_configure_msix(dev);
4993 rte_intr_enable(intr_handle);
4995 /* Re-enable interrupt for VF */
4996 ixgbevf_intr_enable(hw);
5002 ixgbevf_dev_stop(struct rte_eth_dev *dev)
5004 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5005 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
5006 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
5008 PMD_INIT_FUNC_TRACE();
5010 ixgbevf_intr_disable(hw);
5012 hw->adapter_stopped = 1;
5013 ixgbe_stop_adapter(hw);
5016 * Clear what we set, but we still keep shadow_vfta to
5017 * restore after device starts
5019 ixgbevf_set_vfta_all(dev, 0);
5021 /* Clear stored conf */
5022 dev->data->scattered_rx = 0;
5024 ixgbe_dev_clear_queues(dev);
5026 /* Clean datapath event and queue/vec mapping */
5027 rte_intr_efd_disable(intr_handle);
5028 if (intr_handle->intr_vec != NULL) {
5029 rte_free(intr_handle->intr_vec);
5030 intr_handle->intr_vec = NULL;
5035 ixgbevf_dev_close(struct rte_eth_dev *dev)
5037 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5039 PMD_INIT_FUNC_TRACE();
5043 ixgbevf_dev_stop(dev);
5045 ixgbe_dev_free_queues(dev);
5048 * Remove the VF MAC address ro ensure
5049 * that the VF traffic goes to the PF
5050 * after stop, close and detach of the VF
5052 ixgbevf_remove_mac_addr(dev, 0);
5055 static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on)
5057 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5058 struct ixgbe_vfta *shadow_vfta =
5059 IXGBE_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
5060 int i = 0, j = 0, vfta = 0, mask = 1;
5062 for (i = 0; i < IXGBE_VFTA_SIZE; i++) {
5063 vfta = shadow_vfta->vfta[i];
5066 for (j = 0; j < 32; j++) {
5068 ixgbe_set_vfta(hw, (i<<5)+j, 0,
5078 ixgbevf_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
5080 struct ixgbe_hw *hw =
5081 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5082 struct ixgbe_vfta *shadow_vfta =
5083 IXGBE_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
5084 uint32_t vid_idx = 0;
5085 uint32_t vid_bit = 0;
5088 PMD_INIT_FUNC_TRACE();
5090 /* vind is not used in VF driver, set to 0, check ixgbe_set_vfta_vf */
5091 ret = ixgbe_set_vfta(hw, vlan_id, 0, !!on, false);
5093 PMD_INIT_LOG(ERR, "Unable to set VF vlan");
5096 vid_idx = (uint32_t) ((vlan_id >> 5) & 0x7F);
5097 vid_bit = (uint32_t) (1 << (vlan_id & 0x1F));
5099 /* Save what we set and retore it after device reset */
5101 shadow_vfta->vfta[vid_idx] |= vid_bit;
5103 shadow_vfta->vfta[vid_idx] &= ~vid_bit;
5109 ixgbevf_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue, int on)
5111 struct ixgbe_hw *hw =
5112 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5115 PMD_INIT_FUNC_TRACE();
5117 if (queue >= hw->mac.max_rx_queues)
5120 ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(queue));
5122 ctrl |= IXGBE_RXDCTL_VME;
5124 ctrl &= ~IXGBE_RXDCTL_VME;
5125 IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(queue), ctrl);
5127 ixgbe_vlan_hw_strip_bitmap_set(dev, queue, on);
5131 ixgbevf_vlan_offload_set(struct rte_eth_dev *dev, int mask)
5133 struct ixgbe_hw *hw =
5134 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5138 /* VF function only support hw strip feature, others are not support */
5139 if (mask & ETH_VLAN_STRIP_MASK) {
5140 on = !!(dev->data->dev_conf.rxmode.hw_vlan_strip);
5142 for (i = 0; i < hw->mac.max_rx_queues; i++)
5143 ixgbevf_vlan_strip_queue_set(dev, i, on);
5148 ixgbe_vt_check(struct ixgbe_hw *hw)
5152 /* if Virtualization Technology is enabled */
5153 reg_val = IXGBE_READ_REG(hw, IXGBE_VT_CTL);
5154 if (!(reg_val & IXGBE_VT_CTL_VT_ENABLE)) {
5155 PMD_INIT_LOG(ERR, "VT must be enabled for this setting");
5163 ixgbe_uta_vector(struct ixgbe_hw *hw, struct ether_addr *uc_addr)
5165 uint32_t vector = 0;
5167 switch (hw->mac.mc_filter_type) {
5168 case 0: /* use bits [47:36] of the address */
5169 vector = ((uc_addr->addr_bytes[4] >> 4) |
5170 (((uint16_t)uc_addr->addr_bytes[5]) << 4));
5172 case 1: /* use bits [46:35] of the address */
5173 vector = ((uc_addr->addr_bytes[4] >> 3) |
5174 (((uint16_t)uc_addr->addr_bytes[5]) << 5));
5176 case 2: /* use bits [45:34] of the address */
5177 vector = ((uc_addr->addr_bytes[4] >> 2) |
5178 (((uint16_t)uc_addr->addr_bytes[5]) << 6));
5180 case 3: /* use bits [43:32] of the address */
5181 vector = ((uc_addr->addr_bytes[4]) |
5182 (((uint16_t)uc_addr->addr_bytes[5]) << 8));
5184 default: /* Invalid mc_filter_type */
5188 /* vector can only be 12-bits or boundary will be exceeded */
5194 ixgbe_uc_hash_table_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
5202 const uint32_t ixgbe_uta_idx_mask = 0x7F;
5203 const uint32_t ixgbe_uta_bit_shift = 5;
5204 const uint32_t ixgbe_uta_bit_mask = (0x1 << ixgbe_uta_bit_shift) - 1;
5205 const uint32_t bit1 = 0x1;
5207 struct ixgbe_hw *hw =
5208 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5209 struct ixgbe_uta_info *uta_info =
5210 IXGBE_DEV_PRIVATE_TO_UTA(dev->data->dev_private);
5212 /* The UTA table only exists on 82599 hardware and newer */
5213 if (hw->mac.type < ixgbe_mac_82599EB)
5216 vector = ixgbe_uta_vector(hw, mac_addr);
5217 uta_idx = (vector >> ixgbe_uta_bit_shift) & ixgbe_uta_idx_mask;
5218 uta_shift = vector & ixgbe_uta_bit_mask;
5220 rc = ((uta_info->uta_shadow[uta_idx] >> uta_shift & bit1) != 0);
5224 reg_val = IXGBE_READ_REG(hw, IXGBE_UTA(uta_idx));
5226 uta_info->uta_in_use++;
5227 reg_val |= (bit1 << uta_shift);
5228 uta_info->uta_shadow[uta_idx] |= (bit1 << uta_shift);
5230 uta_info->uta_in_use--;
5231 reg_val &= ~(bit1 << uta_shift);
5232 uta_info->uta_shadow[uta_idx] &= ~(bit1 << uta_shift);
5235 IXGBE_WRITE_REG(hw, IXGBE_UTA(uta_idx), reg_val);
5237 if (uta_info->uta_in_use > 0)
5238 IXGBE_WRITE_REG(hw, IXGBE_MCSTCTRL,
5239 IXGBE_MCSTCTRL_MFE | hw->mac.mc_filter_type);
5241 IXGBE_WRITE_REG(hw, IXGBE_MCSTCTRL, hw->mac.mc_filter_type);
5247 ixgbe_uc_all_hash_table_set(struct rte_eth_dev *dev, uint8_t on)
5250 struct ixgbe_hw *hw =
5251 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5252 struct ixgbe_uta_info *uta_info =
5253 IXGBE_DEV_PRIVATE_TO_UTA(dev->data->dev_private);
5255 /* The UTA table only exists on 82599 hardware and newer */
5256 if (hw->mac.type < ixgbe_mac_82599EB)
5260 for (i = 0; i < ETH_VMDQ_NUM_UC_HASH_ARRAY; i++) {
5261 uta_info->uta_shadow[i] = ~0;
5262 IXGBE_WRITE_REG(hw, IXGBE_UTA(i), ~0);
5265 for (i = 0; i < ETH_VMDQ_NUM_UC_HASH_ARRAY; i++) {
5266 uta_info->uta_shadow[i] = 0;
5267 IXGBE_WRITE_REG(hw, IXGBE_UTA(i), 0);
5275 ixgbe_convert_vm_rx_mask_to_val(uint16_t rx_mask, uint32_t orig_val)
5277 uint32_t new_val = orig_val;
5279 if (rx_mask & ETH_VMDQ_ACCEPT_UNTAG)
5280 new_val |= IXGBE_VMOLR_AUPE;
5281 if (rx_mask & ETH_VMDQ_ACCEPT_HASH_MC)
5282 new_val |= IXGBE_VMOLR_ROMPE;
5283 if (rx_mask & ETH_VMDQ_ACCEPT_HASH_UC)
5284 new_val |= IXGBE_VMOLR_ROPE;
5285 if (rx_mask & ETH_VMDQ_ACCEPT_BROADCAST)
5286 new_val |= IXGBE_VMOLR_BAM;
5287 if (rx_mask & ETH_VMDQ_ACCEPT_MULTICAST)
5288 new_val |= IXGBE_VMOLR_MPE;
5293 #define IXGBE_MRCTL_VPME 0x01 /* Virtual Pool Mirroring. */
5294 #define IXGBE_MRCTL_UPME 0x02 /* Uplink Port Mirroring. */
5295 #define IXGBE_MRCTL_DPME 0x04 /* Downlink Port Mirroring. */
5296 #define IXGBE_MRCTL_VLME 0x08 /* VLAN Mirroring. */
5297 #define IXGBE_INVALID_MIRROR_TYPE(mirror_type) \
5298 ((mirror_type) & ~(uint8_t)(ETH_MIRROR_VIRTUAL_POOL_UP | \
5299 ETH_MIRROR_UPLINK_PORT | ETH_MIRROR_DOWNLINK_PORT | ETH_MIRROR_VLAN))
5302 ixgbe_mirror_rule_set(struct rte_eth_dev *dev,
5303 struct rte_eth_mirror_conf *mirror_conf,
5304 uint8_t rule_id, uint8_t on)
5306 uint32_t mr_ctl, vlvf;
5307 uint32_t mp_lsb = 0;
5308 uint32_t mv_msb = 0;
5309 uint32_t mv_lsb = 0;
5310 uint32_t mp_msb = 0;
5313 uint64_t vlan_mask = 0;
5315 const uint8_t pool_mask_offset = 32;
5316 const uint8_t vlan_mask_offset = 32;
5317 const uint8_t dst_pool_offset = 8;
5318 const uint8_t rule_mr_offset = 4;
5319 const uint8_t mirror_rule_mask = 0x0F;
5321 struct ixgbe_mirror_info *mr_info =
5322 (IXGBE_DEV_PRIVATE_TO_PFDATA(dev->data->dev_private));
5323 struct ixgbe_hw *hw =
5324 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5325 uint8_t mirror_type = 0;
5327 if (ixgbe_vt_check(hw) < 0)
5330 if (rule_id >= IXGBE_MAX_MIRROR_RULES)
5333 if (IXGBE_INVALID_MIRROR_TYPE(mirror_conf->rule_type)) {
5334 PMD_DRV_LOG(ERR, "unsupported mirror type 0x%x.",
5335 mirror_conf->rule_type);
5339 if (mirror_conf->rule_type & ETH_MIRROR_VLAN) {
5340 mirror_type |= IXGBE_MRCTL_VLME;
5341 /* Check if vlan id is valid and find conresponding VLAN ID
5344 for (i = 0; i < IXGBE_VLVF_ENTRIES; i++) {
5345 if (mirror_conf->vlan.vlan_mask & (1ULL << i)) {
5346 /* search vlan id related pool vlan filter
5349 reg_index = ixgbe_find_vlvf_slot(
5351 mirror_conf->vlan.vlan_id[i],
5355 vlvf = IXGBE_READ_REG(hw,
5356 IXGBE_VLVF(reg_index));
5357 if ((vlvf & IXGBE_VLVF_VIEN) &&
5358 ((vlvf & IXGBE_VLVF_VLANID_MASK) ==
5359 mirror_conf->vlan.vlan_id[i]))
5360 vlan_mask |= (1ULL << reg_index);
5367 mv_lsb = vlan_mask & 0xFFFFFFFF;
5368 mv_msb = vlan_mask >> vlan_mask_offset;
5370 mr_info->mr_conf[rule_id].vlan.vlan_mask =
5371 mirror_conf->vlan.vlan_mask;
5372 for (i = 0; i < ETH_VMDQ_MAX_VLAN_FILTERS; i++) {
5373 if (mirror_conf->vlan.vlan_mask & (1ULL << i))
5374 mr_info->mr_conf[rule_id].vlan.vlan_id[i] =
5375 mirror_conf->vlan.vlan_id[i];
5380 mr_info->mr_conf[rule_id].vlan.vlan_mask = 0;
5381 for (i = 0; i < ETH_VMDQ_MAX_VLAN_FILTERS; i++)
5382 mr_info->mr_conf[rule_id].vlan.vlan_id[i] = 0;
5387 * if enable pool mirror, write related pool mask register,if disable
5388 * pool mirror, clear PFMRVM register
5390 if (mirror_conf->rule_type & ETH_MIRROR_VIRTUAL_POOL_UP) {
5391 mirror_type |= IXGBE_MRCTL_VPME;
5393 mp_lsb = mirror_conf->pool_mask & 0xFFFFFFFF;
5394 mp_msb = mirror_conf->pool_mask >> pool_mask_offset;
5395 mr_info->mr_conf[rule_id].pool_mask =
5396 mirror_conf->pool_mask;
5401 mr_info->mr_conf[rule_id].pool_mask = 0;
5404 if (mirror_conf->rule_type & ETH_MIRROR_UPLINK_PORT)
5405 mirror_type |= IXGBE_MRCTL_UPME;
5406 if (mirror_conf->rule_type & ETH_MIRROR_DOWNLINK_PORT)
5407 mirror_type |= IXGBE_MRCTL_DPME;
5409 /* read mirror control register and recalculate it */
5410 mr_ctl = IXGBE_READ_REG(hw, IXGBE_MRCTL(rule_id));
5413 mr_ctl |= mirror_type;
5414 mr_ctl &= mirror_rule_mask;
5415 mr_ctl |= mirror_conf->dst_pool << dst_pool_offset;
5417 mr_ctl &= ~(mirror_conf->rule_type & mirror_rule_mask);
5420 mr_info->mr_conf[rule_id].rule_type = mirror_conf->rule_type;
5421 mr_info->mr_conf[rule_id].dst_pool = mirror_conf->dst_pool;
5423 /* write mirrror control register */
5424 IXGBE_WRITE_REG(hw, IXGBE_MRCTL(rule_id), mr_ctl);
5426 /* write pool mirrror control register */
5427 if (mirror_conf->rule_type == ETH_MIRROR_VIRTUAL_POOL_UP) {
5428 IXGBE_WRITE_REG(hw, IXGBE_VMRVM(rule_id), mp_lsb);
5429 IXGBE_WRITE_REG(hw, IXGBE_VMRVM(rule_id + rule_mr_offset),
5432 /* write VLAN mirrror control register */
5433 if (mirror_conf->rule_type == ETH_MIRROR_VLAN) {
5434 IXGBE_WRITE_REG(hw, IXGBE_VMRVLAN(rule_id), mv_lsb);
5435 IXGBE_WRITE_REG(hw, IXGBE_VMRVLAN(rule_id + rule_mr_offset),
5443 ixgbe_mirror_rule_reset(struct rte_eth_dev *dev, uint8_t rule_id)
5446 uint32_t lsb_val = 0;
5447 uint32_t msb_val = 0;
5448 const uint8_t rule_mr_offset = 4;
5450 struct ixgbe_hw *hw =
5451 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5452 struct ixgbe_mirror_info *mr_info =
5453 (IXGBE_DEV_PRIVATE_TO_PFDATA(dev->data->dev_private));
5455 if (ixgbe_vt_check(hw) < 0)
5458 memset(&mr_info->mr_conf[rule_id], 0,
5459 sizeof(struct rte_eth_mirror_conf));
5461 /* clear PFVMCTL register */
5462 IXGBE_WRITE_REG(hw, IXGBE_MRCTL(rule_id), mr_ctl);
5464 /* clear pool mask register */
5465 IXGBE_WRITE_REG(hw, IXGBE_VMRVM(rule_id), lsb_val);
5466 IXGBE_WRITE_REG(hw, IXGBE_VMRVM(rule_id + rule_mr_offset), msb_val);
5468 /* clear vlan mask register */
5469 IXGBE_WRITE_REG(hw, IXGBE_VMRVLAN(rule_id), lsb_val);
5470 IXGBE_WRITE_REG(hw, IXGBE_VMRVLAN(rule_id + rule_mr_offset), msb_val);
5476 ixgbevf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
5478 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
5479 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
5481 struct ixgbe_hw *hw =
5482 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5484 mask = IXGBE_READ_REG(hw, IXGBE_VTEIMS);
5485 mask |= (1 << IXGBE_MISC_VEC_ID);
5486 RTE_SET_USED(queue_id);
5487 IXGBE_WRITE_REG(hw, IXGBE_VTEIMS, mask);
5489 rte_intr_enable(intr_handle);
5495 ixgbevf_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id)
5498 struct ixgbe_hw *hw =
5499 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5501 mask = IXGBE_READ_REG(hw, IXGBE_VTEIMS);
5502 mask &= ~(1 << IXGBE_MISC_VEC_ID);
5503 RTE_SET_USED(queue_id);
5504 IXGBE_WRITE_REG(hw, IXGBE_VTEIMS, mask);
5510 ixgbe_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
5512 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
5513 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
5515 struct ixgbe_hw *hw =
5516 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5517 struct ixgbe_interrupt *intr =
5518 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
5520 if (queue_id < 16) {
5521 ixgbe_disable_intr(hw);
5522 intr->mask |= (1 << queue_id);
5523 ixgbe_enable_intr(dev);
5524 } else if (queue_id < 32) {
5525 mask = IXGBE_READ_REG(hw, IXGBE_EIMS_EX(0));
5526 mask &= (1 << queue_id);
5527 IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(0), mask);
5528 } else if (queue_id < 64) {
5529 mask = IXGBE_READ_REG(hw, IXGBE_EIMS_EX(1));
5530 mask &= (1 << (queue_id - 32));
5531 IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(1), mask);
5533 rte_intr_enable(intr_handle);
5539 ixgbe_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id)
5542 struct ixgbe_hw *hw =
5543 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5544 struct ixgbe_interrupt *intr =
5545 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
5547 if (queue_id < 16) {
5548 ixgbe_disable_intr(hw);
5549 intr->mask &= ~(1 << queue_id);
5550 ixgbe_enable_intr(dev);
5551 } else if (queue_id < 32) {
5552 mask = IXGBE_READ_REG(hw, IXGBE_EIMS_EX(0));
5553 mask &= ~(1 << queue_id);
5554 IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(0), mask);
5555 } else if (queue_id < 64) {
5556 mask = IXGBE_READ_REG(hw, IXGBE_EIMS_EX(1));
5557 mask &= ~(1 << (queue_id - 32));
5558 IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(1), mask);
5565 ixgbevf_set_ivar_map(struct ixgbe_hw *hw, int8_t direction,
5566 uint8_t queue, uint8_t msix_vector)
5570 if (direction == -1) {
5572 msix_vector |= IXGBE_IVAR_ALLOC_VAL;
5573 tmp = IXGBE_READ_REG(hw, IXGBE_VTIVAR_MISC);
5576 IXGBE_WRITE_REG(hw, IXGBE_VTIVAR_MISC, tmp);
5578 /* rx or tx cause */
5579 msix_vector |= IXGBE_IVAR_ALLOC_VAL;
5580 idx = ((16 * (queue & 1)) + (8 * direction));
5581 tmp = IXGBE_READ_REG(hw, IXGBE_VTIVAR(queue >> 1));
5582 tmp &= ~(0xFF << idx);
5583 tmp |= (msix_vector << idx);
5584 IXGBE_WRITE_REG(hw, IXGBE_VTIVAR(queue >> 1), tmp);
5589 * set the IVAR registers, mapping interrupt causes to vectors
5591 * pointer to ixgbe_hw struct
5593 * 0 for Rx, 1 for Tx, -1 for other causes
5595 * queue to map the corresponding interrupt to
5597 * the vector to map to the corresponding queue
5600 ixgbe_set_ivar_map(struct ixgbe_hw *hw, int8_t direction,
5601 uint8_t queue, uint8_t msix_vector)
5605 msix_vector |= IXGBE_IVAR_ALLOC_VAL;
5606 if (hw->mac.type == ixgbe_mac_82598EB) {
5607 if (direction == -1)
5609 idx = (((direction * 64) + queue) >> 2) & 0x1F;
5610 tmp = IXGBE_READ_REG(hw, IXGBE_IVAR(idx));
5611 tmp &= ~(0xFF << (8 * (queue & 0x3)));
5612 tmp |= (msix_vector << (8 * (queue & 0x3)));
5613 IXGBE_WRITE_REG(hw, IXGBE_IVAR(idx), tmp);
5614 } else if ((hw->mac.type == ixgbe_mac_82599EB) ||
5615 (hw->mac.type == ixgbe_mac_X540)) {
5616 if (direction == -1) {
5618 idx = ((queue & 1) * 8);
5619 tmp = IXGBE_READ_REG(hw, IXGBE_IVAR_MISC);
5620 tmp &= ~(0xFF << idx);
5621 tmp |= (msix_vector << idx);
5622 IXGBE_WRITE_REG(hw, IXGBE_IVAR_MISC, tmp);
5624 /* rx or tx causes */
5625 idx = ((16 * (queue & 1)) + (8 * direction));
5626 tmp = IXGBE_READ_REG(hw, IXGBE_IVAR(queue >> 1));
5627 tmp &= ~(0xFF << idx);
5628 tmp |= (msix_vector << idx);
5629 IXGBE_WRITE_REG(hw, IXGBE_IVAR(queue >> 1), tmp);
5635 ixgbevf_configure_msix(struct rte_eth_dev *dev)
5637 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
5638 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
5639 struct ixgbe_hw *hw =
5640 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5642 uint32_t vector_idx = IXGBE_MISC_VEC_ID;
5644 /* Configure VF other cause ivar */
5645 ixgbevf_set_ivar_map(hw, -1, 1, vector_idx);
5647 /* won't configure msix register if no mapping is done
5648 * between intr vector and event fd.
5650 if (!rte_intr_dp_is_en(intr_handle))
5653 /* Configure all RX queues of VF */
5654 for (q_idx = 0; q_idx < dev->data->nb_rx_queues; q_idx++) {
5655 /* Force all queue use vector 0,
5656 * as IXGBE_VF_MAXMSIVECOTR = 1
5658 ixgbevf_set_ivar_map(hw, 0, q_idx, vector_idx);
5659 intr_handle->intr_vec[q_idx] = vector_idx;
5664 * Sets up the hardware to properly generate MSI-X interrupts
5666 * board private structure
5669 ixgbe_configure_msix(struct rte_eth_dev *dev)
5671 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
5672 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
5673 struct ixgbe_hw *hw =
5674 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5675 uint32_t queue_id, base = IXGBE_MISC_VEC_ID;
5676 uint32_t vec = IXGBE_MISC_VEC_ID;
5680 /* won't configure msix register if no mapping is done
5681 * between intr vector and event fd
5683 if (!rte_intr_dp_is_en(intr_handle))
5686 if (rte_intr_allow_others(intr_handle))
5687 vec = base = IXGBE_RX_VEC_START;
5689 /* setup GPIE for MSI-x mode */
5690 gpie = IXGBE_READ_REG(hw, IXGBE_GPIE);
5691 gpie |= IXGBE_GPIE_MSIX_MODE | IXGBE_GPIE_PBA_SUPPORT |
5692 IXGBE_GPIE_OCD | IXGBE_GPIE_EIAME;
5693 /* auto clearing and auto setting corresponding bits in EIMS
5694 * when MSI-X interrupt is triggered
5696 if (hw->mac.type == ixgbe_mac_82598EB) {
5697 IXGBE_WRITE_REG(hw, IXGBE_EIAM, IXGBE_EICS_RTX_QUEUE);
5699 IXGBE_WRITE_REG(hw, IXGBE_EIAM_EX(0), 0xFFFFFFFF);
5700 IXGBE_WRITE_REG(hw, IXGBE_EIAM_EX(1), 0xFFFFFFFF);
5702 IXGBE_WRITE_REG(hw, IXGBE_GPIE, gpie);
5704 /* Populate the IVAR table and set the ITR values to the
5705 * corresponding register.
5707 for (queue_id = 0; queue_id < dev->data->nb_rx_queues;
5709 /* by default, 1:1 mapping */
5710 ixgbe_set_ivar_map(hw, 0, queue_id, vec);
5711 intr_handle->intr_vec[queue_id] = vec;
5712 if (vec < base + intr_handle->nb_efd - 1)
5716 switch (hw->mac.type) {
5717 case ixgbe_mac_82598EB:
5718 ixgbe_set_ivar_map(hw, -1, IXGBE_IVAR_OTHER_CAUSES_INDEX,
5721 case ixgbe_mac_82599EB:
5722 case ixgbe_mac_X540:
5723 ixgbe_set_ivar_map(hw, -1, 1, IXGBE_MISC_VEC_ID);
5728 IXGBE_WRITE_REG(hw, IXGBE_EITR(IXGBE_MISC_VEC_ID),
5729 IXGBE_MIN_INTER_INTERRUPT_INTERVAL_DEFAULT & 0xFFF);
5731 /* set up to autoclear timer, and the vectors */
5732 mask = IXGBE_EIMS_ENABLE_MASK;
5733 mask &= ~(IXGBE_EIMS_OTHER |
5734 IXGBE_EIMS_MAILBOX |
5737 IXGBE_WRITE_REG(hw, IXGBE_EIAC, mask);
5741 ixgbe_set_queue_rate_limit(struct rte_eth_dev *dev,
5742 uint16_t queue_idx, uint16_t tx_rate)
5744 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5745 uint32_t rf_dec, rf_int;
5747 uint16_t link_speed = dev->data->dev_link.link_speed;
5749 if (queue_idx >= hw->mac.max_tx_queues)
5753 /* Calculate the rate factor values to set */
5754 rf_int = (uint32_t)link_speed / (uint32_t)tx_rate;
5755 rf_dec = (uint32_t)link_speed % (uint32_t)tx_rate;
5756 rf_dec = (rf_dec << IXGBE_RTTBCNRC_RF_INT_SHIFT) / tx_rate;
5758 bcnrc_val = IXGBE_RTTBCNRC_RS_ENA;
5759 bcnrc_val |= ((rf_int << IXGBE_RTTBCNRC_RF_INT_SHIFT) &
5760 IXGBE_RTTBCNRC_RF_INT_MASK_M);
5761 bcnrc_val |= (rf_dec & IXGBE_RTTBCNRC_RF_DEC_MASK);
5767 * Set global transmit compensation time to the MMW_SIZE in RTTBCNRM
5768 * register. MMW_SIZE=0x014 if 9728-byte jumbo is supported, otherwise
5771 if ((dev->data->dev_conf.rxmode.jumbo_frame == 1) &&
5772 (dev->data->dev_conf.rxmode.max_rx_pkt_len >=
5773 IXGBE_MAX_JUMBO_FRAME_SIZE))
5774 IXGBE_WRITE_REG(hw, IXGBE_RTTBCNRM,
5775 IXGBE_MMW_SIZE_JUMBO_FRAME);
5777 IXGBE_WRITE_REG(hw, IXGBE_RTTBCNRM,
5778 IXGBE_MMW_SIZE_DEFAULT);
5780 /* Set RTTBCNRC of queue X */
5781 IXGBE_WRITE_REG(hw, IXGBE_RTTDQSEL, queue_idx);
5782 IXGBE_WRITE_REG(hw, IXGBE_RTTBCNRC, bcnrc_val);
5783 IXGBE_WRITE_FLUSH(hw);
5789 ixgbevf_add_mac_addr(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
5790 __attribute__((unused)) uint32_t index,
5791 __attribute__((unused)) uint32_t pool)
5793 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5797 * On a 82599 VF, adding again the same MAC addr is not an idempotent
5798 * operation. Trap this case to avoid exhausting the [very limited]
5799 * set of PF resources used to store VF MAC addresses.
5801 if (memcmp(hw->mac.perm_addr, mac_addr, sizeof(struct ether_addr)) == 0)
5803 diag = ixgbevf_set_uc_addr_vf(hw, 2, mac_addr->addr_bytes);
5805 PMD_DRV_LOG(ERR, "Unable to add MAC address "
5806 "%02x:%02x:%02x:%02x:%02x:%02x - diag=%d",
5807 mac_addr->addr_bytes[0],
5808 mac_addr->addr_bytes[1],
5809 mac_addr->addr_bytes[2],
5810 mac_addr->addr_bytes[3],
5811 mac_addr->addr_bytes[4],
5812 mac_addr->addr_bytes[5],
5818 ixgbevf_remove_mac_addr(struct rte_eth_dev *dev, uint32_t index)
5820 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5821 struct ether_addr *perm_addr = (struct ether_addr *) hw->mac.perm_addr;
5822 struct ether_addr *mac_addr;
5827 * The IXGBE_VF_SET_MACVLAN command of the ixgbe-pf driver does
5828 * not support the deletion of a given MAC address.
5829 * Instead, it imposes to delete all MAC addresses, then to add again
5830 * all MAC addresses with the exception of the one to be deleted.
5832 (void) ixgbevf_set_uc_addr_vf(hw, 0, NULL);
5835 * Add again all MAC addresses, with the exception of the deleted one
5836 * and of the permanent MAC address.
5838 for (i = 0, mac_addr = dev->data->mac_addrs;
5839 i < hw->mac.num_rar_entries; i++, mac_addr++) {
5840 /* Skip the deleted MAC address */
5843 /* Skip NULL MAC addresses */
5844 if (is_zero_ether_addr(mac_addr))
5846 /* Skip the permanent MAC address */
5847 if (memcmp(perm_addr, mac_addr, sizeof(struct ether_addr)) == 0)
5849 diag = ixgbevf_set_uc_addr_vf(hw, 2, mac_addr->addr_bytes);
5852 "Adding again MAC address "
5853 "%02x:%02x:%02x:%02x:%02x:%02x failed "
5855 mac_addr->addr_bytes[0],
5856 mac_addr->addr_bytes[1],
5857 mac_addr->addr_bytes[2],
5858 mac_addr->addr_bytes[3],
5859 mac_addr->addr_bytes[4],
5860 mac_addr->addr_bytes[5],
5866 ixgbevf_set_default_mac_addr(struct rte_eth_dev *dev, struct ether_addr *addr)
5868 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5870 hw->mac.ops.set_rar(hw, 0, (void *)addr, 0, 0);
5874 ixgbe_syn_filter_set(struct rte_eth_dev *dev,
5875 struct rte_eth_syn_filter *filter,
5878 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5879 struct ixgbe_filter_info *filter_info =
5880 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
5884 if (filter->queue >= IXGBE_MAX_RX_QUEUE_NUM)
5887 syn_info = filter_info->syn_info;
5890 if (syn_info & IXGBE_SYN_FILTER_ENABLE)
5892 synqf = (uint32_t)(((filter->queue << IXGBE_SYN_FILTER_QUEUE_SHIFT) &
5893 IXGBE_SYN_FILTER_QUEUE) | IXGBE_SYN_FILTER_ENABLE);
5895 if (filter->hig_pri)
5896 synqf |= IXGBE_SYN_FILTER_SYNQFP;
5898 synqf &= ~IXGBE_SYN_FILTER_SYNQFP;
5900 synqf = IXGBE_READ_REG(hw, IXGBE_SYNQF);
5901 if (!(syn_info & IXGBE_SYN_FILTER_ENABLE))
5903 synqf &= ~(IXGBE_SYN_FILTER_QUEUE | IXGBE_SYN_FILTER_ENABLE);
5906 filter_info->syn_info = synqf;
5907 IXGBE_WRITE_REG(hw, IXGBE_SYNQF, synqf);
5908 IXGBE_WRITE_FLUSH(hw);
5913 ixgbe_syn_filter_get(struct rte_eth_dev *dev,
5914 struct rte_eth_syn_filter *filter)
5916 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5917 uint32_t synqf = IXGBE_READ_REG(hw, IXGBE_SYNQF);
5919 if (synqf & IXGBE_SYN_FILTER_ENABLE) {
5920 filter->hig_pri = (synqf & IXGBE_SYN_FILTER_SYNQFP) ? 1 : 0;
5921 filter->queue = (uint16_t)((synqf & IXGBE_SYN_FILTER_QUEUE) >> 1);
5928 ixgbe_syn_filter_handle(struct rte_eth_dev *dev,
5929 enum rte_filter_op filter_op,
5932 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5935 MAC_TYPE_FILTER_SUP(hw->mac.type);
5937 if (filter_op == RTE_ETH_FILTER_NOP)
5941 PMD_DRV_LOG(ERR, "arg shouldn't be NULL for operation %u",
5946 switch (filter_op) {
5947 case RTE_ETH_FILTER_ADD:
5948 ret = ixgbe_syn_filter_set(dev,
5949 (struct rte_eth_syn_filter *)arg,
5952 case RTE_ETH_FILTER_DELETE:
5953 ret = ixgbe_syn_filter_set(dev,
5954 (struct rte_eth_syn_filter *)arg,
5957 case RTE_ETH_FILTER_GET:
5958 ret = ixgbe_syn_filter_get(dev,
5959 (struct rte_eth_syn_filter *)arg);
5962 PMD_DRV_LOG(ERR, "unsupported operation %u", filter_op);
5971 static inline enum ixgbe_5tuple_protocol
5972 convert_protocol_type(uint8_t protocol_value)
5974 if (protocol_value == IPPROTO_TCP)
5975 return IXGBE_FILTER_PROTOCOL_TCP;
5976 else if (protocol_value == IPPROTO_UDP)
5977 return IXGBE_FILTER_PROTOCOL_UDP;
5978 else if (protocol_value == IPPROTO_SCTP)
5979 return IXGBE_FILTER_PROTOCOL_SCTP;
5981 return IXGBE_FILTER_PROTOCOL_NONE;
5984 /* inject a 5-tuple filter to HW */
5986 ixgbe_inject_5tuple_filter(struct rte_eth_dev *dev,
5987 struct ixgbe_5tuple_filter *filter)
5989 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5991 uint32_t ftqf, sdpqf;
5992 uint32_t l34timir = 0;
5993 uint8_t mask = 0xff;
5997 sdpqf = (uint32_t)(filter->filter_info.dst_port <<
5998 IXGBE_SDPQF_DSTPORT_SHIFT);
5999 sdpqf = sdpqf | (filter->filter_info.src_port & IXGBE_SDPQF_SRCPORT);
6001 ftqf = (uint32_t)(filter->filter_info.proto &
6002 IXGBE_FTQF_PROTOCOL_MASK);
6003 ftqf |= (uint32_t)((filter->filter_info.priority &
6004 IXGBE_FTQF_PRIORITY_MASK) << IXGBE_FTQF_PRIORITY_SHIFT);
6005 if (filter->filter_info.src_ip_mask == 0) /* 0 means compare. */
6006 mask &= IXGBE_FTQF_SOURCE_ADDR_MASK;
6007 if (filter->filter_info.dst_ip_mask == 0)
6008 mask &= IXGBE_FTQF_DEST_ADDR_MASK;
6009 if (filter->filter_info.src_port_mask == 0)
6010 mask &= IXGBE_FTQF_SOURCE_PORT_MASK;
6011 if (filter->filter_info.dst_port_mask == 0)
6012 mask &= IXGBE_FTQF_DEST_PORT_MASK;
6013 if (filter->filter_info.proto_mask == 0)
6014 mask &= IXGBE_FTQF_PROTOCOL_COMP_MASK;
6015 ftqf |= mask << IXGBE_FTQF_5TUPLE_MASK_SHIFT;
6016 ftqf |= IXGBE_FTQF_POOL_MASK_EN;
6017 ftqf |= IXGBE_FTQF_QUEUE_ENABLE;
6019 IXGBE_WRITE_REG(hw, IXGBE_DAQF(i), filter->filter_info.dst_ip);
6020 IXGBE_WRITE_REG(hw, IXGBE_SAQF(i), filter->filter_info.src_ip);
6021 IXGBE_WRITE_REG(hw, IXGBE_SDPQF(i), sdpqf);
6022 IXGBE_WRITE_REG(hw, IXGBE_FTQF(i), ftqf);
6024 l34timir |= IXGBE_L34T_IMIR_RESERVE;
6025 l34timir |= (uint32_t)(filter->queue <<
6026 IXGBE_L34T_IMIR_QUEUE_SHIFT);
6027 IXGBE_WRITE_REG(hw, IXGBE_L34T_IMIR(i), l34timir);
6031 * add a 5tuple filter
6034 * dev: Pointer to struct rte_eth_dev.
6035 * index: the index the filter allocates.
6036 * filter: ponter to the filter that will be added.
6037 * rx_queue: the queue id the filter assigned to.
6040 * - On success, zero.
6041 * - On failure, a negative value.
6044 ixgbe_add_5tuple_filter(struct rte_eth_dev *dev,
6045 struct ixgbe_5tuple_filter *filter)
6047 struct ixgbe_filter_info *filter_info =
6048 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6052 * look for an unused 5tuple filter index,
6053 * and insert the filter to list.
6055 for (i = 0; i < IXGBE_MAX_FTQF_FILTERS; i++) {
6056 idx = i / (sizeof(uint32_t) * NBBY);
6057 shift = i % (sizeof(uint32_t) * NBBY);
6058 if (!(filter_info->fivetuple_mask[idx] & (1 << shift))) {
6059 filter_info->fivetuple_mask[idx] |= 1 << shift;
6061 TAILQ_INSERT_TAIL(&filter_info->fivetuple_list,
6067 if (i >= IXGBE_MAX_FTQF_FILTERS) {
6068 PMD_DRV_LOG(ERR, "5tuple filters are full.");
6072 ixgbe_inject_5tuple_filter(dev, filter);
6078 * remove a 5tuple filter
6081 * dev: Pointer to struct rte_eth_dev.
6082 * filter: the pointer of the filter will be removed.
6085 ixgbe_remove_5tuple_filter(struct rte_eth_dev *dev,
6086 struct ixgbe_5tuple_filter *filter)
6088 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6089 struct ixgbe_filter_info *filter_info =
6090 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6091 uint16_t index = filter->index;
6093 filter_info->fivetuple_mask[index / (sizeof(uint32_t) * NBBY)] &=
6094 ~(1 << (index % (sizeof(uint32_t) * NBBY)));
6095 TAILQ_REMOVE(&filter_info->fivetuple_list, filter, entries);
6098 IXGBE_WRITE_REG(hw, IXGBE_DAQF(index), 0);
6099 IXGBE_WRITE_REG(hw, IXGBE_SAQF(index), 0);
6100 IXGBE_WRITE_REG(hw, IXGBE_SDPQF(index), 0);
6101 IXGBE_WRITE_REG(hw, IXGBE_FTQF(index), 0);
6102 IXGBE_WRITE_REG(hw, IXGBE_L34T_IMIR(index), 0);
6106 ixgbevf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
6108 struct ixgbe_hw *hw;
6109 uint32_t max_frame = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
6110 struct rte_eth_rxmode *rx_conf = &dev->data->dev_conf.rxmode;
6112 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6114 if ((mtu < ETHER_MIN_MTU) || (max_frame > ETHER_MAX_JUMBO_FRAME_LEN))
6117 /* refuse mtu that requires the support of scattered packets when this
6118 * feature has not been enabled before.
6120 if (!rx_conf->enable_scatter &&
6121 (max_frame + 2 * IXGBE_VLAN_TAG_SIZE >
6122 dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM))
6126 * When supported by the underlying PF driver, use the IXGBE_VF_SET_MTU
6127 * request of the version 2.0 of the mailbox API.
6128 * For now, use the IXGBE_VF_SET_LPE request of the version 1.0
6129 * of the mailbox API.
6130 * This call to IXGBE_SET_LPE action won't work with ixgbe pf drivers
6131 * prior to 3.11.33 which contains the following change:
6132 * "ixgbe: Enable jumbo frames support w/ SR-IOV"
6134 ixgbevf_rlpml_set_vf(hw, max_frame);
6136 /* update max frame size */
6137 dev->data->dev_conf.rxmode.max_rx_pkt_len = max_frame;
6141 static inline struct ixgbe_5tuple_filter *
6142 ixgbe_5tuple_filter_lookup(struct ixgbe_5tuple_filter_list *filter_list,
6143 struct ixgbe_5tuple_filter_info *key)
6145 struct ixgbe_5tuple_filter *it;
6147 TAILQ_FOREACH(it, filter_list, entries) {
6148 if (memcmp(key, &it->filter_info,
6149 sizeof(struct ixgbe_5tuple_filter_info)) == 0) {
6156 /* translate elements in struct rte_eth_ntuple_filter to struct ixgbe_5tuple_filter_info*/
6158 ntuple_filter_to_5tuple(struct rte_eth_ntuple_filter *filter,
6159 struct ixgbe_5tuple_filter_info *filter_info)
6161 if (filter->queue >= IXGBE_MAX_RX_QUEUE_NUM ||
6162 filter->priority > IXGBE_5TUPLE_MAX_PRI ||
6163 filter->priority < IXGBE_5TUPLE_MIN_PRI)
6166 switch (filter->dst_ip_mask) {
6168 filter_info->dst_ip_mask = 0;
6169 filter_info->dst_ip = filter->dst_ip;
6172 filter_info->dst_ip_mask = 1;
6175 PMD_DRV_LOG(ERR, "invalid dst_ip mask.");
6179 switch (filter->src_ip_mask) {
6181 filter_info->src_ip_mask = 0;
6182 filter_info->src_ip = filter->src_ip;
6185 filter_info->src_ip_mask = 1;
6188 PMD_DRV_LOG(ERR, "invalid src_ip mask.");
6192 switch (filter->dst_port_mask) {
6194 filter_info->dst_port_mask = 0;
6195 filter_info->dst_port = filter->dst_port;
6198 filter_info->dst_port_mask = 1;
6201 PMD_DRV_LOG(ERR, "invalid dst_port mask.");
6205 switch (filter->src_port_mask) {
6207 filter_info->src_port_mask = 0;
6208 filter_info->src_port = filter->src_port;
6211 filter_info->src_port_mask = 1;
6214 PMD_DRV_LOG(ERR, "invalid src_port mask.");
6218 switch (filter->proto_mask) {
6220 filter_info->proto_mask = 0;
6221 filter_info->proto =
6222 convert_protocol_type(filter->proto);
6225 filter_info->proto_mask = 1;
6228 PMD_DRV_LOG(ERR, "invalid protocol mask.");
6232 filter_info->priority = (uint8_t)filter->priority;
6237 * add or delete a ntuple filter
6240 * dev: Pointer to struct rte_eth_dev.
6241 * ntuple_filter: Pointer to struct rte_eth_ntuple_filter
6242 * add: if true, add filter, if false, remove filter
6245 * - On success, zero.
6246 * - On failure, a negative value.
6249 ixgbe_add_del_ntuple_filter(struct rte_eth_dev *dev,
6250 struct rte_eth_ntuple_filter *ntuple_filter,
6253 struct ixgbe_filter_info *filter_info =
6254 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6255 struct ixgbe_5tuple_filter_info filter_5tuple;
6256 struct ixgbe_5tuple_filter *filter;
6259 if (ntuple_filter->flags != RTE_5TUPLE_FLAGS) {
6260 PMD_DRV_LOG(ERR, "only 5tuple is supported.");
6264 memset(&filter_5tuple, 0, sizeof(struct ixgbe_5tuple_filter_info));
6265 ret = ntuple_filter_to_5tuple(ntuple_filter, &filter_5tuple);
6269 filter = ixgbe_5tuple_filter_lookup(&filter_info->fivetuple_list,
6271 if (filter != NULL && add) {
6272 PMD_DRV_LOG(ERR, "filter exists.");
6275 if (filter == NULL && !add) {
6276 PMD_DRV_LOG(ERR, "filter doesn't exist.");
6281 filter = rte_zmalloc("ixgbe_5tuple_filter",
6282 sizeof(struct ixgbe_5tuple_filter), 0);
6285 (void)rte_memcpy(&filter->filter_info,
6287 sizeof(struct ixgbe_5tuple_filter_info));
6288 filter->queue = ntuple_filter->queue;
6289 ret = ixgbe_add_5tuple_filter(dev, filter);
6295 ixgbe_remove_5tuple_filter(dev, filter);
6301 * get a ntuple filter
6304 * dev: Pointer to struct rte_eth_dev.
6305 * ntuple_filter: Pointer to struct rte_eth_ntuple_filter
6308 * - On success, zero.
6309 * - On failure, a negative value.
6312 ixgbe_get_ntuple_filter(struct rte_eth_dev *dev,
6313 struct rte_eth_ntuple_filter *ntuple_filter)
6315 struct ixgbe_filter_info *filter_info =
6316 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6317 struct ixgbe_5tuple_filter_info filter_5tuple;
6318 struct ixgbe_5tuple_filter *filter;
6321 if (ntuple_filter->flags != RTE_5TUPLE_FLAGS) {
6322 PMD_DRV_LOG(ERR, "only 5tuple is supported.");
6326 memset(&filter_5tuple, 0, sizeof(struct ixgbe_5tuple_filter_info));
6327 ret = ntuple_filter_to_5tuple(ntuple_filter, &filter_5tuple);
6331 filter = ixgbe_5tuple_filter_lookup(&filter_info->fivetuple_list,
6333 if (filter == NULL) {
6334 PMD_DRV_LOG(ERR, "filter doesn't exist.");
6337 ntuple_filter->queue = filter->queue;
6342 * ixgbe_ntuple_filter_handle - Handle operations for ntuple filter.
6343 * @dev: pointer to rte_eth_dev structure
6344 * @filter_op:operation will be taken.
6345 * @arg: a pointer to specific structure corresponding to the filter_op
6348 * - On success, zero.
6349 * - On failure, a negative value.
6352 ixgbe_ntuple_filter_handle(struct rte_eth_dev *dev,
6353 enum rte_filter_op filter_op,
6356 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6359 MAC_TYPE_FILTER_SUP_EXT(hw->mac.type);
6361 if (filter_op == RTE_ETH_FILTER_NOP)
6365 PMD_DRV_LOG(ERR, "arg shouldn't be NULL for operation %u.",
6370 switch (filter_op) {
6371 case RTE_ETH_FILTER_ADD:
6372 ret = ixgbe_add_del_ntuple_filter(dev,
6373 (struct rte_eth_ntuple_filter *)arg,
6376 case RTE_ETH_FILTER_DELETE:
6377 ret = ixgbe_add_del_ntuple_filter(dev,
6378 (struct rte_eth_ntuple_filter *)arg,
6381 case RTE_ETH_FILTER_GET:
6382 ret = ixgbe_get_ntuple_filter(dev,
6383 (struct rte_eth_ntuple_filter *)arg);
6386 PMD_DRV_LOG(ERR, "unsupported operation %u.", filter_op);
6394 ixgbe_add_del_ethertype_filter(struct rte_eth_dev *dev,
6395 struct rte_eth_ethertype_filter *filter,
6398 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6399 struct ixgbe_filter_info *filter_info =
6400 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6404 struct ixgbe_ethertype_filter ethertype_filter;
6406 if (filter->queue >= IXGBE_MAX_RX_QUEUE_NUM)
6409 if (filter->ether_type == ETHER_TYPE_IPv4 ||
6410 filter->ether_type == ETHER_TYPE_IPv6) {
6411 PMD_DRV_LOG(ERR, "unsupported ether_type(0x%04x) in"
6412 " ethertype filter.", filter->ether_type);
6416 if (filter->flags & RTE_ETHTYPE_FLAGS_MAC) {
6417 PMD_DRV_LOG(ERR, "mac compare is unsupported.");
6420 if (filter->flags & RTE_ETHTYPE_FLAGS_DROP) {
6421 PMD_DRV_LOG(ERR, "drop option is unsupported.");
6425 ret = ixgbe_ethertype_filter_lookup(filter_info, filter->ether_type);
6426 if (ret >= 0 && add) {
6427 PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter exists.",
6428 filter->ether_type);
6431 if (ret < 0 && !add) {
6432 PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter doesn't exist.",
6433 filter->ether_type);
6438 etqf = IXGBE_ETQF_FILTER_EN;
6439 etqf |= (uint32_t)filter->ether_type;
6440 etqs |= (uint32_t)((filter->queue <<
6441 IXGBE_ETQS_RX_QUEUE_SHIFT) &
6442 IXGBE_ETQS_RX_QUEUE);
6443 etqs |= IXGBE_ETQS_QUEUE_EN;
6445 ethertype_filter.ethertype = filter->ether_type;
6446 ethertype_filter.etqf = etqf;
6447 ethertype_filter.etqs = etqs;
6448 ethertype_filter.conf = FALSE;
6449 ret = ixgbe_ethertype_filter_insert(filter_info,
6452 PMD_DRV_LOG(ERR, "ethertype filters are full.");
6456 ret = ixgbe_ethertype_filter_remove(filter_info, (uint8_t)ret);
6460 IXGBE_WRITE_REG(hw, IXGBE_ETQF(ret), etqf);
6461 IXGBE_WRITE_REG(hw, IXGBE_ETQS(ret), etqs);
6462 IXGBE_WRITE_FLUSH(hw);
6468 ixgbe_get_ethertype_filter(struct rte_eth_dev *dev,
6469 struct rte_eth_ethertype_filter *filter)
6471 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6472 struct ixgbe_filter_info *filter_info =
6473 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6474 uint32_t etqf, etqs;
6477 ret = ixgbe_ethertype_filter_lookup(filter_info, filter->ether_type);
6479 PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter doesn't exist.",
6480 filter->ether_type);
6484 etqf = IXGBE_READ_REG(hw, IXGBE_ETQF(ret));
6485 if (etqf & IXGBE_ETQF_FILTER_EN) {
6486 etqs = IXGBE_READ_REG(hw, IXGBE_ETQS(ret));
6487 filter->ether_type = etqf & IXGBE_ETQF_ETHERTYPE;
6489 filter->queue = (etqs & IXGBE_ETQS_RX_QUEUE) >>
6490 IXGBE_ETQS_RX_QUEUE_SHIFT;
6497 * ixgbe_ethertype_filter_handle - Handle operations for ethertype 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 ixgbe_ethertype_filter_handle(struct rte_eth_dev *dev,
6504 enum rte_filter_op filter_op,
6507 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6510 MAC_TYPE_FILTER_SUP(hw->mac.type);
6512 if (filter_op == RTE_ETH_FILTER_NOP)
6516 PMD_DRV_LOG(ERR, "arg shouldn't be NULL for operation %u.",
6521 switch (filter_op) {
6522 case RTE_ETH_FILTER_ADD:
6523 ret = ixgbe_add_del_ethertype_filter(dev,
6524 (struct rte_eth_ethertype_filter *)arg,
6527 case RTE_ETH_FILTER_DELETE:
6528 ret = ixgbe_add_del_ethertype_filter(dev,
6529 (struct rte_eth_ethertype_filter *)arg,
6532 case RTE_ETH_FILTER_GET:
6533 ret = ixgbe_get_ethertype_filter(dev,
6534 (struct rte_eth_ethertype_filter *)arg);
6537 PMD_DRV_LOG(ERR, "unsupported operation %u.", filter_op);
6545 ixgbe_dev_filter_ctrl(struct rte_eth_dev *dev,
6546 enum rte_filter_type filter_type,
6547 enum rte_filter_op filter_op,
6552 switch (filter_type) {
6553 case RTE_ETH_FILTER_NTUPLE:
6554 ret = ixgbe_ntuple_filter_handle(dev, filter_op, arg);
6556 case RTE_ETH_FILTER_ETHERTYPE:
6557 ret = ixgbe_ethertype_filter_handle(dev, filter_op, arg);
6559 case RTE_ETH_FILTER_SYN:
6560 ret = ixgbe_syn_filter_handle(dev, filter_op, arg);
6562 case RTE_ETH_FILTER_FDIR:
6563 ret = ixgbe_fdir_ctrl_func(dev, filter_op, arg);
6565 case RTE_ETH_FILTER_L2_TUNNEL:
6566 ret = ixgbe_dev_l2_tunnel_filter_handle(dev, filter_op, arg);
6568 case RTE_ETH_FILTER_GENERIC:
6569 if (filter_op != RTE_ETH_FILTER_GET)
6571 *(const void **)arg = &ixgbe_flow_ops;
6574 PMD_DRV_LOG(WARNING, "Filter type (%d) not supported",
6584 ixgbe_dev_addr_list_itr(__attribute__((unused)) struct ixgbe_hw *hw,
6585 u8 **mc_addr_ptr, u32 *vmdq)
6590 mc_addr = *mc_addr_ptr;
6591 *mc_addr_ptr = (mc_addr + sizeof(struct ether_addr));
6596 ixgbe_dev_set_mc_addr_list(struct rte_eth_dev *dev,
6597 struct ether_addr *mc_addr_set,
6598 uint32_t nb_mc_addr)
6600 struct ixgbe_hw *hw;
6603 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6604 mc_addr_list = (u8 *)mc_addr_set;
6605 return ixgbe_update_mc_addr_list(hw, mc_addr_list, nb_mc_addr,
6606 ixgbe_dev_addr_list_itr, TRUE);
6610 ixgbe_read_systime_cyclecounter(struct rte_eth_dev *dev)
6612 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6613 uint64_t systime_cycles;
6615 switch (hw->mac.type) {
6616 case ixgbe_mac_X550:
6617 case ixgbe_mac_X550EM_x:
6618 case ixgbe_mac_X550EM_a:
6619 /* SYSTIMEL stores ns and SYSTIMEH stores seconds. */
6620 systime_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_SYSTIML);
6621 systime_cycles += (uint64_t)IXGBE_READ_REG(hw, IXGBE_SYSTIMH)
6625 systime_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_SYSTIML);
6626 systime_cycles |= (uint64_t)IXGBE_READ_REG(hw, IXGBE_SYSTIMH)
6630 return systime_cycles;
6634 ixgbe_read_rx_tstamp_cyclecounter(struct rte_eth_dev *dev)
6636 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6637 uint64_t rx_tstamp_cycles;
6639 switch (hw->mac.type) {
6640 case ixgbe_mac_X550:
6641 case ixgbe_mac_X550EM_x:
6642 case ixgbe_mac_X550EM_a:
6643 /* RXSTMPL stores ns and RXSTMPH stores seconds. */
6644 rx_tstamp_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_RXSTMPL);
6645 rx_tstamp_cycles += (uint64_t)IXGBE_READ_REG(hw, IXGBE_RXSTMPH)
6649 /* RXSTMPL stores ns and RXSTMPH stores seconds. */
6650 rx_tstamp_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_RXSTMPL);
6651 rx_tstamp_cycles |= (uint64_t)IXGBE_READ_REG(hw, IXGBE_RXSTMPH)
6655 return rx_tstamp_cycles;
6659 ixgbe_read_tx_tstamp_cyclecounter(struct rte_eth_dev *dev)
6661 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6662 uint64_t tx_tstamp_cycles;
6664 switch (hw->mac.type) {
6665 case ixgbe_mac_X550:
6666 case ixgbe_mac_X550EM_x:
6667 case ixgbe_mac_X550EM_a:
6668 /* TXSTMPL stores ns and TXSTMPH stores seconds. */
6669 tx_tstamp_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_TXSTMPL);
6670 tx_tstamp_cycles += (uint64_t)IXGBE_READ_REG(hw, IXGBE_TXSTMPH)
6674 /* TXSTMPL stores ns and TXSTMPH stores seconds. */
6675 tx_tstamp_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_TXSTMPL);
6676 tx_tstamp_cycles |= (uint64_t)IXGBE_READ_REG(hw, IXGBE_TXSTMPH)
6680 return tx_tstamp_cycles;
6684 ixgbe_start_timecounters(struct rte_eth_dev *dev)
6686 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6687 struct ixgbe_adapter *adapter =
6688 (struct ixgbe_adapter *)dev->data->dev_private;
6689 struct rte_eth_link link;
6690 uint32_t incval = 0;
6693 /* Get current link speed. */
6694 memset(&link, 0, sizeof(link));
6695 ixgbe_dev_link_update(dev, 1);
6696 rte_ixgbe_dev_atomic_read_link_status(dev, &link);
6698 switch (link.link_speed) {
6699 case ETH_SPEED_NUM_100M:
6700 incval = IXGBE_INCVAL_100;
6701 shift = IXGBE_INCVAL_SHIFT_100;
6703 case ETH_SPEED_NUM_1G:
6704 incval = IXGBE_INCVAL_1GB;
6705 shift = IXGBE_INCVAL_SHIFT_1GB;
6707 case ETH_SPEED_NUM_10G:
6709 incval = IXGBE_INCVAL_10GB;
6710 shift = IXGBE_INCVAL_SHIFT_10GB;
6714 switch (hw->mac.type) {
6715 case ixgbe_mac_X550:
6716 case ixgbe_mac_X550EM_x:
6717 case ixgbe_mac_X550EM_a:
6718 /* Independent of link speed. */
6720 /* Cycles read will be interpreted as ns. */
6723 case ixgbe_mac_X540:
6724 IXGBE_WRITE_REG(hw, IXGBE_TIMINCA, incval);
6726 case ixgbe_mac_82599EB:
6727 incval >>= IXGBE_INCVAL_SHIFT_82599;
6728 shift -= IXGBE_INCVAL_SHIFT_82599;
6729 IXGBE_WRITE_REG(hw, IXGBE_TIMINCA,
6730 (1 << IXGBE_INCPER_SHIFT_82599) | incval);
6733 /* Not supported. */
6737 memset(&adapter->systime_tc, 0, sizeof(struct rte_timecounter));
6738 memset(&adapter->rx_tstamp_tc, 0, sizeof(struct rte_timecounter));
6739 memset(&adapter->tx_tstamp_tc, 0, sizeof(struct rte_timecounter));
6741 adapter->systime_tc.cc_mask = IXGBE_CYCLECOUNTER_MASK;
6742 adapter->systime_tc.cc_shift = shift;
6743 adapter->systime_tc.nsec_mask = (1ULL << shift) - 1;
6745 adapter->rx_tstamp_tc.cc_mask = IXGBE_CYCLECOUNTER_MASK;
6746 adapter->rx_tstamp_tc.cc_shift = shift;
6747 adapter->rx_tstamp_tc.nsec_mask = (1ULL << shift) - 1;
6749 adapter->tx_tstamp_tc.cc_mask = IXGBE_CYCLECOUNTER_MASK;
6750 adapter->tx_tstamp_tc.cc_shift = shift;
6751 adapter->tx_tstamp_tc.nsec_mask = (1ULL << shift) - 1;
6755 ixgbe_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta)
6757 struct ixgbe_adapter *adapter =
6758 (struct ixgbe_adapter *)dev->data->dev_private;
6760 adapter->systime_tc.nsec += delta;
6761 adapter->rx_tstamp_tc.nsec += delta;
6762 adapter->tx_tstamp_tc.nsec += delta;
6768 ixgbe_timesync_write_time(struct rte_eth_dev *dev, const struct timespec *ts)
6771 struct ixgbe_adapter *adapter =
6772 (struct ixgbe_adapter *)dev->data->dev_private;
6774 ns = rte_timespec_to_ns(ts);
6775 /* Set the timecounters to a new value. */
6776 adapter->systime_tc.nsec = ns;
6777 adapter->rx_tstamp_tc.nsec = ns;
6778 adapter->tx_tstamp_tc.nsec = ns;
6784 ixgbe_timesync_read_time(struct rte_eth_dev *dev, struct timespec *ts)
6786 uint64_t ns, systime_cycles;
6787 struct ixgbe_adapter *adapter =
6788 (struct ixgbe_adapter *)dev->data->dev_private;
6790 systime_cycles = ixgbe_read_systime_cyclecounter(dev);
6791 ns = rte_timecounter_update(&adapter->systime_tc, systime_cycles);
6792 *ts = rte_ns_to_timespec(ns);
6798 ixgbe_timesync_enable(struct rte_eth_dev *dev)
6800 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6804 /* Stop the timesync system time. */
6805 IXGBE_WRITE_REG(hw, IXGBE_TIMINCA, 0x0);
6806 /* Reset the timesync system time value. */
6807 IXGBE_WRITE_REG(hw, IXGBE_SYSTIML, 0x0);
6808 IXGBE_WRITE_REG(hw, IXGBE_SYSTIMH, 0x0);
6810 /* Enable system time for platforms where it isn't on by default. */
6811 tsauxc = IXGBE_READ_REG(hw, IXGBE_TSAUXC);
6812 tsauxc &= ~IXGBE_TSAUXC_DISABLE_SYSTIME;
6813 IXGBE_WRITE_REG(hw, IXGBE_TSAUXC, tsauxc);
6815 ixgbe_start_timecounters(dev);
6817 /* Enable L2 filtering of IEEE1588/802.1AS Ethernet frame types. */
6818 IXGBE_WRITE_REG(hw, IXGBE_ETQF(IXGBE_ETQF_FILTER_1588),
6820 IXGBE_ETQF_FILTER_EN |
6823 /* Enable timestamping of received PTP packets. */
6824 tsync_ctl = IXGBE_READ_REG(hw, IXGBE_TSYNCRXCTL);
6825 tsync_ctl |= IXGBE_TSYNCRXCTL_ENABLED;
6826 IXGBE_WRITE_REG(hw, IXGBE_TSYNCRXCTL, tsync_ctl);
6828 /* Enable timestamping of transmitted PTP packets. */
6829 tsync_ctl = IXGBE_READ_REG(hw, IXGBE_TSYNCTXCTL);
6830 tsync_ctl |= IXGBE_TSYNCTXCTL_ENABLED;
6831 IXGBE_WRITE_REG(hw, IXGBE_TSYNCTXCTL, tsync_ctl);
6833 IXGBE_WRITE_FLUSH(hw);
6839 ixgbe_timesync_disable(struct rte_eth_dev *dev)
6841 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6844 /* Disable timestamping of transmitted PTP packets. */
6845 tsync_ctl = IXGBE_READ_REG(hw, IXGBE_TSYNCTXCTL);
6846 tsync_ctl &= ~IXGBE_TSYNCTXCTL_ENABLED;
6847 IXGBE_WRITE_REG(hw, IXGBE_TSYNCTXCTL, tsync_ctl);
6849 /* Disable timestamping of received PTP packets. */
6850 tsync_ctl = IXGBE_READ_REG(hw, IXGBE_TSYNCRXCTL);
6851 tsync_ctl &= ~IXGBE_TSYNCRXCTL_ENABLED;
6852 IXGBE_WRITE_REG(hw, IXGBE_TSYNCRXCTL, tsync_ctl);
6854 /* Disable L2 filtering of IEEE1588/802.1AS Ethernet frame types. */
6855 IXGBE_WRITE_REG(hw, IXGBE_ETQF(IXGBE_ETQF_FILTER_1588), 0);
6857 /* Stop incrementating the System Time registers. */
6858 IXGBE_WRITE_REG(hw, IXGBE_TIMINCA, 0);
6864 ixgbe_timesync_read_rx_timestamp(struct rte_eth_dev *dev,
6865 struct timespec *timestamp,
6866 uint32_t flags __rte_unused)
6868 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6869 struct ixgbe_adapter *adapter =
6870 (struct ixgbe_adapter *)dev->data->dev_private;
6871 uint32_t tsync_rxctl;
6872 uint64_t rx_tstamp_cycles;
6875 tsync_rxctl = IXGBE_READ_REG(hw, IXGBE_TSYNCRXCTL);
6876 if ((tsync_rxctl & IXGBE_TSYNCRXCTL_VALID) == 0)
6879 rx_tstamp_cycles = ixgbe_read_rx_tstamp_cyclecounter(dev);
6880 ns = rte_timecounter_update(&adapter->rx_tstamp_tc, rx_tstamp_cycles);
6881 *timestamp = rte_ns_to_timespec(ns);
6887 ixgbe_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
6888 struct timespec *timestamp)
6890 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6891 struct ixgbe_adapter *adapter =
6892 (struct ixgbe_adapter *)dev->data->dev_private;
6893 uint32_t tsync_txctl;
6894 uint64_t tx_tstamp_cycles;
6897 tsync_txctl = IXGBE_READ_REG(hw, IXGBE_TSYNCTXCTL);
6898 if ((tsync_txctl & IXGBE_TSYNCTXCTL_VALID) == 0)
6901 tx_tstamp_cycles = ixgbe_read_tx_tstamp_cyclecounter(dev);
6902 ns = rte_timecounter_update(&adapter->tx_tstamp_tc, tx_tstamp_cycles);
6903 *timestamp = rte_ns_to_timespec(ns);
6909 ixgbe_get_reg_length(struct rte_eth_dev *dev)
6911 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6914 const struct reg_info *reg_group;
6915 const struct reg_info **reg_set = (hw->mac.type == ixgbe_mac_82598EB) ?
6916 ixgbe_regs_mac_82598EB : ixgbe_regs_others;
6918 while ((reg_group = reg_set[g_ind++]))
6919 count += ixgbe_regs_group_count(reg_group);
6925 ixgbevf_get_reg_length(struct rte_eth_dev *dev __rte_unused)
6929 const struct reg_info *reg_group;
6931 while ((reg_group = ixgbevf_regs[g_ind++]))
6932 count += ixgbe_regs_group_count(reg_group);
6938 ixgbe_get_regs(struct rte_eth_dev *dev,
6939 struct rte_dev_reg_info *regs)
6941 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6942 uint32_t *data = regs->data;
6945 const struct reg_info *reg_group;
6946 const struct reg_info **reg_set = (hw->mac.type == ixgbe_mac_82598EB) ?
6947 ixgbe_regs_mac_82598EB : ixgbe_regs_others;
6950 regs->length = ixgbe_get_reg_length(dev);
6951 regs->width = sizeof(uint32_t);
6955 /* Support only full register dump */
6956 if ((regs->length == 0) ||
6957 (regs->length == (uint32_t)ixgbe_get_reg_length(dev))) {
6958 regs->version = hw->mac.type << 24 | hw->revision_id << 16 |
6960 while ((reg_group = reg_set[g_ind++]))
6961 count += ixgbe_read_regs_group(dev, &data[count],
6970 ixgbevf_get_regs(struct rte_eth_dev *dev,
6971 struct rte_dev_reg_info *regs)
6973 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6974 uint32_t *data = regs->data;
6977 const struct reg_info *reg_group;
6980 regs->length = ixgbevf_get_reg_length(dev);
6981 regs->width = sizeof(uint32_t);
6985 /* Support only full register dump */
6986 if ((regs->length == 0) ||
6987 (regs->length == (uint32_t)ixgbevf_get_reg_length(dev))) {
6988 regs->version = hw->mac.type << 24 | hw->revision_id << 16 |
6990 while ((reg_group = ixgbevf_regs[g_ind++]))
6991 count += ixgbe_read_regs_group(dev, &data[count],
7000 ixgbe_get_eeprom_length(struct rte_eth_dev *dev)
7002 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7004 /* Return unit is byte count */
7005 return hw->eeprom.word_size * 2;
7009 ixgbe_get_eeprom(struct rte_eth_dev *dev,
7010 struct rte_dev_eeprom_info *in_eeprom)
7012 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7013 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
7014 uint16_t *data = in_eeprom->data;
7017 first = in_eeprom->offset >> 1;
7018 length = in_eeprom->length >> 1;
7019 if ((first > hw->eeprom.word_size) ||
7020 ((first + length) > hw->eeprom.word_size))
7023 in_eeprom->magic = hw->vendor_id | (hw->device_id << 16);
7025 return eeprom->ops.read_buffer(hw, first, length, data);
7029 ixgbe_set_eeprom(struct rte_eth_dev *dev,
7030 struct rte_dev_eeprom_info *in_eeprom)
7032 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7033 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
7034 uint16_t *data = in_eeprom->data;
7037 first = in_eeprom->offset >> 1;
7038 length = in_eeprom->length >> 1;
7039 if ((first > hw->eeprom.word_size) ||
7040 ((first + length) > hw->eeprom.word_size))
7043 in_eeprom->magic = hw->vendor_id | (hw->device_id << 16);
7045 return eeprom->ops.write_buffer(hw, first, length, data);
7049 ixgbe_reta_size_get(enum ixgbe_mac_type mac_type) {
7051 case ixgbe_mac_X550:
7052 case ixgbe_mac_X550EM_x:
7053 case ixgbe_mac_X550EM_a:
7054 return ETH_RSS_RETA_SIZE_512;
7055 case ixgbe_mac_X550_vf:
7056 case ixgbe_mac_X550EM_x_vf:
7057 case ixgbe_mac_X550EM_a_vf:
7058 return ETH_RSS_RETA_SIZE_64;
7060 return ETH_RSS_RETA_SIZE_128;
7065 ixgbe_reta_reg_get(enum ixgbe_mac_type mac_type, uint16_t reta_idx) {
7067 case ixgbe_mac_X550:
7068 case ixgbe_mac_X550EM_x:
7069 case ixgbe_mac_X550EM_a:
7070 if (reta_idx < ETH_RSS_RETA_SIZE_128)
7071 return IXGBE_RETA(reta_idx >> 2);
7073 return IXGBE_ERETA((reta_idx - ETH_RSS_RETA_SIZE_128) >> 2);
7074 case ixgbe_mac_X550_vf:
7075 case ixgbe_mac_X550EM_x_vf:
7076 case ixgbe_mac_X550EM_a_vf:
7077 return IXGBE_VFRETA(reta_idx >> 2);
7079 return IXGBE_RETA(reta_idx >> 2);
7084 ixgbe_mrqc_reg_get(enum ixgbe_mac_type mac_type) {
7086 case ixgbe_mac_X550_vf:
7087 case ixgbe_mac_X550EM_x_vf:
7088 case ixgbe_mac_X550EM_a_vf:
7089 return IXGBE_VFMRQC;
7096 ixgbe_rssrk_reg_get(enum ixgbe_mac_type mac_type, uint8_t i) {
7098 case ixgbe_mac_X550_vf:
7099 case ixgbe_mac_X550EM_x_vf:
7100 case ixgbe_mac_X550EM_a_vf:
7101 return IXGBE_VFRSSRK(i);
7103 return IXGBE_RSSRK(i);
7108 ixgbe_rss_update_sp(enum ixgbe_mac_type mac_type) {
7110 case ixgbe_mac_82599_vf:
7111 case ixgbe_mac_X540_vf:
7119 ixgbe_dev_get_dcb_info(struct rte_eth_dev *dev,
7120 struct rte_eth_dcb_info *dcb_info)
7122 struct ixgbe_dcb_config *dcb_config =
7123 IXGBE_DEV_PRIVATE_TO_DCB_CFG(dev->data->dev_private);
7124 struct ixgbe_dcb_tc_config *tc;
7127 if (dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_DCB_FLAG)
7128 dcb_info->nb_tcs = dcb_config->num_tcs.pg_tcs;
7130 dcb_info->nb_tcs = 1;
7132 if (dcb_config->vt_mode) { /* vt is enabled*/
7133 struct rte_eth_vmdq_dcb_conf *vmdq_rx_conf =
7134 &dev->data->dev_conf.rx_adv_conf.vmdq_dcb_conf;
7135 for (i = 0; i < ETH_DCB_NUM_USER_PRIORITIES; i++)
7136 dcb_info->prio_tc[i] = vmdq_rx_conf->dcb_tc[i];
7137 for (i = 0; i < vmdq_rx_conf->nb_queue_pools; i++) {
7138 for (j = 0; j < dcb_info->nb_tcs; j++) {
7139 dcb_info->tc_queue.tc_rxq[i][j].base =
7140 i * dcb_info->nb_tcs + j;
7141 dcb_info->tc_queue.tc_rxq[i][j].nb_queue = 1;
7142 dcb_info->tc_queue.tc_txq[i][j].base =
7143 i * dcb_info->nb_tcs + j;
7144 dcb_info->tc_queue.tc_txq[i][j].nb_queue = 1;
7147 } else { /* vt is disabled*/
7148 struct rte_eth_dcb_rx_conf *rx_conf =
7149 &dev->data->dev_conf.rx_adv_conf.dcb_rx_conf;
7150 for (i = 0; i < ETH_DCB_NUM_USER_PRIORITIES; i++)
7151 dcb_info->prio_tc[i] = rx_conf->dcb_tc[i];
7152 if (dcb_info->nb_tcs == ETH_4_TCS) {
7153 for (i = 0; i < dcb_info->nb_tcs; i++) {
7154 dcb_info->tc_queue.tc_rxq[0][i].base = i * 32;
7155 dcb_info->tc_queue.tc_rxq[0][i].nb_queue = 16;
7157 dcb_info->tc_queue.tc_txq[0][0].base = 0;
7158 dcb_info->tc_queue.tc_txq[0][1].base = 64;
7159 dcb_info->tc_queue.tc_txq[0][2].base = 96;
7160 dcb_info->tc_queue.tc_txq[0][3].base = 112;
7161 dcb_info->tc_queue.tc_txq[0][0].nb_queue = 64;
7162 dcb_info->tc_queue.tc_txq[0][1].nb_queue = 32;
7163 dcb_info->tc_queue.tc_txq[0][2].nb_queue = 16;
7164 dcb_info->tc_queue.tc_txq[0][3].nb_queue = 16;
7165 } else if (dcb_info->nb_tcs == ETH_8_TCS) {
7166 for (i = 0; i < dcb_info->nb_tcs; i++) {
7167 dcb_info->tc_queue.tc_rxq[0][i].base = i * 16;
7168 dcb_info->tc_queue.tc_rxq[0][i].nb_queue = 16;
7170 dcb_info->tc_queue.tc_txq[0][0].base = 0;
7171 dcb_info->tc_queue.tc_txq[0][1].base = 32;
7172 dcb_info->tc_queue.tc_txq[0][2].base = 64;
7173 dcb_info->tc_queue.tc_txq[0][3].base = 80;
7174 dcb_info->tc_queue.tc_txq[0][4].base = 96;
7175 dcb_info->tc_queue.tc_txq[0][5].base = 104;
7176 dcb_info->tc_queue.tc_txq[0][6].base = 112;
7177 dcb_info->tc_queue.tc_txq[0][7].base = 120;
7178 dcb_info->tc_queue.tc_txq[0][0].nb_queue = 32;
7179 dcb_info->tc_queue.tc_txq[0][1].nb_queue = 32;
7180 dcb_info->tc_queue.tc_txq[0][2].nb_queue = 16;
7181 dcb_info->tc_queue.tc_txq[0][3].nb_queue = 16;
7182 dcb_info->tc_queue.tc_txq[0][4].nb_queue = 8;
7183 dcb_info->tc_queue.tc_txq[0][5].nb_queue = 8;
7184 dcb_info->tc_queue.tc_txq[0][6].nb_queue = 8;
7185 dcb_info->tc_queue.tc_txq[0][7].nb_queue = 8;
7188 for (i = 0; i < dcb_info->nb_tcs; i++) {
7189 tc = &dcb_config->tc_config[i];
7190 dcb_info->tc_bws[i] = tc->path[IXGBE_DCB_TX_CONFIG].bwg_percent;
7195 /* Update e-tag ether type */
7197 ixgbe_update_e_tag_eth_type(struct ixgbe_hw *hw,
7198 uint16_t ether_type)
7200 uint32_t etag_etype;
7202 if (hw->mac.type != ixgbe_mac_X550 &&
7203 hw->mac.type != ixgbe_mac_X550EM_x &&
7204 hw->mac.type != ixgbe_mac_X550EM_a) {
7208 etag_etype = IXGBE_READ_REG(hw, IXGBE_ETAG_ETYPE);
7209 etag_etype &= ~IXGBE_ETAG_ETYPE_MASK;
7210 etag_etype |= ether_type;
7211 IXGBE_WRITE_REG(hw, IXGBE_ETAG_ETYPE, etag_etype);
7212 IXGBE_WRITE_FLUSH(hw);
7217 /* Config l2 tunnel ether type */
7219 ixgbe_dev_l2_tunnel_eth_type_conf(struct rte_eth_dev *dev,
7220 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7223 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7224 struct ixgbe_l2_tn_info *l2_tn_info =
7225 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
7227 if (l2_tunnel == NULL)
7230 switch (l2_tunnel->l2_tunnel_type) {
7231 case RTE_L2_TUNNEL_TYPE_E_TAG:
7232 l2_tn_info->e_tag_ether_type = l2_tunnel->ether_type;
7233 ret = ixgbe_update_e_tag_eth_type(hw, l2_tunnel->ether_type);
7236 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7244 /* Enable e-tag tunnel */
7246 ixgbe_e_tag_enable(struct ixgbe_hw *hw)
7248 uint32_t etag_etype;
7250 if (hw->mac.type != ixgbe_mac_X550 &&
7251 hw->mac.type != ixgbe_mac_X550EM_x &&
7252 hw->mac.type != ixgbe_mac_X550EM_a) {
7256 etag_etype = IXGBE_READ_REG(hw, IXGBE_ETAG_ETYPE);
7257 etag_etype |= IXGBE_ETAG_ETYPE_VALID;
7258 IXGBE_WRITE_REG(hw, IXGBE_ETAG_ETYPE, etag_etype);
7259 IXGBE_WRITE_FLUSH(hw);
7264 /* Enable l2 tunnel */
7266 ixgbe_dev_l2_tunnel_enable(struct rte_eth_dev *dev,
7267 enum rte_eth_tunnel_type l2_tunnel_type)
7270 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7271 struct ixgbe_l2_tn_info *l2_tn_info =
7272 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
7274 switch (l2_tunnel_type) {
7275 case RTE_L2_TUNNEL_TYPE_E_TAG:
7276 l2_tn_info->e_tag_en = TRUE;
7277 ret = ixgbe_e_tag_enable(hw);
7280 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7288 /* Disable e-tag tunnel */
7290 ixgbe_e_tag_disable(struct ixgbe_hw *hw)
7292 uint32_t etag_etype;
7294 if (hw->mac.type != ixgbe_mac_X550 &&
7295 hw->mac.type != ixgbe_mac_X550EM_x &&
7296 hw->mac.type != ixgbe_mac_X550EM_a) {
7300 etag_etype = IXGBE_READ_REG(hw, IXGBE_ETAG_ETYPE);
7301 etag_etype &= ~IXGBE_ETAG_ETYPE_VALID;
7302 IXGBE_WRITE_REG(hw, IXGBE_ETAG_ETYPE, etag_etype);
7303 IXGBE_WRITE_FLUSH(hw);
7308 /* Disable l2 tunnel */
7310 ixgbe_dev_l2_tunnel_disable(struct rte_eth_dev *dev,
7311 enum rte_eth_tunnel_type l2_tunnel_type)
7314 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7315 struct ixgbe_l2_tn_info *l2_tn_info =
7316 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
7318 switch (l2_tunnel_type) {
7319 case RTE_L2_TUNNEL_TYPE_E_TAG:
7320 l2_tn_info->e_tag_en = FALSE;
7321 ret = ixgbe_e_tag_disable(hw);
7324 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7333 ixgbe_e_tag_filter_del(struct rte_eth_dev *dev,
7334 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7337 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7338 uint32_t i, rar_entries;
7339 uint32_t rar_low, rar_high;
7341 if (hw->mac.type != ixgbe_mac_X550 &&
7342 hw->mac.type != ixgbe_mac_X550EM_x &&
7343 hw->mac.type != ixgbe_mac_X550EM_a) {
7347 rar_entries = ixgbe_get_num_rx_addrs(hw);
7349 for (i = 1; i < rar_entries; i++) {
7350 rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(i));
7351 rar_low = IXGBE_READ_REG(hw, IXGBE_RAL(i));
7352 if ((rar_high & IXGBE_RAH_AV) &&
7353 (rar_high & IXGBE_RAH_ADTYPE) &&
7354 ((rar_low & IXGBE_RAL_ETAG_FILTER_MASK) ==
7355 l2_tunnel->tunnel_id)) {
7356 IXGBE_WRITE_REG(hw, IXGBE_RAL(i), 0);
7357 IXGBE_WRITE_REG(hw, IXGBE_RAH(i), 0);
7359 ixgbe_clear_vmdq(hw, i, IXGBE_CLEAR_VMDQ_ALL);
7369 ixgbe_e_tag_filter_add(struct rte_eth_dev *dev,
7370 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7373 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7374 uint32_t i, rar_entries;
7375 uint32_t rar_low, rar_high;
7377 if (hw->mac.type != ixgbe_mac_X550 &&
7378 hw->mac.type != ixgbe_mac_X550EM_x &&
7379 hw->mac.type != ixgbe_mac_X550EM_a) {
7383 /* One entry for one tunnel. Try to remove potential existing entry. */
7384 ixgbe_e_tag_filter_del(dev, l2_tunnel);
7386 rar_entries = ixgbe_get_num_rx_addrs(hw);
7388 for (i = 1; i < rar_entries; i++) {
7389 rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(i));
7390 if (rar_high & IXGBE_RAH_AV) {
7393 ixgbe_set_vmdq(hw, i, l2_tunnel->pool);
7394 rar_high = IXGBE_RAH_AV | IXGBE_RAH_ADTYPE;
7395 rar_low = l2_tunnel->tunnel_id;
7397 IXGBE_WRITE_REG(hw, IXGBE_RAL(i), rar_low);
7398 IXGBE_WRITE_REG(hw, IXGBE_RAH(i), rar_high);
7404 PMD_INIT_LOG(NOTICE, "The table of E-tag forwarding rule is full."
7405 " Please remove a rule before adding a new one.");
7409 static inline struct ixgbe_l2_tn_filter *
7410 ixgbe_l2_tn_filter_lookup(struct ixgbe_l2_tn_info *l2_tn_info,
7411 struct ixgbe_l2_tn_key *key)
7415 ret = rte_hash_lookup(l2_tn_info->hash_handle, (const void *)key);
7419 return l2_tn_info->hash_map[ret];
7423 ixgbe_insert_l2_tn_filter(struct ixgbe_l2_tn_info *l2_tn_info,
7424 struct ixgbe_l2_tn_filter *l2_tn_filter)
7428 ret = rte_hash_add_key(l2_tn_info->hash_handle,
7429 &l2_tn_filter->key);
7433 "Failed to insert L2 tunnel filter"
7434 " to hash table %d!",
7439 l2_tn_info->hash_map[ret] = l2_tn_filter;
7441 TAILQ_INSERT_TAIL(&l2_tn_info->l2_tn_list, l2_tn_filter, entries);
7447 ixgbe_remove_l2_tn_filter(struct ixgbe_l2_tn_info *l2_tn_info,
7448 struct ixgbe_l2_tn_key *key)
7451 struct ixgbe_l2_tn_filter *l2_tn_filter;
7453 ret = rte_hash_del_key(l2_tn_info->hash_handle, key);
7457 "No such L2 tunnel filter to delete %d!",
7462 l2_tn_filter = l2_tn_info->hash_map[ret];
7463 l2_tn_info->hash_map[ret] = NULL;
7465 TAILQ_REMOVE(&l2_tn_info->l2_tn_list, l2_tn_filter, entries);
7466 rte_free(l2_tn_filter);
7471 /* Add l2 tunnel filter */
7473 ixgbe_dev_l2_tunnel_filter_add(struct rte_eth_dev *dev,
7474 struct rte_eth_l2_tunnel_conf *l2_tunnel,
7478 struct ixgbe_l2_tn_info *l2_tn_info =
7479 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
7480 struct ixgbe_l2_tn_key key;
7481 struct ixgbe_l2_tn_filter *node;
7484 key.l2_tn_type = l2_tunnel->l2_tunnel_type;
7485 key.tn_id = l2_tunnel->tunnel_id;
7487 node = ixgbe_l2_tn_filter_lookup(l2_tn_info, &key);
7491 "The L2 tunnel filter already exists!");
7495 node = rte_zmalloc("ixgbe_l2_tn",
7496 sizeof(struct ixgbe_l2_tn_filter),
7501 (void)rte_memcpy(&node->key,
7503 sizeof(struct ixgbe_l2_tn_key));
7504 node->pool = l2_tunnel->pool;
7505 ret = ixgbe_insert_l2_tn_filter(l2_tn_info, node);
7512 switch (l2_tunnel->l2_tunnel_type) {
7513 case RTE_L2_TUNNEL_TYPE_E_TAG:
7514 ret = ixgbe_e_tag_filter_add(dev, l2_tunnel);
7517 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7522 if ((!restore) && (ret < 0))
7523 (void)ixgbe_remove_l2_tn_filter(l2_tn_info, &key);
7528 /* Delete l2 tunnel filter */
7530 ixgbe_dev_l2_tunnel_filter_del(struct rte_eth_dev *dev,
7531 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7534 struct ixgbe_l2_tn_info *l2_tn_info =
7535 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
7536 struct ixgbe_l2_tn_key key;
7538 key.l2_tn_type = l2_tunnel->l2_tunnel_type;
7539 key.tn_id = l2_tunnel->tunnel_id;
7540 ret = ixgbe_remove_l2_tn_filter(l2_tn_info, &key);
7544 switch (l2_tunnel->l2_tunnel_type) {
7545 case RTE_L2_TUNNEL_TYPE_E_TAG:
7546 ret = ixgbe_e_tag_filter_del(dev, l2_tunnel);
7549 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7558 * ixgbe_dev_l2_tunnel_filter_handle - Handle operations for l2 tunnel filter.
7559 * @dev: pointer to rte_eth_dev structure
7560 * @filter_op:operation will be taken.
7561 * @arg: a pointer to specific structure corresponding to the filter_op
7564 ixgbe_dev_l2_tunnel_filter_handle(struct rte_eth_dev *dev,
7565 enum rte_filter_op filter_op,
7570 if (filter_op == RTE_ETH_FILTER_NOP)
7574 PMD_DRV_LOG(ERR, "arg shouldn't be NULL for operation %u.",
7579 switch (filter_op) {
7580 case RTE_ETH_FILTER_ADD:
7581 ret = ixgbe_dev_l2_tunnel_filter_add
7583 (struct rte_eth_l2_tunnel_conf *)arg,
7586 case RTE_ETH_FILTER_DELETE:
7587 ret = ixgbe_dev_l2_tunnel_filter_del
7589 (struct rte_eth_l2_tunnel_conf *)arg);
7592 PMD_DRV_LOG(ERR, "unsupported operation %u.", filter_op);
7600 ixgbe_e_tag_forwarding_en_dis(struct rte_eth_dev *dev, bool en)
7604 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7606 if (hw->mac.type != ixgbe_mac_X550 &&
7607 hw->mac.type != ixgbe_mac_X550EM_x &&
7608 hw->mac.type != ixgbe_mac_X550EM_a) {
7612 ctrl = IXGBE_READ_REG(hw, IXGBE_VT_CTL);
7613 ctrl &= ~IXGBE_VT_CTL_POOLING_MODE_MASK;
7615 ctrl |= IXGBE_VT_CTL_POOLING_MODE_ETAG;
7616 IXGBE_WRITE_REG(hw, IXGBE_VT_CTL, ctrl);
7621 /* Enable l2 tunnel forwarding */
7623 ixgbe_dev_l2_tunnel_forwarding_enable
7624 (struct rte_eth_dev *dev,
7625 enum rte_eth_tunnel_type l2_tunnel_type)
7627 struct ixgbe_l2_tn_info *l2_tn_info =
7628 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
7631 switch (l2_tunnel_type) {
7632 case RTE_L2_TUNNEL_TYPE_E_TAG:
7633 l2_tn_info->e_tag_fwd_en = TRUE;
7634 ret = ixgbe_e_tag_forwarding_en_dis(dev, 1);
7637 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7645 /* Disable l2 tunnel forwarding */
7647 ixgbe_dev_l2_tunnel_forwarding_disable
7648 (struct rte_eth_dev *dev,
7649 enum rte_eth_tunnel_type l2_tunnel_type)
7651 struct ixgbe_l2_tn_info *l2_tn_info =
7652 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
7655 switch (l2_tunnel_type) {
7656 case RTE_L2_TUNNEL_TYPE_E_TAG:
7657 l2_tn_info->e_tag_fwd_en = FALSE;
7658 ret = ixgbe_e_tag_forwarding_en_dis(dev, 0);
7661 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7670 ixgbe_e_tag_insertion_en_dis(struct rte_eth_dev *dev,
7671 struct rte_eth_l2_tunnel_conf *l2_tunnel,
7674 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
7676 uint32_t vmtir, vmvir;
7677 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7679 if (l2_tunnel->vf_id >= pci_dev->max_vfs) {
7681 "VF id %u should be less than %u",
7687 if (hw->mac.type != ixgbe_mac_X550 &&
7688 hw->mac.type != ixgbe_mac_X550EM_x &&
7689 hw->mac.type != ixgbe_mac_X550EM_a) {
7694 vmtir = l2_tunnel->tunnel_id;
7698 IXGBE_WRITE_REG(hw, IXGBE_VMTIR(l2_tunnel->vf_id), vmtir);
7700 vmvir = IXGBE_READ_REG(hw, IXGBE_VMVIR(l2_tunnel->vf_id));
7701 vmvir &= ~IXGBE_VMVIR_TAGA_MASK;
7703 vmvir |= IXGBE_VMVIR_TAGA_ETAG_INSERT;
7704 IXGBE_WRITE_REG(hw, IXGBE_VMVIR(l2_tunnel->vf_id), vmvir);
7709 /* Enable l2 tunnel tag insertion */
7711 ixgbe_dev_l2_tunnel_insertion_enable(struct rte_eth_dev *dev,
7712 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7716 switch (l2_tunnel->l2_tunnel_type) {
7717 case RTE_L2_TUNNEL_TYPE_E_TAG:
7718 ret = ixgbe_e_tag_insertion_en_dis(dev, l2_tunnel, 1);
7721 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7729 /* Disable l2 tunnel tag insertion */
7731 ixgbe_dev_l2_tunnel_insertion_disable
7732 (struct rte_eth_dev *dev,
7733 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7737 switch (l2_tunnel->l2_tunnel_type) {
7738 case RTE_L2_TUNNEL_TYPE_E_TAG:
7739 ret = ixgbe_e_tag_insertion_en_dis(dev, l2_tunnel, 0);
7742 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7751 ixgbe_e_tag_stripping_en_dis(struct rte_eth_dev *dev,
7756 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7758 if (hw->mac.type != ixgbe_mac_X550 &&
7759 hw->mac.type != ixgbe_mac_X550EM_x &&
7760 hw->mac.type != ixgbe_mac_X550EM_a) {
7764 qde = IXGBE_READ_REG(hw, IXGBE_QDE);
7766 qde |= IXGBE_QDE_STRIP_TAG;
7768 qde &= ~IXGBE_QDE_STRIP_TAG;
7769 qde &= ~IXGBE_QDE_READ;
7770 qde |= IXGBE_QDE_WRITE;
7771 IXGBE_WRITE_REG(hw, IXGBE_QDE, qde);
7776 /* Enable l2 tunnel tag stripping */
7778 ixgbe_dev_l2_tunnel_stripping_enable
7779 (struct rte_eth_dev *dev,
7780 enum rte_eth_tunnel_type l2_tunnel_type)
7784 switch (l2_tunnel_type) {
7785 case RTE_L2_TUNNEL_TYPE_E_TAG:
7786 ret = ixgbe_e_tag_stripping_en_dis(dev, 1);
7789 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7797 /* Disable l2 tunnel tag stripping */
7799 ixgbe_dev_l2_tunnel_stripping_disable
7800 (struct rte_eth_dev *dev,
7801 enum rte_eth_tunnel_type l2_tunnel_type)
7805 switch (l2_tunnel_type) {
7806 case RTE_L2_TUNNEL_TYPE_E_TAG:
7807 ret = ixgbe_e_tag_stripping_en_dis(dev, 0);
7810 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7818 /* Enable/disable l2 tunnel offload functions */
7820 ixgbe_dev_l2_tunnel_offload_set
7821 (struct rte_eth_dev *dev,
7822 struct rte_eth_l2_tunnel_conf *l2_tunnel,
7828 if (l2_tunnel == NULL)
7832 if (mask & ETH_L2_TUNNEL_ENABLE_MASK) {
7834 ret = ixgbe_dev_l2_tunnel_enable(
7836 l2_tunnel->l2_tunnel_type);
7838 ret = ixgbe_dev_l2_tunnel_disable(
7840 l2_tunnel->l2_tunnel_type);
7843 if (mask & ETH_L2_TUNNEL_INSERTION_MASK) {
7845 ret = ixgbe_dev_l2_tunnel_insertion_enable(
7849 ret = ixgbe_dev_l2_tunnel_insertion_disable(
7854 if (mask & ETH_L2_TUNNEL_STRIPPING_MASK) {
7856 ret = ixgbe_dev_l2_tunnel_stripping_enable(
7858 l2_tunnel->l2_tunnel_type);
7860 ret = ixgbe_dev_l2_tunnel_stripping_disable(
7862 l2_tunnel->l2_tunnel_type);
7865 if (mask & ETH_L2_TUNNEL_FORWARDING_MASK) {
7867 ret = ixgbe_dev_l2_tunnel_forwarding_enable(
7869 l2_tunnel->l2_tunnel_type);
7871 ret = ixgbe_dev_l2_tunnel_forwarding_disable(
7873 l2_tunnel->l2_tunnel_type);
7880 ixgbe_update_vxlan_port(struct ixgbe_hw *hw,
7883 IXGBE_WRITE_REG(hw, IXGBE_VXLANCTRL, port);
7884 IXGBE_WRITE_FLUSH(hw);
7889 /* There's only one register for VxLAN UDP port.
7890 * So, we cannot add several ports. Will update it.
7893 ixgbe_add_vxlan_port(struct ixgbe_hw *hw,
7897 PMD_DRV_LOG(ERR, "Add VxLAN port 0 is not allowed.");
7901 return ixgbe_update_vxlan_port(hw, port);
7904 /* We cannot delete the VxLAN port. For there's a register for VxLAN
7905 * UDP port, it must have a value.
7906 * So, will reset it to the original value 0.
7909 ixgbe_del_vxlan_port(struct ixgbe_hw *hw,
7914 cur_port = (uint16_t)IXGBE_READ_REG(hw, IXGBE_VXLANCTRL);
7916 if (cur_port != port) {
7917 PMD_DRV_LOG(ERR, "Port %u does not exist.", port);
7921 return ixgbe_update_vxlan_port(hw, 0);
7924 /* Add UDP tunneling port */
7926 ixgbe_dev_udp_tunnel_port_add(struct rte_eth_dev *dev,
7927 struct rte_eth_udp_tunnel *udp_tunnel)
7930 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7932 if (hw->mac.type != ixgbe_mac_X550 &&
7933 hw->mac.type != ixgbe_mac_X550EM_x &&
7934 hw->mac.type != ixgbe_mac_X550EM_a) {
7938 if (udp_tunnel == NULL)
7941 switch (udp_tunnel->prot_type) {
7942 case RTE_TUNNEL_TYPE_VXLAN:
7943 ret = ixgbe_add_vxlan_port(hw, udp_tunnel->udp_port);
7946 case RTE_TUNNEL_TYPE_GENEVE:
7947 case RTE_TUNNEL_TYPE_TEREDO:
7948 PMD_DRV_LOG(ERR, "Tunnel type is not supported now.");
7953 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7961 /* Remove UDP tunneling port */
7963 ixgbe_dev_udp_tunnel_port_del(struct rte_eth_dev *dev,
7964 struct rte_eth_udp_tunnel *udp_tunnel)
7967 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7969 if (hw->mac.type != ixgbe_mac_X550 &&
7970 hw->mac.type != ixgbe_mac_X550EM_x &&
7971 hw->mac.type != ixgbe_mac_X550EM_a) {
7975 if (udp_tunnel == NULL)
7978 switch (udp_tunnel->prot_type) {
7979 case RTE_TUNNEL_TYPE_VXLAN:
7980 ret = ixgbe_del_vxlan_port(hw, udp_tunnel->udp_port);
7982 case RTE_TUNNEL_TYPE_GENEVE:
7983 case RTE_TUNNEL_TYPE_TEREDO:
7984 PMD_DRV_LOG(ERR, "Tunnel type is not supported now.");
7988 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7997 ixgbevf_dev_allmulticast_enable(struct rte_eth_dev *dev)
7999 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8001 hw->mac.ops.update_xcast_mode(hw, IXGBEVF_XCAST_MODE_ALLMULTI);
8005 ixgbevf_dev_allmulticast_disable(struct rte_eth_dev *dev)
8007 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8009 hw->mac.ops.update_xcast_mode(hw, IXGBEVF_XCAST_MODE_MULTI);
8012 static void ixgbevf_mbx_process(struct rte_eth_dev *dev)
8014 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8017 if (ixgbe_read_mbx(hw, &in_msg, 1, 0))
8020 /* PF reset VF event */
8021 if (in_msg == IXGBE_PF_CONTROL_MSG)
8022 _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RESET,
8027 ixgbevf_dev_interrupt_get_status(struct rte_eth_dev *dev)
8030 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8031 struct ixgbe_interrupt *intr =
8032 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
8033 ixgbevf_intr_disable(hw);
8035 /* read-on-clear nic registers here */
8036 eicr = IXGBE_READ_REG(hw, IXGBE_VTEICR);
8039 /* only one misc vector supported - mailbox */
8040 eicr &= IXGBE_VTEICR_MASK;
8041 if (eicr == IXGBE_MISC_VEC_ID)
8042 intr->flags |= IXGBE_FLAG_MAILBOX;
8048 ixgbevf_dev_interrupt_action(struct rte_eth_dev *dev)
8050 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8051 struct ixgbe_interrupt *intr =
8052 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
8054 if (intr->flags & IXGBE_FLAG_MAILBOX) {
8055 ixgbevf_mbx_process(dev);
8056 intr->flags &= ~IXGBE_FLAG_MAILBOX;
8059 ixgbevf_intr_enable(hw);
8065 ixgbevf_dev_interrupt_handler(void *param)
8067 struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
8069 ixgbevf_dev_interrupt_get_status(dev);
8070 ixgbevf_dev_interrupt_action(dev);
8074 * ixgbe_disable_sec_tx_path_generic - Stops the transmit data path
8075 * @hw: pointer to hardware structure
8077 * Stops the transmit data path and waits for the HW to internally empty
8078 * the Tx security block
8080 int ixgbe_disable_sec_tx_path_generic(struct ixgbe_hw *hw)
8082 #define IXGBE_MAX_SECTX_POLL 40
8087 sectxreg = IXGBE_READ_REG(hw, IXGBE_SECTXCTRL);
8088 sectxreg |= IXGBE_SECTXCTRL_TX_DIS;
8089 IXGBE_WRITE_REG(hw, IXGBE_SECTXCTRL, sectxreg);
8090 for (i = 0; i < IXGBE_MAX_SECTX_POLL; i++) {
8091 sectxreg = IXGBE_READ_REG(hw, IXGBE_SECTXSTAT);
8092 if (sectxreg & IXGBE_SECTXSTAT_SECTX_RDY)
8094 /* Use interrupt-safe sleep just in case */
8098 /* For informational purposes only */
8099 if (i >= IXGBE_MAX_SECTX_POLL)
8100 PMD_DRV_LOG(DEBUG, "Tx unit being enabled before security "
8101 "path fully disabled. Continuing with init.");
8103 return IXGBE_SUCCESS;
8107 * ixgbe_enable_sec_tx_path_generic - Enables the transmit data path
8108 * @hw: pointer to hardware structure
8110 * Enables the transmit data path.
8112 int ixgbe_enable_sec_tx_path_generic(struct ixgbe_hw *hw)
8116 sectxreg = IXGBE_READ_REG(hw, IXGBE_SECTXCTRL);
8117 sectxreg &= ~IXGBE_SECTXCTRL_TX_DIS;
8118 IXGBE_WRITE_REG(hw, IXGBE_SECTXCTRL, sectxreg);
8119 IXGBE_WRITE_FLUSH(hw);
8121 return IXGBE_SUCCESS;
8124 /* restore n-tuple filter */
8126 ixgbe_ntuple_filter_restore(struct rte_eth_dev *dev)
8128 struct ixgbe_filter_info *filter_info =
8129 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
8130 struct ixgbe_5tuple_filter *node;
8132 TAILQ_FOREACH(node, &filter_info->fivetuple_list, entries) {
8133 ixgbe_inject_5tuple_filter(dev, node);
8137 /* restore ethernet type filter */
8139 ixgbe_ethertype_filter_restore(struct rte_eth_dev *dev)
8141 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8142 struct ixgbe_filter_info *filter_info =
8143 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
8146 for (i = 0; i < IXGBE_MAX_ETQF_FILTERS; i++) {
8147 if (filter_info->ethertype_mask & (1 << i)) {
8148 IXGBE_WRITE_REG(hw, IXGBE_ETQF(i),
8149 filter_info->ethertype_filters[i].etqf);
8150 IXGBE_WRITE_REG(hw, IXGBE_ETQS(i),
8151 filter_info->ethertype_filters[i].etqs);
8152 IXGBE_WRITE_FLUSH(hw);
8157 /* restore SYN filter */
8159 ixgbe_syn_filter_restore(struct rte_eth_dev *dev)
8161 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8162 struct ixgbe_filter_info *filter_info =
8163 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
8166 synqf = filter_info->syn_info;
8168 if (synqf & IXGBE_SYN_FILTER_ENABLE) {
8169 IXGBE_WRITE_REG(hw, IXGBE_SYNQF, synqf);
8170 IXGBE_WRITE_FLUSH(hw);
8174 /* restore L2 tunnel filter */
8176 ixgbe_l2_tn_filter_restore(struct rte_eth_dev *dev)
8178 struct ixgbe_l2_tn_info *l2_tn_info =
8179 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
8180 struct ixgbe_l2_tn_filter *node;
8181 struct rte_eth_l2_tunnel_conf l2_tn_conf;
8183 TAILQ_FOREACH(node, &l2_tn_info->l2_tn_list, entries) {
8184 l2_tn_conf.l2_tunnel_type = node->key.l2_tn_type;
8185 l2_tn_conf.tunnel_id = node->key.tn_id;
8186 l2_tn_conf.pool = node->pool;
8187 (void)ixgbe_dev_l2_tunnel_filter_add(dev, &l2_tn_conf, TRUE);
8192 ixgbe_filter_restore(struct rte_eth_dev *dev)
8194 ixgbe_ntuple_filter_restore(dev);
8195 ixgbe_ethertype_filter_restore(dev);
8196 ixgbe_syn_filter_restore(dev);
8197 ixgbe_fdir_filter_restore(dev);
8198 ixgbe_l2_tn_filter_restore(dev);
8204 ixgbe_l2_tunnel_conf(struct rte_eth_dev *dev)
8206 struct ixgbe_l2_tn_info *l2_tn_info =
8207 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
8208 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8210 if (l2_tn_info->e_tag_en)
8211 (void)ixgbe_e_tag_enable(hw);
8213 if (l2_tn_info->e_tag_fwd_en)
8214 (void)ixgbe_e_tag_forwarding_en_dis(dev, 1);
8216 (void)ixgbe_update_e_tag_eth_type(hw, l2_tn_info->e_tag_ether_type);
8219 /* remove all the n-tuple filters */
8221 ixgbe_clear_all_ntuple_filter(struct rte_eth_dev *dev)
8223 struct ixgbe_filter_info *filter_info =
8224 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
8225 struct ixgbe_5tuple_filter *p_5tuple;
8227 while ((p_5tuple = TAILQ_FIRST(&filter_info->fivetuple_list)))
8228 ixgbe_remove_5tuple_filter(dev, p_5tuple);
8231 /* remove all the ether type filters */
8233 ixgbe_clear_all_ethertype_filter(struct rte_eth_dev *dev)
8235 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8236 struct ixgbe_filter_info *filter_info =
8237 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
8240 for (i = 0; i < IXGBE_MAX_ETQF_FILTERS; i++) {
8241 if (filter_info->ethertype_mask & (1 << i) &&
8242 !filter_info->ethertype_filters[i].conf) {
8243 (void)ixgbe_ethertype_filter_remove(filter_info,
8245 IXGBE_WRITE_REG(hw, IXGBE_ETQF(i), 0);
8246 IXGBE_WRITE_REG(hw, IXGBE_ETQS(i), 0);
8247 IXGBE_WRITE_FLUSH(hw);
8252 /* remove the SYN filter */
8254 ixgbe_clear_syn_filter(struct rte_eth_dev *dev)
8256 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8257 struct ixgbe_filter_info *filter_info =
8258 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
8260 if (filter_info->syn_info & IXGBE_SYN_FILTER_ENABLE) {
8261 filter_info->syn_info = 0;
8263 IXGBE_WRITE_REG(hw, IXGBE_SYNQF, 0);
8264 IXGBE_WRITE_FLUSH(hw);
8268 /* remove all the L2 tunnel filters */
8270 ixgbe_clear_all_l2_tn_filter(struct rte_eth_dev *dev)
8272 struct ixgbe_l2_tn_info *l2_tn_info =
8273 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
8274 struct ixgbe_l2_tn_filter *l2_tn_filter;
8275 struct rte_eth_l2_tunnel_conf l2_tn_conf;
8278 while ((l2_tn_filter = TAILQ_FIRST(&l2_tn_info->l2_tn_list))) {
8279 l2_tn_conf.l2_tunnel_type = l2_tn_filter->key.l2_tn_type;
8280 l2_tn_conf.tunnel_id = l2_tn_filter->key.tn_id;
8281 l2_tn_conf.pool = l2_tn_filter->pool;
8282 ret = ixgbe_dev_l2_tunnel_filter_del(dev, &l2_tn_conf);
8290 RTE_PMD_REGISTER_PCI(net_ixgbe, rte_ixgbe_pmd);
8291 RTE_PMD_REGISTER_PCI_TABLE(net_ixgbe, pci_id_ixgbe_map);
8292 RTE_PMD_REGISTER_KMOD_DEP(net_ixgbe, "* igb_uio | uio_pci_generic | vfio-pci");
8293 RTE_PMD_REGISTER_PCI(net_ixgbe_vf, rte_ixgbevf_pmd);
8294 RTE_PMD_REGISTER_PCI_TABLE(net_ixgbe_vf, pci_id_ixgbevf_map);
8295 RTE_PMD_REGISTER_KMOD_DEP(net_ixgbe_vf, "* igb_uio | vfio-pci");