4 * Copyright(c) 2010-2017 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #include <sys/queue.h>
42 #include <netinet/in.h>
43 #include <rte_byteorder.h>
44 #include <rte_common.h>
45 #include <rte_cycles.h>
47 #include <rte_interrupts.h>
49 #include <rte_debug.h>
51 #include <rte_atomic.h>
52 #include <rte_branch_prediction.h>
53 #include <rte_memory.h>
54 #include <rte_memzone.h>
56 #include <rte_alarm.h>
57 #include <rte_ether.h>
58 #include <rte_ethdev.h>
59 #include <rte_ethdev_pci.h>
60 #include <rte_atomic.h>
61 #include <rte_malloc.h>
62 #include <rte_random.h>
64 #include <rte_hash_crc.h>
66 #include "ixgbe_logs.h"
67 #include "base/ixgbe_api.h"
68 #include "base/ixgbe_vf.h"
69 #include "base/ixgbe_common.h"
70 #include "ixgbe_ethdev.h"
71 #include "ixgbe_bypass.h"
72 #include "ixgbe_rxtx.h"
73 #include "base/ixgbe_type.h"
74 #include "base/ixgbe_phy.h"
75 #include "ixgbe_regs.h"
78 * High threshold controlling when to start sending XOFF frames. Must be at
79 * least 8 bytes less than receive packet buffer size. This value is in units
82 #define IXGBE_FC_HI 0x80
85 * Low threshold controlling when to start sending XON frames. This value is
86 * in units of 1024 bytes.
88 #define IXGBE_FC_LO 0x40
90 /* Default minimum inter-interrupt interval for EITR configuration */
91 #define IXGBE_MIN_INTER_INTERRUPT_INTERVAL_DEFAULT 0x79E
93 /* Timer value included in XOFF frames. */
94 #define IXGBE_FC_PAUSE 0x680
96 #define IXGBE_LINK_DOWN_CHECK_TIMEOUT 4000 /* ms */
97 #define IXGBE_LINK_UP_CHECK_TIMEOUT 1000 /* ms */
98 #define IXGBE_VMDQ_NUM_UC_MAC 4096 /* Maximum nb. of UC MAC addr. */
100 #define IXGBE_MMW_SIZE_DEFAULT 0x4
101 #define IXGBE_MMW_SIZE_JUMBO_FRAME 0x14
102 #define IXGBE_MAX_RING_DESC 4096 /* replicate define from rxtx */
105 * Default values for RX/TX configuration
107 #define IXGBE_DEFAULT_RX_FREE_THRESH 32
108 #define IXGBE_DEFAULT_RX_PTHRESH 8
109 #define IXGBE_DEFAULT_RX_HTHRESH 8
110 #define IXGBE_DEFAULT_RX_WTHRESH 0
112 #define IXGBE_DEFAULT_TX_FREE_THRESH 32
113 #define IXGBE_DEFAULT_TX_PTHRESH 32
114 #define IXGBE_DEFAULT_TX_HTHRESH 0
115 #define IXGBE_DEFAULT_TX_WTHRESH 0
116 #define IXGBE_DEFAULT_TX_RSBIT_THRESH 32
118 /* Bit shift and mask */
119 #define IXGBE_4_BIT_WIDTH (CHAR_BIT / 2)
120 #define IXGBE_4_BIT_MASK RTE_LEN2MASK(IXGBE_4_BIT_WIDTH, uint8_t)
121 #define IXGBE_8_BIT_WIDTH CHAR_BIT
122 #define IXGBE_8_BIT_MASK UINT8_MAX
124 #define IXGBEVF_PMD_NAME "rte_ixgbevf_pmd" /* PMD name */
126 #define IXGBE_QUEUE_STAT_COUNTERS (sizeof(hw_stats->qprc) / sizeof(hw_stats->qprc[0]))
128 #define IXGBE_HKEY_MAX_INDEX 10
130 /* Additional timesync values. */
131 #define NSEC_PER_SEC 1000000000L
132 #define IXGBE_INCVAL_10GB 0x66666666
133 #define IXGBE_INCVAL_1GB 0x40000000
134 #define IXGBE_INCVAL_100 0x50000000
135 #define IXGBE_INCVAL_SHIFT_10GB 28
136 #define IXGBE_INCVAL_SHIFT_1GB 24
137 #define IXGBE_INCVAL_SHIFT_100 21
138 #define IXGBE_INCVAL_SHIFT_82599 7
139 #define IXGBE_INCPER_SHIFT_82599 24
141 #define IXGBE_CYCLECOUNTER_MASK 0xffffffffffffffffULL
143 #define IXGBE_VT_CTL_POOLING_MODE_MASK 0x00030000
144 #define IXGBE_VT_CTL_POOLING_MODE_ETAG 0x00010000
145 #define DEFAULT_ETAG_ETYPE 0x893f
146 #define IXGBE_ETAG_ETYPE 0x00005084
147 #define IXGBE_ETAG_ETYPE_MASK 0x0000ffff
148 #define IXGBE_ETAG_ETYPE_VALID 0x80000000
149 #define IXGBE_RAH_ADTYPE 0x40000000
150 #define IXGBE_RAL_ETAG_FILTER_MASK 0x00003fff
151 #define IXGBE_VMVIR_TAGA_MASK 0x18000000
152 #define IXGBE_VMVIR_TAGA_ETAG_INSERT 0x08000000
153 #define IXGBE_VMTIR(_i) (0x00017000 + ((_i) * 4)) /* 64 of these (0-63) */
154 #define IXGBE_QDE_STRIP_TAG 0x00000004
155 #define IXGBE_VTEICR_MASK 0x07
157 #define IXGBE_EXVET_VET_EXT_SHIFT 16
158 #define IXGBE_DMATXCTL_VT_MASK 0xFFFF0000
160 static int eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev);
161 static int eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev);
162 static int ixgbe_fdir_filter_init(struct rte_eth_dev *eth_dev);
163 static int ixgbe_fdir_filter_uninit(struct rte_eth_dev *eth_dev);
164 static int ixgbe_l2_tn_filter_init(struct rte_eth_dev *eth_dev);
165 static int ixgbe_l2_tn_filter_uninit(struct rte_eth_dev *eth_dev);
166 static int ixgbe_ntuple_filter_uninit(struct rte_eth_dev *eth_dev);
167 static int ixgbe_dev_configure(struct rte_eth_dev *dev);
168 static int ixgbe_dev_start(struct rte_eth_dev *dev);
169 static void ixgbe_dev_stop(struct rte_eth_dev *dev);
170 static int ixgbe_dev_set_link_up(struct rte_eth_dev *dev);
171 static int ixgbe_dev_set_link_down(struct rte_eth_dev *dev);
172 static void ixgbe_dev_close(struct rte_eth_dev *dev);
173 static void ixgbe_dev_promiscuous_enable(struct rte_eth_dev *dev);
174 static void ixgbe_dev_promiscuous_disable(struct rte_eth_dev *dev);
175 static void ixgbe_dev_allmulticast_enable(struct rte_eth_dev *dev);
176 static void ixgbe_dev_allmulticast_disable(struct rte_eth_dev *dev);
177 static int ixgbe_dev_link_update(struct rte_eth_dev *dev,
178 int wait_to_complete);
179 static void ixgbe_dev_stats_get(struct rte_eth_dev *dev,
180 struct rte_eth_stats *stats);
181 static int ixgbe_dev_xstats_get(struct rte_eth_dev *dev,
182 struct rte_eth_xstat *xstats, unsigned n);
183 static int ixgbevf_dev_xstats_get(struct rte_eth_dev *dev,
184 struct rte_eth_xstat *xstats, unsigned n);
186 ixgbe_dev_xstats_get_by_ids(struct rte_eth_dev *dev, uint64_t *ids,
187 uint64_t *values, unsigned int n);
188 static void ixgbe_dev_stats_reset(struct rte_eth_dev *dev);
189 static void ixgbe_dev_xstats_reset(struct rte_eth_dev *dev);
190 static int ixgbe_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
191 struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned limit);
192 static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
193 struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned limit);
194 static int ixgbe_dev_xstats_get_names_by_ids(
195 __rte_unused 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 void 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 void ixgbevf_dev_stop(struct rte_eth_dev *dev);
265 static void ixgbevf_dev_close(struct rte_eth_dev *dev);
266 static void ixgbevf_intr_disable(struct ixgbe_hw *hw);
267 static void ixgbevf_intr_enable(struct ixgbe_hw *hw);
268 static void ixgbevf_dev_stats_get(struct rte_eth_dev *dev,
269 struct rte_eth_stats *stats);
270 static void ixgbevf_dev_stats_reset(struct rte_eth_dev *dev);
271 static int ixgbevf_vlan_filter_set(struct rte_eth_dev *dev,
272 uint16_t vlan_id, int on);
273 static void ixgbevf_vlan_strip_queue_set(struct rte_eth_dev *dev,
274 uint16_t queue, int on);
275 static void ixgbevf_vlan_offload_set(struct rte_eth_dev *dev, int mask);
276 static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on);
277 static int ixgbevf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev,
279 static int ixgbevf_dev_rx_queue_intr_disable(struct rte_eth_dev *dev,
281 static void ixgbevf_set_ivar_map(struct ixgbe_hw *hw, int8_t direction,
282 uint8_t queue, uint8_t msix_vector);
283 static void ixgbevf_configure_msix(struct rte_eth_dev *dev);
284 static void ixgbevf_dev_allmulticast_enable(struct rte_eth_dev *dev);
285 static void ixgbevf_dev_allmulticast_disable(struct rte_eth_dev *dev);
287 /* For Eth VMDQ APIs support */
288 static int ixgbe_uc_hash_table_set(struct rte_eth_dev *dev, struct
289 ether_addr * mac_addr, uint8_t on);
290 static int ixgbe_uc_all_hash_table_set(struct rte_eth_dev *dev, uint8_t on);
291 static int ixgbe_mirror_rule_set(struct rte_eth_dev *dev,
292 struct rte_eth_mirror_conf *mirror_conf,
293 uint8_t rule_id, uint8_t on);
294 static int ixgbe_mirror_rule_reset(struct rte_eth_dev *dev,
296 static int ixgbe_dev_rx_queue_intr_enable(struct rte_eth_dev *dev,
298 static int ixgbe_dev_rx_queue_intr_disable(struct rte_eth_dev *dev,
300 static void ixgbe_set_ivar_map(struct ixgbe_hw *hw, int8_t direction,
301 uint8_t queue, uint8_t msix_vector);
302 static void ixgbe_configure_msix(struct rte_eth_dev *dev);
304 static int ixgbe_set_queue_rate_limit(struct rte_eth_dev *dev,
305 uint16_t queue_idx, uint16_t tx_rate);
307 static void ixgbevf_add_mac_addr(struct rte_eth_dev *dev,
308 struct ether_addr *mac_addr,
309 uint32_t index, uint32_t pool);
310 static void ixgbevf_remove_mac_addr(struct rte_eth_dev *dev, uint32_t index);
311 static void ixgbevf_set_default_mac_addr(struct rte_eth_dev *dev,
312 struct ether_addr *mac_addr);
313 static int ixgbe_syn_filter_get(struct rte_eth_dev *dev,
314 struct rte_eth_syn_filter *filter);
315 static int ixgbe_syn_filter_handle(struct rte_eth_dev *dev,
316 enum rte_filter_op filter_op,
318 static int ixgbe_add_5tuple_filter(struct rte_eth_dev *dev,
319 struct ixgbe_5tuple_filter *filter);
320 static void ixgbe_remove_5tuple_filter(struct rte_eth_dev *dev,
321 struct ixgbe_5tuple_filter *filter);
322 static int ixgbe_ntuple_filter_handle(struct rte_eth_dev *dev,
323 enum rte_filter_op filter_op,
325 static int ixgbe_get_ntuple_filter(struct rte_eth_dev *dev,
326 struct rte_eth_ntuple_filter *filter);
327 static int ixgbe_ethertype_filter_handle(struct rte_eth_dev *dev,
328 enum rte_filter_op filter_op,
330 static int ixgbe_get_ethertype_filter(struct rte_eth_dev *dev,
331 struct rte_eth_ethertype_filter *filter);
332 static int ixgbe_dev_filter_ctrl(struct rte_eth_dev *dev,
333 enum rte_filter_type filter_type,
334 enum rte_filter_op filter_op,
336 static int ixgbevf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu);
338 static int ixgbe_dev_set_mc_addr_list(struct rte_eth_dev *dev,
339 struct ether_addr *mc_addr_set,
340 uint32_t nb_mc_addr);
341 static int ixgbe_dev_get_dcb_info(struct rte_eth_dev *dev,
342 struct rte_eth_dcb_info *dcb_info);
344 static int ixgbe_get_reg_length(struct rte_eth_dev *dev);
345 static int ixgbe_get_regs(struct rte_eth_dev *dev,
346 struct rte_dev_reg_info *regs);
347 static int ixgbe_get_eeprom_length(struct rte_eth_dev *dev);
348 static int ixgbe_get_eeprom(struct rte_eth_dev *dev,
349 struct rte_dev_eeprom_info *eeprom);
350 static int ixgbe_set_eeprom(struct rte_eth_dev *dev,
351 struct rte_dev_eeprom_info *eeprom);
353 static int ixgbevf_get_reg_length(struct rte_eth_dev *dev);
354 static int ixgbevf_get_regs(struct rte_eth_dev *dev,
355 struct rte_dev_reg_info *regs);
357 static int ixgbe_timesync_enable(struct rte_eth_dev *dev);
358 static int ixgbe_timesync_disable(struct rte_eth_dev *dev);
359 static int ixgbe_timesync_read_rx_timestamp(struct rte_eth_dev *dev,
360 struct timespec *timestamp,
362 static int ixgbe_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
363 struct timespec *timestamp);
364 static int ixgbe_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta);
365 static int ixgbe_timesync_read_time(struct rte_eth_dev *dev,
366 struct timespec *timestamp);
367 static int ixgbe_timesync_write_time(struct rte_eth_dev *dev,
368 const struct timespec *timestamp);
369 static void ixgbevf_dev_interrupt_handler(void *param);
371 static int ixgbe_dev_l2_tunnel_eth_type_conf
372 (struct rte_eth_dev *dev, struct rte_eth_l2_tunnel_conf *l2_tunnel);
373 static int ixgbe_dev_l2_tunnel_offload_set
374 (struct rte_eth_dev *dev,
375 struct rte_eth_l2_tunnel_conf *l2_tunnel,
378 static int ixgbe_dev_l2_tunnel_filter_handle(struct rte_eth_dev *dev,
379 enum rte_filter_op filter_op,
382 static int ixgbe_dev_udp_tunnel_port_add(struct rte_eth_dev *dev,
383 struct rte_eth_udp_tunnel *udp_tunnel);
384 static int ixgbe_dev_udp_tunnel_port_del(struct rte_eth_dev *dev,
385 struct rte_eth_udp_tunnel *udp_tunnel);
386 static int ixgbe_filter_restore(struct rte_eth_dev *dev);
387 static void ixgbe_l2_tunnel_conf(struct rte_eth_dev *dev);
390 * Define VF Stats MACRO for Non "cleared on read" register
392 #define UPDATE_VF_STAT(reg, last, cur) \
394 uint32_t latest = IXGBE_READ_REG(hw, reg); \
395 cur += (latest - last) & UINT_MAX; \
399 #define UPDATE_VF_STAT_36BIT(lsb, msb, last, cur) \
401 u64 new_lsb = IXGBE_READ_REG(hw, lsb); \
402 u64 new_msb = IXGBE_READ_REG(hw, msb); \
403 u64 latest = ((new_msb << 32) | new_lsb); \
404 cur += (0x1000000000LL + latest - last) & 0xFFFFFFFFFLL; \
408 #define IXGBE_SET_HWSTRIP(h, q) do {\
409 uint32_t idx = (q) / (sizeof((h)->bitmap[0]) * NBBY); \
410 uint32_t bit = (q) % (sizeof((h)->bitmap[0]) * NBBY); \
411 (h)->bitmap[idx] |= 1 << bit;\
414 #define IXGBE_CLEAR_HWSTRIP(h, q) do {\
415 uint32_t idx = (q) / (sizeof((h)->bitmap[0]) * NBBY); \
416 uint32_t bit = (q) % (sizeof((h)->bitmap[0]) * NBBY); \
417 (h)->bitmap[idx] &= ~(1 << bit);\
420 #define IXGBE_GET_HWSTRIP(h, q, r) do {\
421 uint32_t idx = (q) / (sizeof((h)->bitmap[0]) * NBBY); \
422 uint32_t bit = (q) % (sizeof((h)->bitmap[0]) * NBBY); \
423 (r) = (h)->bitmap[idx] >> bit & 1;\
427 * The set of PCI devices this driver supports
429 static const struct rte_pci_id pci_id_ixgbe_map[] = {
430 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598) },
431 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598_BX) },
432 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AF_DUAL_PORT) },
433 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AF_SINGLE_PORT) },
434 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AT) },
435 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AT2) },
436 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598EB_SFP_LOM) },
437 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598EB_CX4) },
438 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598_CX4_DUAL_PORT) },
439 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598_DA_DUAL_PORT) },
440 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM) },
441 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598EB_XF_LR) },
442 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_KX4) },
443 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_KX4_MEZZ) },
444 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_KR) },
445 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_COMBO_BACKPLANE) },
446 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_SUBDEV_ID_82599_KX4_KR_MEZZ) },
447 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_CX4) },
448 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP) },
449 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_SUBDEV_ID_82599_SFP) },
450 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_SUBDEV_ID_82599_RNDC) },
451 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_SUBDEV_ID_82599_560FLR) },
452 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_SUBDEV_ID_82599_ECNA_DP) },
453 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_BACKPLANE_FCOE) },
454 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP_FCOE) },
455 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP_EM) },
456 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP_SF2) },
457 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP_SF_QP) },
458 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_QSFP_SF_QP) },
459 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599EN_SFP) },
460 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_XAUI_LOM) },
461 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_T3_LOM) },
462 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_LS) },
463 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X540T) },
464 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X540T1) },
465 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_SFP) },
466 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_10G_T) },
467 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_1G_T) },
468 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550T) },
469 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550T1) },
470 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_KR) },
471 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_KR_L) },
472 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_SFP_N) },
473 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_SGMII) },
474 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_SGMII_L) },
475 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_10G_T) },
476 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_QSFP) },
477 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_QSFP_N) },
478 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_SFP) },
479 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_1G_T) },
480 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_1G_T_L) },
481 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_KX4) },
482 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_KR) },
483 #ifdef RTE_NIC_BYPASS
484 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_BYPASS) },
486 { .vendor_id = 0, /* sentinel */ },
490 * The set of PCI devices this driver supports (for 82599 VF)
492 static const struct rte_pci_id pci_id_ixgbevf_map[] = {
493 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_VF) },
494 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_VF_HV) },
495 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X540_VF) },
496 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X540_VF_HV) },
497 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550_VF_HV) },
498 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550_VF) },
499 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_VF) },
500 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_VF_HV) },
501 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_VF) },
502 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_VF_HV) },
503 { .vendor_id = 0, /* sentinel */ },
506 static const struct rte_eth_desc_lim rx_desc_lim = {
507 .nb_max = IXGBE_MAX_RING_DESC,
508 .nb_min = IXGBE_MIN_RING_DESC,
509 .nb_align = IXGBE_RXD_ALIGN,
512 static const struct rte_eth_desc_lim tx_desc_lim = {
513 .nb_max = IXGBE_MAX_RING_DESC,
514 .nb_min = IXGBE_MIN_RING_DESC,
515 .nb_align = IXGBE_TXD_ALIGN,
516 .nb_seg_max = IXGBE_TX_MAX_SEG,
517 .nb_mtu_seg_max = IXGBE_TX_MAX_SEG,
520 static const struct eth_dev_ops ixgbe_eth_dev_ops = {
521 .dev_configure = ixgbe_dev_configure,
522 .dev_start = ixgbe_dev_start,
523 .dev_stop = ixgbe_dev_stop,
524 .dev_set_link_up = ixgbe_dev_set_link_up,
525 .dev_set_link_down = ixgbe_dev_set_link_down,
526 .dev_close = ixgbe_dev_close,
527 .promiscuous_enable = ixgbe_dev_promiscuous_enable,
528 .promiscuous_disable = ixgbe_dev_promiscuous_disable,
529 .allmulticast_enable = ixgbe_dev_allmulticast_enable,
530 .allmulticast_disable = ixgbe_dev_allmulticast_disable,
531 .link_update = ixgbe_dev_link_update,
532 .stats_get = ixgbe_dev_stats_get,
533 .xstats_get = ixgbe_dev_xstats_get,
534 .xstats_get_by_ids = ixgbe_dev_xstats_get_by_ids,
535 .stats_reset = ixgbe_dev_stats_reset,
536 .xstats_reset = ixgbe_dev_xstats_reset,
537 .xstats_get_names = ixgbe_dev_xstats_get_names,
538 .xstats_get_names_by_ids = ixgbe_dev_xstats_get_names_by_ids,
539 .queue_stats_mapping_set = ixgbe_dev_queue_stats_mapping_set,
540 .fw_version_get = ixgbe_fw_version_get,
541 .dev_infos_get = ixgbe_dev_info_get,
542 .dev_supported_ptypes_get = ixgbe_dev_supported_ptypes_get,
543 .mtu_set = ixgbe_dev_mtu_set,
544 .vlan_filter_set = ixgbe_vlan_filter_set,
545 .vlan_tpid_set = ixgbe_vlan_tpid_set,
546 .vlan_offload_set = ixgbe_vlan_offload_set,
547 .vlan_strip_queue_set = ixgbe_vlan_strip_queue_set,
548 .rx_queue_start = ixgbe_dev_rx_queue_start,
549 .rx_queue_stop = ixgbe_dev_rx_queue_stop,
550 .tx_queue_start = ixgbe_dev_tx_queue_start,
551 .tx_queue_stop = ixgbe_dev_tx_queue_stop,
552 .rx_queue_setup = ixgbe_dev_rx_queue_setup,
553 .rx_queue_intr_enable = ixgbe_dev_rx_queue_intr_enable,
554 .rx_queue_intr_disable = ixgbe_dev_rx_queue_intr_disable,
555 .rx_queue_release = ixgbe_dev_rx_queue_release,
556 .rx_queue_count = ixgbe_dev_rx_queue_count,
557 .rx_descriptor_done = ixgbe_dev_rx_descriptor_done,
558 .rx_descriptor_status = ixgbe_dev_rx_descriptor_status,
559 .tx_descriptor_status = ixgbe_dev_tx_descriptor_status,
560 .tx_queue_setup = ixgbe_dev_tx_queue_setup,
561 .tx_queue_release = ixgbe_dev_tx_queue_release,
562 .dev_led_on = ixgbe_dev_led_on,
563 .dev_led_off = ixgbe_dev_led_off,
564 .flow_ctrl_get = ixgbe_flow_ctrl_get,
565 .flow_ctrl_set = ixgbe_flow_ctrl_set,
566 .priority_flow_ctrl_set = ixgbe_priority_flow_ctrl_set,
567 .mac_addr_add = ixgbe_add_rar,
568 .mac_addr_remove = ixgbe_remove_rar,
569 .mac_addr_set = ixgbe_set_default_mac_addr,
570 .uc_hash_table_set = ixgbe_uc_hash_table_set,
571 .uc_all_hash_table_set = ixgbe_uc_all_hash_table_set,
572 .mirror_rule_set = ixgbe_mirror_rule_set,
573 .mirror_rule_reset = ixgbe_mirror_rule_reset,
574 .set_queue_rate_limit = ixgbe_set_queue_rate_limit,
575 .reta_update = ixgbe_dev_rss_reta_update,
576 .reta_query = ixgbe_dev_rss_reta_query,
577 #ifdef RTE_NIC_BYPASS
578 .bypass_init = ixgbe_bypass_init,
579 .bypass_state_set = ixgbe_bypass_state_store,
580 .bypass_state_show = ixgbe_bypass_state_show,
581 .bypass_event_set = ixgbe_bypass_event_store,
582 .bypass_event_show = ixgbe_bypass_event_show,
583 .bypass_wd_timeout_set = ixgbe_bypass_wd_timeout_store,
584 .bypass_wd_timeout_show = ixgbe_bypass_wd_timeout_show,
585 .bypass_ver_show = ixgbe_bypass_ver_show,
586 .bypass_wd_reset = ixgbe_bypass_wd_reset,
587 #endif /* RTE_NIC_BYPASS */
588 .rss_hash_update = ixgbe_dev_rss_hash_update,
589 .rss_hash_conf_get = ixgbe_dev_rss_hash_conf_get,
590 .filter_ctrl = ixgbe_dev_filter_ctrl,
591 .set_mc_addr_list = ixgbe_dev_set_mc_addr_list,
592 .rxq_info_get = ixgbe_rxq_info_get,
593 .txq_info_get = ixgbe_txq_info_get,
594 .timesync_enable = ixgbe_timesync_enable,
595 .timesync_disable = ixgbe_timesync_disable,
596 .timesync_read_rx_timestamp = ixgbe_timesync_read_rx_timestamp,
597 .timesync_read_tx_timestamp = ixgbe_timesync_read_tx_timestamp,
598 .get_reg = ixgbe_get_regs,
599 .get_eeprom_length = ixgbe_get_eeprom_length,
600 .get_eeprom = ixgbe_get_eeprom,
601 .set_eeprom = ixgbe_set_eeprom,
602 .get_dcb_info = ixgbe_dev_get_dcb_info,
603 .timesync_adjust_time = ixgbe_timesync_adjust_time,
604 .timesync_read_time = ixgbe_timesync_read_time,
605 .timesync_write_time = ixgbe_timesync_write_time,
606 .l2_tunnel_eth_type_conf = ixgbe_dev_l2_tunnel_eth_type_conf,
607 .l2_tunnel_offload_set = ixgbe_dev_l2_tunnel_offload_set,
608 .udp_tunnel_port_add = ixgbe_dev_udp_tunnel_port_add,
609 .udp_tunnel_port_del = ixgbe_dev_udp_tunnel_port_del,
613 * dev_ops for virtual function, bare necessities for basic vf
614 * operation have been implemented
616 static const struct eth_dev_ops ixgbevf_eth_dev_ops = {
617 .dev_configure = ixgbevf_dev_configure,
618 .dev_start = ixgbevf_dev_start,
619 .dev_stop = ixgbevf_dev_stop,
620 .link_update = ixgbe_dev_link_update,
621 .stats_get = ixgbevf_dev_stats_get,
622 .xstats_get = ixgbevf_dev_xstats_get,
623 .stats_reset = ixgbevf_dev_stats_reset,
624 .xstats_reset = ixgbevf_dev_stats_reset,
625 .xstats_get_names = ixgbevf_dev_xstats_get_names,
626 .dev_close = ixgbevf_dev_close,
627 .allmulticast_enable = ixgbevf_dev_allmulticast_enable,
628 .allmulticast_disable = ixgbevf_dev_allmulticast_disable,
629 .dev_infos_get = ixgbevf_dev_info_get,
630 .dev_supported_ptypes_get = ixgbe_dev_supported_ptypes_get,
631 .mtu_set = ixgbevf_dev_set_mtu,
632 .vlan_filter_set = ixgbevf_vlan_filter_set,
633 .vlan_strip_queue_set = ixgbevf_vlan_strip_queue_set,
634 .vlan_offload_set = ixgbevf_vlan_offload_set,
635 .rx_queue_setup = ixgbe_dev_rx_queue_setup,
636 .rx_queue_release = ixgbe_dev_rx_queue_release,
637 .rx_descriptor_done = ixgbe_dev_rx_descriptor_done,
638 .rx_descriptor_status = ixgbe_dev_rx_descriptor_status,
639 .tx_descriptor_status = ixgbe_dev_tx_descriptor_status,
640 .tx_queue_setup = ixgbe_dev_tx_queue_setup,
641 .tx_queue_release = ixgbe_dev_tx_queue_release,
642 .rx_queue_intr_enable = ixgbevf_dev_rx_queue_intr_enable,
643 .rx_queue_intr_disable = ixgbevf_dev_rx_queue_intr_disable,
644 .mac_addr_add = ixgbevf_add_mac_addr,
645 .mac_addr_remove = ixgbevf_remove_mac_addr,
646 .set_mc_addr_list = ixgbe_dev_set_mc_addr_list,
647 .rxq_info_get = ixgbe_rxq_info_get,
648 .txq_info_get = ixgbe_txq_info_get,
649 .mac_addr_set = ixgbevf_set_default_mac_addr,
650 .get_reg = ixgbevf_get_regs,
651 .reta_update = ixgbe_dev_rss_reta_update,
652 .reta_query = ixgbe_dev_rss_reta_query,
653 .rss_hash_update = ixgbe_dev_rss_hash_update,
654 .rss_hash_conf_get = ixgbe_dev_rss_hash_conf_get,
657 /* store statistics names and its offset in stats structure */
658 struct rte_ixgbe_xstats_name_off {
659 char name[RTE_ETH_XSTATS_NAME_SIZE];
663 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_stats_strings[] = {
664 {"rx_crc_errors", offsetof(struct ixgbe_hw_stats, crcerrs)},
665 {"rx_illegal_byte_errors", offsetof(struct ixgbe_hw_stats, illerrc)},
666 {"rx_error_bytes", offsetof(struct ixgbe_hw_stats, errbc)},
667 {"mac_local_errors", offsetof(struct ixgbe_hw_stats, mlfc)},
668 {"mac_remote_errors", offsetof(struct ixgbe_hw_stats, mrfc)},
669 {"rx_length_errors", offsetof(struct ixgbe_hw_stats, rlec)},
670 {"tx_xon_packets", offsetof(struct ixgbe_hw_stats, lxontxc)},
671 {"rx_xon_packets", offsetof(struct ixgbe_hw_stats, lxonrxc)},
672 {"tx_xoff_packets", offsetof(struct ixgbe_hw_stats, lxofftxc)},
673 {"rx_xoff_packets", offsetof(struct ixgbe_hw_stats, lxoffrxc)},
674 {"rx_size_64_packets", offsetof(struct ixgbe_hw_stats, prc64)},
675 {"rx_size_65_to_127_packets", offsetof(struct ixgbe_hw_stats, prc127)},
676 {"rx_size_128_to_255_packets", offsetof(struct ixgbe_hw_stats, prc255)},
677 {"rx_size_256_to_511_packets", offsetof(struct ixgbe_hw_stats, prc511)},
678 {"rx_size_512_to_1023_packets", offsetof(struct ixgbe_hw_stats,
680 {"rx_size_1024_to_max_packets", offsetof(struct ixgbe_hw_stats,
682 {"rx_broadcast_packets", offsetof(struct ixgbe_hw_stats, bprc)},
683 {"rx_multicast_packets", offsetof(struct ixgbe_hw_stats, mprc)},
684 {"rx_fragment_errors", offsetof(struct ixgbe_hw_stats, rfc)},
685 {"rx_undersize_errors", offsetof(struct ixgbe_hw_stats, ruc)},
686 {"rx_oversize_errors", offsetof(struct ixgbe_hw_stats, roc)},
687 {"rx_jabber_errors", offsetof(struct ixgbe_hw_stats, rjc)},
688 {"rx_management_packets", offsetof(struct ixgbe_hw_stats, mngprc)},
689 {"rx_management_dropped", offsetof(struct ixgbe_hw_stats, mngpdc)},
690 {"tx_management_packets", offsetof(struct ixgbe_hw_stats, mngptc)},
691 {"rx_total_packets", offsetof(struct ixgbe_hw_stats, tpr)},
692 {"rx_total_bytes", offsetof(struct ixgbe_hw_stats, tor)},
693 {"tx_total_packets", offsetof(struct ixgbe_hw_stats, tpt)},
694 {"tx_size_64_packets", offsetof(struct ixgbe_hw_stats, ptc64)},
695 {"tx_size_65_to_127_packets", offsetof(struct ixgbe_hw_stats, ptc127)},
696 {"tx_size_128_to_255_packets", offsetof(struct ixgbe_hw_stats, ptc255)},
697 {"tx_size_256_to_511_packets", offsetof(struct ixgbe_hw_stats, ptc511)},
698 {"tx_size_512_to_1023_packets", offsetof(struct ixgbe_hw_stats,
700 {"tx_size_1024_to_max_packets", offsetof(struct ixgbe_hw_stats,
702 {"tx_multicast_packets", offsetof(struct ixgbe_hw_stats, mptc)},
703 {"tx_broadcast_packets", offsetof(struct ixgbe_hw_stats, bptc)},
704 {"rx_mac_short_packet_dropped", offsetof(struct ixgbe_hw_stats, mspdc)},
705 {"rx_l3_l4_xsum_error", offsetof(struct ixgbe_hw_stats, xec)},
707 {"flow_director_added_filters", offsetof(struct ixgbe_hw_stats,
709 {"flow_director_removed_filters", offsetof(struct ixgbe_hw_stats,
711 {"flow_director_filter_add_errors", offsetof(struct ixgbe_hw_stats,
713 {"flow_director_filter_remove_errors", offsetof(struct ixgbe_hw_stats,
715 {"flow_director_matched_filters", offsetof(struct ixgbe_hw_stats,
717 {"flow_director_missed_filters", offsetof(struct ixgbe_hw_stats,
720 {"rx_fcoe_crc_errors", offsetof(struct ixgbe_hw_stats, fccrc)},
721 {"rx_fcoe_dropped", offsetof(struct ixgbe_hw_stats, fcoerpdc)},
722 {"rx_fcoe_mbuf_allocation_errors", offsetof(struct ixgbe_hw_stats,
724 {"rx_fcoe_packets", offsetof(struct ixgbe_hw_stats, fcoeprc)},
725 {"tx_fcoe_packets", offsetof(struct ixgbe_hw_stats, fcoeptc)},
726 {"rx_fcoe_bytes", offsetof(struct ixgbe_hw_stats, fcoedwrc)},
727 {"tx_fcoe_bytes", offsetof(struct ixgbe_hw_stats, fcoedwtc)},
728 {"rx_fcoe_no_direct_data_placement", offsetof(struct ixgbe_hw_stats,
730 {"rx_fcoe_no_direct_data_placement_ext_buff",
731 offsetof(struct ixgbe_hw_stats, fcoe_noddp_ext_buff)},
733 {"tx_flow_control_xon_packets", offsetof(struct ixgbe_hw_stats,
735 {"rx_flow_control_xon_packets", offsetof(struct ixgbe_hw_stats,
737 {"tx_flow_control_xoff_packets", offsetof(struct ixgbe_hw_stats,
739 {"rx_flow_control_xoff_packets", offsetof(struct ixgbe_hw_stats,
741 {"rx_total_missed_packets", offsetof(struct ixgbe_hw_stats, mpctotal)},
744 #define IXGBE_NB_HW_STATS (sizeof(rte_ixgbe_stats_strings) / \
745 sizeof(rte_ixgbe_stats_strings[0]))
747 /* MACsec statistics */
748 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_macsec_strings[] = {
749 {"out_pkts_untagged", offsetof(struct ixgbe_macsec_stats,
751 {"out_pkts_encrypted", offsetof(struct ixgbe_macsec_stats,
752 out_pkts_encrypted)},
753 {"out_pkts_protected", offsetof(struct ixgbe_macsec_stats,
754 out_pkts_protected)},
755 {"out_octets_encrypted", offsetof(struct ixgbe_macsec_stats,
756 out_octets_encrypted)},
757 {"out_octets_protected", offsetof(struct ixgbe_macsec_stats,
758 out_octets_protected)},
759 {"in_pkts_untagged", offsetof(struct ixgbe_macsec_stats,
761 {"in_pkts_badtag", offsetof(struct ixgbe_macsec_stats,
763 {"in_pkts_nosci", offsetof(struct ixgbe_macsec_stats,
765 {"in_pkts_unknownsci", offsetof(struct ixgbe_macsec_stats,
766 in_pkts_unknownsci)},
767 {"in_octets_decrypted", offsetof(struct ixgbe_macsec_stats,
768 in_octets_decrypted)},
769 {"in_octets_validated", offsetof(struct ixgbe_macsec_stats,
770 in_octets_validated)},
771 {"in_pkts_unchecked", offsetof(struct ixgbe_macsec_stats,
773 {"in_pkts_delayed", offsetof(struct ixgbe_macsec_stats,
775 {"in_pkts_late", offsetof(struct ixgbe_macsec_stats,
777 {"in_pkts_ok", offsetof(struct ixgbe_macsec_stats,
779 {"in_pkts_invalid", offsetof(struct ixgbe_macsec_stats,
781 {"in_pkts_notvalid", offsetof(struct ixgbe_macsec_stats,
783 {"in_pkts_unusedsa", offsetof(struct ixgbe_macsec_stats,
785 {"in_pkts_notusingsa", offsetof(struct ixgbe_macsec_stats,
786 in_pkts_notusingsa)},
789 #define IXGBE_NB_MACSEC_STATS (sizeof(rte_ixgbe_macsec_strings) / \
790 sizeof(rte_ixgbe_macsec_strings[0]))
792 /* Per-queue statistics */
793 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_rxq_strings[] = {
794 {"mbuf_allocation_errors", offsetof(struct ixgbe_hw_stats, rnbc)},
795 {"dropped", offsetof(struct ixgbe_hw_stats, mpc)},
796 {"xon_packets", offsetof(struct ixgbe_hw_stats, pxonrxc)},
797 {"xoff_packets", offsetof(struct ixgbe_hw_stats, pxoffrxc)},
800 #define IXGBE_NB_RXQ_PRIO_STATS (sizeof(rte_ixgbe_rxq_strings) / \
801 sizeof(rte_ixgbe_rxq_strings[0]))
802 #define IXGBE_NB_RXQ_PRIO_VALUES 8
804 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_txq_strings[] = {
805 {"xon_packets", offsetof(struct ixgbe_hw_stats, pxontxc)},
806 {"xoff_packets", offsetof(struct ixgbe_hw_stats, pxofftxc)},
807 {"xon_to_xoff_packets", offsetof(struct ixgbe_hw_stats,
811 #define IXGBE_NB_TXQ_PRIO_STATS (sizeof(rte_ixgbe_txq_strings) / \
812 sizeof(rte_ixgbe_txq_strings[0]))
813 #define IXGBE_NB_TXQ_PRIO_VALUES 8
815 static const struct rte_ixgbe_xstats_name_off rte_ixgbevf_stats_strings[] = {
816 {"rx_multicast_packets", offsetof(struct ixgbevf_hw_stats, vfmprc)},
819 #define IXGBEVF_NB_XSTATS (sizeof(rte_ixgbevf_stats_strings) / \
820 sizeof(rte_ixgbevf_stats_strings[0]))
823 * Atomically reads the link status information from global
824 * structure rte_eth_dev.
827 * - Pointer to the structure rte_eth_dev to read from.
828 * - Pointer to the buffer to be saved with the link status.
831 * - On success, zero.
832 * - On failure, negative value.
835 rte_ixgbe_dev_atomic_read_link_status(struct rte_eth_dev *dev,
836 struct rte_eth_link *link)
838 struct rte_eth_link *dst = link;
839 struct rte_eth_link *src = &(dev->data->dev_link);
841 if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
842 *(uint64_t *)src) == 0)
849 * Atomically writes the link status information into global
850 * structure rte_eth_dev.
853 * - Pointer to the structure rte_eth_dev to read from.
854 * - Pointer to the buffer to be saved with the link status.
857 * - On success, zero.
858 * - On failure, negative value.
861 rte_ixgbe_dev_atomic_write_link_status(struct rte_eth_dev *dev,
862 struct rte_eth_link *link)
864 struct rte_eth_link *dst = &(dev->data->dev_link);
865 struct rte_eth_link *src = link;
867 if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
868 *(uint64_t *)src) == 0)
875 * This function is the same as ixgbe_is_sfp() in base/ixgbe.h.
878 ixgbe_is_sfp(struct ixgbe_hw *hw)
880 switch (hw->phy.type) {
881 case ixgbe_phy_sfp_avago:
882 case ixgbe_phy_sfp_ftl:
883 case ixgbe_phy_sfp_intel:
884 case ixgbe_phy_sfp_unknown:
885 case ixgbe_phy_sfp_passive_tyco:
886 case ixgbe_phy_sfp_passive_unknown:
893 static inline int32_t
894 ixgbe_pf_reset_hw(struct ixgbe_hw *hw)
899 status = ixgbe_reset_hw(hw);
901 ctrl_ext = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
902 /* Set PF Reset Done bit so PF/VF Mail Ops can work */
903 ctrl_ext |= IXGBE_CTRL_EXT_PFRSTD;
904 IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl_ext);
905 IXGBE_WRITE_FLUSH(hw);
907 if (status == IXGBE_ERR_SFP_NOT_PRESENT)
908 status = IXGBE_SUCCESS;
913 ixgbe_enable_intr(struct rte_eth_dev *dev)
915 struct ixgbe_interrupt *intr =
916 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
917 struct ixgbe_hw *hw =
918 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
920 IXGBE_WRITE_REG(hw, IXGBE_EIMS, intr->mask);
921 IXGBE_WRITE_FLUSH(hw);
925 * This function is based on ixgbe_disable_intr() in base/ixgbe.h.
928 ixgbe_disable_intr(struct ixgbe_hw *hw)
930 PMD_INIT_FUNC_TRACE();
932 if (hw->mac.type == ixgbe_mac_82598EB) {
933 IXGBE_WRITE_REG(hw, IXGBE_EIMC, ~0);
935 IXGBE_WRITE_REG(hw, IXGBE_EIMC, 0xFFFF0000);
936 IXGBE_WRITE_REG(hw, IXGBE_EIMC_EX(0), ~0);
937 IXGBE_WRITE_REG(hw, IXGBE_EIMC_EX(1), ~0);
939 IXGBE_WRITE_FLUSH(hw);
943 * This function resets queue statistics mapping registers.
944 * From Niantic datasheet, Initialization of Statistics section:
945 * "...if software requires the queue counters, the RQSMR and TQSM registers
946 * must be re-programmed following a device reset.
949 ixgbe_reset_qstat_mappings(struct ixgbe_hw *hw)
953 for (i = 0; i != IXGBE_NB_STAT_MAPPING_REGS; i++) {
954 IXGBE_WRITE_REG(hw, IXGBE_RQSMR(i), 0);
955 IXGBE_WRITE_REG(hw, IXGBE_TQSM(i), 0);
961 ixgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
966 #define QSM_REG_NB_BITS_PER_QMAP_FIELD 8
967 #define NB_QMAP_FIELDS_PER_QSM_REG 4
968 #define QMAP_FIELD_RESERVED_BITS_MASK 0x0f
970 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
971 struct ixgbe_stat_mapping_registers *stat_mappings =
972 IXGBE_DEV_PRIVATE_TO_STAT_MAPPINGS(eth_dev->data->dev_private);
973 uint32_t qsmr_mask = 0;
974 uint32_t clearing_mask = QMAP_FIELD_RESERVED_BITS_MASK;
978 if ((hw->mac.type != ixgbe_mac_82599EB) &&
979 (hw->mac.type != ixgbe_mac_X540) &&
980 (hw->mac.type != ixgbe_mac_X550) &&
981 (hw->mac.type != ixgbe_mac_X550EM_x) &&
982 (hw->mac.type != ixgbe_mac_X550EM_a))
985 PMD_INIT_LOG(DEBUG, "Setting port %d, %s queue_id %d to stat index %d",
986 (int)(eth_dev->data->port_id), is_rx ? "RX" : "TX",
989 n = (uint8_t)(queue_id / NB_QMAP_FIELDS_PER_QSM_REG);
990 if (n >= IXGBE_NB_STAT_MAPPING_REGS) {
991 PMD_INIT_LOG(ERR, "Nb of stat mapping registers exceeded");
994 offset = (uint8_t)(queue_id % NB_QMAP_FIELDS_PER_QSM_REG);
996 /* Now clear any previous stat_idx set */
997 clearing_mask <<= (QSM_REG_NB_BITS_PER_QMAP_FIELD * offset);
999 stat_mappings->tqsm[n] &= ~clearing_mask;
1001 stat_mappings->rqsmr[n] &= ~clearing_mask;
1003 q_map = (uint32_t)stat_idx;
1004 q_map &= QMAP_FIELD_RESERVED_BITS_MASK;
1005 qsmr_mask = q_map << (QSM_REG_NB_BITS_PER_QMAP_FIELD * offset);
1007 stat_mappings->tqsm[n] |= qsmr_mask;
1009 stat_mappings->rqsmr[n] |= qsmr_mask;
1011 PMD_INIT_LOG(DEBUG, "Set port %d, %s queue_id %d to stat index %d",
1012 (int)(eth_dev->data->port_id), is_rx ? "RX" : "TX",
1013 queue_id, stat_idx);
1014 PMD_INIT_LOG(DEBUG, "%s[%d] = 0x%08x", is_rx ? "RQSMR" : "TQSM", n,
1015 is_rx ? stat_mappings->rqsmr[n] : stat_mappings->tqsm[n]);
1017 /* Now write the mapping in the appropriate register */
1019 PMD_INIT_LOG(DEBUG, "Write 0x%x to RX IXGBE stat mapping reg:%d",
1020 stat_mappings->rqsmr[n], n);
1021 IXGBE_WRITE_REG(hw, IXGBE_RQSMR(n), stat_mappings->rqsmr[n]);
1023 PMD_INIT_LOG(DEBUG, "Write 0x%x to TX IXGBE stat mapping reg:%d",
1024 stat_mappings->tqsm[n], n);
1025 IXGBE_WRITE_REG(hw, IXGBE_TQSM(n), stat_mappings->tqsm[n]);
1031 ixgbe_restore_statistics_mapping(struct rte_eth_dev *dev)
1033 struct ixgbe_stat_mapping_registers *stat_mappings =
1034 IXGBE_DEV_PRIVATE_TO_STAT_MAPPINGS(dev->data->dev_private);
1035 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1038 /* write whatever was in stat mapping table to the NIC */
1039 for (i = 0; i < IXGBE_NB_STAT_MAPPING_REGS; i++) {
1041 IXGBE_WRITE_REG(hw, IXGBE_RQSMR(i), stat_mappings->rqsmr[i]);
1044 IXGBE_WRITE_REG(hw, IXGBE_TQSM(i), stat_mappings->tqsm[i]);
1049 ixgbe_dcb_init(struct ixgbe_hw *hw, struct ixgbe_dcb_config *dcb_config)
1052 struct ixgbe_dcb_tc_config *tc;
1053 uint8_t dcb_max_tc = IXGBE_DCB_MAX_TRAFFIC_CLASS;
1055 dcb_config->num_tcs.pg_tcs = dcb_max_tc;
1056 dcb_config->num_tcs.pfc_tcs = dcb_max_tc;
1057 for (i = 0; i < dcb_max_tc; i++) {
1058 tc = &dcb_config->tc_config[i];
1059 tc->path[IXGBE_DCB_TX_CONFIG].bwg_id = i;
1060 tc->path[IXGBE_DCB_TX_CONFIG].bwg_percent =
1061 (uint8_t)(100/dcb_max_tc + (i & 1));
1062 tc->path[IXGBE_DCB_RX_CONFIG].bwg_id = i;
1063 tc->path[IXGBE_DCB_RX_CONFIG].bwg_percent =
1064 (uint8_t)(100/dcb_max_tc + (i & 1));
1065 tc->pfc = ixgbe_dcb_pfc_disabled;
1068 /* Initialize default user to priority mapping, UPx->TC0 */
1069 tc = &dcb_config->tc_config[0];
1070 tc->path[IXGBE_DCB_TX_CONFIG].up_to_tc_bitmap = 0xFF;
1071 tc->path[IXGBE_DCB_RX_CONFIG].up_to_tc_bitmap = 0xFF;
1072 for (i = 0; i < IXGBE_DCB_MAX_BW_GROUP; i++) {
1073 dcb_config->bw_percentage[IXGBE_DCB_TX_CONFIG][i] = 100;
1074 dcb_config->bw_percentage[IXGBE_DCB_RX_CONFIG][i] = 100;
1076 dcb_config->rx_pba_cfg = ixgbe_dcb_pba_equal;
1077 dcb_config->pfc_mode_enable = false;
1078 dcb_config->vt_mode = true;
1079 dcb_config->round_robin_enable = false;
1080 /* support all DCB capabilities in 82599 */
1081 dcb_config->support.capabilities = 0xFF;
1083 /*we only support 4 Tcs for X540, X550 */
1084 if (hw->mac.type == ixgbe_mac_X540 ||
1085 hw->mac.type == ixgbe_mac_X550 ||
1086 hw->mac.type == ixgbe_mac_X550EM_x ||
1087 hw->mac.type == ixgbe_mac_X550EM_a) {
1088 dcb_config->num_tcs.pg_tcs = 4;
1089 dcb_config->num_tcs.pfc_tcs = 4;
1094 * Ensure that all locks are released before first NVM or PHY access
1097 ixgbe_swfw_lock_reset(struct ixgbe_hw *hw)
1102 * Phy lock should not fail in this early stage. If this is the case,
1103 * it is due to an improper exit of the application.
1104 * So force the release of the faulty lock. Release of common lock
1105 * is done automatically by swfw_sync function.
1107 mask = IXGBE_GSSR_PHY0_SM << hw->bus.func;
1108 if (ixgbe_acquire_swfw_semaphore(hw, mask) < 0) {
1109 PMD_DRV_LOG(DEBUG, "SWFW phy%d lock released", hw->bus.func);
1111 ixgbe_release_swfw_semaphore(hw, mask);
1114 * These ones are more tricky since they are common to all ports; but
1115 * swfw_sync retries last long enough (1s) to be almost sure that if
1116 * lock can not be taken it is due to an improper lock of the
1119 mask = IXGBE_GSSR_EEP_SM | IXGBE_GSSR_MAC_CSR_SM | IXGBE_GSSR_SW_MNG_SM;
1120 if (ixgbe_acquire_swfw_semaphore(hw, mask) < 0) {
1121 PMD_DRV_LOG(DEBUG, "SWFW common locks released");
1123 ixgbe_release_swfw_semaphore(hw, mask);
1127 * This function is based on code in ixgbe_attach() in base/ixgbe.c.
1128 * It returns 0 on success.
1131 eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev)
1133 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(eth_dev);
1134 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
1135 struct ixgbe_hw *hw =
1136 IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
1137 struct ixgbe_vfta *shadow_vfta =
1138 IXGBE_DEV_PRIVATE_TO_VFTA(eth_dev->data->dev_private);
1139 struct ixgbe_hwstrip *hwstrip =
1140 IXGBE_DEV_PRIVATE_TO_HWSTRIP_BITMAP(eth_dev->data->dev_private);
1141 struct ixgbe_dcb_config *dcb_config =
1142 IXGBE_DEV_PRIVATE_TO_DCB_CFG(eth_dev->data->dev_private);
1143 struct ixgbe_filter_info *filter_info =
1144 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(eth_dev->data->dev_private);
1145 struct ixgbe_bw_conf *bw_conf =
1146 IXGBE_DEV_PRIVATE_TO_BW_CONF(eth_dev->data->dev_private);
1151 PMD_INIT_FUNC_TRACE();
1153 eth_dev->dev_ops = &ixgbe_eth_dev_ops;
1154 eth_dev->rx_pkt_burst = &ixgbe_recv_pkts;
1155 eth_dev->tx_pkt_burst = &ixgbe_xmit_pkts;
1156 eth_dev->tx_pkt_prepare = &ixgbe_prep_pkts;
1159 * For secondary processes, we don't initialise any further as primary
1160 * has already done this work. Only check we don't need a different
1161 * RX and TX function.
1163 if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
1164 struct ixgbe_tx_queue *txq;
1165 /* TX queue function in primary, set by last queue initialized
1166 * Tx queue may not initialized by primary process
1168 if (eth_dev->data->tx_queues) {
1169 txq = eth_dev->data->tx_queues[eth_dev->data->nb_tx_queues-1];
1170 ixgbe_set_tx_function(eth_dev, txq);
1172 /* Use default TX function if we get here */
1173 PMD_INIT_LOG(NOTICE, "No TX queues configured yet. "
1174 "Using default TX function.");
1177 ixgbe_set_rx_function(eth_dev);
1182 rte_eth_copy_pci_info(eth_dev, pci_dev);
1183 eth_dev->data->dev_flags |= RTE_ETH_DEV_DETACHABLE;
1185 /* Vendor and Device ID need to be set before init of shared code */
1186 hw->device_id = pci_dev->id.device_id;
1187 hw->vendor_id = pci_dev->id.vendor_id;
1188 hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
1189 hw->allow_unsupported_sfp = 1;
1191 /* Initialize the shared code (base driver) */
1192 #ifdef RTE_NIC_BYPASS
1193 diag = ixgbe_bypass_init_shared_code(hw);
1195 diag = ixgbe_init_shared_code(hw);
1196 #endif /* RTE_NIC_BYPASS */
1198 if (diag != IXGBE_SUCCESS) {
1199 PMD_INIT_LOG(ERR, "Shared code init failed: %d", diag);
1203 /* pick up the PCI bus settings for reporting later */
1204 ixgbe_get_bus_info(hw);
1206 /* Unlock any pending hardware semaphore */
1207 ixgbe_swfw_lock_reset(hw);
1209 /* Initialize DCB configuration*/
1210 memset(dcb_config, 0, sizeof(struct ixgbe_dcb_config));
1211 ixgbe_dcb_init(hw, dcb_config);
1212 /* Get Hardware Flow Control setting */
1213 hw->fc.requested_mode = ixgbe_fc_full;
1214 hw->fc.current_mode = ixgbe_fc_full;
1215 hw->fc.pause_time = IXGBE_FC_PAUSE;
1216 for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
1217 hw->fc.low_water[i] = IXGBE_FC_LO;
1218 hw->fc.high_water[i] = IXGBE_FC_HI;
1220 hw->fc.send_xon = 1;
1222 /* Make sure we have a good EEPROM before we read from it */
1223 diag = ixgbe_validate_eeprom_checksum(hw, &csum);
1224 if (diag != IXGBE_SUCCESS) {
1225 PMD_INIT_LOG(ERR, "The EEPROM checksum is not valid: %d", diag);
1229 #ifdef RTE_NIC_BYPASS
1230 diag = ixgbe_bypass_init_hw(hw);
1232 diag = ixgbe_init_hw(hw);
1233 #endif /* RTE_NIC_BYPASS */
1236 * Devices with copper phys will fail to initialise if ixgbe_init_hw()
1237 * is called too soon after the kernel driver unbinding/binding occurs.
1238 * The failure occurs in ixgbe_identify_phy_generic() for all devices,
1239 * but for non-copper devies, ixgbe_identify_sfp_module_generic() is
1240 * also called. See ixgbe_identify_phy_82599(). The reason for the
1241 * failure is not known, and only occuts when virtualisation features
1242 * are disabled in the bios. A delay of 100ms was found to be enough by
1243 * trial-and-error, and is doubled to be safe.
1245 if (diag && (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper)) {
1247 diag = ixgbe_init_hw(hw);
1250 if (diag == IXGBE_ERR_SFP_NOT_PRESENT)
1251 diag = IXGBE_SUCCESS;
1253 if (diag == IXGBE_ERR_EEPROM_VERSION) {
1254 PMD_INIT_LOG(ERR, "This device is a pre-production adapter/"
1255 "LOM. Please be aware there may be issues associated "
1256 "with your hardware.");
1257 PMD_INIT_LOG(ERR, "If you are experiencing problems "
1258 "please contact your Intel or hardware representative "
1259 "who provided you with this hardware.");
1260 } else if (diag == IXGBE_ERR_SFP_NOT_SUPPORTED)
1261 PMD_INIT_LOG(ERR, "Unsupported SFP+ Module");
1263 PMD_INIT_LOG(ERR, "Hardware Initialization Failure: %d", diag);
1267 /* Reset the hw statistics */
1268 ixgbe_dev_stats_reset(eth_dev);
1270 /* disable interrupt */
1271 ixgbe_disable_intr(hw);
1273 /* reset mappings for queue statistics hw counters*/
1274 ixgbe_reset_qstat_mappings(hw);
1276 /* Allocate memory for storing MAC addresses */
1277 eth_dev->data->mac_addrs = rte_zmalloc("ixgbe", ETHER_ADDR_LEN *
1278 hw->mac.num_rar_entries, 0);
1279 if (eth_dev->data->mac_addrs == NULL) {
1281 "Failed to allocate %u bytes needed to store "
1283 ETHER_ADDR_LEN * hw->mac.num_rar_entries);
1286 /* Copy the permanent MAC address */
1287 ether_addr_copy((struct ether_addr *) hw->mac.perm_addr,
1288 ð_dev->data->mac_addrs[0]);
1290 /* Allocate memory for storing hash filter MAC addresses */
1291 eth_dev->data->hash_mac_addrs = rte_zmalloc("ixgbe", ETHER_ADDR_LEN *
1292 IXGBE_VMDQ_NUM_UC_MAC, 0);
1293 if (eth_dev->data->hash_mac_addrs == NULL) {
1295 "Failed to allocate %d bytes needed to store MAC addresses",
1296 ETHER_ADDR_LEN * IXGBE_VMDQ_NUM_UC_MAC);
1300 /* initialize the vfta */
1301 memset(shadow_vfta, 0, sizeof(*shadow_vfta));
1303 /* initialize the hw strip bitmap*/
1304 memset(hwstrip, 0, sizeof(*hwstrip));
1306 /* initialize PF if max_vfs not zero */
1307 ixgbe_pf_host_init(eth_dev);
1309 ctrl_ext = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
1310 /* let hardware know driver is loaded */
1311 ctrl_ext |= IXGBE_CTRL_EXT_DRV_LOAD;
1312 /* Set PF Reset Done bit so PF/VF Mail Ops can work */
1313 ctrl_ext |= IXGBE_CTRL_EXT_PFRSTD;
1314 IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl_ext);
1315 IXGBE_WRITE_FLUSH(hw);
1317 if (ixgbe_is_sfp(hw) && hw->phy.sfp_type != ixgbe_sfp_type_not_present)
1318 PMD_INIT_LOG(DEBUG, "MAC: %d, PHY: %d, SFP+: %d",
1319 (int) hw->mac.type, (int) hw->phy.type,
1320 (int) hw->phy.sfp_type);
1322 PMD_INIT_LOG(DEBUG, "MAC: %d, PHY: %d",
1323 (int) hw->mac.type, (int) hw->phy.type);
1325 PMD_INIT_LOG(DEBUG, "port %d vendorID=0x%x deviceID=0x%x",
1326 eth_dev->data->port_id, pci_dev->id.vendor_id,
1327 pci_dev->id.device_id);
1329 rte_intr_callback_register(intr_handle,
1330 ixgbe_dev_interrupt_handler, eth_dev);
1332 /* enable uio/vfio intr/eventfd mapping */
1333 rte_intr_enable(intr_handle);
1335 /* enable support intr */
1336 ixgbe_enable_intr(eth_dev);
1338 /* initialize filter info */
1339 memset(filter_info, 0,
1340 sizeof(struct ixgbe_filter_info));
1342 /* initialize 5tuple filter list */
1343 TAILQ_INIT(&filter_info->fivetuple_list);
1345 /* initialize flow director filter list & hash */
1346 ixgbe_fdir_filter_init(eth_dev);
1348 /* initialize l2 tunnel filter list & hash */
1349 ixgbe_l2_tn_filter_init(eth_dev);
1351 TAILQ_INIT(&filter_ntuple_list);
1352 TAILQ_INIT(&filter_ethertype_list);
1353 TAILQ_INIT(&filter_syn_list);
1354 TAILQ_INIT(&filter_fdir_list);
1355 TAILQ_INIT(&filter_l2_tunnel_list);
1356 TAILQ_INIT(&ixgbe_flow_list);
1358 /* initialize bandwidth configuration info */
1359 memset(bw_conf, 0, sizeof(struct ixgbe_bw_conf));
1365 eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev)
1367 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(eth_dev);
1368 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
1369 struct ixgbe_hw *hw;
1371 PMD_INIT_FUNC_TRACE();
1373 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
1376 hw = IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
1378 if (hw->adapter_stopped == 0)
1379 ixgbe_dev_close(eth_dev);
1381 eth_dev->dev_ops = NULL;
1382 eth_dev->rx_pkt_burst = NULL;
1383 eth_dev->tx_pkt_burst = NULL;
1385 /* Unlock any pending hardware semaphore */
1386 ixgbe_swfw_lock_reset(hw);
1388 /* disable uio intr before callback unregister */
1389 rte_intr_disable(intr_handle);
1390 rte_intr_callback_unregister(intr_handle,
1391 ixgbe_dev_interrupt_handler, eth_dev);
1393 /* uninitialize PF if max_vfs not zero */
1394 ixgbe_pf_host_uninit(eth_dev);
1396 rte_free(eth_dev->data->mac_addrs);
1397 eth_dev->data->mac_addrs = NULL;
1399 rte_free(eth_dev->data->hash_mac_addrs);
1400 eth_dev->data->hash_mac_addrs = NULL;
1402 /* remove all the fdir filters & hash */
1403 ixgbe_fdir_filter_uninit(eth_dev);
1405 /* remove all the L2 tunnel filters & hash */
1406 ixgbe_l2_tn_filter_uninit(eth_dev);
1408 /* Remove all ntuple filters of the device */
1409 ixgbe_ntuple_filter_uninit(eth_dev);
1411 /* clear all the filters list */
1412 ixgbe_filterlist_flush();
1417 static int ixgbe_ntuple_filter_uninit(struct rte_eth_dev *eth_dev)
1419 struct ixgbe_filter_info *filter_info =
1420 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(eth_dev->data->dev_private);
1421 struct ixgbe_5tuple_filter *p_5tuple;
1423 while ((p_5tuple = TAILQ_FIRST(&filter_info->fivetuple_list))) {
1424 TAILQ_REMOVE(&filter_info->fivetuple_list,
1429 memset(filter_info->fivetuple_mask, 0,
1430 sizeof(uint32_t) * IXGBE_5TUPLE_ARRAY_SIZE);
1435 static int ixgbe_fdir_filter_uninit(struct rte_eth_dev *eth_dev)
1437 struct ixgbe_hw_fdir_info *fdir_info =
1438 IXGBE_DEV_PRIVATE_TO_FDIR_INFO(eth_dev->data->dev_private);
1439 struct ixgbe_fdir_filter *fdir_filter;
1441 if (fdir_info->hash_map)
1442 rte_free(fdir_info->hash_map);
1443 if (fdir_info->hash_handle)
1444 rte_hash_free(fdir_info->hash_handle);
1446 while ((fdir_filter = TAILQ_FIRST(&fdir_info->fdir_list))) {
1447 TAILQ_REMOVE(&fdir_info->fdir_list,
1450 rte_free(fdir_filter);
1456 static int ixgbe_l2_tn_filter_uninit(struct rte_eth_dev *eth_dev)
1458 struct ixgbe_l2_tn_info *l2_tn_info =
1459 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(eth_dev->data->dev_private);
1460 struct ixgbe_l2_tn_filter *l2_tn_filter;
1462 if (l2_tn_info->hash_map)
1463 rte_free(l2_tn_info->hash_map);
1464 if (l2_tn_info->hash_handle)
1465 rte_hash_free(l2_tn_info->hash_handle);
1467 while ((l2_tn_filter = TAILQ_FIRST(&l2_tn_info->l2_tn_list))) {
1468 TAILQ_REMOVE(&l2_tn_info->l2_tn_list,
1471 rte_free(l2_tn_filter);
1477 static int ixgbe_fdir_filter_init(struct rte_eth_dev *eth_dev)
1479 struct ixgbe_hw_fdir_info *fdir_info =
1480 IXGBE_DEV_PRIVATE_TO_FDIR_INFO(eth_dev->data->dev_private);
1481 char fdir_hash_name[RTE_HASH_NAMESIZE];
1482 struct rte_hash_parameters fdir_hash_params = {
1483 .name = fdir_hash_name,
1484 .entries = IXGBE_MAX_FDIR_FILTER_NUM,
1485 .key_len = sizeof(union ixgbe_atr_input),
1486 .hash_func = rte_hash_crc,
1487 .hash_func_init_val = 0,
1488 .socket_id = rte_socket_id(),
1491 TAILQ_INIT(&fdir_info->fdir_list);
1492 snprintf(fdir_hash_name, RTE_HASH_NAMESIZE,
1493 "fdir_%s", eth_dev->data->name);
1494 fdir_info->hash_handle = rte_hash_create(&fdir_hash_params);
1495 if (!fdir_info->hash_handle) {
1496 PMD_INIT_LOG(ERR, "Failed to create fdir hash table!");
1499 fdir_info->hash_map = rte_zmalloc("ixgbe",
1500 sizeof(struct ixgbe_fdir_filter *) *
1501 IXGBE_MAX_FDIR_FILTER_NUM,
1503 if (!fdir_info->hash_map) {
1505 "Failed to allocate memory for fdir hash map!");
1508 fdir_info->mask_added = FALSE;
1513 static int ixgbe_l2_tn_filter_init(struct rte_eth_dev *eth_dev)
1515 struct ixgbe_l2_tn_info *l2_tn_info =
1516 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(eth_dev->data->dev_private);
1517 char l2_tn_hash_name[RTE_HASH_NAMESIZE];
1518 struct rte_hash_parameters l2_tn_hash_params = {
1519 .name = l2_tn_hash_name,
1520 .entries = IXGBE_MAX_L2_TN_FILTER_NUM,
1521 .key_len = sizeof(struct ixgbe_l2_tn_key),
1522 .hash_func = rte_hash_crc,
1523 .hash_func_init_val = 0,
1524 .socket_id = rte_socket_id(),
1527 TAILQ_INIT(&l2_tn_info->l2_tn_list);
1528 snprintf(l2_tn_hash_name, RTE_HASH_NAMESIZE,
1529 "l2_tn_%s", eth_dev->data->name);
1530 l2_tn_info->hash_handle = rte_hash_create(&l2_tn_hash_params);
1531 if (!l2_tn_info->hash_handle) {
1532 PMD_INIT_LOG(ERR, "Failed to create L2 TN hash table!");
1535 l2_tn_info->hash_map = rte_zmalloc("ixgbe",
1536 sizeof(struct ixgbe_l2_tn_filter *) *
1537 IXGBE_MAX_L2_TN_FILTER_NUM,
1539 if (!l2_tn_info->hash_map) {
1541 "Failed to allocate memory for L2 TN hash map!");
1544 l2_tn_info->e_tag_en = FALSE;
1545 l2_tn_info->e_tag_fwd_en = FALSE;
1546 l2_tn_info->e_tag_ether_type = DEFAULT_ETAG_ETYPE;
1551 * Negotiate mailbox API version with the PF.
1552 * After reset API version is always set to the basic one (ixgbe_mbox_api_10).
1553 * Then we try to negotiate starting with the most recent one.
1554 * If all negotiation attempts fail, then we will proceed with
1555 * the default one (ixgbe_mbox_api_10).
1558 ixgbevf_negotiate_api(struct ixgbe_hw *hw)
1562 /* start with highest supported, proceed down */
1563 static const enum ixgbe_pfvf_api_rev sup_ver[] = {
1570 i != RTE_DIM(sup_ver) &&
1571 ixgbevf_negotiate_api_version(hw, sup_ver[i]) != 0;
1577 generate_random_mac_addr(struct ether_addr *mac_addr)
1581 /* Set Organizationally Unique Identifier (OUI) prefix. */
1582 mac_addr->addr_bytes[0] = 0x00;
1583 mac_addr->addr_bytes[1] = 0x09;
1584 mac_addr->addr_bytes[2] = 0xC0;
1585 /* Force indication of locally assigned MAC address. */
1586 mac_addr->addr_bytes[0] |= ETHER_LOCAL_ADMIN_ADDR;
1587 /* Generate the last 3 bytes of the MAC address with a random number. */
1588 random = rte_rand();
1589 memcpy(&mac_addr->addr_bytes[3], &random, 3);
1593 * Virtual Function device init
1596 eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev)
1600 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(eth_dev);
1601 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
1602 struct ixgbe_hw *hw =
1603 IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
1604 struct ixgbe_vfta *shadow_vfta =
1605 IXGBE_DEV_PRIVATE_TO_VFTA(eth_dev->data->dev_private);
1606 struct ixgbe_hwstrip *hwstrip =
1607 IXGBE_DEV_PRIVATE_TO_HWSTRIP_BITMAP(eth_dev->data->dev_private);
1608 struct ether_addr *perm_addr = (struct ether_addr *) hw->mac.perm_addr;
1610 PMD_INIT_FUNC_TRACE();
1612 eth_dev->dev_ops = &ixgbevf_eth_dev_ops;
1613 eth_dev->rx_pkt_burst = &ixgbe_recv_pkts;
1614 eth_dev->tx_pkt_burst = &ixgbe_xmit_pkts;
1616 /* for secondary processes, we don't initialise any further as primary
1617 * has already done this work. Only check we don't need a different
1620 if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
1621 struct ixgbe_tx_queue *txq;
1622 /* TX queue function in primary, set by last queue initialized
1623 * Tx queue may not initialized by primary process
1625 if (eth_dev->data->tx_queues) {
1626 txq = eth_dev->data->tx_queues[eth_dev->data->nb_tx_queues - 1];
1627 ixgbe_set_tx_function(eth_dev, txq);
1629 /* Use default TX function if we get here */
1630 PMD_INIT_LOG(NOTICE,
1631 "No TX queues configured yet. Using default TX function.");
1634 ixgbe_set_rx_function(eth_dev);
1639 rte_eth_copy_pci_info(eth_dev, pci_dev);
1640 eth_dev->data->dev_flags |= RTE_ETH_DEV_DETACHABLE;
1642 hw->device_id = pci_dev->id.device_id;
1643 hw->vendor_id = pci_dev->id.vendor_id;
1644 hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
1646 /* initialize the vfta */
1647 memset(shadow_vfta, 0, sizeof(*shadow_vfta));
1649 /* initialize the hw strip bitmap*/
1650 memset(hwstrip, 0, sizeof(*hwstrip));
1652 /* Initialize the shared code (base driver) */
1653 diag = ixgbe_init_shared_code(hw);
1654 if (diag != IXGBE_SUCCESS) {
1655 PMD_INIT_LOG(ERR, "Shared code init failed for ixgbevf: %d", diag);
1659 /* init_mailbox_params */
1660 hw->mbx.ops.init_params(hw);
1662 /* Reset the hw statistics */
1663 ixgbevf_dev_stats_reset(eth_dev);
1665 /* Disable the interrupts for VF */
1666 ixgbevf_intr_disable(hw);
1668 hw->mac.num_rar_entries = 128; /* The MAX of the underlying PF */
1669 diag = hw->mac.ops.reset_hw(hw);
1672 * The VF reset operation returns the IXGBE_ERR_INVALID_MAC_ADDR when
1673 * the underlying PF driver has not assigned a MAC address to the VF.
1674 * In this case, assign a random MAC address.
1676 if ((diag != IXGBE_SUCCESS) && (diag != IXGBE_ERR_INVALID_MAC_ADDR)) {
1677 PMD_INIT_LOG(ERR, "VF Initialization Failure: %d", diag);
1681 /* negotiate mailbox API version to use with the PF. */
1682 ixgbevf_negotiate_api(hw);
1684 /* Get Rx/Tx queue count via mailbox, which is ready after reset_hw */
1685 ixgbevf_get_queues(hw, &tcs, &tc);
1687 /* Allocate memory for storing MAC addresses */
1688 eth_dev->data->mac_addrs = rte_zmalloc("ixgbevf", ETHER_ADDR_LEN *
1689 hw->mac.num_rar_entries, 0);
1690 if (eth_dev->data->mac_addrs == NULL) {
1692 "Failed to allocate %u bytes needed to store "
1694 ETHER_ADDR_LEN * hw->mac.num_rar_entries);
1698 /* Generate a random MAC address, if none was assigned by PF. */
1699 if (is_zero_ether_addr(perm_addr)) {
1700 generate_random_mac_addr(perm_addr);
1701 diag = ixgbe_set_rar_vf(hw, 1, perm_addr->addr_bytes, 0, 1);
1703 rte_free(eth_dev->data->mac_addrs);
1704 eth_dev->data->mac_addrs = NULL;
1707 PMD_INIT_LOG(INFO, "\tVF MAC address not assigned by Host PF");
1708 PMD_INIT_LOG(INFO, "\tAssign randomly generated MAC address "
1709 "%02x:%02x:%02x:%02x:%02x:%02x",
1710 perm_addr->addr_bytes[0],
1711 perm_addr->addr_bytes[1],
1712 perm_addr->addr_bytes[2],
1713 perm_addr->addr_bytes[3],
1714 perm_addr->addr_bytes[4],
1715 perm_addr->addr_bytes[5]);
1718 /* Copy the permanent MAC address */
1719 ether_addr_copy(perm_addr, ð_dev->data->mac_addrs[0]);
1721 /* reset the hardware with the new settings */
1722 diag = hw->mac.ops.start_hw(hw);
1728 PMD_INIT_LOG(ERR, "VF Initialization Failure: %d", diag);
1732 rte_intr_callback_register(intr_handle,
1733 ixgbevf_dev_interrupt_handler, eth_dev);
1734 rte_intr_enable(intr_handle);
1735 ixgbevf_intr_enable(hw);
1737 PMD_INIT_LOG(DEBUG, "port %d vendorID=0x%x deviceID=0x%x mac.type=%s",
1738 eth_dev->data->port_id, pci_dev->id.vendor_id,
1739 pci_dev->id.device_id, "ixgbe_mac_82599_vf");
1744 /* Virtual Function device uninit */
1747 eth_ixgbevf_dev_uninit(struct rte_eth_dev *eth_dev)
1749 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(eth_dev);
1750 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
1751 struct ixgbe_hw *hw;
1753 PMD_INIT_FUNC_TRACE();
1755 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
1758 hw = IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
1760 if (hw->adapter_stopped == 0)
1761 ixgbevf_dev_close(eth_dev);
1763 eth_dev->dev_ops = NULL;
1764 eth_dev->rx_pkt_burst = NULL;
1765 eth_dev->tx_pkt_burst = NULL;
1767 /* Disable the interrupts for VF */
1768 ixgbevf_intr_disable(hw);
1770 rte_free(eth_dev->data->mac_addrs);
1771 eth_dev->data->mac_addrs = NULL;
1773 rte_intr_disable(intr_handle);
1774 rte_intr_callback_unregister(intr_handle,
1775 ixgbevf_dev_interrupt_handler, eth_dev);
1780 static int eth_ixgbe_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
1781 struct rte_pci_device *pci_dev)
1783 return rte_eth_dev_pci_generic_probe(pci_dev,
1784 sizeof(struct ixgbe_adapter), eth_ixgbe_dev_init);
1787 static int eth_ixgbe_pci_remove(struct rte_pci_device *pci_dev)
1789 return rte_eth_dev_pci_generic_remove(pci_dev, eth_ixgbe_dev_uninit);
1792 static struct rte_pci_driver rte_ixgbe_pmd = {
1793 .id_table = pci_id_ixgbe_map,
1794 .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
1795 .probe = eth_ixgbe_pci_probe,
1796 .remove = eth_ixgbe_pci_remove,
1799 static int eth_ixgbevf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
1800 struct rte_pci_device *pci_dev)
1802 return rte_eth_dev_pci_generic_probe(pci_dev,
1803 sizeof(struct ixgbe_adapter), eth_ixgbevf_dev_init);
1806 static int eth_ixgbevf_pci_remove(struct rte_pci_device *pci_dev)
1808 return rte_eth_dev_pci_generic_remove(pci_dev, eth_ixgbevf_dev_uninit);
1812 * virtual function driver struct
1814 static struct rte_pci_driver rte_ixgbevf_pmd = {
1815 .id_table = pci_id_ixgbevf_map,
1816 .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
1817 .probe = eth_ixgbevf_pci_probe,
1818 .remove = eth_ixgbevf_pci_remove,
1822 ixgbe_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
1824 struct ixgbe_hw *hw =
1825 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1826 struct ixgbe_vfta *shadow_vfta =
1827 IXGBE_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
1832 vid_idx = (uint32_t) ((vlan_id >> 5) & 0x7F);
1833 vid_bit = (uint32_t) (1 << (vlan_id & 0x1F));
1834 vfta = IXGBE_READ_REG(hw, IXGBE_VFTA(vid_idx));
1839 IXGBE_WRITE_REG(hw, IXGBE_VFTA(vid_idx), vfta);
1841 /* update local VFTA copy */
1842 shadow_vfta->vfta[vid_idx] = vfta;
1848 ixgbe_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue, int on)
1851 ixgbe_vlan_hw_strip_enable(dev, queue);
1853 ixgbe_vlan_hw_strip_disable(dev, queue);
1857 ixgbe_vlan_tpid_set(struct rte_eth_dev *dev,
1858 enum rte_vlan_type vlan_type,
1861 struct ixgbe_hw *hw =
1862 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1867 qinq = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
1868 qinq &= IXGBE_DMATXCTL_GDV;
1870 switch (vlan_type) {
1871 case ETH_VLAN_TYPE_INNER:
1873 reg = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
1874 reg = (reg & (~IXGBE_VLNCTRL_VET)) | (uint32_t)tpid;
1875 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, reg);
1876 reg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
1877 reg = (reg & (~IXGBE_DMATXCTL_VT_MASK))
1878 | ((uint32_t)tpid << IXGBE_DMATXCTL_VT_SHIFT);
1879 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);
1882 PMD_DRV_LOG(ERR, "Inner type is not supported"
1886 case ETH_VLAN_TYPE_OUTER:
1888 /* Only the high 16-bits is valid */
1889 IXGBE_WRITE_REG(hw, IXGBE_EXVET, (uint32_t)tpid <<
1890 IXGBE_EXVET_VET_EXT_SHIFT);
1892 reg = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
1893 reg = (reg & (~IXGBE_VLNCTRL_VET)) | (uint32_t)tpid;
1894 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, reg);
1895 reg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
1896 reg = (reg & (~IXGBE_DMATXCTL_VT_MASK))
1897 | ((uint32_t)tpid << IXGBE_DMATXCTL_VT_SHIFT);
1898 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);
1904 PMD_DRV_LOG(ERR, "Unsupported VLAN type %d", vlan_type);
1912 ixgbe_vlan_hw_filter_disable(struct rte_eth_dev *dev)
1914 struct ixgbe_hw *hw =
1915 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1918 PMD_INIT_FUNC_TRACE();
1920 /* Filter Table Disable */
1921 vlnctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
1922 vlnctrl &= ~IXGBE_VLNCTRL_VFE;
1924 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlnctrl);
1928 ixgbe_vlan_hw_filter_enable(struct rte_eth_dev *dev)
1930 struct ixgbe_hw *hw =
1931 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1932 struct ixgbe_vfta *shadow_vfta =
1933 IXGBE_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
1937 PMD_INIT_FUNC_TRACE();
1939 /* Filter Table Enable */
1940 vlnctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
1941 vlnctrl &= ~IXGBE_VLNCTRL_CFIEN;
1942 vlnctrl |= IXGBE_VLNCTRL_VFE;
1944 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlnctrl);
1946 /* write whatever is in local vfta copy */
1947 for (i = 0; i < IXGBE_VFTA_SIZE; i++)
1948 IXGBE_WRITE_REG(hw, IXGBE_VFTA(i), shadow_vfta->vfta[i]);
1952 ixgbe_vlan_hw_strip_bitmap_set(struct rte_eth_dev *dev, uint16_t queue, bool on)
1954 struct ixgbe_hwstrip *hwstrip =
1955 IXGBE_DEV_PRIVATE_TO_HWSTRIP_BITMAP(dev->data->dev_private);
1956 struct ixgbe_rx_queue *rxq;
1958 if (queue >= IXGBE_MAX_RX_QUEUE_NUM)
1962 IXGBE_SET_HWSTRIP(hwstrip, queue);
1964 IXGBE_CLEAR_HWSTRIP(hwstrip, queue);
1966 if (queue >= dev->data->nb_rx_queues)
1969 rxq = dev->data->rx_queues[queue];
1972 rxq->vlan_flags = PKT_RX_VLAN_PKT | PKT_RX_VLAN_STRIPPED;
1974 rxq->vlan_flags = PKT_RX_VLAN_PKT;
1978 ixgbe_vlan_hw_strip_disable(struct rte_eth_dev *dev, uint16_t queue)
1980 struct ixgbe_hw *hw =
1981 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1984 PMD_INIT_FUNC_TRACE();
1986 if (hw->mac.type == ixgbe_mac_82598EB) {
1987 /* No queue level support */
1988 PMD_INIT_LOG(NOTICE, "82598EB not support queue level hw strip");
1992 /* Other 10G NIC, the VLAN strip can be setup per queue in RXDCTL */
1993 ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(queue));
1994 ctrl &= ~IXGBE_RXDCTL_VME;
1995 IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(queue), ctrl);
1997 /* record those setting for HW strip per queue */
1998 ixgbe_vlan_hw_strip_bitmap_set(dev, queue, 0);
2002 ixgbe_vlan_hw_strip_enable(struct rte_eth_dev *dev, uint16_t queue)
2004 struct ixgbe_hw *hw =
2005 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2008 PMD_INIT_FUNC_TRACE();
2010 if (hw->mac.type == ixgbe_mac_82598EB) {
2011 /* No queue level supported */
2012 PMD_INIT_LOG(NOTICE, "82598EB not support queue level hw strip");
2016 /* Other 10G NIC, the VLAN strip can be setup per queue in RXDCTL */
2017 ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(queue));
2018 ctrl |= IXGBE_RXDCTL_VME;
2019 IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(queue), ctrl);
2021 /* record those setting for HW strip per queue */
2022 ixgbe_vlan_hw_strip_bitmap_set(dev, queue, 1);
2026 ixgbe_vlan_hw_strip_disable_all(struct rte_eth_dev *dev)
2028 struct ixgbe_hw *hw =
2029 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2032 struct ixgbe_rx_queue *rxq;
2034 PMD_INIT_FUNC_TRACE();
2036 if (hw->mac.type == ixgbe_mac_82598EB) {
2037 ctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
2038 ctrl &= ~IXGBE_VLNCTRL_VME;
2039 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, ctrl);
2041 /* Other 10G NIC, the VLAN strip can be setup per queue in RXDCTL */
2042 for (i = 0; i < dev->data->nb_rx_queues; i++) {
2043 rxq = dev->data->rx_queues[i];
2044 ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(rxq->reg_idx));
2045 ctrl &= ~IXGBE_RXDCTL_VME;
2046 IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(rxq->reg_idx), ctrl);
2048 /* record those setting for HW strip per queue */
2049 ixgbe_vlan_hw_strip_bitmap_set(dev, i, 0);
2055 ixgbe_vlan_hw_strip_enable_all(struct rte_eth_dev *dev)
2057 struct ixgbe_hw *hw =
2058 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2061 struct ixgbe_rx_queue *rxq;
2063 PMD_INIT_FUNC_TRACE();
2065 if (hw->mac.type == ixgbe_mac_82598EB) {
2066 ctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
2067 ctrl |= IXGBE_VLNCTRL_VME;
2068 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, ctrl);
2070 /* Other 10G NIC, the VLAN strip can be setup per queue in RXDCTL */
2071 for (i = 0; i < dev->data->nb_rx_queues; i++) {
2072 rxq = dev->data->rx_queues[i];
2073 ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(rxq->reg_idx));
2074 ctrl |= IXGBE_RXDCTL_VME;
2075 IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(rxq->reg_idx), ctrl);
2077 /* record those setting for HW strip per queue */
2078 ixgbe_vlan_hw_strip_bitmap_set(dev, i, 1);
2084 ixgbe_vlan_hw_extend_disable(struct rte_eth_dev *dev)
2086 struct ixgbe_hw *hw =
2087 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2090 PMD_INIT_FUNC_TRACE();
2092 /* DMATXCTRL: Geric Double VLAN Disable */
2093 ctrl = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
2094 ctrl &= ~IXGBE_DMATXCTL_GDV;
2095 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, ctrl);
2097 /* CTRL_EXT: Global Double VLAN Disable */
2098 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
2099 ctrl &= ~IXGBE_EXTENDED_VLAN;
2100 IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl);
2105 ixgbe_vlan_hw_extend_enable(struct rte_eth_dev *dev)
2107 struct ixgbe_hw *hw =
2108 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2111 PMD_INIT_FUNC_TRACE();
2113 /* DMATXCTRL: Geric Double VLAN Enable */
2114 ctrl = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
2115 ctrl |= IXGBE_DMATXCTL_GDV;
2116 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, ctrl);
2118 /* CTRL_EXT: Global Double VLAN Enable */
2119 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
2120 ctrl |= IXGBE_EXTENDED_VLAN;
2121 IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl);
2123 /* Clear pooling mode of PFVTCTL. It's required by X550. */
2124 if (hw->mac.type == ixgbe_mac_X550 ||
2125 hw->mac.type == ixgbe_mac_X550EM_x ||
2126 hw->mac.type == ixgbe_mac_X550EM_a) {
2127 ctrl = IXGBE_READ_REG(hw, IXGBE_VT_CTL);
2128 ctrl &= ~IXGBE_VT_CTL_POOLING_MODE_MASK;
2129 IXGBE_WRITE_REG(hw, IXGBE_VT_CTL, ctrl);
2133 * VET EXT field in the EXVET register = 0x8100 by default
2134 * So no need to change. Same to VT field of DMATXCTL register
2139 ixgbe_vlan_offload_set(struct rte_eth_dev *dev, int mask)
2141 if (mask & ETH_VLAN_STRIP_MASK) {
2142 if (dev->data->dev_conf.rxmode.hw_vlan_strip)
2143 ixgbe_vlan_hw_strip_enable_all(dev);
2145 ixgbe_vlan_hw_strip_disable_all(dev);
2148 if (mask & ETH_VLAN_FILTER_MASK) {
2149 if (dev->data->dev_conf.rxmode.hw_vlan_filter)
2150 ixgbe_vlan_hw_filter_enable(dev);
2152 ixgbe_vlan_hw_filter_disable(dev);
2155 if (mask & ETH_VLAN_EXTEND_MASK) {
2156 if (dev->data->dev_conf.rxmode.hw_vlan_extend)
2157 ixgbe_vlan_hw_extend_enable(dev);
2159 ixgbe_vlan_hw_extend_disable(dev);
2164 ixgbe_vmdq_vlan_hw_filter_enable(struct rte_eth_dev *dev)
2166 struct ixgbe_hw *hw =
2167 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2168 /* VLNCTRL: enable vlan filtering and allow all vlan tags through */
2169 uint32_t vlanctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
2171 vlanctrl |= IXGBE_VLNCTRL_VFE; /* enable vlan filters */
2172 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlanctrl);
2176 ixgbe_check_vf_rss_rxq_num(struct rte_eth_dev *dev, uint16_t nb_rx_q)
2178 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
2183 RTE_ETH_DEV_SRIOV(dev).active = ETH_64_POOLS;
2186 RTE_ETH_DEV_SRIOV(dev).active = ETH_32_POOLS;
2192 RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool = nb_rx_q;
2193 RTE_ETH_DEV_SRIOV(dev).def_pool_q_idx = pci_dev->max_vfs * nb_rx_q;
2199 ixgbe_check_mq_mode(struct rte_eth_dev *dev)
2201 struct rte_eth_conf *dev_conf = &dev->data->dev_conf;
2202 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2203 uint16_t nb_rx_q = dev->data->nb_rx_queues;
2204 uint16_t nb_tx_q = dev->data->nb_tx_queues;
2206 if (RTE_ETH_DEV_SRIOV(dev).active != 0) {
2207 /* check multi-queue mode */
2208 switch (dev_conf->rxmode.mq_mode) {
2209 case ETH_MQ_RX_VMDQ_DCB:
2210 PMD_INIT_LOG(INFO, "ETH_MQ_RX_VMDQ_DCB mode supported in SRIOV");
2212 case ETH_MQ_RX_VMDQ_DCB_RSS:
2213 /* DCB/RSS VMDQ in SRIOV mode, not implement yet */
2214 PMD_INIT_LOG(ERR, "SRIOV active,"
2215 " unsupported mq_mode rx %d.",
2216 dev_conf->rxmode.mq_mode);
2219 case ETH_MQ_RX_VMDQ_RSS:
2220 dev->data->dev_conf.rxmode.mq_mode = ETH_MQ_RX_VMDQ_RSS;
2221 if (nb_rx_q <= RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool)
2222 if (ixgbe_check_vf_rss_rxq_num(dev, nb_rx_q)) {
2223 PMD_INIT_LOG(ERR, "SRIOV is active,"
2224 " invalid queue number"
2225 " for VMDQ RSS, allowed"
2226 " value are 1, 2 or 4.");
2230 case ETH_MQ_RX_VMDQ_ONLY:
2231 case ETH_MQ_RX_NONE:
2232 /* if nothing mq mode configure, use default scheme */
2233 dev->data->dev_conf.rxmode.mq_mode = ETH_MQ_RX_VMDQ_ONLY;
2234 if (RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool > 1)
2235 RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool = 1;
2237 default: /* ETH_MQ_RX_DCB, ETH_MQ_RX_DCB_RSS or ETH_MQ_TX_DCB*/
2238 /* SRIOV only works in VMDq enable mode */
2239 PMD_INIT_LOG(ERR, "SRIOV is active,"
2240 " wrong mq_mode rx %d.",
2241 dev_conf->rxmode.mq_mode);
2245 switch (dev_conf->txmode.mq_mode) {
2246 case ETH_MQ_TX_VMDQ_DCB:
2247 PMD_INIT_LOG(INFO, "ETH_MQ_TX_VMDQ_DCB mode supported in SRIOV");
2248 dev->data->dev_conf.txmode.mq_mode = ETH_MQ_TX_VMDQ_DCB;
2250 default: /* ETH_MQ_TX_VMDQ_ONLY or ETH_MQ_TX_NONE */
2251 dev->data->dev_conf.txmode.mq_mode = ETH_MQ_TX_VMDQ_ONLY;
2255 /* check valid queue number */
2256 if ((nb_rx_q > RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool) ||
2257 (nb_tx_q > RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool)) {
2258 PMD_INIT_LOG(ERR, "SRIOV is active,"
2259 " nb_rx_q=%d nb_tx_q=%d queue number"
2260 " must be less than or equal to %d.",
2262 RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool);
2266 if (dev_conf->rxmode.mq_mode == ETH_MQ_RX_VMDQ_DCB_RSS) {
2267 PMD_INIT_LOG(ERR, "VMDQ+DCB+RSS mq_mode is"
2271 /* check configuration for vmdb+dcb mode */
2272 if (dev_conf->rxmode.mq_mode == ETH_MQ_RX_VMDQ_DCB) {
2273 const struct rte_eth_vmdq_dcb_conf *conf;
2275 if (nb_rx_q != IXGBE_VMDQ_DCB_NB_QUEUES) {
2276 PMD_INIT_LOG(ERR, "VMDQ+DCB, nb_rx_q != %d.",
2277 IXGBE_VMDQ_DCB_NB_QUEUES);
2280 conf = &dev_conf->rx_adv_conf.vmdq_dcb_conf;
2281 if (!(conf->nb_queue_pools == ETH_16_POOLS ||
2282 conf->nb_queue_pools == ETH_32_POOLS)) {
2283 PMD_INIT_LOG(ERR, "VMDQ+DCB selected,"
2284 " nb_queue_pools must be %d or %d.",
2285 ETH_16_POOLS, ETH_32_POOLS);
2289 if (dev_conf->txmode.mq_mode == ETH_MQ_TX_VMDQ_DCB) {
2290 const struct rte_eth_vmdq_dcb_tx_conf *conf;
2292 if (nb_tx_q != IXGBE_VMDQ_DCB_NB_QUEUES) {
2293 PMD_INIT_LOG(ERR, "VMDQ+DCB, nb_tx_q != %d",
2294 IXGBE_VMDQ_DCB_NB_QUEUES);
2297 conf = &dev_conf->tx_adv_conf.vmdq_dcb_tx_conf;
2298 if (!(conf->nb_queue_pools == ETH_16_POOLS ||
2299 conf->nb_queue_pools == ETH_32_POOLS)) {
2300 PMD_INIT_LOG(ERR, "VMDQ+DCB selected,"
2301 " nb_queue_pools != %d and"
2302 " nb_queue_pools != %d.",
2303 ETH_16_POOLS, ETH_32_POOLS);
2308 /* For DCB mode check our configuration before we go further */
2309 if (dev_conf->rxmode.mq_mode == ETH_MQ_RX_DCB) {
2310 const struct rte_eth_dcb_rx_conf *conf;
2312 if (nb_rx_q != IXGBE_DCB_NB_QUEUES) {
2313 PMD_INIT_LOG(ERR, "DCB selected, nb_rx_q != %d.",
2314 IXGBE_DCB_NB_QUEUES);
2317 conf = &dev_conf->rx_adv_conf.dcb_rx_conf;
2318 if (!(conf->nb_tcs == ETH_4_TCS ||
2319 conf->nb_tcs == ETH_8_TCS)) {
2320 PMD_INIT_LOG(ERR, "DCB selected, nb_tcs != %d"
2321 " and nb_tcs != %d.",
2322 ETH_4_TCS, ETH_8_TCS);
2327 if (dev_conf->txmode.mq_mode == ETH_MQ_TX_DCB) {
2328 const struct rte_eth_dcb_tx_conf *conf;
2330 if (nb_tx_q != IXGBE_DCB_NB_QUEUES) {
2331 PMD_INIT_LOG(ERR, "DCB, nb_tx_q != %d.",
2332 IXGBE_DCB_NB_QUEUES);
2335 conf = &dev_conf->tx_adv_conf.dcb_tx_conf;
2336 if (!(conf->nb_tcs == ETH_4_TCS ||
2337 conf->nb_tcs == ETH_8_TCS)) {
2338 PMD_INIT_LOG(ERR, "DCB selected, nb_tcs != %d"
2339 " and nb_tcs != %d.",
2340 ETH_4_TCS, ETH_8_TCS);
2346 * When DCB/VT is off, maximum number of queues changes,
2347 * except for 82598EB, which remains constant.
2349 if (dev_conf->txmode.mq_mode == ETH_MQ_TX_NONE &&
2350 hw->mac.type != ixgbe_mac_82598EB) {
2351 if (nb_tx_q > IXGBE_NONE_MODE_TX_NB_QUEUES) {
2353 "Neither VT nor DCB are enabled, "
2355 IXGBE_NONE_MODE_TX_NB_QUEUES);
2364 ixgbe_dev_configure(struct rte_eth_dev *dev)
2366 struct ixgbe_interrupt *intr =
2367 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
2368 struct ixgbe_adapter *adapter =
2369 (struct ixgbe_adapter *)dev->data->dev_private;
2372 PMD_INIT_FUNC_TRACE();
2373 /* multipe queue mode checking */
2374 ret = ixgbe_check_mq_mode(dev);
2376 PMD_DRV_LOG(ERR, "ixgbe_check_mq_mode fails with %d.",
2381 /* set flag to update link status after init */
2382 intr->flags |= IXGBE_FLAG_NEED_LINK_UPDATE;
2385 * Initialize to TRUE. If any of Rx queues doesn't meet the bulk
2386 * allocation or vector Rx preconditions we will reset it.
2388 adapter->rx_bulk_alloc_allowed = true;
2389 adapter->rx_vec_allowed = true;
2395 ixgbe_dev_phy_intr_setup(struct rte_eth_dev *dev)
2397 struct ixgbe_hw *hw =
2398 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2399 struct ixgbe_interrupt *intr =
2400 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
2403 /* only set up it on X550EM_X */
2404 if (hw->mac.type == ixgbe_mac_X550EM_x) {
2405 gpie = IXGBE_READ_REG(hw, IXGBE_GPIE);
2406 gpie |= IXGBE_SDP0_GPIEN_X550EM_x;
2407 IXGBE_WRITE_REG(hw, IXGBE_GPIE, gpie);
2408 if (hw->phy.type == ixgbe_phy_x550em_ext_t)
2409 intr->mask |= IXGBE_EICR_GPI_SDP0_X550EM_x;
2414 ixgbe_set_vf_rate_limit(struct rte_eth_dev *dev, uint16_t vf,
2415 uint16_t tx_rate, uint64_t q_msk)
2417 struct ixgbe_hw *hw;
2418 struct ixgbe_vf_info *vfinfo;
2419 struct rte_eth_link link;
2420 uint8_t nb_q_per_pool;
2421 uint32_t queue_stride;
2422 uint32_t queue_idx, idx = 0, vf_idx;
2424 uint16_t total_rate = 0;
2425 struct rte_pci_device *pci_dev;
2427 pci_dev = IXGBE_DEV_TO_PCI(dev);
2428 rte_eth_link_get_nowait(dev->data->port_id, &link);
2430 if (vf >= pci_dev->max_vfs)
2433 if (tx_rate > link.link_speed)
2439 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2440 vfinfo = *(IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private));
2441 nb_q_per_pool = RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool;
2442 queue_stride = IXGBE_MAX_RX_QUEUE_NUM / RTE_ETH_DEV_SRIOV(dev).active;
2443 queue_idx = vf * queue_stride;
2444 queue_end = queue_idx + nb_q_per_pool - 1;
2445 if (queue_end >= hw->mac.max_tx_queues)
2449 for (vf_idx = 0; vf_idx < pci_dev->max_vfs; vf_idx++) {
2452 for (idx = 0; idx < RTE_DIM(vfinfo[vf_idx].tx_rate);
2454 total_rate += vfinfo[vf_idx].tx_rate[idx];
2460 /* Store tx_rate for this vf. */
2461 for (idx = 0; idx < nb_q_per_pool; idx++) {
2462 if (((uint64_t)0x1 << idx) & q_msk) {
2463 if (vfinfo[vf].tx_rate[idx] != tx_rate)
2464 vfinfo[vf].tx_rate[idx] = tx_rate;
2465 total_rate += tx_rate;
2469 if (total_rate > dev->data->dev_link.link_speed) {
2470 /* Reset stored TX rate of the VF if it causes exceed
2473 memset(vfinfo[vf].tx_rate, 0, sizeof(vfinfo[vf].tx_rate));
2477 /* Set RTTBCNRC of each queue/pool for vf X */
2478 for (; queue_idx <= queue_end; queue_idx++) {
2480 ixgbe_set_queue_rate_limit(dev, queue_idx, tx_rate);
2488 * Configure device link speed and setup link.
2489 * It returns 0 on success.
2492 ixgbe_dev_start(struct rte_eth_dev *dev)
2494 struct ixgbe_hw *hw =
2495 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2496 struct ixgbe_vf_info *vfinfo =
2497 *IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private);
2498 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
2499 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
2500 uint32_t intr_vector = 0;
2501 int err, link_up = 0, negotiate = 0;
2506 uint32_t *link_speeds;
2508 PMD_INIT_FUNC_TRACE();
2510 /* IXGBE devices don't support:
2511 * - half duplex (checked afterwards for valid speeds)
2512 * - fixed speed: TODO implement
2514 if (dev->data->dev_conf.link_speeds & ETH_LINK_SPEED_FIXED) {
2515 PMD_INIT_LOG(ERR, "Invalid link_speeds for port %hhu; fix speed not supported",
2516 dev->data->port_id);
2520 /* disable uio/vfio intr/eventfd mapping */
2521 rte_intr_disable(intr_handle);
2524 hw->adapter_stopped = 0;
2525 ixgbe_stop_adapter(hw);
2527 /* reinitialize adapter
2528 * this calls reset and start
2530 status = ixgbe_pf_reset_hw(hw);
2533 hw->mac.ops.start_hw(hw);
2534 hw->mac.get_link_status = true;
2536 /* configure PF module if SRIOV enabled */
2537 ixgbe_pf_host_configure(dev);
2539 ixgbe_dev_phy_intr_setup(dev);
2541 /* check and configure queue intr-vector mapping */
2542 if ((rte_intr_cap_multiple(intr_handle) ||
2543 !RTE_ETH_DEV_SRIOV(dev).active) &&
2544 dev->data->dev_conf.intr_conf.rxq != 0) {
2545 intr_vector = dev->data->nb_rx_queues;
2546 if (intr_vector > IXGBE_MAX_INTR_QUEUE_NUM) {
2547 PMD_INIT_LOG(ERR, "At most %d intr queues supported",
2548 IXGBE_MAX_INTR_QUEUE_NUM);
2551 if (rte_intr_efd_enable(intr_handle, intr_vector))
2555 if (rte_intr_dp_is_en(intr_handle) && !intr_handle->intr_vec) {
2556 intr_handle->intr_vec =
2557 rte_zmalloc("intr_vec",
2558 dev->data->nb_rx_queues * sizeof(int), 0);
2559 if (intr_handle->intr_vec == NULL) {
2560 PMD_INIT_LOG(ERR, "Failed to allocate %d rx_queues"
2561 " intr_vec", dev->data->nb_rx_queues);
2566 /* confiugre msix for sleep until rx interrupt */
2567 ixgbe_configure_msix(dev);
2569 /* initialize transmission unit */
2570 ixgbe_dev_tx_init(dev);
2572 /* This can fail when allocating mbufs for descriptor rings */
2573 err = ixgbe_dev_rx_init(dev);
2575 PMD_INIT_LOG(ERR, "Unable to initialize RX hardware");
2579 mask = ETH_VLAN_STRIP_MASK | ETH_VLAN_FILTER_MASK |
2580 ETH_VLAN_EXTEND_MASK;
2581 ixgbe_vlan_offload_set(dev, mask);
2583 if (dev->data->dev_conf.rxmode.mq_mode == ETH_MQ_RX_VMDQ_ONLY) {
2584 /* Enable vlan filtering for VMDq */
2585 ixgbe_vmdq_vlan_hw_filter_enable(dev);
2588 /* Configure DCB hw */
2589 ixgbe_configure_dcb(dev);
2591 if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_NONE) {
2592 err = ixgbe_fdir_configure(dev);
2597 /* Restore vf rate limit */
2598 if (vfinfo != NULL) {
2599 for (vf = 0; vf < pci_dev->max_vfs; vf++)
2600 for (idx = 0; idx < IXGBE_MAX_QUEUE_NUM_PER_VF; idx++)
2601 if (vfinfo[vf].tx_rate[idx] != 0)
2602 ixgbe_set_vf_rate_limit(
2604 vfinfo[vf].tx_rate[idx],
2608 ixgbe_restore_statistics_mapping(dev);
2610 err = ixgbe_dev_rxtx_start(dev);
2612 PMD_INIT_LOG(ERR, "Unable to start rxtx queues");
2616 /* Skip link setup if loopback mode is enabled for 82599. */
2617 if (hw->mac.type == ixgbe_mac_82599EB &&
2618 dev->data->dev_conf.lpbk_mode == IXGBE_LPBK_82599_TX_RX)
2619 goto skip_link_setup;
2621 if (ixgbe_is_sfp(hw) && hw->phy.multispeed_fiber) {
2622 err = hw->mac.ops.setup_sfp(hw);
2627 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper) {
2628 /* Turn on the copper */
2629 ixgbe_set_phy_power(hw, true);
2631 /* Turn on the laser */
2632 ixgbe_enable_tx_laser(hw);
2635 err = ixgbe_check_link(hw, &speed, &link_up, 0);
2638 dev->data->dev_link.link_status = link_up;
2640 err = ixgbe_get_link_capabilities(hw, &speed, &negotiate);
2644 link_speeds = &dev->data->dev_conf.link_speeds;
2645 if (*link_speeds & ~(ETH_LINK_SPEED_100M | ETH_LINK_SPEED_1G |
2646 ETH_LINK_SPEED_10G)) {
2647 PMD_INIT_LOG(ERR, "Invalid link setting");
2652 if (*link_speeds == ETH_LINK_SPEED_AUTONEG) {
2653 speed = (hw->mac.type != ixgbe_mac_82598EB) ?
2654 IXGBE_LINK_SPEED_82599_AUTONEG :
2655 IXGBE_LINK_SPEED_82598_AUTONEG;
2657 if (*link_speeds & ETH_LINK_SPEED_10G)
2658 speed |= IXGBE_LINK_SPEED_10GB_FULL;
2659 if (*link_speeds & ETH_LINK_SPEED_1G)
2660 speed |= IXGBE_LINK_SPEED_1GB_FULL;
2661 if (*link_speeds & ETH_LINK_SPEED_100M)
2662 speed |= IXGBE_LINK_SPEED_100_FULL;
2665 err = ixgbe_setup_link(hw, speed, link_up);
2671 if (rte_intr_allow_others(intr_handle)) {
2672 /* check if lsc interrupt is enabled */
2673 if (dev->data->dev_conf.intr_conf.lsc != 0)
2674 ixgbe_dev_lsc_interrupt_setup(dev);
2675 ixgbe_dev_macsec_interrupt_setup(dev);
2677 rte_intr_callback_unregister(intr_handle,
2678 ixgbe_dev_interrupt_handler, dev);
2679 if (dev->data->dev_conf.intr_conf.lsc != 0)
2680 PMD_INIT_LOG(INFO, "lsc won't enable because of"
2681 " no intr multiplex");
2684 /* check if rxq interrupt is enabled */
2685 if (dev->data->dev_conf.intr_conf.rxq != 0 &&
2686 rte_intr_dp_is_en(intr_handle))
2687 ixgbe_dev_rxq_interrupt_setup(dev);
2689 /* enable uio/vfio intr/eventfd mapping */
2690 rte_intr_enable(intr_handle);
2692 /* resume enabled intr since hw reset */
2693 ixgbe_enable_intr(dev);
2694 ixgbe_l2_tunnel_conf(dev);
2695 ixgbe_filter_restore(dev);
2700 PMD_INIT_LOG(ERR, "failure in ixgbe_dev_start(): %d", err);
2701 ixgbe_dev_clear_queues(dev);
2706 * Stop device: disable rx and tx functions to allow for reconfiguring.
2709 ixgbe_dev_stop(struct rte_eth_dev *dev)
2711 struct rte_eth_link link;
2712 struct ixgbe_hw *hw =
2713 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2714 struct ixgbe_vf_info *vfinfo =
2715 *IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private);
2716 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
2717 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
2720 PMD_INIT_FUNC_TRACE();
2722 /* disable interrupts */
2723 ixgbe_disable_intr(hw);
2726 ixgbe_pf_reset_hw(hw);
2727 hw->adapter_stopped = 0;
2730 ixgbe_stop_adapter(hw);
2732 for (vf = 0; vfinfo != NULL && vf < pci_dev->max_vfs; vf++)
2733 vfinfo[vf].clear_to_send = false;
2735 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper) {
2736 /* Turn off the copper */
2737 ixgbe_set_phy_power(hw, false);
2739 /* Turn off the laser */
2740 ixgbe_disable_tx_laser(hw);
2743 ixgbe_dev_clear_queues(dev);
2745 /* Clear stored conf */
2746 dev->data->scattered_rx = 0;
2749 /* Clear recorded link status */
2750 memset(&link, 0, sizeof(link));
2751 rte_ixgbe_dev_atomic_write_link_status(dev, &link);
2753 if (!rte_intr_allow_others(intr_handle))
2754 /* resume to the default handler */
2755 rte_intr_callback_register(intr_handle,
2756 ixgbe_dev_interrupt_handler,
2759 /* Clean datapath event and queue/vec mapping */
2760 rte_intr_efd_disable(intr_handle);
2761 if (intr_handle->intr_vec != NULL) {
2762 rte_free(intr_handle->intr_vec);
2763 intr_handle->intr_vec = NULL;
2768 * Set device link up: enable tx.
2771 ixgbe_dev_set_link_up(struct rte_eth_dev *dev)
2773 struct ixgbe_hw *hw =
2774 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2775 if (hw->mac.type == ixgbe_mac_82599EB) {
2776 #ifdef RTE_NIC_BYPASS
2777 if (hw->device_id == IXGBE_DEV_ID_82599_BYPASS) {
2778 /* Not suported in bypass mode */
2779 PMD_INIT_LOG(ERR, "Set link up is not supported "
2780 "by device id 0x%x", hw->device_id);
2786 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper) {
2787 /* Turn on the copper */
2788 ixgbe_set_phy_power(hw, true);
2790 /* Turn on the laser */
2791 ixgbe_enable_tx_laser(hw);
2798 * Set device link down: disable tx.
2801 ixgbe_dev_set_link_down(struct rte_eth_dev *dev)
2803 struct ixgbe_hw *hw =
2804 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2805 if (hw->mac.type == ixgbe_mac_82599EB) {
2806 #ifdef RTE_NIC_BYPASS
2807 if (hw->device_id == IXGBE_DEV_ID_82599_BYPASS) {
2808 /* Not suported in bypass mode */
2809 PMD_INIT_LOG(ERR, "Set link down is not supported "
2810 "by device id 0x%x", hw->device_id);
2816 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper) {
2817 /* Turn off the copper */
2818 ixgbe_set_phy_power(hw, false);
2820 /* Turn off the laser */
2821 ixgbe_disable_tx_laser(hw);
2828 * Reest and stop device.
2831 ixgbe_dev_close(struct rte_eth_dev *dev)
2833 struct ixgbe_hw *hw =
2834 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2836 PMD_INIT_FUNC_TRACE();
2838 ixgbe_pf_reset_hw(hw);
2840 ixgbe_dev_stop(dev);
2841 hw->adapter_stopped = 1;
2843 ixgbe_dev_free_queues(dev);
2845 ixgbe_disable_pcie_master(hw);
2847 /* reprogram the RAR[0] in case user changed it. */
2848 ixgbe_set_rar(hw, 0, hw->mac.addr, 0, IXGBE_RAH_AV);
2852 ixgbe_read_stats_registers(struct ixgbe_hw *hw,
2853 struct ixgbe_hw_stats *hw_stats,
2854 struct ixgbe_macsec_stats *macsec_stats,
2855 uint64_t *total_missed_rx, uint64_t *total_qbrc,
2856 uint64_t *total_qprc, uint64_t *total_qprdc)
2858 uint32_t bprc, lxon, lxoff, total;
2859 uint32_t delta_gprc = 0;
2861 /* Workaround for RX byte count not including CRC bytes when CRC
2862 * strip is enabled. CRC bytes are removed from counters when crc_strip
2865 int crc_strip = (IXGBE_READ_REG(hw, IXGBE_HLREG0) &
2866 IXGBE_HLREG0_RXCRCSTRP);
2868 hw_stats->crcerrs += IXGBE_READ_REG(hw, IXGBE_CRCERRS);
2869 hw_stats->illerrc += IXGBE_READ_REG(hw, IXGBE_ILLERRC);
2870 hw_stats->errbc += IXGBE_READ_REG(hw, IXGBE_ERRBC);
2871 hw_stats->mspdc += IXGBE_READ_REG(hw, IXGBE_MSPDC);
2873 for (i = 0; i < 8; i++) {
2874 uint32_t mp = IXGBE_READ_REG(hw, IXGBE_MPC(i));
2876 /* global total per queue */
2877 hw_stats->mpc[i] += mp;
2878 /* Running comprehensive total for stats display */
2879 *total_missed_rx += hw_stats->mpc[i];
2880 if (hw->mac.type == ixgbe_mac_82598EB) {
2881 hw_stats->rnbc[i] +=
2882 IXGBE_READ_REG(hw, IXGBE_RNBC(i));
2883 hw_stats->pxonrxc[i] +=
2884 IXGBE_READ_REG(hw, IXGBE_PXONRXC(i));
2885 hw_stats->pxoffrxc[i] +=
2886 IXGBE_READ_REG(hw, IXGBE_PXOFFRXC(i));
2888 hw_stats->pxonrxc[i] +=
2889 IXGBE_READ_REG(hw, IXGBE_PXONRXCNT(i));
2890 hw_stats->pxoffrxc[i] +=
2891 IXGBE_READ_REG(hw, IXGBE_PXOFFRXCNT(i));
2892 hw_stats->pxon2offc[i] +=
2893 IXGBE_READ_REG(hw, IXGBE_PXON2OFFCNT(i));
2895 hw_stats->pxontxc[i] +=
2896 IXGBE_READ_REG(hw, IXGBE_PXONTXC(i));
2897 hw_stats->pxofftxc[i] +=
2898 IXGBE_READ_REG(hw, IXGBE_PXOFFTXC(i));
2900 for (i = 0; i < IXGBE_QUEUE_STAT_COUNTERS; i++) {
2901 uint32_t delta_qprc = IXGBE_READ_REG(hw, IXGBE_QPRC(i));
2902 uint32_t delta_qptc = IXGBE_READ_REG(hw, IXGBE_QPTC(i));
2903 uint32_t delta_qprdc = IXGBE_READ_REG(hw, IXGBE_QPRDC(i));
2905 delta_gprc += delta_qprc;
2907 hw_stats->qprc[i] += delta_qprc;
2908 hw_stats->qptc[i] += delta_qptc;
2910 hw_stats->qbrc[i] += IXGBE_READ_REG(hw, IXGBE_QBRC_L(i));
2911 hw_stats->qbrc[i] +=
2912 ((uint64_t)IXGBE_READ_REG(hw, IXGBE_QBRC_H(i)) << 32);
2914 hw_stats->qbrc[i] -= delta_qprc * ETHER_CRC_LEN;
2916 hw_stats->qbtc[i] += IXGBE_READ_REG(hw, IXGBE_QBTC_L(i));
2917 hw_stats->qbtc[i] +=
2918 ((uint64_t)IXGBE_READ_REG(hw, IXGBE_QBTC_H(i)) << 32);
2920 hw_stats->qprdc[i] += delta_qprdc;
2921 *total_qprdc += hw_stats->qprdc[i];
2923 *total_qprc += hw_stats->qprc[i];
2924 *total_qbrc += hw_stats->qbrc[i];
2926 hw_stats->mlfc += IXGBE_READ_REG(hw, IXGBE_MLFC);
2927 hw_stats->mrfc += IXGBE_READ_REG(hw, IXGBE_MRFC);
2928 hw_stats->rlec += IXGBE_READ_REG(hw, IXGBE_RLEC);
2931 * An errata states that gprc actually counts good + missed packets:
2932 * Workaround to set gprc to summated queue packet receives
2934 hw_stats->gprc = *total_qprc;
2936 if (hw->mac.type != ixgbe_mac_82598EB) {
2937 hw_stats->gorc += IXGBE_READ_REG(hw, IXGBE_GORCL);
2938 hw_stats->gorc += ((u64)IXGBE_READ_REG(hw, IXGBE_GORCH) << 32);
2939 hw_stats->gotc += IXGBE_READ_REG(hw, IXGBE_GOTCL);
2940 hw_stats->gotc += ((u64)IXGBE_READ_REG(hw, IXGBE_GOTCH) << 32);
2941 hw_stats->tor += IXGBE_READ_REG(hw, IXGBE_TORL);
2942 hw_stats->tor += ((u64)IXGBE_READ_REG(hw, IXGBE_TORH) << 32);
2943 hw_stats->lxonrxc += IXGBE_READ_REG(hw, IXGBE_LXONRXCNT);
2944 hw_stats->lxoffrxc += IXGBE_READ_REG(hw, IXGBE_LXOFFRXCNT);
2946 hw_stats->lxonrxc += IXGBE_READ_REG(hw, IXGBE_LXONRXC);
2947 hw_stats->lxoffrxc += IXGBE_READ_REG(hw, IXGBE_LXOFFRXC);
2948 /* 82598 only has a counter in the high register */
2949 hw_stats->gorc += IXGBE_READ_REG(hw, IXGBE_GORCH);
2950 hw_stats->gotc += IXGBE_READ_REG(hw, IXGBE_GOTCH);
2951 hw_stats->tor += IXGBE_READ_REG(hw, IXGBE_TORH);
2953 uint64_t old_tpr = hw_stats->tpr;
2955 hw_stats->tpr += IXGBE_READ_REG(hw, IXGBE_TPR);
2956 hw_stats->tpt += IXGBE_READ_REG(hw, IXGBE_TPT);
2959 hw_stats->gorc -= delta_gprc * ETHER_CRC_LEN;
2961 uint64_t delta_gptc = IXGBE_READ_REG(hw, IXGBE_GPTC);
2962 hw_stats->gptc += delta_gptc;
2963 hw_stats->gotc -= delta_gptc * ETHER_CRC_LEN;
2964 hw_stats->tor -= (hw_stats->tpr - old_tpr) * ETHER_CRC_LEN;
2967 * Workaround: mprc hardware is incorrectly counting
2968 * broadcasts, so for now we subtract those.
2970 bprc = IXGBE_READ_REG(hw, IXGBE_BPRC);
2971 hw_stats->bprc += bprc;
2972 hw_stats->mprc += IXGBE_READ_REG(hw, IXGBE_MPRC);
2973 if (hw->mac.type == ixgbe_mac_82598EB)
2974 hw_stats->mprc -= bprc;
2976 hw_stats->prc64 += IXGBE_READ_REG(hw, IXGBE_PRC64);
2977 hw_stats->prc127 += IXGBE_READ_REG(hw, IXGBE_PRC127);
2978 hw_stats->prc255 += IXGBE_READ_REG(hw, IXGBE_PRC255);
2979 hw_stats->prc511 += IXGBE_READ_REG(hw, IXGBE_PRC511);
2980 hw_stats->prc1023 += IXGBE_READ_REG(hw, IXGBE_PRC1023);
2981 hw_stats->prc1522 += IXGBE_READ_REG(hw, IXGBE_PRC1522);
2983 lxon = IXGBE_READ_REG(hw, IXGBE_LXONTXC);
2984 hw_stats->lxontxc += lxon;
2985 lxoff = IXGBE_READ_REG(hw, IXGBE_LXOFFTXC);
2986 hw_stats->lxofftxc += lxoff;
2987 total = lxon + lxoff;
2989 hw_stats->mptc += IXGBE_READ_REG(hw, IXGBE_MPTC);
2990 hw_stats->ptc64 += IXGBE_READ_REG(hw, IXGBE_PTC64);
2991 hw_stats->gptc -= total;
2992 hw_stats->mptc -= total;
2993 hw_stats->ptc64 -= total;
2994 hw_stats->gotc -= total * ETHER_MIN_LEN;
2996 hw_stats->ruc += IXGBE_READ_REG(hw, IXGBE_RUC);
2997 hw_stats->rfc += IXGBE_READ_REG(hw, IXGBE_RFC);
2998 hw_stats->roc += IXGBE_READ_REG(hw, IXGBE_ROC);
2999 hw_stats->rjc += IXGBE_READ_REG(hw, IXGBE_RJC);
3000 hw_stats->mngprc += IXGBE_READ_REG(hw, IXGBE_MNGPRC);
3001 hw_stats->mngpdc += IXGBE_READ_REG(hw, IXGBE_MNGPDC);
3002 hw_stats->mngptc += IXGBE_READ_REG(hw, IXGBE_MNGPTC);
3003 hw_stats->ptc127 += IXGBE_READ_REG(hw, IXGBE_PTC127);
3004 hw_stats->ptc255 += IXGBE_READ_REG(hw, IXGBE_PTC255);
3005 hw_stats->ptc511 += IXGBE_READ_REG(hw, IXGBE_PTC511);
3006 hw_stats->ptc1023 += IXGBE_READ_REG(hw, IXGBE_PTC1023);
3007 hw_stats->ptc1522 += IXGBE_READ_REG(hw, IXGBE_PTC1522);
3008 hw_stats->bptc += IXGBE_READ_REG(hw, IXGBE_BPTC);
3009 hw_stats->xec += IXGBE_READ_REG(hw, IXGBE_XEC);
3010 hw_stats->fccrc += IXGBE_READ_REG(hw, IXGBE_FCCRC);
3011 hw_stats->fclast += IXGBE_READ_REG(hw, IXGBE_FCLAST);
3012 /* Only read FCOE on 82599 */
3013 if (hw->mac.type != ixgbe_mac_82598EB) {
3014 hw_stats->fcoerpdc += IXGBE_READ_REG(hw, IXGBE_FCOERPDC);
3015 hw_stats->fcoeprc += IXGBE_READ_REG(hw, IXGBE_FCOEPRC);
3016 hw_stats->fcoeptc += IXGBE_READ_REG(hw, IXGBE_FCOEPTC);
3017 hw_stats->fcoedwrc += IXGBE_READ_REG(hw, IXGBE_FCOEDWRC);
3018 hw_stats->fcoedwtc += IXGBE_READ_REG(hw, IXGBE_FCOEDWTC);
3021 /* Flow Director Stats registers */
3022 hw_stats->fdirmatch += IXGBE_READ_REG(hw, IXGBE_FDIRMATCH);
3023 hw_stats->fdirmiss += IXGBE_READ_REG(hw, IXGBE_FDIRMISS);
3025 /* MACsec Stats registers */
3026 macsec_stats->out_pkts_untagged += IXGBE_READ_REG(hw, IXGBE_LSECTXUT);
3027 macsec_stats->out_pkts_encrypted +=
3028 IXGBE_READ_REG(hw, IXGBE_LSECTXPKTE);
3029 macsec_stats->out_pkts_protected +=
3030 IXGBE_READ_REG(hw, IXGBE_LSECTXPKTP);
3031 macsec_stats->out_octets_encrypted +=
3032 IXGBE_READ_REG(hw, IXGBE_LSECTXOCTE);
3033 macsec_stats->out_octets_protected +=
3034 IXGBE_READ_REG(hw, IXGBE_LSECTXOCTP);
3035 macsec_stats->in_pkts_untagged += IXGBE_READ_REG(hw, IXGBE_LSECRXUT);
3036 macsec_stats->in_pkts_badtag += IXGBE_READ_REG(hw, IXGBE_LSECRXBAD);
3037 macsec_stats->in_pkts_nosci += IXGBE_READ_REG(hw, IXGBE_LSECRXNOSCI);
3038 macsec_stats->in_pkts_unknownsci +=
3039 IXGBE_READ_REG(hw, IXGBE_LSECRXUNSCI);
3040 macsec_stats->in_octets_decrypted +=
3041 IXGBE_READ_REG(hw, IXGBE_LSECRXOCTD);
3042 macsec_stats->in_octets_validated +=
3043 IXGBE_READ_REG(hw, IXGBE_LSECRXOCTV);
3044 macsec_stats->in_pkts_unchecked += IXGBE_READ_REG(hw, IXGBE_LSECRXUNCH);
3045 macsec_stats->in_pkts_delayed += IXGBE_READ_REG(hw, IXGBE_LSECRXDELAY);
3046 macsec_stats->in_pkts_late += IXGBE_READ_REG(hw, IXGBE_LSECRXLATE);
3047 for (i = 0; i < 2; i++) {
3048 macsec_stats->in_pkts_ok +=
3049 IXGBE_READ_REG(hw, IXGBE_LSECRXOK(i));
3050 macsec_stats->in_pkts_invalid +=
3051 IXGBE_READ_REG(hw, IXGBE_LSECRXINV(i));
3052 macsec_stats->in_pkts_notvalid +=
3053 IXGBE_READ_REG(hw, IXGBE_LSECRXNV(i));
3055 macsec_stats->in_pkts_unusedsa += IXGBE_READ_REG(hw, IXGBE_LSECRXUNSA);
3056 macsec_stats->in_pkts_notusingsa +=
3057 IXGBE_READ_REG(hw, IXGBE_LSECRXNUSA);
3061 * This function is based on ixgbe_update_stats_counters() in ixgbe/ixgbe.c
3064 ixgbe_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
3066 struct ixgbe_hw *hw =
3067 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3068 struct ixgbe_hw_stats *hw_stats =
3069 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3070 struct ixgbe_macsec_stats *macsec_stats =
3071 IXGBE_DEV_PRIVATE_TO_MACSEC_STATS(
3072 dev->data->dev_private);
3073 uint64_t total_missed_rx, total_qbrc, total_qprc, total_qprdc;
3076 total_missed_rx = 0;
3081 ixgbe_read_stats_registers(hw, hw_stats, macsec_stats, &total_missed_rx,
3082 &total_qbrc, &total_qprc, &total_qprdc);
3087 /* Fill out the rte_eth_stats statistics structure */
3088 stats->ipackets = total_qprc;
3089 stats->ibytes = total_qbrc;
3090 stats->opackets = hw_stats->gptc;
3091 stats->obytes = hw_stats->gotc;
3093 for (i = 0; i < IXGBE_QUEUE_STAT_COUNTERS; i++) {
3094 stats->q_ipackets[i] = hw_stats->qprc[i];
3095 stats->q_opackets[i] = hw_stats->qptc[i];
3096 stats->q_ibytes[i] = hw_stats->qbrc[i];
3097 stats->q_obytes[i] = hw_stats->qbtc[i];
3098 stats->q_errors[i] = hw_stats->qprdc[i];
3102 stats->imissed = total_missed_rx;
3103 stats->ierrors = hw_stats->crcerrs +
3119 ixgbe_dev_stats_reset(struct rte_eth_dev *dev)
3121 struct ixgbe_hw_stats *stats =
3122 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3124 /* HW registers are cleared on read */
3125 ixgbe_dev_stats_get(dev, NULL);
3127 /* Reset software totals */
3128 memset(stats, 0, sizeof(*stats));
3131 /* This function calculates the number of xstats based on the current config */
3133 ixgbe_xstats_calc_num(void) {
3134 return IXGBE_NB_HW_STATS + IXGBE_NB_MACSEC_STATS +
3135 (IXGBE_NB_RXQ_PRIO_STATS * IXGBE_NB_RXQ_PRIO_VALUES) +
3136 (IXGBE_NB_TXQ_PRIO_STATS * IXGBE_NB_TXQ_PRIO_VALUES);
3139 static int ixgbe_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
3140 struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned limit)
3142 const unsigned cnt_stats = ixgbe_xstats_calc_num();
3143 unsigned stat, i, count;
3145 if (xstats_names != NULL) {
3148 /* Note: limit >= cnt_stats checked upstream
3149 * in rte_eth_xstats_names()
3152 /* Extended stats from ixgbe_hw_stats */
3153 for (i = 0; i < IXGBE_NB_HW_STATS; i++) {
3154 snprintf(xstats_names[count].name,
3155 sizeof(xstats_names[count].name),
3157 rte_ixgbe_stats_strings[i].name);
3162 for (i = 0; i < IXGBE_NB_MACSEC_STATS; i++) {
3163 snprintf(xstats_names[count].name,
3164 sizeof(xstats_names[count].name),
3166 rte_ixgbe_macsec_strings[i].name);
3170 /* RX Priority Stats */
3171 for (stat = 0; stat < IXGBE_NB_RXQ_PRIO_STATS; stat++) {
3172 for (i = 0; i < IXGBE_NB_RXQ_PRIO_VALUES; i++) {
3173 snprintf(xstats_names[count].name,
3174 sizeof(xstats_names[count].name),
3175 "rx_priority%u_%s", i,
3176 rte_ixgbe_rxq_strings[stat].name);
3181 /* TX Priority Stats */
3182 for (stat = 0; stat < IXGBE_NB_TXQ_PRIO_STATS; stat++) {
3183 for (i = 0; i < IXGBE_NB_TXQ_PRIO_VALUES; i++) {
3184 snprintf(xstats_names[count].name,
3185 sizeof(xstats_names[count].name),
3186 "tx_priority%u_%s", i,
3187 rte_ixgbe_txq_strings[stat].name);
3195 static int ixgbe_dev_xstats_get_names_by_ids(
3196 __rte_unused struct rte_eth_dev *dev,
3197 struct rte_eth_xstat_name *xstats_names,
3202 const unsigned int cnt_stats = ixgbe_xstats_calc_num();
3203 unsigned int stat, i, count;
3205 if (xstats_names != NULL) {
3208 /* Note: limit >= cnt_stats checked upstream
3209 * in rte_eth_xstats_names()
3212 /* Extended stats from ixgbe_hw_stats */
3213 for (i = 0; i < IXGBE_NB_HW_STATS; i++) {
3214 snprintf(xstats_names[count].name,
3215 sizeof(xstats_names[count].name),
3217 rte_ixgbe_stats_strings[i].name);
3222 for (i = 0; i < IXGBE_NB_MACSEC_STATS; i++) {
3223 snprintf(xstats_names[count].name,
3224 sizeof(xstats_names[count].name),
3226 rte_ixgbe_macsec_strings[i].name);
3230 /* RX Priority Stats */
3231 for (stat = 0; stat < IXGBE_NB_RXQ_PRIO_STATS; stat++) {
3232 for (i = 0; i < IXGBE_NB_RXQ_PRIO_VALUES; i++) {
3233 snprintf(xstats_names[count].name,
3234 sizeof(xstats_names[count].name),
3235 "rx_priority%u_%s", i,
3236 rte_ixgbe_rxq_strings[stat].name);
3241 /* TX Priority Stats */
3242 for (stat = 0; stat < IXGBE_NB_TXQ_PRIO_STATS; stat++) {
3243 for (i = 0; i < IXGBE_NB_TXQ_PRIO_VALUES; i++) {
3244 snprintf(xstats_names[count].name,
3245 sizeof(xstats_names[count].name),
3246 "tx_priority%u_%s", i,
3247 rte_ixgbe_txq_strings[stat].name);
3256 uint16_t size = ixgbe_xstats_calc_num();
3257 struct rte_eth_xstat_name xstats_names_copy[size];
3259 ixgbe_dev_xstats_get_names_by_ids(dev, xstats_names_copy, NULL,
3262 for (i = 0; i < limit; i++) {
3263 if (ids[i] >= size) {
3264 PMD_INIT_LOG(ERR, "id value isn't valid");
3267 strcpy(xstats_names[i].name,
3268 xstats_names_copy[ids[i]].name);
3273 static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
3274 struct rte_eth_xstat_name *xstats_names, unsigned limit)
3278 if (limit < IXGBEVF_NB_XSTATS && xstats_names != NULL)
3281 if (xstats_names != NULL)
3282 for (i = 0; i < IXGBEVF_NB_XSTATS; i++)
3283 snprintf(xstats_names[i].name,
3284 sizeof(xstats_names[i].name),
3285 "%s", rte_ixgbevf_stats_strings[i].name);
3286 return IXGBEVF_NB_XSTATS;
3290 ixgbe_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
3293 struct ixgbe_hw *hw =
3294 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3295 struct ixgbe_hw_stats *hw_stats =
3296 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3297 struct ixgbe_macsec_stats *macsec_stats =
3298 IXGBE_DEV_PRIVATE_TO_MACSEC_STATS(
3299 dev->data->dev_private);
3300 uint64_t total_missed_rx, total_qbrc, total_qprc, total_qprdc;
3301 unsigned i, stat, count = 0;
3303 count = ixgbe_xstats_calc_num();
3308 total_missed_rx = 0;
3313 ixgbe_read_stats_registers(hw, hw_stats, macsec_stats, &total_missed_rx,
3314 &total_qbrc, &total_qprc, &total_qprdc);
3316 /* If this is a reset xstats is NULL, and we have cleared the
3317 * registers by reading them.
3322 /* Extended stats from ixgbe_hw_stats */
3324 for (i = 0; i < IXGBE_NB_HW_STATS; i++) {
3325 xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
3326 rte_ixgbe_stats_strings[i].offset);
3327 xstats[count].id = count;
3332 for (i = 0; i < IXGBE_NB_MACSEC_STATS; i++) {
3333 xstats[count].value = *(uint64_t *)(((char *)macsec_stats) +
3334 rte_ixgbe_macsec_strings[i].offset);
3335 xstats[count].id = count;
3339 /* RX Priority Stats */
3340 for (stat = 0; stat < IXGBE_NB_RXQ_PRIO_STATS; stat++) {
3341 for (i = 0; i < IXGBE_NB_RXQ_PRIO_VALUES; i++) {
3342 xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
3343 rte_ixgbe_rxq_strings[stat].offset +
3344 (sizeof(uint64_t) * i));
3345 xstats[count].id = count;
3350 /* TX Priority Stats */
3351 for (stat = 0; stat < IXGBE_NB_TXQ_PRIO_STATS; stat++) {
3352 for (i = 0; i < IXGBE_NB_TXQ_PRIO_VALUES; i++) {
3353 xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
3354 rte_ixgbe_txq_strings[stat].offset +
3355 (sizeof(uint64_t) * i));
3356 xstats[count].id = count;
3364 ixgbe_dev_xstats_get_by_ids(struct rte_eth_dev *dev, uint64_t *ids,
3365 uint64_t *values, unsigned int n)
3368 struct ixgbe_hw *hw =
3369 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3370 struct ixgbe_hw_stats *hw_stats =
3371 IXGBE_DEV_PRIVATE_TO_STATS(
3372 dev->data->dev_private);
3373 struct ixgbe_macsec_stats *macsec_stats =
3374 IXGBE_DEV_PRIVATE_TO_MACSEC_STATS(
3375 dev->data->dev_private);
3376 uint64_t total_missed_rx, total_qbrc, total_qprc, total_qprdc;
3377 unsigned int i, stat, count = 0;
3379 count = ixgbe_xstats_calc_num();
3381 if (!ids && n < count)
3384 total_missed_rx = 0;
3389 ixgbe_read_stats_registers(hw, hw_stats, macsec_stats,
3390 &total_missed_rx, &total_qbrc, &total_qprc,
3393 /* If this is a reset xstats is NULL, and we have cleared the
3394 * registers by reading them.
3396 if (!ids && !values)
3399 /* Extended stats from ixgbe_hw_stats */
3401 for (i = 0; i < IXGBE_NB_HW_STATS; i++) {
3402 values[count] = *(uint64_t *)(((char *)hw_stats) +
3403 rte_ixgbe_stats_strings[i].offset);
3408 for (i = 0; i < IXGBE_NB_MACSEC_STATS; i++) {
3409 values[count] = *(uint64_t *)(((char *)macsec_stats) +
3410 rte_ixgbe_macsec_strings[i].offset);
3414 /* RX Priority Stats */
3415 for (stat = 0; stat < IXGBE_NB_RXQ_PRIO_STATS; stat++) {
3416 for (i = 0; i < IXGBE_NB_RXQ_PRIO_VALUES; i++) {
3418 *(uint64_t *)(((char *)hw_stats) +
3419 rte_ixgbe_rxq_strings[stat].offset +
3420 (sizeof(uint64_t) * i));
3425 /* TX Priority Stats */
3426 for (stat = 0; stat < IXGBE_NB_TXQ_PRIO_STATS; stat++) {
3427 for (i = 0; i < IXGBE_NB_TXQ_PRIO_VALUES; i++) {
3429 *(uint64_t *)(((char *)hw_stats) +
3430 rte_ixgbe_txq_strings[stat].offset +
3431 (sizeof(uint64_t) * i));
3439 uint16_t size = ixgbe_xstats_calc_num();
3440 uint64_t values_copy[size];
3442 ixgbe_dev_xstats_get_by_ids(dev, NULL, values_copy, size);
3444 for (i = 0; i < n; i++) {
3445 if (ids[i] >= size) {
3446 PMD_INIT_LOG(ERR, "id value isn't valid");
3449 values[i] = values_copy[ids[i]];
3455 ixgbe_dev_xstats_reset(struct rte_eth_dev *dev)
3457 struct ixgbe_hw_stats *stats =
3458 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3459 struct ixgbe_macsec_stats *macsec_stats =
3460 IXGBE_DEV_PRIVATE_TO_MACSEC_STATS(
3461 dev->data->dev_private);
3463 unsigned count = ixgbe_xstats_calc_num();
3465 /* HW registers are cleared on read */
3466 ixgbe_dev_xstats_get(dev, NULL, count);
3468 /* Reset software totals */
3469 memset(stats, 0, sizeof(*stats));
3470 memset(macsec_stats, 0, sizeof(*macsec_stats));
3474 ixgbevf_update_stats(struct rte_eth_dev *dev)
3476 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3477 struct ixgbevf_hw_stats *hw_stats = (struct ixgbevf_hw_stats *)
3478 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3480 /* Good Rx packet, include VF loopback */
3481 UPDATE_VF_STAT(IXGBE_VFGPRC,
3482 hw_stats->last_vfgprc, hw_stats->vfgprc);
3484 /* Good Rx octets, include VF loopback */
3485 UPDATE_VF_STAT_36BIT(IXGBE_VFGORC_LSB, IXGBE_VFGORC_MSB,
3486 hw_stats->last_vfgorc, hw_stats->vfgorc);
3488 /* Good Tx packet, include VF loopback */
3489 UPDATE_VF_STAT(IXGBE_VFGPTC,
3490 hw_stats->last_vfgptc, hw_stats->vfgptc);
3492 /* Good Tx octets, include VF loopback */
3493 UPDATE_VF_STAT_36BIT(IXGBE_VFGOTC_LSB, IXGBE_VFGOTC_MSB,
3494 hw_stats->last_vfgotc, hw_stats->vfgotc);
3496 /* Rx Multicst Packet */
3497 UPDATE_VF_STAT(IXGBE_VFMPRC,
3498 hw_stats->last_vfmprc, hw_stats->vfmprc);
3502 ixgbevf_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
3505 struct ixgbevf_hw_stats *hw_stats = (struct ixgbevf_hw_stats *)
3506 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3509 if (n < IXGBEVF_NB_XSTATS)
3510 return IXGBEVF_NB_XSTATS;
3512 ixgbevf_update_stats(dev);
3517 /* Extended stats */
3518 for (i = 0; i < IXGBEVF_NB_XSTATS; i++) {
3520 xstats[i].value = *(uint64_t *)(((char *)hw_stats) +
3521 rte_ixgbevf_stats_strings[i].offset);
3524 return IXGBEVF_NB_XSTATS;
3528 ixgbevf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
3530 struct ixgbevf_hw_stats *hw_stats = (struct ixgbevf_hw_stats *)
3531 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3533 ixgbevf_update_stats(dev);
3538 stats->ipackets = hw_stats->vfgprc;
3539 stats->ibytes = hw_stats->vfgorc;
3540 stats->opackets = hw_stats->vfgptc;
3541 stats->obytes = hw_stats->vfgotc;
3545 ixgbevf_dev_stats_reset(struct rte_eth_dev *dev)
3547 struct ixgbevf_hw_stats *hw_stats = (struct ixgbevf_hw_stats *)
3548 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3550 /* Sync HW register to the last stats */
3551 ixgbevf_dev_stats_get(dev, NULL);
3553 /* reset HW current stats*/
3554 hw_stats->vfgprc = 0;
3555 hw_stats->vfgorc = 0;
3556 hw_stats->vfgptc = 0;
3557 hw_stats->vfgotc = 0;
3561 ixgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size)
3563 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3564 u16 eeprom_verh, eeprom_verl;
3568 ixgbe_read_eeprom(hw, 0x2e, &eeprom_verh);
3569 ixgbe_read_eeprom(hw, 0x2d, &eeprom_verl);
3571 etrack_id = (eeprom_verh << 16) | eeprom_verl;
3572 ret = snprintf(fw_version, fw_size, "0x%08x", etrack_id);
3574 ret += 1; /* add the size of '\0' */
3575 if (fw_size < (u32)ret)
3582 ixgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
3584 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
3585 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3586 struct rte_eth_conf *dev_conf = &dev->data->dev_conf;
3588 dev_info->pci_dev = pci_dev;
3589 dev_info->max_rx_queues = (uint16_t)hw->mac.max_rx_queues;
3590 dev_info->max_tx_queues = (uint16_t)hw->mac.max_tx_queues;
3591 if (RTE_ETH_DEV_SRIOV(dev).active == 0) {
3593 * When DCB/VT is off, maximum number of queues changes,
3594 * except for 82598EB, which remains constant.
3596 if (dev_conf->txmode.mq_mode == ETH_MQ_TX_NONE &&
3597 hw->mac.type != ixgbe_mac_82598EB)
3598 dev_info->max_tx_queues = IXGBE_NONE_MODE_TX_NB_QUEUES;
3600 dev_info->min_rx_bufsize = 1024; /* cf BSIZEPACKET in SRRCTL register */
3601 dev_info->max_rx_pktlen = 15872; /* includes CRC, cf MAXFRS register */
3602 dev_info->max_mac_addrs = hw->mac.num_rar_entries;
3603 dev_info->max_hash_mac_addrs = IXGBE_VMDQ_NUM_UC_MAC;
3604 dev_info->max_vfs = pci_dev->max_vfs;
3605 if (hw->mac.type == ixgbe_mac_82598EB)
3606 dev_info->max_vmdq_pools = ETH_16_POOLS;
3608 dev_info->max_vmdq_pools = ETH_64_POOLS;
3609 dev_info->vmdq_queue_num = dev_info->max_rx_queues;
3610 dev_info->rx_offload_capa =
3611 DEV_RX_OFFLOAD_VLAN_STRIP |
3612 DEV_RX_OFFLOAD_IPV4_CKSUM |
3613 DEV_RX_OFFLOAD_UDP_CKSUM |
3614 DEV_RX_OFFLOAD_TCP_CKSUM;
3617 * RSC is only supported by 82599 and x540 PF devices in a non-SR-IOV
3620 if ((hw->mac.type == ixgbe_mac_82599EB ||
3621 hw->mac.type == ixgbe_mac_X540) &&
3622 !RTE_ETH_DEV_SRIOV(dev).active)
3623 dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_TCP_LRO;
3625 if (hw->mac.type == ixgbe_mac_82599EB ||
3626 hw->mac.type == ixgbe_mac_X540)
3627 dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_MACSEC_STRIP;
3629 if (hw->mac.type == ixgbe_mac_X550 ||
3630 hw->mac.type == ixgbe_mac_X550EM_x ||
3631 hw->mac.type == ixgbe_mac_X550EM_a)
3632 dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM;
3634 dev_info->tx_offload_capa =
3635 DEV_TX_OFFLOAD_VLAN_INSERT |
3636 DEV_TX_OFFLOAD_IPV4_CKSUM |
3637 DEV_TX_OFFLOAD_UDP_CKSUM |
3638 DEV_TX_OFFLOAD_TCP_CKSUM |
3639 DEV_TX_OFFLOAD_SCTP_CKSUM |
3640 DEV_TX_OFFLOAD_TCP_TSO;
3642 if (hw->mac.type == ixgbe_mac_82599EB ||
3643 hw->mac.type == ixgbe_mac_X540)
3644 dev_info->tx_offload_capa |= DEV_TX_OFFLOAD_MACSEC_INSERT;
3646 if (hw->mac.type == ixgbe_mac_X550 ||
3647 hw->mac.type == ixgbe_mac_X550EM_x ||
3648 hw->mac.type == ixgbe_mac_X550EM_a)
3649 dev_info->tx_offload_capa |= DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
3651 dev_info->default_rxconf = (struct rte_eth_rxconf) {
3653 .pthresh = IXGBE_DEFAULT_RX_PTHRESH,
3654 .hthresh = IXGBE_DEFAULT_RX_HTHRESH,
3655 .wthresh = IXGBE_DEFAULT_RX_WTHRESH,
3657 .rx_free_thresh = IXGBE_DEFAULT_RX_FREE_THRESH,
3661 dev_info->default_txconf = (struct rte_eth_txconf) {
3663 .pthresh = IXGBE_DEFAULT_TX_PTHRESH,
3664 .hthresh = IXGBE_DEFAULT_TX_HTHRESH,
3665 .wthresh = IXGBE_DEFAULT_TX_WTHRESH,
3667 .tx_free_thresh = IXGBE_DEFAULT_TX_FREE_THRESH,
3668 .tx_rs_thresh = IXGBE_DEFAULT_TX_RSBIT_THRESH,
3669 .txq_flags = ETH_TXQ_FLAGS_NOMULTSEGS |
3670 ETH_TXQ_FLAGS_NOOFFLOADS,
3673 dev_info->rx_desc_lim = rx_desc_lim;
3674 dev_info->tx_desc_lim = tx_desc_lim;
3676 dev_info->hash_key_size = IXGBE_HKEY_MAX_INDEX * sizeof(uint32_t);
3677 dev_info->reta_size = ixgbe_reta_size_get(hw->mac.type);
3678 dev_info->flow_type_rss_offloads = IXGBE_RSS_OFFLOAD_ALL;
3680 dev_info->speed_capa = ETH_LINK_SPEED_1G | ETH_LINK_SPEED_10G;
3681 if (hw->mac.type == ixgbe_mac_X540 ||
3682 hw->mac.type == ixgbe_mac_X540_vf ||
3683 hw->mac.type == ixgbe_mac_X550 ||
3684 hw->mac.type == ixgbe_mac_X550_vf) {
3685 dev_info->speed_capa |= ETH_LINK_SPEED_100M;
3689 static const uint32_t *
3690 ixgbe_dev_supported_ptypes_get(struct rte_eth_dev *dev)
3692 static const uint32_t ptypes[] = {
3693 /* For non-vec functions,
3694 * refers to ixgbe_rxd_pkt_info_to_pkt_type();
3695 * for vec functions,
3696 * refers to _recv_raw_pkts_vec().
3700 RTE_PTYPE_L3_IPV4_EXT,
3702 RTE_PTYPE_L3_IPV6_EXT,
3706 RTE_PTYPE_TUNNEL_IP,
3707 RTE_PTYPE_INNER_L3_IPV6,
3708 RTE_PTYPE_INNER_L3_IPV6_EXT,
3709 RTE_PTYPE_INNER_L4_TCP,
3710 RTE_PTYPE_INNER_L4_UDP,
3714 if (dev->rx_pkt_burst == ixgbe_recv_pkts ||
3715 dev->rx_pkt_burst == ixgbe_recv_pkts_lro_single_alloc ||
3716 dev->rx_pkt_burst == ixgbe_recv_pkts_lro_bulk_alloc ||
3717 dev->rx_pkt_burst == ixgbe_recv_pkts_bulk_alloc)
3723 ixgbevf_dev_info_get(struct rte_eth_dev *dev,
3724 struct rte_eth_dev_info *dev_info)
3726 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
3727 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3729 dev_info->pci_dev = pci_dev;
3730 dev_info->max_rx_queues = (uint16_t)hw->mac.max_rx_queues;
3731 dev_info->max_tx_queues = (uint16_t)hw->mac.max_tx_queues;
3732 dev_info->min_rx_bufsize = 1024; /* cf BSIZEPACKET in SRRCTL reg */
3733 dev_info->max_rx_pktlen = 9728; /* includes CRC, cf MAXFRS reg */
3734 dev_info->max_mac_addrs = hw->mac.num_rar_entries;
3735 dev_info->max_hash_mac_addrs = IXGBE_VMDQ_NUM_UC_MAC;
3736 dev_info->max_vfs = pci_dev->max_vfs;
3737 if (hw->mac.type == ixgbe_mac_82598EB)
3738 dev_info->max_vmdq_pools = ETH_16_POOLS;
3740 dev_info->max_vmdq_pools = ETH_64_POOLS;
3741 dev_info->rx_offload_capa = DEV_RX_OFFLOAD_VLAN_STRIP |
3742 DEV_RX_OFFLOAD_IPV4_CKSUM |
3743 DEV_RX_OFFLOAD_UDP_CKSUM |
3744 DEV_RX_OFFLOAD_TCP_CKSUM;
3745 dev_info->tx_offload_capa = DEV_TX_OFFLOAD_VLAN_INSERT |
3746 DEV_TX_OFFLOAD_IPV4_CKSUM |
3747 DEV_TX_OFFLOAD_UDP_CKSUM |
3748 DEV_TX_OFFLOAD_TCP_CKSUM |
3749 DEV_TX_OFFLOAD_SCTP_CKSUM |
3750 DEV_TX_OFFLOAD_TCP_TSO;
3752 dev_info->default_rxconf = (struct rte_eth_rxconf) {
3754 .pthresh = IXGBE_DEFAULT_RX_PTHRESH,
3755 .hthresh = IXGBE_DEFAULT_RX_HTHRESH,
3756 .wthresh = IXGBE_DEFAULT_RX_WTHRESH,
3758 .rx_free_thresh = IXGBE_DEFAULT_RX_FREE_THRESH,
3762 dev_info->default_txconf = (struct rte_eth_txconf) {
3764 .pthresh = IXGBE_DEFAULT_TX_PTHRESH,
3765 .hthresh = IXGBE_DEFAULT_TX_HTHRESH,
3766 .wthresh = IXGBE_DEFAULT_TX_WTHRESH,
3768 .tx_free_thresh = IXGBE_DEFAULT_TX_FREE_THRESH,
3769 .tx_rs_thresh = IXGBE_DEFAULT_TX_RSBIT_THRESH,
3770 .txq_flags = ETH_TXQ_FLAGS_NOMULTSEGS |
3771 ETH_TXQ_FLAGS_NOOFFLOADS,
3774 dev_info->rx_desc_lim = rx_desc_lim;
3775 dev_info->tx_desc_lim = tx_desc_lim;
3778 /* return 0 means link status changed, -1 means not changed */
3780 ixgbe_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
3782 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3783 struct rte_eth_link link, old;
3784 ixgbe_link_speed link_speed = IXGBE_LINK_SPEED_UNKNOWN;
3785 struct ixgbe_interrupt *intr =
3786 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
3790 bool autoneg = false;
3792 link.link_status = ETH_LINK_DOWN;
3793 link.link_speed = 0;
3794 link.link_duplex = ETH_LINK_HALF_DUPLEX;
3795 memset(&old, 0, sizeof(old));
3796 rte_ixgbe_dev_atomic_read_link_status(dev, &old);
3798 hw->mac.get_link_status = true;
3800 if ((intr->flags & IXGBE_FLAG_NEED_LINK_CONFIG) &&
3801 hw->mac.ops.get_media_type(hw) == ixgbe_media_type_fiber) {
3802 speed = hw->phy.autoneg_advertised;
3804 ixgbe_get_link_capabilities(hw, &speed, &autoneg);
3805 ixgbe_setup_link(hw, speed, true);
3808 /* check if it needs to wait to complete, if lsc interrupt is enabled */
3809 if (wait_to_complete == 0 || dev->data->dev_conf.intr_conf.lsc != 0)
3810 diag = ixgbe_check_link(hw, &link_speed, &link_up, 0);
3812 diag = ixgbe_check_link(hw, &link_speed, &link_up, 1);
3815 link.link_speed = ETH_SPEED_NUM_100M;
3816 link.link_duplex = ETH_LINK_FULL_DUPLEX;
3817 rte_ixgbe_dev_atomic_write_link_status(dev, &link);
3818 if (link.link_status == old.link_status)
3824 rte_ixgbe_dev_atomic_write_link_status(dev, &link);
3825 intr->flags |= IXGBE_FLAG_NEED_LINK_CONFIG;
3826 if (link.link_status == old.link_status)
3830 intr->flags &= ~IXGBE_FLAG_NEED_LINK_CONFIG;
3831 link.link_status = ETH_LINK_UP;
3832 link.link_duplex = ETH_LINK_FULL_DUPLEX;
3834 switch (link_speed) {
3836 case IXGBE_LINK_SPEED_UNKNOWN:
3837 link.link_duplex = ETH_LINK_FULL_DUPLEX;
3838 link.link_speed = ETH_SPEED_NUM_100M;
3841 case IXGBE_LINK_SPEED_100_FULL:
3842 link.link_speed = ETH_SPEED_NUM_100M;
3845 case IXGBE_LINK_SPEED_1GB_FULL:
3846 link.link_speed = ETH_SPEED_NUM_1G;
3849 case IXGBE_LINK_SPEED_10GB_FULL:
3850 link.link_speed = ETH_SPEED_NUM_10G;
3853 rte_ixgbe_dev_atomic_write_link_status(dev, &link);
3855 if (link.link_status == old.link_status)
3862 ixgbe_dev_promiscuous_enable(struct rte_eth_dev *dev)
3864 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3867 fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
3868 fctrl |= (IXGBE_FCTRL_UPE | IXGBE_FCTRL_MPE);
3869 IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
3873 ixgbe_dev_promiscuous_disable(struct rte_eth_dev *dev)
3875 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3878 fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
3879 fctrl &= (~IXGBE_FCTRL_UPE);
3880 if (dev->data->all_multicast == 1)
3881 fctrl |= IXGBE_FCTRL_MPE;
3883 fctrl &= (~IXGBE_FCTRL_MPE);
3884 IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
3888 ixgbe_dev_allmulticast_enable(struct rte_eth_dev *dev)
3890 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3893 fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
3894 fctrl |= IXGBE_FCTRL_MPE;
3895 IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
3899 ixgbe_dev_allmulticast_disable(struct rte_eth_dev *dev)
3901 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3904 if (dev->data->promiscuous == 1)
3905 return; /* must remain in all_multicast mode */
3907 fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
3908 fctrl &= (~IXGBE_FCTRL_MPE);
3909 IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
3913 * It clears the interrupt causes and enables the interrupt.
3914 * It will be called once only during nic initialized.
3917 * Pointer to struct rte_eth_dev.
3920 * - On success, zero.
3921 * - On failure, a negative value.
3924 ixgbe_dev_lsc_interrupt_setup(struct rte_eth_dev *dev)
3926 struct ixgbe_interrupt *intr =
3927 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
3929 ixgbe_dev_link_status_print(dev);
3930 intr->mask |= IXGBE_EICR_LSC;
3936 * It clears the interrupt causes and enables the interrupt.
3937 * It will be called once only during nic initialized.
3940 * Pointer to struct rte_eth_dev.
3943 * - On success, zero.
3944 * - On failure, a negative value.
3947 ixgbe_dev_rxq_interrupt_setup(struct rte_eth_dev *dev)
3949 struct ixgbe_interrupt *intr =
3950 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
3952 intr->mask |= IXGBE_EICR_RTX_QUEUE;
3958 * It clears the interrupt causes and enables the interrupt.
3959 * It will be called once only during nic initialized.
3962 * Pointer to struct rte_eth_dev.
3965 * - On success, zero.
3966 * - On failure, a negative value.
3969 ixgbe_dev_macsec_interrupt_setup(struct rte_eth_dev *dev)
3971 struct ixgbe_interrupt *intr =
3972 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
3974 intr->mask |= IXGBE_EICR_LINKSEC;
3980 * It reads ICR and sets flag (IXGBE_EICR_LSC) for the link_update.
3983 * Pointer to struct rte_eth_dev.
3986 * - On success, zero.
3987 * - On failure, a negative value.
3990 ixgbe_dev_interrupt_get_status(struct rte_eth_dev *dev)
3993 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3994 struct ixgbe_interrupt *intr =
3995 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
3997 /* clear all cause mask */
3998 ixgbe_disable_intr(hw);
4000 /* read-on-clear nic registers here */
4001 eicr = IXGBE_READ_REG(hw, IXGBE_EICR);
4002 PMD_DRV_LOG(DEBUG, "eicr %x", eicr);
4006 /* set flag for async link update */
4007 if (eicr & IXGBE_EICR_LSC)
4008 intr->flags |= IXGBE_FLAG_NEED_LINK_UPDATE;
4010 if (eicr & IXGBE_EICR_MAILBOX)
4011 intr->flags |= IXGBE_FLAG_MAILBOX;
4013 if (eicr & IXGBE_EICR_LINKSEC)
4014 intr->flags |= IXGBE_FLAG_MACSEC;
4016 if (hw->mac.type == ixgbe_mac_X550EM_x &&
4017 hw->phy.type == ixgbe_phy_x550em_ext_t &&
4018 (eicr & IXGBE_EICR_GPI_SDP0_X550EM_x))
4019 intr->flags |= IXGBE_FLAG_PHY_INTERRUPT;
4025 * It gets and then prints the link status.
4028 * Pointer to struct rte_eth_dev.
4031 * - On success, zero.
4032 * - On failure, a negative value.
4035 ixgbe_dev_link_status_print(struct rte_eth_dev *dev)
4037 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
4038 struct rte_eth_link link;
4040 memset(&link, 0, sizeof(link));
4041 rte_ixgbe_dev_atomic_read_link_status(dev, &link);
4042 if (link.link_status) {
4043 PMD_INIT_LOG(INFO, "Port %d: Link Up - speed %u Mbps - %s",
4044 (int)(dev->data->port_id),
4045 (unsigned)link.link_speed,
4046 link.link_duplex == ETH_LINK_FULL_DUPLEX ?
4047 "full-duplex" : "half-duplex");
4049 PMD_INIT_LOG(INFO, " Port %d: Link Down",
4050 (int)(dev->data->port_id));
4052 PMD_INIT_LOG(DEBUG, "PCI Address: " PCI_PRI_FMT,
4053 pci_dev->addr.domain,
4055 pci_dev->addr.devid,
4056 pci_dev->addr.function);
4060 * It executes link_update after knowing an interrupt occurred.
4063 * Pointer to struct rte_eth_dev.
4066 * - On success, zero.
4067 * - On failure, a negative value.
4070 ixgbe_dev_interrupt_action(struct rte_eth_dev *dev,
4071 struct rte_intr_handle *intr_handle)
4073 struct ixgbe_interrupt *intr =
4074 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
4076 struct rte_eth_link link;
4077 struct ixgbe_hw *hw =
4078 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4080 PMD_DRV_LOG(DEBUG, "intr action type %d", intr->flags);
4082 if (intr->flags & IXGBE_FLAG_MAILBOX) {
4083 ixgbe_pf_mbx_process(dev);
4084 intr->flags &= ~IXGBE_FLAG_MAILBOX;
4087 if (intr->flags & IXGBE_FLAG_PHY_INTERRUPT) {
4088 ixgbe_handle_lasi(hw);
4089 intr->flags &= ~IXGBE_FLAG_PHY_INTERRUPT;
4092 if (intr->flags & IXGBE_FLAG_NEED_LINK_UPDATE) {
4093 /* get the link status before link update, for predicting later */
4094 memset(&link, 0, sizeof(link));
4095 rte_ixgbe_dev_atomic_read_link_status(dev, &link);
4097 ixgbe_dev_link_update(dev, 0);
4100 if (!link.link_status)
4101 /* handle it 1 sec later, wait it being stable */
4102 timeout = IXGBE_LINK_UP_CHECK_TIMEOUT;
4103 /* likely to down */
4105 /* handle it 4 sec later, wait it being stable */
4106 timeout = IXGBE_LINK_DOWN_CHECK_TIMEOUT;
4108 ixgbe_dev_link_status_print(dev);
4109 intr->mask_original = intr->mask;
4110 /* only disable lsc interrupt */
4111 intr->mask &= ~IXGBE_EIMS_LSC;
4112 if (rte_eal_alarm_set(timeout * 1000,
4113 ixgbe_dev_interrupt_delayed_handler, (void *)dev) < 0)
4114 PMD_DRV_LOG(ERR, "Error setting alarm");
4116 intr->mask = intr->mask_original;
4119 PMD_DRV_LOG(DEBUG, "enable intr immediately");
4120 ixgbe_enable_intr(dev);
4121 rte_intr_enable(intr_handle);
4127 * Interrupt handler which shall be registered for alarm callback for delayed
4128 * handling specific interrupt to wait for the stable nic state. As the
4129 * NIC interrupt state is not stable for ixgbe after link is just down,
4130 * it needs to wait 4 seconds to get the stable status.
4133 * Pointer to interrupt handle.
4135 * The address of parameter (struct rte_eth_dev *) regsitered before.
4141 ixgbe_dev_interrupt_delayed_handler(void *param)
4143 struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
4144 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
4145 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
4146 struct ixgbe_interrupt *intr =
4147 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
4148 struct ixgbe_hw *hw =
4149 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4152 ixgbe_disable_intr(hw);
4154 eicr = IXGBE_READ_REG(hw, IXGBE_EICR);
4155 if (eicr & IXGBE_EICR_MAILBOX)
4156 ixgbe_pf_mbx_process(dev);
4158 if (intr->flags & IXGBE_FLAG_PHY_INTERRUPT) {
4159 ixgbe_handle_lasi(hw);
4160 intr->flags &= ~IXGBE_FLAG_PHY_INTERRUPT;
4163 if (intr->flags & IXGBE_FLAG_NEED_LINK_UPDATE) {
4164 ixgbe_dev_link_update(dev, 0);
4165 intr->flags &= ~IXGBE_FLAG_NEED_LINK_UPDATE;
4166 ixgbe_dev_link_status_print(dev);
4167 _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
4170 if (intr->flags & IXGBE_FLAG_MACSEC) {
4171 _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_MACSEC,
4173 intr->flags &= ~IXGBE_FLAG_MACSEC;
4176 /* restore original mask */
4177 intr->mask = intr->mask_original;
4178 intr->mask_original = 0;
4180 PMD_DRV_LOG(DEBUG, "enable intr in delayed handler S[%08x]", eicr);
4181 ixgbe_enable_intr(dev);
4182 rte_intr_enable(intr_handle);
4186 * Interrupt handler triggered by NIC for handling
4187 * specific interrupt.
4190 * Pointer to interrupt handle.
4192 * The address of parameter (struct rte_eth_dev *) regsitered before.
4198 ixgbe_dev_interrupt_handler(void *param)
4200 struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
4202 ixgbe_dev_interrupt_get_status(dev);
4203 ixgbe_dev_interrupt_action(dev, dev->intr_handle);
4207 ixgbe_dev_led_on(struct rte_eth_dev *dev)
4209 struct ixgbe_hw *hw;
4211 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4212 return ixgbe_led_on(hw, 0) == IXGBE_SUCCESS ? 0 : -ENOTSUP;
4216 ixgbe_dev_led_off(struct rte_eth_dev *dev)
4218 struct ixgbe_hw *hw;
4220 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4221 return ixgbe_led_off(hw, 0) == IXGBE_SUCCESS ? 0 : -ENOTSUP;
4225 ixgbe_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
4227 struct ixgbe_hw *hw;
4233 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4235 fc_conf->pause_time = hw->fc.pause_time;
4236 fc_conf->high_water = hw->fc.high_water[0];
4237 fc_conf->low_water = hw->fc.low_water[0];
4238 fc_conf->send_xon = hw->fc.send_xon;
4239 fc_conf->autoneg = !hw->fc.disable_fc_autoneg;
4242 * Return rx_pause status according to actual setting of
4245 mflcn_reg = IXGBE_READ_REG(hw, IXGBE_MFLCN);
4246 if (mflcn_reg & (IXGBE_MFLCN_RPFCE | IXGBE_MFLCN_RFCE))
4252 * Return tx_pause status according to actual setting of
4255 fccfg_reg = IXGBE_READ_REG(hw, IXGBE_FCCFG);
4256 if (fccfg_reg & (IXGBE_FCCFG_TFCE_802_3X | IXGBE_FCCFG_TFCE_PRIORITY))
4261 if (rx_pause && tx_pause)
4262 fc_conf->mode = RTE_FC_FULL;
4264 fc_conf->mode = RTE_FC_RX_PAUSE;
4266 fc_conf->mode = RTE_FC_TX_PAUSE;
4268 fc_conf->mode = RTE_FC_NONE;
4274 ixgbe_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
4276 struct ixgbe_hw *hw;
4278 uint32_t rx_buf_size;
4279 uint32_t max_high_water;
4281 enum ixgbe_fc_mode rte_fcmode_2_ixgbe_fcmode[] = {
4288 PMD_INIT_FUNC_TRACE();
4290 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4291 rx_buf_size = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(0));
4292 PMD_INIT_LOG(DEBUG, "Rx packet buffer size = 0x%x", rx_buf_size);
4295 * At least reserve one Ethernet frame for watermark
4296 * high_water/low_water in kilo bytes for ixgbe
4298 max_high_water = (rx_buf_size - ETHER_MAX_LEN) >> IXGBE_RXPBSIZE_SHIFT;
4299 if ((fc_conf->high_water > max_high_water) ||
4300 (fc_conf->high_water < fc_conf->low_water)) {
4301 PMD_INIT_LOG(ERR, "Invalid high/low water setup value in KB");
4302 PMD_INIT_LOG(ERR, "High_water must <= 0x%x", max_high_water);
4306 hw->fc.requested_mode = rte_fcmode_2_ixgbe_fcmode[fc_conf->mode];
4307 hw->fc.pause_time = fc_conf->pause_time;
4308 hw->fc.high_water[0] = fc_conf->high_water;
4309 hw->fc.low_water[0] = fc_conf->low_water;
4310 hw->fc.send_xon = fc_conf->send_xon;
4311 hw->fc.disable_fc_autoneg = !fc_conf->autoneg;
4313 err = ixgbe_fc_enable(hw);
4315 /* Not negotiated is not an error case */
4316 if ((err == IXGBE_SUCCESS) || (err == IXGBE_ERR_FC_NOT_NEGOTIATED)) {
4318 /* check if we want to forward MAC frames - driver doesn't have native
4319 * capability to do that, so we'll write the registers ourselves */
4321 mflcn = IXGBE_READ_REG(hw, IXGBE_MFLCN);
4323 /* set or clear MFLCN.PMCF bit depending on configuration */
4324 if (fc_conf->mac_ctrl_frame_fwd != 0)
4325 mflcn |= IXGBE_MFLCN_PMCF;
4327 mflcn &= ~IXGBE_MFLCN_PMCF;
4329 IXGBE_WRITE_REG(hw, IXGBE_MFLCN, mflcn);
4330 IXGBE_WRITE_FLUSH(hw);
4335 PMD_INIT_LOG(ERR, "ixgbe_fc_enable = 0x%x", err);
4340 * ixgbe_pfc_enable_generic - Enable flow control
4341 * @hw: pointer to hardware structure
4342 * @tc_num: traffic class number
4343 * Enable flow control according to the current settings.
4346 ixgbe_dcb_pfc_enable_generic(struct ixgbe_hw *hw, uint8_t tc_num)
4349 uint32_t mflcn_reg, fccfg_reg;
4351 uint32_t fcrtl, fcrth;
4355 /* Validate the water mark configuration */
4356 if (!hw->fc.pause_time) {
4357 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
4361 /* Low water mark of zero causes XOFF floods */
4362 if (hw->fc.current_mode & ixgbe_fc_tx_pause) {
4363 /* High/Low water can not be 0 */
4364 if ((!hw->fc.high_water[tc_num]) || (!hw->fc.low_water[tc_num])) {
4365 PMD_INIT_LOG(ERR, "Invalid water mark configuration");
4366 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
4370 if (hw->fc.low_water[tc_num] >= hw->fc.high_water[tc_num]) {
4371 PMD_INIT_LOG(ERR, "Invalid water mark configuration");
4372 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
4376 /* Negotiate the fc mode to use */
4377 ixgbe_fc_autoneg(hw);
4379 /* Disable any previous flow control settings */
4380 mflcn_reg = IXGBE_READ_REG(hw, IXGBE_MFLCN);
4381 mflcn_reg &= ~(IXGBE_MFLCN_RPFCE_SHIFT | IXGBE_MFLCN_RFCE|IXGBE_MFLCN_RPFCE);
4383 fccfg_reg = IXGBE_READ_REG(hw, IXGBE_FCCFG);
4384 fccfg_reg &= ~(IXGBE_FCCFG_TFCE_802_3X | IXGBE_FCCFG_TFCE_PRIORITY);
4386 switch (hw->fc.current_mode) {
4389 * If the count of enabled RX Priority Flow control >1,
4390 * and the TX pause can not be disabled
4393 for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
4394 reg = IXGBE_READ_REG(hw, IXGBE_FCRTH_82599(i));
4395 if (reg & IXGBE_FCRTH_FCEN)
4399 fccfg_reg |= IXGBE_FCCFG_TFCE_PRIORITY;
4401 case ixgbe_fc_rx_pause:
4403 * Rx Flow control is enabled and Tx Flow control is
4404 * disabled by software override. Since there really
4405 * isn't a way to advertise that we are capable of RX
4406 * Pause ONLY, we will advertise that we support both
4407 * symmetric and asymmetric Rx PAUSE. Later, we will
4408 * disable the adapter's ability to send PAUSE frames.
4410 mflcn_reg |= IXGBE_MFLCN_RPFCE;
4412 * If the count of enabled RX Priority Flow control >1,
4413 * and the TX pause can not be disabled
4416 for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
4417 reg = IXGBE_READ_REG(hw, IXGBE_FCRTH_82599(i));
4418 if (reg & IXGBE_FCRTH_FCEN)
4422 fccfg_reg |= IXGBE_FCCFG_TFCE_PRIORITY;
4424 case ixgbe_fc_tx_pause:
4426 * Tx Flow control is enabled, and Rx Flow control is
4427 * disabled by software override.
4429 fccfg_reg |= IXGBE_FCCFG_TFCE_PRIORITY;
4432 /* Flow control (both Rx and Tx) is enabled by SW override. */
4433 mflcn_reg |= IXGBE_MFLCN_RPFCE;
4434 fccfg_reg |= IXGBE_FCCFG_TFCE_PRIORITY;
4437 PMD_DRV_LOG(DEBUG, "Flow control param set incorrectly");
4438 ret_val = IXGBE_ERR_CONFIG;
4442 /* Set 802.3x based flow control settings. */
4443 mflcn_reg |= IXGBE_MFLCN_DPF;
4444 IXGBE_WRITE_REG(hw, IXGBE_MFLCN, mflcn_reg);
4445 IXGBE_WRITE_REG(hw, IXGBE_FCCFG, fccfg_reg);
4447 /* Set up and enable Rx high/low water mark thresholds, enable XON. */
4448 if ((hw->fc.current_mode & ixgbe_fc_tx_pause) &&
4449 hw->fc.high_water[tc_num]) {
4450 fcrtl = (hw->fc.low_water[tc_num] << 10) | IXGBE_FCRTL_XONE;
4451 IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(tc_num), fcrtl);
4452 fcrth = (hw->fc.high_water[tc_num] << 10) | IXGBE_FCRTH_FCEN;
4454 IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(tc_num), 0);
4456 * In order to prevent Tx hangs when the internal Tx
4457 * switch is enabled we must set the high water mark
4458 * to the maximum FCRTH value. This allows the Tx
4459 * switch to function even under heavy Rx workloads.
4461 fcrth = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(tc_num)) - 32;
4463 IXGBE_WRITE_REG(hw, IXGBE_FCRTH_82599(tc_num), fcrth);
4465 /* Configure pause time (2 TCs per register) */
4466 reg = hw->fc.pause_time * 0x00010001;
4467 for (i = 0; i < (IXGBE_DCB_MAX_TRAFFIC_CLASS / 2); i++)
4468 IXGBE_WRITE_REG(hw, IXGBE_FCTTV(i), reg);
4470 /* Configure flow control refresh threshold value */
4471 IXGBE_WRITE_REG(hw, IXGBE_FCRTV, hw->fc.pause_time / 2);
4478 ixgbe_dcb_pfc_enable(struct rte_eth_dev *dev, uint8_t tc_num)
4480 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4481 int32_t ret_val = IXGBE_NOT_IMPLEMENTED;
4483 if (hw->mac.type != ixgbe_mac_82598EB) {
4484 ret_val = ixgbe_dcb_pfc_enable_generic(hw, tc_num);
4490 ixgbe_priority_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_pfc_conf *pfc_conf)
4493 uint32_t rx_buf_size;
4494 uint32_t max_high_water;
4496 uint8_t map[IXGBE_DCB_MAX_USER_PRIORITY] = { 0 };
4497 struct ixgbe_hw *hw =
4498 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4499 struct ixgbe_dcb_config *dcb_config =
4500 IXGBE_DEV_PRIVATE_TO_DCB_CFG(dev->data->dev_private);
4502 enum ixgbe_fc_mode rte_fcmode_2_ixgbe_fcmode[] = {
4509 PMD_INIT_FUNC_TRACE();
4511 ixgbe_dcb_unpack_map_cee(dcb_config, IXGBE_DCB_RX_CONFIG, map);
4512 tc_num = map[pfc_conf->priority];
4513 rx_buf_size = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(tc_num));
4514 PMD_INIT_LOG(DEBUG, "Rx packet buffer size = 0x%x", rx_buf_size);
4516 * At least reserve one Ethernet frame for watermark
4517 * high_water/low_water in kilo bytes for ixgbe
4519 max_high_water = (rx_buf_size - ETHER_MAX_LEN) >> IXGBE_RXPBSIZE_SHIFT;
4520 if ((pfc_conf->fc.high_water > max_high_water) ||
4521 (pfc_conf->fc.high_water <= pfc_conf->fc.low_water)) {
4522 PMD_INIT_LOG(ERR, "Invalid high/low water setup value in KB");
4523 PMD_INIT_LOG(ERR, "High_water must <= 0x%x", max_high_water);
4527 hw->fc.requested_mode = rte_fcmode_2_ixgbe_fcmode[pfc_conf->fc.mode];
4528 hw->fc.pause_time = pfc_conf->fc.pause_time;
4529 hw->fc.send_xon = pfc_conf->fc.send_xon;
4530 hw->fc.low_water[tc_num] = pfc_conf->fc.low_water;
4531 hw->fc.high_water[tc_num] = pfc_conf->fc.high_water;
4533 err = ixgbe_dcb_pfc_enable(dev, tc_num);
4535 /* Not negotiated is not an error case */
4536 if ((err == IXGBE_SUCCESS) || (err == IXGBE_ERR_FC_NOT_NEGOTIATED))
4539 PMD_INIT_LOG(ERR, "ixgbe_dcb_pfc_enable = 0x%x", err);
4544 ixgbe_dev_rss_reta_update(struct rte_eth_dev *dev,
4545 struct rte_eth_rss_reta_entry64 *reta_conf,
4548 uint16_t i, sp_reta_size;
4551 uint16_t idx, shift;
4552 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4555 PMD_INIT_FUNC_TRACE();
4557 if (!ixgbe_rss_update_sp(hw->mac.type)) {
4558 PMD_DRV_LOG(ERR, "RSS reta update is not supported on this "
4563 sp_reta_size = ixgbe_reta_size_get(hw->mac.type);
4564 if (reta_size != sp_reta_size) {
4565 PMD_DRV_LOG(ERR, "The size of hash lookup table configured "
4566 "(%d) doesn't match the number hardware can supported "
4567 "(%d)", reta_size, sp_reta_size);
4571 for (i = 0; i < reta_size; i += IXGBE_4_BIT_WIDTH) {
4572 idx = i / RTE_RETA_GROUP_SIZE;
4573 shift = i % RTE_RETA_GROUP_SIZE;
4574 mask = (uint8_t)((reta_conf[idx].mask >> shift) &
4578 reta_reg = ixgbe_reta_reg_get(hw->mac.type, i);
4579 if (mask == IXGBE_4_BIT_MASK)
4582 r = IXGBE_READ_REG(hw, reta_reg);
4583 for (j = 0, reta = 0; j < IXGBE_4_BIT_WIDTH; j++) {
4584 if (mask & (0x1 << j))
4585 reta |= reta_conf[idx].reta[shift + j] <<
4588 reta |= r & (IXGBE_8_BIT_MASK <<
4591 IXGBE_WRITE_REG(hw, reta_reg, reta);
4598 ixgbe_dev_rss_reta_query(struct rte_eth_dev *dev,
4599 struct rte_eth_rss_reta_entry64 *reta_conf,
4602 uint16_t i, sp_reta_size;
4605 uint16_t idx, shift;
4606 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4609 PMD_INIT_FUNC_TRACE();
4610 sp_reta_size = ixgbe_reta_size_get(hw->mac.type);
4611 if (reta_size != sp_reta_size) {
4612 PMD_DRV_LOG(ERR, "The size of hash lookup table configured "
4613 "(%d) doesn't match the number hardware can supported "
4614 "(%d)", reta_size, sp_reta_size);
4618 for (i = 0; i < reta_size; i += IXGBE_4_BIT_WIDTH) {
4619 idx = i / RTE_RETA_GROUP_SIZE;
4620 shift = i % RTE_RETA_GROUP_SIZE;
4621 mask = (uint8_t)((reta_conf[idx].mask >> shift) &
4626 reta_reg = ixgbe_reta_reg_get(hw->mac.type, i);
4627 reta = IXGBE_READ_REG(hw, reta_reg);
4628 for (j = 0; j < IXGBE_4_BIT_WIDTH; j++) {
4629 if (mask & (0x1 << j))
4630 reta_conf[idx].reta[shift + j] =
4631 ((reta >> (CHAR_BIT * j)) &
4640 ixgbe_add_rar(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
4641 uint32_t index, uint32_t pool)
4643 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4644 uint32_t enable_addr = 1;
4646 ixgbe_set_rar(hw, index, mac_addr->addr_bytes, pool, enable_addr);
4650 ixgbe_remove_rar(struct rte_eth_dev *dev, uint32_t index)
4652 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4654 ixgbe_clear_rar(hw, index);
4658 ixgbe_set_default_mac_addr(struct rte_eth_dev *dev, struct ether_addr *addr)
4660 ixgbe_remove_rar(dev, 0);
4662 ixgbe_add_rar(dev, addr, 0, 0);
4666 is_device_supported(struct rte_eth_dev *dev, struct rte_pci_driver *drv)
4668 if (strcmp(dev->data->drv_name, drv->driver.name))
4675 is_ixgbe_supported(struct rte_eth_dev *dev)
4677 return is_device_supported(dev, &rte_ixgbe_pmd);
4681 ixgbe_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
4685 struct ixgbe_hw *hw;
4686 struct rte_eth_dev_info dev_info;
4687 uint32_t frame_size = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
4689 ixgbe_dev_info_get(dev, &dev_info);
4691 /* check that mtu is within the allowed range */
4692 if ((mtu < ETHER_MIN_MTU) || (frame_size > dev_info.max_rx_pktlen))
4695 /* refuse mtu that requires the support of scattered packets when this
4696 * feature has not been enabled before.
4698 if (!dev->data->scattered_rx &&
4699 (frame_size + 2 * IXGBE_VLAN_TAG_SIZE >
4700 dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM))
4703 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4704 hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
4706 /* switch to jumbo mode if needed */
4707 if (frame_size > ETHER_MAX_LEN) {
4708 dev->data->dev_conf.rxmode.jumbo_frame = 1;
4709 hlreg0 |= IXGBE_HLREG0_JUMBOEN;
4711 dev->data->dev_conf.rxmode.jumbo_frame = 0;
4712 hlreg0 &= ~IXGBE_HLREG0_JUMBOEN;
4714 IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
4716 /* update max frame size */
4717 dev->data->dev_conf.rxmode.max_rx_pkt_len = frame_size;
4719 maxfrs = IXGBE_READ_REG(hw, IXGBE_MAXFRS);
4720 maxfrs &= 0x0000FFFF;
4721 maxfrs |= (dev->data->dev_conf.rxmode.max_rx_pkt_len << 16);
4722 IXGBE_WRITE_REG(hw, IXGBE_MAXFRS, maxfrs);
4728 * Virtual Function operations
4731 ixgbevf_intr_disable(struct ixgbe_hw *hw)
4733 PMD_INIT_FUNC_TRACE();
4735 /* Clear interrupt mask to stop from interrupts being generated */
4736 IXGBE_WRITE_REG(hw, IXGBE_VTEIMC, IXGBE_VF_IRQ_CLEAR_MASK);
4738 IXGBE_WRITE_FLUSH(hw);
4742 ixgbevf_intr_enable(struct ixgbe_hw *hw)
4744 PMD_INIT_FUNC_TRACE();
4746 /* VF enable interrupt autoclean */
4747 IXGBE_WRITE_REG(hw, IXGBE_VTEIAM, IXGBE_VF_IRQ_ENABLE_MASK);
4748 IXGBE_WRITE_REG(hw, IXGBE_VTEIAC, IXGBE_VF_IRQ_ENABLE_MASK);
4749 IXGBE_WRITE_REG(hw, IXGBE_VTEIMS, IXGBE_VF_IRQ_ENABLE_MASK);
4751 IXGBE_WRITE_FLUSH(hw);
4755 ixgbevf_dev_configure(struct rte_eth_dev *dev)
4757 struct rte_eth_conf *conf = &dev->data->dev_conf;
4758 struct ixgbe_adapter *adapter =
4759 (struct ixgbe_adapter *)dev->data->dev_private;
4761 PMD_INIT_LOG(DEBUG, "Configured Virtual Function port id: %d",
4762 dev->data->port_id);
4765 * VF has no ability to enable/disable HW CRC
4766 * Keep the persistent behavior the same as Host PF
4768 #ifndef RTE_LIBRTE_IXGBE_PF_DISABLE_STRIP_CRC
4769 if (!conf->rxmode.hw_strip_crc) {
4770 PMD_INIT_LOG(NOTICE, "VF can't disable HW CRC Strip");
4771 conf->rxmode.hw_strip_crc = 1;
4774 if (conf->rxmode.hw_strip_crc) {
4775 PMD_INIT_LOG(NOTICE, "VF can't enable HW CRC Strip");
4776 conf->rxmode.hw_strip_crc = 0;
4781 * Initialize to TRUE. If any of Rx queues doesn't meet the bulk
4782 * allocation or vector Rx preconditions we will reset it.
4784 adapter->rx_bulk_alloc_allowed = true;
4785 adapter->rx_vec_allowed = true;
4791 ixgbevf_dev_start(struct rte_eth_dev *dev)
4793 struct ixgbe_hw *hw =
4794 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4795 uint32_t intr_vector = 0;
4796 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
4797 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
4801 PMD_INIT_FUNC_TRACE();
4803 hw->mac.ops.reset_hw(hw);
4804 hw->mac.get_link_status = true;
4806 /* negotiate mailbox API version to use with the PF. */
4807 ixgbevf_negotiate_api(hw);
4809 ixgbevf_dev_tx_init(dev);
4811 /* This can fail when allocating mbufs for descriptor rings */
4812 err = ixgbevf_dev_rx_init(dev);
4814 PMD_INIT_LOG(ERR, "Unable to initialize RX hardware (%d)", err);
4815 ixgbe_dev_clear_queues(dev);
4820 ixgbevf_set_vfta_all(dev, 1);
4823 mask = ETH_VLAN_STRIP_MASK | ETH_VLAN_FILTER_MASK |
4824 ETH_VLAN_EXTEND_MASK;
4825 ixgbevf_vlan_offload_set(dev, mask);
4827 ixgbevf_dev_rxtx_start(dev);
4829 /* check and configure queue intr-vector mapping */
4830 if (dev->data->dev_conf.intr_conf.rxq != 0) {
4831 intr_vector = dev->data->nb_rx_queues;
4832 if (rte_intr_efd_enable(intr_handle, intr_vector))
4836 if (rte_intr_dp_is_en(intr_handle) && !intr_handle->intr_vec) {
4837 intr_handle->intr_vec =
4838 rte_zmalloc("intr_vec",
4839 dev->data->nb_rx_queues * sizeof(int), 0);
4840 if (intr_handle->intr_vec == NULL) {
4841 PMD_INIT_LOG(ERR, "Failed to allocate %d rx_queues"
4842 " intr_vec", dev->data->nb_rx_queues);
4846 ixgbevf_configure_msix(dev);
4848 rte_intr_enable(intr_handle);
4850 /* Re-enable interrupt for VF */
4851 ixgbevf_intr_enable(hw);
4857 ixgbevf_dev_stop(struct rte_eth_dev *dev)
4859 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4860 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
4861 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
4863 PMD_INIT_FUNC_TRACE();
4865 ixgbevf_intr_disable(hw);
4867 hw->adapter_stopped = 1;
4868 ixgbe_stop_adapter(hw);
4871 * Clear what we set, but we still keep shadow_vfta to
4872 * restore after device starts
4874 ixgbevf_set_vfta_all(dev, 0);
4876 /* Clear stored conf */
4877 dev->data->scattered_rx = 0;
4879 ixgbe_dev_clear_queues(dev);
4881 /* Clean datapath event and queue/vec mapping */
4882 rte_intr_efd_disable(intr_handle);
4883 if (intr_handle->intr_vec != NULL) {
4884 rte_free(intr_handle->intr_vec);
4885 intr_handle->intr_vec = NULL;
4890 ixgbevf_dev_close(struct rte_eth_dev *dev)
4892 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4894 PMD_INIT_FUNC_TRACE();
4898 ixgbevf_dev_stop(dev);
4900 ixgbe_dev_free_queues(dev);
4903 * Remove the VF MAC address ro ensure
4904 * that the VF traffic goes to the PF
4905 * after stop, close and detach of the VF
4907 ixgbevf_remove_mac_addr(dev, 0);
4910 static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on)
4912 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4913 struct ixgbe_vfta *shadow_vfta =
4914 IXGBE_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
4915 int i = 0, j = 0, vfta = 0, mask = 1;
4917 for (i = 0; i < IXGBE_VFTA_SIZE; i++) {
4918 vfta = shadow_vfta->vfta[i];
4921 for (j = 0; j < 32; j++) {
4923 ixgbe_set_vfta(hw, (i<<5)+j, 0,
4933 ixgbevf_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
4935 struct ixgbe_hw *hw =
4936 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4937 struct ixgbe_vfta *shadow_vfta =
4938 IXGBE_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
4939 uint32_t vid_idx = 0;
4940 uint32_t vid_bit = 0;
4943 PMD_INIT_FUNC_TRACE();
4945 /* vind is not used in VF driver, set to 0, check ixgbe_set_vfta_vf */
4946 ret = ixgbe_set_vfta(hw, vlan_id, 0, !!on, false);
4948 PMD_INIT_LOG(ERR, "Unable to set VF vlan");
4951 vid_idx = (uint32_t) ((vlan_id >> 5) & 0x7F);
4952 vid_bit = (uint32_t) (1 << (vlan_id & 0x1F));
4954 /* Save what we set and retore it after device reset */
4956 shadow_vfta->vfta[vid_idx] |= vid_bit;
4958 shadow_vfta->vfta[vid_idx] &= ~vid_bit;
4964 ixgbevf_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue, int on)
4966 struct ixgbe_hw *hw =
4967 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4970 PMD_INIT_FUNC_TRACE();
4972 if (queue >= hw->mac.max_rx_queues)
4975 ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(queue));
4977 ctrl |= IXGBE_RXDCTL_VME;
4979 ctrl &= ~IXGBE_RXDCTL_VME;
4980 IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(queue), ctrl);
4982 ixgbe_vlan_hw_strip_bitmap_set(dev, queue, on);
4986 ixgbevf_vlan_offload_set(struct rte_eth_dev *dev, int mask)
4988 struct ixgbe_hw *hw =
4989 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4993 /* VF function only support hw strip feature, others are not support */
4994 if (mask & ETH_VLAN_STRIP_MASK) {
4995 on = !!(dev->data->dev_conf.rxmode.hw_vlan_strip);
4997 for (i = 0; i < hw->mac.max_rx_queues; i++)
4998 ixgbevf_vlan_strip_queue_set(dev, i, on);
5003 ixgbe_vt_check(struct ixgbe_hw *hw)
5007 /* if Virtualization Technology is enabled */
5008 reg_val = IXGBE_READ_REG(hw, IXGBE_VT_CTL);
5009 if (!(reg_val & IXGBE_VT_CTL_VT_ENABLE)) {
5010 PMD_INIT_LOG(ERR, "VT must be enabled for this setting");
5018 ixgbe_uta_vector(struct ixgbe_hw *hw, struct ether_addr *uc_addr)
5020 uint32_t vector = 0;
5022 switch (hw->mac.mc_filter_type) {
5023 case 0: /* use bits [47:36] of the address */
5024 vector = ((uc_addr->addr_bytes[4] >> 4) |
5025 (((uint16_t)uc_addr->addr_bytes[5]) << 4));
5027 case 1: /* use bits [46:35] of the address */
5028 vector = ((uc_addr->addr_bytes[4] >> 3) |
5029 (((uint16_t)uc_addr->addr_bytes[5]) << 5));
5031 case 2: /* use bits [45:34] of the address */
5032 vector = ((uc_addr->addr_bytes[4] >> 2) |
5033 (((uint16_t)uc_addr->addr_bytes[5]) << 6));
5035 case 3: /* use bits [43:32] of the address */
5036 vector = ((uc_addr->addr_bytes[4]) |
5037 (((uint16_t)uc_addr->addr_bytes[5]) << 8));
5039 default: /* Invalid mc_filter_type */
5043 /* vector can only be 12-bits or boundary will be exceeded */
5049 ixgbe_uc_hash_table_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
5057 const uint32_t ixgbe_uta_idx_mask = 0x7F;
5058 const uint32_t ixgbe_uta_bit_shift = 5;
5059 const uint32_t ixgbe_uta_bit_mask = (0x1 << ixgbe_uta_bit_shift) - 1;
5060 const uint32_t bit1 = 0x1;
5062 struct ixgbe_hw *hw =
5063 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5064 struct ixgbe_uta_info *uta_info =
5065 IXGBE_DEV_PRIVATE_TO_UTA(dev->data->dev_private);
5067 /* The UTA table only exists on 82599 hardware and newer */
5068 if (hw->mac.type < ixgbe_mac_82599EB)
5071 vector = ixgbe_uta_vector(hw, mac_addr);
5072 uta_idx = (vector >> ixgbe_uta_bit_shift) & ixgbe_uta_idx_mask;
5073 uta_shift = vector & ixgbe_uta_bit_mask;
5075 rc = ((uta_info->uta_shadow[uta_idx] >> uta_shift & bit1) != 0);
5079 reg_val = IXGBE_READ_REG(hw, IXGBE_UTA(uta_idx));
5081 uta_info->uta_in_use++;
5082 reg_val |= (bit1 << uta_shift);
5083 uta_info->uta_shadow[uta_idx] |= (bit1 << uta_shift);
5085 uta_info->uta_in_use--;
5086 reg_val &= ~(bit1 << uta_shift);
5087 uta_info->uta_shadow[uta_idx] &= ~(bit1 << uta_shift);
5090 IXGBE_WRITE_REG(hw, IXGBE_UTA(uta_idx), reg_val);
5092 if (uta_info->uta_in_use > 0)
5093 IXGBE_WRITE_REG(hw, IXGBE_MCSTCTRL,
5094 IXGBE_MCSTCTRL_MFE | hw->mac.mc_filter_type);
5096 IXGBE_WRITE_REG(hw, IXGBE_MCSTCTRL, hw->mac.mc_filter_type);
5102 ixgbe_uc_all_hash_table_set(struct rte_eth_dev *dev, uint8_t on)
5105 struct ixgbe_hw *hw =
5106 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5107 struct ixgbe_uta_info *uta_info =
5108 IXGBE_DEV_PRIVATE_TO_UTA(dev->data->dev_private);
5110 /* The UTA table only exists on 82599 hardware and newer */
5111 if (hw->mac.type < ixgbe_mac_82599EB)
5115 for (i = 0; i < ETH_VMDQ_NUM_UC_HASH_ARRAY; i++) {
5116 uta_info->uta_shadow[i] = ~0;
5117 IXGBE_WRITE_REG(hw, IXGBE_UTA(i), ~0);
5120 for (i = 0; i < ETH_VMDQ_NUM_UC_HASH_ARRAY; i++) {
5121 uta_info->uta_shadow[i] = 0;
5122 IXGBE_WRITE_REG(hw, IXGBE_UTA(i), 0);
5130 ixgbe_convert_vm_rx_mask_to_val(uint16_t rx_mask, uint32_t orig_val)
5132 uint32_t new_val = orig_val;
5134 if (rx_mask & ETH_VMDQ_ACCEPT_UNTAG)
5135 new_val |= IXGBE_VMOLR_AUPE;
5136 if (rx_mask & ETH_VMDQ_ACCEPT_HASH_MC)
5137 new_val |= IXGBE_VMOLR_ROMPE;
5138 if (rx_mask & ETH_VMDQ_ACCEPT_HASH_UC)
5139 new_val |= IXGBE_VMOLR_ROPE;
5140 if (rx_mask & ETH_VMDQ_ACCEPT_BROADCAST)
5141 new_val |= IXGBE_VMOLR_BAM;
5142 if (rx_mask & ETH_VMDQ_ACCEPT_MULTICAST)
5143 new_val |= IXGBE_VMOLR_MPE;
5148 #define IXGBE_MRCTL_VPME 0x01 /* Virtual Pool Mirroring. */
5149 #define IXGBE_MRCTL_UPME 0x02 /* Uplink Port Mirroring. */
5150 #define IXGBE_MRCTL_DPME 0x04 /* Downlink Port Mirroring. */
5151 #define IXGBE_MRCTL_VLME 0x08 /* VLAN Mirroring. */
5152 #define IXGBE_INVALID_MIRROR_TYPE(mirror_type) \
5153 ((mirror_type) & ~(uint8_t)(ETH_MIRROR_VIRTUAL_POOL_UP | \
5154 ETH_MIRROR_UPLINK_PORT | ETH_MIRROR_DOWNLINK_PORT | ETH_MIRROR_VLAN))
5157 ixgbe_mirror_rule_set(struct rte_eth_dev *dev,
5158 struct rte_eth_mirror_conf *mirror_conf,
5159 uint8_t rule_id, uint8_t on)
5161 uint32_t mr_ctl, vlvf;
5162 uint32_t mp_lsb = 0;
5163 uint32_t mv_msb = 0;
5164 uint32_t mv_lsb = 0;
5165 uint32_t mp_msb = 0;
5168 uint64_t vlan_mask = 0;
5170 const uint8_t pool_mask_offset = 32;
5171 const uint8_t vlan_mask_offset = 32;
5172 const uint8_t dst_pool_offset = 8;
5173 const uint8_t rule_mr_offset = 4;
5174 const uint8_t mirror_rule_mask = 0x0F;
5176 struct ixgbe_mirror_info *mr_info =
5177 (IXGBE_DEV_PRIVATE_TO_PFDATA(dev->data->dev_private));
5178 struct ixgbe_hw *hw =
5179 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5180 uint8_t mirror_type = 0;
5182 if (ixgbe_vt_check(hw) < 0)
5185 if (rule_id >= IXGBE_MAX_MIRROR_RULES)
5188 if (IXGBE_INVALID_MIRROR_TYPE(mirror_conf->rule_type)) {
5189 PMD_DRV_LOG(ERR, "unsupported mirror type 0x%x.",
5190 mirror_conf->rule_type);
5194 if (mirror_conf->rule_type & ETH_MIRROR_VLAN) {
5195 mirror_type |= IXGBE_MRCTL_VLME;
5196 /* Check if vlan id is valid and find conresponding VLAN ID
5199 for (i = 0; i < IXGBE_VLVF_ENTRIES; i++) {
5200 if (mirror_conf->vlan.vlan_mask & (1ULL << i)) {
5201 /* search vlan id related pool vlan filter
5204 reg_index = ixgbe_find_vlvf_slot(
5206 mirror_conf->vlan.vlan_id[i],
5210 vlvf = IXGBE_READ_REG(hw,
5211 IXGBE_VLVF(reg_index));
5212 if ((vlvf & IXGBE_VLVF_VIEN) &&
5213 ((vlvf & IXGBE_VLVF_VLANID_MASK) ==
5214 mirror_conf->vlan.vlan_id[i]))
5215 vlan_mask |= (1ULL << reg_index);
5222 mv_lsb = vlan_mask & 0xFFFFFFFF;
5223 mv_msb = vlan_mask >> vlan_mask_offset;
5225 mr_info->mr_conf[rule_id].vlan.vlan_mask =
5226 mirror_conf->vlan.vlan_mask;
5227 for (i = 0; i < ETH_VMDQ_MAX_VLAN_FILTERS; i++) {
5228 if (mirror_conf->vlan.vlan_mask & (1ULL << i))
5229 mr_info->mr_conf[rule_id].vlan.vlan_id[i] =
5230 mirror_conf->vlan.vlan_id[i];
5235 mr_info->mr_conf[rule_id].vlan.vlan_mask = 0;
5236 for (i = 0; i < ETH_VMDQ_MAX_VLAN_FILTERS; i++)
5237 mr_info->mr_conf[rule_id].vlan.vlan_id[i] = 0;
5242 * if enable pool mirror, write related pool mask register,if disable
5243 * pool mirror, clear PFMRVM register
5245 if (mirror_conf->rule_type & ETH_MIRROR_VIRTUAL_POOL_UP) {
5246 mirror_type |= IXGBE_MRCTL_VPME;
5248 mp_lsb = mirror_conf->pool_mask & 0xFFFFFFFF;
5249 mp_msb = mirror_conf->pool_mask >> pool_mask_offset;
5250 mr_info->mr_conf[rule_id].pool_mask =
5251 mirror_conf->pool_mask;
5256 mr_info->mr_conf[rule_id].pool_mask = 0;
5259 if (mirror_conf->rule_type & ETH_MIRROR_UPLINK_PORT)
5260 mirror_type |= IXGBE_MRCTL_UPME;
5261 if (mirror_conf->rule_type & ETH_MIRROR_DOWNLINK_PORT)
5262 mirror_type |= IXGBE_MRCTL_DPME;
5264 /* read mirror control register and recalculate it */
5265 mr_ctl = IXGBE_READ_REG(hw, IXGBE_MRCTL(rule_id));
5268 mr_ctl |= mirror_type;
5269 mr_ctl &= mirror_rule_mask;
5270 mr_ctl |= mirror_conf->dst_pool << dst_pool_offset;
5272 mr_ctl &= ~(mirror_conf->rule_type & mirror_rule_mask);
5275 mr_info->mr_conf[rule_id].rule_type = mirror_conf->rule_type;
5276 mr_info->mr_conf[rule_id].dst_pool = mirror_conf->dst_pool;
5278 /* write mirrror control register */
5279 IXGBE_WRITE_REG(hw, IXGBE_MRCTL(rule_id), mr_ctl);
5281 /* write pool mirrror control register */
5282 if (mirror_conf->rule_type == ETH_MIRROR_VIRTUAL_POOL_UP) {
5283 IXGBE_WRITE_REG(hw, IXGBE_VMRVM(rule_id), mp_lsb);
5284 IXGBE_WRITE_REG(hw, IXGBE_VMRVM(rule_id + rule_mr_offset),
5287 /* write VLAN mirrror control register */
5288 if (mirror_conf->rule_type == ETH_MIRROR_VLAN) {
5289 IXGBE_WRITE_REG(hw, IXGBE_VMRVLAN(rule_id), mv_lsb);
5290 IXGBE_WRITE_REG(hw, IXGBE_VMRVLAN(rule_id + rule_mr_offset),
5298 ixgbe_mirror_rule_reset(struct rte_eth_dev *dev, uint8_t rule_id)
5301 uint32_t lsb_val = 0;
5302 uint32_t msb_val = 0;
5303 const uint8_t rule_mr_offset = 4;
5305 struct ixgbe_hw *hw =
5306 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5307 struct ixgbe_mirror_info *mr_info =
5308 (IXGBE_DEV_PRIVATE_TO_PFDATA(dev->data->dev_private));
5310 if (ixgbe_vt_check(hw) < 0)
5313 memset(&mr_info->mr_conf[rule_id], 0,
5314 sizeof(struct rte_eth_mirror_conf));
5316 /* clear PFVMCTL register */
5317 IXGBE_WRITE_REG(hw, IXGBE_MRCTL(rule_id), mr_ctl);
5319 /* clear pool mask register */
5320 IXGBE_WRITE_REG(hw, IXGBE_VMRVM(rule_id), lsb_val);
5321 IXGBE_WRITE_REG(hw, IXGBE_VMRVM(rule_id + rule_mr_offset), msb_val);
5323 /* clear vlan mask register */
5324 IXGBE_WRITE_REG(hw, IXGBE_VMRVLAN(rule_id), lsb_val);
5325 IXGBE_WRITE_REG(hw, IXGBE_VMRVLAN(rule_id + rule_mr_offset), msb_val);
5331 ixgbevf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
5333 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
5334 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
5336 struct ixgbe_hw *hw =
5337 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5339 mask = IXGBE_READ_REG(hw, IXGBE_VTEIMS);
5340 mask |= (1 << IXGBE_MISC_VEC_ID);
5341 RTE_SET_USED(queue_id);
5342 IXGBE_WRITE_REG(hw, IXGBE_VTEIMS, mask);
5344 rte_intr_enable(intr_handle);
5350 ixgbevf_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id)
5353 struct ixgbe_hw *hw =
5354 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5356 mask = IXGBE_READ_REG(hw, IXGBE_VTEIMS);
5357 mask &= ~(1 << IXGBE_MISC_VEC_ID);
5358 RTE_SET_USED(queue_id);
5359 IXGBE_WRITE_REG(hw, IXGBE_VTEIMS, mask);
5365 ixgbe_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
5367 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
5368 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
5370 struct ixgbe_hw *hw =
5371 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5372 struct ixgbe_interrupt *intr =
5373 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
5375 if (queue_id < 16) {
5376 ixgbe_disable_intr(hw);
5377 intr->mask |= (1 << queue_id);
5378 ixgbe_enable_intr(dev);
5379 } else if (queue_id < 32) {
5380 mask = IXGBE_READ_REG(hw, IXGBE_EIMS_EX(0));
5381 mask &= (1 << queue_id);
5382 IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(0), mask);
5383 } else if (queue_id < 64) {
5384 mask = IXGBE_READ_REG(hw, IXGBE_EIMS_EX(1));
5385 mask &= (1 << (queue_id - 32));
5386 IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(1), mask);
5388 rte_intr_enable(intr_handle);
5394 ixgbe_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id)
5397 struct ixgbe_hw *hw =
5398 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5399 struct ixgbe_interrupt *intr =
5400 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
5402 if (queue_id < 16) {
5403 ixgbe_disable_intr(hw);
5404 intr->mask &= ~(1 << queue_id);
5405 ixgbe_enable_intr(dev);
5406 } else if (queue_id < 32) {
5407 mask = IXGBE_READ_REG(hw, IXGBE_EIMS_EX(0));
5408 mask &= ~(1 << queue_id);
5409 IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(0), mask);
5410 } else if (queue_id < 64) {
5411 mask = IXGBE_READ_REG(hw, IXGBE_EIMS_EX(1));
5412 mask &= ~(1 << (queue_id - 32));
5413 IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(1), mask);
5420 ixgbevf_set_ivar_map(struct ixgbe_hw *hw, int8_t direction,
5421 uint8_t queue, uint8_t msix_vector)
5425 if (direction == -1) {
5427 msix_vector |= IXGBE_IVAR_ALLOC_VAL;
5428 tmp = IXGBE_READ_REG(hw, IXGBE_VTIVAR_MISC);
5431 IXGBE_WRITE_REG(hw, IXGBE_VTIVAR_MISC, tmp);
5433 /* rx or tx cause */
5434 msix_vector |= IXGBE_IVAR_ALLOC_VAL;
5435 idx = ((16 * (queue & 1)) + (8 * direction));
5436 tmp = IXGBE_READ_REG(hw, IXGBE_VTIVAR(queue >> 1));
5437 tmp &= ~(0xFF << idx);
5438 tmp |= (msix_vector << idx);
5439 IXGBE_WRITE_REG(hw, IXGBE_VTIVAR(queue >> 1), tmp);
5444 * set the IVAR registers, mapping interrupt causes to vectors
5446 * pointer to ixgbe_hw struct
5448 * 0 for Rx, 1 for Tx, -1 for other causes
5450 * queue to map the corresponding interrupt to
5452 * the vector to map to the corresponding queue
5455 ixgbe_set_ivar_map(struct ixgbe_hw *hw, int8_t direction,
5456 uint8_t queue, uint8_t msix_vector)
5460 msix_vector |= IXGBE_IVAR_ALLOC_VAL;
5461 if (hw->mac.type == ixgbe_mac_82598EB) {
5462 if (direction == -1)
5464 idx = (((direction * 64) + queue) >> 2) & 0x1F;
5465 tmp = IXGBE_READ_REG(hw, IXGBE_IVAR(idx));
5466 tmp &= ~(0xFF << (8 * (queue & 0x3)));
5467 tmp |= (msix_vector << (8 * (queue & 0x3)));
5468 IXGBE_WRITE_REG(hw, IXGBE_IVAR(idx), tmp);
5469 } else if ((hw->mac.type == ixgbe_mac_82599EB) ||
5470 (hw->mac.type == ixgbe_mac_X540)) {
5471 if (direction == -1) {
5473 idx = ((queue & 1) * 8);
5474 tmp = IXGBE_READ_REG(hw, IXGBE_IVAR_MISC);
5475 tmp &= ~(0xFF << idx);
5476 tmp |= (msix_vector << idx);
5477 IXGBE_WRITE_REG(hw, IXGBE_IVAR_MISC, tmp);
5479 /* rx or tx causes */
5480 idx = ((16 * (queue & 1)) + (8 * direction));
5481 tmp = IXGBE_READ_REG(hw, IXGBE_IVAR(queue >> 1));
5482 tmp &= ~(0xFF << idx);
5483 tmp |= (msix_vector << idx);
5484 IXGBE_WRITE_REG(hw, IXGBE_IVAR(queue >> 1), tmp);
5490 ixgbevf_configure_msix(struct rte_eth_dev *dev)
5492 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
5493 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
5494 struct ixgbe_hw *hw =
5495 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5497 uint32_t vector_idx = IXGBE_MISC_VEC_ID;
5499 /* Configure VF other cause ivar */
5500 ixgbevf_set_ivar_map(hw, -1, 1, vector_idx);
5502 /* won't configure msix register if no mapping is done
5503 * between intr vector and event fd.
5505 if (!rte_intr_dp_is_en(intr_handle))
5508 /* Configure all RX queues of VF */
5509 for (q_idx = 0; q_idx < dev->data->nb_rx_queues; q_idx++) {
5510 /* Force all queue use vector 0,
5511 * as IXGBE_VF_MAXMSIVECOTR = 1
5513 ixgbevf_set_ivar_map(hw, 0, q_idx, vector_idx);
5514 intr_handle->intr_vec[q_idx] = vector_idx;
5519 * Sets up the hardware to properly generate MSI-X interrupts
5521 * board private structure
5524 ixgbe_configure_msix(struct rte_eth_dev *dev)
5526 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
5527 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
5528 struct ixgbe_hw *hw =
5529 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5530 uint32_t queue_id, base = IXGBE_MISC_VEC_ID;
5531 uint32_t vec = IXGBE_MISC_VEC_ID;
5535 /* won't configure msix register if no mapping is done
5536 * between intr vector and event fd
5538 if (!rte_intr_dp_is_en(intr_handle))
5541 if (rte_intr_allow_others(intr_handle))
5542 vec = base = IXGBE_RX_VEC_START;
5544 /* setup GPIE for MSI-x mode */
5545 gpie = IXGBE_READ_REG(hw, IXGBE_GPIE);
5546 gpie |= IXGBE_GPIE_MSIX_MODE | IXGBE_GPIE_PBA_SUPPORT |
5547 IXGBE_GPIE_OCD | IXGBE_GPIE_EIAME;
5548 /* auto clearing and auto setting corresponding bits in EIMS
5549 * when MSI-X interrupt is triggered
5551 if (hw->mac.type == ixgbe_mac_82598EB) {
5552 IXGBE_WRITE_REG(hw, IXGBE_EIAM, IXGBE_EICS_RTX_QUEUE);
5554 IXGBE_WRITE_REG(hw, IXGBE_EIAM_EX(0), 0xFFFFFFFF);
5555 IXGBE_WRITE_REG(hw, IXGBE_EIAM_EX(1), 0xFFFFFFFF);
5557 IXGBE_WRITE_REG(hw, IXGBE_GPIE, gpie);
5559 /* Populate the IVAR table and set the ITR values to the
5560 * corresponding register.
5562 for (queue_id = 0; queue_id < dev->data->nb_rx_queues;
5564 /* by default, 1:1 mapping */
5565 ixgbe_set_ivar_map(hw, 0, queue_id, vec);
5566 intr_handle->intr_vec[queue_id] = vec;
5567 if (vec < base + intr_handle->nb_efd - 1)
5571 switch (hw->mac.type) {
5572 case ixgbe_mac_82598EB:
5573 ixgbe_set_ivar_map(hw, -1, IXGBE_IVAR_OTHER_CAUSES_INDEX,
5576 case ixgbe_mac_82599EB:
5577 case ixgbe_mac_X540:
5578 ixgbe_set_ivar_map(hw, -1, 1, IXGBE_MISC_VEC_ID);
5583 IXGBE_WRITE_REG(hw, IXGBE_EITR(IXGBE_MISC_VEC_ID),
5584 IXGBE_MIN_INTER_INTERRUPT_INTERVAL_DEFAULT & 0xFFF);
5586 /* set up to autoclear timer, and the vectors */
5587 mask = IXGBE_EIMS_ENABLE_MASK;
5588 mask &= ~(IXGBE_EIMS_OTHER |
5589 IXGBE_EIMS_MAILBOX |
5592 IXGBE_WRITE_REG(hw, IXGBE_EIAC, mask);
5595 static int ixgbe_set_queue_rate_limit(struct rte_eth_dev *dev,
5596 uint16_t queue_idx, uint16_t tx_rate)
5598 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5599 uint32_t rf_dec, rf_int;
5601 uint16_t link_speed = dev->data->dev_link.link_speed;
5603 if (queue_idx >= hw->mac.max_tx_queues)
5607 /* Calculate the rate factor values to set */
5608 rf_int = (uint32_t)link_speed / (uint32_t)tx_rate;
5609 rf_dec = (uint32_t)link_speed % (uint32_t)tx_rate;
5610 rf_dec = (rf_dec << IXGBE_RTTBCNRC_RF_INT_SHIFT) / tx_rate;
5612 bcnrc_val = IXGBE_RTTBCNRC_RS_ENA;
5613 bcnrc_val |= ((rf_int << IXGBE_RTTBCNRC_RF_INT_SHIFT) &
5614 IXGBE_RTTBCNRC_RF_INT_MASK_M);
5615 bcnrc_val |= (rf_dec & IXGBE_RTTBCNRC_RF_DEC_MASK);
5621 * Set global transmit compensation time to the MMW_SIZE in RTTBCNRM
5622 * register. MMW_SIZE=0x014 if 9728-byte jumbo is supported, otherwise
5625 if ((dev->data->dev_conf.rxmode.jumbo_frame == 1) &&
5626 (dev->data->dev_conf.rxmode.max_rx_pkt_len >=
5627 IXGBE_MAX_JUMBO_FRAME_SIZE))
5628 IXGBE_WRITE_REG(hw, IXGBE_RTTBCNRM,
5629 IXGBE_MMW_SIZE_JUMBO_FRAME);
5631 IXGBE_WRITE_REG(hw, IXGBE_RTTBCNRM,
5632 IXGBE_MMW_SIZE_DEFAULT);
5634 /* Set RTTBCNRC of queue X */
5635 IXGBE_WRITE_REG(hw, IXGBE_RTTDQSEL, queue_idx);
5636 IXGBE_WRITE_REG(hw, IXGBE_RTTBCNRC, bcnrc_val);
5637 IXGBE_WRITE_FLUSH(hw);
5643 ixgbevf_add_mac_addr(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
5644 __attribute__((unused)) uint32_t index,
5645 __attribute__((unused)) uint32_t pool)
5647 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5651 * On a 82599 VF, adding again the same MAC addr is not an idempotent
5652 * operation. Trap this case to avoid exhausting the [very limited]
5653 * set of PF resources used to store VF MAC addresses.
5655 if (memcmp(hw->mac.perm_addr, mac_addr, sizeof(struct ether_addr)) == 0)
5657 diag = ixgbevf_set_uc_addr_vf(hw, 2, mac_addr->addr_bytes);
5660 PMD_DRV_LOG(ERR, "Unable to add MAC address - diag=%d", diag);
5664 ixgbevf_remove_mac_addr(struct rte_eth_dev *dev, uint32_t index)
5666 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5667 struct ether_addr *perm_addr = (struct ether_addr *) hw->mac.perm_addr;
5668 struct ether_addr *mac_addr;
5673 * The IXGBE_VF_SET_MACVLAN command of the ixgbe-pf driver does
5674 * not support the deletion of a given MAC address.
5675 * Instead, it imposes to delete all MAC addresses, then to add again
5676 * all MAC addresses with the exception of the one to be deleted.
5678 (void) ixgbevf_set_uc_addr_vf(hw, 0, NULL);
5681 * Add again all MAC addresses, with the exception of the deleted one
5682 * and of the permanent MAC address.
5684 for (i = 0, mac_addr = dev->data->mac_addrs;
5685 i < hw->mac.num_rar_entries; i++, mac_addr++) {
5686 /* Skip the deleted MAC address */
5689 /* Skip NULL MAC addresses */
5690 if (is_zero_ether_addr(mac_addr))
5692 /* Skip the permanent MAC address */
5693 if (memcmp(perm_addr, mac_addr, sizeof(struct ether_addr)) == 0)
5695 diag = ixgbevf_set_uc_addr_vf(hw, 2, mac_addr->addr_bytes);
5698 "Adding again MAC address "
5699 "%02x:%02x:%02x:%02x:%02x:%02x failed "
5701 mac_addr->addr_bytes[0],
5702 mac_addr->addr_bytes[1],
5703 mac_addr->addr_bytes[2],
5704 mac_addr->addr_bytes[3],
5705 mac_addr->addr_bytes[4],
5706 mac_addr->addr_bytes[5],
5712 ixgbevf_set_default_mac_addr(struct rte_eth_dev *dev, struct ether_addr *addr)
5714 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5716 hw->mac.ops.set_rar(hw, 0, (void *)addr, 0, 0);
5720 ixgbe_syn_filter_set(struct rte_eth_dev *dev,
5721 struct rte_eth_syn_filter *filter,
5724 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5725 struct ixgbe_filter_info *filter_info =
5726 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
5730 if (filter->queue >= IXGBE_MAX_RX_QUEUE_NUM)
5733 syn_info = filter_info->syn_info;
5736 if (syn_info & IXGBE_SYN_FILTER_ENABLE)
5738 synqf = (uint32_t)(((filter->queue << IXGBE_SYN_FILTER_QUEUE_SHIFT) &
5739 IXGBE_SYN_FILTER_QUEUE) | IXGBE_SYN_FILTER_ENABLE);
5741 if (filter->hig_pri)
5742 synqf |= IXGBE_SYN_FILTER_SYNQFP;
5744 synqf &= ~IXGBE_SYN_FILTER_SYNQFP;
5746 synqf = IXGBE_READ_REG(hw, IXGBE_SYNQF);
5747 if (!(syn_info & IXGBE_SYN_FILTER_ENABLE))
5749 synqf &= ~(IXGBE_SYN_FILTER_QUEUE | IXGBE_SYN_FILTER_ENABLE);
5752 filter_info->syn_info = synqf;
5753 IXGBE_WRITE_REG(hw, IXGBE_SYNQF, synqf);
5754 IXGBE_WRITE_FLUSH(hw);
5759 ixgbe_syn_filter_get(struct rte_eth_dev *dev,
5760 struct rte_eth_syn_filter *filter)
5762 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5763 uint32_t synqf = IXGBE_READ_REG(hw, IXGBE_SYNQF);
5765 if (synqf & IXGBE_SYN_FILTER_ENABLE) {
5766 filter->hig_pri = (synqf & IXGBE_SYN_FILTER_SYNQFP) ? 1 : 0;
5767 filter->queue = (uint16_t)((synqf & IXGBE_SYN_FILTER_QUEUE) >> 1);
5774 ixgbe_syn_filter_handle(struct rte_eth_dev *dev,
5775 enum rte_filter_op filter_op,
5778 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5781 MAC_TYPE_FILTER_SUP(hw->mac.type);
5783 if (filter_op == RTE_ETH_FILTER_NOP)
5787 PMD_DRV_LOG(ERR, "arg shouldn't be NULL for operation %u",
5792 switch (filter_op) {
5793 case RTE_ETH_FILTER_ADD:
5794 ret = ixgbe_syn_filter_set(dev,
5795 (struct rte_eth_syn_filter *)arg,
5798 case RTE_ETH_FILTER_DELETE:
5799 ret = ixgbe_syn_filter_set(dev,
5800 (struct rte_eth_syn_filter *)arg,
5803 case RTE_ETH_FILTER_GET:
5804 ret = ixgbe_syn_filter_get(dev,
5805 (struct rte_eth_syn_filter *)arg);
5808 PMD_DRV_LOG(ERR, "unsupported operation %u", filter_op);
5817 static inline enum ixgbe_5tuple_protocol
5818 convert_protocol_type(uint8_t protocol_value)
5820 if (protocol_value == IPPROTO_TCP)
5821 return IXGBE_FILTER_PROTOCOL_TCP;
5822 else if (protocol_value == IPPROTO_UDP)
5823 return IXGBE_FILTER_PROTOCOL_UDP;
5824 else if (protocol_value == IPPROTO_SCTP)
5825 return IXGBE_FILTER_PROTOCOL_SCTP;
5827 return IXGBE_FILTER_PROTOCOL_NONE;
5830 /* inject a 5-tuple filter to HW */
5832 ixgbe_inject_5tuple_filter(struct rte_eth_dev *dev,
5833 struct ixgbe_5tuple_filter *filter)
5835 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5837 uint32_t ftqf, sdpqf;
5838 uint32_t l34timir = 0;
5839 uint8_t mask = 0xff;
5843 sdpqf = (uint32_t)(filter->filter_info.dst_port <<
5844 IXGBE_SDPQF_DSTPORT_SHIFT);
5845 sdpqf = sdpqf | (filter->filter_info.src_port & IXGBE_SDPQF_SRCPORT);
5847 ftqf = (uint32_t)(filter->filter_info.proto &
5848 IXGBE_FTQF_PROTOCOL_MASK);
5849 ftqf |= (uint32_t)((filter->filter_info.priority &
5850 IXGBE_FTQF_PRIORITY_MASK) << IXGBE_FTQF_PRIORITY_SHIFT);
5851 if (filter->filter_info.src_ip_mask == 0) /* 0 means compare. */
5852 mask &= IXGBE_FTQF_SOURCE_ADDR_MASK;
5853 if (filter->filter_info.dst_ip_mask == 0)
5854 mask &= IXGBE_FTQF_DEST_ADDR_MASK;
5855 if (filter->filter_info.src_port_mask == 0)
5856 mask &= IXGBE_FTQF_SOURCE_PORT_MASK;
5857 if (filter->filter_info.dst_port_mask == 0)
5858 mask &= IXGBE_FTQF_DEST_PORT_MASK;
5859 if (filter->filter_info.proto_mask == 0)
5860 mask &= IXGBE_FTQF_PROTOCOL_COMP_MASK;
5861 ftqf |= mask << IXGBE_FTQF_5TUPLE_MASK_SHIFT;
5862 ftqf |= IXGBE_FTQF_POOL_MASK_EN;
5863 ftqf |= IXGBE_FTQF_QUEUE_ENABLE;
5865 IXGBE_WRITE_REG(hw, IXGBE_DAQF(i), filter->filter_info.dst_ip);
5866 IXGBE_WRITE_REG(hw, IXGBE_SAQF(i), filter->filter_info.src_ip);
5867 IXGBE_WRITE_REG(hw, IXGBE_SDPQF(i), sdpqf);
5868 IXGBE_WRITE_REG(hw, IXGBE_FTQF(i), ftqf);
5870 l34timir |= IXGBE_L34T_IMIR_RESERVE;
5871 l34timir |= (uint32_t)(filter->queue <<
5872 IXGBE_L34T_IMIR_QUEUE_SHIFT);
5873 IXGBE_WRITE_REG(hw, IXGBE_L34T_IMIR(i), l34timir);
5877 * add a 5tuple filter
5880 * dev: Pointer to struct rte_eth_dev.
5881 * index: the index the filter allocates.
5882 * filter: ponter to the filter that will be added.
5883 * rx_queue: the queue id the filter assigned to.
5886 * - On success, zero.
5887 * - On failure, a negative value.
5890 ixgbe_add_5tuple_filter(struct rte_eth_dev *dev,
5891 struct ixgbe_5tuple_filter *filter)
5893 struct ixgbe_filter_info *filter_info =
5894 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
5898 * look for an unused 5tuple filter index,
5899 * and insert the filter to list.
5901 for (i = 0; i < IXGBE_MAX_FTQF_FILTERS; i++) {
5902 idx = i / (sizeof(uint32_t) * NBBY);
5903 shift = i % (sizeof(uint32_t) * NBBY);
5904 if (!(filter_info->fivetuple_mask[idx] & (1 << shift))) {
5905 filter_info->fivetuple_mask[idx] |= 1 << shift;
5907 TAILQ_INSERT_TAIL(&filter_info->fivetuple_list,
5913 if (i >= IXGBE_MAX_FTQF_FILTERS) {
5914 PMD_DRV_LOG(ERR, "5tuple filters are full.");
5918 ixgbe_inject_5tuple_filter(dev, filter);
5924 * remove a 5tuple filter
5927 * dev: Pointer to struct rte_eth_dev.
5928 * filter: the pointer of the filter will be removed.
5931 ixgbe_remove_5tuple_filter(struct rte_eth_dev *dev,
5932 struct ixgbe_5tuple_filter *filter)
5934 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5935 struct ixgbe_filter_info *filter_info =
5936 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
5937 uint16_t index = filter->index;
5939 filter_info->fivetuple_mask[index / (sizeof(uint32_t) * NBBY)] &=
5940 ~(1 << (index % (sizeof(uint32_t) * NBBY)));
5941 TAILQ_REMOVE(&filter_info->fivetuple_list, filter, entries);
5944 IXGBE_WRITE_REG(hw, IXGBE_DAQF(index), 0);
5945 IXGBE_WRITE_REG(hw, IXGBE_SAQF(index), 0);
5946 IXGBE_WRITE_REG(hw, IXGBE_SDPQF(index), 0);
5947 IXGBE_WRITE_REG(hw, IXGBE_FTQF(index), 0);
5948 IXGBE_WRITE_REG(hw, IXGBE_L34T_IMIR(index), 0);
5952 ixgbevf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
5954 struct ixgbe_hw *hw;
5955 uint32_t max_frame = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
5957 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5959 if ((mtu < ETHER_MIN_MTU) || (max_frame > ETHER_MAX_JUMBO_FRAME_LEN))
5962 /* refuse mtu that requires the support of scattered packets when this
5963 * feature has not been enabled before.
5965 if (!dev->data->scattered_rx &&
5966 (max_frame + 2 * IXGBE_VLAN_TAG_SIZE >
5967 dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM))
5971 * When supported by the underlying PF driver, use the IXGBE_VF_SET_MTU
5972 * request of the version 2.0 of the mailbox API.
5973 * For now, use the IXGBE_VF_SET_LPE request of the version 1.0
5974 * of the mailbox API.
5975 * This call to IXGBE_SET_LPE action won't work with ixgbe pf drivers
5976 * prior to 3.11.33 which contains the following change:
5977 * "ixgbe: Enable jumbo frames support w/ SR-IOV"
5979 ixgbevf_rlpml_set_vf(hw, max_frame);
5981 /* update max frame size */
5982 dev->data->dev_conf.rxmode.max_rx_pkt_len = max_frame;
5986 static inline struct ixgbe_5tuple_filter *
5987 ixgbe_5tuple_filter_lookup(struct ixgbe_5tuple_filter_list *filter_list,
5988 struct ixgbe_5tuple_filter_info *key)
5990 struct ixgbe_5tuple_filter *it;
5992 TAILQ_FOREACH(it, filter_list, entries) {
5993 if (memcmp(key, &it->filter_info,
5994 sizeof(struct ixgbe_5tuple_filter_info)) == 0) {
6001 /* translate elements in struct rte_eth_ntuple_filter to struct ixgbe_5tuple_filter_info*/
6003 ntuple_filter_to_5tuple(struct rte_eth_ntuple_filter *filter,
6004 struct ixgbe_5tuple_filter_info *filter_info)
6006 if (filter->queue >= IXGBE_MAX_RX_QUEUE_NUM ||
6007 filter->priority > IXGBE_5TUPLE_MAX_PRI ||
6008 filter->priority < IXGBE_5TUPLE_MIN_PRI)
6011 switch (filter->dst_ip_mask) {
6013 filter_info->dst_ip_mask = 0;
6014 filter_info->dst_ip = filter->dst_ip;
6017 filter_info->dst_ip_mask = 1;
6020 PMD_DRV_LOG(ERR, "invalid dst_ip mask.");
6024 switch (filter->src_ip_mask) {
6026 filter_info->src_ip_mask = 0;
6027 filter_info->src_ip = filter->src_ip;
6030 filter_info->src_ip_mask = 1;
6033 PMD_DRV_LOG(ERR, "invalid src_ip mask.");
6037 switch (filter->dst_port_mask) {
6039 filter_info->dst_port_mask = 0;
6040 filter_info->dst_port = filter->dst_port;
6043 filter_info->dst_port_mask = 1;
6046 PMD_DRV_LOG(ERR, "invalid dst_port mask.");
6050 switch (filter->src_port_mask) {
6052 filter_info->src_port_mask = 0;
6053 filter_info->src_port = filter->src_port;
6056 filter_info->src_port_mask = 1;
6059 PMD_DRV_LOG(ERR, "invalid src_port mask.");
6063 switch (filter->proto_mask) {
6065 filter_info->proto_mask = 0;
6066 filter_info->proto =
6067 convert_protocol_type(filter->proto);
6070 filter_info->proto_mask = 1;
6073 PMD_DRV_LOG(ERR, "invalid protocol mask.");
6077 filter_info->priority = (uint8_t)filter->priority;
6082 * add or delete a ntuple filter
6085 * dev: Pointer to struct rte_eth_dev.
6086 * ntuple_filter: Pointer to struct rte_eth_ntuple_filter
6087 * add: if true, add filter, if false, remove filter
6090 * - On success, zero.
6091 * - On failure, a negative value.
6094 ixgbe_add_del_ntuple_filter(struct rte_eth_dev *dev,
6095 struct rte_eth_ntuple_filter *ntuple_filter,
6098 struct ixgbe_filter_info *filter_info =
6099 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6100 struct ixgbe_5tuple_filter_info filter_5tuple;
6101 struct ixgbe_5tuple_filter *filter;
6104 if (ntuple_filter->flags != RTE_5TUPLE_FLAGS) {
6105 PMD_DRV_LOG(ERR, "only 5tuple is supported.");
6109 memset(&filter_5tuple, 0, sizeof(struct ixgbe_5tuple_filter_info));
6110 ret = ntuple_filter_to_5tuple(ntuple_filter, &filter_5tuple);
6114 filter = ixgbe_5tuple_filter_lookup(&filter_info->fivetuple_list,
6116 if (filter != NULL && add) {
6117 PMD_DRV_LOG(ERR, "filter exists.");
6120 if (filter == NULL && !add) {
6121 PMD_DRV_LOG(ERR, "filter doesn't exist.");
6126 filter = rte_zmalloc("ixgbe_5tuple_filter",
6127 sizeof(struct ixgbe_5tuple_filter), 0);
6130 (void)rte_memcpy(&filter->filter_info,
6132 sizeof(struct ixgbe_5tuple_filter_info));
6133 filter->queue = ntuple_filter->queue;
6134 ret = ixgbe_add_5tuple_filter(dev, filter);
6140 ixgbe_remove_5tuple_filter(dev, filter);
6146 * get a ntuple filter
6149 * dev: Pointer to struct rte_eth_dev.
6150 * ntuple_filter: Pointer to struct rte_eth_ntuple_filter
6153 * - On success, zero.
6154 * - On failure, a negative value.
6157 ixgbe_get_ntuple_filter(struct rte_eth_dev *dev,
6158 struct rte_eth_ntuple_filter *ntuple_filter)
6160 struct ixgbe_filter_info *filter_info =
6161 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6162 struct ixgbe_5tuple_filter_info filter_5tuple;
6163 struct ixgbe_5tuple_filter *filter;
6166 if (ntuple_filter->flags != RTE_5TUPLE_FLAGS) {
6167 PMD_DRV_LOG(ERR, "only 5tuple is supported.");
6171 memset(&filter_5tuple, 0, sizeof(struct ixgbe_5tuple_filter_info));
6172 ret = ntuple_filter_to_5tuple(ntuple_filter, &filter_5tuple);
6176 filter = ixgbe_5tuple_filter_lookup(&filter_info->fivetuple_list,
6178 if (filter == NULL) {
6179 PMD_DRV_LOG(ERR, "filter doesn't exist.");
6182 ntuple_filter->queue = filter->queue;
6187 * ixgbe_ntuple_filter_handle - Handle operations for ntuple filter.
6188 * @dev: pointer to rte_eth_dev structure
6189 * @filter_op:operation will be taken.
6190 * @arg: a pointer to specific structure corresponding to the filter_op
6193 * - On success, zero.
6194 * - On failure, a negative value.
6197 ixgbe_ntuple_filter_handle(struct rte_eth_dev *dev,
6198 enum rte_filter_op filter_op,
6201 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6204 MAC_TYPE_FILTER_SUP_EXT(hw->mac.type);
6206 if (filter_op == RTE_ETH_FILTER_NOP)
6210 PMD_DRV_LOG(ERR, "arg shouldn't be NULL for operation %u.",
6215 switch (filter_op) {
6216 case RTE_ETH_FILTER_ADD:
6217 ret = ixgbe_add_del_ntuple_filter(dev,
6218 (struct rte_eth_ntuple_filter *)arg,
6221 case RTE_ETH_FILTER_DELETE:
6222 ret = ixgbe_add_del_ntuple_filter(dev,
6223 (struct rte_eth_ntuple_filter *)arg,
6226 case RTE_ETH_FILTER_GET:
6227 ret = ixgbe_get_ntuple_filter(dev,
6228 (struct rte_eth_ntuple_filter *)arg);
6231 PMD_DRV_LOG(ERR, "unsupported operation %u.", filter_op);
6239 ixgbe_add_del_ethertype_filter(struct rte_eth_dev *dev,
6240 struct rte_eth_ethertype_filter *filter,
6243 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6244 struct ixgbe_filter_info *filter_info =
6245 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6249 struct ixgbe_ethertype_filter ethertype_filter;
6251 if (filter->queue >= IXGBE_MAX_RX_QUEUE_NUM)
6254 if (filter->ether_type == ETHER_TYPE_IPv4 ||
6255 filter->ether_type == ETHER_TYPE_IPv6) {
6256 PMD_DRV_LOG(ERR, "unsupported ether_type(0x%04x) in"
6257 " ethertype filter.", filter->ether_type);
6261 if (filter->flags & RTE_ETHTYPE_FLAGS_MAC) {
6262 PMD_DRV_LOG(ERR, "mac compare is unsupported.");
6265 if (filter->flags & RTE_ETHTYPE_FLAGS_DROP) {
6266 PMD_DRV_LOG(ERR, "drop option is unsupported.");
6270 ret = ixgbe_ethertype_filter_lookup(filter_info, filter->ether_type);
6271 if (ret >= 0 && add) {
6272 PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter exists.",
6273 filter->ether_type);
6276 if (ret < 0 && !add) {
6277 PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter doesn't exist.",
6278 filter->ether_type);
6283 etqf = IXGBE_ETQF_FILTER_EN;
6284 etqf |= (uint32_t)filter->ether_type;
6285 etqs |= (uint32_t)((filter->queue <<
6286 IXGBE_ETQS_RX_QUEUE_SHIFT) &
6287 IXGBE_ETQS_RX_QUEUE);
6288 etqs |= IXGBE_ETQS_QUEUE_EN;
6290 ethertype_filter.ethertype = filter->ether_type;
6291 ethertype_filter.etqf = etqf;
6292 ethertype_filter.etqs = etqs;
6293 ethertype_filter.conf = FALSE;
6294 ret = ixgbe_ethertype_filter_insert(filter_info,
6297 PMD_DRV_LOG(ERR, "ethertype filters are full.");
6301 ret = ixgbe_ethertype_filter_remove(filter_info, (uint8_t)ret);
6305 IXGBE_WRITE_REG(hw, IXGBE_ETQF(ret), etqf);
6306 IXGBE_WRITE_REG(hw, IXGBE_ETQS(ret), etqs);
6307 IXGBE_WRITE_FLUSH(hw);
6313 ixgbe_get_ethertype_filter(struct rte_eth_dev *dev,
6314 struct rte_eth_ethertype_filter *filter)
6316 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6317 struct ixgbe_filter_info *filter_info =
6318 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6319 uint32_t etqf, etqs;
6322 ret = ixgbe_ethertype_filter_lookup(filter_info, filter->ether_type);
6324 PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter doesn't exist.",
6325 filter->ether_type);
6329 etqf = IXGBE_READ_REG(hw, IXGBE_ETQF(ret));
6330 if (etqf & IXGBE_ETQF_FILTER_EN) {
6331 etqs = IXGBE_READ_REG(hw, IXGBE_ETQS(ret));
6332 filter->ether_type = etqf & IXGBE_ETQF_ETHERTYPE;
6334 filter->queue = (etqs & IXGBE_ETQS_RX_QUEUE) >>
6335 IXGBE_ETQS_RX_QUEUE_SHIFT;
6342 * ixgbe_ethertype_filter_handle - Handle operations for ethertype filter.
6343 * @dev: pointer to rte_eth_dev structure
6344 * @filter_op:operation will be taken.
6345 * @arg: a pointer to specific structure corresponding to the filter_op
6348 ixgbe_ethertype_filter_handle(struct rte_eth_dev *dev,
6349 enum rte_filter_op filter_op,
6352 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6355 MAC_TYPE_FILTER_SUP(hw->mac.type);
6357 if (filter_op == RTE_ETH_FILTER_NOP)
6361 PMD_DRV_LOG(ERR, "arg shouldn't be NULL for operation %u.",
6366 switch (filter_op) {
6367 case RTE_ETH_FILTER_ADD:
6368 ret = ixgbe_add_del_ethertype_filter(dev,
6369 (struct rte_eth_ethertype_filter *)arg,
6372 case RTE_ETH_FILTER_DELETE:
6373 ret = ixgbe_add_del_ethertype_filter(dev,
6374 (struct rte_eth_ethertype_filter *)arg,
6377 case RTE_ETH_FILTER_GET:
6378 ret = ixgbe_get_ethertype_filter(dev,
6379 (struct rte_eth_ethertype_filter *)arg);
6382 PMD_DRV_LOG(ERR, "unsupported operation %u.", filter_op);
6390 ixgbe_dev_filter_ctrl(struct rte_eth_dev *dev,
6391 enum rte_filter_type filter_type,
6392 enum rte_filter_op filter_op,
6397 switch (filter_type) {
6398 case RTE_ETH_FILTER_NTUPLE:
6399 ret = ixgbe_ntuple_filter_handle(dev, filter_op, arg);
6401 case RTE_ETH_FILTER_ETHERTYPE:
6402 ret = ixgbe_ethertype_filter_handle(dev, filter_op, arg);
6404 case RTE_ETH_FILTER_SYN:
6405 ret = ixgbe_syn_filter_handle(dev, filter_op, arg);
6407 case RTE_ETH_FILTER_FDIR:
6408 ret = ixgbe_fdir_ctrl_func(dev, filter_op, arg);
6410 case RTE_ETH_FILTER_L2_TUNNEL:
6411 ret = ixgbe_dev_l2_tunnel_filter_handle(dev, filter_op, arg);
6413 case RTE_ETH_FILTER_GENERIC:
6414 if (filter_op != RTE_ETH_FILTER_GET)
6416 *(const void **)arg = &ixgbe_flow_ops;
6419 PMD_DRV_LOG(WARNING, "Filter type (%d) not supported",
6429 ixgbe_dev_addr_list_itr(__attribute__((unused)) struct ixgbe_hw *hw,
6430 u8 **mc_addr_ptr, u32 *vmdq)
6435 mc_addr = *mc_addr_ptr;
6436 *mc_addr_ptr = (mc_addr + sizeof(struct ether_addr));
6441 ixgbe_dev_set_mc_addr_list(struct rte_eth_dev *dev,
6442 struct ether_addr *mc_addr_set,
6443 uint32_t nb_mc_addr)
6445 struct ixgbe_hw *hw;
6448 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6449 mc_addr_list = (u8 *)mc_addr_set;
6450 return ixgbe_update_mc_addr_list(hw, mc_addr_list, nb_mc_addr,
6451 ixgbe_dev_addr_list_itr, TRUE);
6455 ixgbe_read_systime_cyclecounter(struct rte_eth_dev *dev)
6457 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6458 uint64_t systime_cycles;
6460 switch (hw->mac.type) {
6461 case ixgbe_mac_X550:
6462 case ixgbe_mac_X550EM_x:
6463 case ixgbe_mac_X550EM_a:
6464 /* SYSTIMEL stores ns and SYSTIMEH stores seconds. */
6465 systime_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_SYSTIML);
6466 systime_cycles += (uint64_t)IXGBE_READ_REG(hw, IXGBE_SYSTIMH)
6470 systime_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_SYSTIML);
6471 systime_cycles |= (uint64_t)IXGBE_READ_REG(hw, IXGBE_SYSTIMH)
6475 return systime_cycles;
6479 ixgbe_read_rx_tstamp_cyclecounter(struct rte_eth_dev *dev)
6481 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6482 uint64_t rx_tstamp_cycles;
6484 switch (hw->mac.type) {
6485 case ixgbe_mac_X550:
6486 case ixgbe_mac_X550EM_x:
6487 case ixgbe_mac_X550EM_a:
6488 /* RXSTMPL stores ns and RXSTMPH stores seconds. */
6489 rx_tstamp_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_RXSTMPL);
6490 rx_tstamp_cycles += (uint64_t)IXGBE_READ_REG(hw, IXGBE_RXSTMPH)
6494 /* RXSTMPL stores ns and RXSTMPH stores seconds. */
6495 rx_tstamp_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_RXSTMPL);
6496 rx_tstamp_cycles |= (uint64_t)IXGBE_READ_REG(hw, IXGBE_RXSTMPH)
6500 return rx_tstamp_cycles;
6504 ixgbe_read_tx_tstamp_cyclecounter(struct rte_eth_dev *dev)
6506 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6507 uint64_t tx_tstamp_cycles;
6509 switch (hw->mac.type) {
6510 case ixgbe_mac_X550:
6511 case ixgbe_mac_X550EM_x:
6512 case ixgbe_mac_X550EM_a:
6513 /* TXSTMPL stores ns and TXSTMPH stores seconds. */
6514 tx_tstamp_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_TXSTMPL);
6515 tx_tstamp_cycles += (uint64_t)IXGBE_READ_REG(hw, IXGBE_TXSTMPH)
6519 /* TXSTMPL stores ns and TXSTMPH stores seconds. */
6520 tx_tstamp_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_TXSTMPL);
6521 tx_tstamp_cycles |= (uint64_t)IXGBE_READ_REG(hw, IXGBE_TXSTMPH)
6525 return tx_tstamp_cycles;
6529 ixgbe_start_timecounters(struct rte_eth_dev *dev)
6531 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6532 struct ixgbe_adapter *adapter =
6533 (struct ixgbe_adapter *)dev->data->dev_private;
6534 struct rte_eth_link link;
6535 uint32_t incval = 0;
6538 /* Get current link speed. */
6539 memset(&link, 0, sizeof(link));
6540 ixgbe_dev_link_update(dev, 1);
6541 rte_ixgbe_dev_atomic_read_link_status(dev, &link);
6543 switch (link.link_speed) {
6544 case ETH_SPEED_NUM_100M:
6545 incval = IXGBE_INCVAL_100;
6546 shift = IXGBE_INCVAL_SHIFT_100;
6548 case ETH_SPEED_NUM_1G:
6549 incval = IXGBE_INCVAL_1GB;
6550 shift = IXGBE_INCVAL_SHIFT_1GB;
6552 case ETH_SPEED_NUM_10G:
6554 incval = IXGBE_INCVAL_10GB;
6555 shift = IXGBE_INCVAL_SHIFT_10GB;
6559 switch (hw->mac.type) {
6560 case ixgbe_mac_X550:
6561 case ixgbe_mac_X550EM_x:
6562 case ixgbe_mac_X550EM_a:
6563 /* Independent of link speed. */
6565 /* Cycles read will be interpreted as ns. */
6568 case ixgbe_mac_X540:
6569 IXGBE_WRITE_REG(hw, IXGBE_TIMINCA, incval);
6571 case ixgbe_mac_82599EB:
6572 incval >>= IXGBE_INCVAL_SHIFT_82599;
6573 shift -= IXGBE_INCVAL_SHIFT_82599;
6574 IXGBE_WRITE_REG(hw, IXGBE_TIMINCA,
6575 (1 << IXGBE_INCPER_SHIFT_82599) | incval);
6578 /* Not supported. */
6582 memset(&adapter->systime_tc, 0, sizeof(struct rte_timecounter));
6583 memset(&adapter->rx_tstamp_tc, 0, sizeof(struct rte_timecounter));
6584 memset(&adapter->tx_tstamp_tc, 0, sizeof(struct rte_timecounter));
6586 adapter->systime_tc.cc_mask = IXGBE_CYCLECOUNTER_MASK;
6587 adapter->systime_tc.cc_shift = shift;
6588 adapter->systime_tc.nsec_mask = (1ULL << shift) - 1;
6590 adapter->rx_tstamp_tc.cc_mask = IXGBE_CYCLECOUNTER_MASK;
6591 adapter->rx_tstamp_tc.cc_shift = shift;
6592 adapter->rx_tstamp_tc.nsec_mask = (1ULL << shift) - 1;
6594 adapter->tx_tstamp_tc.cc_mask = IXGBE_CYCLECOUNTER_MASK;
6595 adapter->tx_tstamp_tc.cc_shift = shift;
6596 adapter->tx_tstamp_tc.nsec_mask = (1ULL << shift) - 1;
6600 ixgbe_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta)
6602 struct ixgbe_adapter *adapter =
6603 (struct ixgbe_adapter *)dev->data->dev_private;
6605 adapter->systime_tc.nsec += delta;
6606 adapter->rx_tstamp_tc.nsec += delta;
6607 adapter->tx_tstamp_tc.nsec += delta;
6613 ixgbe_timesync_write_time(struct rte_eth_dev *dev, const struct timespec *ts)
6616 struct ixgbe_adapter *adapter =
6617 (struct ixgbe_adapter *)dev->data->dev_private;
6619 ns = rte_timespec_to_ns(ts);
6620 /* Set the timecounters to a new value. */
6621 adapter->systime_tc.nsec = ns;
6622 adapter->rx_tstamp_tc.nsec = ns;
6623 adapter->tx_tstamp_tc.nsec = ns;
6629 ixgbe_timesync_read_time(struct rte_eth_dev *dev, struct timespec *ts)
6631 uint64_t ns, systime_cycles;
6632 struct ixgbe_adapter *adapter =
6633 (struct ixgbe_adapter *)dev->data->dev_private;
6635 systime_cycles = ixgbe_read_systime_cyclecounter(dev);
6636 ns = rte_timecounter_update(&adapter->systime_tc, systime_cycles);
6637 *ts = rte_ns_to_timespec(ns);
6643 ixgbe_timesync_enable(struct rte_eth_dev *dev)
6645 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6649 /* Stop the timesync system time. */
6650 IXGBE_WRITE_REG(hw, IXGBE_TIMINCA, 0x0);
6651 /* Reset the timesync system time value. */
6652 IXGBE_WRITE_REG(hw, IXGBE_SYSTIML, 0x0);
6653 IXGBE_WRITE_REG(hw, IXGBE_SYSTIMH, 0x0);
6655 /* Enable system time for platforms where it isn't on by default. */
6656 tsauxc = IXGBE_READ_REG(hw, IXGBE_TSAUXC);
6657 tsauxc &= ~IXGBE_TSAUXC_DISABLE_SYSTIME;
6658 IXGBE_WRITE_REG(hw, IXGBE_TSAUXC, tsauxc);
6660 ixgbe_start_timecounters(dev);
6662 /* Enable L2 filtering of IEEE1588/802.1AS Ethernet frame types. */
6663 IXGBE_WRITE_REG(hw, IXGBE_ETQF(IXGBE_ETQF_FILTER_1588),
6665 IXGBE_ETQF_FILTER_EN |
6668 /* Enable timestamping of received PTP packets. */
6669 tsync_ctl = IXGBE_READ_REG(hw, IXGBE_TSYNCRXCTL);
6670 tsync_ctl |= IXGBE_TSYNCRXCTL_ENABLED;
6671 IXGBE_WRITE_REG(hw, IXGBE_TSYNCRXCTL, tsync_ctl);
6673 /* Enable timestamping of transmitted PTP packets. */
6674 tsync_ctl = IXGBE_READ_REG(hw, IXGBE_TSYNCTXCTL);
6675 tsync_ctl |= IXGBE_TSYNCTXCTL_ENABLED;
6676 IXGBE_WRITE_REG(hw, IXGBE_TSYNCTXCTL, tsync_ctl);
6678 IXGBE_WRITE_FLUSH(hw);
6684 ixgbe_timesync_disable(struct rte_eth_dev *dev)
6686 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6689 /* Disable timestamping of transmitted PTP packets. */
6690 tsync_ctl = IXGBE_READ_REG(hw, IXGBE_TSYNCTXCTL);
6691 tsync_ctl &= ~IXGBE_TSYNCTXCTL_ENABLED;
6692 IXGBE_WRITE_REG(hw, IXGBE_TSYNCTXCTL, tsync_ctl);
6694 /* Disable timestamping of received PTP packets. */
6695 tsync_ctl = IXGBE_READ_REG(hw, IXGBE_TSYNCRXCTL);
6696 tsync_ctl &= ~IXGBE_TSYNCRXCTL_ENABLED;
6697 IXGBE_WRITE_REG(hw, IXGBE_TSYNCRXCTL, tsync_ctl);
6699 /* Disable L2 filtering of IEEE1588/802.1AS Ethernet frame types. */
6700 IXGBE_WRITE_REG(hw, IXGBE_ETQF(IXGBE_ETQF_FILTER_1588), 0);
6702 /* Stop incrementating the System Time registers. */
6703 IXGBE_WRITE_REG(hw, IXGBE_TIMINCA, 0);
6709 ixgbe_timesync_read_rx_timestamp(struct rte_eth_dev *dev,
6710 struct timespec *timestamp,
6711 uint32_t flags __rte_unused)
6713 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6714 struct ixgbe_adapter *adapter =
6715 (struct ixgbe_adapter *)dev->data->dev_private;
6716 uint32_t tsync_rxctl;
6717 uint64_t rx_tstamp_cycles;
6720 tsync_rxctl = IXGBE_READ_REG(hw, IXGBE_TSYNCRXCTL);
6721 if ((tsync_rxctl & IXGBE_TSYNCRXCTL_VALID) == 0)
6724 rx_tstamp_cycles = ixgbe_read_rx_tstamp_cyclecounter(dev);
6725 ns = rte_timecounter_update(&adapter->rx_tstamp_tc, rx_tstamp_cycles);
6726 *timestamp = rte_ns_to_timespec(ns);
6732 ixgbe_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
6733 struct timespec *timestamp)
6735 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6736 struct ixgbe_adapter *adapter =
6737 (struct ixgbe_adapter *)dev->data->dev_private;
6738 uint32_t tsync_txctl;
6739 uint64_t tx_tstamp_cycles;
6742 tsync_txctl = IXGBE_READ_REG(hw, IXGBE_TSYNCTXCTL);
6743 if ((tsync_txctl & IXGBE_TSYNCTXCTL_VALID) == 0)
6746 tx_tstamp_cycles = ixgbe_read_tx_tstamp_cyclecounter(dev);
6747 ns = rte_timecounter_update(&adapter->tx_tstamp_tc, tx_tstamp_cycles);
6748 *timestamp = rte_ns_to_timespec(ns);
6754 ixgbe_get_reg_length(struct rte_eth_dev *dev)
6756 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6759 const struct reg_info *reg_group;
6760 const struct reg_info **reg_set = (hw->mac.type == ixgbe_mac_82598EB) ?
6761 ixgbe_regs_mac_82598EB : ixgbe_regs_others;
6763 while ((reg_group = reg_set[g_ind++]))
6764 count += ixgbe_regs_group_count(reg_group);
6770 ixgbevf_get_reg_length(struct rte_eth_dev *dev __rte_unused)
6774 const struct reg_info *reg_group;
6776 while ((reg_group = ixgbevf_regs[g_ind++]))
6777 count += ixgbe_regs_group_count(reg_group);
6783 ixgbe_get_regs(struct rte_eth_dev *dev,
6784 struct rte_dev_reg_info *regs)
6786 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6787 uint32_t *data = regs->data;
6790 const struct reg_info *reg_group;
6791 const struct reg_info **reg_set = (hw->mac.type == ixgbe_mac_82598EB) ?
6792 ixgbe_regs_mac_82598EB : ixgbe_regs_others;
6795 regs->length = ixgbe_get_reg_length(dev);
6796 regs->width = sizeof(uint32_t);
6800 /* Support only full register dump */
6801 if ((regs->length == 0) ||
6802 (regs->length == (uint32_t)ixgbe_get_reg_length(dev))) {
6803 regs->version = hw->mac.type << 24 | hw->revision_id << 16 |
6805 while ((reg_group = reg_set[g_ind++]))
6806 count += ixgbe_read_regs_group(dev, &data[count],
6815 ixgbevf_get_regs(struct rte_eth_dev *dev,
6816 struct rte_dev_reg_info *regs)
6818 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6819 uint32_t *data = regs->data;
6822 const struct reg_info *reg_group;
6825 regs->length = ixgbevf_get_reg_length(dev);
6826 regs->width = sizeof(uint32_t);
6830 /* Support only full register dump */
6831 if ((regs->length == 0) ||
6832 (regs->length == (uint32_t)ixgbevf_get_reg_length(dev))) {
6833 regs->version = hw->mac.type << 24 | hw->revision_id << 16 |
6835 while ((reg_group = ixgbevf_regs[g_ind++]))
6836 count += ixgbe_read_regs_group(dev, &data[count],
6845 ixgbe_get_eeprom_length(struct rte_eth_dev *dev)
6847 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6849 /* Return unit is byte count */
6850 return hw->eeprom.word_size * 2;
6854 ixgbe_get_eeprom(struct rte_eth_dev *dev,
6855 struct rte_dev_eeprom_info *in_eeprom)
6857 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6858 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
6859 uint16_t *data = in_eeprom->data;
6862 first = in_eeprom->offset >> 1;
6863 length = in_eeprom->length >> 1;
6864 if ((first > hw->eeprom.word_size) ||
6865 ((first + length) > hw->eeprom.word_size))
6868 in_eeprom->magic = hw->vendor_id | (hw->device_id << 16);
6870 return eeprom->ops.read_buffer(hw, first, length, data);
6874 ixgbe_set_eeprom(struct rte_eth_dev *dev,
6875 struct rte_dev_eeprom_info *in_eeprom)
6877 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6878 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
6879 uint16_t *data = in_eeprom->data;
6882 first = in_eeprom->offset >> 1;
6883 length = in_eeprom->length >> 1;
6884 if ((first > hw->eeprom.word_size) ||
6885 ((first + length) > hw->eeprom.word_size))
6888 in_eeprom->magic = hw->vendor_id | (hw->device_id << 16);
6890 return eeprom->ops.write_buffer(hw, first, length, data);
6894 ixgbe_reta_size_get(enum ixgbe_mac_type mac_type) {
6896 case ixgbe_mac_X550:
6897 case ixgbe_mac_X550EM_x:
6898 case ixgbe_mac_X550EM_a:
6899 return ETH_RSS_RETA_SIZE_512;
6900 case ixgbe_mac_X550_vf:
6901 case ixgbe_mac_X550EM_x_vf:
6902 case ixgbe_mac_X550EM_a_vf:
6903 return ETH_RSS_RETA_SIZE_64;
6905 return ETH_RSS_RETA_SIZE_128;
6910 ixgbe_reta_reg_get(enum ixgbe_mac_type mac_type, uint16_t reta_idx) {
6912 case ixgbe_mac_X550:
6913 case ixgbe_mac_X550EM_x:
6914 case ixgbe_mac_X550EM_a:
6915 if (reta_idx < ETH_RSS_RETA_SIZE_128)
6916 return IXGBE_RETA(reta_idx >> 2);
6918 return IXGBE_ERETA((reta_idx - ETH_RSS_RETA_SIZE_128) >> 2);
6919 case ixgbe_mac_X550_vf:
6920 case ixgbe_mac_X550EM_x_vf:
6921 case ixgbe_mac_X550EM_a_vf:
6922 return IXGBE_VFRETA(reta_idx >> 2);
6924 return IXGBE_RETA(reta_idx >> 2);
6929 ixgbe_mrqc_reg_get(enum ixgbe_mac_type mac_type) {
6931 case ixgbe_mac_X550_vf:
6932 case ixgbe_mac_X550EM_x_vf:
6933 case ixgbe_mac_X550EM_a_vf:
6934 return IXGBE_VFMRQC;
6941 ixgbe_rssrk_reg_get(enum ixgbe_mac_type mac_type, uint8_t i) {
6943 case ixgbe_mac_X550_vf:
6944 case ixgbe_mac_X550EM_x_vf:
6945 case ixgbe_mac_X550EM_a_vf:
6946 return IXGBE_VFRSSRK(i);
6948 return IXGBE_RSSRK(i);
6953 ixgbe_rss_update_sp(enum ixgbe_mac_type mac_type) {
6955 case ixgbe_mac_82599_vf:
6956 case ixgbe_mac_X540_vf:
6964 ixgbe_dev_get_dcb_info(struct rte_eth_dev *dev,
6965 struct rte_eth_dcb_info *dcb_info)
6967 struct ixgbe_dcb_config *dcb_config =
6968 IXGBE_DEV_PRIVATE_TO_DCB_CFG(dev->data->dev_private);
6969 struct ixgbe_dcb_tc_config *tc;
6972 if (dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_DCB_FLAG)
6973 dcb_info->nb_tcs = dcb_config->num_tcs.pg_tcs;
6975 dcb_info->nb_tcs = 1;
6977 if (dcb_config->vt_mode) { /* vt is enabled*/
6978 struct rte_eth_vmdq_dcb_conf *vmdq_rx_conf =
6979 &dev->data->dev_conf.rx_adv_conf.vmdq_dcb_conf;
6980 for (i = 0; i < ETH_DCB_NUM_USER_PRIORITIES; i++)
6981 dcb_info->prio_tc[i] = vmdq_rx_conf->dcb_tc[i];
6982 for (i = 0; i < vmdq_rx_conf->nb_queue_pools; i++) {
6983 for (j = 0; j < dcb_info->nb_tcs; j++) {
6984 dcb_info->tc_queue.tc_rxq[i][j].base =
6985 i * dcb_info->nb_tcs + j;
6986 dcb_info->tc_queue.tc_rxq[i][j].nb_queue = 1;
6987 dcb_info->tc_queue.tc_txq[i][j].base =
6988 i * dcb_info->nb_tcs + j;
6989 dcb_info->tc_queue.tc_txq[i][j].nb_queue = 1;
6992 } else { /* vt is disabled*/
6993 struct rte_eth_dcb_rx_conf *rx_conf =
6994 &dev->data->dev_conf.rx_adv_conf.dcb_rx_conf;
6995 for (i = 0; i < ETH_DCB_NUM_USER_PRIORITIES; i++)
6996 dcb_info->prio_tc[i] = rx_conf->dcb_tc[i];
6997 if (dcb_info->nb_tcs == ETH_4_TCS) {
6998 for (i = 0; i < dcb_info->nb_tcs; i++) {
6999 dcb_info->tc_queue.tc_rxq[0][i].base = i * 32;
7000 dcb_info->tc_queue.tc_rxq[0][i].nb_queue = 16;
7002 dcb_info->tc_queue.tc_txq[0][0].base = 0;
7003 dcb_info->tc_queue.tc_txq[0][1].base = 64;
7004 dcb_info->tc_queue.tc_txq[0][2].base = 96;
7005 dcb_info->tc_queue.tc_txq[0][3].base = 112;
7006 dcb_info->tc_queue.tc_txq[0][0].nb_queue = 64;
7007 dcb_info->tc_queue.tc_txq[0][1].nb_queue = 32;
7008 dcb_info->tc_queue.tc_txq[0][2].nb_queue = 16;
7009 dcb_info->tc_queue.tc_txq[0][3].nb_queue = 16;
7010 } else if (dcb_info->nb_tcs == ETH_8_TCS) {
7011 for (i = 0; i < dcb_info->nb_tcs; i++) {
7012 dcb_info->tc_queue.tc_rxq[0][i].base = i * 16;
7013 dcb_info->tc_queue.tc_rxq[0][i].nb_queue = 16;
7015 dcb_info->tc_queue.tc_txq[0][0].base = 0;
7016 dcb_info->tc_queue.tc_txq[0][1].base = 32;
7017 dcb_info->tc_queue.tc_txq[0][2].base = 64;
7018 dcb_info->tc_queue.tc_txq[0][3].base = 80;
7019 dcb_info->tc_queue.tc_txq[0][4].base = 96;
7020 dcb_info->tc_queue.tc_txq[0][5].base = 104;
7021 dcb_info->tc_queue.tc_txq[0][6].base = 112;
7022 dcb_info->tc_queue.tc_txq[0][7].base = 120;
7023 dcb_info->tc_queue.tc_txq[0][0].nb_queue = 32;
7024 dcb_info->tc_queue.tc_txq[0][1].nb_queue = 32;
7025 dcb_info->tc_queue.tc_txq[0][2].nb_queue = 16;
7026 dcb_info->tc_queue.tc_txq[0][3].nb_queue = 16;
7027 dcb_info->tc_queue.tc_txq[0][4].nb_queue = 8;
7028 dcb_info->tc_queue.tc_txq[0][5].nb_queue = 8;
7029 dcb_info->tc_queue.tc_txq[0][6].nb_queue = 8;
7030 dcb_info->tc_queue.tc_txq[0][7].nb_queue = 8;
7033 for (i = 0; i < dcb_info->nb_tcs; i++) {
7034 tc = &dcb_config->tc_config[i];
7035 dcb_info->tc_bws[i] = tc->path[IXGBE_DCB_TX_CONFIG].bwg_percent;
7040 /* Update e-tag ether type */
7042 ixgbe_update_e_tag_eth_type(struct ixgbe_hw *hw,
7043 uint16_t ether_type)
7045 uint32_t etag_etype;
7047 if (hw->mac.type != ixgbe_mac_X550 &&
7048 hw->mac.type != ixgbe_mac_X550EM_x &&
7049 hw->mac.type != ixgbe_mac_X550EM_a) {
7053 etag_etype = IXGBE_READ_REG(hw, IXGBE_ETAG_ETYPE);
7054 etag_etype &= ~IXGBE_ETAG_ETYPE_MASK;
7055 etag_etype |= ether_type;
7056 IXGBE_WRITE_REG(hw, IXGBE_ETAG_ETYPE, etag_etype);
7057 IXGBE_WRITE_FLUSH(hw);
7062 /* Config l2 tunnel ether type */
7064 ixgbe_dev_l2_tunnel_eth_type_conf(struct rte_eth_dev *dev,
7065 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7068 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7069 struct ixgbe_l2_tn_info *l2_tn_info =
7070 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
7072 if (l2_tunnel == NULL)
7075 switch (l2_tunnel->l2_tunnel_type) {
7076 case RTE_L2_TUNNEL_TYPE_E_TAG:
7077 l2_tn_info->e_tag_ether_type = l2_tunnel->ether_type;
7078 ret = ixgbe_update_e_tag_eth_type(hw, l2_tunnel->ether_type);
7081 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7089 /* Enable e-tag tunnel */
7091 ixgbe_e_tag_enable(struct ixgbe_hw *hw)
7093 uint32_t etag_etype;
7095 if (hw->mac.type != ixgbe_mac_X550 &&
7096 hw->mac.type != ixgbe_mac_X550EM_x &&
7097 hw->mac.type != ixgbe_mac_X550EM_a) {
7101 etag_etype = IXGBE_READ_REG(hw, IXGBE_ETAG_ETYPE);
7102 etag_etype |= IXGBE_ETAG_ETYPE_VALID;
7103 IXGBE_WRITE_REG(hw, IXGBE_ETAG_ETYPE, etag_etype);
7104 IXGBE_WRITE_FLUSH(hw);
7109 /* Enable l2 tunnel */
7111 ixgbe_dev_l2_tunnel_enable(struct rte_eth_dev *dev,
7112 enum rte_eth_tunnel_type l2_tunnel_type)
7115 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7116 struct ixgbe_l2_tn_info *l2_tn_info =
7117 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
7119 switch (l2_tunnel_type) {
7120 case RTE_L2_TUNNEL_TYPE_E_TAG:
7121 l2_tn_info->e_tag_en = TRUE;
7122 ret = ixgbe_e_tag_enable(hw);
7125 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7133 /* Disable e-tag tunnel */
7135 ixgbe_e_tag_disable(struct ixgbe_hw *hw)
7137 uint32_t etag_etype;
7139 if (hw->mac.type != ixgbe_mac_X550 &&
7140 hw->mac.type != ixgbe_mac_X550EM_x &&
7141 hw->mac.type != ixgbe_mac_X550EM_a) {
7145 etag_etype = IXGBE_READ_REG(hw, IXGBE_ETAG_ETYPE);
7146 etag_etype &= ~IXGBE_ETAG_ETYPE_VALID;
7147 IXGBE_WRITE_REG(hw, IXGBE_ETAG_ETYPE, etag_etype);
7148 IXGBE_WRITE_FLUSH(hw);
7153 /* Disable l2 tunnel */
7155 ixgbe_dev_l2_tunnel_disable(struct rte_eth_dev *dev,
7156 enum rte_eth_tunnel_type l2_tunnel_type)
7159 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7160 struct ixgbe_l2_tn_info *l2_tn_info =
7161 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
7163 switch (l2_tunnel_type) {
7164 case RTE_L2_TUNNEL_TYPE_E_TAG:
7165 l2_tn_info->e_tag_en = FALSE;
7166 ret = ixgbe_e_tag_disable(hw);
7169 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7178 ixgbe_e_tag_filter_del(struct rte_eth_dev *dev,
7179 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7182 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7183 uint32_t i, rar_entries;
7184 uint32_t rar_low, rar_high;
7186 if (hw->mac.type != ixgbe_mac_X550 &&
7187 hw->mac.type != ixgbe_mac_X550EM_x &&
7188 hw->mac.type != ixgbe_mac_X550EM_a) {
7192 rar_entries = ixgbe_get_num_rx_addrs(hw);
7194 for (i = 1; i < rar_entries; i++) {
7195 rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(i));
7196 rar_low = IXGBE_READ_REG(hw, IXGBE_RAL(i));
7197 if ((rar_high & IXGBE_RAH_AV) &&
7198 (rar_high & IXGBE_RAH_ADTYPE) &&
7199 ((rar_low & IXGBE_RAL_ETAG_FILTER_MASK) ==
7200 l2_tunnel->tunnel_id)) {
7201 IXGBE_WRITE_REG(hw, IXGBE_RAL(i), 0);
7202 IXGBE_WRITE_REG(hw, IXGBE_RAH(i), 0);
7204 ixgbe_clear_vmdq(hw, i, IXGBE_CLEAR_VMDQ_ALL);
7214 ixgbe_e_tag_filter_add(struct rte_eth_dev *dev,
7215 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7218 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7219 uint32_t i, rar_entries;
7220 uint32_t rar_low, rar_high;
7222 if (hw->mac.type != ixgbe_mac_X550 &&
7223 hw->mac.type != ixgbe_mac_X550EM_x &&
7224 hw->mac.type != ixgbe_mac_X550EM_a) {
7228 /* One entry for one tunnel. Try to remove potential existing entry. */
7229 ixgbe_e_tag_filter_del(dev, l2_tunnel);
7231 rar_entries = ixgbe_get_num_rx_addrs(hw);
7233 for (i = 1; i < rar_entries; i++) {
7234 rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(i));
7235 if (rar_high & IXGBE_RAH_AV) {
7238 ixgbe_set_vmdq(hw, i, l2_tunnel->pool);
7239 rar_high = IXGBE_RAH_AV | IXGBE_RAH_ADTYPE;
7240 rar_low = l2_tunnel->tunnel_id;
7242 IXGBE_WRITE_REG(hw, IXGBE_RAL(i), rar_low);
7243 IXGBE_WRITE_REG(hw, IXGBE_RAH(i), rar_high);
7249 PMD_INIT_LOG(NOTICE, "The table of E-tag forwarding rule is full."
7250 " Please remove a rule before adding a new one.");
7254 static inline struct ixgbe_l2_tn_filter *
7255 ixgbe_l2_tn_filter_lookup(struct ixgbe_l2_tn_info *l2_tn_info,
7256 struct ixgbe_l2_tn_key *key)
7260 ret = rte_hash_lookup(l2_tn_info->hash_handle, (const void *)key);
7264 return l2_tn_info->hash_map[ret];
7268 ixgbe_insert_l2_tn_filter(struct ixgbe_l2_tn_info *l2_tn_info,
7269 struct ixgbe_l2_tn_filter *l2_tn_filter)
7273 ret = rte_hash_add_key(l2_tn_info->hash_handle,
7274 &l2_tn_filter->key);
7278 "Failed to insert L2 tunnel filter"
7279 " to hash table %d!",
7284 l2_tn_info->hash_map[ret] = l2_tn_filter;
7286 TAILQ_INSERT_TAIL(&l2_tn_info->l2_tn_list, l2_tn_filter, entries);
7292 ixgbe_remove_l2_tn_filter(struct ixgbe_l2_tn_info *l2_tn_info,
7293 struct ixgbe_l2_tn_key *key)
7296 struct ixgbe_l2_tn_filter *l2_tn_filter;
7298 ret = rte_hash_del_key(l2_tn_info->hash_handle, key);
7302 "No such L2 tunnel filter to delete %d!",
7307 l2_tn_filter = l2_tn_info->hash_map[ret];
7308 l2_tn_info->hash_map[ret] = NULL;
7310 TAILQ_REMOVE(&l2_tn_info->l2_tn_list, l2_tn_filter, entries);
7311 rte_free(l2_tn_filter);
7316 /* Add l2 tunnel filter */
7318 ixgbe_dev_l2_tunnel_filter_add(struct rte_eth_dev *dev,
7319 struct rte_eth_l2_tunnel_conf *l2_tunnel,
7323 struct ixgbe_l2_tn_info *l2_tn_info =
7324 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
7325 struct ixgbe_l2_tn_key key;
7326 struct ixgbe_l2_tn_filter *node;
7329 key.l2_tn_type = l2_tunnel->l2_tunnel_type;
7330 key.tn_id = l2_tunnel->tunnel_id;
7332 node = ixgbe_l2_tn_filter_lookup(l2_tn_info, &key);
7336 "The L2 tunnel filter already exists!");
7340 node = rte_zmalloc("ixgbe_l2_tn",
7341 sizeof(struct ixgbe_l2_tn_filter),
7346 (void)rte_memcpy(&node->key,
7348 sizeof(struct ixgbe_l2_tn_key));
7349 node->pool = l2_tunnel->pool;
7350 ret = ixgbe_insert_l2_tn_filter(l2_tn_info, node);
7357 switch (l2_tunnel->l2_tunnel_type) {
7358 case RTE_L2_TUNNEL_TYPE_E_TAG:
7359 ret = ixgbe_e_tag_filter_add(dev, l2_tunnel);
7362 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7367 if ((!restore) && (ret < 0))
7368 (void)ixgbe_remove_l2_tn_filter(l2_tn_info, &key);
7373 /* Delete l2 tunnel filter */
7375 ixgbe_dev_l2_tunnel_filter_del(struct rte_eth_dev *dev,
7376 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7379 struct ixgbe_l2_tn_info *l2_tn_info =
7380 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
7381 struct ixgbe_l2_tn_key key;
7383 key.l2_tn_type = l2_tunnel->l2_tunnel_type;
7384 key.tn_id = l2_tunnel->tunnel_id;
7385 ret = ixgbe_remove_l2_tn_filter(l2_tn_info, &key);
7389 switch (l2_tunnel->l2_tunnel_type) {
7390 case RTE_L2_TUNNEL_TYPE_E_TAG:
7391 ret = ixgbe_e_tag_filter_del(dev, l2_tunnel);
7394 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7403 * ixgbe_dev_l2_tunnel_filter_handle - Handle operations for l2 tunnel filter.
7404 * @dev: pointer to rte_eth_dev structure
7405 * @filter_op:operation will be taken.
7406 * @arg: a pointer to specific structure corresponding to the filter_op
7409 ixgbe_dev_l2_tunnel_filter_handle(struct rte_eth_dev *dev,
7410 enum rte_filter_op filter_op,
7415 if (filter_op == RTE_ETH_FILTER_NOP)
7419 PMD_DRV_LOG(ERR, "arg shouldn't be NULL for operation %u.",
7424 switch (filter_op) {
7425 case RTE_ETH_FILTER_ADD:
7426 ret = ixgbe_dev_l2_tunnel_filter_add
7428 (struct rte_eth_l2_tunnel_conf *)arg,
7431 case RTE_ETH_FILTER_DELETE:
7432 ret = ixgbe_dev_l2_tunnel_filter_del
7434 (struct rte_eth_l2_tunnel_conf *)arg);
7437 PMD_DRV_LOG(ERR, "unsupported operation %u.", filter_op);
7445 ixgbe_e_tag_forwarding_en_dis(struct rte_eth_dev *dev, bool en)
7449 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7451 if (hw->mac.type != ixgbe_mac_X550 &&
7452 hw->mac.type != ixgbe_mac_X550EM_x &&
7453 hw->mac.type != ixgbe_mac_X550EM_a) {
7457 ctrl = IXGBE_READ_REG(hw, IXGBE_VT_CTL);
7458 ctrl &= ~IXGBE_VT_CTL_POOLING_MODE_MASK;
7460 ctrl |= IXGBE_VT_CTL_POOLING_MODE_ETAG;
7461 IXGBE_WRITE_REG(hw, IXGBE_VT_CTL, ctrl);
7466 /* Enable l2 tunnel forwarding */
7468 ixgbe_dev_l2_tunnel_forwarding_enable
7469 (struct rte_eth_dev *dev,
7470 enum rte_eth_tunnel_type l2_tunnel_type)
7472 struct ixgbe_l2_tn_info *l2_tn_info =
7473 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
7476 switch (l2_tunnel_type) {
7477 case RTE_L2_TUNNEL_TYPE_E_TAG:
7478 l2_tn_info->e_tag_fwd_en = TRUE;
7479 ret = ixgbe_e_tag_forwarding_en_dis(dev, 1);
7482 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7490 /* Disable l2 tunnel forwarding */
7492 ixgbe_dev_l2_tunnel_forwarding_disable
7493 (struct rte_eth_dev *dev,
7494 enum rte_eth_tunnel_type l2_tunnel_type)
7496 struct ixgbe_l2_tn_info *l2_tn_info =
7497 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
7500 switch (l2_tunnel_type) {
7501 case RTE_L2_TUNNEL_TYPE_E_TAG:
7502 l2_tn_info->e_tag_fwd_en = FALSE;
7503 ret = ixgbe_e_tag_forwarding_en_dis(dev, 0);
7506 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7515 ixgbe_e_tag_insertion_en_dis(struct rte_eth_dev *dev,
7516 struct rte_eth_l2_tunnel_conf *l2_tunnel,
7519 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
7521 uint32_t vmtir, vmvir;
7522 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7524 if (l2_tunnel->vf_id >= pci_dev->max_vfs) {
7526 "VF id %u should be less than %u",
7532 if (hw->mac.type != ixgbe_mac_X550 &&
7533 hw->mac.type != ixgbe_mac_X550EM_x &&
7534 hw->mac.type != ixgbe_mac_X550EM_a) {
7539 vmtir = l2_tunnel->tunnel_id;
7543 IXGBE_WRITE_REG(hw, IXGBE_VMTIR(l2_tunnel->vf_id), vmtir);
7545 vmvir = IXGBE_READ_REG(hw, IXGBE_VMVIR(l2_tunnel->vf_id));
7546 vmvir &= ~IXGBE_VMVIR_TAGA_MASK;
7548 vmvir |= IXGBE_VMVIR_TAGA_ETAG_INSERT;
7549 IXGBE_WRITE_REG(hw, IXGBE_VMVIR(l2_tunnel->vf_id), vmvir);
7554 /* Enable l2 tunnel tag insertion */
7556 ixgbe_dev_l2_tunnel_insertion_enable(struct rte_eth_dev *dev,
7557 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7561 switch (l2_tunnel->l2_tunnel_type) {
7562 case RTE_L2_TUNNEL_TYPE_E_TAG:
7563 ret = ixgbe_e_tag_insertion_en_dis(dev, l2_tunnel, 1);
7566 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7574 /* Disable l2 tunnel tag insertion */
7576 ixgbe_dev_l2_tunnel_insertion_disable
7577 (struct rte_eth_dev *dev,
7578 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7582 switch (l2_tunnel->l2_tunnel_type) {
7583 case RTE_L2_TUNNEL_TYPE_E_TAG:
7584 ret = ixgbe_e_tag_insertion_en_dis(dev, l2_tunnel, 0);
7587 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7596 ixgbe_e_tag_stripping_en_dis(struct rte_eth_dev *dev,
7601 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7603 if (hw->mac.type != ixgbe_mac_X550 &&
7604 hw->mac.type != ixgbe_mac_X550EM_x &&
7605 hw->mac.type != ixgbe_mac_X550EM_a) {
7609 qde = IXGBE_READ_REG(hw, IXGBE_QDE);
7611 qde |= IXGBE_QDE_STRIP_TAG;
7613 qde &= ~IXGBE_QDE_STRIP_TAG;
7614 qde &= ~IXGBE_QDE_READ;
7615 qde |= IXGBE_QDE_WRITE;
7616 IXGBE_WRITE_REG(hw, IXGBE_QDE, qde);
7621 /* Enable l2 tunnel tag stripping */
7623 ixgbe_dev_l2_tunnel_stripping_enable
7624 (struct rte_eth_dev *dev,
7625 enum rte_eth_tunnel_type l2_tunnel_type)
7629 switch (l2_tunnel_type) {
7630 case RTE_L2_TUNNEL_TYPE_E_TAG:
7631 ret = ixgbe_e_tag_stripping_en_dis(dev, 1);
7634 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7642 /* Disable l2 tunnel tag stripping */
7644 ixgbe_dev_l2_tunnel_stripping_disable
7645 (struct rte_eth_dev *dev,
7646 enum rte_eth_tunnel_type l2_tunnel_type)
7650 switch (l2_tunnel_type) {
7651 case RTE_L2_TUNNEL_TYPE_E_TAG:
7652 ret = ixgbe_e_tag_stripping_en_dis(dev, 0);
7655 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7663 /* Enable/disable l2 tunnel offload functions */
7665 ixgbe_dev_l2_tunnel_offload_set
7666 (struct rte_eth_dev *dev,
7667 struct rte_eth_l2_tunnel_conf *l2_tunnel,
7673 if (l2_tunnel == NULL)
7677 if (mask & ETH_L2_TUNNEL_ENABLE_MASK) {
7679 ret = ixgbe_dev_l2_tunnel_enable(
7681 l2_tunnel->l2_tunnel_type);
7683 ret = ixgbe_dev_l2_tunnel_disable(
7685 l2_tunnel->l2_tunnel_type);
7688 if (mask & ETH_L2_TUNNEL_INSERTION_MASK) {
7690 ret = ixgbe_dev_l2_tunnel_insertion_enable(
7694 ret = ixgbe_dev_l2_tunnel_insertion_disable(
7699 if (mask & ETH_L2_TUNNEL_STRIPPING_MASK) {
7701 ret = ixgbe_dev_l2_tunnel_stripping_enable(
7703 l2_tunnel->l2_tunnel_type);
7705 ret = ixgbe_dev_l2_tunnel_stripping_disable(
7707 l2_tunnel->l2_tunnel_type);
7710 if (mask & ETH_L2_TUNNEL_FORWARDING_MASK) {
7712 ret = ixgbe_dev_l2_tunnel_forwarding_enable(
7714 l2_tunnel->l2_tunnel_type);
7716 ret = ixgbe_dev_l2_tunnel_forwarding_disable(
7718 l2_tunnel->l2_tunnel_type);
7725 ixgbe_update_vxlan_port(struct ixgbe_hw *hw,
7728 IXGBE_WRITE_REG(hw, IXGBE_VXLANCTRL, port);
7729 IXGBE_WRITE_FLUSH(hw);
7734 /* There's only one register for VxLAN UDP port.
7735 * So, we cannot add several ports. Will update it.
7738 ixgbe_add_vxlan_port(struct ixgbe_hw *hw,
7742 PMD_DRV_LOG(ERR, "Add VxLAN port 0 is not allowed.");
7746 return ixgbe_update_vxlan_port(hw, port);
7749 /* We cannot delete the VxLAN port. For there's a register for VxLAN
7750 * UDP port, it must have a value.
7751 * So, will reset it to the original value 0.
7754 ixgbe_del_vxlan_port(struct ixgbe_hw *hw,
7759 cur_port = (uint16_t)IXGBE_READ_REG(hw, IXGBE_VXLANCTRL);
7761 if (cur_port != port) {
7762 PMD_DRV_LOG(ERR, "Port %u does not exist.", port);
7766 return ixgbe_update_vxlan_port(hw, 0);
7769 /* Add UDP tunneling port */
7771 ixgbe_dev_udp_tunnel_port_add(struct rte_eth_dev *dev,
7772 struct rte_eth_udp_tunnel *udp_tunnel)
7775 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7777 if (hw->mac.type != ixgbe_mac_X550 &&
7778 hw->mac.type != ixgbe_mac_X550EM_x &&
7779 hw->mac.type != ixgbe_mac_X550EM_a) {
7783 if (udp_tunnel == NULL)
7786 switch (udp_tunnel->prot_type) {
7787 case RTE_TUNNEL_TYPE_VXLAN:
7788 ret = ixgbe_add_vxlan_port(hw, udp_tunnel->udp_port);
7791 case RTE_TUNNEL_TYPE_GENEVE:
7792 case RTE_TUNNEL_TYPE_TEREDO:
7793 PMD_DRV_LOG(ERR, "Tunnel type is not supported now.");
7798 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7806 /* Remove UDP tunneling port */
7808 ixgbe_dev_udp_tunnel_port_del(struct rte_eth_dev *dev,
7809 struct rte_eth_udp_tunnel *udp_tunnel)
7812 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7814 if (hw->mac.type != ixgbe_mac_X550 &&
7815 hw->mac.type != ixgbe_mac_X550EM_x &&
7816 hw->mac.type != ixgbe_mac_X550EM_a) {
7820 if (udp_tunnel == NULL)
7823 switch (udp_tunnel->prot_type) {
7824 case RTE_TUNNEL_TYPE_VXLAN:
7825 ret = ixgbe_del_vxlan_port(hw, udp_tunnel->udp_port);
7827 case RTE_TUNNEL_TYPE_GENEVE:
7828 case RTE_TUNNEL_TYPE_TEREDO:
7829 PMD_DRV_LOG(ERR, "Tunnel type is not supported now.");
7833 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7842 ixgbevf_dev_allmulticast_enable(struct rte_eth_dev *dev)
7844 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7846 hw->mac.ops.update_xcast_mode(hw, IXGBEVF_XCAST_MODE_ALLMULTI);
7850 ixgbevf_dev_allmulticast_disable(struct rte_eth_dev *dev)
7852 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7854 hw->mac.ops.update_xcast_mode(hw, IXGBEVF_XCAST_MODE_NONE);
7857 static void ixgbevf_mbx_process(struct rte_eth_dev *dev)
7859 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7862 if (ixgbe_read_mbx(hw, &in_msg, 1, 0))
7865 /* PF reset VF event */
7866 if (in_msg == IXGBE_PF_CONTROL_MSG)
7867 _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RESET, NULL);
7871 ixgbevf_dev_interrupt_get_status(struct rte_eth_dev *dev)
7874 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7875 struct ixgbe_interrupt *intr =
7876 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
7877 ixgbevf_intr_disable(hw);
7879 /* read-on-clear nic registers here */
7880 eicr = IXGBE_READ_REG(hw, IXGBE_VTEICR);
7883 /* only one misc vector supported - mailbox */
7884 eicr &= IXGBE_VTEICR_MASK;
7885 if (eicr == IXGBE_MISC_VEC_ID)
7886 intr->flags |= IXGBE_FLAG_MAILBOX;
7892 ixgbevf_dev_interrupt_action(struct rte_eth_dev *dev)
7894 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7895 struct ixgbe_interrupt *intr =
7896 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
7898 if (intr->flags & IXGBE_FLAG_MAILBOX) {
7899 ixgbevf_mbx_process(dev);
7900 intr->flags &= ~IXGBE_FLAG_MAILBOX;
7903 ixgbevf_intr_enable(hw);
7909 ixgbevf_dev_interrupt_handler(void *param)
7911 struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
7913 ixgbevf_dev_interrupt_get_status(dev);
7914 ixgbevf_dev_interrupt_action(dev);
7918 * ixgbe_disable_sec_tx_path_generic - Stops the transmit data path
7919 * @hw: pointer to hardware structure
7921 * Stops the transmit data path and waits for the HW to internally empty
7922 * the Tx security block
7924 int ixgbe_disable_sec_tx_path_generic(struct ixgbe_hw *hw)
7926 #define IXGBE_MAX_SECTX_POLL 40
7931 sectxreg = IXGBE_READ_REG(hw, IXGBE_SECTXCTRL);
7932 sectxreg |= IXGBE_SECTXCTRL_TX_DIS;
7933 IXGBE_WRITE_REG(hw, IXGBE_SECTXCTRL, sectxreg);
7934 for (i = 0; i < IXGBE_MAX_SECTX_POLL; i++) {
7935 sectxreg = IXGBE_READ_REG(hw, IXGBE_SECTXSTAT);
7936 if (sectxreg & IXGBE_SECTXSTAT_SECTX_RDY)
7938 /* Use interrupt-safe sleep just in case */
7942 /* For informational purposes only */
7943 if (i >= IXGBE_MAX_SECTX_POLL)
7944 PMD_DRV_LOG(DEBUG, "Tx unit being enabled before security "
7945 "path fully disabled. Continuing with init.");
7947 return IXGBE_SUCCESS;
7951 * ixgbe_enable_sec_tx_path_generic - Enables the transmit data path
7952 * @hw: pointer to hardware structure
7954 * Enables the transmit data path.
7956 int ixgbe_enable_sec_tx_path_generic(struct ixgbe_hw *hw)
7960 sectxreg = IXGBE_READ_REG(hw, IXGBE_SECTXCTRL);
7961 sectxreg &= ~IXGBE_SECTXCTRL_TX_DIS;
7962 IXGBE_WRITE_REG(hw, IXGBE_SECTXCTRL, sectxreg);
7963 IXGBE_WRITE_FLUSH(hw);
7965 return IXGBE_SUCCESS;
7968 /* restore n-tuple filter */
7970 ixgbe_ntuple_filter_restore(struct rte_eth_dev *dev)
7972 struct ixgbe_filter_info *filter_info =
7973 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
7974 struct ixgbe_5tuple_filter *node;
7976 TAILQ_FOREACH(node, &filter_info->fivetuple_list, entries) {
7977 ixgbe_inject_5tuple_filter(dev, node);
7981 /* restore ethernet type filter */
7983 ixgbe_ethertype_filter_restore(struct rte_eth_dev *dev)
7985 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7986 struct ixgbe_filter_info *filter_info =
7987 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
7990 for (i = 0; i < IXGBE_MAX_ETQF_FILTERS; i++) {
7991 if (filter_info->ethertype_mask & (1 << i)) {
7992 IXGBE_WRITE_REG(hw, IXGBE_ETQF(i),
7993 filter_info->ethertype_filters[i].etqf);
7994 IXGBE_WRITE_REG(hw, IXGBE_ETQS(i),
7995 filter_info->ethertype_filters[i].etqs);
7996 IXGBE_WRITE_FLUSH(hw);
8001 /* restore SYN filter */
8003 ixgbe_syn_filter_restore(struct rte_eth_dev *dev)
8005 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8006 struct ixgbe_filter_info *filter_info =
8007 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
8010 synqf = filter_info->syn_info;
8012 if (synqf & IXGBE_SYN_FILTER_ENABLE) {
8013 IXGBE_WRITE_REG(hw, IXGBE_SYNQF, synqf);
8014 IXGBE_WRITE_FLUSH(hw);
8018 /* restore L2 tunnel filter */
8020 ixgbe_l2_tn_filter_restore(struct rte_eth_dev *dev)
8022 struct ixgbe_l2_tn_info *l2_tn_info =
8023 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
8024 struct ixgbe_l2_tn_filter *node;
8025 struct rte_eth_l2_tunnel_conf l2_tn_conf;
8027 TAILQ_FOREACH(node, &l2_tn_info->l2_tn_list, entries) {
8028 l2_tn_conf.l2_tunnel_type = node->key.l2_tn_type;
8029 l2_tn_conf.tunnel_id = node->key.tn_id;
8030 l2_tn_conf.pool = node->pool;
8031 (void)ixgbe_dev_l2_tunnel_filter_add(dev, &l2_tn_conf, TRUE);
8036 ixgbe_filter_restore(struct rte_eth_dev *dev)
8038 ixgbe_ntuple_filter_restore(dev);
8039 ixgbe_ethertype_filter_restore(dev);
8040 ixgbe_syn_filter_restore(dev);
8041 ixgbe_fdir_filter_restore(dev);
8042 ixgbe_l2_tn_filter_restore(dev);
8048 ixgbe_l2_tunnel_conf(struct rte_eth_dev *dev)
8050 struct ixgbe_l2_tn_info *l2_tn_info =
8051 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
8052 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8054 if (l2_tn_info->e_tag_en)
8055 (void)ixgbe_e_tag_enable(hw);
8057 if (l2_tn_info->e_tag_fwd_en)
8058 (void)ixgbe_e_tag_forwarding_en_dis(dev, 1);
8060 (void)ixgbe_update_e_tag_eth_type(hw, l2_tn_info->e_tag_ether_type);
8063 /* remove all the n-tuple filters */
8065 ixgbe_clear_all_ntuple_filter(struct rte_eth_dev *dev)
8067 struct ixgbe_filter_info *filter_info =
8068 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
8069 struct ixgbe_5tuple_filter *p_5tuple;
8071 while ((p_5tuple = TAILQ_FIRST(&filter_info->fivetuple_list)))
8072 ixgbe_remove_5tuple_filter(dev, p_5tuple);
8075 /* remove all the ether type filters */
8077 ixgbe_clear_all_ethertype_filter(struct rte_eth_dev *dev)
8079 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8080 struct ixgbe_filter_info *filter_info =
8081 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
8084 for (i = 0; i < IXGBE_MAX_ETQF_FILTERS; i++) {
8085 if (filter_info->ethertype_mask & (1 << i) &&
8086 !filter_info->ethertype_filters[i].conf) {
8087 (void)ixgbe_ethertype_filter_remove(filter_info,
8089 IXGBE_WRITE_REG(hw, IXGBE_ETQF(i), 0);
8090 IXGBE_WRITE_REG(hw, IXGBE_ETQS(i), 0);
8091 IXGBE_WRITE_FLUSH(hw);
8096 /* remove the SYN filter */
8098 ixgbe_clear_syn_filter(struct rte_eth_dev *dev)
8100 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8101 struct ixgbe_filter_info *filter_info =
8102 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
8104 if (filter_info->syn_info & IXGBE_SYN_FILTER_ENABLE) {
8105 filter_info->syn_info = 0;
8107 IXGBE_WRITE_REG(hw, IXGBE_SYNQF, 0);
8108 IXGBE_WRITE_FLUSH(hw);
8112 /* remove all the L2 tunnel filters */
8114 ixgbe_clear_all_l2_tn_filter(struct rte_eth_dev *dev)
8116 struct ixgbe_l2_tn_info *l2_tn_info =
8117 IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
8118 struct ixgbe_l2_tn_filter *l2_tn_filter;
8119 struct rte_eth_l2_tunnel_conf l2_tn_conf;
8122 while ((l2_tn_filter = TAILQ_FIRST(&l2_tn_info->l2_tn_list))) {
8123 l2_tn_conf.l2_tunnel_type = l2_tn_filter->key.l2_tn_type;
8124 l2_tn_conf.tunnel_id = l2_tn_filter->key.tn_id;
8125 l2_tn_conf.pool = l2_tn_filter->pool;
8126 ret = ixgbe_dev_l2_tunnel_filter_del(dev, &l2_tn_conf);
8134 RTE_PMD_REGISTER_PCI(net_ixgbe, rte_ixgbe_pmd);
8135 RTE_PMD_REGISTER_PCI_TABLE(net_ixgbe, pci_id_ixgbe_map);
8136 RTE_PMD_REGISTER_KMOD_DEP(net_ixgbe, "* igb_uio | uio_pci_generic | vfio");
8137 RTE_PMD_REGISTER_PCI(net_ixgbe_vf, rte_ixgbevf_pmd);
8138 RTE_PMD_REGISTER_PCI_TABLE(net_ixgbe_vf, pci_id_ixgbevf_map);
8139 RTE_PMD_REGISTER_KMOD_DEP(net_ixgbe_vf, "* igb_uio | vfio");