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_atomic.h>
60 #include <rte_malloc.h>
61 #include <rte_random.h>
63 #include <rte_hash_crc.h>
65 #include "ixgbe_logs.h"
66 #include "base/ixgbe_api.h"
67 #include "base/ixgbe_vf.h"
68 #include "base/ixgbe_common.h"
69 #include "ixgbe_ethdev.h"
70 #include "ixgbe_bypass.h"
71 #include "ixgbe_rxtx.h"
72 #include "base/ixgbe_type.h"
73 #include "base/ixgbe_phy.h"
74 #include "ixgbe_regs.h"
76 #include "rte_pmd_ixgbe.h"
79 * High threshold controlling when to start sending XOFF frames. Must be at
80 * least 8 bytes less than receive packet buffer size. This value is in units
83 #define IXGBE_FC_HI 0x80
86 * Low threshold controlling when to start sending XON frames. This value is
87 * in units of 1024 bytes.
89 #define IXGBE_FC_LO 0x40
91 /* Default minimum inter-interrupt interval for EITR configuration */
92 #define IXGBE_MIN_INTER_INTERRUPT_INTERVAL_DEFAULT 0x79E
94 /* Timer value included in XOFF frames. */
95 #define IXGBE_FC_PAUSE 0x680
97 #define IXGBE_LINK_DOWN_CHECK_TIMEOUT 4000 /* ms */
98 #define IXGBE_LINK_UP_CHECK_TIMEOUT 1000 /* ms */
99 #define IXGBE_VMDQ_NUM_UC_MAC 4096 /* Maximum nb. of UC MAC addr. */
101 #define IXGBE_MMW_SIZE_DEFAULT 0x4
102 #define IXGBE_MMW_SIZE_JUMBO_FRAME 0x14
103 #define IXGBE_MAX_RING_DESC 4096 /* replicate define from rxtx */
106 * Default values for RX/TX configuration
108 #define IXGBE_DEFAULT_RX_FREE_THRESH 32
109 #define IXGBE_DEFAULT_RX_PTHRESH 8
110 #define IXGBE_DEFAULT_RX_HTHRESH 8
111 #define IXGBE_DEFAULT_RX_WTHRESH 0
113 #define IXGBE_DEFAULT_TX_FREE_THRESH 32
114 #define IXGBE_DEFAULT_TX_PTHRESH 32
115 #define IXGBE_DEFAULT_TX_HTHRESH 0
116 #define IXGBE_DEFAULT_TX_WTHRESH 0
117 #define IXGBE_DEFAULT_TX_RSBIT_THRESH 32
119 /* Bit shift and mask */
120 #define IXGBE_4_BIT_WIDTH (CHAR_BIT / 2)
121 #define IXGBE_4_BIT_MASK RTE_LEN2MASK(IXGBE_4_BIT_WIDTH, uint8_t)
122 #define IXGBE_8_BIT_WIDTH CHAR_BIT
123 #define IXGBE_8_BIT_MASK UINT8_MAX
125 #define IXGBEVF_PMD_NAME "rte_ixgbevf_pmd" /* PMD name */
127 #define IXGBE_QUEUE_STAT_COUNTERS (sizeof(hw_stats->qprc) / sizeof(hw_stats->qprc[0]))
129 #define IXGBE_HKEY_MAX_INDEX 10
131 /* Additional timesync values. */
132 #define NSEC_PER_SEC 1000000000L
133 #define IXGBE_INCVAL_10GB 0x66666666
134 #define IXGBE_INCVAL_1GB 0x40000000
135 #define IXGBE_INCVAL_100 0x50000000
136 #define IXGBE_INCVAL_SHIFT_10GB 28
137 #define IXGBE_INCVAL_SHIFT_1GB 24
138 #define IXGBE_INCVAL_SHIFT_100 21
139 #define IXGBE_INCVAL_SHIFT_82599 7
140 #define IXGBE_INCPER_SHIFT_82599 24
142 #define IXGBE_CYCLECOUNTER_MASK 0xffffffffffffffffULL
144 #define IXGBE_VT_CTL_POOLING_MODE_MASK 0x00030000
145 #define IXGBE_VT_CTL_POOLING_MODE_ETAG 0x00010000
146 #define DEFAULT_ETAG_ETYPE 0x893f
147 #define IXGBE_ETAG_ETYPE 0x00005084
148 #define IXGBE_ETAG_ETYPE_MASK 0x0000ffff
149 #define IXGBE_ETAG_ETYPE_VALID 0x80000000
150 #define IXGBE_RAH_ADTYPE 0x40000000
151 #define IXGBE_RAL_ETAG_FILTER_MASK 0x00003fff
152 #define IXGBE_VMVIR_TAGA_MASK 0x18000000
153 #define IXGBE_VMVIR_TAGA_ETAG_INSERT 0x08000000
154 #define IXGBE_VMTIR(_i) (0x00017000 + ((_i) * 4)) /* 64 of these (0-63) */
155 #define IXGBE_QDE_STRIP_TAG 0x00000004
156 #define IXGBE_VTEICR_MASK 0x07
158 enum ixgbevf_xcast_modes {
159 IXGBEVF_XCAST_MODE_NONE = 0,
160 IXGBEVF_XCAST_MODE_MULTI,
161 IXGBEVF_XCAST_MODE_ALLMULTI,
164 #define IXGBE_EXVET_VET_EXT_SHIFT 16
165 #define IXGBE_DMATXCTL_VT_MASK 0xFFFF0000
167 static int eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev);
168 static int eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev);
169 static int ixgbe_fdir_filter_init(struct rte_eth_dev *eth_dev);
170 static int ixgbe_fdir_filter_uninit(struct rte_eth_dev *eth_dev);
171 static int ixgbe_dev_configure(struct rte_eth_dev *dev);
172 static int ixgbe_dev_start(struct rte_eth_dev *dev);
173 static void ixgbe_dev_stop(struct rte_eth_dev *dev);
174 static int ixgbe_dev_set_link_up(struct rte_eth_dev *dev);
175 static int ixgbe_dev_set_link_down(struct rte_eth_dev *dev);
176 static void ixgbe_dev_close(struct rte_eth_dev *dev);
177 static void ixgbe_dev_promiscuous_enable(struct rte_eth_dev *dev);
178 static void ixgbe_dev_promiscuous_disable(struct rte_eth_dev *dev);
179 static void ixgbe_dev_allmulticast_enable(struct rte_eth_dev *dev);
180 static void ixgbe_dev_allmulticast_disable(struct rte_eth_dev *dev);
181 static int ixgbe_dev_link_update(struct rte_eth_dev *dev,
182 int wait_to_complete);
183 static void ixgbe_dev_stats_get(struct rte_eth_dev *dev,
184 struct rte_eth_stats *stats);
185 static int ixgbe_dev_xstats_get(struct rte_eth_dev *dev,
186 struct rte_eth_xstat *xstats, unsigned n);
187 static int ixgbevf_dev_xstats_get(struct rte_eth_dev *dev,
188 struct rte_eth_xstat *xstats, unsigned n);
189 static void ixgbe_dev_stats_reset(struct rte_eth_dev *dev);
190 static void ixgbe_dev_xstats_reset(struct rte_eth_dev *dev);
191 static int ixgbe_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
192 struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned limit);
193 static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
194 struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned limit);
195 static int ixgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
199 static int ixgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
201 static void ixgbe_dev_info_get(struct rte_eth_dev *dev,
202 struct rte_eth_dev_info *dev_info);
203 static const uint32_t *ixgbe_dev_supported_ptypes_get(struct rte_eth_dev *dev);
204 static void ixgbevf_dev_info_get(struct rte_eth_dev *dev,
205 struct rte_eth_dev_info *dev_info);
206 static int ixgbe_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
208 static int ixgbe_vlan_filter_set(struct rte_eth_dev *dev,
209 uint16_t vlan_id, int on);
210 static int ixgbe_vlan_tpid_set(struct rte_eth_dev *dev,
211 enum rte_vlan_type vlan_type,
213 static void ixgbe_vlan_hw_strip_bitmap_set(struct rte_eth_dev *dev,
214 uint16_t queue, bool on);
215 static void ixgbe_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue,
217 static void ixgbe_vlan_offload_set(struct rte_eth_dev *dev, int mask);
218 static void ixgbe_vlan_hw_strip_enable(struct rte_eth_dev *dev, uint16_t queue);
219 static void ixgbe_vlan_hw_strip_disable(struct rte_eth_dev *dev, uint16_t queue);
220 static void ixgbe_vlan_hw_extend_enable(struct rte_eth_dev *dev);
221 static void ixgbe_vlan_hw_extend_disable(struct rte_eth_dev *dev);
223 static int ixgbe_dev_led_on(struct rte_eth_dev *dev);
224 static int ixgbe_dev_led_off(struct rte_eth_dev *dev);
225 static int ixgbe_flow_ctrl_get(struct rte_eth_dev *dev,
226 struct rte_eth_fc_conf *fc_conf);
227 static int ixgbe_flow_ctrl_set(struct rte_eth_dev *dev,
228 struct rte_eth_fc_conf *fc_conf);
229 static int ixgbe_priority_flow_ctrl_set(struct rte_eth_dev *dev,
230 struct rte_eth_pfc_conf *pfc_conf);
231 static int ixgbe_dev_rss_reta_update(struct rte_eth_dev *dev,
232 struct rte_eth_rss_reta_entry64 *reta_conf,
234 static int ixgbe_dev_rss_reta_query(struct rte_eth_dev *dev,
235 struct rte_eth_rss_reta_entry64 *reta_conf,
237 static void ixgbe_dev_link_status_print(struct rte_eth_dev *dev);
238 static int ixgbe_dev_lsc_interrupt_setup(struct rte_eth_dev *dev);
239 static int ixgbe_dev_macsec_interrupt_setup(struct rte_eth_dev *dev);
240 static int ixgbe_dev_rxq_interrupt_setup(struct rte_eth_dev *dev);
241 static int ixgbe_dev_interrupt_get_status(struct rte_eth_dev *dev);
242 static int ixgbe_dev_interrupt_action(struct rte_eth_dev *dev,
243 struct rte_intr_handle *handle);
244 static void ixgbe_dev_interrupt_handler(struct rte_intr_handle *handle,
246 static void ixgbe_dev_interrupt_delayed_handler(void *param);
247 static void ixgbe_add_rar(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
248 uint32_t index, uint32_t pool);
249 static void ixgbe_remove_rar(struct rte_eth_dev *dev, uint32_t index);
250 static void ixgbe_set_default_mac_addr(struct rte_eth_dev *dev,
251 struct ether_addr *mac_addr);
252 static void ixgbe_dcb_init(struct ixgbe_hw *hw, struct ixgbe_dcb_config *dcb_config);
253 static int is_ixgbe_pmd(const char *driver_name);
255 /* For Virtual Function support */
256 static int eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev);
257 static int eth_ixgbevf_dev_uninit(struct rte_eth_dev *eth_dev);
258 static int ixgbevf_dev_configure(struct rte_eth_dev *dev);
259 static int ixgbevf_dev_start(struct rte_eth_dev *dev);
260 static void ixgbevf_dev_stop(struct rte_eth_dev *dev);
261 static void ixgbevf_dev_close(struct rte_eth_dev *dev);
262 static void ixgbevf_intr_disable(struct ixgbe_hw *hw);
263 static void ixgbevf_intr_enable(struct ixgbe_hw *hw);
264 static void ixgbevf_dev_stats_get(struct rte_eth_dev *dev,
265 struct rte_eth_stats *stats);
266 static void ixgbevf_dev_stats_reset(struct rte_eth_dev *dev);
267 static int ixgbevf_vlan_filter_set(struct rte_eth_dev *dev,
268 uint16_t vlan_id, int on);
269 static void ixgbevf_vlan_strip_queue_set(struct rte_eth_dev *dev,
270 uint16_t queue, int on);
271 static void ixgbevf_vlan_offload_set(struct rte_eth_dev *dev, int mask);
272 static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on);
273 static int ixgbevf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev,
275 static int ixgbevf_dev_rx_queue_intr_disable(struct rte_eth_dev *dev,
277 static void ixgbevf_set_ivar_map(struct ixgbe_hw *hw, int8_t direction,
278 uint8_t queue, uint8_t msix_vector);
279 static void ixgbevf_configure_msix(struct rte_eth_dev *dev);
280 static void ixgbevf_dev_allmulticast_enable(struct rte_eth_dev *dev);
281 static void ixgbevf_dev_allmulticast_disable(struct rte_eth_dev *dev);
283 /* For Eth VMDQ APIs support */
284 static int ixgbe_uc_hash_table_set(struct rte_eth_dev *dev, struct
285 ether_addr * mac_addr, uint8_t on);
286 static int ixgbe_uc_all_hash_table_set(struct rte_eth_dev *dev, uint8_t on);
287 static int ixgbe_mirror_rule_set(struct rte_eth_dev *dev,
288 struct rte_eth_mirror_conf *mirror_conf,
289 uint8_t rule_id, uint8_t on);
290 static int ixgbe_mirror_rule_reset(struct rte_eth_dev *dev,
292 static int ixgbe_dev_rx_queue_intr_enable(struct rte_eth_dev *dev,
294 static int ixgbe_dev_rx_queue_intr_disable(struct rte_eth_dev *dev,
296 static void ixgbe_set_ivar_map(struct ixgbe_hw *hw, int8_t direction,
297 uint8_t queue, uint8_t msix_vector);
298 static void ixgbe_configure_msix(struct rte_eth_dev *dev);
300 static int ixgbe_set_queue_rate_limit(struct rte_eth_dev *dev,
301 uint16_t queue_idx, uint16_t tx_rate);
303 static void ixgbevf_add_mac_addr(struct rte_eth_dev *dev,
304 struct ether_addr *mac_addr,
305 uint32_t index, uint32_t pool);
306 static void ixgbevf_remove_mac_addr(struct rte_eth_dev *dev, uint32_t index);
307 static void ixgbevf_set_default_mac_addr(struct rte_eth_dev *dev,
308 struct ether_addr *mac_addr);
309 static int ixgbe_syn_filter_set(struct rte_eth_dev *dev,
310 struct rte_eth_syn_filter *filter,
312 static int ixgbe_syn_filter_get(struct rte_eth_dev *dev,
313 struct rte_eth_syn_filter *filter);
314 static int ixgbe_syn_filter_handle(struct rte_eth_dev *dev,
315 enum rte_filter_op filter_op,
317 static int ixgbe_add_5tuple_filter(struct rte_eth_dev *dev,
318 struct ixgbe_5tuple_filter *filter);
319 static void ixgbe_remove_5tuple_filter(struct rte_eth_dev *dev,
320 struct ixgbe_5tuple_filter *filter);
321 static int ixgbe_add_del_ntuple_filter(struct rte_eth_dev *dev,
322 struct rte_eth_ntuple_filter *filter,
324 static int ixgbe_ntuple_filter_handle(struct rte_eth_dev *dev,
325 enum rte_filter_op filter_op,
327 static int ixgbe_get_ntuple_filter(struct rte_eth_dev *dev,
328 struct rte_eth_ntuple_filter *filter);
329 static int ixgbe_add_del_ethertype_filter(struct rte_eth_dev *dev,
330 struct rte_eth_ethertype_filter *filter,
332 static int ixgbe_ethertype_filter_handle(struct rte_eth_dev *dev,
333 enum rte_filter_op filter_op,
335 static int ixgbe_get_ethertype_filter(struct rte_eth_dev *dev,
336 struct rte_eth_ethertype_filter *filter);
337 static int ixgbe_dev_filter_ctrl(struct rte_eth_dev *dev,
338 enum rte_filter_type filter_type,
339 enum rte_filter_op filter_op,
341 static int ixgbevf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu);
343 static int ixgbe_dev_set_mc_addr_list(struct rte_eth_dev *dev,
344 struct ether_addr *mc_addr_set,
345 uint32_t nb_mc_addr);
346 static int ixgbe_dev_get_dcb_info(struct rte_eth_dev *dev,
347 struct rte_eth_dcb_info *dcb_info);
349 static int ixgbe_get_reg_length(struct rte_eth_dev *dev);
350 static int ixgbe_get_regs(struct rte_eth_dev *dev,
351 struct rte_dev_reg_info *regs);
352 static int ixgbe_get_eeprom_length(struct rte_eth_dev *dev);
353 static int ixgbe_get_eeprom(struct rte_eth_dev *dev,
354 struct rte_dev_eeprom_info *eeprom);
355 static int ixgbe_set_eeprom(struct rte_eth_dev *dev,
356 struct rte_dev_eeprom_info *eeprom);
358 static int ixgbevf_get_reg_length(struct rte_eth_dev *dev);
359 static int ixgbevf_get_regs(struct rte_eth_dev *dev,
360 struct rte_dev_reg_info *regs);
362 static int ixgbe_timesync_enable(struct rte_eth_dev *dev);
363 static int ixgbe_timesync_disable(struct rte_eth_dev *dev);
364 static int ixgbe_timesync_read_rx_timestamp(struct rte_eth_dev *dev,
365 struct timespec *timestamp,
367 static int ixgbe_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
368 struct timespec *timestamp);
369 static int ixgbe_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta);
370 static int ixgbe_timesync_read_time(struct rte_eth_dev *dev,
371 struct timespec *timestamp);
372 static int ixgbe_timesync_write_time(struct rte_eth_dev *dev,
373 const struct timespec *timestamp);
374 static void ixgbevf_dev_interrupt_handler(struct rte_intr_handle *handle,
377 static int ixgbe_dev_l2_tunnel_eth_type_conf
378 (struct rte_eth_dev *dev, struct rte_eth_l2_tunnel_conf *l2_tunnel);
379 static int ixgbe_dev_l2_tunnel_offload_set
380 (struct rte_eth_dev *dev,
381 struct rte_eth_l2_tunnel_conf *l2_tunnel,
384 static int ixgbe_dev_l2_tunnel_filter_handle(struct rte_eth_dev *dev,
385 enum rte_filter_op filter_op,
388 static int ixgbe_dev_udp_tunnel_port_add(struct rte_eth_dev *dev,
389 struct rte_eth_udp_tunnel *udp_tunnel);
390 static int ixgbe_dev_udp_tunnel_port_del(struct rte_eth_dev *dev,
391 struct rte_eth_udp_tunnel *udp_tunnel);
394 * Define VF Stats MACRO for Non "cleared on read" register
396 #define UPDATE_VF_STAT(reg, last, cur) \
398 uint32_t latest = IXGBE_READ_REG(hw, reg); \
399 cur += (latest - last) & UINT_MAX; \
403 #define UPDATE_VF_STAT_36BIT(lsb, msb, last, cur) \
405 u64 new_lsb = IXGBE_READ_REG(hw, lsb); \
406 u64 new_msb = IXGBE_READ_REG(hw, msb); \
407 u64 latest = ((new_msb << 32) | new_lsb); \
408 cur += (0x1000000000LL + latest - last) & 0xFFFFFFFFFLL; \
412 #define IXGBE_SET_HWSTRIP(h, q) do {\
413 uint32_t idx = (q) / (sizeof((h)->bitmap[0]) * NBBY); \
414 uint32_t bit = (q) % (sizeof((h)->bitmap[0]) * NBBY); \
415 (h)->bitmap[idx] |= 1 << bit;\
418 #define IXGBE_CLEAR_HWSTRIP(h, q) do {\
419 uint32_t idx = (q) / (sizeof((h)->bitmap[0]) * NBBY); \
420 uint32_t bit = (q) % (sizeof((h)->bitmap[0]) * NBBY); \
421 (h)->bitmap[idx] &= ~(1 << bit);\
424 #define IXGBE_GET_HWSTRIP(h, q, r) do {\
425 uint32_t idx = (q) / (sizeof((h)->bitmap[0]) * NBBY); \
426 uint32_t bit = (q) % (sizeof((h)->bitmap[0]) * NBBY); \
427 (r) = (h)->bitmap[idx] >> bit & 1;\
431 * The set of PCI devices this driver supports
433 static const struct rte_pci_id pci_id_ixgbe_map[] = {
434 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598) },
435 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598_BX) },
436 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AF_DUAL_PORT) },
437 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AF_SINGLE_PORT) },
438 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AT) },
439 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AT2) },
440 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598EB_SFP_LOM) },
441 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598EB_CX4) },
442 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598_CX4_DUAL_PORT) },
443 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598_DA_DUAL_PORT) },
444 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM) },
445 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598EB_XF_LR) },
446 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_KX4) },
447 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_KX4_MEZZ) },
448 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_KR) },
449 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_COMBO_BACKPLANE) },
450 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_SUBDEV_ID_82599_KX4_KR_MEZZ) },
451 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_CX4) },
452 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP) },
453 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_SUBDEV_ID_82599_SFP) },
454 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_SUBDEV_ID_82599_RNDC) },
455 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_SUBDEV_ID_82599_560FLR) },
456 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_SUBDEV_ID_82599_ECNA_DP) },
457 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_BACKPLANE_FCOE) },
458 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP_FCOE) },
459 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP_EM) },
460 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP_SF2) },
461 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP_SF_QP) },
462 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_QSFP_SF_QP) },
463 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599EN_SFP) },
464 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_XAUI_LOM) },
465 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_T3_LOM) },
466 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_LS) },
467 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X540T) },
468 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X540T1) },
469 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_SFP) },
470 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_10G_T) },
471 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_1G_T) },
472 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550T) },
473 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550T1) },
474 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_KR) },
475 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_KR_L) },
476 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_SFP_N) },
477 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_SGMII) },
478 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_SGMII_L) },
479 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_10G_T) },
480 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_QSFP) },
481 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_QSFP_N) },
482 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_SFP) },
483 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_1G_T) },
484 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_1G_T_L) },
485 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_KX4) },
486 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_KR) },
487 #ifdef RTE_NIC_BYPASS
488 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_BYPASS) },
490 { .vendor_id = 0, /* sentinel */ },
494 * The set of PCI devices this driver supports (for 82599 VF)
496 static const struct rte_pci_id pci_id_ixgbevf_map[] = {
497 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_VF) },
498 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_VF_HV) },
499 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X540_VF) },
500 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X540_VF_HV) },
501 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550_VF_HV) },
502 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550_VF) },
503 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_VF) },
504 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_VF_HV) },
505 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_VF) },
506 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_VF_HV) },
507 { .vendor_id = 0, /* sentinel */ },
510 static const struct rte_eth_desc_lim rx_desc_lim = {
511 .nb_max = IXGBE_MAX_RING_DESC,
512 .nb_min = IXGBE_MIN_RING_DESC,
513 .nb_align = IXGBE_RXD_ALIGN,
516 static const struct rte_eth_desc_lim tx_desc_lim = {
517 .nb_max = IXGBE_MAX_RING_DESC,
518 .nb_min = IXGBE_MIN_RING_DESC,
519 .nb_align = IXGBE_TXD_ALIGN,
520 .nb_seg_max = IXGBE_TX_MAX_SEG,
521 .nb_mtu_seg_max = IXGBE_TX_MAX_SEG,
524 static const struct eth_dev_ops ixgbe_eth_dev_ops = {
525 .dev_configure = ixgbe_dev_configure,
526 .dev_start = ixgbe_dev_start,
527 .dev_stop = ixgbe_dev_stop,
528 .dev_set_link_up = ixgbe_dev_set_link_up,
529 .dev_set_link_down = ixgbe_dev_set_link_down,
530 .dev_close = ixgbe_dev_close,
531 .promiscuous_enable = ixgbe_dev_promiscuous_enable,
532 .promiscuous_disable = ixgbe_dev_promiscuous_disable,
533 .allmulticast_enable = ixgbe_dev_allmulticast_enable,
534 .allmulticast_disable = ixgbe_dev_allmulticast_disable,
535 .link_update = ixgbe_dev_link_update,
536 .stats_get = ixgbe_dev_stats_get,
537 .xstats_get = ixgbe_dev_xstats_get,
538 .stats_reset = ixgbe_dev_stats_reset,
539 .xstats_reset = ixgbe_dev_xstats_reset,
540 .xstats_get_names = ixgbe_dev_xstats_get_names,
541 .queue_stats_mapping_set = ixgbe_dev_queue_stats_mapping_set,
542 .fw_version_get = ixgbe_fw_version_get,
543 .dev_infos_get = ixgbe_dev_info_get,
544 .dev_supported_ptypes_get = ixgbe_dev_supported_ptypes_get,
545 .mtu_set = ixgbe_dev_mtu_set,
546 .vlan_filter_set = ixgbe_vlan_filter_set,
547 .vlan_tpid_set = ixgbe_vlan_tpid_set,
548 .vlan_offload_set = ixgbe_vlan_offload_set,
549 .vlan_strip_queue_set = ixgbe_vlan_strip_queue_set,
550 .rx_queue_start = ixgbe_dev_rx_queue_start,
551 .rx_queue_stop = ixgbe_dev_rx_queue_stop,
552 .tx_queue_start = ixgbe_dev_tx_queue_start,
553 .tx_queue_stop = ixgbe_dev_tx_queue_stop,
554 .rx_queue_setup = ixgbe_dev_rx_queue_setup,
555 .rx_queue_intr_enable = ixgbe_dev_rx_queue_intr_enable,
556 .rx_queue_intr_disable = ixgbe_dev_rx_queue_intr_disable,
557 .rx_queue_release = ixgbe_dev_rx_queue_release,
558 .rx_queue_count = ixgbe_dev_rx_queue_count,
559 .rx_descriptor_done = ixgbe_dev_rx_descriptor_done,
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 .tx_queue_setup = ixgbe_dev_tx_queue_setup,
639 .tx_queue_release = ixgbe_dev_tx_queue_release,
640 .rx_queue_intr_enable = ixgbevf_dev_rx_queue_intr_enable,
641 .rx_queue_intr_disable = ixgbevf_dev_rx_queue_intr_disable,
642 .mac_addr_add = ixgbevf_add_mac_addr,
643 .mac_addr_remove = ixgbevf_remove_mac_addr,
644 .set_mc_addr_list = ixgbe_dev_set_mc_addr_list,
645 .rxq_info_get = ixgbe_rxq_info_get,
646 .txq_info_get = ixgbe_txq_info_get,
647 .mac_addr_set = ixgbevf_set_default_mac_addr,
648 .get_reg = ixgbevf_get_regs,
649 .reta_update = ixgbe_dev_rss_reta_update,
650 .reta_query = ixgbe_dev_rss_reta_query,
651 .rss_hash_update = ixgbe_dev_rss_hash_update,
652 .rss_hash_conf_get = ixgbe_dev_rss_hash_conf_get,
655 /* store statistics names and its offset in stats structure */
656 struct rte_ixgbe_xstats_name_off {
657 char name[RTE_ETH_XSTATS_NAME_SIZE];
661 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_stats_strings[] = {
662 {"rx_crc_errors", offsetof(struct ixgbe_hw_stats, crcerrs)},
663 {"rx_illegal_byte_errors", offsetof(struct ixgbe_hw_stats, illerrc)},
664 {"rx_error_bytes", offsetof(struct ixgbe_hw_stats, errbc)},
665 {"mac_local_errors", offsetof(struct ixgbe_hw_stats, mlfc)},
666 {"mac_remote_errors", offsetof(struct ixgbe_hw_stats, mrfc)},
667 {"rx_length_errors", offsetof(struct ixgbe_hw_stats, rlec)},
668 {"tx_xon_packets", offsetof(struct ixgbe_hw_stats, lxontxc)},
669 {"rx_xon_packets", offsetof(struct ixgbe_hw_stats, lxonrxc)},
670 {"tx_xoff_packets", offsetof(struct ixgbe_hw_stats, lxofftxc)},
671 {"rx_xoff_packets", offsetof(struct ixgbe_hw_stats, lxoffrxc)},
672 {"rx_size_64_packets", offsetof(struct ixgbe_hw_stats, prc64)},
673 {"rx_size_65_to_127_packets", offsetof(struct ixgbe_hw_stats, prc127)},
674 {"rx_size_128_to_255_packets", offsetof(struct ixgbe_hw_stats, prc255)},
675 {"rx_size_256_to_511_packets", offsetof(struct ixgbe_hw_stats, prc511)},
676 {"rx_size_512_to_1023_packets", offsetof(struct ixgbe_hw_stats,
678 {"rx_size_1024_to_max_packets", offsetof(struct ixgbe_hw_stats,
680 {"rx_broadcast_packets", offsetof(struct ixgbe_hw_stats, bprc)},
681 {"rx_multicast_packets", offsetof(struct ixgbe_hw_stats, mprc)},
682 {"rx_fragment_errors", offsetof(struct ixgbe_hw_stats, rfc)},
683 {"rx_undersize_errors", offsetof(struct ixgbe_hw_stats, ruc)},
684 {"rx_oversize_errors", offsetof(struct ixgbe_hw_stats, roc)},
685 {"rx_jabber_errors", offsetof(struct ixgbe_hw_stats, rjc)},
686 {"rx_management_packets", offsetof(struct ixgbe_hw_stats, mngprc)},
687 {"rx_management_dropped", offsetof(struct ixgbe_hw_stats, mngpdc)},
688 {"tx_management_packets", offsetof(struct ixgbe_hw_stats, mngptc)},
689 {"rx_total_packets", offsetof(struct ixgbe_hw_stats, tpr)},
690 {"rx_total_bytes", offsetof(struct ixgbe_hw_stats, tor)},
691 {"tx_total_packets", offsetof(struct ixgbe_hw_stats, tpt)},
692 {"tx_size_64_packets", offsetof(struct ixgbe_hw_stats, ptc64)},
693 {"tx_size_65_to_127_packets", offsetof(struct ixgbe_hw_stats, ptc127)},
694 {"tx_size_128_to_255_packets", offsetof(struct ixgbe_hw_stats, ptc255)},
695 {"tx_size_256_to_511_packets", offsetof(struct ixgbe_hw_stats, ptc511)},
696 {"tx_size_512_to_1023_packets", offsetof(struct ixgbe_hw_stats,
698 {"tx_size_1024_to_max_packets", offsetof(struct ixgbe_hw_stats,
700 {"tx_multicast_packets", offsetof(struct ixgbe_hw_stats, mptc)},
701 {"tx_broadcast_packets", offsetof(struct ixgbe_hw_stats, bptc)},
702 {"rx_mac_short_packet_dropped", offsetof(struct ixgbe_hw_stats, mspdc)},
703 {"rx_l3_l4_xsum_error", offsetof(struct ixgbe_hw_stats, xec)},
705 {"flow_director_added_filters", offsetof(struct ixgbe_hw_stats,
707 {"flow_director_removed_filters", offsetof(struct ixgbe_hw_stats,
709 {"flow_director_filter_add_errors", offsetof(struct ixgbe_hw_stats,
711 {"flow_director_filter_remove_errors", offsetof(struct ixgbe_hw_stats,
713 {"flow_director_matched_filters", offsetof(struct ixgbe_hw_stats,
715 {"flow_director_missed_filters", offsetof(struct ixgbe_hw_stats,
718 {"rx_fcoe_crc_errors", offsetof(struct ixgbe_hw_stats, fccrc)},
719 {"rx_fcoe_dropped", offsetof(struct ixgbe_hw_stats, fcoerpdc)},
720 {"rx_fcoe_mbuf_allocation_errors", offsetof(struct ixgbe_hw_stats,
722 {"rx_fcoe_packets", offsetof(struct ixgbe_hw_stats, fcoeprc)},
723 {"tx_fcoe_packets", offsetof(struct ixgbe_hw_stats, fcoeptc)},
724 {"rx_fcoe_bytes", offsetof(struct ixgbe_hw_stats, fcoedwrc)},
725 {"tx_fcoe_bytes", offsetof(struct ixgbe_hw_stats, fcoedwtc)},
726 {"rx_fcoe_no_direct_data_placement", offsetof(struct ixgbe_hw_stats,
728 {"rx_fcoe_no_direct_data_placement_ext_buff",
729 offsetof(struct ixgbe_hw_stats, fcoe_noddp_ext_buff)},
731 {"tx_flow_control_xon_packets", offsetof(struct ixgbe_hw_stats,
733 {"rx_flow_control_xon_packets", offsetof(struct ixgbe_hw_stats,
735 {"tx_flow_control_xoff_packets", offsetof(struct ixgbe_hw_stats,
737 {"rx_flow_control_xoff_packets", offsetof(struct ixgbe_hw_stats,
739 {"rx_total_missed_packets", offsetof(struct ixgbe_hw_stats, mpctotal)},
742 #define IXGBE_NB_HW_STATS (sizeof(rte_ixgbe_stats_strings) / \
743 sizeof(rte_ixgbe_stats_strings[0]))
745 /* MACsec statistics */
746 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_macsec_strings[] = {
747 {"out_pkts_untagged", offsetof(struct ixgbe_macsec_stats,
749 {"out_pkts_encrypted", offsetof(struct ixgbe_macsec_stats,
750 out_pkts_encrypted)},
751 {"out_pkts_protected", offsetof(struct ixgbe_macsec_stats,
752 out_pkts_protected)},
753 {"out_octets_encrypted", offsetof(struct ixgbe_macsec_stats,
754 out_octets_encrypted)},
755 {"out_octets_protected", offsetof(struct ixgbe_macsec_stats,
756 out_octets_protected)},
757 {"in_pkts_untagged", offsetof(struct ixgbe_macsec_stats,
759 {"in_pkts_badtag", offsetof(struct ixgbe_macsec_stats,
761 {"in_pkts_nosci", offsetof(struct ixgbe_macsec_stats,
763 {"in_pkts_unknownsci", offsetof(struct ixgbe_macsec_stats,
764 in_pkts_unknownsci)},
765 {"in_octets_decrypted", offsetof(struct ixgbe_macsec_stats,
766 in_octets_decrypted)},
767 {"in_octets_validated", offsetof(struct ixgbe_macsec_stats,
768 in_octets_validated)},
769 {"in_pkts_unchecked", offsetof(struct ixgbe_macsec_stats,
771 {"in_pkts_delayed", offsetof(struct ixgbe_macsec_stats,
773 {"in_pkts_late", offsetof(struct ixgbe_macsec_stats,
775 {"in_pkts_ok", offsetof(struct ixgbe_macsec_stats,
777 {"in_pkts_invalid", offsetof(struct ixgbe_macsec_stats,
779 {"in_pkts_notvalid", offsetof(struct ixgbe_macsec_stats,
781 {"in_pkts_unusedsa", offsetof(struct ixgbe_macsec_stats,
783 {"in_pkts_notusingsa", offsetof(struct ixgbe_macsec_stats,
784 in_pkts_notusingsa)},
787 #define IXGBE_NB_MACSEC_STATS (sizeof(rte_ixgbe_macsec_strings) / \
788 sizeof(rte_ixgbe_macsec_strings[0]))
790 /* Per-queue statistics */
791 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_rxq_strings[] = {
792 {"mbuf_allocation_errors", offsetof(struct ixgbe_hw_stats, rnbc)},
793 {"dropped", offsetof(struct ixgbe_hw_stats, mpc)},
794 {"xon_packets", offsetof(struct ixgbe_hw_stats, pxonrxc)},
795 {"xoff_packets", offsetof(struct ixgbe_hw_stats, pxoffrxc)},
798 #define IXGBE_NB_RXQ_PRIO_STATS (sizeof(rte_ixgbe_rxq_strings) / \
799 sizeof(rte_ixgbe_rxq_strings[0]))
800 #define IXGBE_NB_RXQ_PRIO_VALUES 8
802 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_txq_strings[] = {
803 {"xon_packets", offsetof(struct ixgbe_hw_stats, pxontxc)},
804 {"xoff_packets", offsetof(struct ixgbe_hw_stats, pxofftxc)},
805 {"xon_to_xoff_packets", offsetof(struct ixgbe_hw_stats,
809 #define IXGBE_NB_TXQ_PRIO_STATS (sizeof(rte_ixgbe_txq_strings) / \
810 sizeof(rte_ixgbe_txq_strings[0]))
811 #define IXGBE_NB_TXQ_PRIO_VALUES 8
813 static const struct rte_ixgbe_xstats_name_off rte_ixgbevf_stats_strings[] = {
814 {"rx_multicast_packets", offsetof(struct ixgbevf_hw_stats, vfmprc)},
817 #define IXGBEVF_NB_XSTATS (sizeof(rte_ixgbevf_stats_strings) / \
818 sizeof(rte_ixgbevf_stats_strings[0]))
821 * Atomically reads the link status information from global
822 * structure rte_eth_dev.
825 * - Pointer to the structure rte_eth_dev to read from.
826 * - Pointer to the buffer to be saved with the link status.
829 * - On success, zero.
830 * - On failure, negative value.
833 rte_ixgbe_dev_atomic_read_link_status(struct rte_eth_dev *dev,
834 struct rte_eth_link *link)
836 struct rte_eth_link *dst = link;
837 struct rte_eth_link *src = &(dev->data->dev_link);
839 if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
840 *(uint64_t *)src) == 0)
847 * Atomically writes the link status information into global
848 * structure rte_eth_dev.
851 * - Pointer to the structure rte_eth_dev to read from.
852 * - Pointer to the buffer to be saved with the link status.
855 * - On success, zero.
856 * - On failure, negative value.
859 rte_ixgbe_dev_atomic_write_link_status(struct rte_eth_dev *dev,
860 struct rte_eth_link *link)
862 struct rte_eth_link *dst = &(dev->data->dev_link);
863 struct rte_eth_link *src = link;
865 if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
866 *(uint64_t *)src) == 0)
873 * This function is the same as ixgbe_is_sfp() in base/ixgbe.h.
876 ixgbe_is_sfp(struct ixgbe_hw *hw)
878 switch (hw->phy.type) {
879 case ixgbe_phy_sfp_avago:
880 case ixgbe_phy_sfp_ftl:
881 case ixgbe_phy_sfp_intel:
882 case ixgbe_phy_sfp_unknown:
883 case ixgbe_phy_sfp_passive_tyco:
884 case ixgbe_phy_sfp_passive_unknown:
891 static inline int32_t
892 ixgbe_pf_reset_hw(struct ixgbe_hw *hw)
897 status = ixgbe_reset_hw(hw);
899 ctrl_ext = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
900 /* Set PF Reset Done bit so PF/VF Mail Ops can work */
901 ctrl_ext |= IXGBE_CTRL_EXT_PFRSTD;
902 IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl_ext);
903 IXGBE_WRITE_FLUSH(hw);
909 ixgbe_enable_intr(struct rte_eth_dev *dev)
911 struct ixgbe_interrupt *intr =
912 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
913 struct ixgbe_hw *hw =
914 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
916 IXGBE_WRITE_REG(hw, IXGBE_EIMS, intr->mask);
917 IXGBE_WRITE_FLUSH(hw);
921 * This function is based on ixgbe_disable_intr() in base/ixgbe.h.
924 ixgbe_disable_intr(struct ixgbe_hw *hw)
926 PMD_INIT_FUNC_TRACE();
928 if (hw->mac.type == ixgbe_mac_82598EB) {
929 IXGBE_WRITE_REG(hw, IXGBE_EIMC, ~0);
931 IXGBE_WRITE_REG(hw, IXGBE_EIMC, 0xFFFF0000);
932 IXGBE_WRITE_REG(hw, IXGBE_EIMC_EX(0), ~0);
933 IXGBE_WRITE_REG(hw, IXGBE_EIMC_EX(1), ~0);
935 IXGBE_WRITE_FLUSH(hw);
939 * This function resets queue statistics mapping registers.
940 * From Niantic datasheet, Initialization of Statistics section:
941 * "...if software requires the queue counters, the RQSMR and TQSM registers
942 * must be re-programmed following a device reset.
945 ixgbe_reset_qstat_mappings(struct ixgbe_hw *hw)
949 for (i = 0; i != IXGBE_NB_STAT_MAPPING_REGS; i++) {
950 IXGBE_WRITE_REG(hw, IXGBE_RQSMR(i), 0);
951 IXGBE_WRITE_REG(hw, IXGBE_TQSM(i), 0);
957 ixgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
962 #define QSM_REG_NB_BITS_PER_QMAP_FIELD 8
963 #define NB_QMAP_FIELDS_PER_QSM_REG 4
964 #define QMAP_FIELD_RESERVED_BITS_MASK 0x0f
966 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
967 struct ixgbe_stat_mapping_registers *stat_mappings =
968 IXGBE_DEV_PRIVATE_TO_STAT_MAPPINGS(eth_dev->data->dev_private);
969 uint32_t qsmr_mask = 0;
970 uint32_t clearing_mask = QMAP_FIELD_RESERVED_BITS_MASK;
974 if ((hw->mac.type != ixgbe_mac_82599EB) &&
975 (hw->mac.type != ixgbe_mac_X540) &&
976 (hw->mac.type != ixgbe_mac_X550) &&
977 (hw->mac.type != ixgbe_mac_X550EM_x) &&
978 (hw->mac.type != ixgbe_mac_X550EM_a))
981 PMD_INIT_LOG(DEBUG, "Setting port %d, %s queue_id %d to stat index %d",
982 (int)(eth_dev->data->port_id), is_rx ? "RX" : "TX",
985 n = (uint8_t)(queue_id / NB_QMAP_FIELDS_PER_QSM_REG);
986 if (n >= IXGBE_NB_STAT_MAPPING_REGS) {
987 PMD_INIT_LOG(ERR, "Nb of stat mapping registers exceeded");
990 offset = (uint8_t)(queue_id % NB_QMAP_FIELDS_PER_QSM_REG);
992 /* Now clear any previous stat_idx set */
993 clearing_mask <<= (QSM_REG_NB_BITS_PER_QMAP_FIELD * offset);
995 stat_mappings->tqsm[n] &= ~clearing_mask;
997 stat_mappings->rqsmr[n] &= ~clearing_mask;
999 q_map = (uint32_t)stat_idx;
1000 q_map &= QMAP_FIELD_RESERVED_BITS_MASK;
1001 qsmr_mask = q_map << (QSM_REG_NB_BITS_PER_QMAP_FIELD * offset);
1003 stat_mappings->tqsm[n] |= qsmr_mask;
1005 stat_mappings->rqsmr[n] |= qsmr_mask;
1007 PMD_INIT_LOG(DEBUG, "Set port %d, %s queue_id %d to stat index %d",
1008 (int)(eth_dev->data->port_id), is_rx ? "RX" : "TX",
1009 queue_id, stat_idx);
1010 PMD_INIT_LOG(DEBUG, "%s[%d] = 0x%08x", is_rx ? "RQSMR" : "TQSM", n,
1011 is_rx ? stat_mappings->rqsmr[n] : stat_mappings->tqsm[n]);
1013 /* Now write the mapping in the appropriate register */
1015 PMD_INIT_LOG(DEBUG, "Write 0x%x to RX IXGBE stat mapping reg:%d",
1016 stat_mappings->rqsmr[n], n);
1017 IXGBE_WRITE_REG(hw, IXGBE_RQSMR(n), stat_mappings->rqsmr[n]);
1019 PMD_INIT_LOG(DEBUG, "Write 0x%x to TX IXGBE stat mapping reg:%d",
1020 stat_mappings->tqsm[n], n);
1021 IXGBE_WRITE_REG(hw, IXGBE_TQSM(n), stat_mappings->tqsm[n]);
1027 ixgbe_restore_statistics_mapping(struct rte_eth_dev *dev)
1029 struct ixgbe_stat_mapping_registers *stat_mappings =
1030 IXGBE_DEV_PRIVATE_TO_STAT_MAPPINGS(dev->data->dev_private);
1031 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1034 /* write whatever was in stat mapping table to the NIC */
1035 for (i = 0; i < IXGBE_NB_STAT_MAPPING_REGS; i++) {
1037 IXGBE_WRITE_REG(hw, IXGBE_RQSMR(i), stat_mappings->rqsmr[i]);
1040 IXGBE_WRITE_REG(hw, IXGBE_TQSM(i), stat_mappings->tqsm[i]);
1045 ixgbe_dcb_init(struct ixgbe_hw *hw, struct ixgbe_dcb_config *dcb_config)
1048 struct ixgbe_dcb_tc_config *tc;
1049 uint8_t dcb_max_tc = IXGBE_DCB_MAX_TRAFFIC_CLASS;
1051 dcb_config->num_tcs.pg_tcs = dcb_max_tc;
1052 dcb_config->num_tcs.pfc_tcs = dcb_max_tc;
1053 for (i = 0; i < dcb_max_tc; i++) {
1054 tc = &dcb_config->tc_config[i];
1055 tc->path[IXGBE_DCB_TX_CONFIG].bwg_id = i;
1056 tc->path[IXGBE_DCB_TX_CONFIG].bwg_percent =
1057 (uint8_t)(100/dcb_max_tc + (i & 1));
1058 tc->path[IXGBE_DCB_RX_CONFIG].bwg_id = i;
1059 tc->path[IXGBE_DCB_RX_CONFIG].bwg_percent =
1060 (uint8_t)(100/dcb_max_tc + (i & 1));
1061 tc->pfc = ixgbe_dcb_pfc_disabled;
1064 /* Initialize default user to priority mapping, UPx->TC0 */
1065 tc = &dcb_config->tc_config[0];
1066 tc->path[IXGBE_DCB_TX_CONFIG].up_to_tc_bitmap = 0xFF;
1067 tc->path[IXGBE_DCB_RX_CONFIG].up_to_tc_bitmap = 0xFF;
1068 for (i = 0; i < IXGBE_DCB_MAX_BW_GROUP; i++) {
1069 dcb_config->bw_percentage[IXGBE_DCB_TX_CONFIG][i] = 100;
1070 dcb_config->bw_percentage[IXGBE_DCB_RX_CONFIG][i] = 100;
1072 dcb_config->rx_pba_cfg = ixgbe_dcb_pba_equal;
1073 dcb_config->pfc_mode_enable = false;
1074 dcb_config->vt_mode = true;
1075 dcb_config->round_robin_enable = false;
1076 /* support all DCB capabilities in 82599 */
1077 dcb_config->support.capabilities = 0xFF;
1079 /*we only support 4 Tcs for X540, X550 */
1080 if (hw->mac.type == ixgbe_mac_X540 ||
1081 hw->mac.type == ixgbe_mac_X550 ||
1082 hw->mac.type == ixgbe_mac_X550EM_x ||
1083 hw->mac.type == ixgbe_mac_X550EM_a) {
1084 dcb_config->num_tcs.pg_tcs = 4;
1085 dcb_config->num_tcs.pfc_tcs = 4;
1090 * Ensure that all locks are released before first NVM or PHY access
1093 ixgbe_swfw_lock_reset(struct ixgbe_hw *hw)
1098 * Phy lock should not fail in this early stage. If this is the case,
1099 * it is due to an improper exit of the application.
1100 * So force the release of the faulty lock. Release of common lock
1101 * is done automatically by swfw_sync function.
1103 mask = IXGBE_GSSR_PHY0_SM << hw->bus.func;
1104 if (ixgbe_acquire_swfw_semaphore(hw, mask) < 0) {
1105 PMD_DRV_LOG(DEBUG, "SWFW phy%d lock released", hw->bus.func);
1107 ixgbe_release_swfw_semaphore(hw, mask);
1110 * These ones are more tricky since they are common to all ports; but
1111 * swfw_sync retries last long enough (1s) to be almost sure that if
1112 * lock can not be taken it is due to an improper lock of the
1115 mask = IXGBE_GSSR_EEP_SM | IXGBE_GSSR_MAC_CSR_SM | IXGBE_GSSR_SW_MNG_SM;
1116 if (ixgbe_acquire_swfw_semaphore(hw, mask) < 0) {
1117 PMD_DRV_LOG(DEBUG, "SWFW common locks released");
1119 ixgbe_release_swfw_semaphore(hw, mask);
1123 * This function is based on code in ixgbe_attach() in base/ixgbe.c.
1124 * It returns 0 on success.
1127 eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev)
1129 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(eth_dev);
1130 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
1131 struct ixgbe_hw *hw =
1132 IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
1133 struct ixgbe_vfta *shadow_vfta =
1134 IXGBE_DEV_PRIVATE_TO_VFTA(eth_dev->data->dev_private);
1135 struct ixgbe_hwstrip *hwstrip =
1136 IXGBE_DEV_PRIVATE_TO_HWSTRIP_BITMAP(eth_dev->data->dev_private);
1137 struct ixgbe_dcb_config *dcb_config =
1138 IXGBE_DEV_PRIVATE_TO_DCB_CFG(eth_dev->data->dev_private);
1139 struct ixgbe_filter_info *filter_info =
1140 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(eth_dev->data->dev_private);
1145 PMD_INIT_FUNC_TRACE();
1147 eth_dev->dev_ops = &ixgbe_eth_dev_ops;
1148 eth_dev->rx_pkt_burst = &ixgbe_recv_pkts;
1149 eth_dev->tx_pkt_burst = &ixgbe_xmit_pkts;
1150 eth_dev->tx_pkt_prepare = &ixgbe_prep_pkts;
1153 * For secondary processes, we don't initialise any further as primary
1154 * has already done this work. Only check we don't need a different
1155 * RX and TX function.
1157 if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
1158 struct ixgbe_tx_queue *txq;
1159 /* TX queue function in primary, set by last queue initialized
1160 * Tx queue may not initialized by primary process
1162 if (eth_dev->data->tx_queues) {
1163 txq = eth_dev->data->tx_queues[eth_dev->data->nb_tx_queues-1];
1164 ixgbe_set_tx_function(eth_dev, txq);
1166 /* Use default TX function if we get here */
1167 PMD_INIT_LOG(NOTICE, "No TX queues configured yet. "
1168 "Using default TX function.");
1171 ixgbe_set_rx_function(eth_dev);
1176 rte_eth_copy_pci_info(eth_dev, pci_dev);
1177 eth_dev->data->dev_flags = RTE_ETH_DEV_DETACHABLE;
1179 /* Vendor and Device ID need to be set before init of shared code */
1180 hw->device_id = pci_dev->id.device_id;
1181 hw->vendor_id = pci_dev->id.vendor_id;
1182 hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
1183 hw->allow_unsupported_sfp = 1;
1185 /* Initialize the shared code (base driver) */
1186 #ifdef RTE_NIC_BYPASS
1187 diag = ixgbe_bypass_init_shared_code(hw);
1189 diag = ixgbe_init_shared_code(hw);
1190 #endif /* RTE_NIC_BYPASS */
1192 if (diag != IXGBE_SUCCESS) {
1193 PMD_INIT_LOG(ERR, "Shared code init failed: %d", diag);
1197 /* pick up the PCI bus settings for reporting later */
1198 ixgbe_get_bus_info(hw);
1200 /* Unlock any pending hardware semaphore */
1201 ixgbe_swfw_lock_reset(hw);
1203 /* Initialize DCB configuration*/
1204 memset(dcb_config, 0, sizeof(struct ixgbe_dcb_config));
1205 ixgbe_dcb_init(hw, dcb_config);
1206 /* Get Hardware Flow Control setting */
1207 hw->fc.requested_mode = ixgbe_fc_full;
1208 hw->fc.current_mode = ixgbe_fc_full;
1209 hw->fc.pause_time = IXGBE_FC_PAUSE;
1210 for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
1211 hw->fc.low_water[i] = IXGBE_FC_LO;
1212 hw->fc.high_water[i] = IXGBE_FC_HI;
1214 hw->fc.send_xon = 1;
1216 /* Make sure we have a good EEPROM before we read from it */
1217 diag = ixgbe_validate_eeprom_checksum(hw, &csum);
1218 if (diag != IXGBE_SUCCESS) {
1219 PMD_INIT_LOG(ERR, "The EEPROM checksum is not valid: %d", diag);
1223 #ifdef RTE_NIC_BYPASS
1224 diag = ixgbe_bypass_init_hw(hw);
1226 diag = ixgbe_init_hw(hw);
1227 #endif /* RTE_NIC_BYPASS */
1230 * Devices with copper phys will fail to initialise if ixgbe_init_hw()
1231 * is called too soon after the kernel driver unbinding/binding occurs.
1232 * The failure occurs in ixgbe_identify_phy_generic() for all devices,
1233 * but for non-copper devies, ixgbe_identify_sfp_module_generic() is
1234 * also called. See ixgbe_identify_phy_82599(). The reason for the
1235 * failure is not known, and only occuts when virtualisation features
1236 * are disabled in the bios. A delay of 100ms was found to be enough by
1237 * trial-and-error, and is doubled to be safe.
1239 if (diag && (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper)) {
1241 diag = ixgbe_init_hw(hw);
1244 if (diag == IXGBE_ERR_EEPROM_VERSION) {
1245 PMD_INIT_LOG(ERR, "This device is a pre-production adapter/"
1246 "LOM. Please be aware there may be issues associated "
1247 "with your hardware.");
1248 PMD_INIT_LOG(ERR, "If you are experiencing problems "
1249 "please contact your Intel or hardware representative "
1250 "who provided you with this hardware.");
1251 } else if (diag == IXGBE_ERR_SFP_NOT_SUPPORTED)
1252 PMD_INIT_LOG(ERR, "Unsupported SFP+ Module");
1254 PMD_INIT_LOG(ERR, "Hardware Initialization Failure: %d", diag);
1258 /* Reset the hw statistics */
1259 ixgbe_dev_stats_reset(eth_dev);
1261 /* disable interrupt */
1262 ixgbe_disable_intr(hw);
1264 /* reset mappings for queue statistics hw counters*/
1265 ixgbe_reset_qstat_mappings(hw);
1267 /* Allocate memory for storing MAC addresses */
1268 eth_dev->data->mac_addrs = rte_zmalloc("ixgbe", ETHER_ADDR_LEN *
1269 hw->mac.num_rar_entries, 0);
1270 if (eth_dev->data->mac_addrs == NULL) {
1272 "Failed to allocate %u bytes needed to store "
1274 ETHER_ADDR_LEN * hw->mac.num_rar_entries);
1277 /* Copy the permanent MAC address */
1278 ether_addr_copy((struct ether_addr *) hw->mac.perm_addr,
1279 ð_dev->data->mac_addrs[0]);
1281 /* Allocate memory for storing hash filter MAC addresses */
1282 eth_dev->data->hash_mac_addrs = rte_zmalloc("ixgbe", ETHER_ADDR_LEN *
1283 IXGBE_VMDQ_NUM_UC_MAC, 0);
1284 if (eth_dev->data->hash_mac_addrs == NULL) {
1286 "Failed to allocate %d bytes needed to store MAC addresses",
1287 ETHER_ADDR_LEN * IXGBE_VMDQ_NUM_UC_MAC);
1291 /* initialize the vfta */
1292 memset(shadow_vfta, 0, sizeof(*shadow_vfta));
1294 /* initialize the hw strip bitmap*/
1295 memset(hwstrip, 0, sizeof(*hwstrip));
1297 /* initialize PF if max_vfs not zero */
1298 ixgbe_pf_host_init(eth_dev);
1300 ctrl_ext = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
1301 /* let hardware know driver is loaded */
1302 ctrl_ext |= IXGBE_CTRL_EXT_DRV_LOAD;
1303 /* Set PF Reset Done bit so PF/VF Mail Ops can work */
1304 ctrl_ext |= IXGBE_CTRL_EXT_PFRSTD;
1305 IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl_ext);
1306 IXGBE_WRITE_FLUSH(hw);
1308 if (ixgbe_is_sfp(hw) && hw->phy.sfp_type != ixgbe_sfp_type_not_present)
1309 PMD_INIT_LOG(DEBUG, "MAC: %d, PHY: %d, SFP+: %d",
1310 (int) hw->mac.type, (int) hw->phy.type,
1311 (int) hw->phy.sfp_type);
1313 PMD_INIT_LOG(DEBUG, "MAC: %d, PHY: %d",
1314 (int) hw->mac.type, (int) hw->phy.type);
1316 PMD_INIT_LOG(DEBUG, "port %d vendorID=0x%x deviceID=0x%x",
1317 eth_dev->data->port_id, pci_dev->id.vendor_id,
1318 pci_dev->id.device_id);
1320 rte_intr_callback_register(intr_handle,
1321 ixgbe_dev_interrupt_handler, eth_dev);
1323 /* enable uio/vfio intr/eventfd mapping */
1324 rte_intr_enable(intr_handle);
1326 /* enable support intr */
1327 ixgbe_enable_intr(eth_dev);
1329 /* initialize filter info */
1330 memset(filter_info, 0,
1331 sizeof(struct ixgbe_filter_info));
1333 /* initialize 5tuple filter list */
1334 TAILQ_INIT(&filter_info->fivetuple_list);
1336 /* initialize flow director filter list & hash */
1337 ixgbe_fdir_filter_init(eth_dev);
1343 eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev)
1345 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(eth_dev);
1346 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
1347 struct ixgbe_hw *hw;
1349 PMD_INIT_FUNC_TRACE();
1351 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
1354 hw = IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
1356 if (hw->adapter_stopped == 0)
1357 ixgbe_dev_close(eth_dev);
1359 eth_dev->dev_ops = NULL;
1360 eth_dev->rx_pkt_burst = NULL;
1361 eth_dev->tx_pkt_burst = NULL;
1363 /* Unlock any pending hardware semaphore */
1364 ixgbe_swfw_lock_reset(hw);
1366 /* disable uio intr before callback unregister */
1367 rte_intr_disable(intr_handle);
1368 rte_intr_callback_unregister(intr_handle,
1369 ixgbe_dev_interrupt_handler, eth_dev);
1371 /* uninitialize PF if max_vfs not zero */
1372 ixgbe_pf_host_uninit(eth_dev);
1374 rte_free(eth_dev->data->mac_addrs);
1375 eth_dev->data->mac_addrs = NULL;
1377 rte_free(eth_dev->data->hash_mac_addrs);
1378 eth_dev->data->hash_mac_addrs = NULL;
1380 /* remove all the fdir filters & hash */
1381 ixgbe_fdir_filter_uninit(eth_dev);
1386 static int ixgbe_fdir_filter_uninit(struct rte_eth_dev *eth_dev)
1388 struct ixgbe_hw_fdir_info *fdir_info =
1389 IXGBE_DEV_PRIVATE_TO_FDIR_INFO(eth_dev->data->dev_private);
1390 struct ixgbe_fdir_filter *fdir_filter;
1392 if (fdir_info->hash_map)
1393 rte_free(fdir_info->hash_map);
1394 if (fdir_info->hash_handle)
1395 rte_hash_free(fdir_info->hash_handle);
1397 while ((fdir_filter = TAILQ_FIRST(&fdir_info->fdir_list))) {
1398 TAILQ_REMOVE(&fdir_info->fdir_list,
1401 rte_free(fdir_filter);
1407 static int ixgbe_fdir_filter_init(struct rte_eth_dev *eth_dev)
1409 struct ixgbe_hw_fdir_info *fdir_info =
1410 IXGBE_DEV_PRIVATE_TO_FDIR_INFO(eth_dev->data->dev_private);
1411 char fdir_hash_name[RTE_HASH_NAMESIZE];
1412 struct rte_hash_parameters fdir_hash_params = {
1413 .name = fdir_hash_name,
1414 .entries = IXGBE_MAX_FDIR_FILTER_NUM,
1415 .key_len = sizeof(union ixgbe_atr_input),
1416 .hash_func = rte_hash_crc,
1417 .hash_func_init_val = 0,
1418 .socket_id = rte_socket_id(),
1421 TAILQ_INIT(&fdir_info->fdir_list);
1422 snprintf(fdir_hash_name, RTE_HASH_NAMESIZE,
1423 "fdir_%s", eth_dev->data->name);
1424 fdir_info->hash_handle = rte_hash_create(&fdir_hash_params);
1425 if (!fdir_info->hash_handle) {
1426 PMD_INIT_LOG(ERR, "Failed to create fdir hash table!");
1429 fdir_info->hash_map = rte_zmalloc("ixgbe",
1430 sizeof(struct ixgbe_fdir_filter *) *
1431 IXGBE_MAX_FDIR_FILTER_NUM,
1433 if (!fdir_info->hash_map) {
1435 "Failed to allocate memory for fdir hash map!");
1442 * Negotiate mailbox API version with the PF.
1443 * After reset API version is always set to the basic one (ixgbe_mbox_api_10).
1444 * Then we try to negotiate starting with the most recent one.
1445 * If all negotiation attempts fail, then we will proceed with
1446 * the default one (ixgbe_mbox_api_10).
1449 ixgbevf_negotiate_api(struct ixgbe_hw *hw)
1453 /* start with highest supported, proceed down */
1454 static const enum ixgbe_pfvf_api_rev sup_ver[] = {
1461 i != RTE_DIM(sup_ver) &&
1462 ixgbevf_negotiate_api_version(hw, sup_ver[i]) != 0;
1468 generate_random_mac_addr(struct ether_addr *mac_addr)
1472 /* Set Organizationally Unique Identifier (OUI) prefix. */
1473 mac_addr->addr_bytes[0] = 0x00;
1474 mac_addr->addr_bytes[1] = 0x09;
1475 mac_addr->addr_bytes[2] = 0xC0;
1476 /* Force indication of locally assigned MAC address. */
1477 mac_addr->addr_bytes[0] |= ETHER_LOCAL_ADMIN_ADDR;
1478 /* Generate the last 3 bytes of the MAC address with a random number. */
1479 random = rte_rand();
1480 memcpy(&mac_addr->addr_bytes[3], &random, 3);
1484 * Virtual Function device init
1487 eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev)
1491 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(eth_dev);
1492 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
1493 struct ixgbe_hw *hw =
1494 IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
1495 struct ixgbe_vfta *shadow_vfta =
1496 IXGBE_DEV_PRIVATE_TO_VFTA(eth_dev->data->dev_private);
1497 struct ixgbe_hwstrip *hwstrip =
1498 IXGBE_DEV_PRIVATE_TO_HWSTRIP_BITMAP(eth_dev->data->dev_private);
1499 struct ether_addr *perm_addr = (struct ether_addr *) hw->mac.perm_addr;
1501 PMD_INIT_FUNC_TRACE();
1503 eth_dev->dev_ops = &ixgbevf_eth_dev_ops;
1504 eth_dev->rx_pkt_burst = &ixgbe_recv_pkts;
1505 eth_dev->tx_pkt_burst = &ixgbe_xmit_pkts;
1507 /* for secondary processes, we don't initialise any further as primary
1508 * has already done this work. Only check we don't need a different
1511 if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
1512 struct ixgbe_tx_queue *txq;
1513 /* TX queue function in primary, set by last queue initialized
1514 * Tx queue may not initialized by primary process
1516 if (eth_dev->data->tx_queues) {
1517 txq = eth_dev->data->tx_queues[eth_dev->data->nb_tx_queues - 1];
1518 ixgbe_set_tx_function(eth_dev, txq);
1520 /* Use default TX function if we get here */
1521 PMD_INIT_LOG(NOTICE,
1522 "No TX queues configured yet. Using default TX function.");
1525 ixgbe_set_rx_function(eth_dev);
1530 rte_eth_copy_pci_info(eth_dev, pci_dev);
1531 eth_dev->data->dev_flags = RTE_ETH_DEV_DETACHABLE;
1533 hw->device_id = pci_dev->id.device_id;
1534 hw->vendor_id = pci_dev->id.vendor_id;
1535 hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
1537 /* initialize the vfta */
1538 memset(shadow_vfta, 0, sizeof(*shadow_vfta));
1540 /* initialize the hw strip bitmap*/
1541 memset(hwstrip, 0, sizeof(*hwstrip));
1543 /* Initialize the shared code (base driver) */
1544 diag = ixgbe_init_shared_code(hw);
1545 if (diag != IXGBE_SUCCESS) {
1546 PMD_INIT_LOG(ERR, "Shared code init failed for ixgbevf: %d", diag);
1550 /* init_mailbox_params */
1551 hw->mbx.ops.init_params(hw);
1553 /* Reset the hw statistics */
1554 ixgbevf_dev_stats_reset(eth_dev);
1556 /* Disable the interrupts for VF */
1557 ixgbevf_intr_disable(hw);
1559 hw->mac.num_rar_entries = 128; /* The MAX of the underlying PF */
1560 diag = hw->mac.ops.reset_hw(hw);
1563 * The VF reset operation returns the IXGBE_ERR_INVALID_MAC_ADDR when
1564 * the underlying PF driver has not assigned a MAC address to the VF.
1565 * In this case, assign a random MAC address.
1567 if ((diag != IXGBE_SUCCESS) && (diag != IXGBE_ERR_INVALID_MAC_ADDR)) {
1568 PMD_INIT_LOG(ERR, "VF Initialization Failure: %d", diag);
1572 /* negotiate mailbox API version to use with the PF. */
1573 ixgbevf_negotiate_api(hw);
1575 /* Get Rx/Tx queue count via mailbox, which is ready after reset_hw */
1576 ixgbevf_get_queues(hw, &tcs, &tc);
1578 /* Allocate memory for storing MAC addresses */
1579 eth_dev->data->mac_addrs = rte_zmalloc("ixgbevf", ETHER_ADDR_LEN *
1580 hw->mac.num_rar_entries, 0);
1581 if (eth_dev->data->mac_addrs == NULL) {
1583 "Failed to allocate %u bytes needed to store "
1585 ETHER_ADDR_LEN * hw->mac.num_rar_entries);
1589 /* Generate a random MAC address, if none was assigned by PF. */
1590 if (is_zero_ether_addr(perm_addr)) {
1591 generate_random_mac_addr(perm_addr);
1592 diag = ixgbe_set_rar_vf(hw, 1, perm_addr->addr_bytes, 0, 1);
1594 rte_free(eth_dev->data->mac_addrs);
1595 eth_dev->data->mac_addrs = NULL;
1598 PMD_INIT_LOG(INFO, "\tVF MAC address not assigned by Host PF");
1599 PMD_INIT_LOG(INFO, "\tAssign randomly generated MAC address "
1600 "%02x:%02x:%02x:%02x:%02x:%02x",
1601 perm_addr->addr_bytes[0],
1602 perm_addr->addr_bytes[1],
1603 perm_addr->addr_bytes[2],
1604 perm_addr->addr_bytes[3],
1605 perm_addr->addr_bytes[4],
1606 perm_addr->addr_bytes[5]);
1609 /* Copy the permanent MAC address */
1610 ether_addr_copy(perm_addr, ð_dev->data->mac_addrs[0]);
1612 /* reset the hardware with the new settings */
1613 diag = hw->mac.ops.start_hw(hw);
1619 PMD_INIT_LOG(ERR, "VF Initialization Failure: %d", diag);
1623 rte_intr_callback_register(intr_handle,
1624 ixgbevf_dev_interrupt_handler, eth_dev);
1625 rte_intr_enable(intr_handle);
1626 ixgbevf_intr_enable(hw);
1628 PMD_INIT_LOG(DEBUG, "port %d vendorID=0x%x deviceID=0x%x mac.type=%s",
1629 eth_dev->data->port_id, pci_dev->id.vendor_id,
1630 pci_dev->id.device_id, "ixgbe_mac_82599_vf");
1635 /* Virtual Function device uninit */
1638 eth_ixgbevf_dev_uninit(struct rte_eth_dev *eth_dev)
1640 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(eth_dev);
1641 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
1642 struct ixgbe_hw *hw;
1644 PMD_INIT_FUNC_TRACE();
1646 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
1649 hw = IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
1651 if (hw->adapter_stopped == 0)
1652 ixgbevf_dev_close(eth_dev);
1654 eth_dev->dev_ops = NULL;
1655 eth_dev->rx_pkt_burst = NULL;
1656 eth_dev->tx_pkt_burst = NULL;
1658 /* Disable the interrupts for VF */
1659 ixgbevf_intr_disable(hw);
1661 rte_free(eth_dev->data->mac_addrs);
1662 eth_dev->data->mac_addrs = NULL;
1664 rte_intr_disable(intr_handle);
1665 rte_intr_callback_unregister(intr_handle,
1666 ixgbevf_dev_interrupt_handler, eth_dev);
1671 static struct eth_driver rte_ixgbe_pmd = {
1673 .id_table = pci_id_ixgbe_map,
1674 .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
1675 .probe = rte_eth_dev_pci_probe,
1676 .remove = rte_eth_dev_pci_remove,
1678 .eth_dev_init = eth_ixgbe_dev_init,
1679 .eth_dev_uninit = eth_ixgbe_dev_uninit,
1680 .dev_private_size = sizeof(struct ixgbe_adapter),
1684 * virtual function driver struct
1686 static struct eth_driver rte_ixgbevf_pmd = {
1688 .id_table = pci_id_ixgbevf_map,
1689 .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
1690 .probe = rte_eth_dev_pci_probe,
1691 .remove = rte_eth_dev_pci_remove,
1693 .eth_dev_init = eth_ixgbevf_dev_init,
1694 .eth_dev_uninit = eth_ixgbevf_dev_uninit,
1695 .dev_private_size = sizeof(struct ixgbe_adapter),
1699 ixgbe_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
1701 struct ixgbe_hw *hw =
1702 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1703 struct ixgbe_vfta *shadow_vfta =
1704 IXGBE_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
1709 vid_idx = (uint32_t) ((vlan_id >> 5) & 0x7F);
1710 vid_bit = (uint32_t) (1 << (vlan_id & 0x1F));
1711 vfta = IXGBE_READ_REG(hw, IXGBE_VFTA(vid_idx));
1716 IXGBE_WRITE_REG(hw, IXGBE_VFTA(vid_idx), vfta);
1718 /* update local VFTA copy */
1719 shadow_vfta->vfta[vid_idx] = vfta;
1725 ixgbe_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue, int on)
1728 ixgbe_vlan_hw_strip_enable(dev, queue);
1730 ixgbe_vlan_hw_strip_disable(dev, queue);
1734 ixgbe_vlan_tpid_set(struct rte_eth_dev *dev,
1735 enum rte_vlan_type vlan_type,
1738 struct ixgbe_hw *hw =
1739 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1744 qinq = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
1745 qinq &= IXGBE_DMATXCTL_GDV;
1747 switch (vlan_type) {
1748 case ETH_VLAN_TYPE_INNER:
1750 reg = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
1751 reg = (reg & (~IXGBE_VLNCTRL_VET)) | (uint32_t)tpid;
1752 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, reg);
1753 reg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
1754 reg = (reg & (~IXGBE_DMATXCTL_VT_MASK))
1755 | ((uint32_t)tpid << IXGBE_DMATXCTL_VT_SHIFT);
1756 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);
1759 PMD_DRV_LOG(ERR, "Inner type is not supported"
1763 case ETH_VLAN_TYPE_OUTER:
1765 /* Only the high 16-bits is valid */
1766 IXGBE_WRITE_REG(hw, IXGBE_EXVET, (uint32_t)tpid <<
1767 IXGBE_EXVET_VET_EXT_SHIFT);
1769 reg = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
1770 reg = (reg & (~IXGBE_VLNCTRL_VET)) | (uint32_t)tpid;
1771 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, reg);
1772 reg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
1773 reg = (reg & (~IXGBE_DMATXCTL_VT_MASK))
1774 | ((uint32_t)tpid << IXGBE_DMATXCTL_VT_SHIFT);
1775 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);
1781 PMD_DRV_LOG(ERR, "Unsupported VLAN type %d", vlan_type);
1789 ixgbe_vlan_hw_filter_disable(struct rte_eth_dev *dev)
1791 struct ixgbe_hw *hw =
1792 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1795 PMD_INIT_FUNC_TRACE();
1797 /* Filter Table Disable */
1798 vlnctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
1799 vlnctrl &= ~IXGBE_VLNCTRL_VFE;
1801 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlnctrl);
1805 ixgbe_vlan_hw_filter_enable(struct rte_eth_dev *dev)
1807 struct ixgbe_hw *hw =
1808 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1809 struct ixgbe_vfta *shadow_vfta =
1810 IXGBE_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
1814 PMD_INIT_FUNC_TRACE();
1816 /* Filter Table Enable */
1817 vlnctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
1818 vlnctrl &= ~IXGBE_VLNCTRL_CFIEN;
1819 vlnctrl |= IXGBE_VLNCTRL_VFE;
1821 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlnctrl);
1823 /* write whatever is in local vfta copy */
1824 for (i = 0; i < IXGBE_VFTA_SIZE; i++)
1825 IXGBE_WRITE_REG(hw, IXGBE_VFTA(i), shadow_vfta->vfta[i]);
1829 ixgbe_vlan_hw_strip_bitmap_set(struct rte_eth_dev *dev, uint16_t queue, bool on)
1831 struct ixgbe_hwstrip *hwstrip =
1832 IXGBE_DEV_PRIVATE_TO_HWSTRIP_BITMAP(dev->data->dev_private);
1833 struct ixgbe_rx_queue *rxq;
1835 if (queue >= IXGBE_MAX_RX_QUEUE_NUM)
1839 IXGBE_SET_HWSTRIP(hwstrip, queue);
1841 IXGBE_CLEAR_HWSTRIP(hwstrip, queue);
1843 if (queue >= dev->data->nb_rx_queues)
1846 rxq = dev->data->rx_queues[queue];
1849 rxq->vlan_flags = PKT_RX_VLAN_PKT | PKT_RX_VLAN_STRIPPED;
1851 rxq->vlan_flags = PKT_RX_VLAN_PKT;
1855 ixgbe_vlan_hw_strip_disable(struct rte_eth_dev *dev, uint16_t queue)
1857 struct ixgbe_hw *hw =
1858 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1861 PMD_INIT_FUNC_TRACE();
1863 if (hw->mac.type == ixgbe_mac_82598EB) {
1864 /* No queue level support */
1865 PMD_INIT_LOG(NOTICE, "82598EB not support queue level hw strip");
1869 /* Other 10G NIC, the VLAN strip can be setup per queue in RXDCTL */
1870 ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(queue));
1871 ctrl &= ~IXGBE_RXDCTL_VME;
1872 IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(queue), ctrl);
1874 /* record those setting for HW strip per queue */
1875 ixgbe_vlan_hw_strip_bitmap_set(dev, queue, 0);
1879 ixgbe_vlan_hw_strip_enable(struct rte_eth_dev *dev, uint16_t queue)
1881 struct ixgbe_hw *hw =
1882 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1885 PMD_INIT_FUNC_TRACE();
1887 if (hw->mac.type == ixgbe_mac_82598EB) {
1888 /* No queue level supported */
1889 PMD_INIT_LOG(NOTICE, "82598EB not support queue level hw strip");
1893 /* Other 10G NIC, the VLAN strip can be setup per queue in RXDCTL */
1894 ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(queue));
1895 ctrl |= IXGBE_RXDCTL_VME;
1896 IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(queue), ctrl);
1898 /* record those setting for HW strip per queue */
1899 ixgbe_vlan_hw_strip_bitmap_set(dev, queue, 1);
1903 ixgbe_vlan_hw_strip_disable_all(struct rte_eth_dev *dev)
1905 struct ixgbe_hw *hw =
1906 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1909 struct ixgbe_rx_queue *rxq;
1911 PMD_INIT_FUNC_TRACE();
1913 if (hw->mac.type == ixgbe_mac_82598EB) {
1914 ctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
1915 ctrl &= ~IXGBE_VLNCTRL_VME;
1916 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, ctrl);
1918 /* Other 10G NIC, the VLAN strip can be setup per queue in RXDCTL */
1919 for (i = 0; i < dev->data->nb_rx_queues; i++) {
1920 rxq = dev->data->rx_queues[i];
1921 ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(rxq->reg_idx));
1922 ctrl &= ~IXGBE_RXDCTL_VME;
1923 IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(rxq->reg_idx), ctrl);
1925 /* record those setting for HW strip per queue */
1926 ixgbe_vlan_hw_strip_bitmap_set(dev, i, 0);
1932 ixgbe_vlan_hw_strip_enable_all(struct rte_eth_dev *dev)
1934 struct ixgbe_hw *hw =
1935 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1938 struct ixgbe_rx_queue *rxq;
1940 PMD_INIT_FUNC_TRACE();
1942 if (hw->mac.type == ixgbe_mac_82598EB) {
1943 ctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
1944 ctrl |= IXGBE_VLNCTRL_VME;
1945 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, ctrl);
1947 /* Other 10G NIC, the VLAN strip can be setup per queue in RXDCTL */
1948 for (i = 0; i < dev->data->nb_rx_queues; i++) {
1949 rxq = dev->data->rx_queues[i];
1950 ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(rxq->reg_idx));
1951 ctrl |= IXGBE_RXDCTL_VME;
1952 IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(rxq->reg_idx), ctrl);
1954 /* record those setting for HW strip per queue */
1955 ixgbe_vlan_hw_strip_bitmap_set(dev, i, 1);
1961 ixgbe_vlan_hw_extend_disable(struct rte_eth_dev *dev)
1963 struct ixgbe_hw *hw =
1964 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1967 PMD_INIT_FUNC_TRACE();
1969 /* DMATXCTRL: Geric Double VLAN Disable */
1970 ctrl = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
1971 ctrl &= ~IXGBE_DMATXCTL_GDV;
1972 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, ctrl);
1974 /* CTRL_EXT: Global Double VLAN Disable */
1975 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
1976 ctrl &= ~IXGBE_EXTENDED_VLAN;
1977 IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl);
1982 ixgbe_vlan_hw_extend_enable(struct rte_eth_dev *dev)
1984 struct ixgbe_hw *hw =
1985 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1988 PMD_INIT_FUNC_TRACE();
1990 /* DMATXCTRL: Geric Double VLAN Enable */
1991 ctrl = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
1992 ctrl |= IXGBE_DMATXCTL_GDV;
1993 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, ctrl);
1995 /* CTRL_EXT: Global Double VLAN Enable */
1996 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
1997 ctrl |= IXGBE_EXTENDED_VLAN;
1998 IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl);
2000 /* Clear pooling mode of PFVTCTL. It's required by X550. */
2001 if (hw->mac.type == ixgbe_mac_X550 ||
2002 hw->mac.type == ixgbe_mac_X550EM_x ||
2003 hw->mac.type == ixgbe_mac_X550EM_a) {
2004 ctrl = IXGBE_READ_REG(hw, IXGBE_VT_CTL);
2005 ctrl &= ~IXGBE_VT_CTL_POOLING_MODE_MASK;
2006 IXGBE_WRITE_REG(hw, IXGBE_VT_CTL, ctrl);
2010 * VET EXT field in the EXVET register = 0x8100 by default
2011 * So no need to change. Same to VT field of DMATXCTL register
2016 ixgbe_vlan_offload_set(struct rte_eth_dev *dev, int mask)
2018 if (mask & ETH_VLAN_STRIP_MASK) {
2019 if (dev->data->dev_conf.rxmode.hw_vlan_strip)
2020 ixgbe_vlan_hw_strip_enable_all(dev);
2022 ixgbe_vlan_hw_strip_disable_all(dev);
2025 if (mask & ETH_VLAN_FILTER_MASK) {
2026 if (dev->data->dev_conf.rxmode.hw_vlan_filter)
2027 ixgbe_vlan_hw_filter_enable(dev);
2029 ixgbe_vlan_hw_filter_disable(dev);
2032 if (mask & ETH_VLAN_EXTEND_MASK) {
2033 if (dev->data->dev_conf.rxmode.hw_vlan_extend)
2034 ixgbe_vlan_hw_extend_enable(dev);
2036 ixgbe_vlan_hw_extend_disable(dev);
2041 ixgbe_vmdq_vlan_hw_filter_enable(struct rte_eth_dev *dev)
2043 struct ixgbe_hw *hw =
2044 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2045 /* VLNCTRL: enable vlan filtering and allow all vlan tags through */
2046 uint32_t vlanctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
2048 vlanctrl |= IXGBE_VLNCTRL_VFE; /* enable vlan filters */
2049 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlanctrl);
2053 ixgbe_check_vf_rss_rxq_num(struct rte_eth_dev *dev, uint16_t nb_rx_q)
2055 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
2060 RTE_ETH_DEV_SRIOV(dev).active = ETH_64_POOLS;
2063 RTE_ETH_DEV_SRIOV(dev).active = ETH_32_POOLS;
2069 RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool = nb_rx_q;
2070 RTE_ETH_DEV_SRIOV(dev).def_pool_q_idx = pci_dev->max_vfs * nb_rx_q;
2076 ixgbe_check_mq_mode(struct rte_eth_dev *dev)
2078 struct rte_eth_conf *dev_conf = &dev->data->dev_conf;
2079 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2080 uint16_t nb_rx_q = dev->data->nb_rx_queues;
2081 uint16_t nb_tx_q = dev->data->nb_tx_queues;
2083 if (RTE_ETH_DEV_SRIOV(dev).active != 0) {
2084 /* check multi-queue mode */
2085 switch (dev_conf->rxmode.mq_mode) {
2086 case ETH_MQ_RX_VMDQ_DCB:
2087 PMD_INIT_LOG(INFO, "ETH_MQ_RX_VMDQ_DCB mode supported in SRIOV");
2089 case ETH_MQ_RX_VMDQ_DCB_RSS:
2090 /* DCB/RSS VMDQ in SRIOV mode, not implement yet */
2091 PMD_INIT_LOG(ERR, "SRIOV active,"
2092 " unsupported mq_mode rx %d.",
2093 dev_conf->rxmode.mq_mode);
2096 case ETH_MQ_RX_VMDQ_RSS:
2097 dev->data->dev_conf.rxmode.mq_mode = ETH_MQ_RX_VMDQ_RSS;
2098 if (nb_rx_q <= RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool)
2099 if (ixgbe_check_vf_rss_rxq_num(dev, nb_rx_q)) {
2100 PMD_INIT_LOG(ERR, "SRIOV is active,"
2101 " invalid queue number"
2102 " for VMDQ RSS, allowed"
2103 " value are 1, 2 or 4.");
2107 case ETH_MQ_RX_VMDQ_ONLY:
2108 case ETH_MQ_RX_NONE:
2109 /* if nothing mq mode configure, use default scheme */
2110 dev->data->dev_conf.rxmode.mq_mode = ETH_MQ_RX_VMDQ_ONLY;
2111 if (RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool > 1)
2112 RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool = 1;
2114 default: /* ETH_MQ_RX_DCB, ETH_MQ_RX_DCB_RSS or ETH_MQ_TX_DCB*/
2115 /* SRIOV only works in VMDq enable mode */
2116 PMD_INIT_LOG(ERR, "SRIOV is active,"
2117 " wrong mq_mode rx %d.",
2118 dev_conf->rxmode.mq_mode);
2122 switch (dev_conf->txmode.mq_mode) {
2123 case ETH_MQ_TX_VMDQ_DCB:
2124 PMD_INIT_LOG(INFO, "ETH_MQ_TX_VMDQ_DCB mode supported in SRIOV");
2125 dev->data->dev_conf.txmode.mq_mode = ETH_MQ_TX_VMDQ_DCB;
2127 default: /* ETH_MQ_TX_VMDQ_ONLY or ETH_MQ_TX_NONE */
2128 dev->data->dev_conf.txmode.mq_mode = ETH_MQ_TX_VMDQ_ONLY;
2132 /* check valid queue number */
2133 if ((nb_rx_q > RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool) ||
2134 (nb_tx_q > RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool)) {
2135 PMD_INIT_LOG(ERR, "SRIOV is active,"
2136 " nb_rx_q=%d nb_tx_q=%d queue number"
2137 " must be less than or equal to %d.",
2139 RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool);
2143 if (dev_conf->rxmode.mq_mode == ETH_MQ_RX_VMDQ_DCB_RSS) {
2144 PMD_INIT_LOG(ERR, "VMDQ+DCB+RSS mq_mode is"
2148 /* check configuration for vmdb+dcb mode */
2149 if (dev_conf->rxmode.mq_mode == ETH_MQ_RX_VMDQ_DCB) {
2150 const struct rte_eth_vmdq_dcb_conf *conf;
2152 if (nb_rx_q != IXGBE_VMDQ_DCB_NB_QUEUES) {
2153 PMD_INIT_LOG(ERR, "VMDQ+DCB, nb_rx_q != %d.",
2154 IXGBE_VMDQ_DCB_NB_QUEUES);
2157 conf = &dev_conf->rx_adv_conf.vmdq_dcb_conf;
2158 if (!(conf->nb_queue_pools == ETH_16_POOLS ||
2159 conf->nb_queue_pools == ETH_32_POOLS)) {
2160 PMD_INIT_LOG(ERR, "VMDQ+DCB selected,"
2161 " nb_queue_pools must be %d or %d.",
2162 ETH_16_POOLS, ETH_32_POOLS);
2166 if (dev_conf->txmode.mq_mode == ETH_MQ_TX_VMDQ_DCB) {
2167 const struct rte_eth_vmdq_dcb_tx_conf *conf;
2169 if (nb_tx_q != IXGBE_VMDQ_DCB_NB_QUEUES) {
2170 PMD_INIT_LOG(ERR, "VMDQ+DCB, nb_tx_q != %d",
2171 IXGBE_VMDQ_DCB_NB_QUEUES);
2174 conf = &dev_conf->tx_adv_conf.vmdq_dcb_tx_conf;
2175 if (!(conf->nb_queue_pools == ETH_16_POOLS ||
2176 conf->nb_queue_pools == ETH_32_POOLS)) {
2177 PMD_INIT_LOG(ERR, "VMDQ+DCB selected,"
2178 " nb_queue_pools != %d and"
2179 " nb_queue_pools != %d.",
2180 ETH_16_POOLS, ETH_32_POOLS);
2185 /* For DCB mode check our configuration before we go further */
2186 if (dev_conf->rxmode.mq_mode == ETH_MQ_RX_DCB) {
2187 const struct rte_eth_dcb_rx_conf *conf;
2189 if (nb_rx_q != IXGBE_DCB_NB_QUEUES) {
2190 PMD_INIT_LOG(ERR, "DCB selected, nb_rx_q != %d.",
2191 IXGBE_DCB_NB_QUEUES);
2194 conf = &dev_conf->rx_adv_conf.dcb_rx_conf;
2195 if (!(conf->nb_tcs == ETH_4_TCS ||
2196 conf->nb_tcs == ETH_8_TCS)) {
2197 PMD_INIT_LOG(ERR, "DCB selected, nb_tcs != %d"
2198 " and nb_tcs != %d.",
2199 ETH_4_TCS, ETH_8_TCS);
2204 if (dev_conf->txmode.mq_mode == ETH_MQ_TX_DCB) {
2205 const struct rte_eth_dcb_tx_conf *conf;
2207 if (nb_tx_q != IXGBE_DCB_NB_QUEUES) {
2208 PMD_INIT_LOG(ERR, "DCB, nb_tx_q != %d.",
2209 IXGBE_DCB_NB_QUEUES);
2212 conf = &dev_conf->tx_adv_conf.dcb_tx_conf;
2213 if (!(conf->nb_tcs == ETH_4_TCS ||
2214 conf->nb_tcs == ETH_8_TCS)) {
2215 PMD_INIT_LOG(ERR, "DCB selected, nb_tcs != %d"
2216 " and nb_tcs != %d.",
2217 ETH_4_TCS, ETH_8_TCS);
2223 * When DCB/VT is off, maximum number of queues changes,
2224 * except for 82598EB, which remains constant.
2226 if (dev_conf->txmode.mq_mode == ETH_MQ_TX_NONE &&
2227 hw->mac.type != ixgbe_mac_82598EB) {
2228 if (nb_tx_q > IXGBE_NONE_MODE_TX_NB_QUEUES) {
2230 "Neither VT nor DCB are enabled, "
2232 IXGBE_NONE_MODE_TX_NB_QUEUES);
2241 ixgbe_dev_configure(struct rte_eth_dev *dev)
2243 struct ixgbe_interrupt *intr =
2244 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
2245 struct ixgbe_adapter *adapter =
2246 (struct ixgbe_adapter *)dev->data->dev_private;
2249 PMD_INIT_FUNC_TRACE();
2250 /* multipe queue mode checking */
2251 ret = ixgbe_check_mq_mode(dev);
2253 PMD_DRV_LOG(ERR, "ixgbe_check_mq_mode fails with %d.",
2258 /* set flag to update link status after init */
2259 intr->flags |= IXGBE_FLAG_NEED_LINK_UPDATE;
2262 * Initialize to TRUE. If any of Rx queues doesn't meet the bulk
2263 * allocation or vector Rx preconditions we will reset it.
2265 adapter->rx_bulk_alloc_allowed = true;
2266 adapter->rx_vec_allowed = true;
2272 ixgbe_dev_phy_intr_setup(struct rte_eth_dev *dev)
2274 struct ixgbe_hw *hw =
2275 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2276 struct ixgbe_interrupt *intr =
2277 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
2280 /* only set up it on X550EM_X */
2281 if (hw->mac.type == ixgbe_mac_X550EM_x) {
2282 gpie = IXGBE_READ_REG(hw, IXGBE_GPIE);
2283 gpie |= IXGBE_SDP0_GPIEN_X550EM_x;
2284 IXGBE_WRITE_REG(hw, IXGBE_GPIE, gpie);
2285 if (hw->phy.type == ixgbe_phy_x550em_ext_t)
2286 intr->mask |= IXGBE_EICR_GPI_SDP0_X550EM_x;
2291 * Configure device link speed and setup link.
2292 * It returns 0 on success.
2295 ixgbe_dev_start(struct rte_eth_dev *dev)
2297 struct ixgbe_hw *hw =
2298 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2299 struct ixgbe_vf_info *vfinfo =
2300 *IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private);
2301 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
2302 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
2303 uint32_t intr_vector = 0;
2304 int err, link_up = 0, negotiate = 0;
2309 uint32_t *link_speeds;
2311 PMD_INIT_FUNC_TRACE();
2313 /* IXGBE devices don't support:
2314 * - half duplex (checked afterwards for valid speeds)
2315 * - fixed speed: TODO implement
2317 if (dev->data->dev_conf.link_speeds & ETH_LINK_SPEED_FIXED) {
2318 PMD_INIT_LOG(ERR, "Invalid link_speeds for port %hhu; fix speed not supported",
2319 dev->data->port_id);
2323 /* disable uio/vfio intr/eventfd mapping */
2324 rte_intr_disable(intr_handle);
2327 hw->adapter_stopped = 0;
2328 ixgbe_stop_adapter(hw);
2330 /* reinitialize adapter
2331 * this calls reset and start
2333 status = ixgbe_pf_reset_hw(hw);
2336 hw->mac.ops.start_hw(hw);
2337 hw->mac.get_link_status = true;
2339 /* configure PF module if SRIOV enabled */
2340 ixgbe_pf_host_configure(dev);
2342 ixgbe_dev_phy_intr_setup(dev);
2344 /* check and configure queue intr-vector mapping */
2345 if ((rte_intr_cap_multiple(intr_handle) ||
2346 !RTE_ETH_DEV_SRIOV(dev).active) &&
2347 dev->data->dev_conf.intr_conf.rxq != 0) {
2348 intr_vector = dev->data->nb_rx_queues;
2349 if (intr_vector > IXGBE_MAX_INTR_QUEUE_NUM) {
2350 PMD_INIT_LOG(ERR, "At most %d intr queues supported",
2351 IXGBE_MAX_INTR_QUEUE_NUM);
2354 if (rte_intr_efd_enable(intr_handle, intr_vector))
2358 if (rte_intr_dp_is_en(intr_handle) && !intr_handle->intr_vec) {
2359 intr_handle->intr_vec =
2360 rte_zmalloc("intr_vec",
2361 dev->data->nb_rx_queues * sizeof(int), 0);
2362 if (intr_handle->intr_vec == NULL) {
2363 PMD_INIT_LOG(ERR, "Failed to allocate %d rx_queues"
2364 " intr_vec\n", dev->data->nb_rx_queues);
2369 /* confiugre msix for sleep until rx interrupt */
2370 ixgbe_configure_msix(dev);
2372 /* initialize transmission unit */
2373 ixgbe_dev_tx_init(dev);
2375 /* This can fail when allocating mbufs for descriptor rings */
2376 err = ixgbe_dev_rx_init(dev);
2378 PMD_INIT_LOG(ERR, "Unable to initialize RX hardware");
2382 mask = ETH_VLAN_STRIP_MASK | ETH_VLAN_FILTER_MASK |
2383 ETH_VLAN_EXTEND_MASK;
2384 ixgbe_vlan_offload_set(dev, mask);
2386 if (dev->data->dev_conf.rxmode.mq_mode == ETH_MQ_RX_VMDQ_ONLY) {
2387 /* Enable vlan filtering for VMDq */
2388 ixgbe_vmdq_vlan_hw_filter_enable(dev);
2391 /* Configure DCB hw */
2392 ixgbe_configure_dcb(dev);
2394 if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_NONE) {
2395 err = ixgbe_fdir_configure(dev);
2400 /* Restore vf rate limit */
2401 if (vfinfo != NULL) {
2402 for (vf = 0; vf < pci_dev->max_vfs; vf++)
2403 for (idx = 0; idx < IXGBE_MAX_QUEUE_NUM_PER_VF; idx++)
2404 if (vfinfo[vf].tx_rate[idx] != 0)
2405 rte_pmd_ixgbe_set_vf_rate_limit(
2406 dev->data->port_id, vf,
2407 vfinfo[vf].tx_rate[idx],
2411 ixgbe_restore_statistics_mapping(dev);
2413 err = ixgbe_dev_rxtx_start(dev);
2415 PMD_INIT_LOG(ERR, "Unable to start rxtx queues");
2419 /* Skip link setup if loopback mode is enabled for 82599. */
2420 if (hw->mac.type == ixgbe_mac_82599EB &&
2421 dev->data->dev_conf.lpbk_mode == IXGBE_LPBK_82599_TX_RX)
2422 goto skip_link_setup;
2424 if (ixgbe_is_sfp(hw) && hw->phy.multispeed_fiber) {
2425 err = hw->mac.ops.setup_sfp(hw);
2430 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper) {
2431 /* Turn on the copper */
2432 ixgbe_set_phy_power(hw, true);
2434 /* Turn on the laser */
2435 ixgbe_enable_tx_laser(hw);
2438 err = ixgbe_check_link(hw, &speed, &link_up, 0);
2441 dev->data->dev_link.link_status = link_up;
2443 err = ixgbe_get_link_capabilities(hw, &speed, &negotiate);
2447 link_speeds = &dev->data->dev_conf.link_speeds;
2448 if (*link_speeds & ~(ETH_LINK_SPEED_100M | ETH_LINK_SPEED_1G |
2449 ETH_LINK_SPEED_10G)) {
2450 PMD_INIT_LOG(ERR, "Invalid link setting");
2455 if (*link_speeds == ETH_LINK_SPEED_AUTONEG) {
2456 speed = (hw->mac.type != ixgbe_mac_82598EB) ?
2457 IXGBE_LINK_SPEED_82599_AUTONEG :
2458 IXGBE_LINK_SPEED_82598_AUTONEG;
2460 if (*link_speeds & ETH_LINK_SPEED_10G)
2461 speed |= IXGBE_LINK_SPEED_10GB_FULL;
2462 if (*link_speeds & ETH_LINK_SPEED_1G)
2463 speed |= IXGBE_LINK_SPEED_1GB_FULL;
2464 if (*link_speeds & ETH_LINK_SPEED_100M)
2465 speed |= IXGBE_LINK_SPEED_100_FULL;
2468 err = ixgbe_setup_link(hw, speed, link_up);
2474 if (rte_intr_allow_others(intr_handle)) {
2475 /* check if lsc interrupt is enabled */
2476 if (dev->data->dev_conf.intr_conf.lsc != 0)
2477 ixgbe_dev_lsc_interrupt_setup(dev);
2478 ixgbe_dev_macsec_interrupt_setup(dev);
2480 rte_intr_callback_unregister(intr_handle,
2481 ixgbe_dev_interrupt_handler, dev);
2482 if (dev->data->dev_conf.intr_conf.lsc != 0)
2483 PMD_INIT_LOG(INFO, "lsc won't enable because of"
2484 " no intr multiplex\n");
2487 /* check if rxq interrupt is enabled */
2488 if (dev->data->dev_conf.intr_conf.rxq != 0 &&
2489 rte_intr_dp_is_en(intr_handle))
2490 ixgbe_dev_rxq_interrupt_setup(dev);
2492 /* enable uio/vfio intr/eventfd mapping */
2493 rte_intr_enable(intr_handle);
2495 /* resume enabled intr since hw reset */
2496 ixgbe_enable_intr(dev);
2501 PMD_INIT_LOG(ERR, "failure in ixgbe_dev_start(): %d", err);
2502 ixgbe_dev_clear_queues(dev);
2507 * Stop device: disable rx and tx functions to allow for reconfiguring.
2510 ixgbe_dev_stop(struct rte_eth_dev *dev)
2512 struct rte_eth_link link;
2513 struct ixgbe_hw *hw =
2514 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2515 struct ixgbe_vf_info *vfinfo =
2516 *IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private);
2517 struct ixgbe_filter_info *filter_info =
2518 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
2519 struct ixgbe_5tuple_filter *p_5tuple, *p_5tuple_next;
2520 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
2521 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
2524 PMD_INIT_FUNC_TRACE();
2526 /* disable interrupts */
2527 ixgbe_disable_intr(hw);
2530 ixgbe_pf_reset_hw(hw);
2531 hw->adapter_stopped = 0;
2534 ixgbe_stop_adapter(hw);
2536 for (vf = 0; vfinfo != NULL && vf < pci_dev->max_vfs; vf++)
2537 vfinfo[vf].clear_to_send = false;
2539 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper) {
2540 /* Turn off the copper */
2541 ixgbe_set_phy_power(hw, false);
2543 /* Turn off the laser */
2544 ixgbe_disable_tx_laser(hw);
2547 ixgbe_dev_clear_queues(dev);
2549 /* Clear stored conf */
2550 dev->data->scattered_rx = 0;
2553 /* Clear recorded link status */
2554 memset(&link, 0, sizeof(link));
2555 rte_ixgbe_dev_atomic_write_link_status(dev, &link);
2557 /* Remove all ntuple filters of the device */
2558 for (p_5tuple = TAILQ_FIRST(&filter_info->fivetuple_list);
2559 p_5tuple != NULL; p_5tuple = p_5tuple_next) {
2560 p_5tuple_next = TAILQ_NEXT(p_5tuple, entries);
2561 TAILQ_REMOVE(&filter_info->fivetuple_list,
2565 memset(filter_info->fivetuple_mask, 0,
2566 sizeof(uint32_t) * IXGBE_5TUPLE_ARRAY_SIZE);
2568 if (!rte_intr_allow_others(intr_handle))
2569 /* resume to the default handler */
2570 rte_intr_callback_register(intr_handle,
2571 ixgbe_dev_interrupt_handler,
2574 /* Clean datapath event and queue/vec mapping */
2575 rte_intr_efd_disable(intr_handle);
2576 if (intr_handle->intr_vec != NULL) {
2577 rte_free(intr_handle->intr_vec);
2578 intr_handle->intr_vec = NULL;
2583 * Set device link up: enable tx.
2586 ixgbe_dev_set_link_up(struct rte_eth_dev *dev)
2588 struct ixgbe_hw *hw =
2589 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2590 if (hw->mac.type == ixgbe_mac_82599EB) {
2591 #ifdef RTE_NIC_BYPASS
2592 if (hw->device_id == IXGBE_DEV_ID_82599_BYPASS) {
2593 /* Not suported in bypass mode */
2594 PMD_INIT_LOG(ERR, "Set link up is not supported "
2595 "by device id 0x%x", hw->device_id);
2601 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper) {
2602 /* Turn on the copper */
2603 ixgbe_set_phy_power(hw, true);
2605 /* Turn on the laser */
2606 ixgbe_enable_tx_laser(hw);
2613 * Set device link down: disable tx.
2616 ixgbe_dev_set_link_down(struct rte_eth_dev *dev)
2618 struct ixgbe_hw *hw =
2619 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2620 if (hw->mac.type == ixgbe_mac_82599EB) {
2621 #ifdef RTE_NIC_BYPASS
2622 if (hw->device_id == IXGBE_DEV_ID_82599_BYPASS) {
2623 /* Not suported in bypass mode */
2624 PMD_INIT_LOG(ERR, "Set link down is not supported "
2625 "by device id 0x%x", hw->device_id);
2631 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper) {
2632 /* Turn off the copper */
2633 ixgbe_set_phy_power(hw, false);
2635 /* Turn off the laser */
2636 ixgbe_disable_tx_laser(hw);
2643 * Reest and stop device.
2646 ixgbe_dev_close(struct rte_eth_dev *dev)
2648 struct ixgbe_hw *hw =
2649 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2651 PMD_INIT_FUNC_TRACE();
2653 ixgbe_pf_reset_hw(hw);
2655 ixgbe_dev_stop(dev);
2656 hw->adapter_stopped = 1;
2658 ixgbe_dev_free_queues(dev);
2660 ixgbe_disable_pcie_master(hw);
2662 /* reprogram the RAR[0] in case user changed it. */
2663 ixgbe_set_rar(hw, 0, hw->mac.addr, 0, IXGBE_RAH_AV);
2667 ixgbe_read_stats_registers(struct ixgbe_hw *hw,
2668 struct ixgbe_hw_stats *hw_stats,
2669 struct ixgbe_macsec_stats *macsec_stats,
2670 uint64_t *total_missed_rx, uint64_t *total_qbrc,
2671 uint64_t *total_qprc, uint64_t *total_qprdc)
2673 uint32_t bprc, lxon, lxoff, total;
2674 uint32_t delta_gprc = 0;
2676 /* Workaround for RX byte count not including CRC bytes when CRC
2677 * strip is enabled. CRC bytes are removed from counters when crc_strip
2680 int crc_strip = (IXGBE_READ_REG(hw, IXGBE_HLREG0) &
2681 IXGBE_HLREG0_RXCRCSTRP);
2683 hw_stats->crcerrs += IXGBE_READ_REG(hw, IXGBE_CRCERRS);
2684 hw_stats->illerrc += IXGBE_READ_REG(hw, IXGBE_ILLERRC);
2685 hw_stats->errbc += IXGBE_READ_REG(hw, IXGBE_ERRBC);
2686 hw_stats->mspdc += IXGBE_READ_REG(hw, IXGBE_MSPDC);
2688 for (i = 0; i < 8; i++) {
2689 uint32_t mp = IXGBE_READ_REG(hw, IXGBE_MPC(i));
2691 /* global total per queue */
2692 hw_stats->mpc[i] += mp;
2693 /* Running comprehensive total for stats display */
2694 *total_missed_rx += hw_stats->mpc[i];
2695 if (hw->mac.type == ixgbe_mac_82598EB) {
2696 hw_stats->rnbc[i] +=
2697 IXGBE_READ_REG(hw, IXGBE_RNBC(i));
2698 hw_stats->pxonrxc[i] +=
2699 IXGBE_READ_REG(hw, IXGBE_PXONRXC(i));
2700 hw_stats->pxoffrxc[i] +=
2701 IXGBE_READ_REG(hw, IXGBE_PXOFFRXC(i));
2703 hw_stats->pxonrxc[i] +=
2704 IXGBE_READ_REG(hw, IXGBE_PXONRXCNT(i));
2705 hw_stats->pxoffrxc[i] +=
2706 IXGBE_READ_REG(hw, IXGBE_PXOFFRXCNT(i));
2707 hw_stats->pxon2offc[i] +=
2708 IXGBE_READ_REG(hw, IXGBE_PXON2OFFCNT(i));
2710 hw_stats->pxontxc[i] +=
2711 IXGBE_READ_REG(hw, IXGBE_PXONTXC(i));
2712 hw_stats->pxofftxc[i] +=
2713 IXGBE_READ_REG(hw, IXGBE_PXOFFTXC(i));
2715 for (i = 0; i < IXGBE_QUEUE_STAT_COUNTERS; i++) {
2716 uint32_t delta_qprc = IXGBE_READ_REG(hw, IXGBE_QPRC(i));
2717 uint32_t delta_qptc = IXGBE_READ_REG(hw, IXGBE_QPTC(i));
2718 uint32_t delta_qprdc = IXGBE_READ_REG(hw, IXGBE_QPRDC(i));
2720 delta_gprc += delta_qprc;
2722 hw_stats->qprc[i] += delta_qprc;
2723 hw_stats->qptc[i] += delta_qptc;
2725 hw_stats->qbrc[i] += IXGBE_READ_REG(hw, IXGBE_QBRC_L(i));
2726 hw_stats->qbrc[i] +=
2727 ((uint64_t)IXGBE_READ_REG(hw, IXGBE_QBRC_H(i)) << 32);
2729 hw_stats->qbrc[i] -= delta_qprc * ETHER_CRC_LEN;
2731 hw_stats->qbtc[i] += IXGBE_READ_REG(hw, IXGBE_QBTC_L(i));
2732 hw_stats->qbtc[i] +=
2733 ((uint64_t)IXGBE_READ_REG(hw, IXGBE_QBTC_H(i)) << 32);
2735 hw_stats->qprdc[i] += delta_qprdc;
2736 *total_qprdc += hw_stats->qprdc[i];
2738 *total_qprc += hw_stats->qprc[i];
2739 *total_qbrc += hw_stats->qbrc[i];
2741 hw_stats->mlfc += IXGBE_READ_REG(hw, IXGBE_MLFC);
2742 hw_stats->mrfc += IXGBE_READ_REG(hw, IXGBE_MRFC);
2743 hw_stats->rlec += IXGBE_READ_REG(hw, IXGBE_RLEC);
2746 * An errata states that gprc actually counts good + missed packets:
2747 * Workaround to set gprc to summated queue packet receives
2749 hw_stats->gprc = *total_qprc;
2751 if (hw->mac.type != ixgbe_mac_82598EB) {
2752 hw_stats->gorc += IXGBE_READ_REG(hw, IXGBE_GORCL);
2753 hw_stats->gorc += ((u64)IXGBE_READ_REG(hw, IXGBE_GORCH) << 32);
2754 hw_stats->gotc += IXGBE_READ_REG(hw, IXGBE_GOTCL);
2755 hw_stats->gotc += ((u64)IXGBE_READ_REG(hw, IXGBE_GOTCH) << 32);
2756 hw_stats->tor += IXGBE_READ_REG(hw, IXGBE_TORL);
2757 hw_stats->tor += ((u64)IXGBE_READ_REG(hw, IXGBE_TORH) << 32);
2758 hw_stats->lxonrxc += IXGBE_READ_REG(hw, IXGBE_LXONRXCNT);
2759 hw_stats->lxoffrxc += IXGBE_READ_REG(hw, IXGBE_LXOFFRXCNT);
2761 hw_stats->lxonrxc += IXGBE_READ_REG(hw, IXGBE_LXONRXC);
2762 hw_stats->lxoffrxc += IXGBE_READ_REG(hw, IXGBE_LXOFFRXC);
2763 /* 82598 only has a counter in the high register */
2764 hw_stats->gorc += IXGBE_READ_REG(hw, IXGBE_GORCH);
2765 hw_stats->gotc += IXGBE_READ_REG(hw, IXGBE_GOTCH);
2766 hw_stats->tor += IXGBE_READ_REG(hw, IXGBE_TORH);
2768 uint64_t old_tpr = hw_stats->tpr;
2770 hw_stats->tpr += IXGBE_READ_REG(hw, IXGBE_TPR);
2771 hw_stats->tpt += IXGBE_READ_REG(hw, IXGBE_TPT);
2774 hw_stats->gorc -= delta_gprc * ETHER_CRC_LEN;
2776 uint64_t delta_gptc = IXGBE_READ_REG(hw, IXGBE_GPTC);
2777 hw_stats->gptc += delta_gptc;
2778 hw_stats->gotc -= delta_gptc * ETHER_CRC_LEN;
2779 hw_stats->tor -= (hw_stats->tpr - old_tpr) * ETHER_CRC_LEN;
2782 * Workaround: mprc hardware is incorrectly counting
2783 * broadcasts, so for now we subtract those.
2785 bprc = IXGBE_READ_REG(hw, IXGBE_BPRC);
2786 hw_stats->bprc += bprc;
2787 hw_stats->mprc += IXGBE_READ_REG(hw, IXGBE_MPRC);
2788 if (hw->mac.type == ixgbe_mac_82598EB)
2789 hw_stats->mprc -= bprc;
2791 hw_stats->prc64 += IXGBE_READ_REG(hw, IXGBE_PRC64);
2792 hw_stats->prc127 += IXGBE_READ_REG(hw, IXGBE_PRC127);
2793 hw_stats->prc255 += IXGBE_READ_REG(hw, IXGBE_PRC255);
2794 hw_stats->prc511 += IXGBE_READ_REG(hw, IXGBE_PRC511);
2795 hw_stats->prc1023 += IXGBE_READ_REG(hw, IXGBE_PRC1023);
2796 hw_stats->prc1522 += IXGBE_READ_REG(hw, IXGBE_PRC1522);
2798 lxon = IXGBE_READ_REG(hw, IXGBE_LXONTXC);
2799 hw_stats->lxontxc += lxon;
2800 lxoff = IXGBE_READ_REG(hw, IXGBE_LXOFFTXC);
2801 hw_stats->lxofftxc += lxoff;
2802 total = lxon + lxoff;
2804 hw_stats->mptc += IXGBE_READ_REG(hw, IXGBE_MPTC);
2805 hw_stats->ptc64 += IXGBE_READ_REG(hw, IXGBE_PTC64);
2806 hw_stats->gptc -= total;
2807 hw_stats->mptc -= total;
2808 hw_stats->ptc64 -= total;
2809 hw_stats->gotc -= total * ETHER_MIN_LEN;
2811 hw_stats->ruc += IXGBE_READ_REG(hw, IXGBE_RUC);
2812 hw_stats->rfc += IXGBE_READ_REG(hw, IXGBE_RFC);
2813 hw_stats->roc += IXGBE_READ_REG(hw, IXGBE_ROC);
2814 hw_stats->rjc += IXGBE_READ_REG(hw, IXGBE_RJC);
2815 hw_stats->mngprc += IXGBE_READ_REG(hw, IXGBE_MNGPRC);
2816 hw_stats->mngpdc += IXGBE_READ_REG(hw, IXGBE_MNGPDC);
2817 hw_stats->mngptc += IXGBE_READ_REG(hw, IXGBE_MNGPTC);
2818 hw_stats->ptc127 += IXGBE_READ_REG(hw, IXGBE_PTC127);
2819 hw_stats->ptc255 += IXGBE_READ_REG(hw, IXGBE_PTC255);
2820 hw_stats->ptc511 += IXGBE_READ_REG(hw, IXGBE_PTC511);
2821 hw_stats->ptc1023 += IXGBE_READ_REG(hw, IXGBE_PTC1023);
2822 hw_stats->ptc1522 += IXGBE_READ_REG(hw, IXGBE_PTC1522);
2823 hw_stats->bptc += IXGBE_READ_REG(hw, IXGBE_BPTC);
2824 hw_stats->xec += IXGBE_READ_REG(hw, IXGBE_XEC);
2825 hw_stats->fccrc += IXGBE_READ_REG(hw, IXGBE_FCCRC);
2826 hw_stats->fclast += IXGBE_READ_REG(hw, IXGBE_FCLAST);
2827 /* Only read FCOE on 82599 */
2828 if (hw->mac.type != ixgbe_mac_82598EB) {
2829 hw_stats->fcoerpdc += IXGBE_READ_REG(hw, IXGBE_FCOERPDC);
2830 hw_stats->fcoeprc += IXGBE_READ_REG(hw, IXGBE_FCOEPRC);
2831 hw_stats->fcoeptc += IXGBE_READ_REG(hw, IXGBE_FCOEPTC);
2832 hw_stats->fcoedwrc += IXGBE_READ_REG(hw, IXGBE_FCOEDWRC);
2833 hw_stats->fcoedwtc += IXGBE_READ_REG(hw, IXGBE_FCOEDWTC);
2836 /* Flow Director Stats registers */
2837 hw_stats->fdirmatch += IXGBE_READ_REG(hw, IXGBE_FDIRMATCH);
2838 hw_stats->fdirmiss += IXGBE_READ_REG(hw, IXGBE_FDIRMISS);
2840 /* MACsec Stats registers */
2841 macsec_stats->out_pkts_untagged += IXGBE_READ_REG(hw, IXGBE_LSECTXUT);
2842 macsec_stats->out_pkts_encrypted +=
2843 IXGBE_READ_REG(hw, IXGBE_LSECTXPKTE);
2844 macsec_stats->out_pkts_protected +=
2845 IXGBE_READ_REG(hw, IXGBE_LSECTXPKTP);
2846 macsec_stats->out_octets_encrypted +=
2847 IXGBE_READ_REG(hw, IXGBE_LSECTXOCTE);
2848 macsec_stats->out_octets_protected +=
2849 IXGBE_READ_REG(hw, IXGBE_LSECTXOCTP);
2850 macsec_stats->in_pkts_untagged += IXGBE_READ_REG(hw, IXGBE_LSECRXUT);
2851 macsec_stats->in_pkts_badtag += IXGBE_READ_REG(hw, IXGBE_LSECRXBAD);
2852 macsec_stats->in_pkts_nosci += IXGBE_READ_REG(hw, IXGBE_LSECRXNOSCI);
2853 macsec_stats->in_pkts_unknownsci +=
2854 IXGBE_READ_REG(hw, IXGBE_LSECRXUNSCI);
2855 macsec_stats->in_octets_decrypted +=
2856 IXGBE_READ_REG(hw, IXGBE_LSECRXOCTD);
2857 macsec_stats->in_octets_validated +=
2858 IXGBE_READ_REG(hw, IXGBE_LSECRXOCTV);
2859 macsec_stats->in_pkts_unchecked += IXGBE_READ_REG(hw, IXGBE_LSECRXUNCH);
2860 macsec_stats->in_pkts_delayed += IXGBE_READ_REG(hw, IXGBE_LSECRXDELAY);
2861 macsec_stats->in_pkts_late += IXGBE_READ_REG(hw, IXGBE_LSECRXLATE);
2862 for (i = 0; i < 2; i++) {
2863 macsec_stats->in_pkts_ok +=
2864 IXGBE_READ_REG(hw, IXGBE_LSECRXOK(i));
2865 macsec_stats->in_pkts_invalid +=
2866 IXGBE_READ_REG(hw, IXGBE_LSECRXINV(i));
2867 macsec_stats->in_pkts_notvalid +=
2868 IXGBE_READ_REG(hw, IXGBE_LSECRXNV(i));
2870 macsec_stats->in_pkts_unusedsa += IXGBE_READ_REG(hw, IXGBE_LSECRXUNSA);
2871 macsec_stats->in_pkts_notusingsa +=
2872 IXGBE_READ_REG(hw, IXGBE_LSECRXNUSA);
2876 * This function is based on ixgbe_update_stats_counters() in ixgbe/ixgbe.c
2879 ixgbe_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
2881 struct ixgbe_hw *hw =
2882 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2883 struct ixgbe_hw_stats *hw_stats =
2884 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
2885 struct ixgbe_macsec_stats *macsec_stats =
2886 IXGBE_DEV_PRIVATE_TO_MACSEC_STATS(
2887 dev->data->dev_private);
2888 uint64_t total_missed_rx, total_qbrc, total_qprc, total_qprdc;
2891 total_missed_rx = 0;
2896 ixgbe_read_stats_registers(hw, hw_stats, macsec_stats, &total_missed_rx,
2897 &total_qbrc, &total_qprc, &total_qprdc);
2902 /* Fill out the rte_eth_stats statistics structure */
2903 stats->ipackets = total_qprc;
2904 stats->ibytes = total_qbrc;
2905 stats->opackets = hw_stats->gptc;
2906 stats->obytes = hw_stats->gotc;
2908 for (i = 0; i < IXGBE_QUEUE_STAT_COUNTERS; i++) {
2909 stats->q_ipackets[i] = hw_stats->qprc[i];
2910 stats->q_opackets[i] = hw_stats->qptc[i];
2911 stats->q_ibytes[i] = hw_stats->qbrc[i];
2912 stats->q_obytes[i] = hw_stats->qbtc[i];
2913 stats->q_errors[i] = hw_stats->qprdc[i];
2917 stats->imissed = total_missed_rx;
2918 stats->ierrors = hw_stats->crcerrs +
2934 ixgbe_dev_stats_reset(struct rte_eth_dev *dev)
2936 struct ixgbe_hw_stats *stats =
2937 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
2939 /* HW registers are cleared on read */
2940 ixgbe_dev_stats_get(dev, NULL);
2942 /* Reset software totals */
2943 memset(stats, 0, sizeof(*stats));
2946 /* This function calculates the number of xstats based on the current config */
2948 ixgbe_xstats_calc_num(void) {
2949 return IXGBE_NB_HW_STATS + IXGBE_NB_MACSEC_STATS +
2950 (IXGBE_NB_RXQ_PRIO_STATS * IXGBE_NB_RXQ_PRIO_VALUES) +
2951 (IXGBE_NB_TXQ_PRIO_STATS * IXGBE_NB_TXQ_PRIO_VALUES);
2954 static int ixgbe_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
2955 struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned limit)
2957 const unsigned cnt_stats = ixgbe_xstats_calc_num();
2958 unsigned stat, i, count;
2960 if (xstats_names != NULL) {
2963 /* Note: limit >= cnt_stats checked upstream
2964 * in rte_eth_xstats_names()
2967 /* Extended stats from ixgbe_hw_stats */
2968 for (i = 0; i < IXGBE_NB_HW_STATS; i++) {
2969 snprintf(xstats_names[count].name,
2970 sizeof(xstats_names[count].name),
2972 rte_ixgbe_stats_strings[i].name);
2977 for (i = 0; i < IXGBE_NB_MACSEC_STATS; i++) {
2978 snprintf(xstats_names[count].name,
2979 sizeof(xstats_names[count].name),
2981 rte_ixgbe_macsec_strings[i].name);
2985 /* RX Priority Stats */
2986 for (stat = 0; stat < IXGBE_NB_RXQ_PRIO_STATS; stat++) {
2987 for (i = 0; i < IXGBE_NB_RXQ_PRIO_VALUES; i++) {
2988 snprintf(xstats_names[count].name,
2989 sizeof(xstats_names[count].name),
2990 "rx_priority%u_%s", i,
2991 rte_ixgbe_rxq_strings[stat].name);
2996 /* TX Priority Stats */
2997 for (stat = 0; stat < IXGBE_NB_TXQ_PRIO_STATS; stat++) {
2998 for (i = 0; i < IXGBE_NB_TXQ_PRIO_VALUES; i++) {
2999 snprintf(xstats_names[count].name,
3000 sizeof(xstats_names[count].name),
3001 "tx_priority%u_%s", i,
3002 rte_ixgbe_txq_strings[stat].name);
3010 static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
3011 struct rte_eth_xstat_name *xstats_names, unsigned limit)
3015 if (limit < IXGBEVF_NB_XSTATS && xstats_names != NULL)
3018 if (xstats_names != NULL)
3019 for (i = 0; i < IXGBEVF_NB_XSTATS; i++)
3020 snprintf(xstats_names[i].name,
3021 sizeof(xstats_names[i].name),
3022 "%s", rte_ixgbevf_stats_strings[i].name);
3023 return IXGBEVF_NB_XSTATS;
3027 ixgbe_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
3030 struct ixgbe_hw *hw =
3031 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3032 struct ixgbe_hw_stats *hw_stats =
3033 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3034 struct ixgbe_macsec_stats *macsec_stats =
3035 IXGBE_DEV_PRIVATE_TO_MACSEC_STATS(
3036 dev->data->dev_private);
3037 uint64_t total_missed_rx, total_qbrc, total_qprc, total_qprdc;
3038 unsigned i, stat, count = 0;
3040 count = ixgbe_xstats_calc_num();
3045 total_missed_rx = 0;
3050 ixgbe_read_stats_registers(hw, hw_stats, macsec_stats, &total_missed_rx,
3051 &total_qbrc, &total_qprc, &total_qprdc);
3053 /* If this is a reset xstats is NULL, and we have cleared the
3054 * registers by reading them.
3059 /* Extended stats from ixgbe_hw_stats */
3061 for (i = 0; i < IXGBE_NB_HW_STATS; i++) {
3062 xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
3063 rte_ixgbe_stats_strings[i].offset);
3064 xstats[count].id = count;
3069 for (i = 0; i < IXGBE_NB_MACSEC_STATS; i++) {
3070 xstats[count].value = *(uint64_t *)(((char *)macsec_stats) +
3071 rte_ixgbe_macsec_strings[i].offset);
3072 xstats[count].id = count;
3076 /* RX Priority Stats */
3077 for (stat = 0; stat < IXGBE_NB_RXQ_PRIO_STATS; stat++) {
3078 for (i = 0; i < IXGBE_NB_RXQ_PRIO_VALUES; i++) {
3079 xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
3080 rte_ixgbe_rxq_strings[stat].offset +
3081 (sizeof(uint64_t) * i));
3082 xstats[count].id = count;
3087 /* TX Priority Stats */
3088 for (stat = 0; stat < IXGBE_NB_TXQ_PRIO_STATS; stat++) {
3089 for (i = 0; i < IXGBE_NB_TXQ_PRIO_VALUES; i++) {
3090 xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
3091 rte_ixgbe_txq_strings[stat].offset +
3092 (sizeof(uint64_t) * i));
3093 xstats[count].id = count;
3101 ixgbe_dev_xstats_reset(struct rte_eth_dev *dev)
3103 struct ixgbe_hw_stats *stats =
3104 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3105 struct ixgbe_macsec_stats *macsec_stats =
3106 IXGBE_DEV_PRIVATE_TO_MACSEC_STATS(
3107 dev->data->dev_private);
3109 unsigned count = ixgbe_xstats_calc_num();
3111 /* HW registers are cleared on read */
3112 ixgbe_dev_xstats_get(dev, NULL, count);
3114 /* Reset software totals */
3115 memset(stats, 0, sizeof(*stats));
3116 memset(macsec_stats, 0, sizeof(*macsec_stats));
3120 ixgbevf_update_stats(struct rte_eth_dev *dev)
3122 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3123 struct ixgbevf_hw_stats *hw_stats = (struct ixgbevf_hw_stats *)
3124 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3126 /* Good Rx packet, include VF loopback */
3127 UPDATE_VF_STAT(IXGBE_VFGPRC,
3128 hw_stats->last_vfgprc, hw_stats->vfgprc);
3130 /* Good Rx octets, include VF loopback */
3131 UPDATE_VF_STAT_36BIT(IXGBE_VFGORC_LSB, IXGBE_VFGORC_MSB,
3132 hw_stats->last_vfgorc, hw_stats->vfgorc);
3134 /* Good Tx packet, include VF loopback */
3135 UPDATE_VF_STAT(IXGBE_VFGPTC,
3136 hw_stats->last_vfgptc, hw_stats->vfgptc);
3138 /* Good Tx octets, include VF loopback */
3139 UPDATE_VF_STAT_36BIT(IXGBE_VFGOTC_LSB, IXGBE_VFGOTC_MSB,
3140 hw_stats->last_vfgotc, hw_stats->vfgotc);
3142 /* Rx Multicst Packet */
3143 UPDATE_VF_STAT(IXGBE_VFMPRC,
3144 hw_stats->last_vfmprc, hw_stats->vfmprc);
3148 ixgbevf_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
3151 struct ixgbevf_hw_stats *hw_stats = (struct ixgbevf_hw_stats *)
3152 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3155 if (n < IXGBEVF_NB_XSTATS)
3156 return IXGBEVF_NB_XSTATS;
3158 ixgbevf_update_stats(dev);
3163 /* Extended stats */
3164 for (i = 0; i < IXGBEVF_NB_XSTATS; i++) {
3165 xstats[i].value = *(uint64_t *)(((char *)hw_stats) +
3166 rte_ixgbevf_stats_strings[i].offset);
3169 return IXGBEVF_NB_XSTATS;
3173 ixgbevf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
3175 struct ixgbevf_hw_stats *hw_stats = (struct ixgbevf_hw_stats *)
3176 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3178 ixgbevf_update_stats(dev);
3183 stats->ipackets = hw_stats->vfgprc;
3184 stats->ibytes = hw_stats->vfgorc;
3185 stats->opackets = hw_stats->vfgptc;
3186 stats->obytes = hw_stats->vfgotc;
3190 ixgbevf_dev_stats_reset(struct rte_eth_dev *dev)
3192 struct ixgbevf_hw_stats *hw_stats = (struct ixgbevf_hw_stats *)
3193 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3195 /* Sync HW register to the last stats */
3196 ixgbevf_dev_stats_get(dev, NULL);
3198 /* reset HW current stats*/
3199 hw_stats->vfgprc = 0;
3200 hw_stats->vfgorc = 0;
3201 hw_stats->vfgptc = 0;
3202 hw_stats->vfgotc = 0;
3206 ixgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size)
3208 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3209 u16 eeprom_verh, eeprom_verl;
3213 ixgbe_read_eeprom(hw, 0x2e, &eeprom_verh);
3214 ixgbe_read_eeprom(hw, 0x2d, &eeprom_verl);
3216 etrack_id = (eeprom_verh << 16) | eeprom_verl;
3217 ret = snprintf(fw_version, fw_size, "0x%08x", etrack_id);
3219 ret += 1; /* add the size of '\0' */
3220 if (fw_size < (u32)ret)
3227 ixgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
3229 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
3230 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3231 struct rte_eth_conf *dev_conf = &dev->data->dev_conf;
3233 dev_info->pci_dev = pci_dev;
3234 dev_info->max_rx_queues = (uint16_t)hw->mac.max_rx_queues;
3235 dev_info->max_tx_queues = (uint16_t)hw->mac.max_tx_queues;
3236 if (RTE_ETH_DEV_SRIOV(dev).active == 0) {
3238 * When DCB/VT is off, maximum number of queues changes,
3239 * except for 82598EB, which remains constant.
3241 if (dev_conf->txmode.mq_mode == ETH_MQ_TX_NONE &&
3242 hw->mac.type != ixgbe_mac_82598EB)
3243 dev_info->max_tx_queues = IXGBE_NONE_MODE_TX_NB_QUEUES;
3245 dev_info->min_rx_bufsize = 1024; /* cf BSIZEPACKET in SRRCTL register */
3246 dev_info->max_rx_pktlen = 15872; /* includes CRC, cf MAXFRS register */
3247 dev_info->max_mac_addrs = hw->mac.num_rar_entries;
3248 dev_info->max_hash_mac_addrs = IXGBE_VMDQ_NUM_UC_MAC;
3249 dev_info->max_vfs = pci_dev->max_vfs;
3250 if (hw->mac.type == ixgbe_mac_82598EB)
3251 dev_info->max_vmdq_pools = ETH_16_POOLS;
3253 dev_info->max_vmdq_pools = ETH_64_POOLS;
3254 dev_info->vmdq_queue_num = dev_info->max_rx_queues;
3255 dev_info->rx_offload_capa =
3256 DEV_RX_OFFLOAD_VLAN_STRIP |
3257 DEV_RX_OFFLOAD_IPV4_CKSUM |
3258 DEV_RX_OFFLOAD_UDP_CKSUM |
3259 DEV_RX_OFFLOAD_TCP_CKSUM;
3262 * RSC is only supported by 82599 and x540 PF devices in a non-SR-IOV
3265 if ((hw->mac.type == ixgbe_mac_82599EB ||
3266 hw->mac.type == ixgbe_mac_X540) &&
3267 !RTE_ETH_DEV_SRIOV(dev).active)
3268 dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_TCP_LRO;
3270 if (hw->mac.type == ixgbe_mac_82599EB ||
3271 hw->mac.type == ixgbe_mac_X540)
3272 dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_MACSEC_STRIP;
3274 if (hw->mac.type == ixgbe_mac_X550 ||
3275 hw->mac.type == ixgbe_mac_X550EM_x ||
3276 hw->mac.type == ixgbe_mac_X550EM_a)
3277 dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM;
3279 dev_info->tx_offload_capa =
3280 DEV_TX_OFFLOAD_VLAN_INSERT |
3281 DEV_TX_OFFLOAD_IPV4_CKSUM |
3282 DEV_TX_OFFLOAD_UDP_CKSUM |
3283 DEV_TX_OFFLOAD_TCP_CKSUM |
3284 DEV_TX_OFFLOAD_SCTP_CKSUM |
3285 DEV_TX_OFFLOAD_TCP_TSO;
3287 if (hw->mac.type == ixgbe_mac_82599EB ||
3288 hw->mac.type == ixgbe_mac_X540)
3289 dev_info->tx_offload_capa |= DEV_TX_OFFLOAD_MACSEC_INSERT;
3291 if (hw->mac.type == ixgbe_mac_X550 ||
3292 hw->mac.type == ixgbe_mac_X550EM_x ||
3293 hw->mac.type == ixgbe_mac_X550EM_a)
3294 dev_info->tx_offload_capa |= DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
3296 dev_info->default_rxconf = (struct rte_eth_rxconf) {
3298 .pthresh = IXGBE_DEFAULT_RX_PTHRESH,
3299 .hthresh = IXGBE_DEFAULT_RX_HTHRESH,
3300 .wthresh = IXGBE_DEFAULT_RX_WTHRESH,
3302 .rx_free_thresh = IXGBE_DEFAULT_RX_FREE_THRESH,
3306 dev_info->default_txconf = (struct rte_eth_txconf) {
3308 .pthresh = IXGBE_DEFAULT_TX_PTHRESH,
3309 .hthresh = IXGBE_DEFAULT_TX_HTHRESH,
3310 .wthresh = IXGBE_DEFAULT_TX_WTHRESH,
3312 .tx_free_thresh = IXGBE_DEFAULT_TX_FREE_THRESH,
3313 .tx_rs_thresh = IXGBE_DEFAULT_TX_RSBIT_THRESH,
3314 .txq_flags = ETH_TXQ_FLAGS_NOMULTSEGS |
3315 ETH_TXQ_FLAGS_NOOFFLOADS,
3318 dev_info->rx_desc_lim = rx_desc_lim;
3319 dev_info->tx_desc_lim = tx_desc_lim;
3321 dev_info->hash_key_size = IXGBE_HKEY_MAX_INDEX * sizeof(uint32_t);
3322 dev_info->reta_size = ixgbe_reta_size_get(hw->mac.type);
3323 dev_info->flow_type_rss_offloads = IXGBE_RSS_OFFLOAD_ALL;
3325 dev_info->speed_capa = ETH_LINK_SPEED_1G | ETH_LINK_SPEED_10G;
3326 if (hw->mac.type == ixgbe_mac_X540 ||
3327 hw->mac.type == ixgbe_mac_X540_vf ||
3328 hw->mac.type == ixgbe_mac_X550 ||
3329 hw->mac.type == ixgbe_mac_X550_vf) {
3330 dev_info->speed_capa |= ETH_LINK_SPEED_100M;
3334 static const uint32_t *
3335 ixgbe_dev_supported_ptypes_get(struct rte_eth_dev *dev)
3337 static const uint32_t ptypes[] = {
3338 /* For non-vec functions,
3339 * refers to ixgbe_rxd_pkt_info_to_pkt_type();
3340 * for vec functions,
3341 * refers to _recv_raw_pkts_vec().
3345 RTE_PTYPE_L3_IPV4_EXT,
3347 RTE_PTYPE_L3_IPV6_EXT,
3351 RTE_PTYPE_TUNNEL_IP,
3352 RTE_PTYPE_INNER_L3_IPV6,
3353 RTE_PTYPE_INNER_L3_IPV6_EXT,
3354 RTE_PTYPE_INNER_L4_TCP,
3355 RTE_PTYPE_INNER_L4_UDP,
3359 if (dev->rx_pkt_burst == ixgbe_recv_pkts ||
3360 dev->rx_pkt_burst == ixgbe_recv_pkts_lro_single_alloc ||
3361 dev->rx_pkt_burst == ixgbe_recv_pkts_lro_bulk_alloc ||
3362 dev->rx_pkt_burst == ixgbe_recv_pkts_bulk_alloc)
3368 ixgbevf_dev_info_get(struct rte_eth_dev *dev,
3369 struct rte_eth_dev_info *dev_info)
3371 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
3372 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3374 dev_info->pci_dev = pci_dev;
3375 dev_info->max_rx_queues = (uint16_t)hw->mac.max_rx_queues;
3376 dev_info->max_tx_queues = (uint16_t)hw->mac.max_tx_queues;
3377 dev_info->min_rx_bufsize = 1024; /* cf BSIZEPACKET in SRRCTL reg */
3378 dev_info->max_rx_pktlen = 15872; /* includes CRC, cf MAXFRS reg */
3379 dev_info->max_mac_addrs = hw->mac.num_rar_entries;
3380 dev_info->max_hash_mac_addrs = IXGBE_VMDQ_NUM_UC_MAC;
3381 dev_info->max_vfs = pci_dev->max_vfs;
3382 if (hw->mac.type == ixgbe_mac_82598EB)
3383 dev_info->max_vmdq_pools = ETH_16_POOLS;
3385 dev_info->max_vmdq_pools = ETH_64_POOLS;
3386 dev_info->rx_offload_capa = DEV_RX_OFFLOAD_VLAN_STRIP |
3387 DEV_RX_OFFLOAD_IPV4_CKSUM |
3388 DEV_RX_OFFLOAD_UDP_CKSUM |
3389 DEV_RX_OFFLOAD_TCP_CKSUM;
3390 dev_info->tx_offload_capa = DEV_TX_OFFLOAD_VLAN_INSERT |
3391 DEV_TX_OFFLOAD_IPV4_CKSUM |
3392 DEV_TX_OFFLOAD_UDP_CKSUM |
3393 DEV_TX_OFFLOAD_TCP_CKSUM |
3394 DEV_TX_OFFLOAD_SCTP_CKSUM |
3395 DEV_TX_OFFLOAD_TCP_TSO;
3397 dev_info->default_rxconf = (struct rte_eth_rxconf) {
3399 .pthresh = IXGBE_DEFAULT_RX_PTHRESH,
3400 .hthresh = IXGBE_DEFAULT_RX_HTHRESH,
3401 .wthresh = IXGBE_DEFAULT_RX_WTHRESH,
3403 .rx_free_thresh = IXGBE_DEFAULT_RX_FREE_THRESH,
3407 dev_info->default_txconf = (struct rte_eth_txconf) {
3409 .pthresh = IXGBE_DEFAULT_TX_PTHRESH,
3410 .hthresh = IXGBE_DEFAULT_TX_HTHRESH,
3411 .wthresh = IXGBE_DEFAULT_TX_WTHRESH,
3413 .tx_free_thresh = IXGBE_DEFAULT_TX_FREE_THRESH,
3414 .tx_rs_thresh = IXGBE_DEFAULT_TX_RSBIT_THRESH,
3415 .txq_flags = ETH_TXQ_FLAGS_NOMULTSEGS |
3416 ETH_TXQ_FLAGS_NOOFFLOADS,
3419 dev_info->rx_desc_lim = rx_desc_lim;
3420 dev_info->tx_desc_lim = tx_desc_lim;
3423 /* return 0 means link status changed, -1 means not changed */
3425 ixgbe_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
3427 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3428 struct rte_eth_link link, old;
3429 ixgbe_link_speed link_speed = IXGBE_LINK_SPEED_UNKNOWN;
3433 link.link_status = ETH_LINK_DOWN;
3434 link.link_speed = 0;
3435 link.link_duplex = ETH_LINK_HALF_DUPLEX;
3436 memset(&old, 0, sizeof(old));
3437 rte_ixgbe_dev_atomic_read_link_status(dev, &old);
3439 hw->mac.get_link_status = true;
3441 /* check if it needs to wait to complete, if lsc interrupt is enabled */
3442 if (wait_to_complete == 0 || dev->data->dev_conf.intr_conf.lsc != 0)
3443 diag = ixgbe_check_link(hw, &link_speed, &link_up, 0);
3445 diag = ixgbe_check_link(hw, &link_speed, &link_up, 1);
3448 link.link_speed = ETH_SPEED_NUM_100M;
3449 link.link_duplex = ETH_LINK_FULL_DUPLEX;
3450 rte_ixgbe_dev_atomic_write_link_status(dev, &link);
3451 if (link.link_status == old.link_status)
3457 rte_ixgbe_dev_atomic_write_link_status(dev, &link);
3458 if (link.link_status == old.link_status)
3462 link.link_status = ETH_LINK_UP;
3463 link.link_duplex = ETH_LINK_FULL_DUPLEX;
3465 switch (link_speed) {
3467 case IXGBE_LINK_SPEED_UNKNOWN:
3468 link.link_duplex = ETH_LINK_FULL_DUPLEX;
3469 link.link_speed = ETH_SPEED_NUM_100M;
3472 case IXGBE_LINK_SPEED_100_FULL:
3473 link.link_speed = ETH_SPEED_NUM_100M;
3476 case IXGBE_LINK_SPEED_1GB_FULL:
3477 link.link_speed = ETH_SPEED_NUM_1G;
3480 case IXGBE_LINK_SPEED_10GB_FULL:
3481 link.link_speed = ETH_SPEED_NUM_10G;
3484 rte_ixgbe_dev_atomic_write_link_status(dev, &link);
3486 if (link.link_status == old.link_status)
3493 ixgbe_dev_promiscuous_enable(struct rte_eth_dev *dev)
3495 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3498 fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
3499 fctrl |= (IXGBE_FCTRL_UPE | IXGBE_FCTRL_MPE);
3500 IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
3504 ixgbe_dev_promiscuous_disable(struct rte_eth_dev *dev)
3506 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3509 fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
3510 fctrl &= (~IXGBE_FCTRL_UPE);
3511 if (dev->data->all_multicast == 1)
3512 fctrl |= IXGBE_FCTRL_MPE;
3514 fctrl &= (~IXGBE_FCTRL_MPE);
3515 IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
3519 ixgbe_dev_allmulticast_enable(struct rte_eth_dev *dev)
3521 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3524 fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
3525 fctrl |= IXGBE_FCTRL_MPE;
3526 IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
3530 ixgbe_dev_allmulticast_disable(struct rte_eth_dev *dev)
3532 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3535 if (dev->data->promiscuous == 1)
3536 return; /* must remain in all_multicast mode */
3538 fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
3539 fctrl &= (~IXGBE_FCTRL_MPE);
3540 IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
3544 * It clears the interrupt causes and enables the interrupt.
3545 * It will be called once only during nic initialized.
3548 * Pointer to struct rte_eth_dev.
3551 * - On success, zero.
3552 * - On failure, a negative value.
3555 ixgbe_dev_lsc_interrupt_setup(struct rte_eth_dev *dev)
3557 struct ixgbe_interrupt *intr =
3558 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
3560 ixgbe_dev_link_status_print(dev);
3561 intr->mask |= IXGBE_EICR_LSC;
3567 * It clears the interrupt causes and enables the interrupt.
3568 * It will be called once only during nic initialized.
3571 * Pointer to struct rte_eth_dev.
3574 * - On success, zero.
3575 * - On failure, a negative value.
3578 ixgbe_dev_rxq_interrupt_setup(struct rte_eth_dev *dev)
3580 struct ixgbe_interrupt *intr =
3581 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
3583 intr->mask |= IXGBE_EICR_RTX_QUEUE;
3589 * It clears the interrupt causes and enables the interrupt.
3590 * It will be called once only during nic initialized.
3593 * Pointer to struct rte_eth_dev.
3596 * - On success, zero.
3597 * - On failure, a negative value.
3600 ixgbe_dev_macsec_interrupt_setup(struct rte_eth_dev *dev)
3602 struct ixgbe_interrupt *intr =
3603 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
3605 intr->mask |= IXGBE_EICR_LINKSEC;
3611 * It reads ICR and sets flag (IXGBE_EICR_LSC) for the link_update.
3614 * Pointer to struct rte_eth_dev.
3617 * - On success, zero.
3618 * - On failure, a negative value.
3621 ixgbe_dev_interrupt_get_status(struct rte_eth_dev *dev)
3624 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3625 struct ixgbe_interrupt *intr =
3626 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
3628 /* clear all cause mask */
3629 ixgbe_disable_intr(hw);
3631 /* read-on-clear nic registers here */
3632 eicr = IXGBE_READ_REG(hw, IXGBE_EICR);
3633 PMD_DRV_LOG(DEBUG, "eicr %x", eicr);
3637 /* set flag for async link update */
3638 if (eicr & IXGBE_EICR_LSC)
3639 intr->flags |= IXGBE_FLAG_NEED_LINK_UPDATE;
3641 if (eicr & IXGBE_EICR_MAILBOX)
3642 intr->flags |= IXGBE_FLAG_MAILBOX;
3644 if (eicr & IXGBE_EICR_LINKSEC)
3645 intr->flags |= IXGBE_FLAG_MACSEC;
3647 if (hw->mac.type == ixgbe_mac_X550EM_x &&
3648 hw->phy.type == ixgbe_phy_x550em_ext_t &&
3649 (eicr & IXGBE_EICR_GPI_SDP0_X550EM_x))
3650 intr->flags |= IXGBE_FLAG_PHY_INTERRUPT;
3656 * It gets and then prints the link status.
3659 * Pointer to struct rte_eth_dev.
3662 * - On success, zero.
3663 * - On failure, a negative value.
3666 ixgbe_dev_link_status_print(struct rte_eth_dev *dev)
3668 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
3669 struct rte_eth_link link;
3671 memset(&link, 0, sizeof(link));
3672 rte_ixgbe_dev_atomic_read_link_status(dev, &link);
3673 if (link.link_status) {
3674 PMD_INIT_LOG(INFO, "Port %d: Link Up - speed %u Mbps - %s",
3675 (int)(dev->data->port_id),
3676 (unsigned)link.link_speed,
3677 link.link_duplex == ETH_LINK_FULL_DUPLEX ?
3678 "full-duplex" : "half-duplex");
3680 PMD_INIT_LOG(INFO, " Port %d: Link Down",
3681 (int)(dev->data->port_id));
3683 PMD_INIT_LOG(DEBUG, "PCI Address: " PCI_PRI_FMT,
3684 pci_dev->addr.domain,
3686 pci_dev->addr.devid,
3687 pci_dev->addr.function);
3691 * It executes link_update after knowing an interrupt occurred.
3694 * Pointer to struct rte_eth_dev.
3697 * - On success, zero.
3698 * - On failure, a negative value.
3701 ixgbe_dev_interrupt_action(struct rte_eth_dev *dev,
3702 struct rte_intr_handle *intr_handle)
3704 struct ixgbe_interrupt *intr =
3705 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
3707 struct rte_eth_link link;
3708 int intr_enable_delay = false;
3709 struct ixgbe_hw *hw =
3710 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3712 PMD_DRV_LOG(DEBUG, "intr action type %d", intr->flags);
3714 if (intr->flags & IXGBE_FLAG_MAILBOX) {
3715 ixgbe_pf_mbx_process(dev);
3716 intr->flags &= ~IXGBE_FLAG_MAILBOX;
3719 if (intr->flags & IXGBE_FLAG_PHY_INTERRUPT) {
3720 ixgbe_handle_lasi(hw);
3721 intr->flags &= ~IXGBE_FLAG_PHY_INTERRUPT;
3724 if (intr->flags & IXGBE_FLAG_NEED_LINK_UPDATE) {
3725 /* get the link status before link update, for predicting later */
3726 memset(&link, 0, sizeof(link));
3727 rte_ixgbe_dev_atomic_read_link_status(dev, &link);
3729 ixgbe_dev_link_update(dev, 0);
3732 if (!link.link_status)
3733 /* handle it 1 sec later, wait it being stable */
3734 timeout = IXGBE_LINK_UP_CHECK_TIMEOUT;
3735 /* likely to down */
3737 /* handle it 4 sec later, wait it being stable */
3738 timeout = IXGBE_LINK_DOWN_CHECK_TIMEOUT;
3740 ixgbe_dev_link_status_print(dev);
3742 intr_enable_delay = true;
3745 if (intr_enable_delay) {
3746 if (rte_eal_alarm_set(timeout * 1000,
3747 ixgbe_dev_interrupt_delayed_handler, (void *)dev) < 0)
3748 PMD_DRV_LOG(ERR, "Error setting alarm");
3750 PMD_DRV_LOG(DEBUG, "enable intr immediately");
3751 ixgbe_enable_intr(dev);
3752 rte_intr_enable(intr_handle);
3760 * Interrupt handler which shall be registered for alarm callback for delayed
3761 * handling specific interrupt to wait for the stable nic state. As the
3762 * NIC interrupt state is not stable for ixgbe after link is just down,
3763 * it needs to wait 4 seconds to get the stable status.
3766 * Pointer to interrupt handle.
3768 * The address of parameter (struct rte_eth_dev *) regsitered before.
3774 ixgbe_dev_interrupt_delayed_handler(void *param)
3776 struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
3777 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
3778 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
3779 struct ixgbe_interrupt *intr =
3780 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
3781 struct ixgbe_hw *hw =
3782 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3785 eicr = IXGBE_READ_REG(hw, IXGBE_EICR);
3786 if (eicr & IXGBE_EICR_MAILBOX)
3787 ixgbe_pf_mbx_process(dev);
3789 if (intr->flags & IXGBE_FLAG_PHY_INTERRUPT) {
3790 ixgbe_handle_lasi(hw);
3791 intr->flags &= ~IXGBE_FLAG_PHY_INTERRUPT;
3794 if (intr->flags & IXGBE_FLAG_NEED_LINK_UPDATE) {
3795 ixgbe_dev_link_update(dev, 0);
3796 intr->flags &= ~IXGBE_FLAG_NEED_LINK_UPDATE;
3797 ixgbe_dev_link_status_print(dev);
3798 _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
3801 if (intr->flags & IXGBE_FLAG_MACSEC) {
3802 _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_MACSEC,
3804 intr->flags &= ~IXGBE_FLAG_MACSEC;
3807 PMD_DRV_LOG(DEBUG, "enable intr in delayed handler S[%08x]", eicr);
3808 ixgbe_enable_intr(dev);
3809 rte_intr_enable(intr_handle);
3813 * Interrupt handler triggered by NIC for handling
3814 * specific interrupt.
3817 * Pointer to interrupt handle.
3819 * The address of parameter (struct rte_eth_dev *) regsitered before.
3825 ixgbe_dev_interrupt_handler(struct rte_intr_handle *handle,
3828 struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
3830 ixgbe_dev_interrupt_get_status(dev);
3831 ixgbe_dev_interrupt_action(dev, handle);
3835 ixgbe_dev_led_on(struct rte_eth_dev *dev)
3837 struct ixgbe_hw *hw;
3839 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3840 return ixgbe_led_on(hw, 0) == IXGBE_SUCCESS ? 0 : -ENOTSUP;
3844 ixgbe_dev_led_off(struct rte_eth_dev *dev)
3846 struct ixgbe_hw *hw;
3848 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3849 return ixgbe_led_off(hw, 0) == IXGBE_SUCCESS ? 0 : -ENOTSUP;
3853 ixgbe_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
3855 struct ixgbe_hw *hw;
3861 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3863 fc_conf->pause_time = hw->fc.pause_time;
3864 fc_conf->high_water = hw->fc.high_water[0];
3865 fc_conf->low_water = hw->fc.low_water[0];
3866 fc_conf->send_xon = hw->fc.send_xon;
3867 fc_conf->autoneg = !hw->fc.disable_fc_autoneg;
3870 * Return rx_pause status according to actual setting of
3873 mflcn_reg = IXGBE_READ_REG(hw, IXGBE_MFLCN);
3874 if (mflcn_reg & (IXGBE_MFLCN_RPFCE | IXGBE_MFLCN_RFCE))
3880 * Return tx_pause status according to actual setting of
3883 fccfg_reg = IXGBE_READ_REG(hw, IXGBE_FCCFG);
3884 if (fccfg_reg & (IXGBE_FCCFG_TFCE_802_3X | IXGBE_FCCFG_TFCE_PRIORITY))
3889 if (rx_pause && tx_pause)
3890 fc_conf->mode = RTE_FC_FULL;
3892 fc_conf->mode = RTE_FC_RX_PAUSE;
3894 fc_conf->mode = RTE_FC_TX_PAUSE;
3896 fc_conf->mode = RTE_FC_NONE;
3902 ixgbe_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
3904 struct ixgbe_hw *hw;
3906 uint32_t rx_buf_size;
3907 uint32_t max_high_water;
3909 enum ixgbe_fc_mode rte_fcmode_2_ixgbe_fcmode[] = {
3916 PMD_INIT_FUNC_TRACE();
3918 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3919 rx_buf_size = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(0));
3920 PMD_INIT_LOG(DEBUG, "Rx packet buffer size = 0x%x", rx_buf_size);
3923 * At least reserve one Ethernet frame for watermark
3924 * high_water/low_water in kilo bytes for ixgbe
3926 max_high_water = (rx_buf_size - ETHER_MAX_LEN) >> IXGBE_RXPBSIZE_SHIFT;
3927 if ((fc_conf->high_water > max_high_water) ||
3928 (fc_conf->high_water < fc_conf->low_water)) {
3929 PMD_INIT_LOG(ERR, "Invalid high/low water setup value in KB");
3930 PMD_INIT_LOG(ERR, "High_water must <= 0x%x", max_high_water);
3934 hw->fc.requested_mode = rte_fcmode_2_ixgbe_fcmode[fc_conf->mode];
3935 hw->fc.pause_time = fc_conf->pause_time;
3936 hw->fc.high_water[0] = fc_conf->high_water;
3937 hw->fc.low_water[0] = fc_conf->low_water;
3938 hw->fc.send_xon = fc_conf->send_xon;
3939 hw->fc.disable_fc_autoneg = !fc_conf->autoneg;
3941 err = ixgbe_fc_enable(hw);
3943 /* Not negotiated is not an error case */
3944 if ((err == IXGBE_SUCCESS) || (err == IXGBE_ERR_FC_NOT_NEGOTIATED)) {
3946 /* check if we want to forward MAC frames - driver doesn't have native
3947 * capability to do that, so we'll write the registers ourselves */
3949 mflcn = IXGBE_READ_REG(hw, IXGBE_MFLCN);
3951 /* set or clear MFLCN.PMCF bit depending on configuration */
3952 if (fc_conf->mac_ctrl_frame_fwd != 0)
3953 mflcn |= IXGBE_MFLCN_PMCF;
3955 mflcn &= ~IXGBE_MFLCN_PMCF;
3957 IXGBE_WRITE_REG(hw, IXGBE_MFLCN, mflcn);
3958 IXGBE_WRITE_FLUSH(hw);
3963 PMD_INIT_LOG(ERR, "ixgbe_fc_enable = 0x%x", err);
3968 * ixgbe_pfc_enable_generic - Enable flow control
3969 * @hw: pointer to hardware structure
3970 * @tc_num: traffic class number
3971 * Enable flow control according to the current settings.
3974 ixgbe_dcb_pfc_enable_generic(struct ixgbe_hw *hw, uint8_t tc_num)
3977 uint32_t mflcn_reg, fccfg_reg;
3979 uint32_t fcrtl, fcrth;
3983 /* Validate the water mark configuration */
3984 if (!hw->fc.pause_time) {
3985 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
3989 /* Low water mark of zero causes XOFF floods */
3990 if (hw->fc.current_mode & ixgbe_fc_tx_pause) {
3991 /* High/Low water can not be 0 */
3992 if ((!hw->fc.high_water[tc_num]) || (!hw->fc.low_water[tc_num])) {
3993 PMD_INIT_LOG(ERR, "Invalid water mark configuration");
3994 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
3998 if (hw->fc.low_water[tc_num] >= hw->fc.high_water[tc_num]) {
3999 PMD_INIT_LOG(ERR, "Invalid water mark configuration");
4000 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
4004 /* Negotiate the fc mode to use */
4005 ixgbe_fc_autoneg(hw);
4007 /* Disable any previous flow control settings */
4008 mflcn_reg = IXGBE_READ_REG(hw, IXGBE_MFLCN);
4009 mflcn_reg &= ~(IXGBE_MFLCN_RPFCE_SHIFT | IXGBE_MFLCN_RFCE|IXGBE_MFLCN_RPFCE);
4011 fccfg_reg = IXGBE_READ_REG(hw, IXGBE_FCCFG);
4012 fccfg_reg &= ~(IXGBE_FCCFG_TFCE_802_3X | IXGBE_FCCFG_TFCE_PRIORITY);
4014 switch (hw->fc.current_mode) {
4017 * If the count of enabled RX Priority Flow control >1,
4018 * and the TX pause can not be disabled
4021 for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
4022 reg = IXGBE_READ_REG(hw, IXGBE_FCRTH_82599(i));
4023 if (reg & IXGBE_FCRTH_FCEN)
4027 fccfg_reg |= IXGBE_FCCFG_TFCE_PRIORITY;
4029 case ixgbe_fc_rx_pause:
4031 * Rx Flow control is enabled and Tx Flow control is
4032 * disabled by software override. Since there really
4033 * isn't a way to advertise that we are capable of RX
4034 * Pause ONLY, we will advertise that we support both
4035 * symmetric and asymmetric Rx PAUSE. Later, we will
4036 * disable the adapter's ability to send PAUSE frames.
4038 mflcn_reg |= IXGBE_MFLCN_RPFCE;
4040 * If the count of enabled RX Priority Flow control >1,
4041 * and the TX pause can not be disabled
4044 for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
4045 reg = IXGBE_READ_REG(hw, IXGBE_FCRTH_82599(i));
4046 if (reg & IXGBE_FCRTH_FCEN)
4050 fccfg_reg |= IXGBE_FCCFG_TFCE_PRIORITY;
4052 case ixgbe_fc_tx_pause:
4054 * Tx Flow control is enabled, and Rx Flow control is
4055 * disabled by software override.
4057 fccfg_reg |= IXGBE_FCCFG_TFCE_PRIORITY;
4060 /* Flow control (both Rx and Tx) is enabled by SW override. */
4061 mflcn_reg |= IXGBE_MFLCN_RPFCE;
4062 fccfg_reg |= IXGBE_FCCFG_TFCE_PRIORITY;
4065 PMD_DRV_LOG(DEBUG, "Flow control param set incorrectly");
4066 ret_val = IXGBE_ERR_CONFIG;
4070 /* Set 802.3x based flow control settings. */
4071 mflcn_reg |= IXGBE_MFLCN_DPF;
4072 IXGBE_WRITE_REG(hw, IXGBE_MFLCN, mflcn_reg);
4073 IXGBE_WRITE_REG(hw, IXGBE_FCCFG, fccfg_reg);
4075 /* Set up and enable Rx high/low water mark thresholds, enable XON. */
4076 if ((hw->fc.current_mode & ixgbe_fc_tx_pause) &&
4077 hw->fc.high_water[tc_num]) {
4078 fcrtl = (hw->fc.low_water[tc_num] << 10) | IXGBE_FCRTL_XONE;
4079 IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(tc_num), fcrtl);
4080 fcrth = (hw->fc.high_water[tc_num] << 10) | IXGBE_FCRTH_FCEN;
4082 IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(tc_num), 0);
4084 * In order to prevent Tx hangs when the internal Tx
4085 * switch is enabled we must set the high water mark
4086 * to the maximum FCRTH value. This allows the Tx
4087 * switch to function even under heavy Rx workloads.
4089 fcrth = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(tc_num)) - 32;
4091 IXGBE_WRITE_REG(hw, IXGBE_FCRTH_82599(tc_num), fcrth);
4093 /* Configure pause time (2 TCs per register) */
4094 reg = hw->fc.pause_time * 0x00010001;
4095 for (i = 0; i < (IXGBE_DCB_MAX_TRAFFIC_CLASS / 2); i++)
4096 IXGBE_WRITE_REG(hw, IXGBE_FCTTV(i), reg);
4098 /* Configure flow control refresh threshold value */
4099 IXGBE_WRITE_REG(hw, IXGBE_FCRTV, hw->fc.pause_time / 2);
4106 ixgbe_dcb_pfc_enable(struct rte_eth_dev *dev, uint8_t tc_num)
4108 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4109 int32_t ret_val = IXGBE_NOT_IMPLEMENTED;
4111 if (hw->mac.type != ixgbe_mac_82598EB) {
4112 ret_val = ixgbe_dcb_pfc_enable_generic(hw, tc_num);
4118 ixgbe_priority_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_pfc_conf *pfc_conf)
4121 uint32_t rx_buf_size;
4122 uint32_t max_high_water;
4124 uint8_t map[IXGBE_DCB_MAX_USER_PRIORITY] = { 0 };
4125 struct ixgbe_hw *hw =
4126 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4127 struct ixgbe_dcb_config *dcb_config =
4128 IXGBE_DEV_PRIVATE_TO_DCB_CFG(dev->data->dev_private);
4130 enum ixgbe_fc_mode rte_fcmode_2_ixgbe_fcmode[] = {
4137 PMD_INIT_FUNC_TRACE();
4139 ixgbe_dcb_unpack_map_cee(dcb_config, IXGBE_DCB_RX_CONFIG, map);
4140 tc_num = map[pfc_conf->priority];
4141 rx_buf_size = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(tc_num));
4142 PMD_INIT_LOG(DEBUG, "Rx packet buffer size = 0x%x", rx_buf_size);
4144 * At least reserve one Ethernet frame for watermark
4145 * high_water/low_water in kilo bytes for ixgbe
4147 max_high_water = (rx_buf_size - ETHER_MAX_LEN) >> IXGBE_RXPBSIZE_SHIFT;
4148 if ((pfc_conf->fc.high_water > max_high_water) ||
4149 (pfc_conf->fc.high_water <= pfc_conf->fc.low_water)) {
4150 PMD_INIT_LOG(ERR, "Invalid high/low water setup value in KB");
4151 PMD_INIT_LOG(ERR, "High_water must <= 0x%x", max_high_water);
4155 hw->fc.requested_mode = rte_fcmode_2_ixgbe_fcmode[pfc_conf->fc.mode];
4156 hw->fc.pause_time = pfc_conf->fc.pause_time;
4157 hw->fc.send_xon = pfc_conf->fc.send_xon;
4158 hw->fc.low_water[tc_num] = pfc_conf->fc.low_water;
4159 hw->fc.high_water[tc_num] = pfc_conf->fc.high_water;
4161 err = ixgbe_dcb_pfc_enable(dev, tc_num);
4163 /* Not negotiated is not an error case */
4164 if ((err == IXGBE_SUCCESS) || (err == IXGBE_ERR_FC_NOT_NEGOTIATED))
4167 PMD_INIT_LOG(ERR, "ixgbe_dcb_pfc_enable = 0x%x", err);
4172 ixgbe_dev_rss_reta_update(struct rte_eth_dev *dev,
4173 struct rte_eth_rss_reta_entry64 *reta_conf,
4176 uint16_t i, sp_reta_size;
4179 uint16_t idx, shift;
4180 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4183 PMD_INIT_FUNC_TRACE();
4185 if (!ixgbe_rss_update_sp(hw->mac.type)) {
4186 PMD_DRV_LOG(ERR, "RSS reta update is not supported on this "
4191 sp_reta_size = ixgbe_reta_size_get(hw->mac.type);
4192 if (reta_size != sp_reta_size) {
4193 PMD_DRV_LOG(ERR, "The size of hash lookup table configured "
4194 "(%d) doesn't match the number hardware can supported "
4195 "(%d)\n", reta_size, sp_reta_size);
4199 for (i = 0; i < reta_size; i += IXGBE_4_BIT_WIDTH) {
4200 idx = i / RTE_RETA_GROUP_SIZE;
4201 shift = i % RTE_RETA_GROUP_SIZE;
4202 mask = (uint8_t)((reta_conf[idx].mask >> shift) &
4206 reta_reg = ixgbe_reta_reg_get(hw->mac.type, i);
4207 if (mask == IXGBE_4_BIT_MASK)
4210 r = IXGBE_READ_REG(hw, reta_reg);
4211 for (j = 0, reta = 0; j < IXGBE_4_BIT_WIDTH; j++) {
4212 if (mask & (0x1 << j))
4213 reta |= reta_conf[idx].reta[shift + j] <<
4216 reta |= r & (IXGBE_8_BIT_MASK <<
4219 IXGBE_WRITE_REG(hw, reta_reg, reta);
4226 ixgbe_dev_rss_reta_query(struct rte_eth_dev *dev,
4227 struct rte_eth_rss_reta_entry64 *reta_conf,
4230 uint16_t i, sp_reta_size;
4233 uint16_t idx, shift;
4234 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4237 PMD_INIT_FUNC_TRACE();
4238 sp_reta_size = ixgbe_reta_size_get(hw->mac.type);
4239 if (reta_size != sp_reta_size) {
4240 PMD_DRV_LOG(ERR, "The size of hash lookup table configured "
4241 "(%d) doesn't match the number hardware can supported "
4242 "(%d)\n", reta_size, sp_reta_size);
4246 for (i = 0; i < reta_size; i += IXGBE_4_BIT_WIDTH) {
4247 idx = i / RTE_RETA_GROUP_SIZE;
4248 shift = i % RTE_RETA_GROUP_SIZE;
4249 mask = (uint8_t)((reta_conf[idx].mask >> shift) &
4254 reta_reg = ixgbe_reta_reg_get(hw->mac.type, i);
4255 reta = IXGBE_READ_REG(hw, reta_reg);
4256 for (j = 0; j < IXGBE_4_BIT_WIDTH; j++) {
4257 if (mask & (0x1 << j))
4258 reta_conf[idx].reta[shift + j] =
4259 ((reta >> (CHAR_BIT * j)) &
4268 ixgbe_add_rar(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
4269 uint32_t index, uint32_t pool)
4271 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4272 uint32_t enable_addr = 1;
4274 ixgbe_set_rar(hw, index, mac_addr->addr_bytes, pool, enable_addr);
4278 ixgbe_remove_rar(struct rte_eth_dev *dev, uint32_t index)
4280 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4282 ixgbe_clear_rar(hw, index);
4286 ixgbe_set_default_mac_addr(struct rte_eth_dev *dev, struct ether_addr *addr)
4288 ixgbe_remove_rar(dev, 0);
4290 ixgbe_add_rar(dev, addr, 0, 0);
4294 is_ixgbe_pmd(const char *driver_name)
4296 if (!strstr(driver_name, "ixgbe"))
4299 if (strstr(driver_name, "ixgbe_vf"))
4306 rte_pmd_ixgbe_set_vf_mac_addr(uint8_t port, uint16_t vf,
4307 struct ether_addr *mac_addr)
4309 struct ixgbe_hw *hw;
4310 struct ixgbe_vf_info *vfinfo;
4312 uint8_t *new_mac = (uint8_t *)(mac_addr);
4313 struct rte_eth_dev *dev;
4314 struct rte_eth_dev_info dev_info;
4316 RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
4318 dev = &rte_eth_devices[port];
4319 rte_eth_dev_info_get(port, &dev_info);
4321 if (is_ixgbe_pmd(dev_info.driver_name) != 0)
4324 if (vf >= dev_info.max_vfs)
4327 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4328 vfinfo = *(IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private));
4329 rar_entry = hw->mac.num_rar_entries - (vf + 1);
4331 if (is_valid_assigned_ether_addr((struct ether_addr *)new_mac)) {
4332 rte_memcpy(vfinfo[vf].vf_mac_addresses, new_mac,
4334 return hw->mac.ops.set_rar(hw, rar_entry, new_mac, vf,
4341 ixgbe_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
4345 struct ixgbe_hw *hw;
4346 struct rte_eth_dev_info dev_info;
4347 uint32_t frame_size = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
4349 ixgbe_dev_info_get(dev, &dev_info);
4351 /* check that mtu is within the allowed range */
4352 if ((mtu < ETHER_MIN_MTU) || (frame_size > dev_info.max_rx_pktlen))
4355 /* refuse mtu that requires the support of scattered packets when this
4356 * feature has not been enabled before.
4358 if (!dev->data->scattered_rx &&
4359 (frame_size + 2 * IXGBE_VLAN_TAG_SIZE >
4360 dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM))
4363 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4364 hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
4366 /* switch to jumbo mode if needed */
4367 if (frame_size > ETHER_MAX_LEN) {
4368 dev->data->dev_conf.rxmode.jumbo_frame = 1;
4369 hlreg0 |= IXGBE_HLREG0_JUMBOEN;
4371 dev->data->dev_conf.rxmode.jumbo_frame = 0;
4372 hlreg0 &= ~IXGBE_HLREG0_JUMBOEN;
4374 IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
4376 /* update max frame size */
4377 dev->data->dev_conf.rxmode.max_rx_pkt_len = frame_size;
4379 maxfrs = IXGBE_READ_REG(hw, IXGBE_MAXFRS);
4380 maxfrs &= 0x0000FFFF;
4381 maxfrs |= (dev->data->dev_conf.rxmode.max_rx_pkt_len << 16);
4382 IXGBE_WRITE_REG(hw, IXGBE_MAXFRS, maxfrs);
4388 * Virtual Function operations
4391 ixgbevf_intr_disable(struct ixgbe_hw *hw)
4393 PMD_INIT_FUNC_TRACE();
4395 /* Clear interrupt mask to stop from interrupts being generated */
4396 IXGBE_WRITE_REG(hw, IXGBE_VTEIMC, IXGBE_VF_IRQ_CLEAR_MASK);
4398 IXGBE_WRITE_FLUSH(hw);
4402 ixgbevf_intr_enable(struct ixgbe_hw *hw)
4404 PMD_INIT_FUNC_TRACE();
4406 /* VF enable interrupt autoclean */
4407 IXGBE_WRITE_REG(hw, IXGBE_VTEIAM, IXGBE_VF_IRQ_ENABLE_MASK);
4408 IXGBE_WRITE_REG(hw, IXGBE_VTEIAC, IXGBE_VF_IRQ_ENABLE_MASK);
4409 IXGBE_WRITE_REG(hw, IXGBE_VTEIMS, IXGBE_VF_IRQ_ENABLE_MASK);
4411 IXGBE_WRITE_FLUSH(hw);
4415 ixgbevf_dev_configure(struct rte_eth_dev *dev)
4417 struct rte_eth_conf *conf = &dev->data->dev_conf;
4418 struct ixgbe_adapter *adapter =
4419 (struct ixgbe_adapter *)dev->data->dev_private;
4421 PMD_INIT_LOG(DEBUG, "Configured Virtual Function port id: %d",
4422 dev->data->port_id);
4425 * VF has no ability to enable/disable HW CRC
4426 * Keep the persistent behavior the same as Host PF
4428 #ifndef RTE_LIBRTE_IXGBE_PF_DISABLE_STRIP_CRC
4429 if (!conf->rxmode.hw_strip_crc) {
4430 PMD_INIT_LOG(NOTICE, "VF can't disable HW CRC Strip");
4431 conf->rxmode.hw_strip_crc = 1;
4434 if (conf->rxmode.hw_strip_crc) {
4435 PMD_INIT_LOG(NOTICE, "VF can't enable HW CRC Strip");
4436 conf->rxmode.hw_strip_crc = 0;
4441 * Initialize to TRUE. If any of Rx queues doesn't meet the bulk
4442 * allocation or vector Rx preconditions we will reset it.
4444 adapter->rx_bulk_alloc_allowed = true;
4445 adapter->rx_vec_allowed = true;
4451 ixgbevf_dev_start(struct rte_eth_dev *dev)
4453 struct ixgbe_hw *hw =
4454 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4455 uint32_t intr_vector = 0;
4456 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
4457 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
4461 PMD_INIT_FUNC_TRACE();
4463 hw->mac.ops.reset_hw(hw);
4464 hw->mac.get_link_status = true;
4466 /* negotiate mailbox API version to use with the PF. */
4467 ixgbevf_negotiate_api(hw);
4469 ixgbevf_dev_tx_init(dev);
4471 /* This can fail when allocating mbufs for descriptor rings */
4472 err = ixgbevf_dev_rx_init(dev);
4474 PMD_INIT_LOG(ERR, "Unable to initialize RX hardware (%d)", err);
4475 ixgbe_dev_clear_queues(dev);
4480 ixgbevf_set_vfta_all(dev, 1);
4483 mask = ETH_VLAN_STRIP_MASK | ETH_VLAN_FILTER_MASK |
4484 ETH_VLAN_EXTEND_MASK;
4485 ixgbevf_vlan_offload_set(dev, mask);
4487 ixgbevf_dev_rxtx_start(dev);
4489 /* check and configure queue intr-vector mapping */
4490 if (dev->data->dev_conf.intr_conf.rxq != 0) {
4491 intr_vector = dev->data->nb_rx_queues;
4492 if (rte_intr_efd_enable(intr_handle, intr_vector))
4496 if (rte_intr_dp_is_en(intr_handle) && !intr_handle->intr_vec) {
4497 intr_handle->intr_vec =
4498 rte_zmalloc("intr_vec",
4499 dev->data->nb_rx_queues * sizeof(int), 0);
4500 if (intr_handle->intr_vec == NULL) {
4501 PMD_INIT_LOG(ERR, "Failed to allocate %d rx_queues"
4502 " intr_vec\n", dev->data->nb_rx_queues);
4506 ixgbevf_configure_msix(dev);
4508 rte_intr_enable(intr_handle);
4510 /* Re-enable interrupt for VF */
4511 ixgbevf_intr_enable(hw);
4517 ixgbevf_dev_stop(struct rte_eth_dev *dev)
4519 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4520 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
4521 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
4523 PMD_INIT_FUNC_TRACE();
4525 ixgbevf_intr_disable(hw);
4527 hw->adapter_stopped = 1;
4528 ixgbe_stop_adapter(hw);
4531 * Clear what we set, but we still keep shadow_vfta to
4532 * restore after device starts
4534 ixgbevf_set_vfta_all(dev, 0);
4536 /* Clear stored conf */
4537 dev->data->scattered_rx = 0;
4539 ixgbe_dev_clear_queues(dev);
4541 /* Clean datapath event and queue/vec mapping */
4542 rte_intr_efd_disable(intr_handle);
4543 if (intr_handle->intr_vec != NULL) {
4544 rte_free(intr_handle->intr_vec);
4545 intr_handle->intr_vec = NULL;
4550 ixgbevf_dev_close(struct rte_eth_dev *dev)
4552 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4554 PMD_INIT_FUNC_TRACE();
4558 ixgbevf_dev_stop(dev);
4560 ixgbe_dev_free_queues(dev);
4563 * Remove the VF MAC address ro ensure
4564 * that the VF traffic goes to the PF
4565 * after stop, close and detach of the VF
4567 ixgbevf_remove_mac_addr(dev, 0);
4570 static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on)
4572 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4573 struct ixgbe_vfta *shadow_vfta =
4574 IXGBE_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
4575 int i = 0, j = 0, vfta = 0, mask = 1;
4577 for (i = 0; i < IXGBE_VFTA_SIZE; i++) {
4578 vfta = shadow_vfta->vfta[i];
4581 for (j = 0; j < 32; j++) {
4583 ixgbe_set_vfta(hw, (i<<5)+j, 0,
4593 ixgbevf_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
4595 struct ixgbe_hw *hw =
4596 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4597 struct ixgbe_vfta *shadow_vfta =
4598 IXGBE_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
4599 uint32_t vid_idx = 0;
4600 uint32_t vid_bit = 0;
4603 PMD_INIT_FUNC_TRACE();
4605 /* vind is not used in VF driver, set to 0, check ixgbe_set_vfta_vf */
4606 ret = ixgbe_set_vfta(hw, vlan_id, 0, !!on, false);
4608 PMD_INIT_LOG(ERR, "Unable to set VF vlan");
4611 vid_idx = (uint32_t) ((vlan_id >> 5) & 0x7F);
4612 vid_bit = (uint32_t) (1 << (vlan_id & 0x1F));
4614 /* Save what we set and retore it after device reset */
4616 shadow_vfta->vfta[vid_idx] |= vid_bit;
4618 shadow_vfta->vfta[vid_idx] &= ~vid_bit;
4624 ixgbevf_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue, int on)
4626 struct ixgbe_hw *hw =
4627 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4630 PMD_INIT_FUNC_TRACE();
4632 if (queue >= hw->mac.max_rx_queues)
4635 ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(queue));
4637 ctrl |= IXGBE_RXDCTL_VME;
4639 ctrl &= ~IXGBE_RXDCTL_VME;
4640 IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(queue), ctrl);
4642 ixgbe_vlan_hw_strip_bitmap_set(dev, queue, on);
4646 ixgbevf_vlan_offload_set(struct rte_eth_dev *dev, int mask)
4648 struct ixgbe_hw *hw =
4649 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4653 /* VF function only support hw strip feature, others are not support */
4654 if (mask & ETH_VLAN_STRIP_MASK) {
4655 on = !!(dev->data->dev_conf.rxmode.hw_vlan_strip);
4657 for (i = 0; i < hw->mac.max_rx_queues; i++)
4658 ixgbevf_vlan_strip_queue_set(dev, i, on);
4663 ixgbe_vt_check(struct ixgbe_hw *hw)
4667 /* if Virtualization Technology is enabled */
4668 reg_val = IXGBE_READ_REG(hw, IXGBE_VT_CTL);
4669 if (!(reg_val & IXGBE_VT_CTL_VT_ENABLE)) {
4670 PMD_INIT_LOG(ERR, "VT must be enabled for this setting");
4678 ixgbe_uta_vector(struct ixgbe_hw *hw, struct ether_addr *uc_addr)
4680 uint32_t vector = 0;
4682 switch (hw->mac.mc_filter_type) {
4683 case 0: /* use bits [47:36] of the address */
4684 vector = ((uc_addr->addr_bytes[4] >> 4) |
4685 (((uint16_t)uc_addr->addr_bytes[5]) << 4));
4687 case 1: /* use bits [46:35] of the address */
4688 vector = ((uc_addr->addr_bytes[4] >> 3) |
4689 (((uint16_t)uc_addr->addr_bytes[5]) << 5));
4691 case 2: /* use bits [45:34] of the address */
4692 vector = ((uc_addr->addr_bytes[4] >> 2) |
4693 (((uint16_t)uc_addr->addr_bytes[5]) << 6));
4695 case 3: /* use bits [43:32] of the address */
4696 vector = ((uc_addr->addr_bytes[4]) |
4697 (((uint16_t)uc_addr->addr_bytes[5]) << 8));
4699 default: /* Invalid mc_filter_type */
4703 /* vector can only be 12-bits or boundary will be exceeded */
4709 ixgbe_uc_hash_table_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
4717 const uint32_t ixgbe_uta_idx_mask = 0x7F;
4718 const uint32_t ixgbe_uta_bit_shift = 5;
4719 const uint32_t ixgbe_uta_bit_mask = (0x1 << ixgbe_uta_bit_shift) - 1;
4720 const uint32_t bit1 = 0x1;
4722 struct ixgbe_hw *hw =
4723 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4724 struct ixgbe_uta_info *uta_info =
4725 IXGBE_DEV_PRIVATE_TO_UTA(dev->data->dev_private);
4727 /* The UTA table only exists on 82599 hardware and newer */
4728 if (hw->mac.type < ixgbe_mac_82599EB)
4731 vector = ixgbe_uta_vector(hw, mac_addr);
4732 uta_idx = (vector >> ixgbe_uta_bit_shift) & ixgbe_uta_idx_mask;
4733 uta_shift = vector & ixgbe_uta_bit_mask;
4735 rc = ((uta_info->uta_shadow[uta_idx] >> uta_shift & bit1) != 0);
4739 reg_val = IXGBE_READ_REG(hw, IXGBE_UTA(uta_idx));
4741 uta_info->uta_in_use++;
4742 reg_val |= (bit1 << uta_shift);
4743 uta_info->uta_shadow[uta_idx] |= (bit1 << uta_shift);
4745 uta_info->uta_in_use--;
4746 reg_val &= ~(bit1 << uta_shift);
4747 uta_info->uta_shadow[uta_idx] &= ~(bit1 << uta_shift);
4750 IXGBE_WRITE_REG(hw, IXGBE_UTA(uta_idx), reg_val);
4752 if (uta_info->uta_in_use > 0)
4753 IXGBE_WRITE_REG(hw, IXGBE_MCSTCTRL,
4754 IXGBE_MCSTCTRL_MFE | hw->mac.mc_filter_type);
4756 IXGBE_WRITE_REG(hw, IXGBE_MCSTCTRL, hw->mac.mc_filter_type);
4762 ixgbe_uc_all_hash_table_set(struct rte_eth_dev *dev, uint8_t on)
4765 struct ixgbe_hw *hw =
4766 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4767 struct ixgbe_uta_info *uta_info =
4768 IXGBE_DEV_PRIVATE_TO_UTA(dev->data->dev_private);
4770 /* The UTA table only exists on 82599 hardware and newer */
4771 if (hw->mac.type < ixgbe_mac_82599EB)
4775 for (i = 0; i < ETH_VMDQ_NUM_UC_HASH_ARRAY; i++) {
4776 uta_info->uta_shadow[i] = ~0;
4777 IXGBE_WRITE_REG(hw, IXGBE_UTA(i), ~0);
4780 for (i = 0; i < ETH_VMDQ_NUM_UC_HASH_ARRAY; i++) {
4781 uta_info->uta_shadow[i] = 0;
4782 IXGBE_WRITE_REG(hw, IXGBE_UTA(i), 0);
4790 ixgbe_convert_vm_rx_mask_to_val(uint16_t rx_mask, uint32_t orig_val)
4792 uint32_t new_val = orig_val;
4794 if (rx_mask & ETH_VMDQ_ACCEPT_UNTAG)
4795 new_val |= IXGBE_VMOLR_AUPE;
4796 if (rx_mask & ETH_VMDQ_ACCEPT_HASH_MC)
4797 new_val |= IXGBE_VMOLR_ROMPE;
4798 if (rx_mask & ETH_VMDQ_ACCEPT_HASH_UC)
4799 new_val |= IXGBE_VMOLR_ROPE;
4800 if (rx_mask & ETH_VMDQ_ACCEPT_BROADCAST)
4801 new_val |= IXGBE_VMOLR_BAM;
4802 if (rx_mask & ETH_VMDQ_ACCEPT_MULTICAST)
4803 new_val |= IXGBE_VMOLR_MPE;
4810 rte_pmd_ixgbe_set_vf_vlan_anti_spoof(uint8_t port, uint16_t vf, uint8_t on)
4812 struct ixgbe_hw *hw;
4813 struct ixgbe_mac_info *mac;
4814 struct rte_eth_dev *dev;
4815 struct rte_eth_dev_info dev_info;
4817 RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
4819 dev = &rte_eth_devices[port];
4820 rte_eth_dev_info_get(port, &dev_info);
4822 if (is_ixgbe_pmd(dev_info.driver_name) != 0)
4825 if (vf >= dev_info.max_vfs)
4831 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4834 mac->ops.set_vlan_anti_spoofing(hw, on, vf);
4840 rte_pmd_ixgbe_set_vf_mac_anti_spoof(uint8_t port, uint16_t vf, uint8_t on)
4842 struct ixgbe_hw *hw;
4843 struct ixgbe_mac_info *mac;
4844 struct rte_eth_dev *dev;
4845 struct rte_eth_dev_info dev_info;
4847 RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
4849 dev = &rte_eth_devices[port];
4850 rte_eth_dev_info_get(port, &dev_info);
4852 if (is_ixgbe_pmd(dev_info.driver_name) != 0)
4855 if (vf >= dev_info.max_vfs)
4861 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4863 mac->ops.set_mac_anti_spoofing(hw, on, vf);
4869 rte_pmd_ixgbe_set_vf_vlan_insert(uint8_t port, uint16_t vf, uint16_t vlan_id)
4871 struct ixgbe_hw *hw;
4873 struct rte_eth_dev *dev;
4874 struct rte_eth_dev_info dev_info;
4876 RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
4878 dev = &rte_eth_devices[port];
4879 rte_eth_dev_info_get(port, &dev_info);
4881 if (is_ixgbe_pmd(dev_info.driver_name) != 0)
4884 if (vf >= dev_info.max_vfs)
4887 if (vlan_id > ETHER_MAX_VLAN_ID)
4890 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4891 ctrl = IXGBE_READ_REG(hw, IXGBE_VMVIR(vf));
4894 ctrl |= IXGBE_VMVIR_VLANA_DEFAULT;
4899 IXGBE_WRITE_REG(hw, IXGBE_VMVIR(vf), ctrl);
4905 rte_pmd_ixgbe_set_tx_loopback(uint8_t port, uint8_t on)
4907 struct ixgbe_hw *hw;
4909 struct rte_eth_dev *dev;
4910 struct rte_eth_dev_info dev_info;
4912 RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
4914 dev = &rte_eth_devices[port];
4915 rte_eth_dev_info_get(port, &dev_info);
4917 if (is_ixgbe_pmd(dev_info.driver_name) != 0)
4923 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4924 ctrl = IXGBE_READ_REG(hw, IXGBE_PFDTXGSWC);
4925 /* enable or disable VMDQ loopback */
4927 ctrl |= IXGBE_PFDTXGSWC_VT_LBEN;
4929 ctrl &= ~IXGBE_PFDTXGSWC_VT_LBEN;
4931 IXGBE_WRITE_REG(hw, IXGBE_PFDTXGSWC, ctrl);
4937 rte_pmd_ixgbe_set_all_queues_drop_en(uint8_t port, uint8_t on)
4939 struct ixgbe_hw *hw;
4942 int num_queues = (int)(IXGBE_QDE_IDX_MASK >> IXGBE_QDE_IDX_SHIFT);
4943 struct rte_eth_dev *dev;
4944 struct rte_eth_dev_info dev_info;
4946 RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
4948 dev = &rte_eth_devices[port];
4949 rte_eth_dev_info_get(port, &dev_info);
4951 if (is_ixgbe_pmd(dev_info.driver_name) != 0)
4957 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4958 for (i = 0; i <= num_queues; i++) {
4959 reg_value = IXGBE_QDE_WRITE |
4960 (i << IXGBE_QDE_IDX_SHIFT) |
4961 (on & IXGBE_QDE_ENABLE);
4962 IXGBE_WRITE_REG(hw, IXGBE_QDE, reg_value);
4969 rte_pmd_ixgbe_set_vf_split_drop_en(uint8_t port, uint16_t vf, uint8_t on)
4971 struct ixgbe_hw *hw;
4973 struct rte_eth_dev *dev;
4974 struct rte_eth_dev_info dev_info;
4976 RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
4978 dev = &rte_eth_devices[port];
4979 rte_eth_dev_info_get(port, &dev_info);
4981 if (is_ixgbe_pmd(dev_info.driver_name) != 0)
4984 /* only support VF's 0 to 63 */
4985 if ((vf >= dev_info.max_vfs) || (vf > 63))
4991 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4992 reg_value = IXGBE_READ_REG(hw, IXGBE_SRRCTL(vf));
4994 reg_value |= IXGBE_SRRCTL_DROP_EN;
4996 reg_value &= ~IXGBE_SRRCTL_DROP_EN;
4998 IXGBE_WRITE_REG(hw, IXGBE_SRRCTL(vf), reg_value);
5004 rte_pmd_ixgbe_set_vf_vlan_stripq(uint8_t port, uint16_t vf, uint8_t on)
5006 struct rte_eth_dev *dev;
5007 struct rte_eth_dev_info dev_info;
5008 uint16_t queues_per_pool;
5011 RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
5013 dev = &rte_eth_devices[port];
5014 rte_eth_dev_info_get(port, &dev_info);
5016 if (is_ixgbe_pmd(dev_info.driver_name) != 0)
5019 if (vf >= dev_info.max_vfs)
5025 RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_strip_queue_set, -ENOTSUP);
5027 /* The PF has 128 queue pairs and in SRIOV configuration
5028 * those queues will be assigned to VF's, so RXDCTL
5029 * registers will be dealing with queues which will be
5031 * Let's say we have SRIOV configured with 31 VF's then the
5032 * first 124 queues 0-123 will be allocated to VF's and only
5033 * the last 4 queues 123-127 will be assigned to the PF.
5036 queues_per_pool = dev_info.vmdq_queue_num / dev_info.max_vmdq_pools;
5038 for (q = 0; q < queues_per_pool; q++)
5039 (*dev->dev_ops->vlan_strip_queue_set)(dev,
5040 q + vf * queues_per_pool, on);
5045 rte_pmd_ixgbe_set_vf_rxmode(uint8_t port, uint16_t vf, uint16_t rx_mask, uint8_t on)
5048 struct rte_eth_dev *dev;
5049 struct rte_eth_dev_info dev_info;
5050 struct ixgbe_hw *hw;
5053 RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
5055 dev = &rte_eth_devices[port];
5056 rte_eth_dev_info_get(port, &dev_info);
5058 if (is_ixgbe_pmd(dev_info.driver_name) != 0)
5061 if (vf >= dev_info.max_vfs)
5067 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5068 vmolr = IXGBE_READ_REG(hw, IXGBE_VMOLR(vf));
5070 if (hw->mac.type == ixgbe_mac_82598EB) {
5071 PMD_INIT_LOG(ERR, "setting VF receive mode set should be done"
5072 " on 82599 hardware and newer");
5075 if (ixgbe_vt_check(hw) < 0)
5078 val = ixgbe_convert_vm_rx_mask_to_val(rx_mask, val);
5085 IXGBE_WRITE_REG(hw, IXGBE_VMOLR(vf), vmolr);
5091 rte_pmd_ixgbe_set_vf_rx(uint8_t port, uint16_t vf, uint8_t on)
5093 struct rte_eth_dev *dev;
5094 struct rte_eth_dev_info dev_info;
5097 const uint8_t bit1 = 0x1;
5098 struct ixgbe_hw *hw;
5100 RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
5102 dev = &rte_eth_devices[port];
5103 rte_eth_dev_info_get(port, &dev_info);
5105 if (is_ixgbe_pmd(dev_info.driver_name) != 0)
5108 if (vf >= dev_info.max_vfs)
5114 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5116 if (ixgbe_vt_check(hw) < 0)
5119 /* for vf >= 32, set bit in PFVFRE[1], otherwise PFVFRE[0] */
5121 addr = IXGBE_VFRE(1);
5122 val = bit1 << (vf - 32);
5124 addr = IXGBE_VFRE(0);
5128 reg = IXGBE_READ_REG(hw, addr);
5135 IXGBE_WRITE_REG(hw, addr, reg);
5141 rte_pmd_ixgbe_set_vf_tx(uint8_t port, uint16_t vf, uint8_t on)
5143 struct rte_eth_dev *dev;
5144 struct rte_eth_dev_info dev_info;
5147 const uint8_t bit1 = 0x1;
5149 struct ixgbe_hw *hw;
5151 RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
5153 dev = &rte_eth_devices[port];
5154 rte_eth_dev_info_get(port, &dev_info);
5156 if (is_ixgbe_pmd(dev_info.driver_name) != 0)
5159 if (vf >= dev_info.max_vfs)
5165 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5166 if (ixgbe_vt_check(hw) < 0)
5169 /* for vf >= 32, set bit in PFVFTE[1], otherwise PFVFTE[0] */
5171 addr = IXGBE_VFTE(1);
5172 val = bit1 << (vf - 32);
5174 addr = IXGBE_VFTE(0);
5178 reg = IXGBE_READ_REG(hw, addr);
5185 IXGBE_WRITE_REG(hw, addr, reg);
5191 rte_pmd_ixgbe_set_vf_vlan_filter(uint8_t port, uint16_t vlan,
5192 uint64_t vf_mask, uint8_t vlan_on)
5194 struct rte_eth_dev *dev;
5195 struct rte_eth_dev_info dev_info;
5198 struct ixgbe_hw *hw;
5200 RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
5202 dev = &rte_eth_devices[port];
5203 rte_eth_dev_info_get(port, &dev_info);
5205 if (is_ixgbe_pmd(dev_info.driver_name) != 0)
5208 if ((vlan > ETHER_MAX_VLAN_ID) || (vf_mask == 0))
5211 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5212 if (ixgbe_vt_check(hw) < 0)
5215 for (vf_idx = 0; vf_idx < 64; vf_idx++) {
5216 if (vf_mask & ((uint64_t)(1ULL << vf_idx))) {
5217 ret = hw->mac.ops.set_vfta(hw, vlan, vf_idx,
5227 int rte_pmd_ixgbe_set_vf_rate_limit(uint8_t port, uint16_t vf,
5228 uint16_t tx_rate, uint64_t q_msk)
5230 struct rte_eth_dev *dev;
5231 struct rte_eth_dev_info dev_info;
5232 struct ixgbe_hw *hw;
5233 struct ixgbe_vf_info *vfinfo;
5234 struct rte_eth_link link;
5235 uint8_t nb_q_per_pool;
5236 uint32_t queue_stride;
5237 uint32_t queue_idx, idx = 0, vf_idx;
5239 uint16_t total_rate = 0;
5240 struct rte_pci_device *pci_dev;
5242 RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
5244 dev = &rte_eth_devices[port];
5245 rte_eth_dev_info_get(port, &dev_info);
5246 rte_eth_link_get_nowait(port, &link);
5248 if (is_ixgbe_pmd(dev_info.driver_name) != 0)
5251 if (vf >= dev_info.max_vfs)
5254 if (tx_rate > link.link_speed)
5260 pci_dev = IXGBE_DEV_TO_PCI(dev);
5261 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5262 vfinfo = *(IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private));
5263 nb_q_per_pool = RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool;
5264 queue_stride = IXGBE_MAX_RX_QUEUE_NUM / RTE_ETH_DEV_SRIOV(dev).active;
5265 queue_idx = vf * queue_stride;
5266 queue_end = queue_idx + nb_q_per_pool - 1;
5267 if (queue_end >= hw->mac.max_tx_queues)
5271 for (vf_idx = 0; vf_idx < pci_dev->max_vfs; vf_idx++) {
5274 for (idx = 0; idx < RTE_DIM(vfinfo[vf_idx].tx_rate);
5276 total_rate += vfinfo[vf_idx].tx_rate[idx];
5282 /* Store tx_rate for this vf. */
5283 for (idx = 0; idx < nb_q_per_pool; idx++) {
5284 if (((uint64_t)0x1 << idx) & q_msk) {
5285 if (vfinfo[vf].tx_rate[idx] != tx_rate)
5286 vfinfo[vf].tx_rate[idx] = tx_rate;
5287 total_rate += tx_rate;
5291 if (total_rate > dev->data->dev_link.link_speed) {
5292 /* Reset stored TX rate of the VF if it causes exceed
5295 memset(vfinfo[vf].tx_rate, 0, sizeof(vfinfo[vf].tx_rate));
5299 /* Set RTTBCNRC of each queue/pool for vf X */
5300 for (; queue_idx <= queue_end; queue_idx++) {
5302 ixgbe_set_queue_rate_limit(dev, queue_idx, tx_rate);
5309 #define IXGBE_MRCTL_VPME 0x01 /* Virtual Pool Mirroring. */
5310 #define IXGBE_MRCTL_UPME 0x02 /* Uplink Port Mirroring. */
5311 #define IXGBE_MRCTL_DPME 0x04 /* Downlink Port Mirroring. */
5312 #define IXGBE_MRCTL_VLME 0x08 /* VLAN Mirroring. */
5313 #define IXGBE_INVALID_MIRROR_TYPE(mirror_type) \
5314 ((mirror_type) & ~(uint8_t)(ETH_MIRROR_VIRTUAL_POOL_UP | \
5315 ETH_MIRROR_UPLINK_PORT | ETH_MIRROR_DOWNLINK_PORT | ETH_MIRROR_VLAN))
5318 ixgbe_mirror_rule_set(struct rte_eth_dev *dev,
5319 struct rte_eth_mirror_conf *mirror_conf,
5320 uint8_t rule_id, uint8_t on)
5322 uint32_t mr_ctl, vlvf;
5323 uint32_t mp_lsb = 0;
5324 uint32_t mv_msb = 0;
5325 uint32_t mv_lsb = 0;
5326 uint32_t mp_msb = 0;
5329 uint64_t vlan_mask = 0;
5331 const uint8_t pool_mask_offset = 32;
5332 const uint8_t vlan_mask_offset = 32;
5333 const uint8_t dst_pool_offset = 8;
5334 const uint8_t rule_mr_offset = 4;
5335 const uint8_t mirror_rule_mask = 0x0F;
5337 struct ixgbe_mirror_info *mr_info =
5338 (IXGBE_DEV_PRIVATE_TO_PFDATA(dev->data->dev_private));
5339 struct ixgbe_hw *hw =
5340 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5341 uint8_t mirror_type = 0;
5343 if (ixgbe_vt_check(hw) < 0)
5346 if (rule_id >= IXGBE_MAX_MIRROR_RULES)
5349 if (IXGBE_INVALID_MIRROR_TYPE(mirror_conf->rule_type)) {
5350 PMD_DRV_LOG(ERR, "unsupported mirror type 0x%x.",
5351 mirror_conf->rule_type);
5355 if (mirror_conf->rule_type & ETH_MIRROR_VLAN) {
5356 mirror_type |= IXGBE_MRCTL_VLME;
5357 /* Check if vlan id is valid and find conresponding VLAN ID index in VLVF */
5358 for (i = 0; i < IXGBE_VLVF_ENTRIES; i++) {
5359 if (mirror_conf->vlan.vlan_mask & (1ULL << i)) {
5360 /* search vlan id related pool vlan filter index */
5361 reg_index = ixgbe_find_vlvf_slot(hw,
5362 mirror_conf->vlan.vlan_id[i],
5366 vlvf = IXGBE_READ_REG(hw, IXGBE_VLVF(reg_index));
5367 if ((vlvf & IXGBE_VLVF_VIEN) &&
5368 ((vlvf & IXGBE_VLVF_VLANID_MASK) ==
5369 mirror_conf->vlan.vlan_id[i]))
5370 vlan_mask |= (1ULL << reg_index);
5377 mv_lsb = vlan_mask & 0xFFFFFFFF;
5378 mv_msb = vlan_mask >> vlan_mask_offset;
5380 mr_info->mr_conf[rule_id].vlan.vlan_mask =
5381 mirror_conf->vlan.vlan_mask;
5382 for (i = 0; i < ETH_VMDQ_MAX_VLAN_FILTERS; i++) {
5383 if (mirror_conf->vlan.vlan_mask & (1ULL << i))
5384 mr_info->mr_conf[rule_id].vlan.vlan_id[i] =
5385 mirror_conf->vlan.vlan_id[i];
5390 mr_info->mr_conf[rule_id].vlan.vlan_mask = 0;
5391 for (i = 0; i < ETH_VMDQ_MAX_VLAN_FILTERS; i++)
5392 mr_info->mr_conf[rule_id].vlan.vlan_id[i] = 0;
5397 * if enable pool mirror, write related pool mask register,if disable
5398 * pool mirror, clear PFMRVM register
5400 if (mirror_conf->rule_type & ETH_MIRROR_VIRTUAL_POOL_UP) {
5401 mirror_type |= IXGBE_MRCTL_VPME;
5403 mp_lsb = mirror_conf->pool_mask & 0xFFFFFFFF;
5404 mp_msb = mirror_conf->pool_mask >> pool_mask_offset;
5405 mr_info->mr_conf[rule_id].pool_mask =
5406 mirror_conf->pool_mask;
5411 mr_info->mr_conf[rule_id].pool_mask = 0;
5414 if (mirror_conf->rule_type & ETH_MIRROR_UPLINK_PORT)
5415 mirror_type |= IXGBE_MRCTL_UPME;
5416 if (mirror_conf->rule_type & ETH_MIRROR_DOWNLINK_PORT)
5417 mirror_type |= IXGBE_MRCTL_DPME;
5419 /* read mirror control register and recalculate it */
5420 mr_ctl = IXGBE_READ_REG(hw, IXGBE_MRCTL(rule_id));
5423 mr_ctl |= mirror_type;
5424 mr_ctl &= mirror_rule_mask;
5425 mr_ctl |= mirror_conf->dst_pool << dst_pool_offset;
5427 mr_ctl &= ~(mirror_conf->rule_type & mirror_rule_mask);
5429 mr_info->mr_conf[rule_id].rule_type = mirror_conf->rule_type;
5430 mr_info->mr_conf[rule_id].dst_pool = mirror_conf->dst_pool;
5432 /* write mirrror control register */
5433 IXGBE_WRITE_REG(hw, IXGBE_MRCTL(rule_id), mr_ctl);
5435 /* write pool mirrror control register */
5436 if (mirror_conf->rule_type == ETH_MIRROR_VIRTUAL_POOL_UP) {
5437 IXGBE_WRITE_REG(hw, IXGBE_VMRVM(rule_id), mp_lsb);
5438 IXGBE_WRITE_REG(hw, IXGBE_VMRVM(rule_id + rule_mr_offset),
5441 /* write VLAN mirrror control register */
5442 if (mirror_conf->rule_type == ETH_MIRROR_VLAN) {
5443 IXGBE_WRITE_REG(hw, IXGBE_VMRVLAN(rule_id), mv_lsb);
5444 IXGBE_WRITE_REG(hw, IXGBE_VMRVLAN(rule_id + rule_mr_offset),
5452 ixgbe_mirror_rule_reset(struct rte_eth_dev *dev, uint8_t rule_id)
5455 uint32_t lsb_val = 0;
5456 uint32_t msb_val = 0;
5457 const uint8_t rule_mr_offset = 4;
5459 struct ixgbe_hw *hw =
5460 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5461 struct ixgbe_mirror_info *mr_info =
5462 (IXGBE_DEV_PRIVATE_TO_PFDATA(dev->data->dev_private));
5464 if (ixgbe_vt_check(hw) < 0)
5467 memset(&mr_info->mr_conf[rule_id], 0,
5468 sizeof(struct rte_eth_mirror_conf));
5470 /* clear PFVMCTL register */
5471 IXGBE_WRITE_REG(hw, IXGBE_MRCTL(rule_id), mr_ctl);
5473 /* clear pool mask register */
5474 IXGBE_WRITE_REG(hw, IXGBE_VMRVM(rule_id), lsb_val);
5475 IXGBE_WRITE_REG(hw, IXGBE_VMRVM(rule_id + rule_mr_offset), msb_val);
5477 /* clear vlan mask register */
5478 IXGBE_WRITE_REG(hw, IXGBE_VMRVLAN(rule_id), lsb_val);
5479 IXGBE_WRITE_REG(hw, IXGBE_VMRVLAN(rule_id + rule_mr_offset), msb_val);
5485 ixgbevf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
5487 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
5488 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
5490 struct ixgbe_hw *hw =
5491 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5493 mask = IXGBE_READ_REG(hw, IXGBE_VTEIMS);
5494 mask |= (1 << IXGBE_MISC_VEC_ID);
5495 RTE_SET_USED(queue_id);
5496 IXGBE_WRITE_REG(hw, IXGBE_VTEIMS, mask);
5498 rte_intr_enable(intr_handle);
5504 ixgbevf_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id)
5507 struct ixgbe_hw *hw =
5508 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5510 mask = IXGBE_READ_REG(hw, IXGBE_VTEIMS);
5511 mask &= ~(1 << IXGBE_MISC_VEC_ID);
5512 RTE_SET_USED(queue_id);
5513 IXGBE_WRITE_REG(hw, IXGBE_VTEIMS, mask);
5519 ixgbe_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
5521 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
5522 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
5524 struct ixgbe_hw *hw =
5525 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5526 struct ixgbe_interrupt *intr =
5527 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
5529 if (queue_id < 16) {
5530 ixgbe_disable_intr(hw);
5531 intr->mask |= (1 << queue_id);
5532 ixgbe_enable_intr(dev);
5533 } else if (queue_id < 32) {
5534 mask = IXGBE_READ_REG(hw, IXGBE_EIMS_EX(0));
5535 mask &= (1 << queue_id);
5536 IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(0), mask);
5537 } else if (queue_id < 64) {
5538 mask = IXGBE_READ_REG(hw, IXGBE_EIMS_EX(1));
5539 mask &= (1 << (queue_id - 32));
5540 IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(1), mask);
5542 rte_intr_enable(intr_handle);
5548 ixgbe_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id)
5551 struct ixgbe_hw *hw =
5552 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5553 struct ixgbe_interrupt *intr =
5554 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
5556 if (queue_id < 16) {
5557 ixgbe_disable_intr(hw);
5558 intr->mask &= ~(1 << queue_id);
5559 ixgbe_enable_intr(dev);
5560 } else if (queue_id < 32) {
5561 mask = IXGBE_READ_REG(hw, IXGBE_EIMS_EX(0));
5562 mask &= ~(1 << queue_id);
5563 IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(0), mask);
5564 } else if (queue_id < 64) {
5565 mask = IXGBE_READ_REG(hw, IXGBE_EIMS_EX(1));
5566 mask &= ~(1 << (queue_id - 32));
5567 IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(1), mask);
5574 ixgbevf_set_ivar_map(struct ixgbe_hw *hw, int8_t direction,
5575 uint8_t queue, uint8_t msix_vector)
5579 if (direction == -1) {
5581 msix_vector |= IXGBE_IVAR_ALLOC_VAL;
5582 tmp = IXGBE_READ_REG(hw, IXGBE_VTIVAR_MISC);
5585 IXGBE_WRITE_REG(hw, IXGBE_VTIVAR_MISC, tmp);
5587 /* rx or tx cause */
5588 msix_vector |= IXGBE_IVAR_ALLOC_VAL;
5589 idx = ((16 * (queue & 1)) + (8 * direction));
5590 tmp = IXGBE_READ_REG(hw, IXGBE_VTIVAR(queue >> 1));
5591 tmp &= ~(0xFF << idx);
5592 tmp |= (msix_vector << idx);
5593 IXGBE_WRITE_REG(hw, IXGBE_VTIVAR(queue >> 1), tmp);
5598 * set the IVAR registers, mapping interrupt causes to vectors
5600 * pointer to ixgbe_hw struct
5602 * 0 for Rx, 1 for Tx, -1 for other causes
5604 * queue to map the corresponding interrupt to
5606 * the vector to map to the corresponding queue
5609 ixgbe_set_ivar_map(struct ixgbe_hw *hw, int8_t direction,
5610 uint8_t queue, uint8_t msix_vector)
5614 msix_vector |= IXGBE_IVAR_ALLOC_VAL;
5615 if (hw->mac.type == ixgbe_mac_82598EB) {
5616 if (direction == -1)
5618 idx = (((direction * 64) + queue) >> 2) & 0x1F;
5619 tmp = IXGBE_READ_REG(hw, IXGBE_IVAR(idx));
5620 tmp &= ~(0xFF << (8 * (queue & 0x3)));
5621 tmp |= (msix_vector << (8 * (queue & 0x3)));
5622 IXGBE_WRITE_REG(hw, IXGBE_IVAR(idx), tmp);
5623 } else if ((hw->mac.type == ixgbe_mac_82599EB) ||
5624 (hw->mac.type == ixgbe_mac_X540)) {
5625 if (direction == -1) {
5627 idx = ((queue & 1) * 8);
5628 tmp = IXGBE_READ_REG(hw, IXGBE_IVAR_MISC);
5629 tmp &= ~(0xFF << idx);
5630 tmp |= (msix_vector << idx);
5631 IXGBE_WRITE_REG(hw, IXGBE_IVAR_MISC, tmp);
5633 /* rx or tx causes */
5634 idx = ((16 * (queue & 1)) + (8 * direction));
5635 tmp = IXGBE_READ_REG(hw, IXGBE_IVAR(queue >> 1));
5636 tmp &= ~(0xFF << idx);
5637 tmp |= (msix_vector << idx);
5638 IXGBE_WRITE_REG(hw, IXGBE_IVAR(queue >> 1), tmp);
5644 ixgbevf_configure_msix(struct rte_eth_dev *dev)
5646 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
5647 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
5648 struct ixgbe_hw *hw =
5649 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5651 uint32_t vector_idx = IXGBE_MISC_VEC_ID;
5653 /* Configure VF other cause ivar */
5654 ixgbevf_set_ivar_map(hw, -1, 1, vector_idx);
5656 /* won't configure msix register if no mapping is done
5657 * between intr vector and event fd.
5659 if (!rte_intr_dp_is_en(intr_handle))
5662 /* Configure all RX queues of VF */
5663 for (q_idx = 0; q_idx < dev->data->nb_rx_queues; q_idx++) {
5664 /* Force all queue use vector 0,
5665 * as IXGBE_VF_MAXMSIVECOTR = 1
5667 ixgbevf_set_ivar_map(hw, 0, q_idx, vector_idx);
5668 intr_handle->intr_vec[q_idx] = vector_idx;
5673 * Sets up the hardware to properly generate MSI-X interrupts
5675 * board private structure
5678 ixgbe_configure_msix(struct rte_eth_dev *dev)
5680 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
5681 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
5682 struct ixgbe_hw *hw =
5683 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5684 uint32_t queue_id, base = IXGBE_MISC_VEC_ID;
5685 uint32_t vec = IXGBE_MISC_VEC_ID;
5689 /* won't configure msix register if no mapping is done
5690 * between intr vector and event fd
5692 if (!rte_intr_dp_is_en(intr_handle))
5695 if (rte_intr_allow_others(intr_handle))
5696 vec = base = IXGBE_RX_VEC_START;
5698 /* setup GPIE for MSI-x mode */
5699 gpie = IXGBE_READ_REG(hw, IXGBE_GPIE);
5700 gpie |= IXGBE_GPIE_MSIX_MODE | IXGBE_GPIE_PBA_SUPPORT |
5701 IXGBE_GPIE_OCD | IXGBE_GPIE_EIAME;
5702 /* auto clearing and auto setting corresponding bits in EIMS
5703 * when MSI-X interrupt is triggered
5705 if (hw->mac.type == ixgbe_mac_82598EB) {
5706 IXGBE_WRITE_REG(hw, IXGBE_EIAM, IXGBE_EICS_RTX_QUEUE);
5708 IXGBE_WRITE_REG(hw, IXGBE_EIAM_EX(0), 0xFFFFFFFF);
5709 IXGBE_WRITE_REG(hw, IXGBE_EIAM_EX(1), 0xFFFFFFFF);
5711 IXGBE_WRITE_REG(hw, IXGBE_GPIE, gpie);
5713 /* Populate the IVAR table and set the ITR values to the
5714 * corresponding register.
5716 for (queue_id = 0; queue_id < dev->data->nb_rx_queues;
5718 /* by default, 1:1 mapping */
5719 ixgbe_set_ivar_map(hw, 0, queue_id, vec);
5720 intr_handle->intr_vec[queue_id] = vec;
5721 if (vec < base + intr_handle->nb_efd - 1)
5725 switch (hw->mac.type) {
5726 case ixgbe_mac_82598EB:
5727 ixgbe_set_ivar_map(hw, -1, IXGBE_IVAR_OTHER_CAUSES_INDEX,
5730 case ixgbe_mac_82599EB:
5731 case ixgbe_mac_X540:
5732 ixgbe_set_ivar_map(hw, -1, 1, IXGBE_MISC_VEC_ID);
5737 IXGBE_WRITE_REG(hw, IXGBE_EITR(IXGBE_MISC_VEC_ID),
5738 IXGBE_MIN_INTER_INTERRUPT_INTERVAL_DEFAULT & 0xFFF);
5740 /* set up to autoclear timer, and the vectors */
5741 mask = IXGBE_EIMS_ENABLE_MASK;
5742 mask &= ~(IXGBE_EIMS_OTHER |
5743 IXGBE_EIMS_MAILBOX |
5746 IXGBE_WRITE_REG(hw, IXGBE_EIAC, mask);
5749 static int ixgbe_set_queue_rate_limit(struct rte_eth_dev *dev,
5750 uint16_t queue_idx, uint16_t tx_rate)
5752 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5753 uint32_t rf_dec, rf_int;
5755 uint16_t link_speed = dev->data->dev_link.link_speed;
5757 if (queue_idx >= hw->mac.max_tx_queues)
5761 /* Calculate the rate factor values to set */
5762 rf_int = (uint32_t)link_speed / (uint32_t)tx_rate;
5763 rf_dec = (uint32_t)link_speed % (uint32_t)tx_rate;
5764 rf_dec = (rf_dec << IXGBE_RTTBCNRC_RF_INT_SHIFT) / tx_rate;
5766 bcnrc_val = IXGBE_RTTBCNRC_RS_ENA;
5767 bcnrc_val |= ((rf_int << IXGBE_RTTBCNRC_RF_INT_SHIFT) &
5768 IXGBE_RTTBCNRC_RF_INT_MASK_M);
5769 bcnrc_val |= (rf_dec & IXGBE_RTTBCNRC_RF_DEC_MASK);
5775 * Set global transmit compensation time to the MMW_SIZE in RTTBCNRM
5776 * register. MMW_SIZE=0x014 if 9728-byte jumbo is supported, otherwise
5779 if ((dev->data->dev_conf.rxmode.jumbo_frame == 1) &&
5780 (dev->data->dev_conf.rxmode.max_rx_pkt_len >=
5781 IXGBE_MAX_JUMBO_FRAME_SIZE))
5782 IXGBE_WRITE_REG(hw, IXGBE_RTTBCNRM,
5783 IXGBE_MMW_SIZE_JUMBO_FRAME);
5785 IXGBE_WRITE_REG(hw, IXGBE_RTTBCNRM,
5786 IXGBE_MMW_SIZE_DEFAULT);
5788 /* Set RTTBCNRC of queue X */
5789 IXGBE_WRITE_REG(hw, IXGBE_RTTDQSEL, queue_idx);
5790 IXGBE_WRITE_REG(hw, IXGBE_RTTBCNRC, bcnrc_val);
5791 IXGBE_WRITE_FLUSH(hw);
5797 ixgbevf_add_mac_addr(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
5798 __attribute__((unused)) uint32_t index,
5799 __attribute__((unused)) uint32_t pool)
5801 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5805 * On a 82599 VF, adding again the same MAC addr is not an idempotent
5806 * operation. Trap this case to avoid exhausting the [very limited]
5807 * set of PF resources used to store VF MAC addresses.
5809 if (memcmp(hw->mac.perm_addr, mac_addr, sizeof(struct ether_addr)) == 0)
5811 diag = ixgbevf_set_uc_addr_vf(hw, 2, mac_addr->addr_bytes);
5814 PMD_DRV_LOG(ERR, "Unable to add MAC address - diag=%d", diag);
5818 ixgbevf_remove_mac_addr(struct rte_eth_dev *dev, uint32_t index)
5820 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5821 struct ether_addr *perm_addr = (struct ether_addr *) hw->mac.perm_addr;
5822 struct ether_addr *mac_addr;
5827 * The IXGBE_VF_SET_MACVLAN command of the ixgbe-pf driver does
5828 * not support the deletion of a given MAC address.
5829 * Instead, it imposes to delete all MAC addresses, then to add again
5830 * all MAC addresses with the exception of the one to be deleted.
5832 (void) ixgbevf_set_uc_addr_vf(hw, 0, NULL);
5835 * Add again all MAC addresses, with the exception of the deleted one
5836 * and of the permanent MAC address.
5838 for (i = 0, mac_addr = dev->data->mac_addrs;
5839 i < hw->mac.num_rar_entries; i++, mac_addr++) {
5840 /* Skip the deleted MAC address */
5843 /* Skip NULL MAC addresses */
5844 if (is_zero_ether_addr(mac_addr))
5846 /* Skip the permanent MAC address */
5847 if (memcmp(perm_addr, mac_addr, sizeof(struct ether_addr)) == 0)
5849 diag = ixgbevf_set_uc_addr_vf(hw, 2, mac_addr->addr_bytes);
5852 "Adding again MAC address "
5853 "%02x:%02x:%02x:%02x:%02x:%02x failed "
5855 mac_addr->addr_bytes[0],
5856 mac_addr->addr_bytes[1],
5857 mac_addr->addr_bytes[2],
5858 mac_addr->addr_bytes[3],
5859 mac_addr->addr_bytes[4],
5860 mac_addr->addr_bytes[5],
5866 ixgbevf_set_default_mac_addr(struct rte_eth_dev *dev, struct ether_addr *addr)
5868 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5870 hw->mac.ops.set_rar(hw, 0, (void *)addr, 0, 0);
5873 #define MAC_TYPE_FILTER_SUP(type) do {\
5874 if ((type) != ixgbe_mac_82599EB && (type) != ixgbe_mac_X540 &&\
5875 (type) != ixgbe_mac_X550 && (type) != ixgbe_mac_X550EM_x &&\
5876 (type) != ixgbe_mac_X550EM_a)\
5881 ixgbe_syn_filter_set(struct rte_eth_dev *dev,
5882 struct rte_eth_syn_filter *filter,
5885 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5886 struct ixgbe_filter_info *filter_info =
5887 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
5891 if (filter->queue >= IXGBE_MAX_RX_QUEUE_NUM)
5894 syn_info = filter_info->syn_info;
5897 if (syn_info & IXGBE_SYN_FILTER_ENABLE)
5899 synqf = (uint32_t)(((filter->queue << IXGBE_SYN_FILTER_QUEUE_SHIFT) &
5900 IXGBE_SYN_FILTER_QUEUE) | IXGBE_SYN_FILTER_ENABLE);
5902 if (filter->hig_pri)
5903 synqf |= IXGBE_SYN_FILTER_SYNQFP;
5905 synqf &= ~IXGBE_SYN_FILTER_SYNQFP;
5907 synqf = IXGBE_READ_REG(hw, IXGBE_SYNQF);
5908 if (!(syn_info & IXGBE_SYN_FILTER_ENABLE))
5910 synqf &= ~(IXGBE_SYN_FILTER_QUEUE | IXGBE_SYN_FILTER_ENABLE);
5913 filter_info->syn_info = synqf;
5914 IXGBE_WRITE_REG(hw, IXGBE_SYNQF, synqf);
5915 IXGBE_WRITE_FLUSH(hw);
5920 ixgbe_syn_filter_get(struct rte_eth_dev *dev,
5921 struct rte_eth_syn_filter *filter)
5923 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5924 uint32_t synqf = IXGBE_READ_REG(hw, IXGBE_SYNQF);
5926 if (synqf & IXGBE_SYN_FILTER_ENABLE) {
5927 filter->hig_pri = (synqf & IXGBE_SYN_FILTER_SYNQFP) ? 1 : 0;
5928 filter->queue = (uint16_t)((synqf & IXGBE_SYN_FILTER_QUEUE) >> 1);
5935 ixgbe_syn_filter_handle(struct rte_eth_dev *dev,
5936 enum rte_filter_op filter_op,
5939 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5942 MAC_TYPE_FILTER_SUP(hw->mac.type);
5944 if (filter_op == RTE_ETH_FILTER_NOP)
5948 PMD_DRV_LOG(ERR, "arg shouldn't be NULL for operation %u",
5953 switch (filter_op) {
5954 case RTE_ETH_FILTER_ADD:
5955 ret = ixgbe_syn_filter_set(dev,
5956 (struct rte_eth_syn_filter *)arg,
5959 case RTE_ETH_FILTER_DELETE:
5960 ret = ixgbe_syn_filter_set(dev,
5961 (struct rte_eth_syn_filter *)arg,
5964 case RTE_ETH_FILTER_GET:
5965 ret = ixgbe_syn_filter_get(dev,
5966 (struct rte_eth_syn_filter *)arg);
5969 PMD_DRV_LOG(ERR, "unsupported operation %u\n", filter_op);
5978 static inline enum ixgbe_5tuple_protocol
5979 convert_protocol_type(uint8_t protocol_value)
5981 if (protocol_value == IPPROTO_TCP)
5982 return IXGBE_FILTER_PROTOCOL_TCP;
5983 else if (protocol_value == IPPROTO_UDP)
5984 return IXGBE_FILTER_PROTOCOL_UDP;
5985 else if (protocol_value == IPPROTO_SCTP)
5986 return IXGBE_FILTER_PROTOCOL_SCTP;
5988 return IXGBE_FILTER_PROTOCOL_NONE;
5992 * add a 5tuple filter
5995 * dev: Pointer to struct rte_eth_dev.
5996 * index: the index the filter allocates.
5997 * filter: ponter to the filter that will be added.
5998 * rx_queue: the queue id the filter assigned to.
6001 * - On success, zero.
6002 * - On failure, a negative value.
6005 ixgbe_add_5tuple_filter(struct rte_eth_dev *dev,
6006 struct ixgbe_5tuple_filter *filter)
6008 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6009 struct ixgbe_filter_info *filter_info =
6010 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6012 uint32_t ftqf, sdpqf;
6013 uint32_t l34timir = 0;
6014 uint8_t mask = 0xff;
6017 * look for an unused 5tuple filter index,
6018 * and insert the filter to list.
6020 for (i = 0; i < IXGBE_MAX_FTQF_FILTERS; i++) {
6021 idx = i / (sizeof(uint32_t) * NBBY);
6022 shift = i % (sizeof(uint32_t) * NBBY);
6023 if (!(filter_info->fivetuple_mask[idx] & (1 << shift))) {
6024 filter_info->fivetuple_mask[idx] |= 1 << shift;
6026 TAILQ_INSERT_TAIL(&filter_info->fivetuple_list,
6032 if (i >= IXGBE_MAX_FTQF_FILTERS) {
6033 PMD_DRV_LOG(ERR, "5tuple filters are full.");
6037 sdpqf = (uint32_t)(filter->filter_info.dst_port <<
6038 IXGBE_SDPQF_DSTPORT_SHIFT);
6039 sdpqf = sdpqf | (filter->filter_info.src_port & IXGBE_SDPQF_SRCPORT);
6041 ftqf = (uint32_t)(filter->filter_info.proto &
6042 IXGBE_FTQF_PROTOCOL_MASK);
6043 ftqf |= (uint32_t)((filter->filter_info.priority &
6044 IXGBE_FTQF_PRIORITY_MASK) << IXGBE_FTQF_PRIORITY_SHIFT);
6045 if (filter->filter_info.src_ip_mask == 0) /* 0 means compare. */
6046 mask &= IXGBE_FTQF_SOURCE_ADDR_MASK;
6047 if (filter->filter_info.dst_ip_mask == 0)
6048 mask &= IXGBE_FTQF_DEST_ADDR_MASK;
6049 if (filter->filter_info.src_port_mask == 0)
6050 mask &= IXGBE_FTQF_SOURCE_PORT_MASK;
6051 if (filter->filter_info.dst_port_mask == 0)
6052 mask &= IXGBE_FTQF_DEST_PORT_MASK;
6053 if (filter->filter_info.proto_mask == 0)
6054 mask &= IXGBE_FTQF_PROTOCOL_COMP_MASK;
6055 ftqf |= mask << IXGBE_FTQF_5TUPLE_MASK_SHIFT;
6056 ftqf |= IXGBE_FTQF_POOL_MASK_EN;
6057 ftqf |= IXGBE_FTQF_QUEUE_ENABLE;
6059 IXGBE_WRITE_REG(hw, IXGBE_DAQF(i), filter->filter_info.dst_ip);
6060 IXGBE_WRITE_REG(hw, IXGBE_SAQF(i), filter->filter_info.src_ip);
6061 IXGBE_WRITE_REG(hw, IXGBE_SDPQF(i), sdpqf);
6062 IXGBE_WRITE_REG(hw, IXGBE_FTQF(i), ftqf);
6064 l34timir |= IXGBE_L34T_IMIR_RESERVE;
6065 l34timir |= (uint32_t)(filter->queue <<
6066 IXGBE_L34T_IMIR_QUEUE_SHIFT);
6067 IXGBE_WRITE_REG(hw, IXGBE_L34T_IMIR(i), l34timir);
6072 * remove a 5tuple filter
6075 * dev: Pointer to struct rte_eth_dev.
6076 * filter: the pointer of the filter will be removed.
6079 ixgbe_remove_5tuple_filter(struct rte_eth_dev *dev,
6080 struct ixgbe_5tuple_filter *filter)
6082 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6083 struct ixgbe_filter_info *filter_info =
6084 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6085 uint16_t index = filter->index;
6087 filter_info->fivetuple_mask[index / (sizeof(uint32_t) * NBBY)] &=
6088 ~(1 << (index % (sizeof(uint32_t) * NBBY)));
6089 TAILQ_REMOVE(&filter_info->fivetuple_list, filter, entries);
6092 IXGBE_WRITE_REG(hw, IXGBE_DAQF(index), 0);
6093 IXGBE_WRITE_REG(hw, IXGBE_SAQF(index), 0);
6094 IXGBE_WRITE_REG(hw, IXGBE_SDPQF(index), 0);
6095 IXGBE_WRITE_REG(hw, IXGBE_FTQF(index), 0);
6096 IXGBE_WRITE_REG(hw, IXGBE_L34T_IMIR(index), 0);
6100 ixgbevf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
6102 struct ixgbe_hw *hw;
6103 uint32_t max_frame = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
6105 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6107 if ((mtu < ETHER_MIN_MTU) || (max_frame > ETHER_MAX_JUMBO_FRAME_LEN))
6110 /* refuse mtu that requires the support of scattered packets when this
6111 * feature has not been enabled before.
6113 if (!dev->data->scattered_rx &&
6114 (max_frame + 2 * IXGBE_VLAN_TAG_SIZE >
6115 dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM))
6119 * When supported by the underlying PF driver, use the IXGBE_VF_SET_MTU
6120 * request of the version 2.0 of the mailbox API.
6121 * For now, use the IXGBE_VF_SET_LPE request of the version 1.0
6122 * of the mailbox API.
6123 * This call to IXGBE_SET_LPE action won't work with ixgbe pf drivers
6124 * prior to 3.11.33 which contains the following change:
6125 * "ixgbe: Enable jumbo frames support w/ SR-IOV"
6127 ixgbevf_rlpml_set_vf(hw, max_frame);
6129 /* update max frame size */
6130 dev->data->dev_conf.rxmode.max_rx_pkt_len = max_frame;
6134 #define MAC_TYPE_FILTER_SUP_EXT(type) do {\
6135 if ((type) != ixgbe_mac_82599EB && (type) != ixgbe_mac_X540)\
6139 static inline struct ixgbe_5tuple_filter *
6140 ixgbe_5tuple_filter_lookup(struct ixgbe_5tuple_filter_list *filter_list,
6141 struct ixgbe_5tuple_filter_info *key)
6143 struct ixgbe_5tuple_filter *it;
6145 TAILQ_FOREACH(it, filter_list, entries) {
6146 if (memcmp(key, &it->filter_info,
6147 sizeof(struct ixgbe_5tuple_filter_info)) == 0) {
6154 /* translate elements in struct rte_eth_ntuple_filter to struct ixgbe_5tuple_filter_info*/
6156 ntuple_filter_to_5tuple(struct rte_eth_ntuple_filter *filter,
6157 struct ixgbe_5tuple_filter_info *filter_info)
6159 if (filter->queue >= IXGBE_MAX_RX_QUEUE_NUM ||
6160 filter->priority > IXGBE_5TUPLE_MAX_PRI ||
6161 filter->priority < IXGBE_5TUPLE_MIN_PRI)
6164 switch (filter->dst_ip_mask) {
6166 filter_info->dst_ip_mask = 0;
6167 filter_info->dst_ip = filter->dst_ip;
6170 filter_info->dst_ip_mask = 1;
6173 PMD_DRV_LOG(ERR, "invalid dst_ip mask.");
6177 switch (filter->src_ip_mask) {
6179 filter_info->src_ip_mask = 0;
6180 filter_info->src_ip = filter->src_ip;
6183 filter_info->src_ip_mask = 1;
6186 PMD_DRV_LOG(ERR, "invalid src_ip mask.");
6190 switch (filter->dst_port_mask) {
6192 filter_info->dst_port_mask = 0;
6193 filter_info->dst_port = filter->dst_port;
6196 filter_info->dst_port_mask = 1;
6199 PMD_DRV_LOG(ERR, "invalid dst_port mask.");
6203 switch (filter->src_port_mask) {
6205 filter_info->src_port_mask = 0;
6206 filter_info->src_port = filter->src_port;
6209 filter_info->src_port_mask = 1;
6212 PMD_DRV_LOG(ERR, "invalid src_port mask.");
6216 switch (filter->proto_mask) {
6218 filter_info->proto_mask = 0;
6219 filter_info->proto =
6220 convert_protocol_type(filter->proto);
6223 filter_info->proto_mask = 1;
6226 PMD_DRV_LOG(ERR, "invalid protocol mask.");
6230 filter_info->priority = (uint8_t)filter->priority;
6235 * add or delete a ntuple filter
6238 * dev: Pointer to struct rte_eth_dev.
6239 * ntuple_filter: Pointer to struct rte_eth_ntuple_filter
6240 * add: if true, add filter, if false, remove filter
6243 * - On success, zero.
6244 * - On failure, a negative value.
6247 ixgbe_add_del_ntuple_filter(struct rte_eth_dev *dev,
6248 struct rte_eth_ntuple_filter *ntuple_filter,
6251 struct ixgbe_filter_info *filter_info =
6252 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6253 struct ixgbe_5tuple_filter_info filter_5tuple;
6254 struct ixgbe_5tuple_filter *filter;
6257 if (ntuple_filter->flags != RTE_5TUPLE_FLAGS) {
6258 PMD_DRV_LOG(ERR, "only 5tuple is supported.");
6262 memset(&filter_5tuple, 0, sizeof(struct ixgbe_5tuple_filter_info));
6263 ret = ntuple_filter_to_5tuple(ntuple_filter, &filter_5tuple);
6267 filter = ixgbe_5tuple_filter_lookup(&filter_info->fivetuple_list,
6269 if (filter != NULL && add) {
6270 PMD_DRV_LOG(ERR, "filter exists.");
6273 if (filter == NULL && !add) {
6274 PMD_DRV_LOG(ERR, "filter doesn't exist.");
6279 filter = rte_zmalloc("ixgbe_5tuple_filter",
6280 sizeof(struct ixgbe_5tuple_filter), 0);
6283 (void)rte_memcpy(&filter->filter_info,
6285 sizeof(struct ixgbe_5tuple_filter_info));
6286 filter->queue = ntuple_filter->queue;
6287 ret = ixgbe_add_5tuple_filter(dev, filter);
6293 ixgbe_remove_5tuple_filter(dev, filter);
6299 * get a ntuple filter
6302 * dev: Pointer to struct rte_eth_dev.
6303 * ntuple_filter: Pointer to struct rte_eth_ntuple_filter
6306 * - On success, zero.
6307 * - On failure, a negative value.
6310 ixgbe_get_ntuple_filter(struct rte_eth_dev *dev,
6311 struct rte_eth_ntuple_filter *ntuple_filter)
6313 struct ixgbe_filter_info *filter_info =
6314 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6315 struct ixgbe_5tuple_filter_info filter_5tuple;
6316 struct ixgbe_5tuple_filter *filter;
6319 if (ntuple_filter->flags != RTE_5TUPLE_FLAGS) {
6320 PMD_DRV_LOG(ERR, "only 5tuple is supported.");
6324 memset(&filter_5tuple, 0, sizeof(struct ixgbe_5tuple_filter_info));
6325 ret = ntuple_filter_to_5tuple(ntuple_filter, &filter_5tuple);
6329 filter = ixgbe_5tuple_filter_lookup(&filter_info->fivetuple_list,
6331 if (filter == NULL) {
6332 PMD_DRV_LOG(ERR, "filter doesn't exist.");
6335 ntuple_filter->queue = filter->queue;
6340 * ixgbe_ntuple_filter_handle - Handle operations for ntuple filter.
6341 * @dev: pointer to rte_eth_dev structure
6342 * @filter_op:operation will be taken.
6343 * @arg: a pointer to specific structure corresponding to the filter_op
6346 * - On success, zero.
6347 * - On failure, a negative value.
6350 ixgbe_ntuple_filter_handle(struct rte_eth_dev *dev,
6351 enum rte_filter_op filter_op,
6354 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6357 MAC_TYPE_FILTER_SUP_EXT(hw->mac.type);
6359 if (filter_op == RTE_ETH_FILTER_NOP)
6363 PMD_DRV_LOG(ERR, "arg shouldn't be NULL for operation %u.",
6368 switch (filter_op) {
6369 case RTE_ETH_FILTER_ADD:
6370 ret = ixgbe_add_del_ntuple_filter(dev,
6371 (struct rte_eth_ntuple_filter *)arg,
6374 case RTE_ETH_FILTER_DELETE:
6375 ret = ixgbe_add_del_ntuple_filter(dev,
6376 (struct rte_eth_ntuple_filter *)arg,
6379 case RTE_ETH_FILTER_GET:
6380 ret = ixgbe_get_ntuple_filter(dev,
6381 (struct rte_eth_ntuple_filter *)arg);
6384 PMD_DRV_LOG(ERR, "unsupported operation %u.", filter_op);
6392 ixgbe_ethertype_filter_lookup(struct ixgbe_filter_info *filter_info,
6397 for (i = 0; i < IXGBE_MAX_ETQF_FILTERS; i++) {
6398 if (filter_info->ethertype_filters[i] == ethertype &&
6399 (filter_info->ethertype_mask & (1 << i)))
6406 ixgbe_ethertype_filter_insert(struct ixgbe_filter_info *filter_info,
6411 for (i = 0; i < IXGBE_MAX_ETQF_FILTERS; i++) {
6412 if (!(filter_info->ethertype_mask & (1 << i))) {
6413 filter_info->ethertype_mask |= 1 << i;
6414 filter_info->ethertype_filters[i] = ethertype;
6422 ixgbe_ethertype_filter_remove(struct ixgbe_filter_info *filter_info,
6425 if (idx >= IXGBE_MAX_ETQF_FILTERS)
6427 filter_info->ethertype_mask &= ~(1 << idx);
6428 filter_info->ethertype_filters[idx] = 0;
6433 ixgbe_add_del_ethertype_filter(struct rte_eth_dev *dev,
6434 struct rte_eth_ethertype_filter *filter,
6437 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6438 struct ixgbe_filter_info *filter_info =
6439 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6444 if (filter->queue >= IXGBE_MAX_RX_QUEUE_NUM)
6447 if (filter->ether_type == ETHER_TYPE_IPv4 ||
6448 filter->ether_type == ETHER_TYPE_IPv6) {
6449 PMD_DRV_LOG(ERR, "unsupported ether_type(0x%04x) in"
6450 " ethertype filter.", filter->ether_type);
6454 if (filter->flags & RTE_ETHTYPE_FLAGS_MAC) {
6455 PMD_DRV_LOG(ERR, "mac compare is unsupported.");
6458 if (filter->flags & RTE_ETHTYPE_FLAGS_DROP) {
6459 PMD_DRV_LOG(ERR, "drop option is unsupported.");
6463 ret = ixgbe_ethertype_filter_lookup(filter_info, filter->ether_type);
6464 if (ret >= 0 && add) {
6465 PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter exists.",
6466 filter->ether_type);
6469 if (ret < 0 && !add) {
6470 PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter doesn't exist.",
6471 filter->ether_type);
6476 ret = ixgbe_ethertype_filter_insert(filter_info,
6477 filter->ether_type);
6479 PMD_DRV_LOG(ERR, "ethertype filters are full.");
6482 etqf = IXGBE_ETQF_FILTER_EN;
6483 etqf |= (uint32_t)filter->ether_type;
6484 etqs |= (uint32_t)((filter->queue <<
6485 IXGBE_ETQS_RX_QUEUE_SHIFT) &
6486 IXGBE_ETQS_RX_QUEUE);
6487 etqs |= IXGBE_ETQS_QUEUE_EN;
6489 ret = ixgbe_ethertype_filter_remove(filter_info, (uint8_t)ret);
6493 IXGBE_WRITE_REG(hw, IXGBE_ETQF(ret), etqf);
6494 IXGBE_WRITE_REG(hw, IXGBE_ETQS(ret), etqs);
6495 IXGBE_WRITE_FLUSH(hw);
6501 ixgbe_get_ethertype_filter(struct rte_eth_dev *dev,
6502 struct rte_eth_ethertype_filter *filter)
6504 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6505 struct ixgbe_filter_info *filter_info =
6506 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6507 uint32_t etqf, etqs;
6510 ret = ixgbe_ethertype_filter_lookup(filter_info, filter->ether_type);
6512 PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter doesn't exist.",
6513 filter->ether_type);
6517 etqf = IXGBE_READ_REG(hw, IXGBE_ETQF(ret));
6518 if (etqf & IXGBE_ETQF_FILTER_EN) {
6519 etqs = IXGBE_READ_REG(hw, IXGBE_ETQS(ret));
6520 filter->ether_type = etqf & IXGBE_ETQF_ETHERTYPE;
6522 filter->queue = (etqs & IXGBE_ETQS_RX_QUEUE) >>
6523 IXGBE_ETQS_RX_QUEUE_SHIFT;
6530 * ixgbe_ethertype_filter_handle - Handle operations for ethertype filter.
6531 * @dev: pointer to rte_eth_dev structure
6532 * @filter_op:operation will be taken.
6533 * @arg: a pointer to specific structure corresponding to the filter_op
6536 ixgbe_ethertype_filter_handle(struct rte_eth_dev *dev,
6537 enum rte_filter_op filter_op,
6540 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6543 MAC_TYPE_FILTER_SUP(hw->mac.type);
6545 if (filter_op == RTE_ETH_FILTER_NOP)
6549 PMD_DRV_LOG(ERR, "arg shouldn't be NULL for operation %u.",
6554 switch (filter_op) {
6555 case RTE_ETH_FILTER_ADD:
6556 ret = ixgbe_add_del_ethertype_filter(dev,
6557 (struct rte_eth_ethertype_filter *)arg,
6560 case RTE_ETH_FILTER_DELETE:
6561 ret = ixgbe_add_del_ethertype_filter(dev,
6562 (struct rte_eth_ethertype_filter *)arg,
6565 case RTE_ETH_FILTER_GET:
6566 ret = ixgbe_get_ethertype_filter(dev,
6567 (struct rte_eth_ethertype_filter *)arg);
6570 PMD_DRV_LOG(ERR, "unsupported operation %u.", filter_op);
6578 ixgbe_dev_filter_ctrl(struct rte_eth_dev *dev,
6579 enum rte_filter_type filter_type,
6580 enum rte_filter_op filter_op,
6585 switch (filter_type) {
6586 case RTE_ETH_FILTER_NTUPLE:
6587 ret = ixgbe_ntuple_filter_handle(dev, filter_op, arg);
6589 case RTE_ETH_FILTER_ETHERTYPE:
6590 ret = ixgbe_ethertype_filter_handle(dev, filter_op, arg);
6592 case RTE_ETH_FILTER_SYN:
6593 ret = ixgbe_syn_filter_handle(dev, filter_op, arg);
6595 case RTE_ETH_FILTER_FDIR:
6596 ret = ixgbe_fdir_ctrl_func(dev, filter_op, arg);
6598 case RTE_ETH_FILTER_L2_TUNNEL:
6599 ret = ixgbe_dev_l2_tunnel_filter_handle(dev, filter_op, arg);
6602 PMD_DRV_LOG(WARNING, "Filter type (%d) not supported",
6611 ixgbe_dev_addr_list_itr(__attribute__((unused)) struct ixgbe_hw *hw,
6612 u8 **mc_addr_ptr, u32 *vmdq)
6617 mc_addr = *mc_addr_ptr;
6618 *mc_addr_ptr = (mc_addr + sizeof(struct ether_addr));
6623 ixgbe_dev_set_mc_addr_list(struct rte_eth_dev *dev,
6624 struct ether_addr *mc_addr_set,
6625 uint32_t nb_mc_addr)
6627 struct ixgbe_hw *hw;
6630 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6631 mc_addr_list = (u8 *)mc_addr_set;
6632 return ixgbe_update_mc_addr_list(hw, mc_addr_list, nb_mc_addr,
6633 ixgbe_dev_addr_list_itr, TRUE);
6637 ixgbe_read_systime_cyclecounter(struct rte_eth_dev *dev)
6639 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6640 uint64_t systime_cycles;
6642 switch (hw->mac.type) {
6643 case ixgbe_mac_X550:
6644 case ixgbe_mac_X550EM_x:
6645 case ixgbe_mac_X550EM_a:
6646 /* SYSTIMEL stores ns and SYSTIMEH stores seconds. */
6647 systime_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_SYSTIML);
6648 systime_cycles += (uint64_t)IXGBE_READ_REG(hw, IXGBE_SYSTIMH)
6652 systime_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_SYSTIML);
6653 systime_cycles |= (uint64_t)IXGBE_READ_REG(hw, IXGBE_SYSTIMH)
6657 return systime_cycles;
6661 ixgbe_read_rx_tstamp_cyclecounter(struct rte_eth_dev *dev)
6663 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6664 uint64_t rx_tstamp_cycles;
6666 switch (hw->mac.type) {
6667 case ixgbe_mac_X550:
6668 case ixgbe_mac_X550EM_x:
6669 case ixgbe_mac_X550EM_a:
6670 /* RXSTMPL stores ns and RXSTMPH stores seconds. */
6671 rx_tstamp_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_RXSTMPL);
6672 rx_tstamp_cycles += (uint64_t)IXGBE_READ_REG(hw, IXGBE_RXSTMPH)
6676 /* RXSTMPL stores ns and RXSTMPH stores seconds. */
6677 rx_tstamp_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_RXSTMPL);
6678 rx_tstamp_cycles |= (uint64_t)IXGBE_READ_REG(hw, IXGBE_RXSTMPH)
6682 return rx_tstamp_cycles;
6686 ixgbe_read_tx_tstamp_cyclecounter(struct rte_eth_dev *dev)
6688 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6689 uint64_t tx_tstamp_cycles;
6691 switch (hw->mac.type) {
6692 case ixgbe_mac_X550:
6693 case ixgbe_mac_X550EM_x:
6694 case ixgbe_mac_X550EM_a:
6695 /* TXSTMPL stores ns and TXSTMPH stores seconds. */
6696 tx_tstamp_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_TXSTMPL);
6697 tx_tstamp_cycles += (uint64_t)IXGBE_READ_REG(hw, IXGBE_TXSTMPH)
6701 /* TXSTMPL stores ns and TXSTMPH stores seconds. */
6702 tx_tstamp_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_TXSTMPL);
6703 tx_tstamp_cycles |= (uint64_t)IXGBE_READ_REG(hw, IXGBE_TXSTMPH)
6707 return tx_tstamp_cycles;
6711 ixgbe_start_timecounters(struct rte_eth_dev *dev)
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 struct rte_eth_link link;
6717 uint32_t incval = 0;
6720 /* Get current link speed. */
6721 memset(&link, 0, sizeof(link));
6722 ixgbe_dev_link_update(dev, 1);
6723 rte_ixgbe_dev_atomic_read_link_status(dev, &link);
6725 switch (link.link_speed) {
6726 case ETH_SPEED_NUM_100M:
6727 incval = IXGBE_INCVAL_100;
6728 shift = IXGBE_INCVAL_SHIFT_100;
6730 case ETH_SPEED_NUM_1G:
6731 incval = IXGBE_INCVAL_1GB;
6732 shift = IXGBE_INCVAL_SHIFT_1GB;
6734 case ETH_SPEED_NUM_10G:
6736 incval = IXGBE_INCVAL_10GB;
6737 shift = IXGBE_INCVAL_SHIFT_10GB;
6741 switch (hw->mac.type) {
6742 case ixgbe_mac_X550:
6743 case ixgbe_mac_X550EM_x:
6744 case ixgbe_mac_X550EM_a:
6745 /* Independent of link speed. */
6747 /* Cycles read will be interpreted as ns. */
6750 case ixgbe_mac_X540:
6751 IXGBE_WRITE_REG(hw, IXGBE_TIMINCA, incval);
6753 case ixgbe_mac_82599EB:
6754 incval >>= IXGBE_INCVAL_SHIFT_82599;
6755 shift -= IXGBE_INCVAL_SHIFT_82599;
6756 IXGBE_WRITE_REG(hw, IXGBE_TIMINCA,
6757 (1 << IXGBE_INCPER_SHIFT_82599) | incval);
6760 /* Not supported. */
6764 memset(&adapter->systime_tc, 0, sizeof(struct rte_timecounter));
6765 memset(&adapter->rx_tstamp_tc, 0, sizeof(struct rte_timecounter));
6766 memset(&adapter->tx_tstamp_tc, 0, sizeof(struct rte_timecounter));
6768 adapter->systime_tc.cc_mask = IXGBE_CYCLECOUNTER_MASK;
6769 adapter->systime_tc.cc_shift = shift;
6770 adapter->systime_tc.nsec_mask = (1ULL << shift) - 1;
6772 adapter->rx_tstamp_tc.cc_mask = IXGBE_CYCLECOUNTER_MASK;
6773 adapter->rx_tstamp_tc.cc_shift = shift;
6774 adapter->rx_tstamp_tc.nsec_mask = (1ULL << shift) - 1;
6776 adapter->tx_tstamp_tc.cc_mask = IXGBE_CYCLECOUNTER_MASK;
6777 adapter->tx_tstamp_tc.cc_shift = shift;
6778 adapter->tx_tstamp_tc.nsec_mask = (1ULL << shift) - 1;
6782 ixgbe_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta)
6784 struct ixgbe_adapter *adapter =
6785 (struct ixgbe_adapter *)dev->data->dev_private;
6787 adapter->systime_tc.nsec += delta;
6788 adapter->rx_tstamp_tc.nsec += delta;
6789 adapter->tx_tstamp_tc.nsec += delta;
6795 ixgbe_timesync_write_time(struct rte_eth_dev *dev, const struct timespec *ts)
6798 struct ixgbe_adapter *adapter =
6799 (struct ixgbe_adapter *)dev->data->dev_private;
6801 ns = rte_timespec_to_ns(ts);
6802 /* Set the timecounters to a new value. */
6803 adapter->systime_tc.nsec = ns;
6804 adapter->rx_tstamp_tc.nsec = ns;
6805 adapter->tx_tstamp_tc.nsec = ns;
6811 ixgbe_timesync_read_time(struct rte_eth_dev *dev, struct timespec *ts)
6813 uint64_t ns, systime_cycles;
6814 struct ixgbe_adapter *adapter =
6815 (struct ixgbe_adapter *)dev->data->dev_private;
6817 systime_cycles = ixgbe_read_systime_cyclecounter(dev);
6818 ns = rte_timecounter_update(&adapter->systime_tc, systime_cycles);
6819 *ts = rte_ns_to_timespec(ns);
6825 ixgbe_timesync_enable(struct rte_eth_dev *dev)
6827 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6831 /* Stop the timesync system time. */
6832 IXGBE_WRITE_REG(hw, IXGBE_TIMINCA, 0x0);
6833 /* Reset the timesync system time value. */
6834 IXGBE_WRITE_REG(hw, IXGBE_SYSTIML, 0x0);
6835 IXGBE_WRITE_REG(hw, IXGBE_SYSTIMH, 0x0);
6837 /* Enable system time for platforms where it isn't on by default. */
6838 tsauxc = IXGBE_READ_REG(hw, IXGBE_TSAUXC);
6839 tsauxc &= ~IXGBE_TSAUXC_DISABLE_SYSTIME;
6840 IXGBE_WRITE_REG(hw, IXGBE_TSAUXC, tsauxc);
6842 ixgbe_start_timecounters(dev);
6844 /* Enable L2 filtering of IEEE1588/802.1AS Ethernet frame types. */
6845 IXGBE_WRITE_REG(hw, IXGBE_ETQF(IXGBE_ETQF_FILTER_1588),
6847 IXGBE_ETQF_FILTER_EN |
6850 /* Enable timestamping of received PTP packets. */
6851 tsync_ctl = IXGBE_READ_REG(hw, IXGBE_TSYNCRXCTL);
6852 tsync_ctl |= IXGBE_TSYNCRXCTL_ENABLED;
6853 IXGBE_WRITE_REG(hw, IXGBE_TSYNCRXCTL, tsync_ctl);
6855 /* Enable timestamping of transmitted PTP packets. */
6856 tsync_ctl = IXGBE_READ_REG(hw, IXGBE_TSYNCTXCTL);
6857 tsync_ctl |= IXGBE_TSYNCTXCTL_ENABLED;
6858 IXGBE_WRITE_REG(hw, IXGBE_TSYNCTXCTL, tsync_ctl);
6860 IXGBE_WRITE_FLUSH(hw);
6866 ixgbe_timesync_disable(struct rte_eth_dev *dev)
6868 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6871 /* Disable timestamping of transmitted PTP packets. */
6872 tsync_ctl = IXGBE_READ_REG(hw, IXGBE_TSYNCTXCTL);
6873 tsync_ctl &= ~IXGBE_TSYNCTXCTL_ENABLED;
6874 IXGBE_WRITE_REG(hw, IXGBE_TSYNCTXCTL, tsync_ctl);
6876 /* Disable timestamping of received PTP packets. */
6877 tsync_ctl = IXGBE_READ_REG(hw, IXGBE_TSYNCRXCTL);
6878 tsync_ctl &= ~IXGBE_TSYNCRXCTL_ENABLED;
6879 IXGBE_WRITE_REG(hw, IXGBE_TSYNCRXCTL, tsync_ctl);
6881 /* Disable L2 filtering of IEEE1588/802.1AS Ethernet frame types. */
6882 IXGBE_WRITE_REG(hw, IXGBE_ETQF(IXGBE_ETQF_FILTER_1588), 0);
6884 /* Stop incrementating the System Time registers. */
6885 IXGBE_WRITE_REG(hw, IXGBE_TIMINCA, 0);
6891 ixgbe_timesync_read_rx_timestamp(struct rte_eth_dev *dev,
6892 struct timespec *timestamp,
6893 uint32_t flags __rte_unused)
6895 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6896 struct ixgbe_adapter *adapter =
6897 (struct ixgbe_adapter *)dev->data->dev_private;
6898 uint32_t tsync_rxctl;
6899 uint64_t rx_tstamp_cycles;
6902 tsync_rxctl = IXGBE_READ_REG(hw, IXGBE_TSYNCRXCTL);
6903 if ((tsync_rxctl & IXGBE_TSYNCRXCTL_VALID) == 0)
6906 rx_tstamp_cycles = ixgbe_read_rx_tstamp_cyclecounter(dev);
6907 ns = rte_timecounter_update(&adapter->rx_tstamp_tc, rx_tstamp_cycles);
6908 *timestamp = rte_ns_to_timespec(ns);
6914 ixgbe_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
6915 struct timespec *timestamp)
6917 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6918 struct ixgbe_adapter *adapter =
6919 (struct ixgbe_adapter *)dev->data->dev_private;
6920 uint32_t tsync_txctl;
6921 uint64_t tx_tstamp_cycles;
6924 tsync_txctl = IXGBE_READ_REG(hw, IXGBE_TSYNCTXCTL);
6925 if ((tsync_txctl & IXGBE_TSYNCTXCTL_VALID) == 0)
6928 tx_tstamp_cycles = ixgbe_read_tx_tstamp_cyclecounter(dev);
6929 ns = rte_timecounter_update(&adapter->tx_tstamp_tc, tx_tstamp_cycles);
6930 *timestamp = rte_ns_to_timespec(ns);
6936 ixgbe_get_reg_length(struct rte_eth_dev *dev)
6938 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6941 const struct reg_info *reg_group;
6942 const struct reg_info **reg_set = (hw->mac.type == ixgbe_mac_82598EB) ?
6943 ixgbe_regs_mac_82598EB : ixgbe_regs_others;
6945 while ((reg_group = reg_set[g_ind++]))
6946 count += ixgbe_regs_group_count(reg_group);
6952 ixgbevf_get_reg_length(struct rte_eth_dev *dev __rte_unused)
6956 const struct reg_info *reg_group;
6958 while ((reg_group = ixgbevf_regs[g_ind++]))
6959 count += ixgbe_regs_group_count(reg_group);
6965 ixgbe_get_regs(struct rte_eth_dev *dev,
6966 struct rte_dev_reg_info *regs)
6968 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6969 uint32_t *data = regs->data;
6972 const struct reg_info *reg_group;
6973 const struct reg_info **reg_set = (hw->mac.type == ixgbe_mac_82598EB) ?
6974 ixgbe_regs_mac_82598EB : ixgbe_regs_others;
6977 regs->length = ixgbe_get_reg_length(dev);
6978 regs->width = sizeof(uint32_t);
6982 /* Support only full register dump */
6983 if ((regs->length == 0) ||
6984 (regs->length == (uint32_t)ixgbe_get_reg_length(dev))) {
6985 regs->version = hw->mac.type << 24 | hw->revision_id << 16 |
6987 while ((reg_group = reg_set[g_ind++]))
6988 count += ixgbe_read_regs_group(dev, &data[count],
6997 ixgbevf_get_regs(struct rte_eth_dev *dev,
6998 struct rte_dev_reg_info *regs)
7000 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7001 uint32_t *data = regs->data;
7004 const struct reg_info *reg_group;
7007 regs->length = ixgbevf_get_reg_length(dev);
7008 regs->width = sizeof(uint32_t);
7012 /* Support only full register dump */
7013 if ((regs->length == 0) ||
7014 (regs->length == (uint32_t)ixgbevf_get_reg_length(dev))) {
7015 regs->version = hw->mac.type << 24 | hw->revision_id << 16 |
7017 while ((reg_group = ixgbevf_regs[g_ind++]))
7018 count += ixgbe_read_regs_group(dev, &data[count],
7027 ixgbe_get_eeprom_length(struct rte_eth_dev *dev)
7029 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7031 /* Return unit is byte count */
7032 return hw->eeprom.word_size * 2;
7036 ixgbe_get_eeprom(struct rte_eth_dev *dev,
7037 struct rte_dev_eeprom_info *in_eeprom)
7039 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7040 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
7041 uint16_t *data = in_eeprom->data;
7044 first = in_eeprom->offset >> 1;
7045 length = in_eeprom->length >> 1;
7046 if ((first > hw->eeprom.word_size) ||
7047 ((first + length) > hw->eeprom.word_size))
7050 in_eeprom->magic = hw->vendor_id | (hw->device_id << 16);
7052 return eeprom->ops.read_buffer(hw, first, length, data);
7056 ixgbe_set_eeprom(struct rte_eth_dev *dev,
7057 struct rte_dev_eeprom_info *in_eeprom)
7059 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7060 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
7061 uint16_t *data = in_eeprom->data;
7064 first = in_eeprom->offset >> 1;
7065 length = in_eeprom->length >> 1;
7066 if ((first > hw->eeprom.word_size) ||
7067 ((first + length) > hw->eeprom.word_size))
7070 in_eeprom->magic = hw->vendor_id | (hw->device_id << 16);
7072 return eeprom->ops.write_buffer(hw, first, length, data);
7076 ixgbe_reta_size_get(enum ixgbe_mac_type mac_type) {
7078 case ixgbe_mac_X550:
7079 case ixgbe_mac_X550EM_x:
7080 case ixgbe_mac_X550EM_a:
7081 return ETH_RSS_RETA_SIZE_512;
7082 case ixgbe_mac_X550_vf:
7083 case ixgbe_mac_X550EM_x_vf:
7084 case ixgbe_mac_X550EM_a_vf:
7085 return ETH_RSS_RETA_SIZE_64;
7087 return ETH_RSS_RETA_SIZE_128;
7092 ixgbe_reta_reg_get(enum ixgbe_mac_type mac_type, uint16_t reta_idx) {
7094 case ixgbe_mac_X550:
7095 case ixgbe_mac_X550EM_x:
7096 case ixgbe_mac_X550EM_a:
7097 if (reta_idx < ETH_RSS_RETA_SIZE_128)
7098 return IXGBE_RETA(reta_idx >> 2);
7100 return IXGBE_ERETA((reta_idx - ETH_RSS_RETA_SIZE_128) >> 2);
7101 case ixgbe_mac_X550_vf:
7102 case ixgbe_mac_X550EM_x_vf:
7103 case ixgbe_mac_X550EM_a_vf:
7104 return IXGBE_VFRETA(reta_idx >> 2);
7106 return IXGBE_RETA(reta_idx >> 2);
7111 ixgbe_mrqc_reg_get(enum ixgbe_mac_type mac_type) {
7113 case ixgbe_mac_X550_vf:
7114 case ixgbe_mac_X550EM_x_vf:
7115 case ixgbe_mac_X550EM_a_vf:
7116 return IXGBE_VFMRQC;
7123 ixgbe_rssrk_reg_get(enum ixgbe_mac_type mac_type, uint8_t i) {
7125 case ixgbe_mac_X550_vf:
7126 case ixgbe_mac_X550EM_x_vf:
7127 case ixgbe_mac_X550EM_a_vf:
7128 return IXGBE_VFRSSRK(i);
7130 return IXGBE_RSSRK(i);
7135 ixgbe_rss_update_sp(enum ixgbe_mac_type mac_type) {
7137 case ixgbe_mac_82599_vf:
7138 case ixgbe_mac_X540_vf:
7146 ixgbe_dev_get_dcb_info(struct rte_eth_dev *dev,
7147 struct rte_eth_dcb_info *dcb_info)
7149 struct ixgbe_dcb_config *dcb_config =
7150 IXGBE_DEV_PRIVATE_TO_DCB_CFG(dev->data->dev_private);
7151 struct ixgbe_dcb_tc_config *tc;
7154 if (dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_DCB_FLAG)
7155 dcb_info->nb_tcs = dcb_config->num_tcs.pg_tcs;
7157 dcb_info->nb_tcs = 1;
7159 if (dcb_config->vt_mode) { /* vt is enabled*/
7160 struct rte_eth_vmdq_dcb_conf *vmdq_rx_conf =
7161 &dev->data->dev_conf.rx_adv_conf.vmdq_dcb_conf;
7162 for (i = 0; i < ETH_DCB_NUM_USER_PRIORITIES; i++)
7163 dcb_info->prio_tc[i] = vmdq_rx_conf->dcb_tc[i];
7164 for (i = 0; i < vmdq_rx_conf->nb_queue_pools; i++) {
7165 for (j = 0; j < dcb_info->nb_tcs; j++) {
7166 dcb_info->tc_queue.tc_rxq[i][j].base =
7167 i * dcb_info->nb_tcs + j;
7168 dcb_info->tc_queue.tc_rxq[i][j].nb_queue = 1;
7169 dcb_info->tc_queue.tc_txq[i][j].base =
7170 i * dcb_info->nb_tcs + j;
7171 dcb_info->tc_queue.tc_txq[i][j].nb_queue = 1;
7174 } else { /* vt is disabled*/
7175 struct rte_eth_dcb_rx_conf *rx_conf =
7176 &dev->data->dev_conf.rx_adv_conf.dcb_rx_conf;
7177 for (i = 0; i < ETH_DCB_NUM_USER_PRIORITIES; i++)
7178 dcb_info->prio_tc[i] = rx_conf->dcb_tc[i];
7179 if (dcb_info->nb_tcs == ETH_4_TCS) {
7180 for (i = 0; i < dcb_info->nb_tcs; i++) {
7181 dcb_info->tc_queue.tc_rxq[0][i].base = i * 32;
7182 dcb_info->tc_queue.tc_rxq[0][i].nb_queue = 16;
7184 dcb_info->tc_queue.tc_txq[0][0].base = 0;
7185 dcb_info->tc_queue.tc_txq[0][1].base = 64;
7186 dcb_info->tc_queue.tc_txq[0][2].base = 96;
7187 dcb_info->tc_queue.tc_txq[0][3].base = 112;
7188 dcb_info->tc_queue.tc_txq[0][0].nb_queue = 64;
7189 dcb_info->tc_queue.tc_txq[0][1].nb_queue = 32;
7190 dcb_info->tc_queue.tc_txq[0][2].nb_queue = 16;
7191 dcb_info->tc_queue.tc_txq[0][3].nb_queue = 16;
7192 } else if (dcb_info->nb_tcs == ETH_8_TCS) {
7193 for (i = 0; i < dcb_info->nb_tcs; i++) {
7194 dcb_info->tc_queue.tc_rxq[0][i].base = i * 16;
7195 dcb_info->tc_queue.tc_rxq[0][i].nb_queue = 16;
7197 dcb_info->tc_queue.tc_txq[0][0].base = 0;
7198 dcb_info->tc_queue.tc_txq[0][1].base = 32;
7199 dcb_info->tc_queue.tc_txq[0][2].base = 64;
7200 dcb_info->tc_queue.tc_txq[0][3].base = 80;
7201 dcb_info->tc_queue.tc_txq[0][4].base = 96;
7202 dcb_info->tc_queue.tc_txq[0][5].base = 104;
7203 dcb_info->tc_queue.tc_txq[0][6].base = 112;
7204 dcb_info->tc_queue.tc_txq[0][7].base = 120;
7205 dcb_info->tc_queue.tc_txq[0][0].nb_queue = 32;
7206 dcb_info->tc_queue.tc_txq[0][1].nb_queue = 32;
7207 dcb_info->tc_queue.tc_txq[0][2].nb_queue = 16;
7208 dcb_info->tc_queue.tc_txq[0][3].nb_queue = 16;
7209 dcb_info->tc_queue.tc_txq[0][4].nb_queue = 8;
7210 dcb_info->tc_queue.tc_txq[0][5].nb_queue = 8;
7211 dcb_info->tc_queue.tc_txq[0][6].nb_queue = 8;
7212 dcb_info->tc_queue.tc_txq[0][7].nb_queue = 8;
7215 for (i = 0; i < dcb_info->nb_tcs; i++) {
7216 tc = &dcb_config->tc_config[i];
7217 dcb_info->tc_bws[i] = tc->path[IXGBE_DCB_TX_CONFIG].bwg_percent;
7222 /* Update e-tag ether type */
7224 ixgbe_update_e_tag_eth_type(struct ixgbe_hw *hw,
7225 uint16_t ether_type)
7227 uint32_t etag_etype;
7229 if (hw->mac.type != ixgbe_mac_X550 &&
7230 hw->mac.type != ixgbe_mac_X550EM_x &&
7231 hw->mac.type != ixgbe_mac_X550EM_a) {
7235 etag_etype = IXGBE_READ_REG(hw, IXGBE_ETAG_ETYPE);
7236 etag_etype &= ~IXGBE_ETAG_ETYPE_MASK;
7237 etag_etype |= ether_type;
7238 IXGBE_WRITE_REG(hw, IXGBE_ETAG_ETYPE, etag_etype);
7239 IXGBE_WRITE_FLUSH(hw);
7244 /* Config l2 tunnel ether type */
7246 ixgbe_dev_l2_tunnel_eth_type_conf(struct rte_eth_dev *dev,
7247 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7250 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7252 if (l2_tunnel == NULL)
7255 switch (l2_tunnel->l2_tunnel_type) {
7256 case RTE_L2_TUNNEL_TYPE_E_TAG:
7257 ret = ixgbe_update_e_tag_eth_type(hw, l2_tunnel->ether_type);
7260 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7268 /* Enable e-tag tunnel */
7270 ixgbe_e_tag_enable(struct ixgbe_hw *hw)
7272 uint32_t etag_etype;
7274 if (hw->mac.type != ixgbe_mac_X550 &&
7275 hw->mac.type != ixgbe_mac_X550EM_x &&
7276 hw->mac.type != ixgbe_mac_X550EM_a) {
7280 etag_etype = IXGBE_READ_REG(hw, IXGBE_ETAG_ETYPE);
7281 etag_etype |= IXGBE_ETAG_ETYPE_VALID;
7282 IXGBE_WRITE_REG(hw, IXGBE_ETAG_ETYPE, etag_etype);
7283 IXGBE_WRITE_FLUSH(hw);
7288 /* Enable l2 tunnel */
7290 ixgbe_dev_l2_tunnel_enable(struct rte_eth_dev *dev,
7291 enum rte_eth_tunnel_type l2_tunnel_type)
7294 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7296 switch (l2_tunnel_type) {
7297 case RTE_L2_TUNNEL_TYPE_E_TAG:
7298 ret = ixgbe_e_tag_enable(hw);
7301 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7309 /* Disable e-tag tunnel */
7311 ixgbe_e_tag_disable(struct ixgbe_hw *hw)
7313 uint32_t etag_etype;
7315 if (hw->mac.type != ixgbe_mac_X550 &&
7316 hw->mac.type != ixgbe_mac_X550EM_x &&
7317 hw->mac.type != ixgbe_mac_X550EM_a) {
7321 etag_etype = IXGBE_READ_REG(hw, IXGBE_ETAG_ETYPE);
7322 etag_etype &= ~IXGBE_ETAG_ETYPE_VALID;
7323 IXGBE_WRITE_REG(hw, IXGBE_ETAG_ETYPE, etag_etype);
7324 IXGBE_WRITE_FLUSH(hw);
7329 /* Disable l2 tunnel */
7331 ixgbe_dev_l2_tunnel_disable(struct rte_eth_dev *dev,
7332 enum rte_eth_tunnel_type l2_tunnel_type)
7335 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7337 switch (l2_tunnel_type) {
7338 case RTE_L2_TUNNEL_TYPE_E_TAG:
7339 ret = ixgbe_e_tag_disable(hw);
7342 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7351 ixgbe_e_tag_filter_del(struct rte_eth_dev *dev,
7352 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7355 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7356 uint32_t i, rar_entries;
7357 uint32_t rar_low, rar_high;
7359 if (hw->mac.type != ixgbe_mac_X550 &&
7360 hw->mac.type != ixgbe_mac_X550EM_x &&
7361 hw->mac.type != ixgbe_mac_X550EM_a) {
7365 rar_entries = ixgbe_get_num_rx_addrs(hw);
7367 for (i = 1; i < rar_entries; i++) {
7368 rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(i));
7369 rar_low = IXGBE_READ_REG(hw, IXGBE_RAL(i));
7370 if ((rar_high & IXGBE_RAH_AV) &&
7371 (rar_high & IXGBE_RAH_ADTYPE) &&
7372 ((rar_low & IXGBE_RAL_ETAG_FILTER_MASK) ==
7373 l2_tunnel->tunnel_id)) {
7374 IXGBE_WRITE_REG(hw, IXGBE_RAL(i), 0);
7375 IXGBE_WRITE_REG(hw, IXGBE_RAH(i), 0);
7377 ixgbe_clear_vmdq(hw, i, IXGBE_CLEAR_VMDQ_ALL);
7387 ixgbe_e_tag_filter_add(struct rte_eth_dev *dev,
7388 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7391 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7392 uint32_t i, rar_entries;
7393 uint32_t rar_low, rar_high;
7395 if (hw->mac.type != ixgbe_mac_X550 &&
7396 hw->mac.type != ixgbe_mac_X550EM_x &&
7397 hw->mac.type != ixgbe_mac_X550EM_a) {
7401 /* One entry for one tunnel. Try to remove potential existing entry. */
7402 ixgbe_e_tag_filter_del(dev, l2_tunnel);
7404 rar_entries = ixgbe_get_num_rx_addrs(hw);
7406 for (i = 1; i < rar_entries; i++) {
7407 rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(i));
7408 if (rar_high & IXGBE_RAH_AV) {
7411 ixgbe_set_vmdq(hw, i, l2_tunnel->pool);
7412 rar_high = IXGBE_RAH_AV | IXGBE_RAH_ADTYPE;
7413 rar_low = l2_tunnel->tunnel_id;
7415 IXGBE_WRITE_REG(hw, IXGBE_RAL(i), rar_low);
7416 IXGBE_WRITE_REG(hw, IXGBE_RAH(i), rar_high);
7422 PMD_INIT_LOG(NOTICE, "The table of E-tag forwarding rule is full."
7423 " Please remove a rule before adding a new one.");
7427 /* Add l2 tunnel filter */
7429 ixgbe_dev_l2_tunnel_filter_add(struct rte_eth_dev *dev,
7430 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7434 switch (l2_tunnel->l2_tunnel_type) {
7435 case RTE_L2_TUNNEL_TYPE_E_TAG:
7436 ret = ixgbe_e_tag_filter_add(dev, l2_tunnel);
7439 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7447 /* Delete l2 tunnel filter */
7449 ixgbe_dev_l2_tunnel_filter_del(struct rte_eth_dev *dev,
7450 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7454 switch (l2_tunnel->l2_tunnel_type) {
7455 case RTE_L2_TUNNEL_TYPE_E_TAG:
7456 ret = ixgbe_e_tag_filter_del(dev, l2_tunnel);
7459 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7468 * ixgbe_dev_l2_tunnel_filter_handle - Handle operations for l2 tunnel filter.
7469 * @dev: pointer to rte_eth_dev structure
7470 * @filter_op:operation will be taken.
7471 * @arg: a pointer to specific structure corresponding to the filter_op
7474 ixgbe_dev_l2_tunnel_filter_handle(struct rte_eth_dev *dev,
7475 enum rte_filter_op filter_op,
7480 if (filter_op == RTE_ETH_FILTER_NOP)
7484 PMD_DRV_LOG(ERR, "arg shouldn't be NULL for operation %u.",
7489 switch (filter_op) {
7490 case RTE_ETH_FILTER_ADD:
7491 ret = ixgbe_dev_l2_tunnel_filter_add
7493 (struct rte_eth_l2_tunnel_conf *)arg);
7495 case RTE_ETH_FILTER_DELETE:
7496 ret = ixgbe_dev_l2_tunnel_filter_del
7498 (struct rte_eth_l2_tunnel_conf *)arg);
7501 PMD_DRV_LOG(ERR, "unsupported operation %u.", filter_op);
7509 ixgbe_e_tag_forwarding_en_dis(struct rte_eth_dev *dev, bool en)
7513 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7515 if (hw->mac.type != ixgbe_mac_X550 &&
7516 hw->mac.type != ixgbe_mac_X550EM_x &&
7517 hw->mac.type != ixgbe_mac_X550EM_a) {
7521 ctrl = IXGBE_READ_REG(hw, IXGBE_VT_CTL);
7522 ctrl &= ~IXGBE_VT_CTL_POOLING_MODE_MASK;
7524 ctrl |= IXGBE_VT_CTL_POOLING_MODE_ETAG;
7525 IXGBE_WRITE_REG(hw, IXGBE_VT_CTL, ctrl);
7530 /* Enable l2 tunnel forwarding */
7532 ixgbe_dev_l2_tunnel_forwarding_enable
7533 (struct rte_eth_dev *dev,
7534 enum rte_eth_tunnel_type l2_tunnel_type)
7538 switch (l2_tunnel_type) {
7539 case RTE_L2_TUNNEL_TYPE_E_TAG:
7540 ret = ixgbe_e_tag_forwarding_en_dis(dev, 1);
7543 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7551 /* Disable l2 tunnel forwarding */
7553 ixgbe_dev_l2_tunnel_forwarding_disable
7554 (struct rte_eth_dev *dev,
7555 enum rte_eth_tunnel_type l2_tunnel_type)
7559 switch (l2_tunnel_type) {
7560 case RTE_L2_TUNNEL_TYPE_E_TAG:
7561 ret = ixgbe_e_tag_forwarding_en_dis(dev, 0);
7564 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7573 ixgbe_e_tag_insertion_en_dis(struct rte_eth_dev *dev,
7574 struct rte_eth_l2_tunnel_conf *l2_tunnel,
7577 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
7579 uint32_t vmtir, vmvir;
7580 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7582 if (l2_tunnel->vf_id >= pci_dev->max_vfs) {
7584 "VF id %u should be less than %u",
7590 if (hw->mac.type != ixgbe_mac_X550 &&
7591 hw->mac.type != ixgbe_mac_X550EM_x &&
7592 hw->mac.type != ixgbe_mac_X550EM_a) {
7597 vmtir = l2_tunnel->tunnel_id;
7601 IXGBE_WRITE_REG(hw, IXGBE_VMTIR(l2_tunnel->vf_id), vmtir);
7603 vmvir = IXGBE_READ_REG(hw, IXGBE_VMVIR(l2_tunnel->vf_id));
7604 vmvir &= ~IXGBE_VMVIR_TAGA_MASK;
7606 vmvir |= IXGBE_VMVIR_TAGA_ETAG_INSERT;
7607 IXGBE_WRITE_REG(hw, IXGBE_VMVIR(l2_tunnel->vf_id), vmvir);
7612 /* Enable l2 tunnel tag insertion */
7614 ixgbe_dev_l2_tunnel_insertion_enable(struct rte_eth_dev *dev,
7615 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7619 switch (l2_tunnel->l2_tunnel_type) {
7620 case RTE_L2_TUNNEL_TYPE_E_TAG:
7621 ret = ixgbe_e_tag_insertion_en_dis(dev, l2_tunnel, 1);
7624 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7632 /* Disable l2 tunnel tag insertion */
7634 ixgbe_dev_l2_tunnel_insertion_disable
7635 (struct rte_eth_dev *dev,
7636 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7640 switch (l2_tunnel->l2_tunnel_type) {
7641 case RTE_L2_TUNNEL_TYPE_E_TAG:
7642 ret = ixgbe_e_tag_insertion_en_dis(dev, l2_tunnel, 0);
7645 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7654 ixgbe_e_tag_stripping_en_dis(struct rte_eth_dev *dev,
7659 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7661 if (hw->mac.type != ixgbe_mac_X550 &&
7662 hw->mac.type != ixgbe_mac_X550EM_x &&
7663 hw->mac.type != ixgbe_mac_X550EM_a) {
7667 qde = IXGBE_READ_REG(hw, IXGBE_QDE);
7669 qde |= IXGBE_QDE_STRIP_TAG;
7671 qde &= ~IXGBE_QDE_STRIP_TAG;
7672 qde &= ~IXGBE_QDE_READ;
7673 qde |= IXGBE_QDE_WRITE;
7674 IXGBE_WRITE_REG(hw, IXGBE_QDE, qde);
7679 /* Enable l2 tunnel tag stripping */
7681 ixgbe_dev_l2_tunnel_stripping_enable
7682 (struct rte_eth_dev *dev,
7683 enum rte_eth_tunnel_type l2_tunnel_type)
7687 switch (l2_tunnel_type) {
7688 case RTE_L2_TUNNEL_TYPE_E_TAG:
7689 ret = ixgbe_e_tag_stripping_en_dis(dev, 1);
7692 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7700 /* Disable l2 tunnel tag stripping */
7702 ixgbe_dev_l2_tunnel_stripping_disable
7703 (struct rte_eth_dev *dev,
7704 enum rte_eth_tunnel_type l2_tunnel_type)
7708 switch (l2_tunnel_type) {
7709 case RTE_L2_TUNNEL_TYPE_E_TAG:
7710 ret = ixgbe_e_tag_stripping_en_dis(dev, 0);
7713 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7721 /* Enable/disable l2 tunnel offload functions */
7723 ixgbe_dev_l2_tunnel_offload_set
7724 (struct rte_eth_dev *dev,
7725 struct rte_eth_l2_tunnel_conf *l2_tunnel,
7731 if (l2_tunnel == NULL)
7735 if (mask & ETH_L2_TUNNEL_ENABLE_MASK) {
7737 ret = ixgbe_dev_l2_tunnel_enable(
7739 l2_tunnel->l2_tunnel_type);
7741 ret = ixgbe_dev_l2_tunnel_disable(
7743 l2_tunnel->l2_tunnel_type);
7746 if (mask & ETH_L2_TUNNEL_INSERTION_MASK) {
7748 ret = ixgbe_dev_l2_tunnel_insertion_enable(
7752 ret = ixgbe_dev_l2_tunnel_insertion_disable(
7757 if (mask & ETH_L2_TUNNEL_STRIPPING_MASK) {
7759 ret = ixgbe_dev_l2_tunnel_stripping_enable(
7761 l2_tunnel->l2_tunnel_type);
7763 ret = ixgbe_dev_l2_tunnel_stripping_disable(
7765 l2_tunnel->l2_tunnel_type);
7768 if (mask & ETH_L2_TUNNEL_FORWARDING_MASK) {
7770 ret = ixgbe_dev_l2_tunnel_forwarding_enable(
7772 l2_tunnel->l2_tunnel_type);
7774 ret = ixgbe_dev_l2_tunnel_forwarding_disable(
7776 l2_tunnel->l2_tunnel_type);
7783 ixgbe_update_vxlan_port(struct ixgbe_hw *hw,
7786 IXGBE_WRITE_REG(hw, IXGBE_VXLANCTRL, port);
7787 IXGBE_WRITE_FLUSH(hw);
7792 /* There's only one register for VxLAN UDP port.
7793 * So, we cannot add several ports. Will update it.
7796 ixgbe_add_vxlan_port(struct ixgbe_hw *hw,
7800 PMD_DRV_LOG(ERR, "Add VxLAN port 0 is not allowed.");
7804 return ixgbe_update_vxlan_port(hw, port);
7807 /* We cannot delete the VxLAN port. For there's a register for VxLAN
7808 * UDP port, it must have a value.
7809 * So, will reset it to the original value 0.
7812 ixgbe_del_vxlan_port(struct ixgbe_hw *hw,
7817 cur_port = (uint16_t)IXGBE_READ_REG(hw, IXGBE_VXLANCTRL);
7819 if (cur_port != port) {
7820 PMD_DRV_LOG(ERR, "Port %u does not exist.", port);
7824 return ixgbe_update_vxlan_port(hw, 0);
7827 /* Add UDP tunneling port */
7829 ixgbe_dev_udp_tunnel_port_add(struct rte_eth_dev *dev,
7830 struct rte_eth_udp_tunnel *udp_tunnel)
7833 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7835 if (hw->mac.type != ixgbe_mac_X550 &&
7836 hw->mac.type != ixgbe_mac_X550EM_x &&
7837 hw->mac.type != ixgbe_mac_X550EM_a) {
7841 if (udp_tunnel == NULL)
7844 switch (udp_tunnel->prot_type) {
7845 case RTE_TUNNEL_TYPE_VXLAN:
7846 ret = ixgbe_add_vxlan_port(hw, udp_tunnel->udp_port);
7849 case RTE_TUNNEL_TYPE_GENEVE:
7850 case RTE_TUNNEL_TYPE_TEREDO:
7851 PMD_DRV_LOG(ERR, "Tunnel type is not supported now.");
7856 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7864 /* Remove UDP tunneling port */
7866 ixgbe_dev_udp_tunnel_port_del(struct rte_eth_dev *dev,
7867 struct rte_eth_udp_tunnel *udp_tunnel)
7870 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7872 if (hw->mac.type != ixgbe_mac_X550 &&
7873 hw->mac.type != ixgbe_mac_X550EM_x &&
7874 hw->mac.type != ixgbe_mac_X550EM_a) {
7878 if (udp_tunnel == NULL)
7881 switch (udp_tunnel->prot_type) {
7882 case RTE_TUNNEL_TYPE_VXLAN:
7883 ret = ixgbe_del_vxlan_port(hw, udp_tunnel->udp_port);
7885 case RTE_TUNNEL_TYPE_GENEVE:
7886 case RTE_TUNNEL_TYPE_TEREDO:
7887 PMD_DRV_LOG(ERR, "Tunnel type is not supported now.");
7891 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7900 ixgbevf_dev_allmulticast_enable(struct rte_eth_dev *dev)
7902 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7904 hw->mac.ops.update_xcast_mode(hw, IXGBEVF_XCAST_MODE_ALLMULTI);
7908 ixgbevf_dev_allmulticast_disable(struct rte_eth_dev *dev)
7910 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7912 hw->mac.ops.update_xcast_mode(hw, IXGBEVF_XCAST_MODE_NONE);
7915 static void ixgbevf_mbx_process(struct rte_eth_dev *dev)
7917 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7920 if (ixgbe_read_mbx(hw, &in_msg, 1, 0))
7923 /* PF reset VF event */
7924 if (in_msg == IXGBE_PF_CONTROL_MSG)
7925 _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RESET, NULL);
7929 ixgbevf_dev_interrupt_get_status(struct rte_eth_dev *dev)
7932 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7933 struct ixgbe_interrupt *intr =
7934 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
7935 ixgbevf_intr_disable(hw);
7937 /* read-on-clear nic registers here */
7938 eicr = IXGBE_READ_REG(hw, IXGBE_VTEICR);
7941 /* only one misc vector supported - mailbox */
7942 eicr &= IXGBE_VTEICR_MASK;
7943 if (eicr == IXGBE_MISC_VEC_ID)
7944 intr->flags |= IXGBE_FLAG_MAILBOX;
7950 ixgbevf_dev_interrupt_action(struct rte_eth_dev *dev)
7952 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7953 struct ixgbe_interrupt *intr =
7954 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
7956 if (intr->flags & IXGBE_FLAG_MAILBOX) {
7957 ixgbevf_mbx_process(dev);
7958 intr->flags &= ~IXGBE_FLAG_MAILBOX;
7961 ixgbevf_intr_enable(hw);
7967 ixgbevf_dev_interrupt_handler(__rte_unused struct rte_intr_handle *handle,
7970 struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
7972 ixgbevf_dev_interrupt_get_status(dev);
7973 ixgbevf_dev_interrupt_action(dev);
7977 * ixgbe_disable_sec_tx_path_generic - Stops the transmit data path
7978 * @hw: pointer to hardware structure
7980 * Stops the transmit data path and waits for the HW to internally empty
7981 * the Tx security block
7983 int ixgbe_disable_sec_tx_path_generic(struct ixgbe_hw *hw)
7985 #define IXGBE_MAX_SECTX_POLL 40
7990 sectxreg = IXGBE_READ_REG(hw, IXGBE_SECTXCTRL);
7991 sectxreg |= IXGBE_SECTXCTRL_TX_DIS;
7992 IXGBE_WRITE_REG(hw, IXGBE_SECTXCTRL, sectxreg);
7993 for (i = 0; i < IXGBE_MAX_SECTX_POLL; i++) {
7994 sectxreg = IXGBE_READ_REG(hw, IXGBE_SECTXSTAT);
7995 if (sectxreg & IXGBE_SECTXSTAT_SECTX_RDY)
7997 /* Use interrupt-safe sleep just in case */
8001 /* For informational purposes only */
8002 if (i >= IXGBE_MAX_SECTX_POLL)
8003 PMD_DRV_LOG(DEBUG, "Tx unit being enabled before security "
8004 "path fully disabled. Continuing with init.\n");
8006 return IXGBE_SUCCESS;
8010 * ixgbe_enable_sec_tx_path_generic - Enables the transmit data path
8011 * @hw: pointer to hardware structure
8013 * Enables the transmit data path.
8015 int ixgbe_enable_sec_tx_path_generic(struct ixgbe_hw *hw)
8019 sectxreg = IXGBE_READ_REG(hw, IXGBE_SECTXCTRL);
8020 sectxreg &= ~IXGBE_SECTXCTRL_TX_DIS;
8021 IXGBE_WRITE_REG(hw, IXGBE_SECTXCTRL, sectxreg);
8022 IXGBE_WRITE_FLUSH(hw);
8024 return IXGBE_SUCCESS;
8028 rte_pmd_ixgbe_macsec_enable(uint8_t port, uint8_t en, uint8_t rp)
8030 struct ixgbe_hw *hw;
8031 struct rte_eth_dev *dev;
8034 RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
8036 dev = &rte_eth_devices[port];
8037 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8039 /* Stop the data paths */
8040 if (ixgbe_disable_sec_rx_path(hw) != IXGBE_SUCCESS)
8044 * As no ixgbe_disable_sec_rx_path equivalent is
8045 * implemented for tx in the base code, and we are
8046 * not allowed to modify the base code in DPDK, so
8047 * just call the hand-written one directly for now.
8048 * The hardware support has been checked by
8049 * ixgbe_disable_sec_rx_path().
8051 ixgbe_disable_sec_tx_path_generic(hw);
8053 /* Enable Ethernet CRC (required by MACsec offload) */
8054 ctrl = IXGBE_READ_REG(hw, IXGBE_HLREG0);
8055 ctrl |= IXGBE_HLREG0_TXCRCEN | IXGBE_HLREG0_RXCRCSTRP;
8056 IXGBE_WRITE_REG(hw, IXGBE_HLREG0, ctrl);
8058 /* Enable the TX and RX crypto engines */
8059 ctrl = IXGBE_READ_REG(hw, IXGBE_SECTXCTRL);
8060 ctrl &= ~IXGBE_SECTXCTRL_SECTX_DIS;
8061 IXGBE_WRITE_REG(hw, IXGBE_SECTXCTRL, ctrl);
8063 ctrl = IXGBE_READ_REG(hw, IXGBE_SECRXCTRL);
8064 ctrl &= ~IXGBE_SECRXCTRL_SECRX_DIS;
8065 IXGBE_WRITE_REG(hw, IXGBE_SECRXCTRL, ctrl);
8067 ctrl = IXGBE_READ_REG(hw, IXGBE_SECTXMINIFG);
8068 ctrl &= ~IXGBE_SECTX_MINSECIFG_MASK;
8070 IXGBE_WRITE_REG(hw, IXGBE_SECTXMINIFG, ctrl);
8072 /* Enable SA lookup */
8073 ctrl = IXGBE_READ_REG(hw, IXGBE_LSECTXCTRL);
8074 ctrl &= ~IXGBE_LSECTXCTRL_EN_MASK;
8075 ctrl |= en ? IXGBE_LSECTXCTRL_AUTH_ENCRYPT :
8076 IXGBE_LSECTXCTRL_AUTH;
8077 ctrl |= IXGBE_LSECTXCTRL_AISCI;
8078 ctrl &= ~IXGBE_LSECTXCTRL_PNTHRSH_MASK;
8079 ctrl |= IXGBE_MACSEC_PNTHRSH & IXGBE_LSECTXCTRL_PNTHRSH_MASK;
8080 IXGBE_WRITE_REG(hw, IXGBE_LSECTXCTRL, ctrl);
8082 ctrl = IXGBE_READ_REG(hw, IXGBE_LSECRXCTRL);
8083 ctrl &= ~IXGBE_LSECRXCTRL_EN_MASK;
8084 ctrl |= IXGBE_LSECRXCTRL_STRICT << IXGBE_LSECRXCTRL_EN_SHIFT;
8085 ctrl &= ~IXGBE_LSECRXCTRL_PLSH;
8087 ctrl |= IXGBE_LSECRXCTRL_RP;
8089 ctrl &= ~IXGBE_LSECRXCTRL_RP;
8090 IXGBE_WRITE_REG(hw, IXGBE_LSECRXCTRL, ctrl);
8092 /* Start the data paths */
8093 ixgbe_enable_sec_rx_path(hw);
8096 * As no ixgbe_enable_sec_rx_path equivalent is
8097 * implemented for tx in the base code, and we are
8098 * not allowed to modify the base code in DPDK, so
8099 * just call the hand-written one directly for now.
8101 ixgbe_enable_sec_tx_path_generic(hw);
8107 rte_pmd_ixgbe_macsec_disable(uint8_t port)
8109 struct ixgbe_hw *hw;
8110 struct rte_eth_dev *dev;
8113 RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
8115 dev = &rte_eth_devices[port];
8116 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8118 /* Stop the data paths */
8119 if (ixgbe_disable_sec_rx_path(hw) != IXGBE_SUCCESS)
8123 * As no ixgbe_disable_sec_rx_path equivalent is
8124 * implemented for tx in the base code, and we are
8125 * not allowed to modify the base code in DPDK, so
8126 * just call the hand-written one directly for now.
8127 * The hardware support has been checked by
8128 * ixgbe_disable_sec_rx_path().
8130 ixgbe_disable_sec_tx_path_generic(hw);
8132 /* Disable the TX and RX crypto engines */
8133 ctrl = IXGBE_READ_REG(hw, IXGBE_SECTXCTRL);
8134 ctrl |= IXGBE_SECTXCTRL_SECTX_DIS;
8135 IXGBE_WRITE_REG(hw, IXGBE_SECTXCTRL, ctrl);
8137 ctrl = IXGBE_READ_REG(hw, IXGBE_SECRXCTRL);
8138 ctrl |= IXGBE_SECRXCTRL_SECRX_DIS;
8139 IXGBE_WRITE_REG(hw, IXGBE_SECRXCTRL, ctrl);
8141 /* Disable SA lookup */
8142 ctrl = IXGBE_READ_REG(hw, IXGBE_LSECTXCTRL);
8143 ctrl &= ~IXGBE_LSECTXCTRL_EN_MASK;
8144 ctrl |= IXGBE_LSECTXCTRL_DISABLE;
8145 IXGBE_WRITE_REG(hw, IXGBE_LSECTXCTRL, ctrl);
8147 ctrl = IXGBE_READ_REG(hw, IXGBE_LSECRXCTRL);
8148 ctrl &= ~IXGBE_LSECRXCTRL_EN_MASK;
8149 ctrl |= IXGBE_LSECRXCTRL_DISABLE << IXGBE_LSECRXCTRL_EN_SHIFT;
8150 IXGBE_WRITE_REG(hw, IXGBE_LSECRXCTRL, ctrl);
8152 /* Start the data paths */
8153 ixgbe_enable_sec_rx_path(hw);
8156 * As no ixgbe_enable_sec_rx_path equivalent is
8157 * implemented for tx in the base code, and we are
8158 * not allowed to modify the base code in DPDK, so
8159 * just call the hand-written one directly for now.
8161 ixgbe_enable_sec_tx_path_generic(hw);
8167 rte_pmd_ixgbe_macsec_config_txsc(uint8_t port, uint8_t *mac)
8169 struct ixgbe_hw *hw;
8170 struct rte_eth_dev *dev;
8173 RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
8175 dev = &rte_eth_devices[port];
8176 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8178 ctrl = mac[0] | (mac[1] << 8) | (mac[2] << 16) | (mac[3] << 24);
8179 IXGBE_WRITE_REG(hw, IXGBE_LSECTXSCL, ctrl);
8181 ctrl = mac[4] | (mac[5] << 8);
8182 IXGBE_WRITE_REG(hw, IXGBE_LSECTXSCH, ctrl);
8188 rte_pmd_ixgbe_macsec_config_rxsc(uint8_t port, uint8_t *mac, uint16_t pi)
8190 struct ixgbe_hw *hw;
8191 struct rte_eth_dev *dev;
8194 RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
8196 dev = &rte_eth_devices[port];
8197 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8199 ctrl = mac[0] | (mac[1] << 8) | (mac[2] << 16) | (mac[3] << 24);
8200 IXGBE_WRITE_REG(hw, IXGBE_LSECRXSCL, ctrl);
8202 pi = rte_cpu_to_be_16(pi);
8203 ctrl = mac[4] | (mac[5] << 8) | (pi << 16);
8204 IXGBE_WRITE_REG(hw, IXGBE_LSECRXSCH, ctrl);
8210 rte_pmd_ixgbe_macsec_select_txsa(uint8_t port, uint8_t idx, uint8_t an,
8211 uint32_t pn, uint8_t *key)
8213 struct ixgbe_hw *hw;
8214 struct rte_eth_dev *dev;
8217 RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
8219 dev = &rte_eth_devices[port];
8220 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8222 if (idx != 0 && idx != 1)
8228 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8230 /* Set the PN and key */
8231 pn = rte_cpu_to_be_32(pn);
8233 IXGBE_WRITE_REG(hw, IXGBE_LSECTXPN0, pn);
8235 for (i = 0; i < 4; i++) {
8236 ctrl = (key[i * 4 + 0] << 0) |
8237 (key[i * 4 + 1] << 8) |
8238 (key[i * 4 + 2] << 16) |
8239 (key[i * 4 + 3] << 24);
8240 IXGBE_WRITE_REG(hw, IXGBE_LSECTXKEY0(i), ctrl);
8243 IXGBE_WRITE_REG(hw, IXGBE_LSECTXPN1, pn);
8245 for (i = 0; i < 4; i++) {
8246 ctrl = (key[i * 4 + 0] << 0) |
8247 (key[i * 4 + 1] << 8) |
8248 (key[i * 4 + 2] << 16) |
8249 (key[i * 4 + 3] << 24);
8250 IXGBE_WRITE_REG(hw, IXGBE_LSECTXKEY1(i), ctrl);
8254 /* Set AN and select the SA */
8255 ctrl = (an << idx * 2) | (idx << 4);
8256 IXGBE_WRITE_REG(hw, IXGBE_LSECTXSA, ctrl);
8262 rte_pmd_ixgbe_macsec_select_rxsa(uint8_t port, uint8_t idx, uint8_t an,
8263 uint32_t pn, uint8_t *key)
8265 struct ixgbe_hw *hw;
8266 struct rte_eth_dev *dev;
8269 RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
8271 dev = &rte_eth_devices[port];
8272 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8274 if (idx != 0 && idx != 1)
8281 pn = rte_cpu_to_be_32(pn);
8282 IXGBE_WRITE_REG(hw, IXGBE_LSECRXPN(idx), pn);
8285 for (i = 0; i < 4; i++) {
8286 ctrl = (key[i * 4 + 0] << 0) |
8287 (key[i * 4 + 1] << 8) |
8288 (key[i * 4 + 2] << 16) |
8289 (key[i * 4 + 3] << 24);
8290 IXGBE_WRITE_REG(hw, IXGBE_LSECRXKEY(idx, i), ctrl);
8293 /* Set the AN and validate the SA */
8294 ctrl = an | (1 << 2);
8295 IXGBE_WRITE_REG(hw, IXGBE_LSECRXSA(idx), ctrl);
8300 RTE_PMD_REGISTER_PCI(net_ixgbe, rte_ixgbe_pmd.pci_drv);
8301 RTE_PMD_REGISTER_PCI_TABLE(net_ixgbe, pci_id_ixgbe_map);
8302 RTE_PMD_REGISTER_KMOD_DEP(net_ixgbe, "* igb_uio | uio_pci_generic | vfio");
8303 RTE_PMD_REGISTER_PCI(net_ixgbe_vf, rte_ixgbevf_pmd.pci_drv);
8304 RTE_PMD_REGISTER_PCI_TABLE(net_ixgbe_vf, pci_id_ixgbevf_map);
8305 RTE_PMD_REGISTER_KMOD_DEP(net_ixgbe_vf, "* igb_uio | vfio");