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_malloc.h>
61 #include <rte_random.h>
63 #include <rte_hash_crc.h>
65 #include "ixgbe_logs.h"
66 #include "base/ixgbe_api.h"
67 #include "base/ixgbe_vf.h"
68 #include "base/ixgbe_common.h"
69 #include "ixgbe_ethdev.h"
70 #include "ixgbe_bypass.h"
71 #include "ixgbe_rxtx.h"
72 #include "base/ixgbe_type.h"
73 #include "base/ixgbe_phy.h"
74 #include "ixgbe_regs.h"
77 * High threshold controlling when to start sending XOFF frames. Must be at
78 * least 8 bytes less than receive packet buffer size. This value is in units
81 #define IXGBE_FC_HI 0x80
84 * Low threshold controlling when to start sending XON frames. This value is
85 * in units of 1024 bytes.
87 #define IXGBE_FC_LO 0x40
89 /* Default minimum inter-interrupt interval for EITR configuration */
90 #define IXGBE_MIN_INTER_INTERRUPT_INTERVAL_DEFAULT 0x79E
92 /* Timer value included in XOFF frames. */
93 #define IXGBE_FC_PAUSE 0x680
95 #define IXGBE_LINK_DOWN_CHECK_TIMEOUT 4000 /* ms */
96 #define IXGBE_LINK_UP_CHECK_TIMEOUT 1000 /* ms */
97 #define IXGBE_VMDQ_NUM_UC_MAC 4096 /* Maximum nb. of UC MAC addr. */
99 #define IXGBE_MMW_SIZE_DEFAULT 0x4
100 #define IXGBE_MMW_SIZE_JUMBO_FRAME 0x14
101 #define IXGBE_MAX_RING_DESC 4096 /* replicate define from rxtx */
104 * Default values for RX/TX configuration
106 #define IXGBE_DEFAULT_RX_FREE_THRESH 32
107 #define IXGBE_DEFAULT_RX_PTHRESH 8
108 #define IXGBE_DEFAULT_RX_HTHRESH 8
109 #define IXGBE_DEFAULT_RX_WTHRESH 0
111 #define IXGBE_DEFAULT_TX_FREE_THRESH 32
112 #define IXGBE_DEFAULT_TX_PTHRESH 32
113 #define IXGBE_DEFAULT_TX_HTHRESH 0
114 #define IXGBE_DEFAULT_TX_WTHRESH 0
115 #define IXGBE_DEFAULT_TX_RSBIT_THRESH 32
117 /* Bit shift and mask */
118 #define IXGBE_4_BIT_WIDTH (CHAR_BIT / 2)
119 #define IXGBE_4_BIT_MASK RTE_LEN2MASK(IXGBE_4_BIT_WIDTH, uint8_t)
120 #define IXGBE_8_BIT_WIDTH CHAR_BIT
121 #define IXGBE_8_BIT_MASK UINT8_MAX
123 #define IXGBEVF_PMD_NAME "rte_ixgbevf_pmd" /* PMD name */
125 #define IXGBE_QUEUE_STAT_COUNTERS (sizeof(hw_stats->qprc) / sizeof(hw_stats->qprc[0]))
127 #define IXGBE_HKEY_MAX_INDEX 10
129 /* Additional timesync values. */
130 #define NSEC_PER_SEC 1000000000L
131 #define IXGBE_INCVAL_10GB 0x66666666
132 #define IXGBE_INCVAL_1GB 0x40000000
133 #define IXGBE_INCVAL_100 0x50000000
134 #define IXGBE_INCVAL_SHIFT_10GB 28
135 #define IXGBE_INCVAL_SHIFT_1GB 24
136 #define IXGBE_INCVAL_SHIFT_100 21
137 #define IXGBE_INCVAL_SHIFT_82599 7
138 #define IXGBE_INCPER_SHIFT_82599 24
140 #define IXGBE_CYCLECOUNTER_MASK 0xffffffffffffffffULL
142 #define IXGBE_VT_CTL_POOLING_MODE_MASK 0x00030000
143 #define IXGBE_VT_CTL_POOLING_MODE_ETAG 0x00010000
144 #define DEFAULT_ETAG_ETYPE 0x893f
145 #define IXGBE_ETAG_ETYPE 0x00005084
146 #define IXGBE_ETAG_ETYPE_MASK 0x0000ffff
147 #define IXGBE_ETAG_ETYPE_VALID 0x80000000
148 #define IXGBE_RAH_ADTYPE 0x40000000
149 #define IXGBE_RAL_ETAG_FILTER_MASK 0x00003fff
150 #define IXGBE_VMVIR_TAGA_MASK 0x18000000
151 #define IXGBE_VMVIR_TAGA_ETAG_INSERT 0x08000000
152 #define IXGBE_VMTIR(_i) (0x00017000 + ((_i) * 4)) /* 64 of these (0-63) */
153 #define IXGBE_QDE_STRIP_TAG 0x00000004
154 #define IXGBE_VTEICR_MASK 0x07
156 #define IXGBE_EXVET_VET_EXT_SHIFT 16
157 #define IXGBE_DMATXCTL_VT_MASK 0xFFFF0000
159 static int eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev);
160 static int eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev);
161 static int ixgbe_fdir_filter_init(struct rte_eth_dev *eth_dev);
162 static int ixgbe_fdir_filter_uninit(struct rte_eth_dev *eth_dev);
163 static int ixgbe_l2_tn_filter_init(struct rte_eth_dev *eth_dev);
164 static int ixgbe_l2_tn_filter_uninit(struct rte_eth_dev *eth_dev);
165 static int ixgbe_ntuple_filter_uninit(struct rte_eth_dev *eth_dev);
166 static int ixgbe_dev_configure(struct rte_eth_dev *dev);
167 static int ixgbe_dev_start(struct rte_eth_dev *dev);
168 static void ixgbe_dev_stop(struct rte_eth_dev *dev);
169 static int ixgbe_dev_set_link_up(struct rte_eth_dev *dev);
170 static int ixgbe_dev_set_link_down(struct rte_eth_dev *dev);
171 static void ixgbe_dev_close(struct rte_eth_dev *dev);
172 static void ixgbe_dev_promiscuous_enable(struct rte_eth_dev *dev);
173 static void ixgbe_dev_promiscuous_disable(struct rte_eth_dev *dev);
174 static void ixgbe_dev_allmulticast_enable(struct rte_eth_dev *dev);
175 static void ixgbe_dev_allmulticast_disable(struct rte_eth_dev *dev);
176 static int ixgbe_dev_link_update(struct rte_eth_dev *dev,
177 int wait_to_complete);
178 static void ixgbe_dev_stats_get(struct rte_eth_dev *dev,
179 struct rte_eth_stats *stats);
180 static int ixgbe_dev_xstats_get(struct rte_eth_dev *dev,
181 struct rte_eth_xstat *xstats, unsigned n);
182 static int ixgbevf_dev_xstats_get(struct rte_eth_dev *dev,
183 struct rte_eth_xstat *xstats, unsigned n);
185 ixgbe_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids,
186 uint64_t *values, unsigned int n);
187 static void ixgbe_dev_stats_reset(struct rte_eth_dev *dev);
188 static void ixgbe_dev_xstats_reset(struct rte_eth_dev *dev);
189 static int ixgbe_dev_xstats_get_names(struct rte_eth_dev *dev,
190 struct rte_eth_xstat_name *xstats_names,
192 static int ixgbevf_dev_xstats_get_names(struct rte_eth_dev *dev,
193 struct rte_eth_xstat_name *xstats_names, unsigned limit);
194 static int ixgbe_dev_xstats_get_names_by_id(
195 struct rte_eth_dev *dev,
196 struct rte_eth_xstat_name *xstats_names,
199 static int ixgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
203 static int ixgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
205 static void ixgbe_dev_info_get(struct rte_eth_dev *dev,
206 struct rte_eth_dev_info *dev_info);
207 static const uint32_t *ixgbe_dev_supported_ptypes_get(struct rte_eth_dev *dev);
208 static void ixgbevf_dev_info_get(struct rte_eth_dev *dev,
209 struct rte_eth_dev_info *dev_info);
210 static int ixgbe_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
212 static int ixgbe_vlan_filter_set(struct rte_eth_dev *dev,
213 uint16_t vlan_id, int on);
214 static int ixgbe_vlan_tpid_set(struct rte_eth_dev *dev,
215 enum rte_vlan_type vlan_type,
217 static void ixgbe_vlan_hw_strip_bitmap_set(struct rte_eth_dev *dev,
218 uint16_t queue, bool on);
219 static void ixgbe_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue,
221 static void ixgbe_vlan_offload_set(struct rte_eth_dev *dev, int mask);
222 static void ixgbe_vlan_hw_strip_enable(struct rte_eth_dev *dev, uint16_t queue);
223 static void ixgbe_vlan_hw_strip_disable(struct rte_eth_dev *dev, uint16_t queue);
224 static void ixgbe_vlan_hw_extend_enable(struct rte_eth_dev *dev);
225 static void ixgbe_vlan_hw_extend_disable(struct rte_eth_dev *dev);
227 static int ixgbe_dev_led_on(struct rte_eth_dev *dev);
228 static int ixgbe_dev_led_off(struct rte_eth_dev *dev);
229 static int ixgbe_flow_ctrl_get(struct rte_eth_dev *dev,
230 struct rte_eth_fc_conf *fc_conf);
231 static int ixgbe_flow_ctrl_set(struct rte_eth_dev *dev,
232 struct rte_eth_fc_conf *fc_conf);
233 static int ixgbe_priority_flow_ctrl_set(struct rte_eth_dev *dev,
234 struct rte_eth_pfc_conf *pfc_conf);
235 static int ixgbe_dev_rss_reta_update(struct rte_eth_dev *dev,
236 struct rte_eth_rss_reta_entry64 *reta_conf,
238 static int ixgbe_dev_rss_reta_query(struct rte_eth_dev *dev,
239 struct rte_eth_rss_reta_entry64 *reta_conf,
241 static void ixgbe_dev_link_status_print(struct rte_eth_dev *dev);
242 static int ixgbe_dev_lsc_interrupt_setup(struct rte_eth_dev *dev);
243 static int ixgbe_dev_macsec_interrupt_setup(struct rte_eth_dev *dev);
244 static int ixgbe_dev_rxq_interrupt_setup(struct rte_eth_dev *dev);
245 static int ixgbe_dev_interrupt_get_status(struct rte_eth_dev *dev);
246 static int ixgbe_dev_interrupt_action(struct rte_eth_dev *dev,
247 struct rte_intr_handle *handle);
248 static void ixgbe_dev_interrupt_handler(void *param);
249 static void ixgbe_dev_interrupt_delayed_handler(void *param);
250 static int ixgbe_add_rar(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
251 uint32_t index, uint32_t pool);
252 static void ixgbe_remove_rar(struct rte_eth_dev *dev, uint32_t index);
253 static void ixgbe_set_default_mac_addr(struct rte_eth_dev *dev,
254 struct ether_addr *mac_addr);
255 static void ixgbe_dcb_init(struct ixgbe_hw *hw, struct ixgbe_dcb_config *dcb_config);
256 static bool is_device_supported(struct rte_eth_dev *dev,
257 struct rte_pci_driver *drv);
259 /* For Virtual Function support */
260 static int eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev);
261 static int eth_ixgbevf_dev_uninit(struct rte_eth_dev *eth_dev);
262 static int ixgbevf_dev_configure(struct rte_eth_dev *dev);
263 static int ixgbevf_dev_start(struct rte_eth_dev *dev);
264 static int ixgbevf_dev_link_update(struct rte_eth_dev *dev,
265 int wait_to_complete);
266 static void ixgbevf_dev_stop(struct rte_eth_dev *dev);
267 static void ixgbevf_dev_close(struct rte_eth_dev *dev);
268 static void ixgbevf_intr_disable(struct ixgbe_hw *hw);
269 static void ixgbevf_intr_enable(struct ixgbe_hw *hw);
270 static void ixgbevf_dev_stats_get(struct rte_eth_dev *dev,
271 struct rte_eth_stats *stats);
272 static void ixgbevf_dev_stats_reset(struct rte_eth_dev *dev);
273 static int ixgbevf_vlan_filter_set(struct rte_eth_dev *dev,
274 uint16_t vlan_id, int on);
275 static void ixgbevf_vlan_strip_queue_set(struct rte_eth_dev *dev,
276 uint16_t queue, int on);
277 static void ixgbevf_vlan_offload_set(struct rte_eth_dev *dev, int mask);
278 static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on);
279 static int ixgbevf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev,
281 static int ixgbevf_dev_rx_queue_intr_disable(struct rte_eth_dev *dev,
283 static void ixgbevf_set_ivar_map(struct ixgbe_hw *hw, int8_t direction,
284 uint8_t queue, uint8_t msix_vector);
285 static void ixgbevf_configure_msix(struct rte_eth_dev *dev);
286 static void ixgbevf_dev_allmulticast_enable(struct rte_eth_dev *dev);
287 static void ixgbevf_dev_allmulticast_disable(struct rte_eth_dev *dev);
289 /* For Eth VMDQ APIs support */
290 static int ixgbe_uc_hash_table_set(struct rte_eth_dev *dev, struct
291 ether_addr * mac_addr, uint8_t on);
292 static int ixgbe_uc_all_hash_table_set(struct rte_eth_dev *dev, uint8_t on);
293 static int ixgbe_mirror_rule_set(struct rte_eth_dev *dev,
294 struct rte_eth_mirror_conf *mirror_conf,
295 uint8_t rule_id, uint8_t on);
296 static int ixgbe_mirror_rule_reset(struct rte_eth_dev *dev,
298 static int ixgbe_dev_rx_queue_intr_enable(struct rte_eth_dev *dev,
300 static int ixgbe_dev_rx_queue_intr_disable(struct rte_eth_dev *dev,
302 static void ixgbe_set_ivar_map(struct ixgbe_hw *hw, int8_t direction,
303 uint8_t queue, uint8_t msix_vector);
304 static void ixgbe_configure_msix(struct rte_eth_dev *dev);
306 static int ixgbevf_add_mac_addr(struct rte_eth_dev *dev,
307 struct ether_addr *mac_addr,
308 uint32_t index, uint32_t pool);
309 static void ixgbevf_remove_mac_addr(struct rte_eth_dev *dev, uint32_t index);
310 static void ixgbevf_set_default_mac_addr(struct rte_eth_dev *dev,
311 struct ether_addr *mac_addr);
312 static int ixgbe_syn_filter_get(struct rte_eth_dev *dev,
313 struct rte_eth_syn_filter *filter);
314 static int ixgbe_syn_filter_handle(struct rte_eth_dev *dev,
315 enum rte_filter_op filter_op,
317 static int ixgbe_add_5tuple_filter(struct rte_eth_dev *dev,
318 struct ixgbe_5tuple_filter *filter);
319 static void ixgbe_remove_5tuple_filter(struct rte_eth_dev *dev,
320 struct ixgbe_5tuple_filter *filter);
321 static int ixgbe_ntuple_filter_handle(struct rte_eth_dev *dev,
322 enum rte_filter_op filter_op,
324 static int ixgbe_get_ntuple_filter(struct rte_eth_dev *dev,
325 struct rte_eth_ntuple_filter *filter);
326 static int ixgbe_ethertype_filter_handle(struct rte_eth_dev *dev,
327 enum rte_filter_op filter_op,
329 static int ixgbe_get_ethertype_filter(struct rte_eth_dev *dev,
330 struct rte_eth_ethertype_filter *filter);
331 static int ixgbe_dev_filter_ctrl(struct rte_eth_dev *dev,
332 enum rte_filter_type filter_type,
333 enum rte_filter_op filter_op,
335 static int ixgbevf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu);
337 static int ixgbe_dev_set_mc_addr_list(struct rte_eth_dev *dev,
338 struct ether_addr *mc_addr_set,
339 uint32_t nb_mc_addr);
340 static int ixgbe_dev_get_dcb_info(struct rte_eth_dev *dev,
341 struct rte_eth_dcb_info *dcb_info);
343 static int ixgbe_get_reg_length(struct rte_eth_dev *dev);
344 static int ixgbe_get_regs(struct rte_eth_dev *dev,
345 struct rte_dev_reg_info *regs);
346 static int ixgbe_get_eeprom_length(struct rte_eth_dev *dev);
347 static int ixgbe_get_eeprom(struct rte_eth_dev *dev,
348 struct rte_dev_eeprom_info *eeprom);
349 static int ixgbe_set_eeprom(struct rte_eth_dev *dev,
350 struct rte_dev_eeprom_info *eeprom);
352 static int ixgbevf_get_reg_length(struct rte_eth_dev *dev);
353 static int ixgbevf_get_regs(struct rte_eth_dev *dev,
354 struct rte_dev_reg_info *regs);
356 static int ixgbe_timesync_enable(struct rte_eth_dev *dev);
357 static int ixgbe_timesync_disable(struct rte_eth_dev *dev);
358 static int ixgbe_timesync_read_rx_timestamp(struct rte_eth_dev *dev,
359 struct timespec *timestamp,
361 static int ixgbe_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
362 struct timespec *timestamp);
363 static int ixgbe_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta);
364 static int ixgbe_timesync_read_time(struct rte_eth_dev *dev,
365 struct timespec *timestamp);
366 static int ixgbe_timesync_write_time(struct rte_eth_dev *dev,
367 const struct timespec *timestamp);
368 static void ixgbevf_dev_interrupt_handler(void *param);
370 static int ixgbe_dev_l2_tunnel_eth_type_conf
371 (struct rte_eth_dev *dev, struct rte_eth_l2_tunnel_conf *l2_tunnel);
372 static int ixgbe_dev_l2_tunnel_offload_set
373 (struct rte_eth_dev *dev,
374 struct rte_eth_l2_tunnel_conf *l2_tunnel,
377 static int ixgbe_dev_l2_tunnel_filter_handle(struct rte_eth_dev *dev,
378 enum rte_filter_op filter_op,
381 static int ixgbe_dev_udp_tunnel_port_add(struct rte_eth_dev *dev,
382 struct rte_eth_udp_tunnel *udp_tunnel);
383 static int ixgbe_dev_udp_tunnel_port_del(struct rte_eth_dev *dev,
384 struct rte_eth_udp_tunnel *udp_tunnel);
385 static int ixgbe_filter_restore(struct rte_eth_dev *dev);
386 static void ixgbe_l2_tunnel_conf(struct rte_eth_dev *dev);
389 * Define VF Stats MACRO for Non "cleared on read" register
391 #define UPDATE_VF_STAT(reg, last, cur) \
393 uint32_t latest = IXGBE_READ_REG(hw, reg); \
394 cur += (latest - last) & UINT_MAX; \
398 #define UPDATE_VF_STAT_36BIT(lsb, msb, last, cur) \
400 u64 new_lsb = IXGBE_READ_REG(hw, lsb); \
401 u64 new_msb = IXGBE_READ_REG(hw, msb); \
402 u64 latest = ((new_msb << 32) | new_lsb); \
403 cur += (0x1000000000LL + latest - last) & 0xFFFFFFFFFLL; \
407 #define IXGBE_SET_HWSTRIP(h, q) do {\
408 uint32_t idx = (q) / (sizeof((h)->bitmap[0]) * NBBY); \
409 uint32_t bit = (q) % (sizeof((h)->bitmap[0]) * NBBY); \
410 (h)->bitmap[idx] |= 1 << bit;\
413 #define IXGBE_CLEAR_HWSTRIP(h, q) do {\
414 uint32_t idx = (q) / (sizeof((h)->bitmap[0]) * NBBY); \
415 uint32_t bit = (q) % (sizeof((h)->bitmap[0]) * NBBY); \
416 (h)->bitmap[idx] &= ~(1 << bit);\
419 #define IXGBE_GET_HWSTRIP(h, q, r) do {\
420 uint32_t idx = (q) / (sizeof((h)->bitmap[0]) * NBBY); \
421 uint32_t bit = (q) % (sizeof((h)->bitmap[0]) * NBBY); \
422 (r) = (h)->bitmap[idx] >> bit & 1;\
426 * The set of PCI devices this driver supports
428 static const struct rte_pci_id pci_id_ixgbe_map[] = {
429 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598) },
430 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598_BX) },
431 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AF_DUAL_PORT) },
432 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AF_SINGLE_PORT) },
433 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AT) },
434 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AT2) },
435 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598EB_SFP_LOM) },
436 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598EB_CX4) },
437 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598_CX4_DUAL_PORT) },
438 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598_DA_DUAL_PORT) },
439 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM) },
440 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598EB_XF_LR) },
441 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_KX4) },
442 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_KX4_MEZZ) },
443 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_KR) },
444 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_COMBO_BACKPLANE) },
445 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_SUBDEV_ID_82599_KX4_KR_MEZZ) },
446 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_CX4) },
447 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP) },
448 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_SUBDEV_ID_82599_SFP) },
449 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_SUBDEV_ID_82599_RNDC) },
450 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_SUBDEV_ID_82599_560FLR) },
451 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_SUBDEV_ID_82599_ECNA_DP) },
452 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_BACKPLANE_FCOE) },
453 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP_FCOE) },
454 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP_EM) },
455 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP_SF2) },
456 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP_SF_QP) },
457 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_QSFP_SF_QP) },
458 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599EN_SFP) },
459 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_XAUI_LOM) },
460 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_T3_LOM) },
461 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_LS) },
462 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X540T) },
463 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X540T1) },
464 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_SFP) },
465 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_10G_T) },
466 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_1G_T) },
467 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550T) },
468 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550T1) },
469 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_KR) },
470 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_KR_L) },
471 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_SFP_N) },
472 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_SGMII) },
473 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_SGMII_L) },
474 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_10G_T) },
475 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_QSFP) },
476 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_QSFP_N) },
477 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_SFP) },
478 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_1G_T) },
479 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_1G_T_L) },
480 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_KX4) },
481 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_KR) },
482 #ifdef RTE_LIBRTE_IXGBE_BYPASS
483 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_BYPASS) },
485 { .vendor_id = 0, /* sentinel */ },
489 * The set of PCI devices this driver supports (for 82599 VF)
491 static const struct rte_pci_id pci_id_ixgbevf_map[] = {
492 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_VF) },
493 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_VF_HV) },
494 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X540_VF) },
495 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X540_VF_HV) },
496 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550_VF_HV) },
497 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550_VF) },
498 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_VF) },
499 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_VF_HV) },
500 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_VF) },
501 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_VF_HV) },
502 { .vendor_id = 0, /* sentinel */ },
505 static const struct rte_eth_desc_lim rx_desc_lim = {
506 .nb_max = IXGBE_MAX_RING_DESC,
507 .nb_min = IXGBE_MIN_RING_DESC,
508 .nb_align = IXGBE_RXD_ALIGN,
511 static const struct rte_eth_desc_lim tx_desc_lim = {
512 .nb_max = IXGBE_MAX_RING_DESC,
513 .nb_min = IXGBE_MIN_RING_DESC,
514 .nb_align = IXGBE_TXD_ALIGN,
515 .nb_seg_max = IXGBE_TX_MAX_SEG,
516 .nb_mtu_seg_max = IXGBE_TX_MAX_SEG,
519 static const struct eth_dev_ops ixgbe_eth_dev_ops = {
520 .dev_configure = ixgbe_dev_configure,
521 .dev_start = ixgbe_dev_start,
522 .dev_stop = ixgbe_dev_stop,
523 .dev_set_link_up = ixgbe_dev_set_link_up,
524 .dev_set_link_down = ixgbe_dev_set_link_down,
525 .dev_close = ixgbe_dev_close,
526 .promiscuous_enable = ixgbe_dev_promiscuous_enable,
527 .promiscuous_disable = ixgbe_dev_promiscuous_disable,
528 .allmulticast_enable = ixgbe_dev_allmulticast_enable,
529 .allmulticast_disable = ixgbe_dev_allmulticast_disable,
530 .link_update = ixgbe_dev_link_update,
531 .stats_get = ixgbe_dev_stats_get,
532 .xstats_get = ixgbe_dev_xstats_get,
533 .xstats_get_by_id = ixgbe_dev_xstats_get_by_id,
534 .stats_reset = ixgbe_dev_stats_reset,
535 .xstats_reset = ixgbe_dev_xstats_reset,
536 .xstats_get_names = ixgbe_dev_xstats_get_names,
537 .xstats_get_names_by_id = ixgbe_dev_xstats_get_names_by_id,
538 .queue_stats_mapping_set = ixgbe_dev_queue_stats_mapping_set,
539 .fw_version_get = ixgbe_fw_version_get,
540 .dev_infos_get = ixgbe_dev_info_get,
541 .dev_supported_ptypes_get = ixgbe_dev_supported_ptypes_get,
542 .mtu_set = ixgbe_dev_mtu_set,
543 .vlan_filter_set = ixgbe_vlan_filter_set,
544 .vlan_tpid_set = ixgbe_vlan_tpid_set,
545 .vlan_offload_set = ixgbe_vlan_offload_set,
546 .vlan_strip_queue_set = ixgbe_vlan_strip_queue_set,
547 .rx_queue_start = ixgbe_dev_rx_queue_start,
548 .rx_queue_stop = ixgbe_dev_rx_queue_stop,
549 .tx_queue_start = ixgbe_dev_tx_queue_start,
550 .tx_queue_stop = ixgbe_dev_tx_queue_stop,
551 .rx_queue_setup = ixgbe_dev_rx_queue_setup,
552 .rx_queue_intr_enable = ixgbe_dev_rx_queue_intr_enable,
553 .rx_queue_intr_disable = ixgbe_dev_rx_queue_intr_disable,
554 .rx_queue_release = ixgbe_dev_rx_queue_release,
555 .rx_queue_count = ixgbe_dev_rx_queue_count,
556 .rx_descriptor_done = ixgbe_dev_rx_descriptor_done,
557 .rx_descriptor_status = ixgbe_dev_rx_descriptor_status,
558 .tx_descriptor_status = ixgbe_dev_tx_descriptor_status,
559 .tx_queue_setup = ixgbe_dev_tx_queue_setup,
560 .tx_queue_release = ixgbe_dev_tx_queue_release,
561 .dev_led_on = ixgbe_dev_led_on,
562 .dev_led_off = ixgbe_dev_led_off,
563 .flow_ctrl_get = ixgbe_flow_ctrl_get,
564 .flow_ctrl_set = ixgbe_flow_ctrl_set,
565 .priority_flow_ctrl_set = ixgbe_priority_flow_ctrl_set,
566 .mac_addr_add = ixgbe_add_rar,
567 .mac_addr_remove = ixgbe_remove_rar,
568 .mac_addr_set = ixgbe_set_default_mac_addr,
569 .uc_hash_table_set = ixgbe_uc_hash_table_set,
570 .uc_all_hash_table_set = ixgbe_uc_all_hash_table_set,
571 .mirror_rule_set = ixgbe_mirror_rule_set,
572 .mirror_rule_reset = ixgbe_mirror_rule_reset,
573 .set_queue_rate_limit = ixgbe_set_queue_rate_limit,
574 .reta_update = ixgbe_dev_rss_reta_update,
575 .reta_query = ixgbe_dev_rss_reta_query,
576 .rss_hash_update = ixgbe_dev_rss_hash_update,
577 .rss_hash_conf_get = ixgbe_dev_rss_hash_conf_get,
578 .filter_ctrl = ixgbe_dev_filter_ctrl,
579 .set_mc_addr_list = ixgbe_dev_set_mc_addr_list,
580 .rxq_info_get = ixgbe_rxq_info_get,
581 .txq_info_get = ixgbe_txq_info_get,
582 .timesync_enable = ixgbe_timesync_enable,
583 .timesync_disable = ixgbe_timesync_disable,
584 .timesync_read_rx_timestamp = ixgbe_timesync_read_rx_timestamp,
585 .timesync_read_tx_timestamp = ixgbe_timesync_read_tx_timestamp,
586 .get_reg = ixgbe_get_regs,
587 .get_eeprom_length = ixgbe_get_eeprom_length,
588 .get_eeprom = ixgbe_get_eeprom,
589 .set_eeprom = ixgbe_set_eeprom,
590 .get_dcb_info = ixgbe_dev_get_dcb_info,
591 .timesync_adjust_time = ixgbe_timesync_adjust_time,
592 .timesync_read_time = ixgbe_timesync_read_time,
593 .timesync_write_time = ixgbe_timesync_write_time,
594 .l2_tunnel_eth_type_conf = ixgbe_dev_l2_tunnel_eth_type_conf,
595 .l2_tunnel_offload_set = ixgbe_dev_l2_tunnel_offload_set,
596 .udp_tunnel_port_add = ixgbe_dev_udp_tunnel_port_add,
597 .udp_tunnel_port_del = ixgbe_dev_udp_tunnel_port_del,
598 .tm_ops_get = ixgbe_tm_ops_get,
602 * dev_ops for virtual function, bare necessities for basic vf
603 * operation have been implemented
605 static const struct eth_dev_ops ixgbevf_eth_dev_ops = {
606 .dev_configure = ixgbevf_dev_configure,
607 .dev_start = ixgbevf_dev_start,
608 .dev_stop = ixgbevf_dev_stop,
609 .link_update = ixgbevf_dev_link_update,
610 .stats_get = ixgbevf_dev_stats_get,
611 .xstats_get = ixgbevf_dev_xstats_get,
612 .stats_reset = ixgbevf_dev_stats_reset,
613 .xstats_reset = ixgbevf_dev_stats_reset,
614 .xstats_get_names = ixgbevf_dev_xstats_get_names,
615 .dev_close = ixgbevf_dev_close,
616 .allmulticast_enable = ixgbevf_dev_allmulticast_enable,
617 .allmulticast_disable = ixgbevf_dev_allmulticast_disable,
618 .dev_infos_get = ixgbevf_dev_info_get,
619 .dev_supported_ptypes_get = ixgbe_dev_supported_ptypes_get,
620 .mtu_set = ixgbevf_dev_set_mtu,
621 .vlan_filter_set = ixgbevf_vlan_filter_set,
622 .vlan_strip_queue_set = ixgbevf_vlan_strip_queue_set,
623 .vlan_offload_set = ixgbevf_vlan_offload_set,
624 .rx_queue_setup = ixgbe_dev_rx_queue_setup,
625 .rx_queue_release = ixgbe_dev_rx_queue_release,
626 .rx_descriptor_done = ixgbe_dev_rx_descriptor_done,
627 .rx_descriptor_status = ixgbe_dev_rx_descriptor_status,
628 .tx_descriptor_status = ixgbe_dev_tx_descriptor_status,
629 .tx_queue_setup = ixgbe_dev_tx_queue_setup,
630 .tx_queue_release = ixgbe_dev_tx_queue_release,
631 .rx_queue_intr_enable = ixgbevf_dev_rx_queue_intr_enable,
632 .rx_queue_intr_disable = ixgbevf_dev_rx_queue_intr_disable,
633 .mac_addr_add = ixgbevf_add_mac_addr,
634 .mac_addr_remove = ixgbevf_remove_mac_addr,
635 .set_mc_addr_list = ixgbe_dev_set_mc_addr_list,
636 .rxq_info_get = ixgbe_rxq_info_get,
637 .txq_info_get = ixgbe_txq_info_get,
638 .mac_addr_set = ixgbevf_set_default_mac_addr,
639 .get_reg = ixgbevf_get_regs,
640 .reta_update = ixgbe_dev_rss_reta_update,
641 .reta_query = ixgbe_dev_rss_reta_query,
642 .rss_hash_update = ixgbe_dev_rss_hash_update,
643 .rss_hash_conf_get = ixgbe_dev_rss_hash_conf_get,
646 /* store statistics names and its offset in stats structure */
647 struct rte_ixgbe_xstats_name_off {
648 char name[RTE_ETH_XSTATS_NAME_SIZE];
652 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_stats_strings[] = {
653 {"rx_crc_errors", offsetof(struct ixgbe_hw_stats, crcerrs)},
654 {"rx_illegal_byte_errors", offsetof(struct ixgbe_hw_stats, illerrc)},
655 {"rx_error_bytes", offsetof(struct ixgbe_hw_stats, errbc)},
656 {"mac_local_errors", offsetof(struct ixgbe_hw_stats, mlfc)},
657 {"mac_remote_errors", offsetof(struct ixgbe_hw_stats, mrfc)},
658 {"rx_length_errors", offsetof(struct ixgbe_hw_stats, rlec)},
659 {"tx_xon_packets", offsetof(struct ixgbe_hw_stats, lxontxc)},
660 {"rx_xon_packets", offsetof(struct ixgbe_hw_stats, lxonrxc)},
661 {"tx_xoff_packets", offsetof(struct ixgbe_hw_stats, lxofftxc)},
662 {"rx_xoff_packets", offsetof(struct ixgbe_hw_stats, lxoffrxc)},
663 {"rx_size_64_packets", offsetof(struct ixgbe_hw_stats, prc64)},
664 {"rx_size_65_to_127_packets", offsetof(struct ixgbe_hw_stats, prc127)},
665 {"rx_size_128_to_255_packets", offsetof(struct ixgbe_hw_stats, prc255)},
666 {"rx_size_256_to_511_packets", offsetof(struct ixgbe_hw_stats, prc511)},
667 {"rx_size_512_to_1023_packets", offsetof(struct ixgbe_hw_stats,
669 {"rx_size_1024_to_max_packets", offsetof(struct ixgbe_hw_stats,
671 {"rx_broadcast_packets", offsetof(struct ixgbe_hw_stats, bprc)},
672 {"rx_multicast_packets", offsetof(struct ixgbe_hw_stats, mprc)},
673 {"rx_fragment_errors", offsetof(struct ixgbe_hw_stats, rfc)},
674 {"rx_undersize_errors", offsetof(struct ixgbe_hw_stats, ruc)},
675 {"rx_oversize_errors", offsetof(struct ixgbe_hw_stats, roc)},
676 {"rx_jabber_errors", offsetof(struct ixgbe_hw_stats, rjc)},
677 {"rx_management_packets", offsetof(struct ixgbe_hw_stats, mngprc)},
678 {"rx_management_dropped", offsetof(struct ixgbe_hw_stats, mngpdc)},
679 {"tx_management_packets", offsetof(struct ixgbe_hw_stats, mngptc)},
680 {"rx_total_packets", offsetof(struct ixgbe_hw_stats, tpr)},
681 {"rx_total_bytes", offsetof(struct ixgbe_hw_stats, tor)},
682 {"tx_total_packets", offsetof(struct ixgbe_hw_stats, tpt)},
683 {"tx_size_64_packets", offsetof(struct ixgbe_hw_stats, ptc64)},
684 {"tx_size_65_to_127_packets", offsetof(struct ixgbe_hw_stats, ptc127)},
685 {"tx_size_128_to_255_packets", offsetof(struct ixgbe_hw_stats, ptc255)},
686 {"tx_size_256_to_511_packets", offsetof(struct ixgbe_hw_stats, ptc511)},
687 {"tx_size_512_to_1023_packets", offsetof(struct ixgbe_hw_stats,
689 {"tx_size_1024_to_max_packets", offsetof(struct ixgbe_hw_stats,
691 {"tx_multicast_packets", offsetof(struct ixgbe_hw_stats, mptc)},
692 {"tx_broadcast_packets", offsetof(struct ixgbe_hw_stats, bptc)},
693 {"rx_mac_short_packet_dropped", offsetof(struct ixgbe_hw_stats, mspdc)},
694 {"rx_l3_l4_xsum_error", offsetof(struct ixgbe_hw_stats, xec)},
696 {"flow_director_added_filters", offsetof(struct ixgbe_hw_stats,
698 {"flow_director_removed_filters", offsetof(struct ixgbe_hw_stats,
700 {"flow_director_filter_add_errors", offsetof(struct ixgbe_hw_stats,
702 {"flow_director_filter_remove_errors", offsetof(struct ixgbe_hw_stats,
704 {"flow_director_matched_filters", offsetof(struct ixgbe_hw_stats,
706 {"flow_director_missed_filters", offsetof(struct ixgbe_hw_stats,
709 {"rx_fcoe_crc_errors", offsetof(struct ixgbe_hw_stats, fccrc)},
710 {"rx_fcoe_dropped", offsetof(struct ixgbe_hw_stats, fcoerpdc)},
711 {"rx_fcoe_mbuf_allocation_errors", offsetof(struct ixgbe_hw_stats,
713 {"rx_fcoe_packets", offsetof(struct ixgbe_hw_stats, fcoeprc)},
714 {"tx_fcoe_packets", offsetof(struct ixgbe_hw_stats, fcoeptc)},
715 {"rx_fcoe_bytes", offsetof(struct ixgbe_hw_stats, fcoedwrc)},
716 {"tx_fcoe_bytes", offsetof(struct ixgbe_hw_stats, fcoedwtc)},
717 {"rx_fcoe_no_direct_data_placement", offsetof(struct ixgbe_hw_stats,
719 {"rx_fcoe_no_direct_data_placement_ext_buff",
720 offsetof(struct ixgbe_hw_stats, fcoe_noddp_ext_buff)},
722 {"tx_flow_control_xon_packets", offsetof(struct ixgbe_hw_stats,
724 {"rx_flow_control_xon_packets", offsetof(struct ixgbe_hw_stats,
726 {"tx_flow_control_xoff_packets", offsetof(struct ixgbe_hw_stats,
728 {"rx_flow_control_xoff_packets", offsetof(struct ixgbe_hw_stats,
730 {"rx_total_missed_packets", offsetof(struct ixgbe_hw_stats, mpctotal)},
733 #define IXGBE_NB_HW_STATS (sizeof(rte_ixgbe_stats_strings) / \
734 sizeof(rte_ixgbe_stats_strings[0]))
736 /* MACsec statistics */
737 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_macsec_strings[] = {
738 {"out_pkts_untagged", offsetof(struct ixgbe_macsec_stats,
740 {"out_pkts_encrypted", offsetof(struct ixgbe_macsec_stats,
741 out_pkts_encrypted)},
742 {"out_pkts_protected", offsetof(struct ixgbe_macsec_stats,
743 out_pkts_protected)},
744 {"out_octets_encrypted", offsetof(struct ixgbe_macsec_stats,
745 out_octets_encrypted)},
746 {"out_octets_protected", offsetof(struct ixgbe_macsec_stats,
747 out_octets_protected)},
748 {"in_pkts_untagged", offsetof(struct ixgbe_macsec_stats,
750 {"in_pkts_badtag", offsetof(struct ixgbe_macsec_stats,
752 {"in_pkts_nosci", offsetof(struct ixgbe_macsec_stats,
754 {"in_pkts_unknownsci", offsetof(struct ixgbe_macsec_stats,
755 in_pkts_unknownsci)},
756 {"in_octets_decrypted", offsetof(struct ixgbe_macsec_stats,
757 in_octets_decrypted)},
758 {"in_octets_validated", offsetof(struct ixgbe_macsec_stats,
759 in_octets_validated)},
760 {"in_pkts_unchecked", offsetof(struct ixgbe_macsec_stats,
762 {"in_pkts_delayed", offsetof(struct ixgbe_macsec_stats,
764 {"in_pkts_late", offsetof(struct ixgbe_macsec_stats,
766 {"in_pkts_ok", offsetof(struct ixgbe_macsec_stats,
768 {"in_pkts_invalid", offsetof(struct ixgbe_macsec_stats,
770 {"in_pkts_notvalid", offsetof(struct ixgbe_macsec_stats,
772 {"in_pkts_unusedsa", offsetof(struct ixgbe_macsec_stats,
774 {"in_pkts_notusingsa", offsetof(struct ixgbe_macsec_stats,
775 in_pkts_notusingsa)},
778 #define IXGBE_NB_MACSEC_STATS (sizeof(rte_ixgbe_macsec_strings) / \
779 sizeof(rte_ixgbe_macsec_strings[0]))
781 /* Per-queue statistics */
782 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_rxq_strings[] = {
783 {"mbuf_allocation_errors", offsetof(struct ixgbe_hw_stats, rnbc)},
784 {"dropped", offsetof(struct ixgbe_hw_stats, mpc)},
785 {"xon_packets", offsetof(struct ixgbe_hw_stats, pxonrxc)},
786 {"xoff_packets", offsetof(struct ixgbe_hw_stats, pxoffrxc)},
789 #define IXGBE_NB_RXQ_PRIO_STATS (sizeof(rte_ixgbe_rxq_strings) / \
790 sizeof(rte_ixgbe_rxq_strings[0]))
791 #define IXGBE_NB_RXQ_PRIO_VALUES 8
793 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_txq_strings[] = {
794 {"xon_packets", offsetof(struct ixgbe_hw_stats, pxontxc)},
795 {"xoff_packets", offsetof(struct ixgbe_hw_stats, pxofftxc)},
796 {"xon_to_xoff_packets", offsetof(struct ixgbe_hw_stats,
800 #define IXGBE_NB_TXQ_PRIO_STATS (sizeof(rte_ixgbe_txq_strings) / \
801 sizeof(rte_ixgbe_txq_strings[0]))
802 #define IXGBE_NB_TXQ_PRIO_VALUES 8
804 static const struct rte_ixgbe_xstats_name_off rte_ixgbevf_stats_strings[] = {
805 {"rx_multicast_packets", offsetof(struct ixgbevf_hw_stats, vfmprc)},
808 #define IXGBEVF_NB_XSTATS (sizeof(rte_ixgbevf_stats_strings) / \
809 sizeof(rte_ixgbevf_stats_strings[0]))
812 * Atomically reads the link status information from global
813 * structure rte_eth_dev.
816 * - Pointer to the structure rte_eth_dev to read from.
817 * - Pointer to the buffer to be saved with the link status.
820 * - On success, zero.
821 * - On failure, negative value.
824 rte_ixgbe_dev_atomic_read_link_status(struct rte_eth_dev *dev,
825 struct rte_eth_link *link)
827 struct rte_eth_link *dst = link;
828 struct rte_eth_link *src = &(dev->data->dev_link);
830 if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
831 *(uint64_t *)src) == 0)
838 * Atomically writes the link status information into global
839 * structure rte_eth_dev.
842 * - Pointer to the structure rte_eth_dev to read from.
843 * - Pointer to the buffer to be saved with the link status.
846 * - On success, zero.
847 * - On failure, negative value.
850 rte_ixgbe_dev_atomic_write_link_status(struct rte_eth_dev *dev,
851 struct rte_eth_link *link)
853 struct rte_eth_link *dst = &(dev->data->dev_link);
854 struct rte_eth_link *src = link;
856 if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
857 *(uint64_t *)src) == 0)
864 * This function is the same as ixgbe_is_sfp() in base/ixgbe.h.
867 ixgbe_is_sfp(struct ixgbe_hw *hw)
869 switch (hw->phy.type) {
870 case ixgbe_phy_sfp_avago:
871 case ixgbe_phy_sfp_ftl:
872 case ixgbe_phy_sfp_intel:
873 case ixgbe_phy_sfp_unknown:
874 case ixgbe_phy_sfp_passive_tyco:
875 case ixgbe_phy_sfp_passive_unknown:
882 static inline int32_t
883 ixgbe_pf_reset_hw(struct ixgbe_hw *hw)
888 status = ixgbe_reset_hw(hw);
890 ctrl_ext = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
891 /* Set PF Reset Done bit so PF/VF Mail Ops can work */
892 ctrl_ext |= IXGBE_CTRL_EXT_PFRSTD;
893 IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl_ext);
894 IXGBE_WRITE_FLUSH(hw);
896 if (status == IXGBE_ERR_SFP_NOT_PRESENT)
897 status = IXGBE_SUCCESS;
902 ixgbe_enable_intr(struct rte_eth_dev *dev)
904 struct ixgbe_interrupt *intr =
905 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
906 struct ixgbe_hw *hw =
907 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
909 IXGBE_WRITE_REG(hw, IXGBE_EIMS, intr->mask);
910 IXGBE_WRITE_FLUSH(hw);
914 * This function is based on ixgbe_disable_intr() in base/ixgbe.h.
917 ixgbe_disable_intr(struct ixgbe_hw *hw)
919 PMD_INIT_FUNC_TRACE();
921 if (hw->mac.type == ixgbe_mac_82598EB) {
922 IXGBE_WRITE_REG(hw, IXGBE_EIMC, ~0);
924 IXGBE_WRITE_REG(hw, IXGBE_EIMC, 0xFFFF0000);
925 IXGBE_WRITE_REG(hw, IXGBE_EIMC_EX(0), ~0);
926 IXGBE_WRITE_REG(hw, IXGBE_EIMC_EX(1), ~0);
928 IXGBE_WRITE_FLUSH(hw);
932 * This function resets queue statistics mapping registers.
933 * From Niantic datasheet, Initialization of Statistics section:
934 * "...if software requires the queue counters, the RQSMR and TQSM registers
935 * must be re-programmed following a device reset.
938 ixgbe_reset_qstat_mappings(struct ixgbe_hw *hw)
942 for (i = 0; i != IXGBE_NB_STAT_MAPPING_REGS; i++) {
943 IXGBE_WRITE_REG(hw, IXGBE_RQSMR(i), 0);
944 IXGBE_WRITE_REG(hw, IXGBE_TQSM(i), 0);
950 ixgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
955 #define QSM_REG_NB_BITS_PER_QMAP_FIELD 8
956 #define NB_QMAP_FIELDS_PER_QSM_REG 4
957 #define QMAP_FIELD_RESERVED_BITS_MASK 0x0f
959 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
960 struct ixgbe_stat_mapping_registers *stat_mappings =
961 IXGBE_DEV_PRIVATE_TO_STAT_MAPPINGS(eth_dev->data->dev_private);
962 uint32_t qsmr_mask = 0;
963 uint32_t clearing_mask = QMAP_FIELD_RESERVED_BITS_MASK;
967 if ((hw->mac.type != ixgbe_mac_82599EB) &&
968 (hw->mac.type != ixgbe_mac_X540) &&
969 (hw->mac.type != ixgbe_mac_X550) &&
970 (hw->mac.type != ixgbe_mac_X550EM_x) &&
971 (hw->mac.type != ixgbe_mac_X550EM_a))
974 PMD_INIT_LOG(DEBUG, "Setting port %d, %s queue_id %d to stat index %d",
975 (int)(eth_dev->data->port_id), is_rx ? "RX" : "TX",
978 n = (uint8_t)(queue_id / NB_QMAP_FIELDS_PER_QSM_REG);
979 if (n >= IXGBE_NB_STAT_MAPPING_REGS) {
980 PMD_INIT_LOG(ERR, "Nb of stat mapping registers exceeded");
983 offset = (uint8_t)(queue_id % NB_QMAP_FIELDS_PER_QSM_REG);
985 /* Now clear any previous stat_idx set */
986 clearing_mask <<= (QSM_REG_NB_BITS_PER_QMAP_FIELD * offset);
988 stat_mappings->tqsm[n] &= ~clearing_mask;
990 stat_mappings->rqsmr[n] &= ~clearing_mask;
992 q_map = (uint32_t)stat_idx;
993 q_map &= QMAP_FIELD_RESERVED_BITS_MASK;
994 qsmr_mask = q_map << (QSM_REG_NB_BITS_PER_QMAP_FIELD * offset);
996 stat_mappings->tqsm[n] |= qsmr_mask;
998 stat_mappings->rqsmr[n] |= qsmr_mask;
1000 PMD_INIT_LOG(DEBUG, "Set port %d, %s queue_id %d to stat index %d",
1001 (int)(eth_dev->data->port_id), is_rx ? "RX" : "TX",
1002 queue_id, stat_idx);
1003 PMD_INIT_LOG(DEBUG, "%s[%d] = 0x%08x", is_rx ? "RQSMR" : "TQSM", n,
1004 is_rx ? stat_mappings->rqsmr[n] : stat_mappings->tqsm[n]);
1006 /* Now write the mapping in the appropriate register */
1008 PMD_INIT_LOG(DEBUG, "Write 0x%x to RX IXGBE stat mapping reg:%d",
1009 stat_mappings->rqsmr[n], n);
1010 IXGBE_WRITE_REG(hw, IXGBE_RQSMR(n), stat_mappings->rqsmr[n]);
1012 PMD_INIT_LOG(DEBUG, "Write 0x%x to TX IXGBE stat mapping reg:%d",
1013 stat_mappings->tqsm[n], n);
1014 IXGBE_WRITE_REG(hw, IXGBE_TQSM(n), stat_mappings->tqsm[n]);
1020 ixgbe_restore_statistics_mapping(struct rte_eth_dev *dev)
1022 struct ixgbe_stat_mapping_registers *stat_mappings =
1023 IXGBE_DEV_PRIVATE_TO_STAT_MAPPINGS(dev->data->dev_private);
1024 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1027 /* write whatever was in stat mapping table to the NIC */
1028 for (i = 0; i < IXGBE_NB_STAT_MAPPING_REGS; i++) {
1030 IXGBE_WRITE_REG(hw, IXGBE_RQSMR(i), stat_mappings->rqsmr[i]);
1033 IXGBE_WRITE_REG(hw, IXGBE_TQSM(i), stat_mappings->tqsm[i]);
1038 ixgbe_dcb_init(struct ixgbe_hw *hw, struct ixgbe_dcb_config *dcb_config)
1041 struct ixgbe_dcb_tc_config *tc;
1042 uint8_t dcb_max_tc = IXGBE_DCB_MAX_TRAFFIC_CLASS;
1044 dcb_config->num_tcs.pg_tcs = dcb_max_tc;
1045 dcb_config->num_tcs.pfc_tcs = dcb_max_tc;
1046 for (i = 0; i < dcb_max_tc; i++) {
1047 tc = &dcb_config->tc_config[i];
1048 tc->path[IXGBE_DCB_TX_CONFIG].bwg_id = i;
1049 tc->path[IXGBE_DCB_TX_CONFIG].bwg_percent =
1050 (uint8_t)(100/dcb_max_tc + (i & 1));
1051 tc->path[IXGBE_DCB_RX_CONFIG].bwg_id = i;
1052 tc->path[IXGBE_DCB_RX_CONFIG].bwg_percent =
1053 (uint8_t)(100/dcb_max_tc + (i & 1));
1054 tc->pfc = ixgbe_dcb_pfc_disabled;
1057 /* Initialize default user to priority mapping, UPx->TC0 */
1058 tc = &dcb_config->tc_config[0];
1059 tc->path[IXGBE_DCB_TX_CONFIG].up_to_tc_bitmap = 0xFF;
1060 tc->path[IXGBE_DCB_RX_CONFIG].up_to_tc_bitmap = 0xFF;
1061 for (i = 0; i < IXGBE_DCB_MAX_BW_GROUP; i++) {
1062 dcb_config->bw_percentage[IXGBE_DCB_TX_CONFIG][i] = 100;
1063 dcb_config->bw_percentage[IXGBE_DCB_RX_CONFIG][i] = 100;
1065 dcb_config->rx_pba_cfg = ixgbe_dcb_pba_equal;
1066 dcb_config->pfc_mode_enable = false;
1067 dcb_config->vt_mode = true;
1068 dcb_config->round_robin_enable = false;
1069 /* support all DCB capabilities in 82599 */
1070 dcb_config->support.capabilities = 0xFF;
1072 /*we only support 4 Tcs for X540, X550 */
1073 if (hw->mac.type == ixgbe_mac_X540 ||
1074 hw->mac.type == ixgbe_mac_X550 ||
1075 hw->mac.type == ixgbe_mac_X550EM_x ||
1076 hw->mac.type == ixgbe_mac_X550EM_a) {
1077 dcb_config->num_tcs.pg_tcs = 4;
1078 dcb_config->num_tcs.pfc_tcs = 4;
1083 * Ensure that all locks are released before first NVM or PHY access
1086 ixgbe_swfw_lock_reset(struct ixgbe_hw *hw)
1091 * Phy lock should not fail in this early stage. If this is the case,
1092 * it is due to an improper exit of the application.
1093 * So force the release of the faulty lock. Release of common lock
1094 * is done automatically by swfw_sync function.
1096 mask = IXGBE_GSSR_PHY0_SM << hw->bus.func;
1097 if (ixgbe_acquire_swfw_semaphore(hw, mask) < 0) {
1098 PMD_DRV_LOG(DEBUG, "SWFW phy%d lock released", hw->bus.func);
1100 ixgbe_release_swfw_semaphore(hw, mask);
1103 * These ones are more tricky since they are common to all ports; but
1104 * swfw_sync retries last long enough (1s) to be almost sure that if
1105 * lock can not be taken it is due to an improper lock of the
1108 mask = IXGBE_GSSR_EEP_SM | IXGBE_GSSR_MAC_CSR_SM | IXGBE_GSSR_SW_MNG_SM;
1109 if (ixgbe_acquire_swfw_semaphore(hw, mask) < 0) {
1110 PMD_DRV_LOG(DEBUG, "SWFW common locks released");
1112 ixgbe_release_swfw_semaphore(hw, mask);
1116 * This function is based on code in ixgbe_attach() in base/ixgbe.c.
1117 * It returns 0 on success.
1120 eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev)
1122 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
1123 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
1124 struct ixgbe_hw *hw =
1125 IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
1126 struct ixgbe_vfta *shadow_vfta =
1127 IXGBE_DEV_PRIVATE_TO_VFTA(eth_dev->data->dev_private);
1128 struct ixgbe_hwstrip *hwstrip =
1129 IXGBE_DEV_PRIVATE_TO_HWSTRIP_BITMAP(eth_dev->data->dev_private);
1130 struct ixgbe_dcb_config *dcb_config =
1131 IXGBE_DEV_PRIVATE_TO_DCB_CFG(eth_dev->data->dev_private);
1132 struct ixgbe_filter_info *filter_info =
1133 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(eth_dev->data->dev_private);
1134 struct ixgbe_bw_conf *bw_conf =
1135 IXGBE_DEV_PRIVATE_TO_BW_CONF(eth_dev->data->dev_private);
1140 PMD_INIT_FUNC_TRACE();
1142 eth_dev->dev_ops = &ixgbe_eth_dev_ops;
1143 eth_dev->rx_pkt_burst = &ixgbe_recv_pkts;
1144 eth_dev->tx_pkt_burst = &ixgbe_xmit_pkts;
1145 eth_dev->tx_pkt_prepare = &ixgbe_prep_pkts;
1148 * For secondary processes, we don't initialise any further as primary
1149 * has already done this work. Only check we don't need a different
1150 * RX and TX function.
1152 if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
1153 struct ixgbe_tx_queue *txq;
1154 /* TX queue function in primary, set by last queue initialized
1155 * Tx queue may not initialized by primary process
1157 if (eth_dev->data->tx_queues) {
1158 txq = eth_dev->data->tx_queues[eth_dev->data->nb_tx_queues-1];
1159 ixgbe_set_tx_function(eth_dev, txq);
1161 /* Use default TX function if we get here */
1162 PMD_INIT_LOG(NOTICE, "No TX queues configured yet. "
1163 "Using default TX function.");
1166 ixgbe_set_rx_function(eth_dev);
1171 rte_eth_copy_pci_info(eth_dev, pci_dev);
1172 eth_dev->data->dev_flags |= RTE_ETH_DEV_DETACHABLE;
1174 /* Vendor and Device ID need to be set before init of shared code */
1175 hw->device_id = pci_dev->id.device_id;
1176 hw->vendor_id = pci_dev->id.vendor_id;
1177 hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
1178 hw->allow_unsupported_sfp = 1;
1180 /* Initialize the shared code (base driver) */
1181 #ifdef RTE_LIBRTE_IXGBE_BYPASS
1182 diag = ixgbe_bypass_init_shared_code(hw);
1184 diag = ixgbe_init_shared_code(hw);
1185 #endif /* RTE_LIBRTE_IXGBE_BYPASS */
1187 if (diag != IXGBE_SUCCESS) {
1188 PMD_INIT_LOG(ERR, "Shared code init failed: %d", diag);
1192 /* pick up the PCI bus settings for reporting later */
1193 ixgbe_get_bus_info(hw);
1195 /* Unlock any pending hardware semaphore */
1196 ixgbe_swfw_lock_reset(hw);
1198 /* Initialize DCB configuration*/
1199 memset(dcb_config, 0, sizeof(struct ixgbe_dcb_config));
1200 ixgbe_dcb_init(hw, dcb_config);
1201 /* Get Hardware Flow Control setting */
1202 hw->fc.requested_mode = ixgbe_fc_full;
1203 hw->fc.current_mode = ixgbe_fc_full;
1204 hw->fc.pause_time = IXGBE_FC_PAUSE;
1205 for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
1206 hw->fc.low_water[i] = IXGBE_FC_LO;
1207 hw->fc.high_water[i] = IXGBE_FC_HI;
1209 hw->fc.send_xon = 1;
1211 /* Make sure we have a good EEPROM before we read from it */
1212 diag = ixgbe_validate_eeprom_checksum(hw, &csum);
1213 if (diag != IXGBE_SUCCESS) {
1214 PMD_INIT_LOG(ERR, "The EEPROM checksum is not valid: %d", diag);
1218 #ifdef RTE_LIBRTE_IXGBE_BYPASS
1219 diag = ixgbe_bypass_init_hw(hw);
1221 diag = ixgbe_init_hw(hw);
1222 #endif /* RTE_LIBRTE_IXGBE_BYPASS */
1225 * Devices with copper phys will fail to initialise if ixgbe_init_hw()
1226 * is called too soon after the kernel driver unbinding/binding occurs.
1227 * The failure occurs in ixgbe_identify_phy_generic() for all devices,
1228 * but for non-copper devies, ixgbe_identify_sfp_module_generic() is
1229 * also called. See ixgbe_identify_phy_82599(). The reason for the
1230 * failure is not known, and only occuts when virtualisation features
1231 * are disabled in the bios. A delay of 100ms was found to be enough by
1232 * trial-and-error, and is doubled to be safe.
1234 if (diag && (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper)) {
1236 diag = ixgbe_init_hw(hw);
1239 if (diag == IXGBE_ERR_SFP_NOT_PRESENT)
1240 diag = IXGBE_SUCCESS;
1242 if (diag == IXGBE_ERR_EEPROM_VERSION) {
1243 PMD_INIT_LOG(ERR, "This device is a pre-production adapter/"
1244 "LOM. Please be aware there may be issues associated "
1245 "with your hardware.");
1246 PMD_INIT_LOG(ERR, "If you are experiencing problems "
1247 "please contact your Intel or hardware representative "
1248 "who provided you with this hardware.");
1249 } else if (diag == IXGBE_ERR_SFP_NOT_SUPPORTED)
1250 PMD_INIT_LOG(ERR, "Unsupported SFP+ Module");
1252 PMD_INIT_LOG(ERR, "Hardware Initialization Failure: %d", diag);
1256 /* Reset the hw statistics */
1257 ixgbe_dev_stats_reset(eth_dev);
1259 /* disable interrupt */
1260 ixgbe_disable_intr(hw);
1262 /* reset mappings for queue statistics hw counters*/
1263 ixgbe_reset_qstat_mappings(hw);
1265 /* Allocate memory for storing MAC addresses */
1266 eth_dev->data->mac_addrs = rte_zmalloc("ixgbe", ETHER_ADDR_LEN *
1267 hw->mac.num_rar_entries, 0);
1268 if (eth_dev->data->mac_addrs == NULL) {
1270 "Failed to allocate %u bytes needed to store "
1272 ETHER_ADDR_LEN * hw->mac.num_rar_entries);
1275 /* Copy the permanent MAC address */
1276 ether_addr_copy((struct ether_addr *) hw->mac.perm_addr,
1277 ð_dev->data->mac_addrs[0]);
1279 /* Allocate memory for storing hash filter MAC addresses */
1280 eth_dev->data->hash_mac_addrs = rte_zmalloc("ixgbe", ETHER_ADDR_LEN *
1281 IXGBE_VMDQ_NUM_UC_MAC, 0);
1282 if (eth_dev->data->hash_mac_addrs == NULL) {
1284 "Failed to allocate %d bytes needed to store MAC addresses",
1285 ETHER_ADDR_LEN * IXGBE_VMDQ_NUM_UC_MAC);
1289 /* initialize the vfta */
1290 memset(shadow_vfta, 0, sizeof(*shadow_vfta));
1292 /* initialize the hw strip bitmap*/
1293 memset(hwstrip, 0, sizeof(*hwstrip));
1295 /* initialize PF if max_vfs not zero */
1296 ixgbe_pf_host_init(eth_dev);
1298 ctrl_ext = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
1299 /* let hardware know driver is loaded */
1300 ctrl_ext |= IXGBE_CTRL_EXT_DRV_LOAD;
1301 /* Set PF Reset Done bit so PF/VF Mail Ops can work */
1302 ctrl_ext |= IXGBE_CTRL_EXT_PFRSTD;
1303 IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl_ext);
1304 IXGBE_WRITE_FLUSH(hw);
1306 if (ixgbe_is_sfp(hw) && hw->phy.sfp_type != ixgbe_sfp_type_not_present)
1307 PMD_INIT_LOG(DEBUG, "MAC: %d, PHY: %d, SFP+: %d",
1308 (int) hw->mac.type, (int) hw->phy.type,
1309 (int) hw->phy.sfp_type);
1311 PMD_INIT_LOG(DEBUG, "MAC: %d, PHY: %d",
1312 (int) hw->mac.type, (int) hw->phy.type);
1314 PMD_INIT_LOG(DEBUG, "port %d vendorID=0x%x deviceID=0x%x",
1315 eth_dev->data->port_id, pci_dev->id.vendor_id,
1316 pci_dev->id.device_id);
1318 rte_intr_callback_register(intr_handle,
1319 ixgbe_dev_interrupt_handler, eth_dev);
1321 /* enable uio/vfio intr/eventfd mapping */
1322 rte_intr_enable(intr_handle);
1324 /* enable support intr */
1325 ixgbe_enable_intr(eth_dev);
1327 /* initialize filter info */
1328 memset(filter_info, 0,
1329 sizeof(struct ixgbe_filter_info));
1331 /* initialize 5tuple filter list */
1332 TAILQ_INIT(&filter_info->fivetuple_list);
1334 /* initialize flow director filter list & hash */
1335 ixgbe_fdir_filter_init(eth_dev);
1337 /* initialize l2 tunnel filter list & hash */
1338 ixgbe_l2_tn_filter_init(eth_dev);
1340 TAILQ_INIT(&filter_ntuple_list);
1341 TAILQ_INIT(&filter_ethertype_list);
1342 TAILQ_INIT(&filter_syn_list);
1343 TAILQ_INIT(&filter_fdir_list);
1344 TAILQ_INIT(&filter_l2_tunnel_list);
1345 TAILQ_INIT(&ixgbe_flow_list);
1347 /* initialize bandwidth configuration info */
1348 memset(bw_conf, 0, sizeof(struct ixgbe_bw_conf));
1350 /* initialize Traffic Manager configuration */
1351 ixgbe_tm_conf_init(eth_dev);
1357 eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev)
1359 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
1360 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
1361 struct ixgbe_hw *hw;
1363 PMD_INIT_FUNC_TRACE();
1365 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
1368 hw = IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
1370 if (hw->adapter_stopped == 0)
1371 ixgbe_dev_close(eth_dev);
1373 eth_dev->dev_ops = NULL;
1374 eth_dev->rx_pkt_burst = NULL;
1375 eth_dev->tx_pkt_burst = NULL;
1377 /* Unlock any pending hardware semaphore */
1378 ixgbe_swfw_lock_reset(hw);
1380 /* disable uio intr before callback unregister */
1381 rte_intr_disable(intr_handle);
1382 rte_intr_callback_unregister(intr_handle,
1383 ixgbe_dev_interrupt_handler, eth_dev);
1385 /* uninitialize PF if max_vfs not zero */
1386 ixgbe_pf_host_uninit(eth_dev);
1388 rte_free(eth_dev->data->mac_addrs);
1389 eth_dev->data->mac_addrs = NULL;
1391 rte_free(eth_dev->data->hash_mac_addrs);
1392 eth_dev->data->hash_mac_addrs = NULL;
1394 /* remove all the fdir filters & hash */
1395 ixgbe_fdir_filter_uninit(eth_dev);
1397 /* remove all the L2 tunnel filters & hash */
1398 ixgbe_l2_tn_filter_uninit(eth_dev);
1400 /* Remove all ntuple filters of the device */
1401 ixgbe_ntuple_filter_uninit(eth_dev);
1403 /* clear all the filters list */
1404 ixgbe_filterlist_flush();
1406 /* Remove all Traffic Manager configuration */
1407 ixgbe_tm_conf_uninit(eth_dev);
1412 static int ixgbe_ntuple_filter_uninit(struct rte_eth_dev *eth_dev)
1414 struct ixgbe_filter_info *filter_info =
1415 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(eth_dev->data->dev_private);
1416 struct ixgbe_5tuple_filter *p_5tuple;
1418 while ((p_5tuple = TAILQ_FIRST(&filter_info->fivetuple_list))) {
1419 TAILQ_REMOVE(&filter_info->fivetuple_list,
1424 memset(filter_info->fivetuple_mask, 0,
1425 sizeof(uint32_t) * IXGBE_5TUPLE_ARRAY_SIZE);
1430 static int ixgbe_fdir_filter_uninit(struct rte_eth_dev *eth_dev)
1432 struct ixgbe_hw_fdir_info *fdir_info =
1433 IXGBE_DEV_PRIVATE_TO_FDIR_INFO(eth_dev->data->dev_private);
1434 struct ixgbe_fdir_filter *fdir_filter;
1436 if (fdir_info->hash_map)
1437 rte_free(fdir_info->hash_map);
1438 if (fdir_info->hash_handle)
1439 rte_hash_free(fdir_info->hash_handle);
1441 while ((fdir_filter = TAILQ_FIRST(&fdir_info->fdir_list))) {
1442 TAILQ_REMOVE(&fdir_info->fdir_list,
1445 rte_free(fdir_filter);
1451 static int ixgbe_l2_tn_filter_uninit(struct rte_eth_dev *eth_dev)
1453 struct ixgbe_l2_tn_info *l2_tn_info =
1454 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(eth_dev->data->dev_private);
1455 struct ixgbe_l2_tn_filter *l2_tn_filter;
1457 if (l2_tn_info->hash_map)
1458 rte_free(l2_tn_info->hash_map);
1459 if (l2_tn_info->hash_handle)
1460 rte_hash_free(l2_tn_info->hash_handle);
1462 while ((l2_tn_filter = TAILQ_FIRST(&l2_tn_info->l2_tn_list))) {
1463 TAILQ_REMOVE(&l2_tn_info->l2_tn_list,
1466 rte_free(l2_tn_filter);
1472 static int ixgbe_fdir_filter_init(struct rte_eth_dev *eth_dev)
1474 struct ixgbe_hw_fdir_info *fdir_info =
1475 IXGBE_DEV_PRIVATE_TO_FDIR_INFO(eth_dev->data->dev_private);
1476 char fdir_hash_name[RTE_HASH_NAMESIZE];
1477 struct rte_hash_parameters fdir_hash_params = {
1478 .name = fdir_hash_name,
1479 .entries = IXGBE_MAX_FDIR_FILTER_NUM,
1480 .key_len = sizeof(union ixgbe_atr_input),
1481 .hash_func = rte_hash_crc,
1482 .hash_func_init_val = 0,
1483 .socket_id = rte_socket_id(),
1486 TAILQ_INIT(&fdir_info->fdir_list);
1487 snprintf(fdir_hash_name, RTE_HASH_NAMESIZE,
1488 "fdir_%s", eth_dev->device->name);
1489 fdir_info->hash_handle = rte_hash_create(&fdir_hash_params);
1490 if (!fdir_info->hash_handle) {
1491 PMD_INIT_LOG(ERR, "Failed to create fdir hash table!");
1494 fdir_info->hash_map = rte_zmalloc("ixgbe",
1495 sizeof(struct ixgbe_fdir_filter *) *
1496 IXGBE_MAX_FDIR_FILTER_NUM,
1498 if (!fdir_info->hash_map) {
1500 "Failed to allocate memory for fdir hash map!");
1503 fdir_info->mask_added = FALSE;
1508 static int ixgbe_l2_tn_filter_init(struct rte_eth_dev *eth_dev)
1510 struct ixgbe_l2_tn_info *l2_tn_info =
1511 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(eth_dev->data->dev_private);
1512 char l2_tn_hash_name[RTE_HASH_NAMESIZE];
1513 struct rte_hash_parameters l2_tn_hash_params = {
1514 .name = l2_tn_hash_name,
1515 .entries = IXGBE_MAX_L2_TN_FILTER_NUM,
1516 .key_len = sizeof(struct ixgbe_l2_tn_key),
1517 .hash_func = rte_hash_crc,
1518 .hash_func_init_val = 0,
1519 .socket_id = rte_socket_id(),
1522 TAILQ_INIT(&l2_tn_info->l2_tn_list);
1523 snprintf(l2_tn_hash_name, RTE_HASH_NAMESIZE,
1524 "l2_tn_%s", eth_dev->device->name);
1525 l2_tn_info->hash_handle = rte_hash_create(&l2_tn_hash_params);
1526 if (!l2_tn_info->hash_handle) {
1527 PMD_INIT_LOG(ERR, "Failed to create L2 TN hash table!");
1530 l2_tn_info->hash_map = rte_zmalloc("ixgbe",
1531 sizeof(struct ixgbe_l2_tn_filter *) *
1532 IXGBE_MAX_L2_TN_FILTER_NUM,
1534 if (!l2_tn_info->hash_map) {
1536 "Failed to allocate memory for L2 TN hash map!");
1539 l2_tn_info->e_tag_en = FALSE;
1540 l2_tn_info->e_tag_fwd_en = FALSE;
1541 l2_tn_info->e_tag_ether_type = DEFAULT_ETAG_ETYPE;
1546 * Negotiate mailbox API version with the PF.
1547 * After reset API version is always set to the basic one (ixgbe_mbox_api_10).
1548 * Then we try to negotiate starting with the most recent one.
1549 * If all negotiation attempts fail, then we will proceed with
1550 * the default one (ixgbe_mbox_api_10).
1553 ixgbevf_negotiate_api(struct ixgbe_hw *hw)
1557 /* start with highest supported, proceed down */
1558 static const enum ixgbe_pfvf_api_rev sup_ver[] = {
1565 i != RTE_DIM(sup_ver) &&
1566 ixgbevf_negotiate_api_version(hw, sup_ver[i]) != 0;
1572 generate_random_mac_addr(struct ether_addr *mac_addr)
1576 /* Set Organizationally Unique Identifier (OUI) prefix. */
1577 mac_addr->addr_bytes[0] = 0x00;
1578 mac_addr->addr_bytes[1] = 0x09;
1579 mac_addr->addr_bytes[2] = 0xC0;
1580 /* Force indication of locally assigned MAC address. */
1581 mac_addr->addr_bytes[0] |= ETHER_LOCAL_ADMIN_ADDR;
1582 /* Generate the last 3 bytes of the MAC address with a random number. */
1583 random = rte_rand();
1584 memcpy(&mac_addr->addr_bytes[3], &random, 3);
1588 * Virtual Function device init
1591 eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev)
1595 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
1596 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
1597 struct ixgbe_hw *hw =
1598 IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
1599 struct ixgbe_vfta *shadow_vfta =
1600 IXGBE_DEV_PRIVATE_TO_VFTA(eth_dev->data->dev_private);
1601 struct ixgbe_hwstrip *hwstrip =
1602 IXGBE_DEV_PRIVATE_TO_HWSTRIP_BITMAP(eth_dev->data->dev_private);
1603 struct ether_addr *perm_addr = (struct ether_addr *) hw->mac.perm_addr;
1605 PMD_INIT_FUNC_TRACE();
1607 eth_dev->dev_ops = &ixgbevf_eth_dev_ops;
1608 eth_dev->rx_pkt_burst = &ixgbe_recv_pkts;
1609 eth_dev->tx_pkt_burst = &ixgbe_xmit_pkts;
1611 /* for secondary processes, we don't initialise any further as primary
1612 * has already done this work. Only check we don't need a different
1615 if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
1616 struct ixgbe_tx_queue *txq;
1617 /* TX queue function in primary, set by last queue initialized
1618 * Tx queue may not initialized by primary process
1620 if (eth_dev->data->tx_queues) {
1621 txq = eth_dev->data->tx_queues[eth_dev->data->nb_tx_queues - 1];
1622 ixgbe_set_tx_function(eth_dev, txq);
1624 /* Use default TX function if we get here */
1625 PMD_INIT_LOG(NOTICE,
1626 "No TX queues configured yet. Using default TX function.");
1629 ixgbe_set_rx_function(eth_dev);
1634 rte_eth_copy_pci_info(eth_dev, pci_dev);
1635 eth_dev->data->dev_flags |= RTE_ETH_DEV_DETACHABLE;
1637 hw->device_id = pci_dev->id.device_id;
1638 hw->vendor_id = pci_dev->id.vendor_id;
1639 hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
1641 /* initialize the vfta */
1642 memset(shadow_vfta, 0, sizeof(*shadow_vfta));
1644 /* initialize the hw strip bitmap*/
1645 memset(hwstrip, 0, sizeof(*hwstrip));
1647 /* Initialize the shared code (base driver) */
1648 diag = ixgbe_init_shared_code(hw);
1649 if (diag != IXGBE_SUCCESS) {
1650 PMD_INIT_LOG(ERR, "Shared code init failed for ixgbevf: %d", diag);
1654 /* init_mailbox_params */
1655 hw->mbx.ops.init_params(hw);
1657 /* Reset the hw statistics */
1658 ixgbevf_dev_stats_reset(eth_dev);
1660 /* Disable the interrupts for VF */
1661 ixgbevf_intr_disable(hw);
1663 hw->mac.num_rar_entries = 128; /* The MAX of the underlying PF */
1664 diag = hw->mac.ops.reset_hw(hw);
1667 * The VF reset operation returns the IXGBE_ERR_INVALID_MAC_ADDR when
1668 * the underlying PF driver has not assigned a MAC address to the VF.
1669 * In this case, assign a random MAC address.
1671 if ((diag != IXGBE_SUCCESS) && (diag != IXGBE_ERR_INVALID_MAC_ADDR)) {
1672 PMD_INIT_LOG(ERR, "VF Initialization Failure: %d", diag);
1676 /* negotiate mailbox API version to use with the PF. */
1677 ixgbevf_negotiate_api(hw);
1679 /* Get Rx/Tx queue count via mailbox, which is ready after reset_hw */
1680 ixgbevf_get_queues(hw, &tcs, &tc);
1682 /* Allocate memory for storing MAC addresses */
1683 eth_dev->data->mac_addrs = rte_zmalloc("ixgbevf", ETHER_ADDR_LEN *
1684 hw->mac.num_rar_entries, 0);
1685 if (eth_dev->data->mac_addrs == NULL) {
1687 "Failed to allocate %u bytes needed to store "
1689 ETHER_ADDR_LEN * hw->mac.num_rar_entries);
1693 /* Generate a random MAC address, if none was assigned by PF. */
1694 if (is_zero_ether_addr(perm_addr)) {
1695 generate_random_mac_addr(perm_addr);
1696 diag = ixgbe_set_rar_vf(hw, 1, perm_addr->addr_bytes, 0, 1);
1698 rte_free(eth_dev->data->mac_addrs);
1699 eth_dev->data->mac_addrs = NULL;
1702 PMD_INIT_LOG(INFO, "\tVF MAC address not assigned by Host PF");
1703 PMD_INIT_LOG(INFO, "\tAssign randomly generated MAC address "
1704 "%02x:%02x:%02x:%02x:%02x:%02x",
1705 perm_addr->addr_bytes[0],
1706 perm_addr->addr_bytes[1],
1707 perm_addr->addr_bytes[2],
1708 perm_addr->addr_bytes[3],
1709 perm_addr->addr_bytes[4],
1710 perm_addr->addr_bytes[5]);
1713 /* Copy the permanent MAC address */
1714 ether_addr_copy(perm_addr, ð_dev->data->mac_addrs[0]);
1716 /* reset the hardware with the new settings */
1717 diag = hw->mac.ops.start_hw(hw);
1723 PMD_INIT_LOG(ERR, "VF Initialization Failure: %d", diag);
1727 rte_intr_callback_register(intr_handle,
1728 ixgbevf_dev_interrupt_handler, eth_dev);
1729 rte_intr_enable(intr_handle);
1730 ixgbevf_intr_enable(hw);
1732 PMD_INIT_LOG(DEBUG, "port %d vendorID=0x%x deviceID=0x%x mac.type=%s",
1733 eth_dev->data->port_id, pci_dev->id.vendor_id,
1734 pci_dev->id.device_id, "ixgbe_mac_82599_vf");
1739 /* Virtual Function device uninit */
1742 eth_ixgbevf_dev_uninit(struct rte_eth_dev *eth_dev)
1744 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
1745 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
1746 struct ixgbe_hw *hw;
1748 PMD_INIT_FUNC_TRACE();
1750 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
1753 hw = IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
1755 if (hw->adapter_stopped == 0)
1756 ixgbevf_dev_close(eth_dev);
1758 eth_dev->dev_ops = NULL;
1759 eth_dev->rx_pkt_burst = NULL;
1760 eth_dev->tx_pkt_burst = NULL;
1762 /* Disable the interrupts for VF */
1763 ixgbevf_intr_disable(hw);
1765 rte_free(eth_dev->data->mac_addrs);
1766 eth_dev->data->mac_addrs = NULL;
1768 rte_intr_disable(intr_handle);
1769 rte_intr_callback_unregister(intr_handle,
1770 ixgbevf_dev_interrupt_handler, eth_dev);
1775 static int eth_ixgbe_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
1776 struct rte_pci_device *pci_dev)
1778 return rte_eth_dev_pci_generic_probe(pci_dev,
1779 sizeof(struct ixgbe_adapter), eth_ixgbe_dev_init);
1782 static int eth_ixgbe_pci_remove(struct rte_pci_device *pci_dev)
1784 return rte_eth_dev_pci_generic_remove(pci_dev, eth_ixgbe_dev_uninit);
1787 static struct rte_pci_driver rte_ixgbe_pmd = {
1788 .id_table = pci_id_ixgbe_map,
1789 .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
1790 .probe = eth_ixgbe_pci_probe,
1791 .remove = eth_ixgbe_pci_remove,
1794 static int eth_ixgbevf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
1795 struct rte_pci_device *pci_dev)
1797 return rte_eth_dev_pci_generic_probe(pci_dev,
1798 sizeof(struct ixgbe_adapter), eth_ixgbevf_dev_init);
1801 static int eth_ixgbevf_pci_remove(struct rte_pci_device *pci_dev)
1803 return rte_eth_dev_pci_generic_remove(pci_dev, eth_ixgbevf_dev_uninit);
1807 * virtual function driver struct
1809 static struct rte_pci_driver rte_ixgbevf_pmd = {
1810 .id_table = pci_id_ixgbevf_map,
1811 .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
1812 .probe = eth_ixgbevf_pci_probe,
1813 .remove = eth_ixgbevf_pci_remove,
1817 ixgbe_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
1819 struct ixgbe_hw *hw =
1820 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1821 struct ixgbe_vfta *shadow_vfta =
1822 IXGBE_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
1827 vid_idx = (uint32_t) ((vlan_id >> 5) & 0x7F);
1828 vid_bit = (uint32_t) (1 << (vlan_id & 0x1F));
1829 vfta = IXGBE_READ_REG(hw, IXGBE_VFTA(vid_idx));
1834 IXGBE_WRITE_REG(hw, IXGBE_VFTA(vid_idx), vfta);
1836 /* update local VFTA copy */
1837 shadow_vfta->vfta[vid_idx] = vfta;
1843 ixgbe_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue, int on)
1846 ixgbe_vlan_hw_strip_enable(dev, queue);
1848 ixgbe_vlan_hw_strip_disable(dev, queue);
1852 ixgbe_vlan_tpid_set(struct rte_eth_dev *dev,
1853 enum rte_vlan_type vlan_type,
1856 struct ixgbe_hw *hw =
1857 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1862 qinq = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
1863 qinq &= IXGBE_DMATXCTL_GDV;
1865 switch (vlan_type) {
1866 case ETH_VLAN_TYPE_INNER:
1868 reg = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
1869 reg = (reg & (~IXGBE_VLNCTRL_VET)) | (uint32_t)tpid;
1870 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, reg);
1871 reg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
1872 reg = (reg & (~IXGBE_DMATXCTL_VT_MASK))
1873 | ((uint32_t)tpid << IXGBE_DMATXCTL_VT_SHIFT);
1874 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);
1877 PMD_DRV_LOG(ERR, "Inner type is not supported"
1881 case ETH_VLAN_TYPE_OUTER:
1883 /* Only the high 16-bits is valid */
1884 IXGBE_WRITE_REG(hw, IXGBE_EXVET, (uint32_t)tpid <<
1885 IXGBE_EXVET_VET_EXT_SHIFT);
1887 reg = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
1888 reg = (reg & (~IXGBE_VLNCTRL_VET)) | (uint32_t)tpid;
1889 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, reg);
1890 reg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
1891 reg = (reg & (~IXGBE_DMATXCTL_VT_MASK))
1892 | ((uint32_t)tpid << IXGBE_DMATXCTL_VT_SHIFT);
1893 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);
1899 PMD_DRV_LOG(ERR, "Unsupported VLAN type %d", vlan_type);
1907 ixgbe_vlan_hw_filter_disable(struct rte_eth_dev *dev)
1909 struct ixgbe_hw *hw =
1910 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1913 PMD_INIT_FUNC_TRACE();
1915 /* Filter Table Disable */
1916 vlnctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
1917 vlnctrl &= ~IXGBE_VLNCTRL_VFE;
1919 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlnctrl);
1923 ixgbe_vlan_hw_filter_enable(struct rte_eth_dev *dev)
1925 struct ixgbe_hw *hw =
1926 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1927 struct ixgbe_vfta *shadow_vfta =
1928 IXGBE_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
1932 PMD_INIT_FUNC_TRACE();
1934 /* Filter Table Enable */
1935 vlnctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
1936 vlnctrl &= ~IXGBE_VLNCTRL_CFIEN;
1937 vlnctrl |= IXGBE_VLNCTRL_VFE;
1939 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlnctrl);
1941 /* write whatever is in local vfta copy */
1942 for (i = 0; i < IXGBE_VFTA_SIZE; i++)
1943 IXGBE_WRITE_REG(hw, IXGBE_VFTA(i), shadow_vfta->vfta[i]);
1947 ixgbe_vlan_hw_strip_bitmap_set(struct rte_eth_dev *dev, uint16_t queue, bool on)
1949 struct ixgbe_hwstrip *hwstrip =
1950 IXGBE_DEV_PRIVATE_TO_HWSTRIP_BITMAP(dev->data->dev_private);
1951 struct ixgbe_rx_queue *rxq;
1953 if (queue >= IXGBE_MAX_RX_QUEUE_NUM)
1957 IXGBE_SET_HWSTRIP(hwstrip, queue);
1959 IXGBE_CLEAR_HWSTRIP(hwstrip, queue);
1961 if (queue >= dev->data->nb_rx_queues)
1964 rxq = dev->data->rx_queues[queue];
1967 rxq->vlan_flags = PKT_RX_VLAN_PKT | PKT_RX_VLAN_STRIPPED;
1969 rxq->vlan_flags = PKT_RX_VLAN_PKT;
1973 ixgbe_vlan_hw_strip_disable(struct rte_eth_dev *dev, uint16_t queue)
1975 struct ixgbe_hw *hw =
1976 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1979 PMD_INIT_FUNC_TRACE();
1981 if (hw->mac.type == ixgbe_mac_82598EB) {
1982 /* No queue level support */
1983 PMD_INIT_LOG(NOTICE, "82598EB not support queue level hw strip");
1987 /* Other 10G NIC, the VLAN strip can be setup per queue in RXDCTL */
1988 ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(queue));
1989 ctrl &= ~IXGBE_RXDCTL_VME;
1990 IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(queue), ctrl);
1992 /* record those setting for HW strip per queue */
1993 ixgbe_vlan_hw_strip_bitmap_set(dev, queue, 0);
1997 ixgbe_vlan_hw_strip_enable(struct rte_eth_dev *dev, uint16_t queue)
1999 struct ixgbe_hw *hw =
2000 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2003 PMD_INIT_FUNC_TRACE();
2005 if (hw->mac.type == ixgbe_mac_82598EB) {
2006 /* No queue level supported */
2007 PMD_INIT_LOG(NOTICE, "82598EB not support queue level hw strip");
2011 /* Other 10G NIC, the VLAN strip can be setup per queue in RXDCTL */
2012 ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(queue));
2013 ctrl |= IXGBE_RXDCTL_VME;
2014 IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(queue), ctrl);
2016 /* record those setting for HW strip per queue */
2017 ixgbe_vlan_hw_strip_bitmap_set(dev, queue, 1);
2021 ixgbe_vlan_hw_strip_disable_all(struct rte_eth_dev *dev)
2023 struct ixgbe_hw *hw =
2024 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2027 struct ixgbe_rx_queue *rxq;
2029 PMD_INIT_FUNC_TRACE();
2031 if (hw->mac.type == ixgbe_mac_82598EB) {
2032 ctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
2033 ctrl &= ~IXGBE_VLNCTRL_VME;
2034 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, ctrl);
2036 /* Other 10G NIC, the VLAN strip can be setup per queue in RXDCTL */
2037 for (i = 0; i < dev->data->nb_rx_queues; i++) {
2038 rxq = dev->data->rx_queues[i];
2039 ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(rxq->reg_idx));
2040 ctrl &= ~IXGBE_RXDCTL_VME;
2041 IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(rxq->reg_idx), ctrl);
2043 /* record those setting for HW strip per queue */
2044 ixgbe_vlan_hw_strip_bitmap_set(dev, i, 0);
2050 ixgbe_vlan_hw_strip_enable_all(struct rte_eth_dev *dev)
2052 struct ixgbe_hw *hw =
2053 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2056 struct ixgbe_rx_queue *rxq;
2058 PMD_INIT_FUNC_TRACE();
2060 if (hw->mac.type == ixgbe_mac_82598EB) {
2061 ctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
2062 ctrl |= IXGBE_VLNCTRL_VME;
2063 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, ctrl);
2065 /* Other 10G NIC, the VLAN strip can be setup per queue in RXDCTL */
2066 for (i = 0; i < dev->data->nb_rx_queues; i++) {
2067 rxq = dev->data->rx_queues[i];
2068 ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(rxq->reg_idx));
2069 ctrl |= IXGBE_RXDCTL_VME;
2070 IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(rxq->reg_idx), ctrl);
2072 /* record those setting for HW strip per queue */
2073 ixgbe_vlan_hw_strip_bitmap_set(dev, i, 1);
2079 ixgbe_vlan_hw_extend_disable(struct rte_eth_dev *dev)
2081 struct ixgbe_hw *hw =
2082 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2085 PMD_INIT_FUNC_TRACE();
2087 /* DMATXCTRL: Geric Double VLAN Disable */
2088 ctrl = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
2089 ctrl &= ~IXGBE_DMATXCTL_GDV;
2090 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, ctrl);
2092 /* CTRL_EXT: Global Double VLAN Disable */
2093 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
2094 ctrl &= ~IXGBE_EXTENDED_VLAN;
2095 IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl);
2100 ixgbe_vlan_hw_extend_enable(struct rte_eth_dev *dev)
2102 struct ixgbe_hw *hw =
2103 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2106 PMD_INIT_FUNC_TRACE();
2108 /* DMATXCTRL: Geric Double VLAN Enable */
2109 ctrl = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
2110 ctrl |= IXGBE_DMATXCTL_GDV;
2111 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, ctrl);
2113 /* CTRL_EXT: Global Double VLAN Enable */
2114 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
2115 ctrl |= IXGBE_EXTENDED_VLAN;
2116 IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl);
2118 /* Clear pooling mode of PFVTCTL. It's required by X550. */
2119 if (hw->mac.type == ixgbe_mac_X550 ||
2120 hw->mac.type == ixgbe_mac_X550EM_x ||
2121 hw->mac.type == ixgbe_mac_X550EM_a) {
2122 ctrl = IXGBE_READ_REG(hw, IXGBE_VT_CTL);
2123 ctrl &= ~IXGBE_VT_CTL_POOLING_MODE_MASK;
2124 IXGBE_WRITE_REG(hw, IXGBE_VT_CTL, ctrl);
2128 * VET EXT field in the EXVET register = 0x8100 by default
2129 * So no need to change. Same to VT field of DMATXCTL register
2134 ixgbe_vlan_offload_set(struct rte_eth_dev *dev, int mask)
2136 if (mask & ETH_VLAN_STRIP_MASK) {
2137 if (dev->data->dev_conf.rxmode.hw_vlan_strip)
2138 ixgbe_vlan_hw_strip_enable_all(dev);
2140 ixgbe_vlan_hw_strip_disable_all(dev);
2143 if (mask & ETH_VLAN_FILTER_MASK) {
2144 if (dev->data->dev_conf.rxmode.hw_vlan_filter)
2145 ixgbe_vlan_hw_filter_enable(dev);
2147 ixgbe_vlan_hw_filter_disable(dev);
2150 if (mask & ETH_VLAN_EXTEND_MASK) {
2151 if (dev->data->dev_conf.rxmode.hw_vlan_extend)
2152 ixgbe_vlan_hw_extend_enable(dev);
2154 ixgbe_vlan_hw_extend_disable(dev);
2159 ixgbe_vmdq_vlan_hw_filter_enable(struct rte_eth_dev *dev)
2161 struct ixgbe_hw *hw =
2162 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2163 /* VLNCTRL: enable vlan filtering and allow all vlan tags through */
2164 uint32_t vlanctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
2166 vlanctrl |= IXGBE_VLNCTRL_VFE; /* enable vlan filters */
2167 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlanctrl);
2171 ixgbe_check_vf_rss_rxq_num(struct rte_eth_dev *dev, uint16_t nb_rx_q)
2173 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
2178 RTE_ETH_DEV_SRIOV(dev).active = ETH_64_POOLS;
2181 RTE_ETH_DEV_SRIOV(dev).active = ETH_32_POOLS;
2187 RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool = nb_rx_q;
2188 RTE_ETH_DEV_SRIOV(dev).def_pool_q_idx = pci_dev->max_vfs * nb_rx_q;
2194 ixgbe_check_mq_mode(struct rte_eth_dev *dev)
2196 struct rte_eth_conf *dev_conf = &dev->data->dev_conf;
2197 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2198 uint16_t nb_rx_q = dev->data->nb_rx_queues;
2199 uint16_t nb_tx_q = dev->data->nb_tx_queues;
2201 if (RTE_ETH_DEV_SRIOV(dev).active != 0) {
2202 /* check multi-queue mode */
2203 switch (dev_conf->rxmode.mq_mode) {
2204 case ETH_MQ_RX_VMDQ_DCB:
2205 PMD_INIT_LOG(INFO, "ETH_MQ_RX_VMDQ_DCB mode supported in SRIOV");
2207 case ETH_MQ_RX_VMDQ_DCB_RSS:
2208 /* DCB/RSS VMDQ in SRIOV mode, not implement yet */
2209 PMD_INIT_LOG(ERR, "SRIOV active,"
2210 " unsupported mq_mode rx %d.",
2211 dev_conf->rxmode.mq_mode);
2214 case ETH_MQ_RX_VMDQ_RSS:
2215 dev->data->dev_conf.rxmode.mq_mode = ETH_MQ_RX_VMDQ_RSS;
2216 if (nb_rx_q <= RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool)
2217 if (ixgbe_check_vf_rss_rxq_num(dev, nb_rx_q)) {
2218 PMD_INIT_LOG(ERR, "SRIOV is active,"
2219 " invalid queue number"
2220 " for VMDQ RSS, allowed"
2221 " value are 1, 2 or 4.");
2225 case ETH_MQ_RX_VMDQ_ONLY:
2226 case ETH_MQ_RX_NONE:
2227 /* if nothing mq mode configure, use default scheme */
2228 dev->data->dev_conf.rxmode.mq_mode = ETH_MQ_RX_VMDQ_ONLY;
2229 if (RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool > 1)
2230 RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool = 1;
2232 default: /* ETH_MQ_RX_DCB, ETH_MQ_RX_DCB_RSS or ETH_MQ_TX_DCB*/
2233 /* SRIOV only works in VMDq enable mode */
2234 PMD_INIT_LOG(ERR, "SRIOV is active,"
2235 " wrong mq_mode rx %d.",
2236 dev_conf->rxmode.mq_mode);
2240 switch (dev_conf->txmode.mq_mode) {
2241 case ETH_MQ_TX_VMDQ_DCB:
2242 PMD_INIT_LOG(INFO, "ETH_MQ_TX_VMDQ_DCB mode supported in SRIOV");
2243 dev->data->dev_conf.txmode.mq_mode = ETH_MQ_TX_VMDQ_DCB;
2245 default: /* ETH_MQ_TX_VMDQ_ONLY or ETH_MQ_TX_NONE */
2246 dev->data->dev_conf.txmode.mq_mode = ETH_MQ_TX_VMDQ_ONLY;
2250 /* check valid queue number */
2251 if ((nb_rx_q > RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool) ||
2252 (nb_tx_q > RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool)) {
2253 PMD_INIT_LOG(ERR, "SRIOV is active,"
2254 " nb_rx_q=%d nb_tx_q=%d queue number"
2255 " must be less than or equal to %d.",
2257 RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool);
2261 if (dev_conf->rxmode.mq_mode == ETH_MQ_RX_VMDQ_DCB_RSS) {
2262 PMD_INIT_LOG(ERR, "VMDQ+DCB+RSS mq_mode is"
2266 /* check configuration for vmdb+dcb mode */
2267 if (dev_conf->rxmode.mq_mode == ETH_MQ_RX_VMDQ_DCB) {
2268 const struct rte_eth_vmdq_dcb_conf *conf;
2270 if (nb_rx_q != IXGBE_VMDQ_DCB_NB_QUEUES) {
2271 PMD_INIT_LOG(ERR, "VMDQ+DCB, nb_rx_q != %d.",
2272 IXGBE_VMDQ_DCB_NB_QUEUES);
2275 conf = &dev_conf->rx_adv_conf.vmdq_dcb_conf;
2276 if (!(conf->nb_queue_pools == ETH_16_POOLS ||
2277 conf->nb_queue_pools == ETH_32_POOLS)) {
2278 PMD_INIT_LOG(ERR, "VMDQ+DCB selected,"
2279 " nb_queue_pools must be %d or %d.",
2280 ETH_16_POOLS, ETH_32_POOLS);
2284 if (dev_conf->txmode.mq_mode == ETH_MQ_TX_VMDQ_DCB) {
2285 const struct rte_eth_vmdq_dcb_tx_conf *conf;
2287 if (nb_tx_q != IXGBE_VMDQ_DCB_NB_QUEUES) {
2288 PMD_INIT_LOG(ERR, "VMDQ+DCB, nb_tx_q != %d",
2289 IXGBE_VMDQ_DCB_NB_QUEUES);
2292 conf = &dev_conf->tx_adv_conf.vmdq_dcb_tx_conf;
2293 if (!(conf->nb_queue_pools == ETH_16_POOLS ||
2294 conf->nb_queue_pools == ETH_32_POOLS)) {
2295 PMD_INIT_LOG(ERR, "VMDQ+DCB selected,"
2296 " nb_queue_pools != %d and"
2297 " nb_queue_pools != %d.",
2298 ETH_16_POOLS, ETH_32_POOLS);
2303 /* For DCB mode check our configuration before we go further */
2304 if (dev_conf->rxmode.mq_mode == ETH_MQ_RX_DCB) {
2305 const struct rte_eth_dcb_rx_conf *conf;
2307 if (nb_rx_q != IXGBE_DCB_NB_QUEUES) {
2308 PMD_INIT_LOG(ERR, "DCB selected, nb_rx_q != %d.",
2309 IXGBE_DCB_NB_QUEUES);
2312 conf = &dev_conf->rx_adv_conf.dcb_rx_conf;
2313 if (!(conf->nb_tcs == ETH_4_TCS ||
2314 conf->nb_tcs == ETH_8_TCS)) {
2315 PMD_INIT_LOG(ERR, "DCB selected, nb_tcs != %d"
2316 " and nb_tcs != %d.",
2317 ETH_4_TCS, ETH_8_TCS);
2322 if (dev_conf->txmode.mq_mode == ETH_MQ_TX_DCB) {
2323 const struct rte_eth_dcb_tx_conf *conf;
2325 if (nb_tx_q != IXGBE_DCB_NB_QUEUES) {
2326 PMD_INIT_LOG(ERR, "DCB, nb_tx_q != %d.",
2327 IXGBE_DCB_NB_QUEUES);
2330 conf = &dev_conf->tx_adv_conf.dcb_tx_conf;
2331 if (!(conf->nb_tcs == ETH_4_TCS ||
2332 conf->nb_tcs == ETH_8_TCS)) {
2333 PMD_INIT_LOG(ERR, "DCB selected, nb_tcs != %d"
2334 " and nb_tcs != %d.",
2335 ETH_4_TCS, ETH_8_TCS);
2341 * When DCB/VT is off, maximum number of queues changes,
2342 * except for 82598EB, which remains constant.
2344 if (dev_conf->txmode.mq_mode == ETH_MQ_TX_NONE &&
2345 hw->mac.type != ixgbe_mac_82598EB) {
2346 if (nb_tx_q > IXGBE_NONE_MODE_TX_NB_QUEUES) {
2348 "Neither VT nor DCB are enabled, "
2350 IXGBE_NONE_MODE_TX_NB_QUEUES);
2359 ixgbe_dev_configure(struct rte_eth_dev *dev)
2361 struct ixgbe_interrupt *intr =
2362 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
2363 struct ixgbe_adapter *adapter =
2364 (struct ixgbe_adapter *)dev->data->dev_private;
2367 PMD_INIT_FUNC_TRACE();
2368 /* multipe queue mode checking */
2369 ret = ixgbe_check_mq_mode(dev);
2371 PMD_DRV_LOG(ERR, "ixgbe_check_mq_mode fails with %d.",
2376 /* set flag to update link status after init */
2377 intr->flags |= IXGBE_FLAG_NEED_LINK_UPDATE;
2380 * Initialize to TRUE. If any of Rx queues doesn't meet the bulk
2381 * allocation or vector Rx preconditions we will reset it.
2383 adapter->rx_bulk_alloc_allowed = true;
2384 adapter->rx_vec_allowed = true;
2390 ixgbe_dev_phy_intr_setup(struct rte_eth_dev *dev)
2392 struct ixgbe_hw *hw =
2393 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2394 struct ixgbe_interrupt *intr =
2395 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
2398 /* only set up it on X550EM_X */
2399 if (hw->mac.type == ixgbe_mac_X550EM_x) {
2400 gpie = IXGBE_READ_REG(hw, IXGBE_GPIE);
2401 gpie |= IXGBE_SDP0_GPIEN_X550EM_x;
2402 IXGBE_WRITE_REG(hw, IXGBE_GPIE, gpie);
2403 if (hw->phy.type == ixgbe_phy_x550em_ext_t)
2404 intr->mask |= IXGBE_EICR_GPI_SDP0_X550EM_x;
2409 ixgbe_set_vf_rate_limit(struct rte_eth_dev *dev, uint16_t vf,
2410 uint16_t tx_rate, uint64_t q_msk)
2412 struct ixgbe_hw *hw;
2413 struct ixgbe_vf_info *vfinfo;
2414 struct rte_eth_link link;
2415 uint8_t nb_q_per_pool;
2416 uint32_t queue_stride;
2417 uint32_t queue_idx, idx = 0, vf_idx;
2419 uint16_t total_rate = 0;
2420 struct rte_pci_device *pci_dev;
2422 pci_dev = RTE_ETH_DEV_TO_PCI(dev);
2423 rte_eth_link_get_nowait(dev->data->port_id, &link);
2425 if (vf >= pci_dev->max_vfs)
2428 if (tx_rate > link.link_speed)
2434 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2435 vfinfo = *(IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private));
2436 nb_q_per_pool = RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool;
2437 queue_stride = IXGBE_MAX_RX_QUEUE_NUM / RTE_ETH_DEV_SRIOV(dev).active;
2438 queue_idx = vf * queue_stride;
2439 queue_end = queue_idx + nb_q_per_pool - 1;
2440 if (queue_end >= hw->mac.max_tx_queues)
2444 for (vf_idx = 0; vf_idx < pci_dev->max_vfs; vf_idx++) {
2447 for (idx = 0; idx < RTE_DIM(vfinfo[vf_idx].tx_rate);
2449 total_rate += vfinfo[vf_idx].tx_rate[idx];
2455 /* Store tx_rate for this vf. */
2456 for (idx = 0; idx < nb_q_per_pool; idx++) {
2457 if (((uint64_t)0x1 << idx) & q_msk) {
2458 if (vfinfo[vf].tx_rate[idx] != tx_rate)
2459 vfinfo[vf].tx_rate[idx] = tx_rate;
2460 total_rate += tx_rate;
2464 if (total_rate > dev->data->dev_link.link_speed) {
2465 /* Reset stored TX rate of the VF if it causes exceed
2468 memset(vfinfo[vf].tx_rate, 0, sizeof(vfinfo[vf].tx_rate));
2472 /* Set RTTBCNRC of each queue/pool for vf X */
2473 for (; queue_idx <= queue_end; queue_idx++) {
2475 ixgbe_set_queue_rate_limit(dev, queue_idx, tx_rate);
2483 * Configure device link speed and setup link.
2484 * It returns 0 on success.
2487 ixgbe_dev_start(struct rte_eth_dev *dev)
2489 struct ixgbe_hw *hw =
2490 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2491 struct ixgbe_vf_info *vfinfo =
2492 *IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private);
2493 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
2494 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
2495 uint32_t intr_vector = 0;
2496 int err, link_up = 0, negotiate = 0;
2501 uint32_t *link_speeds;
2502 struct ixgbe_tm_conf *tm_conf =
2503 IXGBE_DEV_PRIVATE_TO_TM_CONF(dev->data->dev_private);
2505 PMD_INIT_FUNC_TRACE();
2507 /* IXGBE devices don't support:
2508 * - half duplex (checked afterwards for valid speeds)
2509 * - fixed speed: TODO implement
2511 if (dev->data->dev_conf.link_speeds & ETH_LINK_SPEED_FIXED) {
2512 PMD_INIT_LOG(ERR, "Invalid link_speeds for port %hhu; fix speed not supported",
2513 dev->data->port_id);
2517 /* disable uio/vfio intr/eventfd mapping */
2518 rte_intr_disable(intr_handle);
2521 hw->adapter_stopped = 0;
2522 ixgbe_stop_adapter(hw);
2524 /* reinitialize adapter
2525 * this calls reset and start
2527 status = ixgbe_pf_reset_hw(hw);
2530 hw->mac.ops.start_hw(hw);
2531 hw->mac.get_link_status = true;
2533 /* configure PF module if SRIOV enabled */
2534 ixgbe_pf_host_configure(dev);
2536 ixgbe_dev_phy_intr_setup(dev);
2538 /* check and configure queue intr-vector mapping */
2539 if ((rte_intr_cap_multiple(intr_handle) ||
2540 !RTE_ETH_DEV_SRIOV(dev).active) &&
2541 dev->data->dev_conf.intr_conf.rxq != 0) {
2542 intr_vector = dev->data->nb_rx_queues;
2543 if (intr_vector > IXGBE_MAX_INTR_QUEUE_NUM) {
2544 PMD_INIT_LOG(ERR, "At most %d intr queues supported",
2545 IXGBE_MAX_INTR_QUEUE_NUM);
2548 if (rte_intr_efd_enable(intr_handle, intr_vector))
2552 if (rte_intr_dp_is_en(intr_handle) && !intr_handle->intr_vec) {
2553 intr_handle->intr_vec =
2554 rte_zmalloc("intr_vec",
2555 dev->data->nb_rx_queues * sizeof(int), 0);
2556 if (intr_handle->intr_vec == NULL) {
2557 PMD_INIT_LOG(ERR, "Failed to allocate %d rx_queues"
2558 " intr_vec", dev->data->nb_rx_queues);
2563 /* confiugre msix for sleep until rx interrupt */
2564 ixgbe_configure_msix(dev);
2566 /* initialize transmission unit */
2567 ixgbe_dev_tx_init(dev);
2569 /* This can fail when allocating mbufs for descriptor rings */
2570 err = ixgbe_dev_rx_init(dev);
2572 PMD_INIT_LOG(ERR, "Unable to initialize RX hardware");
2576 mask = ETH_VLAN_STRIP_MASK | ETH_VLAN_FILTER_MASK |
2577 ETH_VLAN_EXTEND_MASK;
2578 ixgbe_vlan_offload_set(dev, mask);
2580 if (dev->data->dev_conf.rxmode.mq_mode == ETH_MQ_RX_VMDQ_ONLY) {
2581 /* Enable vlan filtering for VMDq */
2582 ixgbe_vmdq_vlan_hw_filter_enable(dev);
2585 /* Configure DCB hw */
2586 ixgbe_configure_dcb(dev);
2588 if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_NONE) {
2589 err = ixgbe_fdir_configure(dev);
2594 /* Restore vf rate limit */
2595 if (vfinfo != NULL) {
2596 for (vf = 0; vf < pci_dev->max_vfs; vf++)
2597 for (idx = 0; idx < IXGBE_MAX_QUEUE_NUM_PER_VF; idx++)
2598 if (vfinfo[vf].tx_rate[idx] != 0)
2599 ixgbe_set_vf_rate_limit(
2601 vfinfo[vf].tx_rate[idx],
2605 ixgbe_restore_statistics_mapping(dev);
2607 err = ixgbe_dev_rxtx_start(dev);
2609 PMD_INIT_LOG(ERR, "Unable to start rxtx queues");
2613 /* Skip link setup if loopback mode is enabled for 82599. */
2614 if (hw->mac.type == ixgbe_mac_82599EB &&
2615 dev->data->dev_conf.lpbk_mode == IXGBE_LPBK_82599_TX_RX)
2616 goto skip_link_setup;
2618 if (ixgbe_is_sfp(hw) && hw->phy.multispeed_fiber) {
2619 err = hw->mac.ops.setup_sfp(hw);
2624 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper) {
2625 /* Turn on the copper */
2626 ixgbe_set_phy_power(hw, true);
2628 /* Turn on the laser */
2629 ixgbe_enable_tx_laser(hw);
2632 err = ixgbe_check_link(hw, &speed, &link_up, 0);
2635 dev->data->dev_link.link_status = link_up;
2637 err = ixgbe_get_link_capabilities(hw, &speed, &negotiate);
2641 link_speeds = &dev->data->dev_conf.link_speeds;
2642 if (*link_speeds & ~(ETH_LINK_SPEED_100M | ETH_LINK_SPEED_1G |
2643 ETH_LINK_SPEED_10G)) {
2644 PMD_INIT_LOG(ERR, "Invalid link setting");
2649 if (*link_speeds == ETH_LINK_SPEED_AUTONEG) {
2650 speed = (hw->mac.type != ixgbe_mac_82598EB) ?
2651 IXGBE_LINK_SPEED_82599_AUTONEG :
2652 IXGBE_LINK_SPEED_82598_AUTONEG;
2654 if (*link_speeds & ETH_LINK_SPEED_10G)
2655 speed |= IXGBE_LINK_SPEED_10GB_FULL;
2656 if (*link_speeds & ETH_LINK_SPEED_1G)
2657 speed |= IXGBE_LINK_SPEED_1GB_FULL;
2658 if (*link_speeds & ETH_LINK_SPEED_100M)
2659 speed |= IXGBE_LINK_SPEED_100_FULL;
2662 err = ixgbe_setup_link(hw, speed, link_up);
2668 if (rte_intr_allow_others(intr_handle)) {
2669 /* check if lsc interrupt is enabled */
2670 if (dev->data->dev_conf.intr_conf.lsc != 0)
2671 ixgbe_dev_lsc_interrupt_setup(dev);
2672 ixgbe_dev_macsec_interrupt_setup(dev);
2674 rte_intr_callback_unregister(intr_handle,
2675 ixgbe_dev_interrupt_handler, dev);
2676 if (dev->data->dev_conf.intr_conf.lsc != 0)
2677 PMD_INIT_LOG(INFO, "lsc won't enable because of"
2678 " no intr multiplex");
2681 /* check if rxq interrupt is enabled */
2682 if (dev->data->dev_conf.intr_conf.rxq != 0 &&
2683 rte_intr_dp_is_en(intr_handle))
2684 ixgbe_dev_rxq_interrupt_setup(dev);
2686 /* enable uio/vfio intr/eventfd mapping */
2687 rte_intr_enable(intr_handle);
2689 /* resume enabled intr since hw reset */
2690 ixgbe_enable_intr(dev);
2691 ixgbe_l2_tunnel_conf(dev);
2692 ixgbe_filter_restore(dev);
2694 if (!tm_conf->committed)
2695 PMD_DRV_LOG(WARNING,
2696 "please call hierarchy_commit() "
2697 "before starting the port");
2702 PMD_INIT_LOG(ERR, "failure in ixgbe_dev_start(): %d", err);
2703 ixgbe_dev_clear_queues(dev);
2708 * Stop device: disable rx and tx functions to allow for reconfiguring.
2711 ixgbe_dev_stop(struct rte_eth_dev *dev)
2713 struct rte_eth_link link;
2714 struct ixgbe_hw *hw =
2715 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2716 struct ixgbe_vf_info *vfinfo =
2717 *IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private);
2718 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
2719 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
2721 struct ixgbe_tm_conf *tm_conf =
2722 IXGBE_DEV_PRIVATE_TO_TM_CONF(dev->data->dev_private);
2724 PMD_INIT_FUNC_TRACE();
2726 /* disable interrupts */
2727 ixgbe_disable_intr(hw);
2730 ixgbe_pf_reset_hw(hw);
2731 hw->adapter_stopped = 0;
2734 ixgbe_stop_adapter(hw);
2736 for (vf = 0; vfinfo != NULL && vf < pci_dev->max_vfs; vf++)
2737 vfinfo[vf].clear_to_send = false;
2739 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper) {
2740 /* Turn off the copper */
2741 ixgbe_set_phy_power(hw, false);
2743 /* Turn off the laser */
2744 ixgbe_disable_tx_laser(hw);
2747 ixgbe_dev_clear_queues(dev);
2749 /* Clear stored conf */
2750 dev->data->scattered_rx = 0;
2753 /* Clear recorded link status */
2754 memset(&link, 0, sizeof(link));
2755 rte_ixgbe_dev_atomic_write_link_status(dev, &link);
2757 if (!rte_intr_allow_others(intr_handle))
2758 /* resume to the default handler */
2759 rte_intr_callback_register(intr_handle,
2760 ixgbe_dev_interrupt_handler,
2763 /* Clean datapath event and queue/vec mapping */
2764 rte_intr_efd_disable(intr_handle);
2765 if (intr_handle->intr_vec != NULL) {
2766 rte_free(intr_handle->intr_vec);
2767 intr_handle->intr_vec = NULL;
2770 /* reset hierarchy commit */
2771 tm_conf->committed = false;
2775 * Set device link up: enable tx.
2778 ixgbe_dev_set_link_up(struct rte_eth_dev *dev)
2780 struct ixgbe_hw *hw =
2781 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2782 if (hw->mac.type == ixgbe_mac_82599EB) {
2783 #ifdef RTE_LIBRTE_IXGBE_BYPASS
2784 if (hw->device_id == IXGBE_DEV_ID_82599_BYPASS) {
2785 /* Not suported in bypass mode */
2786 PMD_INIT_LOG(ERR, "Set link up is not supported "
2787 "by device id 0x%x", hw->device_id);
2793 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper) {
2794 /* Turn on the copper */
2795 ixgbe_set_phy_power(hw, true);
2797 /* Turn on the laser */
2798 ixgbe_enable_tx_laser(hw);
2805 * Set device link down: disable tx.
2808 ixgbe_dev_set_link_down(struct rte_eth_dev *dev)
2810 struct ixgbe_hw *hw =
2811 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2812 if (hw->mac.type == ixgbe_mac_82599EB) {
2813 #ifdef RTE_LIBRTE_IXGBE_BYPASS
2814 if (hw->device_id == IXGBE_DEV_ID_82599_BYPASS) {
2815 /* Not suported in bypass mode */
2816 PMD_INIT_LOG(ERR, "Set link down is not supported "
2817 "by device id 0x%x", hw->device_id);
2823 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper) {
2824 /* Turn off the copper */
2825 ixgbe_set_phy_power(hw, false);
2827 /* Turn off the laser */
2828 ixgbe_disable_tx_laser(hw);
2835 * Reest and stop device.
2838 ixgbe_dev_close(struct rte_eth_dev *dev)
2840 struct ixgbe_hw *hw =
2841 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2843 PMD_INIT_FUNC_TRACE();
2845 ixgbe_pf_reset_hw(hw);
2847 ixgbe_dev_stop(dev);
2848 hw->adapter_stopped = 1;
2850 ixgbe_dev_free_queues(dev);
2852 ixgbe_disable_pcie_master(hw);
2854 /* reprogram the RAR[0] in case user changed it. */
2855 ixgbe_set_rar(hw, 0, hw->mac.addr, 0, IXGBE_RAH_AV);
2859 ixgbe_read_stats_registers(struct ixgbe_hw *hw,
2860 struct ixgbe_hw_stats *hw_stats,
2861 struct ixgbe_macsec_stats *macsec_stats,
2862 uint64_t *total_missed_rx, uint64_t *total_qbrc,
2863 uint64_t *total_qprc, uint64_t *total_qprdc)
2865 uint32_t bprc, lxon, lxoff, total;
2866 uint32_t delta_gprc = 0;
2868 /* Workaround for RX byte count not including CRC bytes when CRC
2869 * strip is enabled. CRC bytes are removed from counters when crc_strip
2872 int crc_strip = (IXGBE_READ_REG(hw, IXGBE_HLREG0) &
2873 IXGBE_HLREG0_RXCRCSTRP);
2875 hw_stats->crcerrs += IXGBE_READ_REG(hw, IXGBE_CRCERRS);
2876 hw_stats->illerrc += IXGBE_READ_REG(hw, IXGBE_ILLERRC);
2877 hw_stats->errbc += IXGBE_READ_REG(hw, IXGBE_ERRBC);
2878 hw_stats->mspdc += IXGBE_READ_REG(hw, IXGBE_MSPDC);
2880 for (i = 0; i < 8; i++) {
2881 uint32_t mp = IXGBE_READ_REG(hw, IXGBE_MPC(i));
2883 /* global total per queue */
2884 hw_stats->mpc[i] += mp;
2885 /* Running comprehensive total for stats display */
2886 *total_missed_rx += hw_stats->mpc[i];
2887 if (hw->mac.type == ixgbe_mac_82598EB) {
2888 hw_stats->rnbc[i] +=
2889 IXGBE_READ_REG(hw, IXGBE_RNBC(i));
2890 hw_stats->pxonrxc[i] +=
2891 IXGBE_READ_REG(hw, IXGBE_PXONRXC(i));
2892 hw_stats->pxoffrxc[i] +=
2893 IXGBE_READ_REG(hw, IXGBE_PXOFFRXC(i));
2895 hw_stats->pxonrxc[i] +=
2896 IXGBE_READ_REG(hw, IXGBE_PXONRXCNT(i));
2897 hw_stats->pxoffrxc[i] +=
2898 IXGBE_READ_REG(hw, IXGBE_PXOFFRXCNT(i));
2899 hw_stats->pxon2offc[i] +=
2900 IXGBE_READ_REG(hw, IXGBE_PXON2OFFCNT(i));
2902 hw_stats->pxontxc[i] +=
2903 IXGBE_READ_REG(hw, IXGBE_PXONTXC(i));
2904 hw_stats->pxofftxc[i] +=
2905 IXGBE_READ_REG(hw, IXGBE_PXOFFTXC(i));
2907 for (i = 0; i < IXGBE_QUEUE_STAT_COUNTERS; i++) {
2908 uint32_t delta_qprc = IXGBE_READ_REG(hw, IXGBE_QPRC(i));
2909 uint32_t delta_qptc = IXGBE_READ_REG(hw, IXGBE_QPTC(i));
2910 uint32_t delta_qprdc = IXGBE_READ_REG(hw, IXGBE_QPRDC(i));
2912 delta_gprc += delta_qprc;
2914 hw_stats->qprc[i] += delta_qprc;
2915 hw_stats->qptc[i] += delta_qptc;
2917 hw_stats->qbrc[i] += IXGBE_READ_REG(hw, IXGBE_QBRC_L(i));
2918 hw_stats->qbrc[i] +=
2919 ((uint64_t)IXGBE_READ_REG(hw, IXGBE_QBRC_H(i)) << 32);
2921 hw_stats->qbrc[i] -= delta_qprc * ETHER_CRC_LEN;
2923 hw_stats->qbtc[i] += IXGBE_READ_REG(hw, IXGBE_QBTC_L(i));
2924 hw_stats->qbtc[i] +=
2925 ((uint64_t)IXGBE_READ_REG(hw, IXGBE_QBTC_H(i)) << 32);
2927 hw_stats->qprdc[i] += delta_qprdc;
2928 *total_qprdc += hw_stats->qprdc[i];
2930 *total_qprc += hw_stats->qprc[i];
2931 *total_qbrc += hw_stats->qbrc[i];
2933 hw_stats->mlfc += IXGBE_READ_REG(hw, IXGBE_MLFC);
2934 hw_stats->mrfc += IXGBE_READ_REG(hw, IXGBE_MRFC);
2935 hw_stats->rlec += IXGBE_READ_REG(hw, IXGBE_RLEC);
2938 * An errata states that gprc actually counts good + missed packets:
2939 * Workaround to set gprc to summated queue packet receives
2941 hw_stats->gprc = *total_qprc;
2943 if (hw->mac.type != ixgbe_mac_82598EB) {
2944 hw_stats->gorc += IXGBE_READ_REG(hw, IXGBE_GORCL);
2945 hw_stats->gorc += ((u64)IXGBE_READ_REG(hw, IXGBE_GORCH) << 32);
2946 hw_stats->gotc += IXGBE_READ_REG(hw, IXGBE_GOTCL);
2947 hw_stats->gotc += ((u64)IXGBE_READ_REG(hw, IXGBE_GOTCH) << 32);
2948 hw_stats->tor += IXGBE_READ_REG(hw, IXGBE_TORL);
2949 hw_stats->tor += ((u64)IXGBE_READ_REG(hw, IXGBE_TORH) << 32);
2950 hw_stats->lxonrxc += IXGBE_READ_REG(hw, IXGBE_LXONRXCNT);
2951 hw_stats->lxoffrxc += IXGBE_READ_REG(hw, IXGBE_LXOFFRXCNT);
2953 hw_stats->lxonrxc += IXGBE_READ_REG(hw, IXGBE_LXONRXC);
2954 hw_stats->lxoffrxc += IXGBE_READ_REG(hw, IXGBE_LXOFFRXC);
2955 /* 82598 only has a counter in the high register */
2956 hw_stats->gorc += IXGBE_READ_REG(hw, IXGBE_GORCH);
2957 hw_stats->gotc += IXGBE_READ_REG(hw, IXGBE_GOTCH);
2958 hw_stats->tor += IXGBE_READ_REG(hw, IXGBE_TORH);
2960 uint64_t old_tpr = hw_stats->tpr;
2962 hw_stats->tpr += IXGBE_READ_REG(hw, IXGBE_TPR);
2963 hw_stats->tpt += IXGBE_READ_REG(hw, IXGBE_TPT);
2966 hw_stats->gorc -= delta_gprc * ETHER_CRC_LEN;
2968 uint64_t delta_gptc = IXGBE_READ_REG(hw, IXGBE_GPTC);
2969 hw_stats->gptc += delta_gptc;
2970 hw_stats->gotc -= delta_gptc * ETHER_CRC_LEN;
2971 hw_stats->tor -= (hw_stats->tpr - old_tpr) * ETHER_CRC_LEN;
2974 * Workaround: mprc hardware is incorrectly counting
2975 * broadcasts, so for now we subtract those.
2977 bprc = IXGBE_READ_REG(hw, IXGBE_BPRC);
2978 hw_stats->bprc += bprc;
2979 hw_stats->mprc += IXGBE_READ_REG(hw, IXGBE_MPRC);
2980 if (hw->mac.type == ixgbe_mac_82598EB)
2981 hw_stats->mprc -= bprc;
2983 hw_stats->prc64 += IXGBE_READ_REG(hw, IXGBE_PRC64);
2984 hw_stats->prc127 += IXGBE_READ_REG(hw, IXGBE_PRC127);
2985 hw_stats->prc255 += IXGBE_READ_REG(hw, IXGBE_PRC255);
2986 hw_stats->prc511 += IXGBE_READ_REG(hw, IXGBE_PRC511);
2987 hw_stats->prc1023 += IXGBE_READ_REG(hw, IXGBE_PRC1023);
2988 hw_stats->prc1522 += IXGBE_READ_REG(hw, IXGBE_PRC1522);
2990 lxon = IXGBE_READ_REG(hw, IXGBE_LXONTXC);
2991 hw_stats->lxontxc += lxon;
2992 lxoff = IXGBE_READ_REG(hw, IXGBE_LXOFFTXC);
2993 hw_stats->lxofftxc += lxoff;
2994 total = lxon + lxoff;
2996 hw_stats->mptc += IXGBE_READ_REG(hw, IXGBE_MPTC);
2997 hw_stats->ptc64 += IXGBE_READ_REG(hw, IXGBE_PTC64);
2998 hw_stats->gptc -= total;
2999 hw_stats->mptc -= total;
3000 hw_stats->ptc64 -= total;
3001 hw_stats->gotc -= total * ETHER_MIN_LEN;
3003 hw_stats->ruc += IXGBE_READ_REG(hw, IXGBE_RUC);
3004 hw_stats->rfc += IXGBE_READ_REG(hw, IXGBE_RFC);
3005 hw_stats->roc += IXGBE_READ_REG(hw, IXGBE_ROC);
3006 hw_stats->rjc += IXGBE_READ_REG(hw, IXGBE_RJC);
3007 hw_stats->mngprc += IXGBE_READ_REG(hw, IXGBE_MNGPRC);
3008 hw_stats->mngpdc += IXGBE_READ_REG(hw, IXGBE_MNGPDC);
3009 hw_stats->mngptc += IXGBE_READ_REG(hw, IXGBE_MNGPTC);
3010 hw_stats->ptc127 += IXGBE_READ_REG(hw, IXGBE_PTC127);
3011 hw_stats->ptc255 += IXGBE_READ_REG(hw, IXGBE_PTC255);
3012 hw_stats->ptc511 += IXGBE_READ_REG(hw, IXGBE_PTC511);
3013 hw_stats->ptc1023 += IXGBE_READ_REG(hw, IXGBE_PTC1023);
3014 hw_stats->ptc1522 += IXGBE_READ_REG(hw, IXGBE_PTC1522);
3015 hw_stats->bptc += IXGBE_READ_REG(hw, IXGBE_BPTC);
3016 hw_stats->xec += IXGBE_READ_REG(hw, IXGBE_XEC);
3017 hw_stats->fccrc += IXGBE_READ_REG(hw, IXGBE_FCCRC);
3018 hw_stats->fclast += IXGBE_READ_REG(hw, IXGBE_FCLAST);
3019 /* Only read FCOE on 82599 */
3020 if (hw->mac.type != ixgbe_mac_82598EB) {
3021 hw_stats->fcoerpdc += IXGBE_READ_REG(hw, IXGBE_FCOERPDC);
3022 hw_stats->fcoeprc += IXGBE_READ_REG(hw, IXGBE_FCOEPRC);
3023 hw_stats->fcoeptc += IXGBE_READ_REG(hw, IXGBE_FCOEPTC);
3024 hw_stats->fcoedwrc += IXGBE_READ_REG(hw, IXGBE_FCOEDWRC);
3025 hw_stats->fcoedwtc += IXGBE_READ_REG(hw, IXGBE_FCOEDWTC);
3028 /* Flow Director Stats registers */
3029 hw_stats->fdirmatch += IXGBE_READ_REG(hw, IXGBE_FDIRMATCH);
3030 hw_stats->fdirmiss += IXGBE_READ_REG(hw, IXGBE_FDIRMISS);
3032 /* MACsec Stats registers */
3033 macsec_stats->out_pkts_untagged += IXGBE_READ_REG(hw, IXGBE_LSECTXUT);
3034 macsec_stats->out_pkts_encrypted +=
3035 IXGBE_READ_REG(hw, IXGBE_LSECTXPKTE);
3036 macsec_stats->out_pkts_protected +=
3037 IXGBE_READ_REG(hw, IXGBE_LSECTXPKTP);
3038 macsec_stats->out_octets_encrypted +=
3039 IXGBE_READ_REG(hw, IXGBE_LSECTXOCTE);
3040 macsec_stats->out_octets_protected +=
3041 IXGBE_READ_REG(hw, IXGBE_LSECTXOCTP);
3042 macsec_stats->in_pkts_untagged += IXGBE_READ_REG(hw, IXGBE_LSECRXUT);
3043 macsec_stats->in_pkts_badtag += IXGBE_READ_REG(hw, IXGBE_LSECRXBAD);
3044 macsec_stats->in_pkts_nosci += IXGBE_READ_REG(hw, IXGBE_LSECRXNOSCI);
3045 macsec_stats->in_pkts_unknownsci +=
3046 IXGBE_READ_REG(hw, IXGBE_LSECRXUNSCI);
3047 macsec_stats->in_octets_decrypted +=
3048 IXGBE_READ_REG(hw, IXGBE_LSECRXOCTD);
3049 macsec_stats->in_octets_validated +=
3050 IXGBE_READ_REG(hw, IXGBE_LSECRXOCTV);
3051 macsec_stats->in_pkts_unchecked += IXGBE_READ_REG(hw, IXGBE_LSECRXUNCH);
3052 macsec_stats->in_pkts_delayed += IXGBE_READ_REG(hw, IXGBE_LSECRXDELAY);
3053 macsec_stats->in_pkts_late += IXGBE_READ_REG(hw, IXGBE_LSECRXLATE);
3054 for (i = 0; i < 2; i++) {
3055 macsec_stats->in_pkts_ok +=
3056 IXGBE_READ_REG(hw, IXGBE_LSECRXOK(i));
3057 macsec_stats->in_pkts_invalid +=
3058 IXGBE_READ_REG(hw, IXGBE_LSECRXINV(i));
3059 macsec_stats->in_pkts_notvalid +=
3060 IXGBE_READ_REG(hw, IXGBE_LSECRXNV(i));
3062 macsec_stats->in_pkts_unusedsa += IXGBE_READ_REG(hw, IXGBE_LSECRXUNSA);
3063 macsec_stats->in_pkts_notusingsa +=
3064 IXGBE_READ_REG(hw, IXGBE_LSECRXNUSA);
3068 * This function is based on ixgbe_update_stats_counters() in ixgbe/ixgbe.c
3071 ixgbe_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
3073 struct ixgbe_hw *hw =
3074 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3075 struct ixgbe_hw_stats *hw_stats =
3076 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3077 struct ixgbe_macsec_stats *macsec_stats =
3078 IXGBE_DEV_PRIVATE_TO_MACSEC_STATS(
3079 dev->data->dev_private);
3080 uint64_t total_missed_rx, total_qbrc, total_qprc, total_qprdc;
3083 total_missed_rx = 0;
3088 ixgbe_read_stats_registers(hw, hw_stats, macsec_stats, &total_missed_rx,
3089 &total_qbrc, &total_qprc, &total_qprdc);
3094 /* Fill out the rte_eth_stats statistics structure */
3095 stats->ipackets = total_qprc;
3096 stats->ibytes = total_qbrc;
3097 stats->opackets = hw_stats->gptc;
3098 stats->obytes = hw_stats->gotc;
3100 for (i = 0; i < IXGBE_QUEUE_STAT_COUNTERS; i++) {
3101 stats->q_ipackets[i] = hw_stats->qprc[i];
3102 stats->q_opackets[i] = hw_stats->qptc[i];
3103 stats->q_ibytes[i] = hw_stats->qbrc[i];
3104 stats->q_obytes[i] = hw_stats->qbtc[i];
3105 stats->q_errors[i] = hw_stats->qprdc[i];
3109 stats->imissed = total_missed_rx;
3110 stats->ierrors = hw_stats->crcerrs +
3126 ixgbe_dev_stats_reset(struct rte_eth_dev *dev)
3128 struct ixgbe_hw_stats *stats =
3129 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3131 /* HW registers are cleared on read */
3132 ixgbe_dev_stats_get(dev, NULL);
3134 /* Reset software totals */
3135 memset(stats, 0, sizeof(*stats));
3138 /* This function calculates the number of xstats based on the current config */
3140 ixgbe_xstats_calc_num(void) {
3141 return IXGBE_NB_HW_STATS + IXGBE_NB_MACSEC_STATS +
3142 (IXGBE_NB_RXQ_PRIO_STATS * IXGBE_NB_RXQ_PRIO_VALUES) +
3143 (IXGBE_NB_TXQ_PRIO_STATS * IXGBE_NB_TXQ_PRIO_VALUES);
3146 static int ixgbe_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
3147 struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned int size)
3149 const unsigned cnt_stats = ixgbe_xstats_calc_num();
3150 unsigned stat, i, count;
3152 if (xstats_names != NULL) {
3155 /* Note: limit >= cnt_stats checked upstream
3156 * in rte_eth_xstats_names()
3159 /* Extended stats from ixgbe_hw_stats */
3160 for (i = 0; i < IXGBE_NB_HW_STATS; i++) {
3161 snprintf(xstats_names[count].name,
3162 sizeof(xstats_names[count].name),
3164 rte_ixgbe_stats_strings[i].name);
3169 for (i = 0; i < IXGBE_NB_MACSEC_STATS; i++) {
3170 snprintf(xstats_names[count].name,
3171 sizeof(xstats_names[count].name),
3173 rte_ixgbe_macsec_strings[i].name);
3177 /* RX Priority Stats */
3178 for (stat = 0; stat < IXGBE_NB_RXQ_PRIO_STATS; stat++) {
3179 for (i = 0; i < IXGBE_NB_RXQ_PRIO_VALUES; i++) {
3180 snprintf(xstats_names[count].name,
3181 sizeof(xstats_names[count].name),
3182 "rx_priority%u_%s", i,
3183 rte_ixgbe_rxq_strings[stat].name);
3188 /* TX Priority Stats */
3189 for (stat = 0; stat < IXGBE_NB_TXQ_PRIO_STATS; stat++) {
3190 for (i = 0; i < IXGBE_NB_TXQ_PRIO_VALUES; i++) {
3191 snprintf(xstats_names[count].name,
3192 sizeof(xstats_names[count].name),
3193 "tx_priority%u_%s", i,
3194 rte_ixgbe_txq_strings[stat].name);
3202 static int ixgbe_dev_xstats_get_names_by_id(
3203 struct rte_eth_dev *dev,
3204 struct rte_eth_xstat_name *xstats_names,
3205 const uint64_t *ids,
3209 const unsigned int cnt_stats = ixgbe_xstats_calc_num();
3210 unsigned int stat, i, count;
3212 if (xstats_names != NULL) {
3215 /* Note: limit >= cnt_stats checked upstream
3216 * in rte_eth_xstats_names()
3219 /* Extended stats from ixgbe_hw_stats */
3220 for (i = 0; i < IXGBE_NB_HW_STATS; i++) {
3221 snprintf(xstats_names[count].name,
3222 sizeof(xstats_names[count].name),
3224 rte_ixgbe_stats_strings[i].name);
3229 for (i = 0; i < IXGBE_NB_MACSEC_STATS; i++) {
3230 snprintf(xstats_names[count].name,
3231 sizeof(xstats_names[count].name),
3233 rte_ixgbe_macsec_strings[i].name);
3237 /* RX Priority Stats */
3238 for (stat = 0; stat < IXGBE_NB_RXQ_PRIO_STATS; stat++) {
3239 for (i = 0; i < IXGBE_NB_RXQ_PRIO_VALUES; i++) {
3240 snprintf(xstats_names[count].name,
3241 sizeof(xstats_names[count].name),
3242 "rx_priority%u_%s", i,
3243 rte_ixgbe_rxq_strings[stat].name);
3248 /* TX Priority Stats */
3249 for (stat = 0; stat < IXGBE_NB_TXQ_PRIO_STATS; stat++) {
3250 for (i = 0; i < IXGBE_NB_TXQ_PRIO_VALUES; i++) {
3251 snprintf(xstats_names[count].name,
3252 sizeof(xstats_names[count].name),
3253 "tx_priority%u_%s", i,
3254 rte_ixgbe_txq_strings[stat].name);
3263 uint16_t size = ixgbe_xstats_calc_num();
3264 struct rte_eth_xstat_name xstats_names_copy[size];
3266 ixgbe_dev_xstats_get_names_by_id(dev, xstats_names_copy, NULL,
3269 for (i = 0; i < limit; i++) {
3270 if (ids[i] >= size) {
3271 PMD_INIT_LOG(ERR, "id value isn't valid");
3274 strcpy(xstats_names[i].name,
3275 xstats_names_copy[ids[i]].name);
3280 static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
3281 struct rte_eth_xstat_name *xstats_names, unsigned limit)
3285 if (limit < IXGBEVF_NB_XSTATS && xstats_names != NULL)
3288 if (xstats_names != NULL)
3289 for (i = 0; i < IXGBEVF_NB_XSTATS; i++)
3290 snprintf(xstats_names[i].name,
3291 sizeof(xstats_names[i].name),
3292 "%s", rte_ixgbevf_stats_strings[i].name);
3293 return IXGBEVF_NB_XSTATS;
3297 ixgbe_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
3300 struct ixgbe_hw *hw =
3301 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3302 struct ixgbe_hw_stats *hw_stats =
3303 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3304 struct ixgbe_macsec_stats *macsec_stats =
3305 IXGBE_DEV_PRIVATE_TO_MACSEC_STATS(
3306 dev->data->dev_private);
3307 uint64_t total_missed_rx, total_qbrc, total_qprc, total_qprdc;
3308 unsigned i, stat, count = 0;
3310 count = ixgbe_xstats_calc_num();
3315 total_missed_rx = 0;
3320 ixgbe_read_stats_registers(hw, hw_stats, macsec_stats, &total_missed_rx,
3321 &total_qbrc, &total_qprc, &total_qprdc);
3323 /* If this is a reset xstats is NULL, and we have cleared the
3324 * registers by reading them.
3329 /* Extended stats from ixgbe_hw_stats */
3331 for (i = 0; i < IXGBE_NB_HW_STATS; i++) {
3332 xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
3333 rte_ixgbe_stats_strings[i].offset);
3334 xstats[count].id = count;
3339 for (i = 0; i < IXGBE_NB_MACSEC_STATS; i++) {
3340 xstats[count].value = *(uint64_t *)(((char *)macsec_stats) +
3341 rte_ixgbe_macsec_strings[i].offset);
3342 xstats[count].id = count;
3346 /* RX Priority Stats */
3347 for (stat = 0; stat < IXGBE_NB_RXQ_PRIO_STATS; stat++) {
3348 for (i = 0; i < IXGBE_NB_RXQ_PRIO_VALUES; i++) {
3349 xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
3350 rte_ixgbe_rxq_strings[stat].offset +
3351 (sizeof(uint64_t) * i));
3352 xstats[count].id = count;
3357 /* TX Priority Stats */
3358 for (stat = 0; stat < IXGBE_NB_TXQ_PRIO_STATS; stat++) {
3359 for (i = 0; i < IXGBE_NB_TXQ_PRIO_VALUES; i++) {
3360 xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
3361 rte_ixgbe_txq_strings[stat].offset +
3362 (sizeof(uint64_t) * i));
3363 xstats[count].id = count;
3371 ixgbe_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids,
3372 uint64_t *values, unsigned int n)
3375 struct ixgbe_hw *hw =
3376 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3377 struct ixgbe_hw_stats *hw_stats =
3378 IXGBE_DEV_PRIVATE_TO_STATS(
3379 dev->data->dev_private);
3380 struct ixgbe_macsec_stats *macsec_stats =
3381 IXGBE_DEV_PRIVATE_TO_MACSEC_STATS(
3382 dev->data->dev_private);
3383 uint64_t total_missed_rx, total_qbrc, total_qprc, total_qprdc;
3384 unsigned int i, stat, count = 0;
3386 count = ixgbe_xstats_calc_num();
3388 if (!ids && n < count)
3391 total_missed_rx = 0;
3396 ixgbe_read_stats_registers(hw, hw_stats, macsec_stats,
3397 &total_missed_rx, &total_qbrc, &total_qprc,
3400 /* If this is a reset xstats is NULL, and we have cleared the
3401 * registers by reading them.
3403 if (!ids && !values)
3406 /* Extended stats from ixgbe_hw_stats */
3408 for (i = 0; i < IXGBE_NB_HW_STATS; i++) {
3409 values[count] = *(uint64_t *)(((char *)hw_stats) +
3410 rte_ixgbe_stats_strings[i].offset);
3415 for (i = 0; i < IXGBE_NB_MACSEC_STATS; i++) {
3416 values[count] = *(uint64_t *)(((char *)macsec_stats) +
3417 rte_ixgbe_macsec_strings[i].offset);
3421 /* RX Priority Stats */
3422 for (stat = 0; stat < IXGBE_NB_RXQ_PRIO_STATS; stat++) {
3423 for (i = 0; i < IXGBE_NB_RXQ_PRIO_VALUES; i++) {
3425 *(uint64_t *)(((char *)hw_stats) +
3426 rte_ixgbe_rxq_strings[stat].offset +
3427 (sizeof(uint64_t) * i));
3432 /* TX Priority Stats */
3433 for (stat = 0; stat < IXGBE_NB_TXQ_PRIO_STATS; stat++) {
3434 for (i = 0; i < IXGBE_NB_TXQ_PRIO_VALUES; i++) {
3436 *(uint64_t *)(((char *)hw_stats) +
3437 rte_ixgbe_txq_strings[stat].offset +
3438 (sizeof(uint64_t) * i));
3446 uint16_t size = ixgbe_xstats_calc_num();
3447 uint64_t values_copy[size];
3449 ixgbe_dev_xstats_get_by_id(dev, NULL, values_copy, size);
3451 for (i = 0; i < n; i++) {
3452 if (ids[i] >= size) {
3453 PMD_INIT_LOG(ERR, "id value isn't valid");
3456 values[i] = values_copy[ids[i]];
3462 ixgbe_dev_xstats_reset(struct rte_eth_dev *dev)
3464 struct ixgbe_hw_stats *stats =
3465 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3466 struct ixgbe_macsec_stats *macsec_stats =
3467 IXGBE_DEV_PRIVATE_TO_MACSEC_STATS(
3468 dev->data->dev_private);
3470 unsigned count = ixgbe_xstats_calc_num();
3472 /* HW registers are cleared on read */
3473 ixgbe_dev_xstats_get(dev, NULL, count);
3475 /* Reset software totals */
3476 memset(stats, 0, sizeof(*stats));
3477 memset(macsec_stats, 0, sizeof(*macsec_stats));
3481 ixgbevf_update_stats(struct rte_eth_dev *dev)
3483 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3484 struct ixgbevf_hw_stats *hw_stats = (struct ixgbevf_hw_stats *)
3485 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3487 /* Good Rx packet, include VF loopback */
3488 UPDATE_VF_STAT(IXGBE_VFGPRC,
3489 hw_stats->last_vfgprc, hw_stats->vfgprc);
3491 /* Good Rx octets, include VF loopback */
3492 UPDATE_VF_STAT_36BIT(IXGBE_VFGORC_LSB, IXGBE_VFGORC_MSB,
3493 hw_stats->last_vfgorc, hw_stats->vfgorc);
3495 /* Good Tx packet, include VF loopback */
3496 UPDATE_VF_STAT(IXGBE_VFGPTC,
3497 hw_stats->last_vfgptc, hw_stats->vfgptc);
3499 /* Good Tx octets, include VF loopback */
3500 UPDATE_VF_STAT_36BIT(IXGBE_VFGOTC_LSB, IXGBE_VFGOTC_MSB,
3501 hw_stats->last_vfgotc, hw_stats->vfgotc);
3503 /* Rx Multicst Packet */
3504 UPDATE_VF_STAT(IXGBE_VFMPRC,
3505 hw_stats->last_vfmprc, hw_stats->vfmprc);
3509 ixgbevf_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
3512 struct ixgbevf_hw_stats *hw_stats = (struct ixgbevf_hw_stats *)
3513 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3516 if (n < IXGBEVF_NB_XSTATS)
3517 return IXGBEVF_NB_XSTATS;
3519 ixgbevf_update_stats(dev);
3524 /* Extended stats */
3525 for (i = 0; i < IXGBEVF_NB_XSTATS; i++) {
3527 xstats[i].value = *(uint64_t *)(((char *)hw_stats) +
3528 rte_ixgbevf_stats_strings[i].offset);
3531 return IXGBEVF_NB_XSTATS;
3535 ixgbevf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
3537 struct ixgbevf_hw_stats *hw_stats = (struct ixgbevf_hw_stats *)
3538 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3540 ixgbevf_update_stats(dev);
3545 stats->ipackets = hw_stats->vfgprc;
3546 stats->ibytes = hw_stats->vfgorc;
3547 stats->opackets = hw_stats->vfgptc;
3548 stats->obytes = hw_stats->vfgotc;
3552 ixgbevf_dev_stats_reset(struct rte_eth_dev *dev)
3554 struct ixgbevf_hw_stats *hw_stats = (struct ixgbevf_hw_stats *)
3555 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3557 /* Sync HW register to the last stats */
3558 ixgbevf_dev_stats_get(dev, NULL);
3560 /* reset HW current stats*/
3561 hw_stats->vfgprc = 0;
3562 hw_stats->vfgorc = 0;
3563 hw_stats->vfgptc = 0;
3564 hw_stats->vfgotc = 0;
3568 ixgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size)
3570 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3571 u16 eeprom_verh, eeprom_verl;
3575 ixgbe_read_eeprom(hw, 0x2e, &eeprom_verh);
3576 ixgbe_read_eeprom(hw, 0x2d, &eeprom_verl);
3578 etrack_id = (eeprom_verh << 16) | eeprom_verl;
3579 ret = snprintf(fw_version, fw_size, "0x%08x", etrack_id);
3581 ret += 1; /* add the size of '\0' */
3582 if (fw_size < (u32)ret)
3589 ixgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
3591 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
3592 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3593 struct rte_eth_conf *dev_conf = &dev->data->dev_conf;
3595 dev_info->pci_dev = pci_dev;
3596 dev_info->max_rx_queues = (uint16_t)hw->mac.max_rx_queues;
3597 dev_info->max_tx_queues = (uint16_t)hw->mac.max_tx_queues;
3598 if (RTE_ETH_DEV_SRIOV(dev).active == 0) {
3600 * When DCB/VT is off, maximum number of queues changes,
3601 * except for 82598EB, which remains constant.
3603 if (dev_conf->txmode.mq_mode == ETH_MQ_TX_NONE &&
3604 hw->mac.type != ixgbe_mac_82598EB)
3605 dev_info->max_tx_queues = IXGBE_NONE_MODE_TX_NB_QUEUES;
3607 dev_info->min_rx_bufsize = 1024; /* cf BSIZEPACKET in SRRCTL register */
3608 dev_info->max_rx_pktlen = 15872; /* includes CRC, cf MAXFRS register */
3609 dev_info->max_mac_addrs = hw->mac.num_rar_entries;
3610 dev_info->max_hash_mac_addrs = IXGBE_VMDQ_NUM_UC_MAC;
3611 dev_info->max_vfs = pci_dev->max_vfs;
3612 if (hw->mac.type == ixgbe_mac_82598EB)
3613 dev_info->max_vmdq_pools = ETH_16_POOLS;
3615 dev_info->max_vmdq_pools = ETH_64_POOLS;
3616 dev_info->vmdq_queue_num = dev_info->max_rx_queues;
3617 dev_info->rx_offload_capa =
3618 DEV_RX_OFFLOAD_VLAN_STRIP |
3619 DEV_RX_OFFLOAD_IPV4_CKSUM |
3620 DEV_RX_OFFLOAD_UDP_CKSUM |
3621 DEV_RX_OFFLOAD_TCP_CKSUM;
3624 * RSC is only supported by 82599 and x540 PF devices in a non-SR-IOV
3627 if ((hw->mac.type == ixgbe_mac_82599EB ||
3628 hw->mac.type == ixgbe_mac_X540) &&
3629 !RTE_ETH_DEV_SRIOV(dev).active)
3630 dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_TCP_LRO;
3632 if (hw->mac.type == ixgbe_mac_82599EB ||
3633 hw->mac.type == ixgbe_mac_X540)
3634 dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_MACSEC_STRIP;
3636 if (hw->mac.type == ixgbe_mac_X550 ||
3637 hw->mac.type == ixgbe_mac_X550EM_x ||
3638 hw->mac.type == ixgbe_mac_X550EM_a)
3639 dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM;
3641 dev_info->tx_offload_capa =
3642 DEV_TX_OFFLOAD_VLAN_INSERT |
3643 DEV_TX_OFFLOAD_IPV4_CKSUM |
3644 DEV_TX_OFFLOAD_UDP_CKSUM |
3645 DEV_TX_OFFLOAD_TCP_CKSUM |
3646 DEV_TX_OFFLOAD_SCTP_CKSUM |
3647 DEV_TX_OFFLOAD_TCP_TSO;
3649 if (hw->mac.type == ixgbe_mac_82599EB ||
3650 hw->mac.type == ixgbe_mac_X540)
3651 dev_info->tx_offload_capa |= DEV_TX_OFFLOAD_MACSEC_INSERT;
3653 if (hw->mac.type == ixgbe_mac_X550 ||
3654 hw->mac.type == ixgbe_mac_X550EM_x ||
3655 hw->mac.type == ixgbe_mac_X550EM_a)
3656 dev_info->tx_offload_capa |= DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
3658 dev_info->default_rxconf = (struct rte_eth_rxconf) {
3660 .pthresh = IXGBE_DEFAULT_RX_PTHRESH,
3661 .hthresh = IXGBE_DEFAULT_RX_HTHRESH,
3662 .wthresh = IXGBE_DEFAULT_RX_WTHRESH,
3664 .rx_free_thresh = IXGBE_DEFAULT_RX_FREE_THRESH,
3668 dev_info->default_txconf = (struct rte_eth_txconf) {
3670 .pthresh = IXGBE_DEFAULT_TX_PTHRESH,
3671 .hthresh = IXGBE_DEFAULT_TX_HTHRESH,
3672 .wthresh = IXGBE_DEFAULT_TX_WTHRESH,
3674 .tx_free_thresh = IXGBE_DEFAULT_TX_FREE_THRESH,
3675 .tx_rs_thresh = IXGBE_DEFAULT_TX_RSBIT_THRESH,
3676 .txq_flags = ETH_TXQ_FLAGS_NOMULTSEGS |
3677 ETH_TXQ_FLAGS_NOOFFLOADS,
3680 dev_info->rx_desc_lim = rx_desc_lim;
3681 dev_info->tx_desc_lim = tx_desc_lim;
3683 dev_info->hash_key_size = IXGBE_HKEY_MAX_INDEX * sizeof(uint32_t);
3684 dev_info->reta_size = ixgbe_reta_size_get(hw->mac.type);
3685 dev_info->flow_type_rss_offloads = IXGBE_RSS_OFFLOAD_ALL;
3687 dev_info->speed_capa = ETH_LINK_SPEED_1G | ETH_LINK_SPEED_10G;
3688 if (hw->mac.type == ixgbe_mac_X540 ||
3689 hw->mac.type == ixgbe_mac_X540_vf ||
3690 hw->mac.type == ixgbe_mac_X550 ||
3691 hw->mac.type == ixgbe_mac_X550_vf) {
3692 dev_info->speed_capa |= ETH_LINK_SPEED_100M;
3696 static const uint32_t *
3697 ixgbe_dev_supported_ptypes_get(struct rte_eth_dev *dev)
3699 static const uint32_t ptypes[] = {
3700 /* For non-vec functions,
3701 * refers to ixgbe_rxd_pkt_info_to_pkt_type();
3702 * for vec functions,
3703 * refers to _recv_raw_pkts_vec().
3707 RTE_PTYPE_L3_IPV4_EXT,
3709 RTE_PTYPE_L3_IPV6_EXT,
3713 RTE_PTYPE_TUNNEL_IP,
3714 RTE_PTYPE_INNER_L3_IPV6,
3715 RTE_PTYPE_INNER_L3_IPV6_EXT,
3716 RTE_PTYPE_INNER_L4_TCP,
3717 RTE_PTYPE_INNER_L4_UDP,
3721 if (dev->rx_pkt_burst == ixgbe_recv_pkts ||
3722 dev->rx_pkt_burst == ixgbe_recv_pkts_lro_single_alloc ||
3723 dev->rx_pkt_burst == ixgbe_recv_pkts_lro_bulk_alloc ||
3724 dev->rx_pkt_burst == ixgbe_recv_pkts_bulk_alloc)
3727 #if defined(RTE_ARCH_X86)
3728 if (dev->rx_pkt_burst == ixgbe_recv_pkts_vec ||
3729 dev->rx_pkt_burst == ixgbe_recv_scattered_pkts_vec)
3736 ixgbevf_dev_info_get(struct rte_eth_dev *dev,
3737 struct rte_eth_dev_info *dev_info)
3739 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
3740 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3742 dev_info->pci_dev = pci_dev;
3743 dev_info->max_rx_queues = (uint16_t)hw->mac.max_rx_queues;
3744 dev_info->max_tx_queues = (uint16_t)hw->mac.max_tx_queues;
3745 dev_info->min_rx_bufsize = 1024; /* cf BSIZEPACKET in SRRCTL reg */
3746 dev_info->max_rx_pktlen = 9728; /* includes CRC, cf MAXFRS reg */
3747 dev_info->max_mac_addrs = hw->mac.num_rar_entries;
3748 dev_info->max_hash_mac_addrs = IXGBE_VMDQ_NUM_UC_MAC;
3749 dev_info->max_vfs = pci_dev->max_vfs;
3750 if (hw->mac.type == ixgbe_mac_82598EB)
3751 dev_info->max_vmdq_pools = ETH_16_POOLS;
3753 dev_info->max_vmdq_pools = ETH_64_POOLS;
3754 dev_info->rx_offload_capa = DEV_RX_OFFLOAD_VLAN_STRIP |
3755 DEV_RX_OFFLOAD_IPV4_CKSUM |
3756 DEV_RX_OFFLOAD_UDP_CKSUM |
3757 DEV_RX_OFFLOAD_TCP_CKSUM;
3758 dev_info->tx_offload_capa = DEV_TX_OFFLOAD_VLAN_INSERT |
3759 DEV_TX_OFFLOAD_IPV4_CKSUM |
3760 DEV_TX_OFFLOAD_UDP_CKSUM |
3761 DEV_TX_OFFLOAD_TCP_CKSUM |
3762 DEV_TX_OFFLOAD_SCTP_CKSUM |
3763 DEV_TX_OFFLOAD_TCP_TSO;
3765 dev_info->default_rxconf = (struct rte_eth_rxconf) {
3767 .pthresh = IXGBE_DEFAULT_RX_PTHRESH,
3768 .hthresh = IXGBE_DEFAULT_RX_HTHRESH,
3769 .wthresh = IXGBE_DEFAULT_RX_WTHRESH,
3771 .rx_free_thresh = IXGBE_DEFAULT_RX_FREE_THRESH,
3775 dev_info->default_txconf = (struct rte_eth_txconf) {
3777 .pthresh = IXGBE_DEFAULT_TX_PTHRESH,
3778 .hthresh = IXGBE_DEFAULT_TX_HTHRESH,
3779 .wthresh = IXGBE_DEFAULT_TX_WTHRESH,
3781 .tx_free_thresh = IXGBE_DEFAULT_TX_FREE_THRESH,
3782 .tx_rs_thresh = IXGBE_DEFAULT_TX_RSBIT_THRESH,
3783 .txq_flags = ETH_TXQ_FLAGS_NOMULTSEGS |
3784 ETH_TXQ_FLAGS_NOOFFLOADS,
3787 dev_info->rx_desc_lim = rx_desc_lim;
3788 dev_info->tx_desc_lim = tx_desc_lim;
3792 ixgbevf_check_link(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
3793 int *link_up, int wait_to_complete)
3796 * for a quick link status checking, wait_to_compelet == 0,
3797 * skip PF link status checking
3799 bool no_pflink_check = wait_to_complete == 0;
3800 struct ixgbe_mbx_info *mbx = &hw->mbx;
3801 struct ixgbe_mac_info *mac = &hw->mac;
3802 uint32_t links_reg, in_msg;
3805 /* If we were hit with a reset drop the link */
3806 if (!mbx->ops.check_for_rst(hw, 0) || !mbx->timeout)
3807 mac->get_link_status = true;
3809 if (!mac->get_link_status)
3812 /* if link status is down no point in checking to see if pf is up */
3813 links_reg = IXGBE_READ_REG(hw, IXGBE_VFLINKS);
3814 if (!(links_reg & IXGBE_LINKS_UP))
3817 /* for SFP+ modules and DA cables on 82599 it can take up to 500usecs
3818 * before the link status is correct
3820 if (mac->type == ixgbe_mac_82599_vf) {
3823 for (i = 0; i < 5; i++) {
3825 links_reg = IXGBE_READ_REG(hw, IXGBE_VFLINKS);
3827 if (!(links_reg & IXGBE_LINKS_UP))
3832 switch (links_reg & IXGBE_LINKS_SPEED_82599) {
3833 case IXGBE_LINKS_SPEED_10G_82599:
3834 *speed = IXGBE_LINK_SPEED_10GB_FULL;
3835 if (hw->mac.type >= ixgbe_mac_X550) {
3836 if (links_reg & IXGBE_LINKS_SPEED_NON_STD)
3837 *speed = IXGBE_LINK_SPEED_2_5GB_FULL;
3840 case IXGBE_LINKS_SPEED_1G_82599:
3841 *speed = IXGBE_LINK_SPEED_1GB_FULL;
3843 case IXGBE_LINKS_SPEED_100_82599:
3844 *speed = IXGBE_LINK_SPEED_100_FULL;
3845 if (hw->mac.type == ixgbe_mac_X550) {
3846 if (links_reg & IXGBE_LINKS_SPEED_NON_STD)
3847 *speed = IXGBE_LINK_SPEED_5GB_FULL;
3850 case IXGBE_LINKS_SPEED_10_X550EM_A:
3851 *speed = IXGBE_LINK_SPEED_UNKNOWN;
3852 /* Since Reserved in older MAC's */
3853 if (hw->mac.type >= ixgbe_mac_X550)
3854 *speed = IXGBE_LINK_SPEED_10_FULL;
3857 *speed = IXGBE_LINK_SPEED_UNKNOWN;
3860 if (no_pflink_check) {
3861 if (*speed == IXGBE_LINK_SPEED_UNKNOWN)
3862 mac->get_link_status = true;
3864 mac->get_link_status = false;
3868 /* if the read failed it could just be a mailbox collision, best wait
3869 * until we are called again and don't report an error
3871 if (mbx->ops.read(hw, &in_msg, 1, 0))
3874 if (!(in_msg & IXGBE_VT_MSGTYPE_CTS)) {
3875 /* msg is not CTS and is NACK we must have lost CTS status */
3876 if (in_msg & IXGBE_VT_MSGTYPE_NACK)
3881 /* the pf is talking, if we timed out in the past we reinit */
3882 if (!mbx->timeout) {
3887 /* if we passed all the tests above then the link is up and we no
3888 * longer need to check for link
3890 mac->get_link_status = false;
3893 *link_up = !mac->get_link_status;
3897 /* return 0 means link status changed, -1 means not changed */
3899 ixgbe_dev_link_update_share(struct rte_eth_dev *dev,
3900 int wait_to_complete, int vf)
3902 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3903 struct rte_eth_link link, old;
3904 ixgbe_link_speed link_speed = IXGBE_LINK_SPEED_UNKNOWN;
3905 struct ixgbe_interrupt *intr =
3906 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
3911 bool autoneg = false;
3913 link.link_status = ETH_LINK_DOWN;
3914 link.link_speed = 0;
3915 link.link_duplex = ETH_LINK_HALF_DUPLEX;
3916 memset(&old, 0, sizeof(old));
3917 rte_ixgbe_dev_atomic_read_link_status(dev, &old);
3919 hw->mac.get_link_status = true;
3921 if ((intr->flags & IXGBE_FLAG_NEED_LINK_CONFIG) &&
3922 ixgbe_get_media_type(hw) == ixgbe_media_type_fiber) {
3923 speed = hw->phy.autoneg_advertised;
3925 ixgbe_get_link_capabilities(hw, &speed, &autoneg);
3926 ixgbe_setup_link(hw, speed, true);
3929 /* check if it needs to wait to complete, if lsc interrupt is enabled */
3930 if (wait_to_complete == 0 || dev->data->dev_conf.intr_conf.lsc != 0)
3934 diag = ixgbevf_check_link(hw, &link_speed, &link_up, wait);
3936 diag = ixgbe_check_link(hw, &link_speed, &link_up, wait);
3939 link.link_speed = ETH_SPEED_NUM_100M;
3940 link.link_duplex = ETH_LINK_FULL_DUPLEX;
3941 rte_ixgbe_dev_atomic_write_link_status(dev, &link);
3942 if (link.link_status == old.link_status)
3948 rte_ixgbe_dev_atomic_write_link_status(dev, &link);
3949 intr->flags |= IXGBE_FLAG_NEED_LINK_CONFIG;
3950 if (link.link_status == old.link_status)
3954 intr->flags &= ~IXGBE_FLAG_NEED_LINK_CONFIG;
3955 link.link_status = ETH_LINK_UP;
3956 link.link_duplex = ETH_LINK_FULL_DUPLEX;
3958 switch (link_speed) {
3960 case IXGBE_LINK_SPEED_UNKNOWN:
3961 link.link_duplex = ETH_LINK_FULL_DUPLEX;
3962 link.link_speed = ETH_SPEED_NUM_100M;
3965 case IXGBE_LINK_SPEED_100_FULL:
3966 link.link_speed = ETH_SPEED_NUM_100M;
3969 case IXGBE_LINK_SPEED_1GB_FULL:
3970 link.link_speed = ETH_SPEED_NUM_1G;
3973 case IXGBE_LINK_SPEED_10GB_FULL:
3974 link.link_speed = ETH_SPEED_NUM_10G;
3977 rte_ixgbe_dev_atomic_write_link_status(dev, &link);
3979 if (link.link_status == old.link_status)
3986 ixgbe_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
3988 return ixgbe_dev_link_update_share(dev, wait_to_complete, 0);
3992 ixgbevf_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
3994 return ixgbe_dev_link_update_share(dev, wait_to_complete, 1);
3998 ixgbe_dev_promiscuous_enable(struct rte_eth_dev *dev)
4000 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4003 fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
4004 fctrl |= (IXGBE_FCTRL_UPE | IXGBE_FCTRL_MPE);
4005 IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
4009 ixgbe_dev_promiscuous_disable(struct rte_eth_dev *dev)
4011 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4014 fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
4015 fctrl &= (~IXGBE_FCTRL_UPE);
4016 if (dev->data->all_multicast == 1)
4017 fctrl |= IXGBE_FCTRL_MPE;
4019 fctrl &= (~IXGBE_FCTRL_MPE);
4020 IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
4024 ixgbe_dev_allmulticast_enable(struct rte_eth_dev *dev)
4026 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4029 fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
4030 fctrl |= IXGBE_FCTRL_MPE;
4031 IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
4035 ixgbe_dev_allmulticast_disable(struct rte_eth_dev *dev)
4037 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4040 if (dev->data->promiscuous == 1)
4041 return; /* must remain in all_multicast mode */
4043 fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
4044 fctrl &= (~IXGBE_FCTRL_MPE);
4045 IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
4049 * It clears the interrupt causes and enables the interrupt.
4050 * It will be called once only during nic initialized.
4053 * Pointer to struct rte_eth_dev.
4056 * - On success, zero.
4057 * - On failure, a negative value.
4060 ixgbe_dev_lsc_interrupt_setup(struct rte_eth_dev *dev)
4062 struct ixgbe_interrupt *intr =
4063 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
4065 ixgbe_dev_link_status_print(dev);
4066 intr->mask |= IXGBE_EICR_LSC;
4072 * It clears the interrupt causes and enables the interrupt.
4073 * It will be called once only during nic initialized.
4076 * Pointer to struct rte_eth_dev.
4079 * - On success, zero.
4080 * - On failure, a negative value.
4083 ixgbe_dev_rxq_interrupt_setup(struct rte_eth_dev *dev)
4085 struct ixgbe_interrupt *intr =
4086 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
4088 intr->mask |= IXGBE_EICR_RTX_QUEUE;
4094 * It clears the interrupt causes and enables the interrupt.
4095 * It will be called once only during nic initialized.
4098 * Pointer to struct rte_eth_dev.
4101 * - On success, zero.
4102 * - On failure, a negative value.
4105 ixgbe_dev_macsec_interrupt_setup(struct rte_eth_dev *dev)
4107 struct ixgbe_interrupt *intr =
4108 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
4110 intr->mask |= IXGBE_EICR_LINKSEC;
4116 * It reads ICR and sets flag (IXGBE_EICR_LSC) for the link_update.
4119 * Pointer to struct rte_eth_dev.
4122 * - On success, zero.
4123 * - On failure, a negative value.
4126 ixgbe_dev_interrupt_get_status(struct rte_eth_dev *dev)
4129 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4130 struct ixgbe_interrupt *intr =
4131 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
4133 /* clear all cause mask */
4134 ixgbe_disable_intr(hw);
4136 /* read-on-clear nic registers here */
4137 eicr = IXGBE_READ_REG(hw, IXGBE_EICR);
4138 PMD_DRV_LOG(DEBUG, "eicr %x", eicr);
4142 /* set flag for async link update */
4143 if (eicr & IXGBE_EICR_LSC)
4144 intr->flags |= IXGBE_FLAG_NEED_LINK_UPDATE;
4146 if (eicr & IXGBE_EICR_MAILBOX)
4147 intr->flags |= IXGBE_FLAG_MAILBOX;
4149 if (eicr & IXGBE_EICR_LINKSEC)
4150 intr->flags |= IXGBE_FLAG_MACSEC;
4152 if (hw->mac.type == ixgbe_mac_X550EM_x &&
4153 hw->phy.type == ixgbe_phy_x550em_ext_t &&
4154 (eicr & IXGBE_EICR_GPI_SDP0_X550EM_x))
4155 intr->flags |= IXGBE_FLAG_PHY_INTERRUPT;
4161 * It gets and then prints the link status.
4164 * Pointer to struct rte_eth_dev.
4167 * - On success, zero.
4168 * - On failure, a negative value.
4171 ixgbe_dev_link_status_print(struct rte_eth_dev *dev)
4173 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
4174 struct rte_eth_link link;
4176 memset(&link, 0, sizeof(link));
4177 rte_ixgbe_dev_atomic_read_link_status(dev, &link);
4178 if (link.link_status) {
4179 PMD_INIT_LOG(INFO, "Port %d: Link Up - speed %u Mbps - %s",
4180 (int)(dev->data->port_id),
4181 (unsigned)link.link_speed,
4182 link.link_duplex == ETH_LINK_FULL_DUPLEX ?
4183 "full-duplex" : "half-duplex");
4185 PMD_INIT_LOG(INFO, " Port %d: Link Down",
4186 (int)(dev->data->port_id));
4188 PMD_INIT_LOG(DEBUG, "PCI Address: " PCI_PRI_FMT,
4189 pci_dev->addr.domain,
4191 pci_dev->addr.devid,
4192 pci_dev->addr.function);
4196 * It executes link_update after knowing an interrupt occurred.
4199 * Pointer to struct rte_eth_dev.
4202 * - On success, zero.
4203 * - On failure, a negative value.
4206 ixgbe_dev_interrupt_action(struct rte_eth_dev *dev,
4207 struct rte_intr_handle *intr_handle)
4209 struct ixgbe_interrupt *intr =
4210 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
4212 struct rte_eth_link link;
4213 struct ixgbe_hw *hw =
4214 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4216 PMD_DRV_LOG(DEBUG, "intr action type %d", intr->flags);
4218 if (intr->flags & IXGBE_FLAG_MAILBOX) {
4219 ixgbe_pf_mbx_process(dev);
4220 intr->flags &= ~IXGBE_FLAG_MAILBOX;
4223 if (intr->flags & IXGBE_FLAG_PHY_INTERRUPT) {
4224 ixgbe_handle_lasi(hw);
4225 intr->flags &= ~IXGBE_FLAG_PHY_INTERRUPT;
4228 if (intr->flags & IXGBE_FLAG_NEED_LINK_UPDATE) {
4229 /* get the link status before link update, for predicting later */
4230 memset(&link, 0, sizeof(link));
4231 rte_ixgbe_dev_atomic_read_link_status(dev, &link);
4233 ixgbe_dev_link_update(dev, 0);
4236 if (!link.link_status)
4237 /* handle it 1 sec later, wait it being stable */
4238 timeout = IXGBE_LINK_UP_CHECK_TIMEOUT;
4239 /* likely to down */
4241 /* handle it 4 sec later, wait it being stable */
4242 timeout = IXGBE_LINK_DOWN_CHECK_TIMEOUT;
4244 ixgbe_dev_link_status_print(dev);
4245 if (rte_eal_alarm_set(timeout * 1000,
4246 ixgbe_dev_interrupt_delayed_handler, (void *)dev) < 0)
4247 PMD_DRV_LOG(ERR, "Error setting alarm");
4249 /* remember original mask */
4250 intr->mask_original = intr->mask;
4251 /* only disable lsc interrupt */
4252 intr->mask &= ~IXGBE_EIMS_LSC;
4256 PMD_DRV_LOG(DEBUG, "enable intr immediately");
4257 ixgbe_enable_intr(dev);
4258 rte_intr_enable(intr_handle);
4264 * Interrupt handler which shall be registered for alarm callback for delayed
4265 * handling specific interrupt to wait for the stable nic state. As the
4266 * NIC interrupt state is not stable for ixgbe after link is just down,
4267 * it needs to wait 4 seconds to get the stable status.
4270 * Pointer to interrupt handle.
4272 * The address of parameter (struct rte_eth_dev *) regsitered before.
4278 ixgbe_dev_interrupt_delayed_handler(void *param)
4280 struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
4281 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
4282 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
4283 struct ixgbe_interrupt *intr =
4284 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
4285 struct ixgbe_hw *hw =
4286 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4289 ixgbe_disable_intr(hw);
4291 eicr = IXGBE_READ_REG(hw, IXGBE_EICR);
4292 if (eicr & IXGBE_EICR_MAILBOX)
4293 ixgbe_pf_mbx_process(dev);
4295 if (intr->flags & IXGBE_FLAG_PHY_INTERRUPT) {
4296 ixgbe_handle_lasi(hw);
4297 intr->flags &= ~IXGBE_FLAG_PHY_INTERRUPT;
4300 if (intr->flags & IXGBE_FLAG_NEED_LINK_UPDATE) {
4301 ixgbe_dev_link_update(dev, 0);
4302 intr->flags &= ~IXGBE_FLAG_NEED_LINK_UPDATE;
4303 ixgbe_dev_link_status_print(dev);
4304 _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC,
4308 if (intr->flags & IXGBE_FLAG_MACSEC) {
4309 _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_MACSEC,
4311 intr->flags &= ~IXGBE_FLAG_MACSEC;
4314 /* restore original mask */
4315 intr->mask = intr->mask_original;
4316 intr->mask_original = 0;
4318 PMD_DRV_LOG(DEBUG, "enable intr in delayed handler S[%08x]", eicr);
4319 ixgbe_enable_intr(dev);
4320 rte_intr_enable(intr_handle);
4324 * Interrupt handler triggered by NIC for handling
4325 * specific interrupt.
4328 * Pointer to interrupt handle.
4330 * The address of parameter (struct rte_eth_dev *) regsitered before.
4336 ixgbe_dev_interrupt_handler(void *param)
4338 struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
4340 ixgbe_dev_interrupt_get_status(dev);
4341 ixgbe_dev_interrupt_action(dev, dev->intr_handle);
4345 ixgbe_dev_led_on(struct rte_eth_dev *dev)
4347 struct ixgbe_hw *hw;
4349 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4350 return ixgbe_led_on(hw, 0) == IXGBE_SUCCESS ? 0 : -ENOTSUP;
4354 ixgbe_dev_led_off(struct rte_eth_dev *dev)
4356 struct ixgbe_hw *hw;
4358 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4359 return ixgbe_led_off(hw, 0) == IXGBE_SUCCESS ? 0 : -ENOTSUP;
4363 ixgbe_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
4365 struct ixgbe_hw *hw;
4371 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4373 fc_conf->pause_time = hw->fc.pause_time;
4374 fc_conf->high_water = hw->fc.high_water[0];
4375 fc_conf->low_water = hw->fc.low_water[0];
4376 fc_conf->send_xon = hw->fc.send_xon;
4377 fc_conf->autoneg = !hw->fc.disable_fc_autoneg;
4380 * Return rx_pause status according to actual setting of
4383 mflcn_reg = IXGBE_READ_REG(hw, IXGBE_MFLCN);
4384 if (mflcn_reg & (IXGBE_MFLCN_RPFCE | IXGBE_MFLCN_RFCE))
4390 * Return tx_pause status according to actual setting of
4393 fccfg_reg = IXGBE_READ_REG(hw, IXGBE_FCCFG);
4394 if (fccfg_reg & (IXGBE_FCCFG_TFCE_802_3X | IXGBE_FCCFG_TFCE_PRIORITY))
4399 if (rx_pause && tx_pause)
4400 fc_conf->mode = RTE_FC_FULL;
4402 fc_conf->mode = RTE_FC_RX_PAUSE;
4404 fc_conf->mode = RTE_FC_TX_PAUSE;
4406 fc_conf->mode = RTE_FC_NONE;
4412 ixgbe_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
4414 struct ixgbe_hw *hw;
4416 uint32_t rx_buf_size;
4417 uint32_t max_high_water;
4419 enum ixgbe_fc_mode rte_fcmode_2_ixgbe_fcmode[] = {
4426 PMD_INIT_FUNC_TRACE();
4428 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4429 rx_buf_size = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(0));
4430 PMD_INIT_LOG(DEBUG, "Rx packet buffer size = 0x%x", rx_buf_size);
4433 * At least reserve one Ethernet frame for watermark
4434 * high_water/low_water in kilo bytes for ixgbe
4436 max_high_water = (rx_buf_size - ETHER_MAX_LEN) >> IXGBE_RXPBSIZE_SHIFT;
4437 if ((fc_conf->high_water > max_high_water) ||
4438 (fc_conf->high_water < fc_conf->low_water)) {
4439 PMD_INIT_LOG(ERR, "Invalid high/low water setup value in KB");
4440 PMD_INIT_LOG(ERR, "High_water must <= 0x%x", max_high_water);
4444 hw->fc.requested_mode = rte_fcmode_2_ixgbe_fcmode[fc_conf->mode];
4445 hw->fc.pause_time = fc_conf->pause_time;
4446 hw->fc.high_water[0] = fc_conf->high_water;
4447 hw->fc.low_water[0] = fc_conf->low_water;
4448 hw->fc.send_xon = fc_conf->send_xon;
4449 hw->fc.disable_fc_autoneg = !fc_conf->autoneg;
4451 err = ixgbe_fc_enable(hw);
4453 /* Not negotiated is not an error case */
4454 if ((err == IXGBE_SUCCESS) || (err == IXGBE_ERR_FC_NOT_NEGOTIATED)) {
4456 /* check if we want to forward MAC frames - driver doesn't have native
4457 * capability to do that, so we'll write the registers ourselves */
4459 mflcn = IXGBE_READ_REG(hw, IXGBE_MFLCN);
4461 /* set or clear MFLCN.PMCF bit depending on configuration */
4462 if (fc_conf->mac_ctrl_frame_fwd != 0)
4463 mflcn |= IXGBE_MFLCN_PMCF;
4465 mflcn &= ~IXGBE_MFLCN_PMCF;
4467 IXGBE_WRITE_REG(hw, IXGBE_MFLCN, mflcn);
4468 IXGBE_WRITE_FLUSH(hw);
4473 PMD_INIT_LOG(ERR, "ixgbe_fc_enable = 0x%x", err);
4478 * ixgbe_pfc_enable_generic - Enable flow control
4479 * @hw: pointer to hardware structure
4480 * @tc_num: traffic class number
4481 * Enable flow control according to the current settings.
4484 ixgbe_dcb_pfc_enable_generic(struct ixgbe_hw *hw, uint8_t tc_num)
4487 uint32_t mflcn_reg, fccfg_reg;
4489 uint32_t fcrtl, fcrth;
4493 /* Validate the water mark configuration */
4494 if (!hw->fc.pause_time) {
4495 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
4499 /* Low water mark of zero causes XOFF floods */
4500 if (hw->fc.current_mode & ixgbe_fc_tx_pause) {
4501 /* High/Low water can not be 0 */
4502 if ((!hw->fc.high_water[tc_num]) || (!hw->fc.low_water[tc_num])) {
4503 PMD_INIT_LOG(ERR, "Invalid water mark configuration");
4504 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
4508 if (hw->fc.low_water[tc_num] >= hw->fc.high_water[tc_num]) {
4509 PMD_INIT_LOG(ERR, "Invalid water mark configuration");
4510 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
4514 /* Negotiate the fc mode to use */
4515 ixgbe_fc_autoneg(hw);
4517 /* Disable any previous flow control settings */
4518 mflcn_reg = IXGBE_READ_REG(hw, IXGBE_MFLCN);
4519 mflcn_reg &= ~(IXGBE_MFLCN_RPFCE_SHIFT | IXGBE_MFLCN_RFCE|IXGBE_MFLCN_RPFCE);
4521 fccfg_reg = IXGBE_READ_REG(hw, IXGBE_FCCFG);
4522 fccfg_reg &= ~(IXGBE_FCCFG_TFCE_802_3X | IXGBE_FCCFG_TFCE_PRIORITY);
4524 switch (hw->fc.current_mode) {
4527 * If the count of enabled RX Priority Flow control >1,
4528 * and the TX pause can not be disabled
4531 for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
4532 reg = IXGBE_READ_REG(hw, IXGBE_FCRTH_82599(i));
4533 if (reg & IXGBE_FCRTH_FCEN)
4537 fccfg_reg |= IXGBE_FCCFG_TFCE_PRIORITY;
4539 case ixgbe_fc_rx_pause:
4541 * Rx Flow control is enabled and Tx Flow control is
4542 * disabled by software override. Since there really
4543 * isn't a way to advertise that we are capable of RX
4544 * Pause ONLY, we will advertise that we support both
4545 * symmetric and asymmetric Rx PAUSE. Later, we will
4546 * disable the adapter's ability to send PAUSE frames.
4548 mflcn_reg |= IXGBE_MFLCN_RPFCE;
4550 * If the count of enabled RX Priority Flow control >1,
4551 * and the TX pause can not be disabled
4554 for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
4555 reg = IXGBE_READ_REG(hw, IXGBE_FCRTH_82599(i));
4556 if (reg & IXGBE_FCRTH_FCEN)
4560 fccfg_reg |= IXGBE_FCCFG_TFCE_PRIORITY;
4562 case ixgbe_fc_tx_pause:
4564 * Tx Flow control is enabled, and Rx Flow control is
4565 * disabled by software override.
4567 fccfg_reg |= IXGBE_FCCFG_TFCE_PRIORITY;
4570 /* Flow control (both Rx and Tx) is enabled by SW override. */
4571 mflcn_reg |= IXGBE_MFLCN_RPFCE;
4572 fccfg_reg |= IXGBE_FCCFG_TFCE_PRIORITY;
4575 PMD_DRV_LOG(DEBUG, "Flow control param set incorrectly");
4576 ret_val = IXGBE_ERR_CONFIG;
4580 /* Set 802.3x based flow control settings. */
4581 mflcn_reg |= IXGBE_MFLCN_DPF;
4582 IXGBE_WRITE_REG(hw, IXGBE_MFLCN, mflcn_reg);
4583 IXGBE_WRITE_REG(hw, IXGBE_FCCFG, fccfg_reg);
4585 /* Set up and enable Rx high/low water mark thresholds, enable XON. */
4586 if ((hw->fc.current_mode & ixgbe_fc_tx_pause) &&
4587 hw->fc.high_water[tc_num]) {
4588 fcrtl = (hw->fc.low_water[tc_num] << 10) | IXGBE_FCRTL_XONE;
4589 IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(tc_num), fcrtl);
4590 fcrth = (hw->fc.high_water[tc_num] << 10) | IXGBE_FCRTH_FCEN;
4592 IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(tc_num), 0);
4594 * In order to prevent Tx hangs when the internal Tx
4595 * switch is enabled we must set the high water mark
4596 * to the maximum FCRTH value. This allows the Tx
4597 * switch to function even under heavy Rx workloads.
4599 fcrth = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(tc_num)) - 32;
4601 IXGBE_WRITE_REG(hw, IXGBE_FCRTH_82599(tc_num), fcrth);
4603 /* Configure pause time (2 TCs per register) */
4604 reg = hw->fc.pause_time * 0x00010001;
4605 for (i = 0; i < (IXGBE_DCB_MAX_TRAFFIC_CLASS / 2); i++)
4606 IXGBE_WRITE_REG(hw, IXGBE_FCTTV(i), reg);
4608 /* Configure flow control refresh threshold value */
4609 IXGBE_WRITE_REG(hw, IXGBE_FCRTV, hw->fc.pause_time / 2);
4616 ixgbe_dcb_pfc_enable(struct rte_eth_dev *dev, uint8_t tc_num)
4618 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4619 int32_t ret_val = IXGBE_NOT_IMPLEMENTED;
4621 if (hw->mac.type != ixgbe_mac_82598EB) {
4622 ret_val = ixgbe_dcb_pfc_enable_generic(hw, tc_num);
4628 ixgbe_priority_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_pfc_conf *pfc_conf)
4631 uint32_t rx_buf_size;
4632 uint32_t max_high_water;
4634 uint8_t map[IXGBE_DCB_MAX_USER_PRIORITY] = { 0 };
4635 struct ixgbe_hw *hw =
4636 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4637 struct ixgbe_dcb_config *dcb_config =
4638 IXGBE_DEV_PRIVATE_TO_DCB_CFG(dev->data->dev_private);
4640 enum ixgbe_fc_mode rte_fcmode_2_ixgbe_fcmode[] = {
4647 PMD_INIT_FUNC_TRACE();
4649 ixgbe_dcb_unpack_map_cee(dcb_config, IXGBE_DCB_RX_CONFIG, map);
4650 tc_num = map[pfc_conf->priority];
4651 rx_buf_size = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(tc_num));
4652 PMD_INIT_LOG(DEBUG, "Rx packet buffer size = 0x%x", rx_buf_size);
4654 * At least reserve one Ethernet frame for watermark
4655 * high_water/low_water in kilo bytes for ixgbe
4657 max_high_water = (rx_buf_size - ETHER_MAX_LEN) >> IXGBE_RXPBSIZE_SHIFT;
4658 if ((pfc_conf->fc.high_water > max_high_water) ||
4659 (pfc_conf->fc.high_water <= pfc_conf->fc.low_water)) {
4660 PMD_INIT_LOG(ERR, "Invalid high/low water setup value in KB");
4661 PMD_INIT_LOG(ERR, "High_water must <= 0x%x", max_high_water);
4665 hw->fc.requested_mode = rte_fcmode_2_ixgbe_fcmode[pfc_conf->fc.mode];
4666 hw->fc.pause_time = pfc_conf->fc.pause_time;
4667 hw->fc.send_xon = pfc_conf->fc.send_xon;
4668 hw->fc.low_water[tc_num] = pfc_conf->fc.low_water;
4669 hw->fc.high_water[tc_num] = pfc_conf->fc.high_water;
4671 err = ixgbe_dcb_pfc_enable(dev, tc_num);
4673 /* Not negotiated is not an error case */
4674 if ((err == IXGBE_SUCCESS) || (err == IXGBE_ERR_FC_NOT_NEGOTIATED))
4677 PMD_INIT_LOG(ERR, "ixgbe_dcb_pfc_enable = 0x%x", err);
4682 ixgbe_dev_rss_reta_update(struct rte_eth_dev *dev,
4683 struct rte_eth_rss_reta_entry64 *reta_conf,
4686 uint16_t i, sp_reta_size;
4689 uint16_t idx, shift;
4690 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4693 PMD_INIT_FUNC_TRACE();
4695 if (!ixgbe_rss_update_sp(hw->mac.type)) {
4696 PMD_DRV_LOG(ERR, "RSS reta update is not supported on this "
4701 sp_reta_size = ixgbe_reta_size_get(hw->mac.type);
4702 if (reta_size != sp_reta_size) {
4703 PMD_DRV_LOG(ERR, "The size of hash lookup table configured "
4704 "(%d) doesn't match the number hardware can supported "
4705 "(%d)", reta_size, sp_reta_size);
4709 for (i = 0; i < reta_size; i += IXGBE_4_BIT_WIDTH) {
4710 idx = i / RTE_RETA_GROUP_SIZE;
4711 shift = i % RTE_RETA_GROUP_SIZE;
4712 mask = (uint8_t)((reta_conf[idx].mask >> shift) &
4716 reta_reg = ixgbe_reta_reg_get(hw->mac.type, i);
4717 if (mask == IXGBE_4_BIT_MASK)
4720 r = IXGBE_READ_REG(hw, reta_reg);
4721 for (j = 0, reta = 0; j < IXGBE_4_BIT_WIDTH; j++) {
4722 if (mask & (0x1 << j))
4723 reta |= reta_conf[idx].reta[shift + j] <<
4726 reta |= r & (IXGBE_8_BIT_MASK <<
4729 IXGBE_WRITE_REG(hw, reta_reg, reta);
4736 ixgbe_dev_rss_reta_query(struct rte_eth_dev *dev,
4737 struct rte_eth_rss_reta_entry64 *reta_conf,
4740 uint16_t i, sp_reta_size;
4743 uint16_t idx, shift;
4744 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4747 PMD_INIT_FUNC_TRACE();
4748 sp_reta_size = ixgbe_reta_size_get(hw->mac.type);
4749 if (reta_size != sp_reta_size) {
4750 PMD_DRV_LOG(ERR, "The size of hash lookup table configured "
4751 "(%d) doesn't match the number hardware can supported "
4752 "(%d)", reta_size, sp_reta_size);
4756 for (i = 0; i < reta_size; i += IXGBE_4_BIT_WIDTH) {
4757 idx = i / RTE_RETA_GROUP_SIZE;
4758 shift = i % RTE_RETA_GROUP_SIZE;
4759 mask = (uint8_t)((reta_conf[idx].mask >> shift) &
4764 reta_reg = ixgbe_reta_reg_get(hw->mac.type, i);
4765 reta = IXGBE_READ_REG(hw, reta_reg);
4766 for (j = 0; j < IXGBE_4_BIT_WIDTH; j++) {
4767 if (mask & (0x1 << j))
4768 reta_conf[idx].reta[shift + j] =
4769 ((reta >> (CHAR_BIT * j)) &
4778 ixgbe_add_rar(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
4779 uint32_t index, uint32_t pool)
4781 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4782 uint32_t enable_addr = 1;
4784 return ixgbe_set_rar(hw, index, mac_addr->addr_bytes,
4789 ixgbe_remove_rar(struct rte_eth_dev *dev, uint32_t index)
4791 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4793 ixgbe_clear_rar(hw, index);
4797 ixgbe_set_default_mac_addr(struct rte_eth_dev *dev, struct ether_addr *addr)
4799 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
4801 ixgbe_remove_rar(dev, 0);
4803 ixgbe_add_rar(dev, addr, 0, pci_dev->max_vfs);
4807 is_device_supported(struct rte_eth_dev *dev, struct rte_pci_driver *drv)
4809 if (strcmp(dev->device->driver->name, drv->driver.name))
4816 is_ixgbe_supported(struct rte_eth_dev *dev)
4818 return is_device_supported(dev, &rte_ixgbe_pmd);
4822 ixgbe_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
4826 struct ixgbe_hw *hw;
4827 struct rte_eth_dev_info dev_info;
4828 uint32_t frame_size = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
4829 struct rte_eth_dev_data *dev_data = dev->data;
4831 ixgbe_dev_info_get(dev, &dev_info);
4833 /* check that mtu is within the allowed range */
4834 if ((mtu < ETHER_MIN_MTU) || (frame_size > dev_info.max_rx_pktlen))
4837 /* If device is started, refuse mtu that requires the support of
4838 * scattered packets when this feature has not been enabled before.
4840 if (dev_data->dev_started && !dev_data->scattered_rx &&
4841 (frame_size + 2 * IXGBE_VLAN_TAG_SIZE >
4842 dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM)) {
4843 PMD_INIT_LOG(ERR, "Stop port first.");
4847 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4848 hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
4850 /* switch to jumbo mode if needed */
4851 if (frame_size > ETHER_MAX_LEN) {
4852 dev->data->dev_conf.rxmode.jumbo_frame = 1;
4853 hlreg0 |= IXGBE_HLREG0_JUMBOEN;
4855 dev->data->dev_conf.rxmode.jumbo_frame = 0;
4856 hlreg0 &= ~IXGBE_HLREG0_JUMBOEN;
4858 IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
4860 /* update max frame size */
4861 dev->data->dev_conf.rxmode.max_rx_pkt_len = frame_size;
4863 maxfrs = IXGBE_READ_REG(hw, IXGBE_MAXFRS);
4864 maxfrs &= 0x0000FFFF;
4865 maxfrs |= (dev->data->dev_conf.rxmode.max_rx_pkt_len << 16);
4866 IXGBE_WRITE_REG(hw, IXGBE_MAXFRS, maxfrs);
4872 * Virtual Function operations
4875 ixgbevf_intr_disable(struct ixgbe_hw *hw)
4877 PMD_INIT_FUNC_TRACE();
4879 /* Clear interrupt mask to stop from interrupts being generated */
4880 IXGBE_WRITE_REG(hw, IXGBE_VTEIMC, IXGBE_VF_IRQ_CLEAR_MASK);
4882 IXGBE_WRITE_FLUSH(hw);
4886 ixgbevf_intr_enable(struct ixgbe_hw *hw)
4888 PMD_INIT_FUNC_TRACE();
4890 /* VF enable interrupt autoclean */
4891 IXGBE_WRITE_REG(hw, IXGBE_VTEIAM, IXGBE_VF_IRQ_ENABLE_MASK);
4892 IXGBE_WRITE_REG(hw, IXGBE_VTEIAC, IXGBE_VF_IRQ_ENABLE_MASK);
4893 IXGBE_WRITE_REG(hw, IXGBE_VTEIMS, IXGBE_VF_IRQ_ENABLE_MASK);
4895 IXGBE_WRITE_FLUSH(hw);
4899 ixgbevf_dev_configure(struct rte_eth_dev *dev)
4901 struct rte_eth_conf *conf = &dev->data->dev_conf;
4902 struct ixgbe_adapter *adapter =
4903 (struct ixgbe_adapter *)dev->data->dev_private;
4905 PMD_INIT_LOG(DEBUG, "Configured Virtual Function port id: %d",
4906 dev->data->port_id);
4909 * VF has no ability to enable/disable HW CRC
4910 * Keep the persistent behavior the same as Host PF
4912 #ifndef RTE_LIBRTE_IXGBE_PF_DISABLE_STRIP_CRC
4913 if (!conf->rxmode.hw_strip_crc) {
4914 PMD_INIT_LOG(NOTICE, "VF can't disable HW CRC Strip");
4915 conf->rxmode.hw_strip_crc = 1;
4918 if (conf->rxmode.hw_strip_crc) {
4919 PMD_INIT_LOG(NOTICE, "VF can't enable HW CRC Strip");
4920 conf->rxmode.hw_strip_crc = 0;
4925 * Initialize to TRUE. If any of Rx queues doesn't meet the bulk
4926 * allocation or vector Rx preconditions we will reset it.
4928 adapter->rx_bulk_alloc_allowed = true;
4929 adapter->rx_vec_allowed = true;
4935 ixgbevf_dev_start(struct rte_eth_dev *dev)
4937 struct ixgbe_hw *hw =
4938 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4939 uint32_t intr_vector = 0;
4940 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
4941 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
4945 PMD_INIT_FUNC_TRACE();
4947 hw->mac.ops.reset_hw(hw);
4948 hw->mac.get_link_status = true;
4950 /* negotiate mailbox API version to use with the PF. */
4951 ixgbevf_negotiate_api(hw);
4953 ixgbevf_dev_tx_init(dev);
4955 /* This can fail when allocating mbufs for descriptor rings */
4956 err = ixgbevf_dev_rx_init(dev);
4958 PMD_INIT_LOG(ERR, "Unable to initialize RX hardware (%d)", err);
4959 ixgbe_dev_clear_queues(dev);
4964 ixgbevf_set_vfta_all(dev, 1);
4967 mask = ETH_VLAN_STRIP_MASK | ETH_VLAN_FILTER_MASK |
4968 ETH_VLAN_EXTEND_MASK;
4969 ixgbevf_vlan_offload_set(dev, mask);
4971 ixgbevf_dev_rxtx_start(dev);
4973 /* check and configure queue intr-vector mapping */
4974 if (dev->data->dev_conf.intr_conf.rxq != 0) {
4975 intr_vector = dev->data->nb_rx_queues;
4976 if (rte_intr_efd_enable(intr_handle, intr_vector))
4980 if (rte_intr_dp_is_en(intr_handle) && !intr_handle->intr_vec) {
4981 intr_handle->intr_vec =
4982 rte_zmalloc("intr_vec",
4983 dev->data->nb_rx_queues * sizeof(int), 0);
4984 if (intr_handle->intr_vec == NULL) {
4985 PMD_INIT_LOG(ERR, "Failed to allocate %d rx_queues"
4986 " intr_vec", dev->data->nb_rx_queues);
4990 ixgbevf_configure_msix(dev);
4992 rte_intr_enable(intr_handle);
4994 /* Re-enable interrupt for VF */
4995 ixgbevf_intr_enable(hw);
5001 ixgbevf_dev_stop(struct rte_eth_dev *dev)
5003 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5004 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
5005 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
5007 PMD_INIT_FUNC_TRACE();
5009 ixgbevf_intr_disable(hw);
5011 hw->adapter_stopped = 1;
5012 ixgbe_stop_adapter(hw);
5015 * Clear what we set, but we still keep shadow_vfta to
5016 * restore after device starts
5018 ixgbevf_set_vfta_all(dev, 0);
5020 /* Clear stored conf */
5021 dev->data->scattered_rx = 0;
5023 ixgbe_dev_clear_queues(dev);
5025 /* Clean datapath event and queue/vec mapping */
5026 rte_intr_efd_disable(intr_handle);
5027 if (intr_handle->intr_vec != NULL) {
5028 rte_free(intr_handle->intr_vec);
5029 intr_handle->intr_vec = NULL;
5034 ixgbevf_dev_close(struct rte_eth_dev *dev)
5036 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5038 PMD_INIT_FUNC_TRACE();
5042 ixgbevf_dev_stop(dev);
5044 ixgbe_dev_free_queues(dev);
5047 * Remove the VF MAC address ro ensure
5048 * that the VF traffic goes to the PF
5049 * after stop, close and detach of the VF
5051 ixgbevf_remove_mac_addr(dev, 0);
5054 static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on)
5056 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5057 struct ixgbe_vfta *shadow_vfta =
5058 IXGBE_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
5059 int i = 0, j = 0, vfta = 0, mask = 1;
5061 for (i = 0; i < IXGBE_VFTA_SIZE; i++) {
5062 vfta = shadow_vfta->vfta[i];
5065 for (j = 0; j < 32; j++) {
5067 ixgbe_set_vfta(hw, (i<<5)+j, 0,
5077 ixgbevf_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
5079 struct ixgbe_hw *hw =
5080 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5081 struct ixgbe_vfta *shadow_vfta =
5082 IXGBE_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
5083 uint32_t vid_idx = 0;
5084 uint32_t vid_bit = 0;
5087 PMD_INIT_FUNC_TRACE();
5089 /* vind is not used in VF driver, set to 0, check ixgbe_set_vfta_vf */
5090 ret = ixgbe_set_vfta(hw, vlan_id, 0, !!on, false);
5092 PMD_INIT_LOG(ERR, "Unable to set VF vlan");
5095 vid_idx = (uint32_t) ((vlan_id >> 5) & 0x7F);
5096 vid_bit = (uint32_t) (1 << (vlan_id & 0x1F));
5098 /* Save what we set and retore it after device reset */
5100 shadow_vfta->vfta[vid_idx] |= vid_bit;
5102 shadow_vfta->vfta[vid_idx] &= ~vid_bit;
5108 ixgbevf_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue, int on)
5110 struct ixgbe_hw *hw =
5111 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5114 PMD_INIT_FUNC_TRACE();
5116 if (queue >= hw->mac.max_rx_queues)
5119 ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(queue));
5121 ctrl |= IXGBE_RXDCTL_VME;
5123 ctrl &= ~IXGBE_RXDCTL_VME;
5124 IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(queue), ctrl);
5126 ixgbe_vlan_hw_strip_bitmap_set(dev, queue, on);
5130 ixgbevf_vlan_offload_set(struct rte_eth_dev *dev, int mask)
5132 struct ixgbe_hw *hw =
5133 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5137 /* VF function only support hw strip feature, others are not support */
5138 if (mask & ETH_VLAN_STRIP_MASK) {
5139 on = !!(dev->data->dev_conf.rxmode.hw_vlan_strip);
5141 for (i = 0; i < hw->mac.max_rx_queues; i++)
5142 ixgbevf_vlan_strip_queue_set(dev, i, on);
5147 ixgbe_vt_check(struct ixgbe_hw *hw)
5151 /* if Virtualization Technology is enabled */
5152 reg_val = IXGBE_READ_REG(hw, IXGBE_VT_CTL);
5153 if (!(reg_val & IXGBE_VT_CTL_VT_ENABLE)) {
5154 PMD_INIT_LOG(ERR, "VT must be enabled for this setting");
5162 ixgbe_uta_vector(struct ixgbe_hw *hw, struct ether_addr *uc_addr)
5164 uint32_t vector = 0;
5166 switch (hw->mac.mc_filter_type) {
5167 case 0: /* use bits [47:36] of the address */
5168 vector = ((uc_addr->addr_bytes[4] >> 4) |
5169 (((uint16_t)uc_addr->addr_bytes[5]) << 4));
5171 case 1: /* use bits [46:35] of the address */
5172 vector = ((uc_addr->addr_bytes[4] >> 3) |
5173 (((uint16_t)uc_addr->addr_bytes[5]) << 5));
5175 case 2: /* use bits [45:34] of the address */
5176 vector = ((uc_addr->addr_bytes[4] >> 2) |
5177 (((uint16_t)uc_addr->addr_bytes[5]) << 6));
5179 case 3: /* use bits [43:32] of the address */
5180 vector = ((uc_addr->addr_bytes[4]) |
5181 (((uint16_t)uc_addr->addr_bytes[5]) << 8));
5183 default: /* Invalid mc_filter_type */
5187 /* vector can only be 12-bits or boundary will be exceeded */
5193 ixgbe_uc_hash_table_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
5201 const uint32_t ixgbe_uta_idx_mask = 0x7F;
5202 const uint32_t ixgbe_uta_bit_shift = 5;
5203 const uint32_t ixgbe_uta_bit_mask = (0x1 << ixgbe_uta_bit_shift) - 1;
5204 const uint32_t bit1 = 0x1;
5206 struct ixgbe_hw *hw =
5207 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5208 struct ixgbe_uta_info *uta_info =
5209 IXGBE_DEV_PRIVATE_TO_UTA(dev->data->dev_private);
5211 /* The UTA table only exists on 82599 hardware and newer */
5212 if (hw->mac.type < ixgbe_mac_82599EB)
5215 vector = ixgbe_uta_vector(hw, mac_addr);
5216 uta_idx = (vector >> ixgbe_uta_bit_shift) & ixgbe_uta_idx_mask;
5217 uta_shift = vector & ixgbe_uta_bit_mask;
5219 rc = ((uta_info->uta_shadow[uta_idx] >> uta_shift & bit1) != 0);
5223 reg_val = IXGBE_READ_REG(hw, IXGBE_UTA(uta_idx));
5225 uta_info->uta_in_use++;
5226 reg_val |= (bit1 << uta_shift);
5227 uta_info->uta_shadow[uta_idx] |= (bit1 << uta_shift);
5229 uta_info->uta_in_use--;
5230 reg_val &= ~(bit1 << uta_shift);
5231 uta_info->uta_shadow[uta_idx] &= ~(bit1 << uta_shift);
5234 IXGBE_WRITE_REG(hw, IXGBE_UTA(uta_idx), reg_val);
5236 if (uta_info->uta_in_use > 0)
5237 IXGBE_WRITE_REG(hw, IXGBE_MCSTCTRL,
5238 IXGBE_MCSTCTRL_MFE | hw->mac.mc_filter_type);
5240 IXGBE_WRITE_REG(hw, IXGBE_MCSTCTRL, hw->mac.mc_filter_type);
5246 ixgbe_uc_all_hash_table_set(struct rte_eth_dev *dev, uint8_t on)
5249 struct ixgbe_hw *hw =
5250 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5251 struct ixgbe_uta_info *uta_info =
5252 IXGBE_DEV_PRIVATE_TO_UTA(dev->data->dev_private);
5254 /* The UTA table only exists on 82599 hardware and newer */
5255 if (hw->mac.type < ixgbe_mac_82599EB)
5259 for (i = 0; i < ETH_VMDQ_NUM_UC_HASH_ARRAY; i++) {
5260 uta_info->uta_shadow[i] = ~0;
5261 IXGBE_WRITE_REG(hw, IXGBE_UTA(i), ~0);
5264 for (i = 0; i < ETH_VMDQ_NUM_UC_HASH_ARRAY; i++) {
5265 uta_info->uta_shadow[i] = 0;
5266 IXGBE_WRITE_REG(hw, IXGBE_UTA(i), 0);
5274 ixgbe_convert_vm_rx_mask_to_val(uint16_t rx_mask, uint32_t orig_val)
5276 uint32_t new_val = orig_val;
5278 if (rx_mask & ETH_VMDQ_ACCEPT_UNTAG)
5279 new_val |= IXGBE_VMOLR_AUPE;
5280 if (rx_mask & ETH_VMDQ_ACCEPT_HASH_MC)
5281 new_val |= IXGBE_VMOLR_ROMPE;
5282 if (rx_mask & ETH_VMDQ_ACCEPT_HASH_UC)
5283 new_val |= IXGBE_VMOLR_ROPE;
5284 if (rx_mask & ETH_VMDQ_ACCEPT_BROADCAST)
5285 new_val |= IXGBE_VMOLR_BAM;
5286 if (rx_mask & ETH_VMDQ_ACCEPT_MULTICAST)
5287 new_val |= IXGBE_VMOLR_MPE;
5292 #define IXGBE_MRCTL_VPME 0x01 /* Virtual Pool Mirroring. */
5293 #define IXGBE_MRCTL_UPME 0x02 /* Uplink Port Mirroring. */
5294 #define IXGBE_MRCTL_DPME 0x04 /* Downlink Port Mirroring. */
5295 #define IXGBE_MRCTL_VLME 0x08 /* VLAN Mirroring. */
5296 #define IXGBE_INVALID_MIRROR_TYPE(mirror_type) \
5297 ((mirror_type) & ~(uint8_t)(ETH_MIRROR_VIRTUAL_POOL_UP | \
5298 ETH_MIRROR_UPLINK_PORT | ETH_MIRROR_DOWNLINK_PORT | ETH_MIRROR_VLAN))
5301 ixgbe_mirror_rule_set(struct rte_eth_dev *dev,
5302 struct rte_eth_mirror_conf *mirror_conf,
5303 uint8_t rule_id, uint8_t on)
5305 uint32_t mr_ctl, vlvf;
5306 uint32_t mp_lsb = 0;
5307 uint32_t mv_msb = 0;
5308 uint32_t mv_lsb = 0;
5309 uint32_t mp_msb = 0;
5312 uint64_t vlan_mask = 0;
5314 const uint8_t pool_mask_offset = 32;
5315 const uint8_t vlan_mask_offset = 32;
5316 const uint8_t dst_pool_offset = 8;
5317 const uint8_t rule_mr_offset = 4;
5318 const uint8_t mirror_rule_mask = 0x0F;
5320 struct ixgbe_mirror_info *mr_info =
5321 (IXGBE_DEV_PRIVATE_TO_PFDATA(dev->data->dev_private));
5322 struct ixgbe_hw *hw =
5323 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5324 uint8_t mirror_type = 0;
5326 if (ixgbe_vt_check(hw) < 0)
5329 if (rule_id >= IXGBE_MAX_MIRROR_RULES)
5332 if (IXGBE_INVALID_MIRROR_TYPE(mirror_conf->rule_type)) {
5333 PMD_DRV_LOG(ERR, "unsupported mirror type 0x%x.",
5334 mirror_conf->rule_type);
5338 if (mirror_conf->rule_type & ETH_MIRROR_VLAN) {
5339 mirror_type |= IXGBE_MRCTL_VLME;
5340 /* Check if vlan id is valid and find conresponding VLAN ID
5343 for (i = 0; i < IXGBE_VLVF_ENTRIES; i++) {
5344 if (mirror_conf->vlan.vlan_mask & (1ULL << i)) {
5345 /* search vlan id related pool vlan filter
5348 reg_index = ixgbe_find_vlvf_slot(
5350 mirror_conf->vlan.vlan_id[i],
5354 vlvf = IXGBE_READ_REG(hw,
5355 IXGBE_VLVF(reg_index));
5356 if ((vlvf & IXGBE_VLVF_VIEN) &&
5357 ((vlvf & IXGBE_VLVF_VLANID_MASK) ==
5358 mirror_conf->vlan.vlan_id[i]))
5359 vlan_mask |= (1ULL << reg_index);
5366 mv_lsb = vlan_mask & 0xFFFFFFFF;
5367 mv_msb = vlan_mask >> vlan_mask_offset;
5369 mr_info->mr_conf[rule_id].vlan.vlan_mask =
5370 mirror_conf->vlan.vlan_mask;
5371 for (i = 0; i < ETH_VMDQ_MAX_VLAN_FILTERS; i++) {
5372 if (mirror_conf->vlan.vlan_mask & (1ULL << i))
5373 mr_info->mr_conf[rule_id].vlan.vlan_id[i] =
5374 mirror_conf->vlan.vlan_id[i];
5379 mr_info->mr_conf[rule_id].vlan.vlan_mask = 0;
5380 for (i = 0; i < ETH_VMDQ_MAX_VLAN_FILTERS; i++)
5381 mr_info->mr_conf[rule_id].vlan.vlan_id[i] = 0;
5386 * if enable pool mirror, write related pool mask register,if disable
5387 * pool mirror, clear PFMRVM register
5389 if (mirror_conf->rule_type & ETH_MIRROR_VIRTUAL_POOL_UP) {
5390 mirror_type |= IXGBE_MRCTL_VPME;
5392 mp_lsb = mirror_conf->pool_mask & 0xFFFFFFFF;
5393 mp_msb = mirror_conf->pool_mask >> pool_mask_offset;
5394 mr_info->mr_conf[rule_id].pool_mask =
5395 mirror_conf->pool_mask;
5400 mr_info->mr_conf[rule_id].pool_mask = 0;
5403 if (mirror_conf->rule_type & ETH_MIRROR_UPLINK_PORT)
5404 mirror_type |= IXGBE_MRCTL_UPME;
5405 if (mirror_conf->rule_type & ETH_MIRROR_DOWNLINK_PORT)
5406 mirror_type |= IXGBE_MRCTL_DPME;
5408 /* read mirror control register and recalculate it */
5409 mr_ctl = IXGBE_READ_REG(hw, IXGBE_MRCTL(rule_id));
5412 mr_ctl |= mirror_type;
5413 mr_ctl &= mirror_rule_mask;
5414 mr_ctl |= mirror_conf->dst_pool << dst_pool_offset;
5416 mr_ctl &= ~(mirror_conf->rule_type & mirror_rule_mask);
5419 mr_info->mr_conf[rule_id].rule_type = mirror_conf->rule_type;
5420 mr_info->mr_conf[rule_id].dst_pool = mirror_conf->dst_pool;
5422 /* write mirrror control register */
5423 IXGBE_WRITE_REG(hw, IXGBE_MRCTL(rule_id), mr_ctl);
5425 /* write pool mirrror control register */
5426 if (mirror_conf->rule_type == ETH_MIRROR_VIRTUAL_POOL_UP) {
5427 IXGBE_WRITE_REG(hw, IXGBE_VMRVM(rule_id), mp_lsb);
5428 IXGBE_WRITE_REG(hw, IXGBE_VMRVM(rule_id + rule_mr_offset),
5431 /* write VLAN mirrror control register */
5432 if (mirror_conf->rule_type == ETH_MIRROR_VLAN) {
5433 IXGBE_WRITE_REG(hw, IXGBE_VMRVLAN(rule_id), mv_lsb);
5434 IXGBE_WRITE_REG(hw, IXGBE_VMRVLAN(rule_id + rule_mr_offset),
5442 ixgbe_mirror_rule_reset(struct rte_eth_dev *dev, uint8_t rule_id)
5445 uint32_t lsb_val = 0;
5446 uint32_t msb_val = 0;
5447 const uint8_t rule_mr_offset = 4;
5449 struct ixgbe_hw *hw =
5450 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5451 struct ixgbe_mirror_info *mr_info =
5452 (IXGBE_DEV_PRIVATE_TO_PFDATA(dev->data->dev_private));
5454 if (ixgbe_vt_check(hw) < 0)
5457 memset(&mr_info->mr_conf[rule_id], 0,
5458 sizeof(struct rte_eth_mirror_conf));
5460 /* clear PFVMCTL register */
5461 IXGBE_WRITE_REG(hw, IXGBE_MRCTL(rule_id), mr_ctl);
5463 /* clear pool mask register */
5464 IXGBE_WRITE_REG(hw, IXGBE_VMRVM(rule_id), lsb_val);
5465 IXGBE_WRITE_REG(hw, IXGBE_VMRVM(rule_id + rule_mr_offset), msb_val);
5467 /* clear vlan mask register */
5468 IXGBE_WRITE_REG(hw, IXGBE_VMRVLAN(rule_id), lsb_val);
5469 IXGBE_WRITE_REG(hw, IXGBE_VMRVLAN(rule_id + rule_mr_offset), msb_val);
5475 ixgbevf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
5477 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
5478 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
5480 struct ixgbe_hw *hw =
5481 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5483 mask = IXGBE_READ_REG(hw, IXGBE_VTEIMS);
5484 mask |= (1 << IXGBE_MISC_VEC_ID);
5485 RTE_SET_USED(queue_id);
5486 IXGBE_WRITE_REG(hw, IXGBE_VTEIMS, mask);
5488 rte_intr_enable(intr_handle);
5494 ixgbevf_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id)
5497 struct ixgbe_hw *hw =
5498 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5500 mask = IXGBE_READ_REG(hw, IXGBE_VTEIMS);
5501 mask &= ~(1 << IXGBE_MISC_VEC_ID);
5502 RTE_SET_USED(queue_id);
5503 IXGBE_WRITE_REG(hw, IXGBE_VTEIMS, mask);
5509 ixgbe_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
5511 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
5512 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
5514 struct ixgbe_hw *hw =
5515 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5516 struct ixgbe_interrupt *intr =
5517 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
5519 if (queue_id < 16) {
5520 ixgbe_disable_intr(hw);
5521 intr->mask |= (1 << queue_id);
5522 ixgbe_enable_intr(dev);
5523 } else if (queue_id < 32) {
5524 mask = IXGBE_READ_REG(hw, IXGBE_EIMS_EX(0));
5525 mask &= (1 << queue_id);
5526 IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(0), mask);
5527 } else if (queue_id < 64) {
5528 mask = IXGBE_READ_REG(hw, IXGBE_EIMS_EX(1));
5529 mask &= (1 << (queue_id - 32));
5530 IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(1), mask);
5532 rte_intr_enable(intr_handle);
5538 ixgbe_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id)
5541 struct ixgbe_hw *hw =
5542 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5543 struct ixgbe_interrupt *intr =
5544 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
5546 if (queue_id < 16) {
5547 ixgbe_disable_intr(hw);
5548 intr->mask &= ~(1 << queue_id);
5549 ixgbe_enable_intr(dev);
5550 } else if (queue_id < 32) {
5551 mask = IXGBE_READ_REG(hw, IXGBE_EIMS_EX(0));
5552 mask &= ~(1 << queue_id);
5553 IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(0), mask);
5554 } else if (queue_id < 64) {
5555 mask = IXGBE_READ_REG(hw, IXGBE_EIMS_EX(1));
5556 mask &= ~(1 << (queue_id - 32));
5557 IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(1), mask);
5564 ixgbevf_set_ivar_map(struct ixgbe_hw *hw, int8_t direction,
5565 uint8_t queue, uint8_t msix_vector)
5569 if (direction == -1) {
5571 msix_vector |= IXGBE_IVAR_ALLOC_VAL;
5572 tmp = IXGBE_READ_REG(hw, IXGBE_VTIVAR_MISC);
5575 IXGBE_WRITE_REG(hw, IXGBE_VTIVAR_MISC, tmp);
5577 /* rx or tx cause */
5578 msix_vector |= IXGBE_IVAR_ALLOC_VAL;
5579 idx = ((16 * (queue & 1)) + (8 * direction));
5580 tmp = IXGBE_READ_REG(hw, IXGBE_VTIVAR(queue >> 1));
5581 tmp &= ~(0xFF << idx);
5582 tmp |= (msix_vector << idx);
5583 IXGBE_WRITE_REG(hw, IXGBE_VTIVAR(queue >> 1), tmp);
5588 * set the IVAR registers, mapping interrupt causes to vectors
5590 * pointer to ixgbe_hw struct
5592 * 0 for Rx, 1 for Tx, -1 for other causes
5594 * queue to map the corresponding interrupt to
5596 * the vector to map to the corresponding queue
5599 ixgbe_set_ivar_map(struct ixgbe_hw *hw, int8_t direction,
5600 uint8_t queue, uint8_t msix_vector)
5604 msix_vector |= IXGBE_IVAR_ALLOC_VAL;
5605 if (hw->mac.type == ixgbe_mac_82598EB) {
5606 if (direction == -1)
5608 idx = (((direction * 64) + queue) >> 2) & 0x1F;
5609 tmp = IXGBE_READ_REG(hw, IXGBE_IVAR(idx));
5610 tmp &= ~(0xFF << (8 * (queue & 0x3)));
5611 tmp |= (msix_vector << (8 * (queue & 0x3)));
5612 IXGBE_WRITE_REG(hw, IXGBE_IVAR(idx), tmp);
5613 } else if ((hw->mac.type == ixgbe_mac_82599EB) ||
5614 (hw->mac.type == ixgbe_mac_X540)) {
5615 if (direction == -1) {
5617 idx = ((queue & 1) * 8);
5618 tmp = IXGBE_READ_REG(hw, IXGBE_IVAR_MISC);
5619 tmp &= ~(0xFF << idx);
5620 tmp |= (msix_vector << idx);
5621 IXGBE_WRITE_REG(hw, IXGBE_IVAR_MISC, tmp);
5623 /* rx or tx causes */
5624 idx = ((16 * (queue & 1)) + (8 * direction));
5625 tmp = IXGBE_READ_REG(hw, IXGBE_IVAR(queue >> 1));
5626 tmp &= ~(0xFF << idx);
5627 tmp |= (msix_vector << idx);
5628 IXGBE_WRITE_REG(hw, IXGBE_IVAR(queue >> 1), tmp);
5634 ixgbevf_configure_msix(struct rte_eth_dev *dev)
5636 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
5637 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
5638 struct ixgbe_hw *hw =
5639 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5641 uint32_t vector_idx = IXGBE_MISC_VEC_ID;
5643 /* Configure VF other cause ivar */
5644 ixgbevf_set_ivar_map(hw, -1, 1, vector_idx);
5646 /* won't configure msix register if no mapping is done
5647 * between intr vector and event fd.
5649 if (!rte_intr_dp_is_en(intr_handle))
5652 /* Configure all RX queues of VF */
5653 for (q_idx = 0; q_idx < dev->data->nb_rx_queues; q_idx++) {
5654 /* Force all queue use vector 0,
5655 * as IXGBE_VF_MAXMSIVECOTR = 1
5657 ixgbevf_set_ivar_map(hw, 0, q_idx, vector_idx);
5658 intr_handle->intr_vec[q_idx] = vector_idx;
5663 * Sets up the hardware to properly generate MSI-X interrupts
5665 * board private structure
5668 ixgbe_configure_msix(struct rte_eth_dev *dev)
5670 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
5671 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
5672 struct ixgbe_hw *hw =
5673 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5674 uint32_t queue_id, base = IXGBE_MISC_VEC_ID;
5675 uint32_t vec = IXGBE_MISC_VEC_ID;
5679 /* won't configure msix register if no mapping is done
5680 * between intr vector and event fd
5682 if (!rte_intr_dp_is_en(intr_handle))
5685 if (rte_intr_allow_others(intr_handle))
5686 vec = base = IXGBE_RX_VEC_START;
5688 /* setup GPIE for MSI-x mode */
5689 gpie = IXGBE_READ_REG(hw, IXGBE_GPIE);
5690 gpie |= IXGBE_GPIE_MSIX_MODE | IXGBE_GPIE_PBA_SUPPORT |
5691 IXGBE_GPIE_OCD | IXGBE_GPIE_EIAME;
5692 /* auto clearing and auto setting corresponding bits in EIMS
5693 * when MSI-X interrupt is triggered
5695 if (hw->mac.type == ixgbe_mac_82598EB) {
5696 IXGBE_WRITE_REG(hw, IXGBE_EIAM, IXGBE_EICS_RTX_QUEUE);
5698 IXGBE_WRITE_REG(hw, IXGBE_EIAM_EX(0), 0xFFFFFFFF);
5699 IXGBE_WRITE_REG(hw, IXGBE_EIAM_EX(1), 0xFFFFFFFF);
5701 IXGBE_WRITE_REG(hw, IXGBE_GPIE, gpie);
5703 /* Populate the IVAR table and set the ITR values to the
5704 * corresponding register.
5706 for (queue_id = 0; queue_id < dev->data->nb_rx_queues;
5708 /* by default, 1:1 mapping */
5709 ixgbe_set_ivar_map(hw, 0, queue_id, vec);
5710 intr_handle->intr_vec[queue_id] = vec;
5711 if (vec < base + intr_handle->nb_efd - 1)
5715 switch (hw->mac.type) {
5716 case ixgbe_mac_82598EB:
5717 ixgbe_set_ivar_map(hw, -1, IXGBE_IVAR_OTHER_CAUSES_INDEX,
5720 case ixgbe_mac_82599EB:
5721 case ixgbe_mac_X540:
5722 ixgbe_set_ivar_map(hw, -1, 1, IXGBE_MISC_VEC_ID);
5727 IXGBE_WRITE_REG(hw, IXGBE_EITR(IXGBE_MISC_VEC_ID),
5728 IXGBE_MIN_INTER_INTERRUPT_INTERVAL_DEFAULT & 0xFFF);
5730 /* set up to autoclear timer, and the vectors */
5731 mask = IXGBE_EIMS_ENABLE_MASK;
5732 mask &= ~(IXGBE_EIMS_OTHER |
5733 IXGBE_EIMS_MAILBOX |
5736 IXGBE_WRITE_REG(hw, IXGBE_EIAC, mask);
5740 ixgbe_set_queue_rate_limit(struct rte_eth_dev *dev,
5741 uint16_t queue_idx, uint16_t tx_rate)
5743 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5744 uint32_t rf_dec, rf_int;
5746 uint16_t link_speed = dev->data->dev_link.link_speed;
5748 if (queue_idx >= hw->mac.max_tx_queues)
5752 /* Calculate the rate factor values to set */
5753 rf_int = (uint32_t)link_speed / (uint32_t)tx_rate;
5754 rf_dec = (uint32_t)link_speed % (uint32_t)tx_rate;
5755 rf_dec = (rf_dec << IXGBE_RTTBCNRC_RF_INT_SHIFT) / tx_rate;
5757 bcnrc_val = IXGBE_RTTBCNRC_RS_ENA;
5758 bcnrc_val |= ((rf_int << IXGBE_RTTBCNRC_RF_INT_SHIFT) &
5759 IXGBE_RTTBCNRC_RF_INT_MASK_M);
5760 bcnrc_val |= (rf_dec & IXGBE_RTTBCNRC_RF_DEC_MASK);
5766 * Set global transmit compensation time to the MMW_SIZE in RTTBCNRM
5767 * register. MMW_SIZE=0x014 if 9728-byte jumbo is supported, otherwise
5770 if ((dev->data->dev_conf.rxmode.jumbo_frame == 1) &&
5771 (dev->data->dev_conf.rxmode.max_rx_pkt_len >=
5772 IXGBE_MAX_JUMBO_FRAME_SIZE))
5773 IXGBE_WRITE_REG(hw, IXGBE_RTTBCNRM,
5774 IXGBE_MMW_SIZE_JUMBO_FRAME);
5776 IXGBE_WRITE_REG(hw, IXGBE_RTTBCNRM,
5777 IXGBE_MMW_SIZE_DEFAULT);
5779 /* Set RTTBCNRC of queue X */
5780 IXGBE_WRITE_REG(hw, IXGBE_RTTDQSEL, queue_idx);
5781 IXGBE_WRITE_REG(hw, IXGBE_RTTBCNRC, bcnrc_val);
5782 IXGBE_WRITE_FLUSH(hw);
5788 ixgbevf_add_mac_addr(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
5789 __attribute__((unused)) uint32_t index,
5790 __attribute__((unused)) uint32_t pool)
5792 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5796 * On a 82599 VF, adding again the same MAC addr is not an idempotent
5797 * operation. Trap this case to avoid exhausting the [very limited]
5798 * set of PF resources used to store VF MAC addresses.
5800 if (memcmp(hw->mac.perm_addr, mac_addr, sizeof(struct ether_addr)) == 0)
5802 diag = ixgbevf_set_uc_addr_vf(hw, 2, mac_addr->addr_bytes);
5804 PMD_DRV_LOG(ERR, "Unable to add MAC address "
5805 "%02x:%02x:%02x:%02x:%02x:%02x - diag=%d",
5806 mac_addr->addr_bytes[0],
5807 mac_addr->addr_bytes[1],
5808 mac_addr->addr_bytes[2],
5809 mac_addr->addr_bytes[3],
5810 mac_addr->addr_bytes[4],
5811 mac_addr->addr_bytes[5],
5817 ixgbevf_remove_mac_addr(struct rte_eth_dev *dev, uint32_t index)
5819 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5820 struct ether_addr *perm_addr = (struct ether_addr *) hw->mac.perm_addr;
5821 struct ether_addr *mac_addr;
5826 * The IXGBE_VF_SET_MACVLAN command of the ixgbe-pf driver does
5827 * not support the deletion of a given MAC address.
5828 * Instead, it imposes to delete all MAC addresses, then to add again
5829 * all MAC addresses with the exception of the one to be deleted.
5831 (void) ixgbevf_set_uc_addr_vf(hw, 0, NULL);
5834 * Add again all MAC addresses, with the exception of the deleted one
5835 * and of the permanent MAC address.
5837 for (i = 0, mac_addr = dev->data->mac_addrs;
5838 i < hw->mac.num_rar_entries; i++, mac_addr++) {
5839 /* Skip the deleted MAC address */
5842 /* Skip NULL MAC addresses */
5843 if (is_zero_ether_addr(mac_addr))
5845 /* Skip the permanent MAC address */
5846 if (memcmp(perm_addr, mac_addr, sizeof(struct ether_addr)) == 0)
5848 diag = ixgbevf_set_uc_addr_vf(hw, 2, mac_addr->addr_bytes);
5851 "Adding again MAC address "
5852 "%02x:%02x:%02x:%02x:%02x:%02x failed "
5854 mac_addr->addr_bytes[0],
5855 mac_addr->addr_bytes[1],
5856 mac_addr->addr_bytes[2],
5857 mac_addr->addr_bytes[3],
5858 mac_addr->addr_bytes[4],
5859 mac_addr->addr_bytes[5],
5865 ixgbevf_set_default_mac_addr(struct rte_eth_dev *dev, struct ether_addr *addr)
5867 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5869 hw->mac.ops.set_rar(hw, 0, (void *)addr, 0, 0);
5873 ixgbe_syn_filter_set(struct rte_eth_dev *dev,
5874 struct rte_eth_syn_filter *filter,
5877 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5878 struct ixgbe_filter_info *filter_info =
5879 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
5883 if (filter->queue >= IXGBE_MAX_RX_QUEUE_NUM)
5886 syn_info = filter_info->syn_info;
5889 if (syn_info & IXGBE_SYN_FILTER_ENABLE)
5891 synqf = (uint32_t)(((filter->queue << IXGBE_SYN_FILTER_QUEUE_SHIFT) &
5892 IXGBE_SYN_FILTER_QUEUE) | IXGBE_SYN_FILTER_ENABLE);
5894 if (filter->hig_pri)
5895 synqf |= IXGBE_SYN_FILTER_SYNQFP;
5897 synqf &= ~IXGBE_SYN_FILTER_SYNQFP;
5899 synqf = IXGBE_READ_REG(hw, IXGBE_SYNQF);
5900 if (!(syn_info & IXGBE_SYN_FILTER_ENABLE))
5902 synqf &= ~(IXGBE_SYN_FILTER_QUEUE | IXGBE_SYN_FILTER_ENABLE);
5905 filter_info->syn_info = synqf;
5906 IXGBE_WRITE_REG(hw, IXGBE_SYNQF, synqf);
5907 IXGBE_WRITE_FLUSH(hw);
5912 ixgbe_syn_filter_get(struct rte_eth_dev *dev,
5913 struct rte_eth_syn_filter *filter)
5915 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5916 uint32_t synqf = IXGBE_READ_REG(hw, IXGBE_SYNQF);
5918 if (synqf & IXGBE_SYN_FILTER_ENABLE) {
5919 filter->hig_pri = (synqf & IXGBE_SYN_FILTER_SYNQFP) ? 1 : 0;
5920 filter->queue = (uint16_t)((synqf & IXGBE_SYN_FILTER_QUEUE) >> 1);
5927 ixgbe_syn_filter_handle(struct rte_eth_dev *dev,
5928 enum rte_filter_op filter_op,
5931 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5934 MAC_TYPE_FILTER_SUP(hw->mac.type);
5936 if (filter_op == RTE_ETH_FILTER_NOP)
5940 PMD_DRV_LOG(ERR, "arg shouldn't be NULL for operation %u",
5945 switch (filter_op) {
5946 case RTE_ETH_FILTER_ADD:
5947 ret = ixgbe_syn_filter_set(dev,
5948 (struct rte_eth_syn_filter *)arg,
5951 case RTE_ETH_FILTER_DELETE:
5952 ret = ixgbe_syn_filter_set(dev,
5953 (struct rte_eth_syn_filter *)arg,
5956 case RTE_ETH_FILTER_GET:
5957 ret = ixgbe_syn_filter_get(dev,
5958 (struct rte_eth_syn_filter *)arg);
5961 PMD_DRV_LOG(ERR, "unsupported operation %u", filter_op);
5970 static inline enum ixgbe_5tuple_protocol
5971 convert_protocol_type(uint8_t protocol_value)
5973 if (protocol_value == IPPROTO_TCP)
5974 return IXGBE_FILTER_PROTOCOL_TCP;
5975 else if (protocol_value == IPPROTO_UDP)
5976 return IXGBE_FILTER_PROTOCOL_UDP;
5977 else if (protocol_value == IPPROTO_SCTP)
5978 return IXGBE_FILTER_PROTOCOL_SCTP;
5980 return IXGBE_FILTER_PROTOCOL_NONE;
5983 /* inject a 5-tuple filter to HW */
5985 ixgbe_inject_5tuple_filter(struct rte_eth_dev *dev,
5986 struct ixgbe_5tuple_filter *filter)
5988 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5990 uint32_t ftqf, sdpqf;
5991 uint32_t l34timir = 0;
5992 uint8_t mask = 0xff;
5996 sdpqf = (uint32_t)(filter->filter_info.dst_port <<
5997 IXGBE_SDPQF_DSTPORT_SHIFT);
5998 sdpqf = sdpqf | (filter->filter_info.src_port & IXGBE_SDPQF_SRCPORT);
6000 ftqf = (uint32_t)(filter->filter_info.proto &
6001 IXGBE_FTQF_PROTOCOL_MASK);
6002 ftqf |= (uint32_t)((filter->filter_info.priority &
6003 IXGBE_FTQF_PRIORITY_MASK) << IXGBE_FTQF_PRIORITY_SHIFT);
6004 if (filter->filter_info.src_ip_mask == 0) /* 0 means compare. */
6005 mask &= IXGBE_FTQF_SOURCE_ADDR_MASK;
6006 if (filter->filter_info.dst_ip_mask == 0)
6007 mask &= IXGBE_FTQF_DEST_ADDR_MASK;
6008 if (filter->filter_info.src_port_mask == 0)
6009 mask &= IXGBE_FTQF_SOURCE_PORT_MASK;
6010 if (filter->filter_info.dst_port_mask == 0)
6011 mask &= IXGBE_FTQF_DEST_PORT_MASK;
6012 if (filter->filter_info.proto_mask == 0)
6013 mask &= IXGBE_FTQF_PROTOCOL_COMP_MASK;
6014 ftqf |= mask << IXGBE_FTQF_5TUPLE_MASK_SHIFT;
6015 ftqf |= IXGBE_FTQF_POOL_MASK_EN;
6016 ftqf |= IXGBE_FTQF_QUEUE_ENABLE;
6018 IXGBE_WRITE_REG(hw, IXGBE_DAQF(i), filter->filter_info.dst_ip);
6019 IXGBE_WRITE_REG(hw, IXGBE_SAQF(i), filter->filter_info.src_ip);
6020 IXGBE_WRITE_REG(hw, IXGBE_SDPQF(i), sdpqf);
6021 IXGBE_WRITE_REG(hw, IXGBE_FTQF(i), ftqf);
6023 l34timir |= IXGBE_L34T_IMIR_RESERVE;
6024 l34timir |= (uint32_t)(filter->queue <<
6025 IXGBE_L34T_IMIR_QUEUE_SHIFT);
6026 IXGBE_WRITE_REG(hw, IXGBE_L34T_IMIR(i), l34timir);
6030 * add a 5tuple filter
6033 * dev: Pointer to struct rte_eth_dev.
6034 * index: the index the filter allocates.
6035 * filter: ponter to the filter that will be added.
6036 * rx_queue: the queue id the filter assigned to.
6039 * - On success, zero.
6040 * - On failure, a negative value.
6043 ixgbe_add_5tuple_filter(struct rte_eth_dev *dev,
6044 struct ixgbe_5tuple_filter *filter)
6046 struct ixgbe_filter_info *filter_info =
6047 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6051 * look for an unused 5tuple filter index,
6052 * and insert the filter to list.
6054 for (i = 0; i < IXGBE_MAX_FTQF_FILTERS; i++) {
6055 idx = i / (sizeof(uint32_t) * NBBY);
6056 shift = i % (sizeof(uint32_t) * NBBY);
6057 if (!(filter_info->fivetuple_mask[idx] & (1 << shift))) {
6058 filter_info->fivetuple_mask[idx] |= 1 << shift;
6060 TAILQ_INSERT_TAIL(&filter_info->fivetuple_list,
6066 if (i >= IXGBE_MAX_FTQF_FILTERS) {
6067 PMD_DRV_LOG(ERR, "5tuple filters are full.");
6071 ixgbe_inject_5tuple_filter(dev, filter);
6077 * remove a 5tuple filter
6080 * dev: Pointer to struct rte_eth_dev.
6081 * filter: the pointer of the filter will be removed.
6084 ixgbe_remove_5tuple_filter(struct rte_eth_dev *dev,
6085 struct ixgbe_5tuple_filter *filter)
6087 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6088 struct ixgbe_filter_info *filter_info =
6089 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6090 uint16_t index = filter->index;
6092 filter_info->fivetuple_mask[index / (sizeof(uint32_t) * NBBY)] &=
6093 ~(1 << (index % (sizeof(uint32_t) * NBBY)));
6094 TAILQ_REMOVE(&filter_info->fivetuple_list, filter, entries);
6097 IXGBE_WRITE_REG(hw, IXGBE_DAQF(index), 0);
6098 IXGBE_WRITE_REG(hw, IXGBE_SAQF(index), 0);
6099 IXGBE_WRITE_REG(hw, IXGBE_SDPQF(index), 0);
6100 IXGBE_WRITE_REG(hw, IXGBE_FTQF(index), 0);
6101 IXGBE_WRITE_REG(hw, IXGBE_L34T_IMIR(index), 0);
6105 ixgbevf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
6107 struct ixgbe_hw *hw;
6108 uint32_t max_frame = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
6109 struct rte_eth_rxmode *rx_conf = &dev->data->dev_conf.rxmode;
6111 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6113 if ((mtu < ETHER_MIN_MTU) || (max_frame > ETHER_MAX_JUMBO_FRAME_LEN))
6116 /* refuse mtu that requires the support of scattered packets when this
6117 * feature has not been enabled before.
6119 if (!rx_conf->enable_scatter &&
6120 (max_frame + 2 * IXGBE_VLAN_TAG_SIZE >
6121 dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM))
6125 * When supported by the underlying PF driver, use the IXGBE_VF_SET_MTU
6126 * request of the version 2.0 of the mailbox API.
6127 * For now, use the IXGBE_VF_SET_LPE request of the version 1.0
6128 * of the mailbox API.
6129 * This call to IXGBE_SET_LPE action won't work with ixgbe pf drivers
6130 * prior to 3.11.33 which contains the following change:
6131 * "ixgbe: Enable jumbo frames support w/ SR-IOV"
6133 ixgbevf_rlpml_set_vf(hw, max_frame);
6135 /* update max frame size */
6136 dev->data->dev_conf.rxmode.max_rx_pkt_len = max_frame;
6140 static inline struct ixgbe_5tuple_filter *
6141 ixgbe_5tuple_filter_lookup(struct ixgbe_5tuple_filter_list *filter_list,
6142 struct ixgbe_5tuple_filter_info *key)
6144 struct ixgbe_5tuple_filter *it;
6146 TAILQ_FOREACH(it, filter_list, entries) {
6147 if (memcmp(key, &it->filter_info,
6148 sizeof(struct ixgbe_5tuple_filter_info)) == 0) {
6155 /* translate elements in struct rte_eth_ntuple_filter to struct ixgbe_5tuple_filter_info*/
6157 ntuple_filter_to_5tuple(struct rte_eth_ntuple_filter *filter,
6158 struct ixgbe_5tuple_filter_info *filter_info)
6160 if (filter->queue >= IXGBE_MAX_RX_QUEUE_NUM ||
6161 filter->priority > IXGBE_5TUPLE_MAX_PRI ||
6162 filter->priority < IXGBE_5TUPLE_MIN_PRI)
6165 switch (filter->dst_ip_mask) {
6167 filter_info->dst_ip_mask = 0;
6168 filter_info->dst_ip = filter->dst_ip;
6171 filter_info->dst_ip_mask = 1;
6174 PMD_DRV_LOG(ERR, "invalid dst_ip mask.");
6178 switch (filter->src_ip_mask) {
6180 filter_info->src_ip_mask = 0;
6181 filter_info->src_ip = filter->src_ip;
6184 filter_info->src_ip_mask = 1;
6187 PMD_DRV_LOG(ERR, "invalid src_ip mask.");
6191 switch (filter->dst_port_mask) {
6193 filter_info->dst_port_mask = 0;
6194 filter_info->dst_port = filter->dst_port;
6197 filter_info->dst_port_mask = 1;
6200 PMD_DRV_LOG(ERR, "invalid dst_port mask.");
6204 switch (filter->src_port_mask) {
6206 filter_info->src_port_mask = 0;
6207 filter_info->src_port = filter->src_port;
6210 filter_info->src_port_mask = 1;
6213 PMD_DRV_LOG(ERR, "invalid src_port mask.");
6217 switch (filter->proto_mask) {
6219 filter_info->proto_mask = 0;
6220 filter_info->proto =
6221 convert_protocol_type(filter->proto);
6224 filter_info->proto_mask = 1;
6227 PMD_DRV_LOG(ERR, "invalid protocol mask.");
6231 filter_info->priority = (uint8_t)filter->priority;
6236 * add or delete a ntuple filter
6239 * dev: Pointer to struct rte_eth_dev.
6240 * ntuple_filter: Pointer to struct rte_eth_ntuple_filter
6241 * add: if true, add filter, if false, remove filter
6244 * - On success, zero.
6245 * - On failure, a negative value.
6248 ixgbe_add_del_ntuple_filter(struct rte_eth_dev *dev,
6249 struct rte_eth_ntuple_filter *ntuple_filter,
6252 struct ixgbe_filter_info *filter_info =
6253 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6254 struct ixgbe_5tuple_filter_info filter_5tuple;
6255 struct ixgbe_5tuple_filter *filter;
6258 if (ntuple_filter->flags != RTE_5TUPLE_FLAGS) {
6259 PMD_DRV_LOG(ERR, "only 5tuple is supported.");
6263 memset(&filter_5tuple, 0, sizeof(struct ixgbe_5tuple_filter_info));
6264 ret = ntuple_filter_to_5tuple(ntuple_filter, &filter_5tuple);
6268 filter = ixgbe_5tuple_filter_lookup(&filter_info->fivetuple_list,
6270 if (filter != NULL && add) {
6271 PMD_DRV_LOG(ERR, "filter exists.");
6274 if (filter == NULL && !add) {
6275 PMD_DRV_LOG(ERR, "filter doesn't exist.");
6280 filter = rte_zmalloc("ixgbe_5tuple_filter",
6281 sizeof(struct ixgbe_5tuple_filter), 0);
6284 (void)rte_memcpy(&filter->filter_info,
6286 sizeof(struct ixgbe_5tuple_filter_info));
6287 filter->queue = ntuple_filter->queue;
6288 ret = ixgbe_add_5tuple_filter(dev, filter);
6294 ixgbe_remove_5tuple_filter(dev, filter);
6300 * get a ntuple filter
6303 * dev: Pointer to struct rte_eth_dev.
6304 * ntuple_filter: Pointer to struct rte_eth_ntuple_filter
6307 * - On success, zero.
6308 * - On failure, a negative value.
6311 ixgbe_get_ntuple_filter(struct rte_eth_dev *dev,
6312 struct rte_eth_ntuple_filter *ntuple_filter)
6314 struct ixgbe_filter_info *filter_info =
6315 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6316 struct ixgbe_5tuple_filter_info filter_5tuple;
6317 struct ixgbe_5tuple_filter *filter;
6320 if (ntuple_filter->flags != RTE_5TUPLE_FLAGS) {
6321 PMD_DRV_LOG(ERR, "only 5tuple is supported.");
6325 memset(&filter_5tuple, 0, sizeof(struct ixgbe_5tuple_filter_info));
6326 ret = ntuple_filter_to_5tuple(ntuple_filter, &filter_5tuple);
6330 filter = ixgbe_5tuple_filter_lookup(&filter_info->fivetuple_list,
6332 if (filter == NULL) {
6333 PMD_DRV_LOG(ERR, "filter doesn't exist.");
6336 ntuple_filter->queue = filter->queue;
6341 * ixgbe_ntuple_filter_handle - Handle operations for ntuple filter.
6342 * @dev: pointer to rte_eth_dev structure
6343 * @filter_op:operation will be taken.
6344 * @arg: a pointer to specific structure corresponding to the filter_op
6347 * - On success, zero.
6348 * - On failure, a negative value.
6351 ixgbe_ntuple_filter_handle(struct rte_eth_dev *dev,
6352 enum rte_filter_op filter_op,
6355 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6358 MAC_TYPE_FILTER_SUP_EXT(hw->mac.type);
6360 if (filter_op == RTE_ETH_FILTER_NOP)
6364 PMD_DRV_LOG(ERR, "arg shouldn't be NULL for operation %u.",
6369 switch (filter_op) {
6370 case RTE_ETH_FILTER_ADD:
6371 ret = ixgbe_add_del_ntuple_filter(dev,
6372 (struct rte_eth_ntuple_filter *)arg,
6375 case RTE_ETH_FILTER_DELETE:
6376 ret = ixgbe_add_del_ntuple_filter(dev,
6377 (struct rte_eth_ntuple_filter *)arg,
6380 case RTE_ETH_FILTER_GET:
6381 ret = ixgbe_get_ntuple_filter(dev,
6382 (struct rte_eth_ntuple_filter *)arg);
6385 PMD_DRV_LOG(ERR, "unsupported operation %u.", filter_op);
6393 ixgbe_add_del_ethertype_filter(struct rte_eth_dev *dev,
6394 struct rte_eth_ethertype_filter *filter,
6397 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6398 struct ixgbe_filter_info *filter_info =
6399 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6403 struct ixgbe_ethertype_filter ethertype_filter;
6405 if (filter->queue >= IXGBE_MAX_RX_QUEUE_NUM)
6408 if (filter->ether_type == ETHER_TYPE_IPv4 ||
6409 filter->ether_type == ETHER_TYPE_IPv6) {
6410 PMD_DRV_LOG(ERR, "unsupported ether_type(0x%04x) in"
6411 " ethertype filter.", filter->ether_type);
6415 if (filter->flags & RTE_ETHTYPE_FLAGS_MAC) {
6416 PMD_DRV_LOG(ERR, "mac compare is unsupported.");
6419 if (filter->flags & RTE_ETHTYPE_FLAGS_DROP) {
6420 PMD_DRV_LOG(ERR, "drop option is unsupported.");
6424 ret = ixgbe_ethertype_filter_lookup(filter_info, filter->ether_type);
6425 if (ret >= 0 && add) {
6426 PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter exists.",
6427 filter->ether_type);
6430 if (ret < 0 && !add) {
6431 PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter doesn't exist.",
6432 filter->ether_type);
6437 etqf = IXGBE_ETQF_FILTER_EN;
6438 etqf |= (uint32_t)filter->ether_type;
6439 etqs |= (uint32_t)((filter->queue <<
6440 IXGBE_ETQS_RX_QUEUE_SHIFT) &
6441 IXGBE_ETQS_RX_QUEUE);
6442 etqs |= IXGBE_ETQS_QUEUE_EN;
6444 ethertype_filter.ethertype = filter->ether_type;
6445 ethertype_filter.etqf = etqf;
6446 ethertype_filter.etqs = etqs;
6447 ethertype_filter.conf = FALSE;
6448 ret = ixgbe_ethertype_filter_insert(filter_info,
6451 PMD_DRV_LOG(ERR, "ethertype filters are full.");
6455 ret = ixgbe_ethertype_filter_remove(filter_info, (uint8_t)ret);
6459 IXGBE_WRITE_REG(hw, IXGBE_ETQF(ret), etqf);
6460 IXGBE_WRITE_REG(hw, IXGBE_ETQS(ret), etqs);
6461 IXGBE_WRITE_FLUSH(hw);
6467 ixgbe_get_ethertype_filter(struct rte_eth_dev *dev,
6468 struct rte_eth_ethertype_filter *filter)
6470 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6471 struct ixgbe_filter_info *filter_info =
6472 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6473 uint32_t etqf, etqs;
6476 ret = ixgbe_ethertype_filter_lookup(filter_info, filter->ether_type);
6478 PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter doesn't exist.",
6479 filter->ether_type);
6483 etqf = IXGBE_READ_REG(hw, IXGBE_ETQF(ret));
6484 if (etqf & IXGBE_ETQF_FILTER_EN) {
6485 etqs = IXGBE_READ_REG(hw, IXGBE_ETQS(ret));
6486 filter->ether_type = etqf & IXGBE_ETQF_ETHERTYPE;
6488 filter->queue = (etqs & IXGBE_ETQS_RX_QUEUE) >>
6489 IXGBE_ETQS_RX_QUEUE_SHIFT;
6496 * ixgbe_ethertype_filter_handle - Handle operations for ethertype filter.
6497 * @dev: pointer to rte_eth_dev structure
6498 * @filter_op:operation will be taken.
6499 * @arg: a pointer to specific structure corresponding to the filter_op
6502 ixgbe_ethertype_filter_handle(struct rte_eth_dev *dev,
6503 enum rte_filter_op filter_op,
6506 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6509 MAC_TYPE_FILTER_SUP(hw->mac.type);
6511 if (filter_op == RTE_ETH_FILTER_NOP)
6515 PMD_DRV_LOG(ERR, "arg shouldn't be NULL for operation %u.",
6520 switch (filter_op) {
6521 case RTE_ETH_FILTER_ADD:
6522 ret = ixgbe_add_del_ethertype_filter(dev,
6523 (struct rte_eth_ethertype_filter *)arg,
6526 case RTE_ETH_FILTER_DELETE:
6527 ret = ixgbe_add_del_ethertype_filter(dev,
6528 (struct rte_eth_ethertype_filter *)arg,
6531 case RTE_ETH_FILTER_GET:
6532 ret = ixgbe_get_ethertype_filter(dev,
6533 (struct rte_eth_ethertype_filter *)arg);
6536 PMD_DRV_LOG(ERR, "unsupported operation %u.", filter_op);
6544 ixgbe_dev_filter_ctrl(struct rte_eth_dev *dev,
6545 enum rte_filter_type filter_type,
6546 enum rte_filter_op filter_op,
6551 switch (filter_type) {
6552 case RTE_ETH_FILTER_NTUPLE:
6553 ret = ixgbe_ntuple_filter_handle(dev, filter_op, arg);
6555 case RTE_ETH_FILTER_ETHERTYPE:
6556 ret = ixgbe_ethertype_filter_handle(dev, filter_op, arg);
6558 case RTE_ETH_FILTER_SYN:
6559 ret = ixgbe_syn_filter_handle(dev, filter_op, arg);
6561 case RTE_ETH_FILTER_FDIR:
6562 ret = ixgbe_fdir_ctrl_func(dev, filter_op, arg);
6564 case RTE_ETH_FILTER_L2_TUNNEL:
6565 ret = ixgbe_dev_l2_tunnel_filter_handle(dev, filter_op, arg);
6567 case RTE_ETH_FILTER_GENERIC:
6568 if (filter_op != RTE_ETH_FILTER_GET)
6570 *(const void **)arg = &ixgbe_flow_ops;
6573 PMD_DRV_LOG(WARNING, "Filter type (%d) not supported",
6583 ixgbe_dev_addr_list_itr(__attribute__((unused)) struct ixgbe_hw *hw,
6584 u8 **mc_addr_ptr, u32 *vmdq)
6589 mc_addr = *mc_addr_ptr;
6590 *mc_addr_ptr = (mc_addr + sizeof(struct ether_addr));
6595 ixgbe_dev_set_mc_addr_list(struct rte_eth_dev *dev,
6596 struct ether_addr *mc_addr_set,
6597 uint32_t nb_mc_addr)
6599 struct ixgbe_hw *hw;
6602 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6603 mc_addr_list = (u8 *)mc_addr_set;
6604 return ixgbe_update_mc_addr_list(hw, mc_addr_list, nb_mc_addr,
6605 ixgbe_dev_addr_list_itr, TRUE);
6609 ixgbe_read_systime_cyclecounter(struct rte_eth_dev *dev)
6611 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6612 uint64_t systime_cycles;
6614 switch (hw->mac.type) {
6615 case ixgbe_mac_X550:
6616 case ixgbe_mac_X550EM_x:
6617 case ixgbe_mac_X550EM_a:
6618 /* SYSTIMEL stores ns and SYSTIMEH stores seconds. */
6619 systime_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_SYSTIML);
6620 systime_cycles += (uint64_t)IXGBE_READ_REG(hw, IXGBE_SYSTIMH)
6624 systime_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_SYSTIML);
6625 systime_cycles |= (uint64_t)IXGBE_READ_REG(hw, IXGBE_SYSTIMH)
6629 return systime_cycles;
6633 ixgbe_read_rx_tstamp_cyclecounter(struct rte_eth_dev *dev)
6635 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6636 uint64_t rx_tstamp_cycles;
6638 switch (hw->mac.type) {
6639 case ixgbe_mac_X550:
6640 case ixgbe_mac_X550EM_x:
6641 case ixgbe_mac_X550EM_a:
6642 /* RXSTMPL stores ns and RXSTMPH stores seconds. */
6643 rx_tstamp_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_RXSTMPL);
6644 rx_tstamp_cycles += (uint64_t)IXGBE_READ_REG(hw, IXGBE_RXSTMPH)
6648 /* RXSTMPL stores ns and RXSTMPH stores seconds. */
6649 rx_tstamp_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_RXSTMPL);
6650 rx_tstamp_cycles |= (uint64_t)IXGBE_READ_REG(hw, IXGBE_RXSTMPH)
6654 return rx_tstamp_cycles;
6658 ixgbe_read_tx_tstamp_cyclecounter(struct rte_eth_dev *dev)
6660 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6661 uint64_t tx_tstamp_cycles;
6663 switch (hw->mac.type) {
6664 case ixgbe_mac_X550:
6665 case ixgbe_mac_X550EM_x:
6666 case ixgbe_mac_X550EM_a:
6667 /* TXSTMPL stores ns and TXSTMPH stores seconds. */
6668 tx_tstamp_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_TXSTMPL);
6669 tx_tstamp_cycles += (uint64_t)IXGBE_READ_REG(hw, IXGBE_TXSTMPH)
6673 /* TXSTMPL stores ns and TXSTMPH stores seconds. */
6674 tx_tstamp_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_TXSTMPL);
6675 tx_tstamp_cycles |= (uint64_t)IXGBE_READ_REG(hw, IXGBE_TXSTMPH)
6679 return tx_tstamp_cycles;
6683 ixgbe_start_timecounters(struct rte_eth_dev *dev)
6685 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6686 struct ixgbe_adapter *adapter =
6687 (struct ixgbe_adapter *)dev->data->dev_private;
6688 struct rte_eth_link link;
6689 uint32_t incval = 0;
6692 /* Get current link speed. */
6693 memset(&link, 0, sizeof(link));
6694 ixgbe_dev_link_update(dev, 1);
6695 rte_ixgbe_dev_atomic_read_link_status(dev, &link);
6697 switch (link.link_speed) {
6698 case ETH_SPEED_NUM_100M:
6699 incval = IXGBE_INCVAL_100;
6700 shift = IXGBE_INCVAL_SHIFT_100;
6702 case ETH_SPEED_NUM_1G:
6703 incval = IXGBE_INCVAL_1GB;
6704 shift = IXGBE_INCVAL_SHIFT_1GB;
6706 case ETH_SPEED_NUM_10G:
6708 incval = IXGBE_INCVAL_10GB;
6709 shift = IXGBE_INCVAL_SHIFT_10GB;
6713 switch (hw->mac.type) {
6714 case ixgbe_mac_X550:
6715 case ixgbe_mac_X550EM_x:
6716 case ixgbe_mac_X550EM_a:
6717 /* Independent of link speed. */
6719 /* Cycles read will be interpreted as ns. */
6722 case ixgbe_mac_X540:
6723 IXGBE_WRITE_REG(hw, IXGBE_TIMINCA, incval);
6725 case ixgbe_mac_82599EB:
6726 incval >>= IXGBE_INCVAL_SHIFT_82599;
6727 shift -= IXGBE_INCVAL_SHIFT_82599;
6728 IXGBE_WRITE_REG(hw, IXGBE_TIMINCA,
6729 (1 << IXGBE_INCPER_SHIFT_82599) | incval);
6732 /* Not supported. */
6736 memset(&adapter->systime_tc, 0, sizeof(struct rte_timecounter));
6737 memset(&adapter->rx_tstamp_tc, 0, sizeof(struct rte_timecounter));
6738 memset(&adapter->tx_tstamp_tc, 0, sizeof(struct rte_timecounter));
6740 adapter->systime_tc.cc_mask = IXGBE_CYCLECOUNTER_MASK;
6741 adapter->systime_tc.cc_shift = shift;
6742 adapter->systime_tc.nsec_mask = (1ULL << shift) - 1;
6744 adapter->rx_tstamp_tc.cc_mask = IXGBE_CYCLECOUNTER_MASK;
6745 adapter->rx_tstamp_tc.cc_shift = shift;
6746 adapter->rx_tstamp_tc.nsec_mask = (1ULL << shift) - 1;
6748 adapter->tx_tstamp_tc.cc_mask = IXGBE_CYCLECOUNTER_MASK;
6749 adapter->tx_tstamp_tc.cc_shift = shift;
6750 adapter->tx_tstamp_tc.nsec_mask = (1ULL << shift) - 1;
6754 ixgbe_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta)
6756 struct ixgbe_adapter *adapter =
6757 (struct ixgbe_adapter *)dev->data->dev_private;
6759 adapter->systime_tc.nsec += delta;
6760 adapter->rx_tstamp_tc.nsec += delta;
6761 adapter->tx_tstamp_tc.nsec += delta;
6767 ixgbe_timesync_write_time(struct rte_eth_dev *dev, const struct timespec *ts)
6770 struct ixgbe_adapter *adapter =
6771 (struct ixgbe_adapter *)dev->data->dev_private;
6773 ns = rte_timespec_to_ns(ts);
6774 /* Set the timecounters to a new value. */
6775 adapter->systime_tc.nsec = ns;
6776 adapter->rx_tstamp_tc.nsec = ns;
6777 adapter->tx_tstamp_tc.nsec = ns;
6783 ixgbe_timesync_read_time(struct rte_eth_dev *dev, struct timespec *ts)
6785 uint64_t ns, systime_cycles;
6786 struct ixgbe_adapter *adapter =
6787 (struct ixgbe_adapter *)dev->data->dev_private;
6789 systime_cycles = ixgbe_read_systime_cyclecounter(dev);
6790 ns = rte_timecounter_update(&adapter->systime_tc, systime_cycles);
6791 *ts = rte_ns_to_timespec(ns);
6797 ixgbe_timesync_enable(struct rte_eth_dev *dev)
6799 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6803 /* Stop the timesync system time. */
6804 IXGBE_WRITE_REG(hw, IXGBE_TIMINCA, 0x0);
6805 /* Reset the timesync system time value. */
6806 IXGBE_WRITE_REG(hw, IXGBE_SYSTIML, 0x0);
6807 IXGBE_WRITE_REG(hw, IXGBE_SYSTIMH, 0x0);
6809 /* Enable system time for platforms where it isn't on by default. */
6810 tsauxc = IXGBE_READ_REG(hw, IXGBE_TSAUXC);
6811 tsauxc &= ~IXGBE_TSAUXC_DISABLE_SYSTIME;
6812 IXGBE_WRITE_REG(hw, IXGBE_TSAUXC, tsauxc);
6814 ixgbe_start_timecounters(dev);
6816 /* Enable L2 filtering of IEEE1588/802.1AS Ethernet frame types. */
6817 IXGBE_WRITE_REG(hw, IXGBE_ETQF(IXGBE_ETQF_FILTER_1588),
6819 IXGBE_ETQF_FILTER_EN |
6822 /* Enable timestamping of received PTP packets. */
6823 tsync_ctl = IXGBE_READ_REG(hw, IXGBE_TSYNCRXCTL);
6824 tsync_ctl |= IXGBE_TSYNCRXCTL_ENABLED;
6825 IXGBE_WRITE_REG(hw, IXGBE_TSYNCRXCTL, tsync_ctl);
6827 /* Enable timestamping of transmitted PTP packets. */
6828 tsync_ctl = IXGBE_READ_REG(hw, IXGBE_TSYNCTXCTL);
6829 tsync_ctl |= IXGBE_TSYNCTXCTL_ENABLED;
6830 IXGBE_WRITE_REG(hw, IXGBE_TSYNCTXCTL, tsync_ctl);
6832 IXGBE_WRITE_FLUSH(hw);
6838 ixgbe_timesync_disable(struct rte_eth_dev *dev)
6840 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6843 /* Disable timestamping of transmitted PTP packets. */
6844 tsync_ctl = IXGBE_READ_REG(hw, IXGBE_TSYNCTXCTL);
6845 tsync_ctl &= ~IXGBE_TSYNCTXCTL_ENABLED;
6846 IXGBE_WRITE_REG(hw, IXGBE_TSYNCTXCTL, tsync_ctl);
6848 /* Disable timestamping of received PTP packets. */
6849 tsync_ctl = IXGBE_READ_REG(hw, IXGBE_TSYNCRXCTL);
6850 tsync_ctl &= ~IXGBE_TSYNCRXCTL_ENABLED;
6851 IXGBE_WRITE_REG(hw, IXGBE_TSYNCRXCTL, tsync_ctl);
6853 /* Disable L2 filtering of IEEE1588/802.1AS Ethernet frame types. */
6854 IXGBE_WRITE_REG(hw, IXGBE_ETQF(IXGBE_ETQF_FILTER_1588), 0);
6856 /* Stop incrementating the System Time registers. */
6857 IXGBE_WRITE_REG(hw, IXGBE_TIMINCA, 0);
6863 ixgbe_timesync_read_rx_timestamp(struct rte_eth_dev *dev,
6864 struct timespec *timestamp,
6865 uint32_t flags __rte_unused)
6867 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6868 struct ixgbe_adapter *adapter =
6869 (struct ixgbe_adapter *)dev->data->dev_private;
6870 uint32_t tsync_rxctl;
6871 uint64_t rx_tstamp_cycles;
6874 tsync_rxctl = IXGBE_READ_REG(hw, IXGBE_TSYNCRXCTL);
6875 if ((tsync_rxctl & IXGBE_TSYNCRXCTL_VALID) == 0)
6878 rx_tstamp_cycles = ixgbe_read_rx_tstamp_cyclecounter(dev);
6879 ns = rte_timecounter_update(&adapter->rx_tstamp_tc, rx_tstamp_cycles);
6880 *timestamp = rte_ns_to_timespec(ns);
6886 ixgbe_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
6887 struct timespec *timestamp)
6889 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6890 struct ixgbe_adapter *adapter =
6891 (struct ixgbe_adapter *)dev->data->dev_private;
6892 uint32_t tsync_txctl;
6893 uint64_t tx_tstamp_cycles;
6896 tsync_txctl = IXGBE_READ_REG(hw, IXGBE_TSYNCTXCTL);
6897 if ((tsync_txctl & IXGBE_TSYNCTXCTL_VALID) == 0)
6900 tx_tstamp_cycles = ixgbe_read_tx_tstamp_cyclecounter(dev);
6901 ns = rte_timecounter_update(&adapter->tx_tstamp_tc, tx_tstamp_cycles);
6902 *timestamp = rte_ns_to_timespec(ns);
6908 ixgbe_get_reg_length(struct rte_eth_dev *dev)
6910 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6913 const struct reg_info *reg_group;
6914 const struct reg_info **reg_set = (hw->mac.type == ixgbe_mac_82598EB) ?
6915 ixgbe_regs_mac_82598EB : ixgbe_regs_others;
6917 while ((reg_group = reg_set[g_ind++]))
6918 count += ixgbe_regs_group_count(reg_group);
6924 ixgbevf_get_reg_length(struct rte_eth_dev *dev __rte_unused)
6928 const struct reg_info *reg_group;
6930 while ((reg_group = ixgbevf_regs[g_ind++]))
6931 count += ixgbe_regs_group_count(reg_group);
6937 ixgbe_get_regs(struct rte_eth_dev *dev,
6938 struct rte_dev_reg_info *regs)
6940 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6941 uint32_t *data = regs->data;
6944 const struct reg_info *reg_group;
6945 const struct reg_info **reg_set = (hw->mac.type == ixgbe_mac_82598EB) ?
6946 ixgbe_regs_mac_82598EB : ixgbe_regs_others;
6949 regs->length = ixgbe_get_reg_length(dev);
6950 regs->width = sizeof(uint32_t);
6954 /* Support only full register dump */
6955 if ((regs->length == 0) ||
6956 (regs->length == (uint32_t)ixgbe_get_reg_length(dev))) {
6957 regs->version = hw->mac.type << 24 | hw->revision_id << 16 |
6959 while ((reg_group = reg_set[g_ind++]))
6960 count += ixgbe_read_regs_group(dev, &data[count],
6969 ixgbevf_get_regs(struct rte_eth_dev *dev,
6970 struct rte_dev_reg_info *regs)
6972 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6973 uint32_t *data = regs->data;
6976 const struct reg_info *reg_group;
6979 regs->length = ixgbevf_get_reg_length(dev);
6980 regs->width = sizeof(uint32_t);
6984 /* Support only full register dump */
6985 if ((regs->length == 0) ||
6986 (regs->length == (uint32_t)ixgbevf_get_reg_length(dev))) {
6987 regs->version = hw->mac.type << 24 | hw->revision_id << 16 |
6989 while ((reg_group = ixgbevf_regs[g_ind++]))
6990 count += ixgbe_read_regs_group(dev, &data[count],
6999 ixgbe_get_eeprom_length(struct rte_eth_dev *dev)
7001 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7003 /* Return unit is byte count */
7004 return hw->eeprom.word_size * 2;
7008 ixgbe_get_eeprom(struct rte_eth_dev *dev,
7009 struct rte_dev_eeprom_info *in_eeprom)
7011 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7012 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
7013 uint16_t *data = in_eeprom->data;
7016 first = in_eeprom->offset >> 1;
7017 length = in_eeprom->length >> 1;
7018 if ((first > hw->eeprom.word_size) ||
7019 ((first + length) > hw->eeprom.word_size))
7022 in_eeprom->magic = hw->vendor_id | (hw->device_id << 16);
7024 return eeprom->ops.read_buffer(hw, first, length, data);
7028 ixgbe_set_eeprom(struct rte_eth_dev *dev,
7029 struct rte_dev_eeprom_info *in_eeprom)
7031 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7032 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
7033 uint16_t *data = in_eeprom->data;
7036 first = in_eeprom->offset >> 1;
7037 length = in_eeprom->length >> 1;
7038 if ((first > hw->eeprom.word_size) ||
7039 ((first + length) > hw->eeprom.word_size))
7042 in_eeprom->magic = hw->vendor_id | (hw->device_id << 16);
7044 return eeprom->ops.write_buffer(hw, first, length, data);
7048 ixgbe_reta_size_get(enum ixgbe_mac_type mac_type) {
7050 case ixgbe_mac_X550:
7051 case ixgbe_mac_X550EM_x:
7052 case ixgbe_mac_X550EM_a:
7053 return ETH_RSS_RETA_SIZE_512;
7054 case ixgbe_mac_X550_vf:
7055 case ixgbe_mac_X550EM_x_vf:
7056 case ixgbe_mac_X550EM_a_vf:
7057 return ETH_RSS_RETA_SIZE_64;
7059 return ETH_RSS_RETA_SIZE_128;
7064 ixgbe_reta_reg_get(enum ixgbe_mac_type mac_type, uint16_t reta_idx) {
7066 case ixgbe_mac_X550:
7067 case ixgbe_mac_X550EM_x:
7068 case ixgbe_mac_X550EM_a:
7069 if (reta_idx < ETH_RSS_RETA_SIZE_128)
7070 return IXGBE_RETA(reta_idx >> 2);
7072 return IXGBE_ERETA((reta_idx - ETH_RSS_RETA_SIZE_128) >> 2);
7073 case ixgbe_mac_X550_vf:
7074 case ixgbe_mac_X550EM_x_vf:
7075 case ixgbe_mac_X550EM_a_vf:
7076 return IXGBE_VFRETA(reta_idx >> 2);
7078 return IXGBE_RETA(reta_idx >> 2);
7083 ixgbe_mrqc_reg_get(enum ixgbe_mac_type mac_type) {
7085 case ixgbe_mac_X550_vf:
7086 case ixgbe_mac_X550EM_x_vf:
7087 case ixgbe_mac_X550EM_a_vf:
7088 return IXGBE_VFMRQC;
7095 ixgbe_rssrk_reg_get(enum ixgbe_mac_type mac_type, uint8_t i) {
7097 case ixgbe_mac_X550_vf:
7098 case ixgbe_mac_X550EM_x_vf:
7099 case ixgbe_mac_X550EM_a_vf:
7100 return IXGBE_VFRSSRK(i);
7102 return IXGBE_RSSRK(i);
7107 ixgbe_rss_update_sp(enum ixgbe_mac_type mac_type) {
7109 case ixgbe_mac_82599_vf:
7110 case ixgbe_mac_X540_vf:
7118 ixgbe_dev_get_dcb_info(struct rte_eth_dev *dev,
7119 struct rte_eth_dcb_info *dcb_info)
7121 struct ixgbe_dcb_config *dcb_config =
7122 IXGBE_DEV_PRIVATE_TO_DCB_CFG(dev->data->dev_private);
7123 struct ixgbe_dcb_tc_config *tc;
7126 if (dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_DCB_FLAG)
7127 dcb_info->nb_tcs = dcb_config->num_tcs.pg_tcs;
7129 dcb_info->nb_tcs = 1;
7131 if (dcb_config->vt_mode) { /* vt is enabled*/
7132 struct rte_eth_vmdq_dcb_conf *vmdq_rx_conf =
7133 &dev->data->dev_conf.rx_adv_conf.vmdq_dcb_conf;
7134 for (i = 0; i < ETH_DCB_NUM_USER_PRIORITIES; i++)
7135 dcb_info->prio_tc[i] = vmdq_rx_conf->dcb_tc[i];
7136 for (i = 0; i < vmdq_rx_conf->nb_queue_pools; i++) {
7137 for (j = 0; j < dcb_info->nb_tcs; j++) {
7138 dcb_info->tc_queue.tc_rxq[i][j].base =
7139 i * dcb_info->nb_tcs + j;
7140 dcb_info->tc_queue.tc_rxq[i][j].nb_queue = 1;
7141 dcb_info->tc_queue.tc_txq[i][j].base =
7142 i * dcb_info->nb_tcs + j;
7143 dcb_info->tc_queue.tc_txq[i][j].nb_queue = 1;
7146 } else { /* vt is disabled*/
7147 struct rte_eth_dcb_rx_conf *rx_conf =
7148 &dev->data->dev_conf.rx_adv_conf.dcb_rx_conf;
7149 for (i = 0; i < ETH_DCB_NUM_USER_PRIORITIES; i++)
7150 dcb_info->prio_tc[i] = rx_conf->dcb_tc[i];
7151 if (dcb_info->nb_tcs == ETH_4_TCS) {
7152 for (i = 0; i < dcb_info->nb_tcs; i++) {
7153 dcb_info->tc_queue.tc_rxq[0][i].base = i * 32;
7154 dcb_info->tc_queue.tc_rxq[0][i].nb_queue = 16;
7156 dcb_info->tc_queue.tc_txq[0][0].base = 0;
7157 dcb_info->tc_queue.tc_txq[0][1].base = 64;
7158 dcb_info->tc_queue.tc_txq[0][2].base = 96;
7159 dcb_info->tc_queue.tc_txq[0][3].base = 112;
7160 dcb_info->tc_queue.tc_txq[0][0].nb_queue = 64;
7161 dcb_info->tc_queue.tc_txq[0][1].nb_queue = 32;
7162 dcb_info->tc_queue.tc_txq[0][2].nb_queue = 16;
7163 dcb_info->tc_queue.tc_txq[0][3].nb_queue = 16;
7164 } else if (dcb_info->nb_tcs == ETH_8_TCS) {
7165 for (i = 0; i < dcb_info->nb_tcs; i++) {
7166 dcb_info->tc_queue.tc_rxq[0][i].base = i * 16;
7167 dcb_info->tc_queue.tc_rxq[0][i].nb_queue = 16;
7169 dcb_info->tc_queue.tc_txq[0][0].base = 0;
7170 dcb_info->tc_queue.tc_txq[0][1].base = 32;
7171 dcb_info->tc_queue.tc_txq[0][2].base = 64;
7172 dcb_info->tc_queue.tc_txq[0][3].base = 80;
7173 dcb_info->tc_queue.tc_txq[0][4].base = 96;
7174 dcb_info->tc_queue.tc_txq[0][5].base = 104;
7175 dcb_info->tc_queue.tc_txq[0][6].base = 112;
7176 dcb_info->tc_queue.tc_txq[0][7].base = 120;
7177 dcb_info->tc_queue.tc_txq[0][0].nb_queue = 32;
7178 dcb_info->tc_queue.tc_txq[0][1].nb_queue = 32;
7179 dcb_info->tc_queue.tc_txq[0][2].nb_queue = 16;
7180 dcb_info->tc_queue.tc_txq[0][3].nb_queue = 16;
7181 dcb_info->tc_queue.tc_txq[0][4].nb_queue = 8;
7182 dcb_info->tc_queue.tc_txq[0][5].nb_queue = 8;
7183 dcb_info->tc_queue.tc_txq[0][6].nb_queue = 8;
7184 dcb_info->tc_queue.tc_txq[0][7].nb_queue = 8;
7187 for (i = 0; i < dcb_info->nb_tcs; i++) {
7188 tc = &dcb_config->tc_config[i];
7189 dcb_info->tc_bws[i] = tc->path[IXGBE_DCB_TX_CONFIG].bwg_percent;
7194 /* Update e-tag ether type */
7196 ixgbe_update_e_tag_eth_type(struct ixgbe_hw *hw,
7197 uint16_t ether_type)
7199 uint32_t etag_etype;
7201 if (hw->mac.type != ixgbe_mac_X550 &&
7202 hw->mac.type != ixgbe_mac_X550EM_x &&
7203 hw->mac.type != ixgbe_mac_X550EM_a) {
7207 etag_etype = IXGBE_READ_REG(hw, IXGBE_ETAG_ETYPE);
7208 etag_etype &= ~IXGBE_ETAG_ETYPE_MASK;
7209 etag_etype |= ether_type;
7210 IXGBE_WRITE_REG(hw, IXGBE_ETAG_ETYPE, etag_etype);
7211 IXGBE_WRITE_FLUSH(hw);
7216 /* Config l2 tunnel ether type */
7218 ixgbe_dev_l2_tunnel_eth_type_conf(struct rte_eth_dev *dev,
7219 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7222 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7223 struct ixgbe_l2_tn_info *l2_tn_info =
7224 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
7226 if (l2_tunnel == NULL)
7229 switch (l2_tunnel->l2_tunnel_type) {
7230 case RTE_L2_TUNNEL_TYPE_E_TAG:
7231 l2_tn_info->e_tag_ether_type = l2_tunnel->ether_type;
7232 ret = ixgbe_update_e_tag_eth_type(hw, l2_tunnel->ether_type);
7235 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7243 /* Enable e-tag tunnel */
7245 ixgbe_e_tag_enable(struct ixgbe_hw *hw)
7247 uint32_t etag_etype;
7249 if (hw->mac.type != ixgbe_mac_X550 &&
7250 hw->mac.type != ixgbe_mac_X550EM_x &&
7251 hw->mac.type != ixgbe_mac_X550EM_a) {
7255 etag_etype = IXGBE_READ_REG(hw, IXGBE_ETAG_ETYPE);
7256 etag_etype |= IXGBE_ETAG_ETYPE_VALID;
7257 IXGBE_WRITE_REG(hw, IXGBE_ETAG_ETYPE, etag_etype);
7258 IXGBE_WRITE_FLUSH(hw);
7263 /* Enable l2 tunnel */
7265 ixgbe_dev_l2_tunnel_enable(struct rte_eth_dev *dev,
7266 enum rte_eth_tunnel_type l2_tunnel_type)
7269 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7270 struct ixgbe_l2_tn_info *l2_tn_info =
7271 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
7273 switch (l2_tunnel_type) {
7274 case RTE_L2_TUNNEL_TYPE_E_TAG:
7275 l2_tn_info->e_tag_en = TRUE;
7276 ret = ixgbe_e_tag_enable(hw);
7279 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7287 /* Disable e-tag tunnel */
7289 ixgbe_e_tag_disable(struct ixgbe_hw *hw)
7291 uint32_t etag_etype;
7293 if (hw->mac.type != ixgbe_mac_X550 &&
7294 hw->mac.type != ixgbe_mac_X550EM_x &&
7295 hw->mac.type != ixgbe_mac_X550EM_a) {
7299 etag_etype = IXGBE_READ_REG(hw, IXGBE_ETAG_ETYPE);
7300 etag_etype &= ~IXGBE_ETAG_ETYPE_VALID;
7301 IXGBE_WRITE_REG(hw, IXGBE_ETAG_ETYPE, etag_etype);
7302 IXGBE_WRITE_FLUSH(hw);
7307 /* Disable l2 tunnel */
7309 ixgbe_dev_l2_tunnel_disable(struct rte_eth_dev *dev,
7310 enum rte_eth_tunnel_type l2_tunnel_type)
7313 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7314 struct ixgbe_l2_tn_info *l2_tn_info =
7315 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
7317 switch (l2_tunnel_type) {
7318 case RTE_L2_TUNNEL_TYPE_E_TAG:
7319 l2_tn_info->e_tag_en = FALSE;
7320 ret = ixgbe_e_tag_disable(hw);
7323 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7332 ixgbe_e_tag_filter_del(struct rte_eth_dev *dev,
7333 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7336 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7337 uint32_t i, rar_entries;
7338 uint32_t rar_low, rar_high;
7340 if (hw->mac.type != ixgbe_mac_X550 &&
7341 hw->mac.type != ixgbe_mac_X550EM_x &&
7342 hw->mac.type != ixgbe_mac_X550EM_a) {
7346 rar_entries = ixgbe_get_num_rx_addrs(hw);
7348 for (i = 1; i < rar_entries; i++) {
7349 rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(i));
7350 rar_low = IXGBE_READ_REG(hw, IXGBE_RAL(i));
7351 if ((rar_high & IXGBE_RAH_AV) &&
7352 (rar_high & IXGBE_RAH_ADTYPE) &&
7353 ((rar_low & IXGBE_RAL_ETAG_FILTER_MASK) ==
7354 l2_tunnel->tunnel_id)) {
7355 IXGBE_WRITE_REG(hw, IXGBE_RAL(i), 0);
7356 IXGBE_WRITE_REG(hw, IXGBE_RAH(i), 0);
7358 ixgbe_clear_vmdq(hw, i, IXGBE_CLEAR_VMDQ_ALL);
7368 ixgbe_e_tag_filter_add(struct rte_eth_dev *dev,
7369 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7372 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7373 uint32_t i, rar_entries;
7374 uint32_t rar_low, rar_high;
7376 if (hw->mac.type != ixgbe_mac_X550 &&
7377 hw->mac.type != ixgbe_mac_X550EM_x &&
7378 hw->mac.type != ixgbe_mac_X550EM_a) {
7382 /* One entry for one tunnel. Try to remove potential existing entry. */
7383 ixgbe_e_tag_filter_del(dev, l2_tunnel);
7385 rar_entries = ixgbe_get_num_rx_addrs(hw);
7387 for (i = 1; i < rar_entries; i++) {
7388 rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(i));
7389 if (rar_high & IXGBE_RAH_AV) {
7392 ixgbe_set_vmdq(hw, i, l2_tunnel->pool);
7393 rar_high = IXGBE_RAH_AV | IXGBE_RAH_ADTYPE;
7394 rar_low = l2_tunnel->tunnel_id;
7396 IXGBE_WRITE_REG(hw, IXGBE_RAL(i), rar_low);
7397 IXGBE_WRITE_REG(hw, IXGBE_RAH(i), rar_high);
7403 PMD_INIT_LOG(NOTICE, "The table of E-tag forwarding rule is full."
7404 " Please remove a rule before adding a new one.");
7408 static inline struct ixgbe_l2_tn_filter *
7409 ixgbe_l2_tn_filter_lookup(struct ixgbe_l2_tn_info *l2_tn_info,
7410 struct ixgbe_l2_tn_key *key)
7414 ret = rte_hash_lookup(l2_tn_info->hash_handle, (const void *)key);
7418 return l2_tn_info->hash_map[ret];
7422 ixgbe_insert_l2_tn_filter(struct ixgbe_l2_tn_info *l2_tn_info,
7423 struct ixgbe_l2_tn_filter *l2_tn_filter)
7427 ret = rte_hash_add_key(l2_tn_info->hash_handle,
7428 &l2_tn_filter->key);
7432 "Failed to insert L2 tunnel filter"
7433 " to hash table %d!",
7438 l2_tn_info->hash_map[ret] = l2_tn_filter;
7440 TAILQ_INSERT_TAIL(&l2_tn_info->l2_tn_list, l2_tn_filter, entries);
7446 ixgbe_remove_l2_tn_filter(struct ixgbe_l2_tn_info *l2_tn_info,
7447 struct ixgbe_l2_tn_key *key)
7450 struct ixgbe_l2_tn_filter *l2_tn_filter;
7452 ret = rte_hash_del_key(l2_tn_info->hash_handle, key);
7456 "No such L2 tunnel filter to delete %d!",
7461 l2_tn_filter = l2_tn_info->hash_map[ret];
7462 l2_tn_info->hash_map[ret] = NULL;
7464 TAILQ_REMOVE(&l2_tn_info->l2_tn_list, l2_tn_filter, entries);
7465 rte_free(l2_tn_filter);
7470 /* Add l2 tunnel filter */
7472 ixgbe_dev_l2_tunnel_filter_add(struct rte_eth_dev *dev,
7473 struct rte_eth_l2_tunnel_conf *l2_tunnel,
7477 struct ixgbe_l2_tn_info *l2_tn_info =
7478 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
7479 struct ixgbe_l2_tn_key key;
7480 struct ixgbe_l2_tn_filter *node;
7483 key.l2_tn_type = l2_tunnel->l2_tunnel_type;
7484 key.tn_id = l2_tunnel->tunnel_id;
7486 node = ixgbe_l2_tn_filter_lookup(l2_tn_info, &key);
7490 "The L2 tunnel filter already exists!");
7494 node = rte_zmalloc("ixgbe_l2_tn",
7495 sizeof(struct ixgbe_l2_tn_filter),
7500 (void)rte_memcpy(&node->key,
7502 sizeof(struct ixgbe_l2_tn_key));
7503 node->pool = l2_tunnel->pool;
7504 ret = ixgbe_insert_l2_tn_filter(l2_tn_info, node);
7511 switch (l2_tunnel->l2_tunnel_type) {
7512 case RTE_L2_TUNNEL_TYPE_E_TAG:
7513 ret = ixgbe_e_tag_filter_add(dev, l2_tunnel);
7516 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7521 if ((!restore) && (ret < 0))
7522 (void)ixgbe_remove_l2_tn_filter(l2_tn_info, &key);
7527 /* Delete l2 tunnel filter */
7529 ixgbe_dev_l2_tunnel_filter_del(struct rte_eth_dev *dev,
7530 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7533 struct ixgbe_l2_tn_info *l2_tn_info =
7534 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
7535 struct ixgbe_l2_tn_key key;
7537 key.l2_tn_type = l2_tunnel->l2_tunnel_type;
7538 key.tn_id = l2_tunnel->tunnel_id;
7539 ret = ixgbe_remove_l2_tn_filter(l2_tn_info, &key);
7543 switch (l2_tunnel->l2_tunnel_type) {
7544 case RTE_L2_TUNNEL_TYPE_E_TAG:
7545 ret = ixgbe_e_tag_filter_del(dev, l2_tunnel);
7548 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7557 * ixgbe_dev_l2_tunnel_filter_handle - Handle operations for l2 tunnel filter.
7558 * @dev: pointer to rte_eth_dev structure
7559 * @filter_op:operation will be taken.
7560 * @arg: a pointer to specific structure corresponding to the filter_op
7563 ixgbe_dev_l2_tunnel_filter_handle(struct rte_eth_dev *dev,
7564 enum rte_filter_op filter_op,
7569 if (filter_op == RTE_ETH_FILTER_NOP)
7573 PMD_DRV_LOG(ERR, "arg shouldn't be NULL for operation %u.",
7578 switch (filter_op) {
7579 case RTE_ETH_FILTER_ADD:
7580 ret = ixgbe_dev_l2_tunnel_filter_add
7582 (struct rte_eth_l2_tunnel_conf *)arg,
7585 case RTE_ETH_FILTER_DELETE:
7586 ret = ixgbe_dev_l2_tunnel_filter_del
7588 (struct rte_eth_l2_tunnel_conf *)arg);
7591 PMD_DRV_LOG(ERR, "unsupported operation %u.", filter_op);
7599 ixgbe_e_tag_forwarding_en_dis(struct rte_eth_dev *dev, bool en)
7603 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7605 if (hw->mac.type != ixgbe_mac_X550 &&
7606 hw->mac.type != ixgbe_mac_X550EM_x &&
7607 hw->mac.type != ixgbe_mac_X550EM_a) {
7611 ctrl = IXGBE_READ_REG(hw, IXGBE_VT_CTL);
7612 ctrl &= ~IXGBE_VT_CTL_POOLING_MODE_MASK;
7614 ctrl |= IXGBE_VT_CTL_POOLING_MODE_ETAG;
7615 IXGBE_WRITE_REG(hw, IXGBE_VT_CTL, ctrl);
7620 /* Enable l2 tunnel forwarding */
7622 ixgbe_dev_l2_tunnel_forwarding_enable
7623 (struct rte_eth_dev *dev,
7624 enum rte_eth_tunnel_type l2_tunnel_type)
7626 struct ixgbe_l2_tn_info *l2_tn_info =
7627 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
7630 switch (l2_tunnel_type) {
7631 case RTE_L2_TUNNEL_TYPE_E_TAG:
7632 l2_tn_info->e_tag_fwd_en = TRUE;
7633 ret = ixgbe_e_tag_forwarding_en_dis(dev, 1);
7636 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7644 /* Disable l2 tunnel forwarding */
7646 ixgbe_dev_l2_tunnel_forwarding_disable
7647 (struct rte_eth_dev *dev,
7648 enum rte_eth_tunnel_type l2_tunnel_type)
7650 struct ixgbe_l2_tn_info *l2_tn_info =
7651 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
7654 switch (l2_tunnel_type) {
7655 case RTE_L2_TUNNEL_TYPE_E_TAG:
7656 l2_tn_info->e_tag_fwd_en = FALSE;
7657 ret = ixgbe_e_tag_forwarding_en_dis(dev, 0);
7660 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7669 ixgbe_e_tag_insertion_en_dis(struct rte_eth_dev *dev,
7670 struct rte_eth_l2_tunnel_conf *l2_tunnel,
7673 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
7675 uint32_t vmtir, vmvir;
7676 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7678 if (l2_tunnel->vf_id >= pci_dev->max_vfs) {
7680 "VF id %u should be less than %u",
7686 if (hw->mac.type != ixgbe_mac_X550 &&
7687 hw->mac.type != ixgbe_mac_X550EM_x &&
7688 hw->mac.type != ixgbe_mac_X550EM_a) {
7693 vmtir = l2_tunnel->tunnel_id;
7697 IXGBE_WRITE_REG(hw, IXGBE_VMTIR(l2_tunnel->vf_id), vmtir);
7699 vmvir = IXGBE_READ_REG(hw, IXGBE_VMVIR(l2_tunnel->vf_id));
7700 vmvir &= ~IXGBE_VMVIR_TAGA_MASK;
7702 vmvir |= IXGBE_VMVIR_TAGA_ETAG_INSERT;
7703 IXGBE_WRITE_REG(hw, IXGBE_VMVIR(l2_tunnel->vf_id), vmvir);
7708 /* Enable l2 tunnel tag insertion */
7710 ixgbe_dev_l2_tunnel_insertion_enable(struct rte_eth_dev *dev,
7711 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7715 switch (l2_tunnel->l2_tunnel_type) {
7716 case RTE_L2_TUNNEL_TYPE_E_TAG:
7717 ret = ixgbe_e_tag_insertion_en_dis(dev, l2_tunnel, 1);
7720 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7728 /* Disable l2 tunnel tag insertion */
7730 ixgbe_dev_l2_tunnel_insertion_disable
7731 (struct rte_eth_dev *dev,
7732 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7736 switch (l2_tunnel->l2_tunnel_type) {
7737 case RTE_L2_TUNNEL_TYPE_E_TAG:
7738 ret = ixgbe_e_tag_insertion_en_dis(dev, l2_tunnel, 0);
7741 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7750 ixgbe_e_tag_stripping_en_dis(struct rte_eth_dev *dev,
7755 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7757 if (hw->mac.type != ixgbe_mac_X550 &&
7758 hw->mac.type != ixgbe_mac_X550EM_x &&
7759 hw->mac.type != ixgbe_mac_X550EM_a) {
7763 qde = IXGBE_READ_REG(hw, IXGBE_QDE);
7765 qde |= IXGBE_QDE_STRIP_TAG;
7767 qde &= ~IXGBE_QDE_STRIP_TAG;
7768 qde &= ~IXGBE_QDE_READ;
7769 qde |= IXGBE_QDE_WRITE;
7770 IXGBE_WRITE_REG(hw, IXGBE_QDE, qde);
7775 /* Enable l2 tunnel tag stripping */
7777 ixgbe_dev_l2_tunnel_stripping_enable
7778 (struct rte_eth_dev *dev,
7779 enum rte_eth_tunnel_type l2_tunnel_type)
7783 switch (l2_tunnel_type) {
7784 case RTE_L2_TUNNEL_TYPE_E_TAG:
7785 ret = ixgbe_e_tag_stripping_en_dis(dev, 1);
7788 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7796 /* Disable l2 tunnel tag stripping */
7798 ixgbe_dev_l2_tunnel_stripping_disable
7799 (struct rte_eth_dev *dev,
7800 enum rte_eth_tunnel_type l2_tunnel_type)
7804 switch (l2_tunnel_type) {
7805 case RTE_L2_TUNNEL_TYPE_E_TAG:
7806 ret = ixgbe_e_tag_stripping_en_dis(dev, 0);
7809 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7817 /* Enable/disable l2 tunnel offload functions */
7819 ixgbe_dev_l2_tunnel_offload_set
7820 (struct rte_eth_dev *dev,
7821 struct rte_eth_l2_tunnel_conf *l2_tunnel,
7827 if (l2_tunnel == NULL)
7831 if (mask & ETH_L2_TUNNEL_ENABLE_MASK) {
7833 ret = ixgbe_dev_l2_tunnel_enable(
7835 l2_tunnel->l2_tunnel_type);
7837 ret = ixgbe_dev_l2_tunnel_disable(
7839 l2_tunnel->l2_tunnel_type);
7842 if (mask & ETH_L2_TUNNEL_INSERTION_MASK) {
7844 ret = ixgbe_dev_l2_tunnel_insertion_enable(
7848 ret = ixgbe_dev_l2_tunnel_insertion_disable(
7853 if (mask & ETH_L2_TUNNEL_STRIPPING_MASK) {
7855 ret = ixgbe_dev_l2_tunnel_stripping_enable(
7857 l2_tunnel->l2_tunnel_type);
7859 ret = ixgbe_dev_l2_tunnel_stripping_disable(
7861 l2_tunnel->l2_tunnel_type);
7864 if (mask & ETH_L2_TUNNEL_FORWARDING_MASK) {
7866 ret = ixgbe_dev_l2_tunnel_forwarding_enable(
7868 l2_tunnel->l2_tunnel_type);
7870 ret = ixgbe_dev_l2_tunnel_forwarding_disable(
7872 l2_tunnel->l2_tunnel_type);
7879 ixgbe_update_vxlan_port(struct ixgbe_hw *hw,
7882 IXGBE_WRITE_REG(hw, IXGBE_VXLANCTRL, port);
7883 IXGBE_WRITE_FLUSH(hw);
7888 /* There's only one register for VxLAN UDP port.
7889 * So, we cannot add several ports. Will update it.
7892 ixgbe_add_vxlan_port(struct ixgbe_hw *hw,
7896 PMD_DRV_LOG(ERR, "Add VxLAN port 0 is not allowed.");
7900 return ixgbe_update_vxlan_port(hw, port);
7903 /* We cannot delete the VxLAN port. For there's a register for VxLAN
7904 * UDP port, it must have a value.
7905 * So, will reset it to the original value 0.
7908 ixgbe_del_vxlan_port(struct ixgbe_hw *hw,
7913 cur_port = (uint16_t)IXGBE_READ_REG(hw, IXGBE_VXLANCTRL);
7915 if (cur_port != port) {
7916 PMD_DRV_LOG(ERR, "Port %u does not exist.", port);
7920 return ixgbe_update_vxlan_port(hw, 0);
7923 /* Add UDP tunneling port */
7925 ixgbe_dev_udp_tunnel_port_add(struct rte_eth_dev *dev,
7926 struct rte_eth_udp_tunnel *udp_tunnel)
7929 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7931 if (hw->mac.type != ixgbe_mac_X550 &&
7932 hw->mac.type != ixgbe_mac_X550EM_x &&
7933 hw->mac.type != ixgbe_mac_X550EM_a) {
7937 if (udp_tunnel == NULL)
7940 switch (udp_tunnel->prot_type) {
7941 case RTE_TUNNEL_TYPE_VXLAN:
7942 ret = ixgbe_add_vxlan_port(hw, udp_tunnel->udp_port);
7945 case RTE_TUNNEL_TYPE_GENEVE:
7946 case RTE_TUNNEL_TYPE_TEREDO:
7947 PMD_DRV_LOG(ERR, "Tunnel type is not supported now.");
7952 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7960 /* Remove UDP tunneling port */
7962 ixgbe_dev_udp_tunnel_port_del(struct rte_eth_dev *dev,
7963 struct rte_eth_udp_tunnel *udp_tunnel)
7966 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7968 if (hw->mac.type != ixgbe_mac_X550 &&
7969 hw->mac.type != ixgbe_mac_X550EM_x &&
7970 hw->mac.type != ixgbe_mac_X550EM_a) {
7974 if (udp_tunnel == NULL)
7977 switch (udp_tunnel->prot_type) {
7978 case RTE_TUNNEL_TYPE_VXLAN:
7979 ret = ixgbe_del_vxlan_port(hw, udp_tunnel->udp_port);
7981 case RTE_TUNNEL_TYPE_GENEVE:
7982 case RTE_TUNNEL_TYPE_TEREDO:
7983 PMD_DRV_LOG(ERR, "Tunnel type is not supported now.");
7987 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7996 ixgbevf_dev_allmulticast_enable(struct rte_eth_dev *dev)
7998 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8000 hw->mac.ops.update_xcast_mode(hw, IXGBEVF_XCAST_MODE_ALLMULTI);
8004 ixgbevf_dev_allmulticast_disable(struct rte_eth_dev *dev)
8006 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8008 hw->mac.ops.update_xcast_mode(hw, IXGBEVF_XCAST_MODE_MULTI);
8011 static void ixgbevf_mbx_process(struct rte_eth_dev *dev)
8013 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8016 if (ixgbe_read_mbx(hw, &in_msg, 1, 0))
8019 /* PF reset VF event */
8020 if (in_msg == IXGBE_PF_CONTROL_MSG)
8021 _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RESET,
8026 ixgbevf_dev_interrupt_get_status(struct rte_eth_dev *dev)
8029 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8030 struct ixgbe_interrupt *intr =
8031 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
8032 ixgbevf_intr_disable(hw);
8034 /* read-on-clear nic registers here */
8035 eicr = IXGBE_READ_REG(hw, IXGBE_VTEICR);
8038 /* only one misc vector supported - mailbox */
8039 eicr &= IXGBE_VTEICR_MASK;
8040 if (eicr == IXGBE_MISC_VEC_ID)
8041 intr->flags |= IXGBE_FLAG_MAILBOX;
8047 ixgbevf_dev_interrupt_action(struct rte_eth_dev *dev)
8049 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8050 struct ixgbe_interrupt *intr =
8051 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
8053 if (intr->flags & IXGBE_FLAG_MAILBOX) {
8054 ixgbevf_mbx_process(dev);
8055 intr->flags &= ~IXGBE_FLAG_MAILBOX;
8058 ixgbevf_intr_enable(hw);
8064 ixgbevf_dev_interrupt_handler(void *param)
8066 struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
8068 ixgbevf_dev_interrupt_get_status(dev);
8069 ixgbevf_dev_interrupt_action(dev);
8073 * ixgbe_disable_sec_tx_path_generic - Stops the transmit data path
8074 * @hw: pointer to hardware structure
8076 * Stops the transmit data path and waits for the HW to internally empty
8077 * the Tx security block
8079 int ixgbe_disable_sec_tx_path_generic(struct ixgbe_hw *hw)
8081 #define IXGBE_MAX_SECTX_POLL 40
8086 sectxreg = IXGBE_READ_REG(hw, IXGBE_SECTXCTRL);
8087 sectxreg |= IXGBE_SECTXCTRL_TX_DIS;
8088 IXGBE_WRITE_REG(hw, IXGBE_SECTXCTRL, sectxreg);
8089 for (i = 0; i < IXGBE_MAX_SECTX_POLL; i++) {
8090 sectxreg = IXGBE_READ_REG(hw, IXGBE_SECTXSTAT);
8091 if (sectxreg & IXGBE_SECTXSTAT_SECTX_RDY)
8093 /* Use interrupt-safe sleep just in case */
8097 /* For informational purposes only */
8098 if (i >= IXGBE_MAX_SECTX_POLL)
8099 PMD_DRV_LOG(DEBUG, "Tx unit being enabled before security "
8100 "path fully disabled. Continuing with init.");
8102 return IXGBE_SUCCESS;
8106 * ixgbe_enable_sec_tx_path_generic - Enables the transmit data path
8107 * @hw: pointer to hardware structure
8109 * Enables the transmit data path.
8111 int ixgbe_enable_sec_tx_path_generic(struct ixgbe_hw *hw)
8115 sectxreg = IXGBE_READ_REG(hw, IXGBE_SECTXCTRL);
8116 sectxreg &= ~IXGBE_SECTXCTRL_TX_DIS;
8117 IXGBE_WRITE_REG(hw, IXGBE_SECTXCTRL, sectxreg);
8118 IXGBE_WRITE_FLUSH(hw);
8120 return IXGBE_SUCCESS;
8123 /* restore n-tuple filter */
8125 ixgbe_ntuple_filter_restore(struct rte_eth_dev *dev)
8127 struct ixgbe_filter_info *filter_info =
8128 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
8129 struct ixgbe_5tuple_filter *node;
8131 TAILQ_FOREACH(node, &filter_info->fivetuple_list, entries) {
8132 ixgbe_inject_5tuple_filter(dev, node);
8136 /* restore ethernet type filter */
8138 ixgbe_ethertype_filter_restore(struct rte_eth_dev *dev)
8140 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8141 struct ixgbe_filter_info *filter_info =
8142 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
8145 for (i = 0; i < IXGBE_MAX_ETQF_FILTERS; i++) {
8146 if (filter_info->ethertype_mask & (1 << i)) {
8147 IXGBE_WRITE_REG(hw, IXGBE_ETQF(i),
8148 filter_info->ethertype_filters[i].etqf);
8149 IXGBE_WRITE_REG(hw, IXGBE_ETQS(i),
8150 filter_info->ethertype_filters[i].etqs);
8151 IXGBE_WRITE_FLUSH(hw);
8156 /* restore SYN filter */
8158 ixgbe_syn_filter_restore(struct rte_eth_dev *dev)
8160 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8161 struct ixgbe_filter_info *filter_info =
8162 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
8165 synqf = filter_info->syn_info;
8167 if (synqf & IXGBE_SYN_FILTER_ENABLE) {
8168 IXGBE_WRITE_REG(hw, IXGBE_SYNQF, synqf);
8169 IXGBE_WRITE_FLUSH(hw);
8173 /* restore L2 tunnel filter */
8175 ixgbe_l2_tn_filter_restore(struct rte_eth_dev *dev)
8177 struct ixgbe_l2_tn_info *l2_tn_info =
8178 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
8179 struct ixgbe_l2_tn_filter *node;
8180 struct rte_eth_l2_tunnel_conf l2_tn_conf;
8182 TAILQ_FOREACH(node, &l2_tn_info->l2_tn_list, entries) {
8183 l2_tn_conf.l2_tunnel_type = node->key.l2_tn_type;
8184 l2_tn_conf.tunnel_id = node->key.tn_id;
8185 l2_tn_conf.pool = node->pool;
8186 (void)ixgbe_dev_l2_tunnel_filter_add(dev, &l2_tn_conf, TRUE);
8191 ixgbe_filter_restore(struct rte_eth_dev *dev)
8193 ixgbe_ntuple_filter_restore(dev);
8194 ixgbe_ethertype_filter_restore(dev);
8195 ixgbe_syn_filter_restore(dev);
8196 ixgbe_fdir_filter_restore(dev);
8197 ixgbe_l2_tn_filter_restore(dev);
8203 ixgbe_l2_tunnel_conf(struct rte_eth_dev *dev)
8205 struct ixgbe_l2_tn_info *l2_tn_info =
8206 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
8207 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8209 if (l2_tn_info->e_tag_en)
8210 (void)ixgbe_e_tag_enable(hw);
8212 if (l2_tn_info->e_tag_fwd_en)
8213 (void)ixgbe_e_tag_forwarding_en_dis(dev, 1);
8215 (void)ixgbe_update_e_tag_eth_type(hw, l2_tn_info->e_tag_ether_type);
8218 /* remove all the n-tuple filters */
8220 ixgbe_clear_all_ntuple_filter(struct rte_eth_dev *dev)
8222 struct ixgbe_filter_info *filter_info =
8223 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
8224 struct ixgbe_5tuple_filter *p_5tuple;
8226 while ((p_5tuple = TAILQ_FIRST(&filter_info->fivetuple_list)))
8227 ixgbe_remove_5tuple_filter(dev, p_5tuple);
8230 /* remove all the ether type filters */
8232 ixgbe_clear_all_ethertype_filter(struct rte_eth_dev *dev)
8234 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8235 struct ixgbe_filter_info *filter_info =
8236 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
8239 for (i = 0; i < IXGBE_MAX_ETQF_FILTERS; i++) {
8240 if (filter_info->ethertype_mask & (1 << i) &&
8241 !filter_info->ethertype_filters[i].conf) {
8242 (void)ixgbe_ethertype_filter_remove(filter_info,
8244 IXGBE_WRITE_REG(hw, IXGBE_ETQF(i), 0);
8245 IXGBE_WRITE_REG(hw, IXGBE_ETQS(i), 0);
8246 IXGBE_WRITE_FLUSH(hw);
8251 /* remove the SYN filter */
8253 ixgbe_clear_syn_filter(struct rte_eth_dev *dev)
8255 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8256 struct ixgbe_filter_info *filter_info =
8257 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
8259 if (filter_info->syn_info & IXGBE_SYN_FILTER_ENABLE) {
8260 filter_info->syn_info = 0;
8262 IXGBE_WRITE_REG(hw, IXGBE_SYNQF, 0);
8263 IXGBE_WRITE_FLUSH(hw);
8267 /* remove all the L2 tunnel filters */
8269 ixgbe_clear_all_l2_tn_filter(struct rte_eth_dev *dev)
8271 struct ixgbe_l2_tn_info *l2_tn_info =
8272 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
8273 struct ixgbe_l2_tn_filter *l2_tn_filter;
8274 struct rte_eth_l2_tunnel_conf l2_tn_conf;
8277 while ((l2_tn_filter = TAILQ_FIRST(&l2_tn_info->l2_tn_list))) {
8278 l2_tn_conf.l2_tunnel_type = l2_tn_filter->key.l2_tn_type;
8279 l2_tn_conf.tunnel_id = l2_tn_filter->key.tn_id;
8280 l2_tn_conf.pool = l2_tn_filter->pool;
8281 ret = ixgbe_dev_l2_tunnel_filter_del(dev, &l2_tn_conf);
8289 RTE_PMD_REGISTER_PCI(net_ixgbe, rte_ixgbe_pmd);
8290 RTE_PMD_REGISTER_PCI_TABLE(net_ixgbe, pci_id_ixgbe_map);
8291 RTE_PMD_REGISTER_KMOD_DEP(net_ixgbe, "* igb_uio | uio_pci_generic | vfio-pci");
8292 RTE_PMD_REGISTER_PCI(net_ixgbe_vf, rte_ixgbevf_pmd);
8293 RTE_PMD_REGISTER_PCI_TABLE(net_ixgbe_vf, pci_id_ixgbevf_map);
8294 RTE_PMD_REGISTER_KMOD_DEP(net_ixgbe_vf, "* igb_uio | vfio-pci");