4 * Copyright(c) 2010-2016 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>
64 #include "ixgbe_logs.h"
65 #include "base/ixgbe_api.h"
66 #include "base/ixgbe_vf.h"
67 #include "base/ixgbe_common.h"
68 #include "ixgbe_ethdev.h"
69 #include "ixgbe_bypass.h"
70 #include "ixgbe_rxtx.h"
71 #include "base/ixgbe_type.h"
72 #include "base/ixgbe_phy.h"
73 #include "ixgbe_regs.h"
75 #include "rte_pmd_ixgbe.h"
78 * High threshold controlling when to start sending XOFF frames. Must be at
79 * least 8 bytes less than receive packet buffer size. This value is in units
82 #define IXGBE_FC_HI 0x80
85 * Low threshold controlling when to start sending XON frames. This value is
86 * in units of 1024 bytes.
88 #define IXGBE_FC_LO 0x40
90 /* Default minimum inter-interrupt interval for EITR configuration */
91 #define IXGBE_MIN_INTER_INTERRUPT_INTERVAL_DEFAULT 0x79E
93 /* Timer value included in XOFF frames. */
94 #define IXGBE_FC_PAUSE 0x680
96 #define IXGBE_LINK_DOWN_CHECK_TIMEOUT 4000 /* ms */
97 #define IXGBE_LINK_UP_CHECK_TIMEOUT 1000 /* ms */
98 #define IXGBE_VMDQ_NUM_UC_MAC 4096 /* Maximum nb. of UC MAC addr. */
100 #define IXGBE_MMW_SIZE_DEFAULT 0x4
101 #define IXGBE_MMW_SIZE_JUMBO_FRAME 0x14
102 #define IXGBE_MAX_RING_DESC 4096 /* replicate define from rxtx */
105 * Default values for RX/TX configuration
107 #define IXGBE_DEFAULT_RX_FREE_THRESH 32
108 #define IXGBE_DEFAULT_RX_PTHRESH 8
109 #define IXGBE_DEFAULT_RX_HTHRESH 8
110 #define IXGBE_DEFAULT_RX_WTHRESH 0
112 #define IXGBE_DEFAULT_TX_FREE_THRESH 32
113 #define IXGBE_DEFAULT_TX_PTHRESH 32
114 #define IXGBE_DEFAULT_TX_HTHRESH 0
115 #define IXGBE_DEFAULT_TX_WTHRESH 0
116 #define IXGBE_DEFAULT_TX_RSBIT_THRESH 32
118 /* Bit shift and mask */
119 #define IXGBE_4_BIT_WIDTH (CHAR_BIT / 2)
120 #define IXGBE_4_BIT_MASK RTE_LEN2MASK(IXGBE_4_BIT_WIDTH, uint8_t)
121 #define IXGBE_8_BIT_WIDTH CHAR_BIT
122 #define IXGBE_8_BIT_MASK UINT8_MAX
124 #define IXGBEVF_PMD_NAME "rte_ixgbevf_pmd" /* PMD name */
126 #define IXGBE_QUEUE_STAT_COUNTERS (sizeof(hw_stats->qprc) / sizeof(hw_stats->qprc[0]))
128 #define IXGBE_HKEY_MAX_INDEX 10
130 /* Additional timesync values. */
131 #define NSEC_PER_SEC 1000000000L
132 #define IXGBE_INCVAL_10GB 0x66666666
133 #define IXGBE_INCVAL_1GB 0x40000000
134 #define IXGBE_INCVAL_100 0x50000000
135 #define IXGBE_INCVAL_SHIFT_10GB 28
136 #define IXGBE_INCVAL_SHIFT_1GB 24
137 #define IXGBE_INCVAL_SHIFT_100 21
138 #define IXGBE_INCVAL_SHIFT_82599 7
139 #define IXGBE_INCPER_SHIFT_82599 24
141 #define IXGBE_CYCLECOUNTER_MASK 0xffffffffffffffffULL
143 #define IXGBE_VT_CTL_POOLING_MODE_MASK 0x00030000
144 #define IXGBE_VT_CTL_POOLING_MODE_ETAG 0x00010000
145 #define DEFAULT_ETAG_ETYPE 0x893f
146 #define IXGBE_ETAG_ETYPE 0x00005084
147 #define IXGBE_ETAG_ETYPE_MASK 0x0000ffff
148 #define IXGBE_ETAG_ETYPE_VALID 0x80000000
149 #define IXGBE_RAH_ADTYPE 0x40000000
150 #define IXGBE_RAL_ETAG_FILTER_MASK 0x00003fff
151 #define IXGBE_VMVIR_TAGA_MASK 0x18000000
152 #define IXGBE_VMVIR_TAGA_ETAG_INSERT 0x08000000
153 #define IXGBE_VMTIR(_i) (0x00017000 + ((_i) * 4)) /* 64 of these (0-63) */
154 #define IXGBE_QDE_STRIP_TAG 0x00000004
155 #define IXGBE_VTEICR_MASK 0x07
157 enum ixgbevf_xcast_modes {
158 IXGBEVF_XCAST_MODE_NONE = 0,
159 IXGBEVF_XCAST_MODE_MULTI,
160 IXGBEVF_XCAST_MODE_ALLMULTI,
163 #define IXGBE_EXVET_VET_EXT_SHIFT 16
164 #define IXGBE_DMATXCTL_VT_MASK 0xFFFF0000
166 static int eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev);
167 static int eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev);
168 static int ixgbe_dev_configure(struct rte_eth_dev *dev);
169 static int ixgbe_dev_start(struct rte_eth_dev *dev);
170 static void ixgbe_dev_stop(struct rte_eth_dev *dev);
171 static int ixgbe_dev_set_link_up(struct rte_eth_dev *dev);
172 static int ixgbe_dev_set_link_down(struct rte_eth_dev *dev);
173 static void ixgbe_dev_close(struct rte_eth_dev *dev);
174 static void ixgbe_dev_promiscuous_enable(struct rte_eth_dev *dev);
175 static void ixgbe_dev_promiscuous_disable(struct rte_eth_dev *dev);
176 static void ixgbe_dev_allmulticast_enable(struct rte_eth_dev *dev);
177 static void ixgbe_dev_allmulticast_disable(struct rte_eth_dev *dev);
178 static int ixgbe_dev_link_update(struct rte_eth_dev *dev,
179 int wait_to_complete);
180 static void ixgbe_dev_stats_get(struct rte_eth_dev *dev,
181 struct rte_eth_stats *stats);
182 static int ixgbe_dev_xstats_get(struct rte_eth_dev *dev,
183 struct rte_eth_xstat *xstats, unsigned n);
184 static int ixgbevf_dev_xstats_get(struct rte_eth_dev *dev,
185 struct rte_eth_xstat *xstats, unsigned n);
186 static void ixgbe_dev_stats_reset(struct rte_eth_dev *dev);
187 static void ixgbe_dev_xstats_reset(struct rte_eth_dev *dev);
188 static int ixgbe_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
189 struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned limit);
190 static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
191 struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned limit);
192 static int ixgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
196 static void ixgbe_dev_info_get(struct rte_eth_dev *dev,
197 struct rte_eth_dev_info *dev_info);
198 static const uint32_t *ixgbe_dev_supported_ptypes_get(struct rte_eth_dev *dev);
199 static void ixgbevf_dev_info_get(struct rte_eth_dev *dev,
200 struct rte_eth_dev_info *dev_info);
201 static int ixgbe_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
203 static int ixgbe_vlan_filter_set(struct rte_eth_dev *dev,
204 uint16_t vlan_id, int on);
205 static int ixgbe_vlan_tpid_set(struct rte_eth_dev *dev,
206 enum rte_vlan_type vlan_type,
208 static void ixgbe_vlan_hw_strip_bitmap_set(struct rte_eth_dev *dev,
209 uint16_t queue, bool on);
210 static void ixgbe_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue,
212 static void ixgbe_vlan_offload_set(struct rte_eth_dev *dev, int mask);
213 static void ixgbe_vlan_hw_strip_enable(struct rte_eth_dev *dev, uint16_t queue);
214 static void ixgbe_vlan_hw_strip_disable(struct rte_eth_dev *dev, uint16_t queue);
215 static void ixgbe_vlan_hw_extend_enable(struct rte_eth_dev *dev);
216 static void ixgbe_vlan_hw_extend_disable(struct rte_eth_dev *dev);
218 static int ixgbe_dev_led_on(struct rte_eth_dev *dev);
219 static int ixgbe_dev_led_off(struct rte_eth_dev *dev);
220 static int ixgbe_flow_ctrl_get(struct rte_eth_dev *dev,
221 struct rte_eth_fc_conf *fc_conf);
222 static int ixgbe_flow_ctrl_set(struct rte_eth_dev *dev,
223 struct rte_eth_fc_conf *fc_conf);
224 static int ixgbe_priority_flow_ctrl_set(struct rte_eth_dev *dev,
225 struct rte_eth_pfc_conf *pfc_conf);
226 static int ixgbe_dev_rss_reta_update(struct rte_eth_dev *dev,
227 struct rte_eth_rss_reta_entry64 *reta_conf,
229 static int ixgbe_dev_rss_reta_query(struct rte_eth_dev *dev,
230 struct rte_eth_rss_reta_entry64 *reta_conf,
232 static void ixgbe_dev_link_status_print(struct rte_eth_dev *dev);
233 static int ixgbe_dev_lsc_interrupt_setup(struct rte_eth_dev *dev);
234 static int ixgbe_dev_macsec_interrupt_setup(struct rte_eth_dev *dev);
235 static int ixgbe_dev_rxq_interrupt_setup(struct rte_eth_dev *dev);
236 static int ixgbe_dev_interrupt_get_status(struct rte_eth_dev *dev);
237 static int ixgbe_dev_interrupt_action(struct rte_eth_dev *dev,
238 struct rte_intr_handle *handle);
239 static void ixgbe_dev_interrupt_handler(struct rte_intr_handle *handle,
241 static void ixgbe_dev_interrupt_delayed_handler(void *param);
242 static void ixgbe_add_rar(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
243 uint32_t index, uint32_t pool);
244 static void ixgbe_remove_rar(struct rte_eth_dev *dev, uint32_t index);
245 static void ixgbe_set_default_mac_addr(struct rte_eth_dev *dev,
246 struct ether_addr *mac_addr);
247 static void ixgbe_dcb_init(struct ixgbe_hw *hw, struct ixgbe_dcb_config *dcb_config);
249 /* For Virtual Function support */
250 static int eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev);
251 static int eth_ixgbevf_dev_uninit(struct rte_eth_dev *eth_dev);
252 static int ixgbevf_dev_configure(struct rte_eth_dev *dev);
253 static int ixgbevf_dev_start(struct rte_eth_dev *dev);
254 static void ixgbevf_dev_stop(struct rte_eth_dev *dev);
255 static void ixgbevf_dev_close(struct rte_eth_dev *dev);
256 static void ixgbevf_intr_disable(struct ixgbe_hw *hw);
257 static void ixgbevf_intr_enable(struct ixgbe_hw *hw);
258 static void ixgbevf_dev_stats_get(struct rte_eth_dev *dev,
259 struct rte_eth_stats *stats);
260 static void ixgbevf_dev_stats_reset(struct rte_eth_dev *dev);
261 static int ixgbevf_vlan_filter_set(struct rte_eth_dev *dev,
262 uint16_t vlan_id, int on);
263 static void ixgbevf_vlan_strip_queue_set(struct rte_eth_dev *dev,
264 uint16_t queue, int on);
265 static void ixgbevf_vlan_offload_set(struct rte_eth_dev *dev, int mask);
266 static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on);
267 static int ixgbevf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev,
269 static int ixgbevf_dev_rx_queue_intr_disable(struct rte_eth_dev *dev,
271 static void ixgbevf_set_ivar_map(struct ixgbe_hw *hw, int8_t direction,
272 uint8_t queue, uint8_t msix_vector);
273 static void ixgbevf_configure_msix(struct rte_eth_dev *dev);
274 static void ixgbevf_dev_allmulticast_enable(struct rte_eth_dev *dev);
275 static void ixgbevf_dev_allmulticast_disable(struct rte_eth_dev *dev);
277 /* For Eth VMDQ APIs support */
278 static int ixgbe_uc_hash_table_set(struct rte_eth_dev *dev, struct
279 ether_addr * mac_addr, uint8_t on);
280 static int ixgbe_uc_all_hash_table_set(struct rte_eth_dev *dev, uint8_t on);
281 static int ixgbe_set_pool_rx_mode(struct rte_eth_dev *dev, uint16_t pool,
282 uint16_t rx_mask, uint8_t on);
283 static int ixgbe_set_pool_rx(struct rte_eth_dev *dev, uint16_t pool, uint8_t on);
284 static int ixgbe_set_pool_tx(struct rte_eth_dev *dev, uint16_t pool, uint8_t on);
285 static int ixgbe_set_pool_vlan_filter(struct rte_eth_dev *dev, uint16_t vlan,
286 uint64_t pool_mask, uint8_t vlan_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);
302 static int ixgbe_set_vf_rate_limit(struct rte_eth_dev *dev, uint16_t vf,
303 uint16_t tx_rate, uint64_t q_msk);
305 static void ixgbevf_add_mac_addr(struct rte_eth_dev *dev,
306 struct ether_addr *mac_addr,
307 uint32_t index, uint32_t pool);
308 static void ixgbevf_remove_mac_addr(struct rte_eth_dev *dev, uint32_t index);
309 static void ixgbevf_set_default_mac_addr(struct rte_eth_dev *dev,
310 struct ether_addr *mac_addr);
311 static int ixgbe_syn_filter_set(struct rte_eth_dev *dev,
312 struct rte_eth_syn_filter *filter,
314 static int ixgbe_syn_filter_get(struct rte_eth_dev *dev,
315 struct rte_eth_syn_filter *filter);
316 static int ixgbe_syn_filter_handle(struct rte_eth_dev *dev,
317 enum rte_filter_op filter_op,
319 static int ixgbe_add_5tuple_filter(struct rte_eth_dev *dev,
320 struct ixgbe_5tuple_filter *filter);
321 static void ixgbe_remove_5tuple_filter(struct rte_eth_dev *dev,
322 struct ixgbe_5tuple_filter *filter);
323 static int ixgbe_add_del_ntuple_filter(struct rte_eth_dev *dev,
324 struct rte_eth_ntuple_filter *filter,
326 static int ixgbe_ntuple_filter_handle(struct rte_eth_dev *dev,
327 enum rte_filter_op filter_op,
329 static int ixgbe_get_ntuple_filter(struct rte_eth_dev *dev,
330 struct rte_eth_ntuple_filter *filter);
331 static int ixgbe_add_del_ethertype_filter(struct rte_eth_dev *dev,
332 struct rte_eth_ethertype_filter *filter,
334 static int ixgbe_ethertype_filter_handle(struct rte_eth_dev *dev,
335 enum rte_filter_op filter_op,
337 static int ixgbe_get_ethertype_filter(struct rte_eth_dev *dev,
338 struct rte_eth_ethertype_filter *filter);
339 static int ixgbe_dev_filter_ctrl(struct rte_eth_dev *dev,
340 enum rte_filter_type filter_type,
341 enum rte_filter_op filter_op,
343 static int ixgbevf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu);
345 static int ixgbe_dev_set_mc_addr_list(struct rte_eth_dev *dev,
346 struct ether_addr *mc_addr_set,
347 uint32_t nb_mc_addr);
348 static int ixgbe_dev_get_dcb_info(struct rte_eth_dev *dev,
349 struct rte_eth_dcb_info *dcb_info);
351 static int ixgbe_get_reg_length(struct rte_eth_dev *dev);
352 static int ixgbe_get_regs(struct rte_eth_dev *dev,
353 struct rte_dev_reg_info *regs);
354 static int ixgbe_get_eeprom_length(struct rte_eth_dev *dev);
355 static int ixgbe_get_eeprom(struct rte_eth_dev *dev,
356 struct rte_dev_eeprom_info *eeprom);
357 static int ixgbe_set_eeprom(struct rte_eth_dev *dev,
358 struct rte_dev_eeprom_info *eeprom);
360 static int ixgbevf_get_reg_length(struct rte_eth_dev *dev);
361 static int ixgbevf_get_regs(struct rte_eth_dev *dev,
362 struct rte_dev_reg_info *regs);
364 static int ixgbe_timesync_enable(struct rte_eth_dev *dev);
365 static int ixgbe_timesync_disable(struct rte_eth_dev *dev);
366 static int ixgbe_timesync_read_rx_timestamp(struct rte_eth_dev *dev,
367 struct timespec *timestamp,
369 static int ixgbe_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
370 struct timespec *timestamp);
371 static int ixgbe_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta);
372 static int ixgbe_timesync_read_time(struct rte_eth_dev *dev,
373 struct timespec *timestamp);
374 static int ixgbe_timesync_write_time(struct rte_eth_dev *dev,
375 const struct timespec *timestamp);
376 static void ixgbevf_dev_interrupt_handler(struct rte_intr_handle *handle,
379 static int ixgbe_dev_l2_tunnel_eth_type_conf
380 (struct rte_eth_dev *dev, struct rte_eth_l2_tunnel_conf *l2_tunnel);
381 static int ixgbe_dev_l2_tunnel_offload_set
382 (struct rte_eth_dev *dev,
383 struct rte_eth_l2_tunnel_conf *l2_tunnel,
386 static int ixgbe_dev_l2_tunnel_filter_handle(struct rte_eth_dev *dev,
387 enum rte_filter_op filter_op,
390 static int ixgbe_dev_udp_tunnel_port_add(struct rte_eth_dev *dev,
391 struct rte_eth_udp_tunnel *udp_tunnel);
392 static int ixgbe_dev_udp_tunnel_port_del(struct rte_eth_dev *dev,
393 struct rte_eth_udp_tunnel *udp_tunnel);
396 * Define VF Stats MACRO for Non "cleared on read" register
398 #define UPDATE_VF_STAT(reg, last, cur) \
400 uint32_t latest = IXGBE_READ_REG(hw, reg); \
401 cur += (latest - last) & UINT_MAX; \
405 #define UPDATE_VF_STAT_36BIT(lsb, msb, last, cur) \
407 u64 new_lsb = IXGBE_READ_REG(hw, lsb); \
408 u64 new_msb = IXGBE_READ_REG(hw, msb); \
409 u64 latest = ((new_msb << 32) | new_lsb); \
410 cur += (0x1000000000LL + latest - last) & 0xFFFFFFFFFLL; \
414 #define IXGBE_SET_HWSTRIP(h, q) do {\
415 uint32_t idx = (q) / (sizeof((h)->bitmap[0]) * NBBY); \
416 uint32_t bit = (q) % (sizeof((h)->bitmap[0]) * NBBY); \
417 (h)->bitmap[idx] |= 1 << bit;\
420 #define IXGBE_CLEAR_HWSTRIP(h, q) do {\
421 uint32_t idx = (q) / (sizeof((h)->bitmap[0]) * NBBY); \
422 uint32_t bit = (q) % (sizeof((h)->bitmap[0]) * NBBY); \
423 (h)->bitmap[idx] &= ~(1 << bit);\
426 #define IXGBE_GET_HWSTRIP(h, q, r) do {\
427 uint32_t idx = (q) / (sizeof((h)->bitmap[0]) * NBBY); \
428 uint32_t bit = (q) % (sizeof((h)->bitmap[0]) * NBBY); \
429 (r) = (h)->bitmap[idx] >> bit & 1;\
433 * The set of PCI devices this driver supports
435 static const struct rte_pci_id pci_id_ixgbe_map[] = {
436 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598) },
437 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598_BX) },
438 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AF_DUAL_PORT) },
439 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AF_SINGLE_PORT) },
440 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AT) },
441 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AT2) },
442 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598EB_SFP_LOM) },
443 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598EB_CX4) },
444 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598_CX4_DUAL_PORT) },
445 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598_DA_DUAL_PORT) },
446 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM) },
447 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598EB_XF_LR) },
448 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_KX4) },
449 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_KX4_MEZZ) },
450 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_KR) },
451 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_COMBO_BACKPLANE) },
452 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_SUBDEV_ID_82599_KX4_KR_MEZZ) },
453 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_CX4) },
454 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP) },
455 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_SUBDEV_ID_82599_SFP) },
456 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_SUBDEV_ID_82599_RNDC) },
457 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_SUBDEV_ID_82599_560FLR) },
458 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_SUBDEV_ID_82599_ECNA_DP) },
459 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_BACKPLANE_FCOE) },
460 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP_FCOE) },
461 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP_EM) },
462 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP_SF2) },
463 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP_SF_QP) },
464 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_QSFP_SF_QP) },
465 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599EN_SFP) },
466 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_XAUI_LOM) },
467 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_T3_LOM) },
468 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_LS) },
469 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X540T) },
470 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X540T1) },
471 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_SFP) },
472 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_10G_T) },
473 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_1G_T) },
474 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550T) },
475 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550T1) },
476 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_KR) },
477 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_KR_L) },
478 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_SFP_N) },
479 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_SGMII) },
480 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_SGMII_L) },
481 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_10G_T) },
482 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_QSFP) },
483 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_QSFP_N) },
484 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_SFP) },
485 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_1G_T) },
486 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_1G_T_L) },
487 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_KX4) },
488 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_KR) },
489 #ifdef RTE_NIC_BYPASS
490 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_BYPASS) },
492 { .vendor_id = 0, /* sentinel */ },
496 * The set of PCI devices this driver supports (for 82599 VF)
498 static const struct rte_pci_id pci_id_ixgbevf_map[] = {
499 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_VF) },
500 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_VF_HV) },
501 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X540_VF) },
502 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X540_VF_HV) },
503 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550_VF_HV) },
504 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550_VF) },
505 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_VF) },
506 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_VF_HV) },
507 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_VF) },
508 { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_VF_HV) },
509 { .vendor_id = 0, /* sentinel */ },
512 static const struct rte_eth_desc_lim rx_desc_lim = {
513 .nb_max = IXGBE_MAX_RING_DESC,
514 .nb_min = IXGBE_MIN_RING_DESC,
515 .nb_align = IXGBE_RXD_ALIGN,
518 static const struct rte_eth_desc_lim tx_desc_lim = {
519 .nb_max = IXGBE_MAX_RING_DESC,
520 .nb_min = IXGBE_MIN_RING_DESC,
521 .nb_align = IXGBE_TXD_ALIGN,
522 .nb_seg_max = IXGBE_TX_MAX_SEG,
523 .nb_mtu_seg_max = IXGBE_TX_MAX_SEG,
526 static const struct eth_dev_ops ixgbe_eth_dev_ops = {
527 .dev_configure = ixgbe_dev_configure,
528 .dev_start = ixgbe_dev_start,
529 .dev_stop = ixgbe_dev_stop,
530 .dev_set_link_up = ixgbe_dev_set_link_up,
531 .dev_set_link_down = ixgbe_dev_set_link_down,
532 .dev_close = ixgbe_dev_close,
533 .promiscuous_enable = ixgbe_dev_promiscuous_enable,
534 .promiscuous_disable = ixgbe_dev_promiscuous_disable,
535 .allmulticast_enable = ixgbe_dev_allmulticast_enable,
536 .allmulticast_disable = ixgbe_dev_allmulticast_disable,
537 .link_update = ixgbe_dev_link_update,
538 .stats_get = ixgbe_dev_stats_get,
539 .xstats_get = ixgbe_dev_xstats_get,
540 .stats_reset = ixgbe_dev_stats_reset,
541 .xstats_reset = ixgbe_dev_xstats_reset,
542 .xstats_get_names = ixgbe_dev_xstats_get_names,
543 .queue_stats_mapping_set = ixgbe_dev_queue_stats_mapping_set,
544 .dev_infos_get = ixgbe_dev_info_get,
545 .dev_supported_ptypes_get = ixgbe_dev_supported_ptypes_get,
546 .mtu_set = ixgbe_dev_mtu_set,
547 .vlan_filter_set = ixgbe_vlan_filter_set,
548 .vlan_tpid_set = ixgbe_vlan_tpid_set,
549 .vlan_offload_set = ixgbe_vlan_offload_set,
550 .vlan_strip_queue_set = ixgbe_vlan_strip_queue_set,
551 .rx_queue_start = ixgbe_dev_rx_queue_start,
552 .rx_queue_stop = ixgbe_dev_rx_queue_stop,
553 .tx_queue_start = ixgbe_dev_tx_queue_start,
554 .tx_queue_stop = ixgbe_dev_tx_queue_stop,
555 .rx_queue_setup = ixgbe_dev_rx_queue_setup,
556 .rx_queue_intr_enable = ixgbe_dev_rx_queue_intr_enable,
557 .rx_queue_intr_disable = ixgbe_dev_rx_queue_intr_disable,
558 .rx_queue_release = ixgbe_dev_rx_queue_release,
559 .rx_queue_count = ixgbe_dev_rx_queue_count,
560 .rx_descriptor_done = ixgbe_dev_rx_descriptor_done,
561 .tx_queue_setup = ixgbe_dev_tx_queue_setup,
562 .tx_queue_release = ixgbe_dev_tx_queue_release,
563 .dev_led_on = ixgbe_dev_led_on,
564 .dev_led_off = ixgbe_dev_led_off,
565 .flow_ctrl_get = ixgbe_flow_ctrl_get,
566 .flow_ctrl_set = ixgbe_flow_ctrl_set,
567 .priority_flow_ctrl_set = ixgbe_priority_flow_ctrl_set,
568 .mac_addr_add = ixgbe_add_rar,
569 .mac_addr_remove = ixgbe_remove_rar,
570 .mac_addr_set = ixgbe_set_default_mac_addr,
571 .uc_hash_table_set = ixgbe_uc_hash_table_set,
572 .uc_all_hash_table_set = ixgbe_uc_all_hash_table_set,
573 .mirror_rule_set = ixgbe_mirror_rule_set,
574 .mirror_rule_reset = ixgbe_mirror_rule_reset,
575 .set_vf_rx_mode = ixgbe_set_pool_rx_mode,
576 .set_vf_rx = ixgbe_set_pool_rx,
577 .set_vf_tx = ixgbe_set_pool_tx,
578 .set_vf_vlan_filter = ixgbe_set_pool_vlan_filter,
579 .set_queue_rate_limit = ixgbe_set_queue_rate_limit,
580 .set_vf_rate_limit = ixgbe_set_vf_rate_limit,
581 .reta_update = ixgbe_dev_rss_reta_update,
582 .reta_query = ixgbe_dev_rss_reta_query,
583 #ifdef RTE_NIC_BYPASS
584 .bypass_init = ixgbe_bypass_init,
585 .bypass_state_set = ixgbe_bypass_state_store,
586 .bypass_state_show = ixgbe_bypass_state_show,
587 .bypass_event_set = ixgbe_bypass_event_store,
588 .bypass_event_show = ixgbe_bypass_event_show,
589 .bypass_wd_timeout_set = ixgbe_bypass_wd_timeout_store,
590 .bypass_wd_timeout_show = ixgbe_bypass_wd_timeout_show,
591 .bypass_ver_show = ixgbe_bypass_ver_show,
592 .bypass_wd_reset = ixgbe_bypass_wd_reset,
593 #endif /* RTE_NIC_BYPASS */
594 .rss_hash_update = ixgbe_dev_rss_hash_update,
595 .rss_hash_conf_get = ixgbe_dev_rss_hash_conf_get,
596 .filter_ctrl = ixgbe_dev_filter_ctrl,
597 .set_mc_addr_list = ixgbe_dev_set_mc_addr_list,
598 .rxq_info_get = ixgbe_rxq_info_get,
599 .txq_info_get = ixgbe_txq_info_get,
600 .timesync_enable = ixgbe_timesync_enable,
601 .timesync_disable = ixgbe_timesync_disable,
602 .timesync_read_rx_timestamp = ixgbe_timesync_read_rx_timestamp,
603 .timesync_read_tx_timestamp = ixgbe_timesync_read_tx_timestamp,
604 .get_reg = ixgbe_get_regs,
605 .get_eeprom_length = ixgbe_get_eeprom_length,
606 .get_eeprom = ixgbe_get_eeprom,
607 .set_eeprom = ixgbe_set_eeprom,
608 .get_dcb_info = ixgbe_dev_get_dcb_info,
609 .timesync_adjust_time = ixgbe_timesync_adjust_time,
610 .timesync_read_time = ixgbe_timesync_read_time,
611 .timesync_write_time = ixgbe_timesync_write_time,
612 .l2_tunnel_eth_type_conf = ixgbe_dev_l2_tunnel_eth_type_conf,
613 .l2_tunnel_offload_set = ixgbe_dev_l2_tunnel_offload_set,
614 .udp_tunnel_port_add = ixgbe_dev_udp_tunnel_port_add,
615 .udp_tunnel_port_del = ixgbe_dev_udp_tunnel_port_del,
619 * dev_ops for virtual function, bare necessities for basic vf
620 * operation have been implemented
622 static const struct eth_dev_ops ixgbevf_eth_dev_ops = {
623 .dev_configure = ixgbevf_dev_configure,
624 .dev_start = ixgbevf_dev_start,
625 .dev_stop = ixgbevf_dev_stop,
626 .link_update = ixgbe_dev_link_update,
627 .stats_get = ixgbevf_dev_stats_get,
628 .xstats_get = ixgbevf_dev_xstats_get,
629 .stats_reset = ixgbevf_dev_stats_reset,
630 .xstats_reset = ixgbevf_dev_stats_reset,
631 .xstats_get_names = ixgbevf_dev_xstats_get_names,
632 .dev_close = ixgbevf_dev_close,
633 .allmulticast_enable = ixgbevf_dev_allmulticast_enable,
634 .allmulticast_disable = ixgbevf_dev_allmulticast_disable,
635 .dev_infos_get = ixgbevf_dev_info_get,
636 .dev_supported_ptypes_get = ixgbe_dev_supported_ptypes_get,
637 .mtu_set = ixgbevf_dev_set_mtu,
638 .vlan_filter_set = ixgbevf_vlan_filter_set,
639 .vlan_strip_queue_set = ixgbevf_vlan_strip_queue_set,
640 .vlan_offload_set = ixgbevf_vlan_offload_set,
641 .rx_queue_setup = ixgbe_dev_rx_queue_setup,
642 .rx_queue_release = ixgbe_dev_rx_queue_release,
643 .rx_descriptor_done = ixgbe_dev_rx_descriptor_done,
644 .tx_queue_setup = ixgbe_dev_tx_queue_setup,
645 .tx_queue_release = ixgbe_dev_tx_queue_release,
646 .rx_queue_intr_enable = ixgbevf_dev_rx_queue_intr_enable,
647 .rx_queue_intr_disable = ixgbevf_dev_rx_queue_intr_disable,
648 .mac_addr_add = ixgbevf_add_mac_addr,
649 .mac_addr_remove = ixgbevf_remove_mac_addr,
650 .set_mc_addr_list = ixgbe_dev_set_mc_addr_list,
651 .rxq_info_get = ixgbe_rxq_info_get,
652 .txq_info_get = ixgbe_txq_info_get,
653 .mac_addr_set = ixgbevf_set_default_mac_addr,
654 .get_reg = ixgbevf_get_regs,
655 .reta_update = ixgbe_dev_rss_reta_update,
656 .reta_query = ixgbe_dev_rss_reta_query,
657 .rss_hash_update = ixgbe_dev_rss_hash_update,
658 .rss_hash_conf_get = ixgbe_dev_rss_hash_conf_get,
661 /* store statistics names and its offset in stats structure */
662 struct rte_ixgbe_xstats_name_off {
663 char name[RTE_ETH_XSTATS_NAME_SIZE];
667 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_stats_strings[] = {
668 {"rx_crc_errors", offsetof(struct ixgbe_hw_stats, crcerrs)},
669 {"rx_illegal_byte_errors", offsetof(struct ixgbe_hw_stats, illerrc)},
670 {"rx_error_bytes", offsetof(struct ixgbe_hw_stats, errbc)},
671 {"mac_local_errors", offsetof(struct ixgbe_hw_stats, mlfc)},
672 {"mac_remote_errors", offsetof(struct ixgbe_hw_stats, mrfc)},
673 {"rx_length_errors", offsetof(struct ixgbe_hw_stats, rlec)},
674 {"tx_xon_packets", offsetof(struct ixgbe_hw_stats, lxontxc)},
675 {"rx_xon_packets", offsetof(struct ixgbe_hw_stats, lxonrxc)},
676 {"tx_xoff_packets", offsetof(struct ixgbe_hw_stats, lxofftxc)},
677 {"rx_xoff_packets", offsetof(struct ixgbe_hw_stats, lxoffrxc)},
678 {"rx_size_64_packets", offsetof(struct ixgbe_hw_stats, prc64)},
679 {"rx_size_65_to_127_packets", offsetof(struct ixgbe_hw_stats, prc127)},
680 {"rx_size_128_to_255_packets", offsetof(struct ixgbe_hw_stats, prc255)},
681 {"rx_size_256_to_511_packets", offsetof(struct ixgbe_hw_stats, prc511)},
682 {"rx_size_512_to_1023_packets", offsetof(struct ixgbe_hw_stats,
684 {"rx_size_1024_to_max_packets", offsetof(struct ixgbe_hw_stats,
686 {"rx_broadcast_packets", offsetof(struct ixgbe_hw_stats, bprc)},
687 {"rx_multicast_packets", offsetof(struct ixgbe_hw_stats, mprc)},
688 {"rx_fragment_errors", offsetof(struct ixgbe_hw_stats, rfc)},
689 {"rx_undersize_errors", offsetof(struct ixgbe_hw_stats, ruc)},
690 {"rx_oversize_errors", offsetof(struct ixgbe_hw_stats, roc)},
691 {"rx_jabber_errors", offsetof(struct ixgbe_hw_stats, rjc)},
692 {"rx_management_packets", offsetof(struct ixgbe_hw_stats, mngprc)},
693 {"rx_management_dropped", offsetof(struct ixgbe_hw_stats, mngpdc)},
694 {"tx_management_packets", offsetof(struct ixgbe_hw_stats, mngptc)},
695 {"rx_total_packets", offsetof(struct ixgbe_hw_stats, tpr)},
696 {"rx_total_bytes", offsetof(struct ixgbe_hw_stats, tor)},
697 {"tx_total_packets", offsetof(struct ixgbe_hw_stats, tpt)},
698 {"tx_size_64_packets", offsetof(struct ixgbe_hw_stats, ptc64)},
699 {"tx_size_65_to_127_packets", offsetof(struct ixgbe_hw_stats, ptc127)},
700 {"tx_size_128_to_255_packets", offsetof(struct ixgbe_hw_stats, ptc255)},
701 {"tx_size_256_to_511_packets", offsetof(struct ixgbe_hw_stats, ptc511)},
702 {"tx_size_512_to_1023_packets", offsetof(struct ixgbe_hw_stats,
704 {"tx_size_1024_to_max_packets", offsetof(struct ixgbe_hw_stats,
706 {"tx_multicast_packets", offsetof(struct ixgbe_hw_stats, mptc)},
707 {"tx_broadcast_packets", offsetof(struct ixgbe_hw_stats, bptc)},
708 {"rx_mac_short_packet_dropped", offsetof(struct ixgbe_hw_stats, mspdc)},
709 {"rx_l3_l4_xsum_error", offsetof(struct ixgbe_hw_stats, xec)},
711 {"flow_director_added_filters", offsetof(struct ixgbe_hw_stats,
713 {"flow_director_removed_filters", offsetof(struct ixgbe_hw_stats,
715 {"flow_director_filter_add_errors", offsetof(struct ixgbe_hw_stats,
717 {"flow_director_filter_remove_errors", offsetof(struct ixgbe_hw_stats,
719 {"flow_director_matched_filters", offsetof(struct ixgbe_hw_stats,
721 {"flow_director_missed_filters", offsetof(struct ixgbe_hw_stats,
724 {"rx_fcoe_crc_errors", offsetof(struct ixgbe_hw_stats, fccrc)},
725 {"rx_fcoe_dropped", offsetof(struct ixgbe_hw_stats, fcoerpdc)},
726 {"rx_fcoe_mbuf_allocation_errors", offsetof(struct ixgbe_hw_stats,
728 {"rx_fcoe_packets", offsetof(struct ixgbe_hw_stats, fcoeprc)},
729 {"tx_fcoe_packets", offsetof(struct ixgbe_hw_stats, fcoeptc)},
730 {"rx_fcoe_bytes", offsetof(struct ixgbe_hw_stats, fcoedwrc)},
731 {"tx_fcoe_bytes", offsetof(struct ixgbe_hw_stats, fcoedwtc)},
732 {"rx_fcoe_no_direct_data_placement", offsetof(struct ixgbe_hw_stats,
734 {"rx_fcoe_no_direct_data_placement_ext_buff",
735 offsetof(struct ixgbe_hw_stats, fcoe_noddp_ext_buff)},
737 {"tx_flow_control_xon_packets", offsetof(struct ixgbe_hw_stats,
739 {"rx_flow_control_xon_packets", offsetof(struct ixgbe_hw_stats,
741 {"tx_flow_control_xoff_packets", offsetof(struct ixgbe_hw_stats,
743 {"rx_flow_control_xoff_packets", offsetof(struct ixgbe_hw_stats,
745 {"rx_total_missed_packets", offsetof(struct ixgbe_hw_stats, mpctotal)},
748 #define IXGBE_NB_HW_STATS (sizeof(rte_ixgbe_stats_strings) / \
749 sizeof(rte_ixgbe_stats_strings[0]))
751 /* MACsec statistics */
752 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_macsec_strings[] = {
753 {"out_pkts_untagged", offsetof(struct ixgbe_macsec_stats,
755 {"out_pkts_encrypted", offsetof(struct ixgbe_macsec_stats,
756 out_pkts_encrypted)},
757 {"out_pkts_protected", offsetof(struct ixgbe_macsec_stats,
758 out_pkts_protected)},
759 {"out_octets_encrypted", offsetof(struct ixgbe_macsec_stats,
760 out_octets_encrypted)},
761 {"out_octets_protected", offsetof(struct ixgbe_macsec_stats,
762 out_octets_protected)},
763 {"in_pkts_untagged", offsetof(struct ixgbe_macsec_stats,
765 {"in_pkts_badtag", offsetof(struct ixgbe_macsec_stats,
767 {"in_pkts_nosci", offsetof(struct ixgbe_macsec_stats,
769 {"in_pkts_unknownsci", offsetof(struct ixgbe_macsec_stats,
770 in_pkts_unknownsci)},
771 {"in_octets_decrypted", offsetof(struct ixgbe_macsec_stats,
772 in_octets_decrypted)},
773 {"in_octets_validated", offsetof(struct ixgbe_macsec_stats,
774 in_octets_validated)},
775 {"in_pkts_unchecked", offsetof(struct ixgbe_macsec_stats,
777 {"in_pkts_delayed", offsetof(struct ixgbe_macsec_stats,
779 {"in_pkts_late", offsetof(struct ixgbe_macsec_stats,
781 {"in_pkts_ok", offsetof(struct ixgbe_macsec_stats,
783 {"in_pkts_invalid", offsetof(struct ixgbe_macsec_stats,
785 {"in_pkts_notvalid", offsetof(struct ixgbe_macsec_stats,
787 {"in_pkts_unusedsa", offsetof(struct ixgbe_macsec_stats,
789 {"in_pkts_notusingsa", offsetof(struct ixgbe_macsec_stats,
790 in_pkts_notusingsa)},
793 #define IXGBE_NB_MACSEC_STATS (sizeof(rte_ixgbe_macsec_strings) / \
794 sizeof(rte_ixgbe_macsec_strings[0]))
796 /* Per-queue statistics */
797 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_rxq_strings[] = {
798 {"mbuf_allocation_errors", offsetof(struct ixgbe_hw_stats, rnbc)},
799 {"dropped", offsetof(struct ixgbe_hw_stats, mpc)},
800 {"xon_packets", offsetof(struct ixgbe_hw_stats, pxonrxc)},
801 {"xoff_packets", offsetof(struct ixgbe_hw_stats, pxoffrxc)},
804 #define IXGBE_NB_RXQ_PRIO_STATS (sizeof(rte_ixgbe_rxq_strings) / \
805 sizeof(rte_ixgbe_rxq_strings[0]))
806 #define IXGBE_NB_RXQ_PRIO_VALUES 8
808 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_txq_strings[] = {
809 {"xon_packets", offsetof(struct ixgbe_hw_stats, pxontxc)},
810 {"xoff_packets", offsetof(struct ixgbe_hw_stats, pxofftxc)},
811 {"xon_to_xoff_packets", offsetof(struct ixgbe_hw_stats,
815 #define IXGBE_NB_TXQ_PRIO_STATS (sizeof(rte_ixgbe_txq_strings) / \
816 sizeof(rte_ixgbe_txq_strings[0]))
817 #define IXGBE_NB_TXQ_PRIO_VALUES 8
819 static const struct rte_ixgbe_xstats_name_off rte_ixgbevf_stats_strings[] = {
820 {"rx_multicast_packets", offsetof(struct ixgbevf_hw_stats, vfmprc)},
823 #define IXGBEVF_NB_XSTATS (sizeof(rte_ixgbevf_stats_strings) / \
824 sizeof(rte_ixgbevf_stats_strings[0]))
827 * Atomically reads the link status information from global
828 * structure rte_eth_dev.
831 * - Pointer to the structure rte_eth_dev to read from.
832 * - Pointer to the buffer to be saved with the link status.
835 * - On success, zero.
836 * - On failure, negative value.
839 rte_ixgbe_dev_atomic_read_link_status(struct rte_eth_dev *dev,
840 struct rte_eth_link *link)
842 struct rte_eth_link *dst = link;
843 struct rte_eth_link *src = &(dev->data->dev_link);
845 if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
846 *(uint64_t *)src) == 0)
853 * Atomically writes the link status information into global
854 * structure rte_eth_dev.
857 * - Pointer to the structure rte_eth_dev to read from.
858 * - Pointer to the buffer to be saved with the link status.
861 * - On success, zero.
862 * - On failure, negative value.
865 rte_ixgbe_dev_atomic_write_link_status(struct rte_eth_dev *dev,
866 struct rte_eth_link *link)
868 struct rte_eth_link *dst = &(dev->data->dev_link);
869 struct rte_eth_link *src = link;
871 if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
872 *(uint64_t *)src) == 0)
879 * This function is the same as ixgbe_is_sfp() in base/ixgbe.h.
882 ixgbe_is_sfp(struct ixgbe_hw *hw)
884 switch (hw->phy.type) {
885 case ixgbe_phy_sfp_avago:
886 case ixgbe_phy_sfp_ftl:
887 case ixgbe_phy_sfp_intel:
888 case ixgbe_phy_sfp_unknown:
889 case ixgbe_phy_sfp_passive_tyco:
890 case ixgbe_phy_sfp_passive_unknown:
897 static inline int32_t
898 ixgbe_pf_reset_hw(struct ixgbe_hw *hw)
903 status = ixgbe_reset_hw(hw);
905 ctrl_ext = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
906 /* Set PF Reset Done bit so PF/VF Mail Ops can work */
907 ctrl_ext |= IXGBE_CTRL_EXT_PFRSTD;
908 IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl_ext);
909 IXGBE_WRITE_FLUSH(hw);
915 ixgbe_enable_intr(struct rte_eth_dev *dev)
917 struct ixgbe_interrupt *intr =
918 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
919 struct ixgbe_hw *hw =
920 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
922 IXGBE_WRITE_REG(hw, IXGBE_EIMS, intr->mask);
923 IXGBE_WRITE_FLUSH(hw);
927 * This function is based on ixgbe_disable_intr() in base/ixgbe.h.
930 ixgbe_disable_intr(struct ixgbe_hw *hw)
932 PMD_INIT_FUNC_TRACE();
934 if (hw->mac.type == ixgbe_mac_82598EB) {
935 IXGBE_WRITE_REG(hw, IXGBE_EIMC, ~0);
937 IXGBE_WRITE_REG(hw, IXGBE_EIMC, 0xFFFF0000);
938 IXGBE_WRITE_REG(hw, IXGBE_EIMC_EX(0), ~0);
939 IXGBE_WRITE_REG(hw, IXGBE_EIMC_EX(1), ~0);
941 IXGBE_WRITE_FLUSH(hw);
945 * This function resets queue statistics mapping registers.
946 * From Niantic datasheet, Initialization of Statistics section:
947 * "...if software requires the queue counters, the RQSMR and TQSM registers
948 * must be re-programmed following a device reset.
951 ixgbe_reset_qstat_mappings(struct ixgbe_hw *hw)
955 for (i = 0; i != IXGBE_NB_STAT_MAPPING_REGS; i++) {
956 IXGBE_WRITE_REG(hw, IXGBE_RQSMR(i), 0);
957 IXGBE_WRITE_REG(hw, IXGBE_TQSM(i), 0);
963 ixgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
968 #define QSM_REG_NB_BITS_PER_QMAP_FIELD 8
969 #define NB_QMAP_FIELDS_PER_QSM_REG 4
970 #define QMAP_FIELD_RESERVED_BITS_MASK 0x0f
972 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
973 struct ixgbe_stat_mapping_registers *stat_mappings =
974 IXGBE_DEV_PRIVATE_TO_STAT_MAPPINGS(eth_dev->data->dev_private);
975 uint32_t qsmr_mask = 0;
976 uint32_t clearing_mask = QMAP_FIELD_RESERVED_BITS_MASK;
980 if ((hw->mac.type != ixgbe_mac_82599EB) &&
981 (hw->mac.type != ixgbe_mac_X540) &&
982 (hw->mac.type != ixgbe_mac_X550) &&
983 (hw->mac.type != ixgbe_mac_X550EM_x) &&
984 (hw->mac.type != ixgbe_mac_X550EM_a))
987 PMD_INIT_LOG(DEBUG, "Setting port %d, %s queue_id %d to stat index %d",
988 (int)(eth_dev->data->port_id), is_rx ? "RX" : "TX",
991 n = (uint8_t)(queue_id / NB_QMAP_FIELDS_PER_QSM_REG);
992 if (n >= IXGBE_NB_STAT_MAPPING_REGS) {
993 PMD_INIT_LOG(ERR, "Nb of stat mapping registers exceeded");
996 offset = (uint8_t)(queue_id % NB_QMAP_FIELDS_PER_QSM_REG);
998 /* Now clear any previous stat_idx set */
999 clearing_mask <<= (QSM_REG_NB_BITS_PER_QMAP_FIELD * offset);
1001 stat_mappings->tqsm[n] &= ~clearing_mask;
1003 stat_mappings->rqsmr[n] &= ~clearing_mask;
1005 q_map = (uint32_t)stat_idx;
1006 q_map &= QMAP_FIELD_RESERVED_BITS_MASK;
1007 qsmr_mask = q_map << (QSM_REG_NB_BITS_PER_QMAP_FIELD * offset);
1009 stat_mappings->tqsm[n] |= qsmr_mask;
1011 stat_mappings->rqsmr[n] |= qsmr_mask;
1013 PMD_INIT_LOG(DEBUG, "Set port %d, %s queue_id %d to stat index %d",
1014 (int)(eth_dev->data->port_id), is_rx ? "RX" : "TX",
1015 queue_id, stat_idx);
1016 PMD_INIT_LOG(DEBUG, "%s[%d] = 0x%08x", is_rx ? "RQSMR" : "TQSM", n,
1017 is_rx ? stat_mappings->rqsmr[n] : stat_mappings->tqsm[n]);
1019 /* Now write the mapping in the appropriate register */
1021 PMD_INIT_LOG(DEBUG, "Write 0x%x to RX IXGBE stat mapping reg:%d",
1022 stat_mappings->rqsmr[n], n);
1023 IXGBE_WRITE_REG(hw, IXGBE_RQSMR(n), stat_mappings->rqsmr[n]);
1025 PMD_INIT_LOG(DEBUG, "Write 0x%x to TX IXGBE stat mapping reg:%d",
1026 stat_mappings->tqsm[n], n);
1027 IXGBE_WRITE_REG(hw, IXGBE_TQSM(n), stat_mappings->tqsm[n]);
1033 ixgbe_restore_statistics_mapping(struct rte_eth_dev *dev)
1035 struct ixgbe_stat_mapping_registers *stat_mappings =
1036 IXGBE_DEV_PRIVATE_TO_STAT_MAPPINGS(dev->data->dev_private);
1037 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1040 /* write whatever was in stat mapping table to the NIC */
1041 for (i = 0; i < IXGBE_NB_STAT_MAPPING_REGS; i++) {
1043 IXGBE_WRITE_REG(hw, IXGBE_RQSMR(i), stat_mappings->rqsmr[i]);
1046 IXGBE_WRITE_REG(hw, IXGBE_TQSM(i), stat_mappings->tqsm[i]);
1051 ixgbe_dcb_init(struct ixgbe_hw *hw, struct ixgbe_dcb_config *dcb_config)
1054 struct ixgbe_dcb_tc_config *tc;
1055 uint8_t dcb_max_tc = IXGBE_DCB_MAX_TRAFFIC_CLASS;
1057 dcb_config->num_tcs.pg_tcs = dcb_max_tc;
1058 dcb_config->num_tcs.pfc_tcs = dcb_max_tc;
1059 for (i = 0; i < dcb_max_tc; i++) {
1060 tc = &dcb_config->tc_config[i];
1061 tc->path[IXGBE_DCB_TX_CONFIG].bwg_id = i;
1062 tc->path[IXGBE_DCB_TX_CONFIG].bwg_percent =
1063 (uint8_t)(100/dcb_max_tc + (i & 1));
1064 tc->path[IXGBE_DCB_RX_CONFIG].bwg_id = i;
1065 tc->path[IXGBE_DCB_RX_CONFIG].bwg_percent =
1066 (uint8_t)(100/dcb_max_tc + (i & 1));
1067 tc->pfc = ixgbe_dcb_pfc_disabled;
1070 /* Initialize default user to priority mapping, UPx->TC0 */
1071 tc = &dcb_config->tc_config[0];
1072 tc->path[IXGBE_DCB_TX_CONFIG].up_to_tc_bitmap = 0xFF;
1073 tc->path[IXGBE_DCB_RX_CONFIG].up_to_tc_bitmap = 0xFF;
1074 for (i = 0; i < IXGBE_DCB_MAX_BW_GROUP; i++) {
1075 dcb_config->bw_percentage[IXGBE_DCB_TX_CONFIG][i] = 100;
1076 dcb_config->bw_percentage[IXGBE_DCB_RX_CONFIG][i] = 100;
1078 dcb_config->rx_pba_cfg = ixgbe_dcb_pba_equal;
1079 dcb_config->pfc_mode_enable = false;
1080 dcb_config->vt_mode = true;
1081 dcb_config->round_robin_enable = false;
1082 /* support all DCB capabilities in 82599 */
1083 dcb_config->support.capabilities = 0xFF;
1085 /*we only support 4 Tcs for X540, X550 */
1086 if (hw->mac.type == ixgbe_mac_X540 ||
1087 hw->mac.type == ixgbe_mac_X550 ||
1088 hw->mac.type == ixgbe_mac_X550EM_x ||
1089 hw->mac.type == ixgbe_mac_X550EM_a) {
1090 dcb_config->num_tcs.pg_tcs = 4;
1091 dcb_config->num_tcs.pfc_tcs = 4;
1096 * Ensure that all locks are released before first NVM or PHY access
1099 ixgbe_swfw_lock_reset(struct ixgbe_hw *hw)
1104 * Phy lock should not fail in this early stage. If this is the case,
1105 * it is due to an improper exit of the application.
1106 * So force the release of the faulty lock. Release of common lock
1107 * is done automatically by swfw_sync function.
1109 mask = IXGBE_GSSR_PHY0_SM << hw->bus.func;
1110 if (ixgbe_acquire_swfw_semaphore(hw, mask) < 0) {
1111 PMD_DRV_LOG(DEBUG, "SWFW phy%d lock released", hw->bus.func);
1113 ixgbe_release_swfw_semaphore(hw, mask);
1116 * These ones are more tricky since they are common to all ports; but
1117 * swfw_sync retries last long enough (1s) to be almost sure that if
1118 * lock can not be taken it is due to an improper lock of the
1121 mask = IXGBE_GSSR_EEP_SM | IXGBE_GSSR_MAC_CSR_SM | IXGBE_GSSR_SW_MNG_SM;
1122 if (ixgbe_acquire_swfw_semaphore(hw, mask) < 0) {
1123 PMD_DRV_LOG(DEBUG, "SWFW common locks released");
1125 ixgbe_release_swfw_semaphore(hw, mask);
1129 * This function is based on code in ixgbe_attach() in base/ixgbe.c.
1130 * It returns 0 on success.
1133 eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev)
1135 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(eth_dev);
1136 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
1137 struct ixgbe_hw *hw =
1138 IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
1139 struct ixgbe_vfta *shadow_vfta =
1140 IXGBE_DEV_PRIVATE_TO_VFTA(eth_dev->data->dev_private);
1141 struct ixgbe_hwstrip *hwstrip =
1142 IXGBE_DEV_PRIVATE_TO_HWSTRIP_BITMAP(eth_dev->data->dev_private);
1143 struct ixgbe_dcb_config *dcb_config =
1144 IXGBE_DEV_PRIVATE_TO_DCB_CFG(eth_dev->data->dev_private);
1145 struct ixgbe_filter_info *filter_info =
1146 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(eth_dev->data->dev_private);
1151 PMD_INIT_FUNC_TRACE();
1153 eth_dev->dev_ops = &ixgbe_eth_dev_ops;
1154 eth_dev->rx_pkt_burst = &ixgbe_recv_pkts;
1155 eth_dev->tx_pkt_burst = &ixgbe_xmit_pkts;
1156 eth_dev->tx_pkt_prepare = &ixgbe_prep_pkts;
1159 * For secondary processes, we don't initialise any further as primary
1160 * has already done this work. Only check we don't need a different
1161 * RX and TX function.
1163 if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
1164 struct ixgbe_tx_queue *txq;
1165 /* TX queue function in primary, set by last queue initialized
1166 * Tx queue may not initialized by primary process
1168 if (eth_dev->data->tx_queues) {
1169 txq = eth_dev->data->tx_queues[eth_dev->data->nb_tx_queues-1];
1170 ixgbe_set_tx_function(eth_dev, txq);
1172 /* Use default TX function if we get here */
1173 PMD_INIT_LOG(NOTICE, "No TX queues configured yet. "
1174 "Using default TX function.");
1177 ixgbe_set_rx_function(eth_dev);
1182 rte_eth_copy_pci_info(eth_dev, pci_dev);
1183 eth_dev->data->dev_flags = RTE_ETH_DEV_DETACHABLE;
1185 /* Vendor and Device ID need to be set before init of shared code */
1186 hw->device_id = pci_dev->id.device_id;
1187 hw->vendor_id = pci_dev->id.vendor_id;
1188 hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
1189 hw->allow_unsupported_sfp = 1;
1191 /* Initialize the shared code (base driver) */
1192 #ifdef RTE_NIC_BYPASS
1193 diag = ixgbe_bypass_init_shared_code(hw);
1195 diag = ixgbe_init_shared_code(hw);
1196 #endif /* RTE_NIC_BYPASS */
1198 if (diag != IXGBE_SUCCESS) {
1199 PMD_INIT_LOG(ERR, "Shared code init failed: %d", diag);
1203 /* pick up the PCI bus settings for reporting later */
1204 ixgbe_get_bus_info(hw);
1206 /* Unlock any pending hardware semaphore */
1207 ixgbe_swfw_lock_reset(hw);
1209 /* Initialize DCB configuration*/
1210 memset(dcb_config, 0, sizeof(struct ixgbe_dcb_config));
1211 ixgbe_dcb_init(hw, dcb_config);
1212 /* Get Hardware Flow Control setting */
1213 hw->fc.requested_mode = ixgbe_fc_full;
1214 hw->fc.current_mode = ixgbe_fc_full;
1215 hw->fc.pause_time = IXGBE_FC_PAUSE;
1216 for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
1217 hw->fc.low_water[i] = IXGBE_FC_LO;
1218 hw->fc.high_water[i] = IXGBE_FC_HI;
1220 hw->fc.send_xon = 1;
1222 /* Make sure we have a good EEPROM before we read from it */
1223 diag = ixgbe_validate_eeprom_checksum(hw, &csum);
1224 if (diag != IXGBE_SUCCESS) {
1225 PMD_INIT_LOG(ERR, "The EEPROM checksum is not valid: %d", diag);
1229 #ifdef RTE_NIC_BYPASS
1230 diag = ixgbe_bypass_init_hw(hw);
1232 diag = ixgbe_init_hw(hw);
1233 #endif /* RTE_NIC_BYPASS */
1236 * Devices with copper phys will fail to initialise if ixgbe_init_hw()
1237 * is called too soon after the kernel driver unbinding/binding occurs.
1238 * The failure occurs in ixgbe_identify_phy_generic() for all devices,
1239 * but for non-copper devies, ixgbe_identify_sfp_module_generic() is
1240 * also called. See ixgbe_identify_phy_82599(). The reason for the
1241 * failure is not known, and only occuts when virtualisation features
1242 * are disabled in the bios. A delay of 100ms was found to be enough by
1243 * trial-and-error, and is doubled to be safe.
1245 if (diag && (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper)) {
1247 diag = ixgbe_init_hw(hw);
1250 if (diag == IXGBE_ERR_EEPROM_VERSION) {
1251 PMD_INIT_LOG(ERR, "This device is a pre-production adapter/"
1252 "LOM. Please be aware there may be issues associated "
1253 "with your hardware.");
1254 PMD_INIT_LOG(ERR, "If you are experiencing problems "
1255 "please contact your Intel or hardware representative "
1256 "who provided you with this hardware.");
1257 } else if (diag == IXGBE_ERR_SFP_NOT_SUPPORTED)
1258 PMD_INIT_LOG(ERR, "Unsupported SFP+ Module");
1260 PMD_INIT_LOG(ERR, "Hardware Initialization Failure: %d", diag);
1264 /* Reset the hw statistics */
1265 ixgbe_dev_stats_reset(eth_dev);
1267 /* disable interrupt */
1268 ixgbe_disable_intr(hw);
1270 /* reset mappings for queue statistics hw counters*/
1271 ixgbe_reset_qstat_mappings(hw);
1273 /* Allocate memory for storing MAC addresses */
1274 eth_dev->data->mac_addrs = rte_zmalloc("ixgbe", ETHER_ADDR_LEN *
1275 hw->mac.num_rar_entries, 0);
1276 if (eth_dev->data->mac_addrs == NULL) {
1278 "Failed to allocate %u bytes needed to store "
1280 ETHER_ADDR_LEN * hw->mac.num_rar_entries);
1283 /* Copy the permanent MAC address */
1284 ether_addr_copy((struct ether_addr *) hw->mac.perm_addr,
1285 ð_dev->data->mac_addrs[0]);
1287 /* Allocate memory for storing hash filter MAC addresses */
1288 eth_dev->data->hash_mac_addrs = rte_zmalloc("ixgbe", ETHER_ADDR_LEN *
1289 IXGBE_VMDQ_NUM_UC_MAC, 0);
1290 if (eth_dev->data->hash_mac_addrs == NULL) {
1292 "Failed to allocate %d bytes needed to store MAC addresses",
1293 ETHER_ADDR_LEN * IXGBE_VMDQ_NUM_UC_MAC);
1297 /* initialize the vfta */
1298 memset(shadow_vfta, 0, sizeof(*shadow_vfta));
1300 /* initialize the hw strip bitmap*/
1301 memset(hwstrip, 0, sizeof(*hwstrip));
1303 /* initialize PF if max_vfs not zero */
1304 ixgbe_pf_host_init(eth_dev);
1306 ctrl_ext = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
1307 /* let hardware know driver is loaded */
1308 ctrl_ext |= IXGBE_CTRL_EXT_DRV_LOAD;
1309 /* Set PF Reset Done bit so PF/VF Mail Ops can work */
1310 ctrl_ext |= IXGBE_CTRL_EXT_PFRSTD;
1311 IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl_ext);
1312 IXGBE_WRITE_FLUSH(hw);
1314 if (ixgbe_is_sfp(hw) && hw->phy.sfp_type != ixgbe_sfp_type_not_present)
1315 PMD_INIT_LOG(DEBUG, "MAC: %d, PHY: %d, SFP+: %d",
1316 (int) hw->mac.type, (int) hw->phy.type,
1317 (int) hw->phy.sfp_type);
1319 PMD_INIT_LOG(DEBUG, "MAC: %d, PHY: %d",
1320 (int) hw->mac.type, (int) hw->phy.type);
1322 PMD_INIT_LOG(DEBUG, "port %d vendorID=0x%x deviceID=0x%x",
1323 eth_dev->data->port_id, pci_dev->id.vendor_id,
1324 pci_dev->id.device_id);
1326 rte_intr_callback_register(intr_handle,
1327 ixgbe_dev_interrupt_handler, eth_dev);
1329 /* enable uio/vfio intr/eventfd mapping */
1330 rte_intr_enable(intr_handle);
1332 /* enable support intr */
1333 ixgbe_enable_intr(eth_dev);
1335 /* initialize 5tuple filter list */
1336 TAILQ_INIT(&filter_info->fivetuple_list);
1337 memset(filter_info->fivetuple_mask, 0,
1338 sizeof(uint32_t) * IXGBE_5TUPLE_ARRAY_SIZE);
1344 eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev)
1346 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(eth_dev);
1347 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
1348 struct ixgbe_hw *hw;
1350 PMD_INIT_FUNC_TRACE();
1352 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
1355 hw = IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
1357 if (hw->adapter_stopped == 0)
1358 ixgbe_dev_close(eth_dev);
1360 eth_dev->dev_ops = NULL;
1361 eth_dev->rx_pkt_burst = NULL;
1362 eth_dev->tx_pkt_burst = NULL;
1364 /* Unlock any pending hardware semaphore */
1365 ixgbe_swfw_lock_reset(hw);
1367 /* disable uio intr before callback unregister */
1368 rte_intr_disable(intr_handle);
1369 rte_intr_callback_unregister(intr_handle,
1370 ixgbe_dev_interrupt_handler, eth_dev);
1372 /* uninitialize PF if max_vfs not zero */
1373 ixgbe_pf_host_uninit(eth_dev);
1375 rte_free(eth_dev->data->mac_addrs);
1376 eth_dev->data->mac_addrs = NULL;
1378 rte_free(eth_dev->data->hash_mac_addrs);
1379 eth_dev->data->hash_mac_addrs = NULL;
1385 * Negotiate mailbox API version with the PF.
1386 * After reset API version is always set to the basic one (ixgbe_mbox_api_10).
1387 * Then we try to negotiate starting with the most recent one.
1388 * If all negotiation attempts fail, then we will proceed with
1389 * the default one (ixgbe_mbox_api_10).
1392 ixgbevf_negotiate_api(struct ixgbe_hw *hw)
1396 /* start with highest supported, proceed down */
1397 static const enum ixgbe_pfvf_api_rev sup_ver[] = {
1404 i != RTE_DIM(sup_ver) &&
1405 ixgbevf_negotiate_api_version(hw, sup_ver[i]) != 0;
1411 generate_random_mac_addr(struct ether_addr *mac_addr)
1415 /* Set Organizationally Unique Identifier (OUI) prefix. */
1416 mac_addr->addr_bytes[0] = 0x00;
1417 mac_addr->addr_bytes[1] = 0x09;
1418 mac_addr->addr_bytes[2] = 0xC0;
1419 /* Force indication of locally assigned MAC address. */
1420 mac_addr->addr_bytes[0] |= ETHER_LOCAL_ADMIN_ADDR;
1421 /* Generate the last 3 bytes of the MAC address with a random number. */
1422 random = rte_rand();
1423 memcpy(&mac_addr->addr_bytes[3], &random, 3);
1427 * Virtual Function device init
1430 eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev)
1434 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(eth_dev);
1435 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
1436 struct ixgbe_hw *hw =
1437 IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
1438 struct ixgbe_vfta *shadow_vfta =
1439 IXGBE_DEV_PRIVATE_TO_VFTA(eth_dev->data->dev_private);
1440 struct ixgbe_hwstrip *hwstrip =
1441 IXGBE_DEV_PRIVATE_TO_HWSTRIP_BITMAP(eth_dev->data->dev_private);
1442 struct ether_addr *perm_addr = (struct ether_addr *) hw->mac.perm_addr;
1444 PMD_INIT_FUNC_TRACE();
1446 eth_dev->dev_ops = &ixgbevf_eth_dev_ops;
1447 eth_dev->rx_pkt_burst = &ixgbe_recv_pkts;
1448 eth_dev->tx_pkt_burst = &ixgbe_xmit_pkts;
1450 /* for secondary processes, we don't initialise any further as primary
1451 * has already done this work. Only check we don't need a different
1454 if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
1455 struct ixgbe_tx_queue *txq;
1456 /* TX queue function in primary, set by last queue initialized
1457 * Tx queue may not initialized by primary process
1459 if (eth_dev->data->tx_queues) {
1460 txq = eth_dev->data->tx_queues[eth_dev->data->nb_tx_queues - 1];
1461 ixgbe_set_tx_function(eth_dev, txq);
1463 /* Use default TX function if we get here */
1464 PMD_INIT_LOG(NOTICE,
1465 "No TX queues configured yet. Using default TX function.");
1468 ixgbe_set_rx_function(eth_dev);
1473 rte_eth_copy_pci_info(eth_dev, pci_dev);
1474 eth_dev->data->dev_flags = RTE_ETH_DEV_DETACHABLE;
1476 hw->device_id = pci_dev->id.device_id;
1477 hw->vendor_id = pci_dev->id.vendor_id;
1478 hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
1480 /* initialize the vfta */
1481 memset(shadow_vfta, 0, sizeof(*shadow_vfta));
1483 /* initialize the hw strip bitmap*/
1484 memset(hwstrip, 0, sizeof(*hwstrip));
1486 /* Initialize the shared code (base driver) */
1487 diag = ixgbe_init_shared_code(hw);
1488 if (diag != IXGBE_SUCCESS) {
1489 PMD_INIT_LOG(ERR, "Shared code init failed for ixgbevf: %d", diag);
1493 /* init_mailbox_params */
1494 hw->mbx.ops.init_params(hw);
1496 /* Reset the hw statistics */
1497 ixgbevf_dev_stats_reset(eth_dev);
1499 /* Disable the interrupts for VF */
1500 ixgbevf_intr_disable(hw);
1502 hw->mac.num_rar_entries = 128; /* The MAX of the underlying PF */
1503 diag = hw->mac.ops.reset_hw(hw);
1506 * The VF reset operation returns the IXGBE_ERR_INVALID_MAC_ADDR when
1507 * the underlying PF driver has not assigned a MAC address to the VF.
1508 * In this case, assign a random MAC address.
1510 if ((diag != IXGBE_SUCCESS) && (diag != IXGBE_ERR_INVALID_MAC_ADDR)) {
1511 PMD_INIT_LOG(ERR, "VF Initialization Failure: %d", diag);
1515 /* negotiate mailbox API version to use with the PF. */
1516 ixgbevf_negotiate_api(hw);
1518 /* Get Rx/Tx queue count via mailbox, which is ready after reset_hw */
1519 ixgbevf_get_queues(hw, &tcs, &tc);
1521 /* Allocate memory for storing MAC addresses */
1522 eth_dev->data->mac_addrs = rte_zmalloc("ixgbevf", ETHER_ADDR_LEN *
1523 hw->mac.num_rar_entries, 0);
1524 if (eth_dev->data->mac_addrs == NULL) {
1526 "Failed to allocate %u bytes needed to store "
1528 ETHER_ADDR_LEN * hw->mac.num_rar_entries);
1532 /* Generate a random MAC address, if none was assigned by PF. */
1533 if (is_zero_ether_addr(perm_addr)) {
1534 generate_random_mac_addr(perm_addr);
1535 diag = ixgbe_set_rar_vf(hw, 1, perm_addr->addr_bytes, 0, 1);
1537 rte_free(eth_dev->data->mac_addrs);
1538 eth_dev->data->mac_addrs = NULL;
1541 PMD_INIT_LOG(INFO, "\tVF MAC address not assigned by Host PF");
1542 PMD_INIT_LOG(INFO, "\tAssign randomly generated MAC address "
1543 "%02x:%02x:%02x:%02x:%02x:%02x",
1544 perm_addr->addr_bytes[0],
1545 perm_addr->addr_bytes[1],
1546 perm_addr->addr_bytes[2],
1547 perm_addr->addr_bytes[3],
1548 perm_addr->addr_bytes[4],
1549 perm_addr->addr_bytes[5]);
1552 /* Copy the permanent MAC address */
1553 ether_addr_copy(perm_addr, ð_dev->data->mac_addrs[0]);
1555 /* reset the hardware with the new settings */
1556 diag = hw->mac.ops.start_hw(hw);
1562 PMD_INIT_LOG(ERR, "VF Initialization Failure: %d", diag);
1566 rte_intr_callback_register(intr_handle,
1567 ixgbevf_dev_interrupt_handler, eth_dev);
1568 rte_intr_enable(intr_handle);
1569 ixgbevf_intr_enable(hw);
1571 PMD_INIT_LOG(DEBUG, "port %d vendorID=0x%x deviceID=0x%x mac.type=%s",
1572 eth_dev->data->port_id, pci_dev->id.vendor_id,
1573 pci_dev->id.device_id, "ixgbe_mac_82599_vf");
1578 /* Virtual Function device uninit */
1581 eth_ixgbevf_dev_uninit(struct rte_eth_dev *eth_dev)
1583 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(eth_dev);
1584 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
1585 struct ixgbe_hw *hw;
1587 PMD_INIT_FUNC_TRACE();
1589 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
1592 hw = IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
1594 if (hw->adapter_stopped == 0)
1595 ixgbevf_dev_close(eth_dev);
1597 eth_dev->dev_ops = NULL;
1598 eth_dev->rx_pkt_burst = NULL;
1599 eth_dev->tx_pkt_burst = NULL;
1601 /* Disable the interrupts for VF */
1602 ixgbevf_intr_disable(hw);
1604 rte_free(eth_dev->data->mac_addrs);
1605 eth_dev->data->mac_addrs = NULL;
1607 rte_intr_disable(intr_handle);
1608 rte_intr_callback_unregister(intr_handle,
1609 ixgbevf_dev_interrupt_handler, eth_dev);
1614 static struct eth_driver rte_ixgbe_pmd = {
1616 .id_table = pci_id_ixgbe_map,
1617 .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
1618 .probe = rte_eth_dev_pci_probe,
1619 .remove = rte_eth_dev_pci_remove,
1621 .eth_dev_init = eth_ixgbe_dev_init,
1622 .eth_dev_uninit = eth_ixgbe_dev_uninit,
1623 .dev_private_size = sizeof(struct ixgbe_adapter),
1627 * virtual function driver struct
1629 static struct eth_driver rte_ixgbevf_pmd = {
1631 .id_table = pci_id_ixgbevf_map,
1632 .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
1633 .probe = rte_eth_dev_pci_probe,
1634 .remove = rte_eth_dev_pci_remove,
1636 .eth_dev_init = eth_ixgbevf_dev_init,
1637 .eth_dev_uninit = eth_ixgbevf_dev_uninit,
1638 .dev_private_size = sizeof(struct ixgbe_adapter),
1642 ixgbe_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
1644 struct ixgbe_hw *hw =
1645 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1646 struct ixgbe_vfta *shadow_vfta =
1647 IXGBE_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
1652 vid_idx = (uint32_t) ((vlan_id >> 5) & 0x7F);
1653 vid_bit = (uint32_t) (1 << (vlan_id & 0x1F));
1654 vfta = IXGBE_READ_REG(hw, IXGBE_VFTA(vid_idx));
1659 IXGBE_WRITE_REG(hw, IXGBE_VFTA(vid_idx), vfta);
1661 /* update local VFTA copy */
1662 shadow_vfta->vfta[vid_idx] = vfta;
1668 ixgbe_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue, int on)
1671 ixgbe_vlan_hw_strip_enable(dev, queue);
1673 ixgbe_vlan_hw_strip_disable(dev, queue);
1677 ixgbe_vlan_tpid_set(struct rte_eth_dev *dev,
1678 enum rte_vlan_type vlan_type,
1681 struct ixgbe_hw *hw =
1682 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1687 qinq = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
1688 qinq &= IXGBE_DMATXCTL_GDV;
1690 switch (vlan_type) {
1691 case ETH_VLAN_TYPE_INNER:
1693 reg = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
1694 reg = (reg & (~IXGBE_VLNCTRL_VET)) | (uint32_t)tpid;
1695 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, reg);
1696 reg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
1697 reg = (reg & (~IXGBE_DMATXCTL_VT_MASK))
1698 | ((uint32_t)tpid << IXGBE_DMATXCTL_VT_SHIFT);
1699 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);
1702 PMD_DRV_LOG(ERR, "Inner type is not supported"
1706 case ETH_VLAN_TYPE_OUTER:
1708 /* Only the high 16-bits is valid */
1709 IXGBE_WRITE_REG(hw, IXGBE_EXVET, (uint32_t)tpid <<
1710 IXGBE_EXVET_VET_EXT_SHIFT);
1712 reg = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
1713 reg = (reg & (~IXGBE_VLNCTRL_VET)) | (uint32_t)tpid;
1714 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, reg);
1715 reg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
1716 reg = (reg & (~IXGBE_DMATXCTL_VT_MASK))
1717 | ((uint32_t)tpid << IXGBE_DMATXCTL_VT_SHIFT);
1718 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);
1724 PMD_DRV_LOG(ERR, "Unsupported VLAN type %d", vlan_type);
1732 ixgbe_vlan_hw_filter_disable(struct rte_eth_dev *dev)
1734 struct ixgbe_hw *hw =
1735 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1738 PMD_INIT_FUNC_TRACE();
1740 /* Filter Table Disable */
1741 vlnctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
1742 vlnctrl &= ~IXGBE_VLNCTRL_VFE;
1744 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlnctrl);
1748 ixgbe_vlan_hw_filter_enable(struct rte_eth_dev *dev)
1750 struct ixgbe_hw *hw =
1751 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1752 struct ixgbe_vfta *shadow_vfta =
1753 IXGBE_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
1757 PMD_INIT_FUNC_TRACE();
1759 /* Filter Table Enable */
1760 vlnctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
1761 vlnctrl &= ~IXGBE_VLNCTRL_CFIEN;
1762 vlnctrl |= IXGBE_VLNCTRL_VFE;
1764 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlnctrl);
1766 /* write whatever is in local vfta copy */
1767 for (i = 0; i < IXGBE_VFTA_SIZE; i++)
1768 IXGBE_WRITE_REG(hw, IXGBE_VFTA(i), shadow_vfta->vfta[i]);
1772 ixgbe_vlan_hw_strip_bitmap_set(struct rte_eth_dev *dev, uint16_t queue, bool on)
1774 struct ixgbe_hwstrip *hwstrip =
1775 IXGBE_DEV_PRIVATE_TO_HWSTRIP_BITMAP(dev->data->dev_private);
1776 struct ixgbe_rx_queue *rxq;
1778 if (queue >= IXGBE_MAX_RX_QUEUE_NUM)
1782 IXGBE_SET_HWSTRIP(hwstrip, queue);
1784 IXGBE_CLEAR_HWSTRIP(hwstrip, queue);
1786 if (queue >= dev->data->nb_rx_queues)
1789 rxq = dev->data->rx_queues[queue];
1792 rxq->vlan_flags = PKT_RX_VLAN_PKT | PKT_RX_VLAN_STRIPPED;
1794 rxq->vlan_flags = PKT_RX_VLAN_PKT;
1798 ixgbe_vlan_hw_strip_disable(struct rte_eth_dev *dev, uint16_t queue)
1800 struct ixgbe_hw *hw =
1801 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1804 PMD_INIT_FUNC_TRACE();
1806 if (hw->mac.type == ixgbe_mac_82598EB) {
1807 /* No queue level support */
1808 PMD_INIT_LOG(NOTICE, "82598EB not support queue level hw strip");
1812 /* Other 10G NIC, the VLAN strip can be setup per queue in RXDCTL */
1813 ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(queue));
1814 ctrl &= ~IXGBE_RXDCTL_VME;
1815 IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(queue), ctrl);
1817 /* record those setting for HW strip per queue */
1818 ixgbe_vlan_hw_strip_bitmap_set(dev, queue, 0);
1822 ixgbe_vlan_hw_strip_enable(struct rte_eth_dev *dev, uint16_t queue)
1824 struct ixgbe_hw *hw =
1825 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1828 PMD_INIT_FUNC_TRACE();
1830 if (hw->mac.type == ixgbe_mac_82598EB) {
1831 /* No queue level supported */
1832 PMD_INIT_LOG(NOTICE, "82598EB not support queue level hw strip");
1836 /* Other 10G NIC, the VLAN strip can be setup per queue in RXDCTL */
1837 ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(queue));
1838 ctrl |= IXGBE_RXDCTL_VME;
1839 IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(queue), ctrl);
1841 /* record those setting for HW strip per queue */
1842 ixgbe_vlan_hw_strip_bitmap_set(dev, queue, 1);
1846 ixgbe_vlan_hw_strip_disable_all(struct rte_eth_dev *dev)
1848 struct ixgbe_hw *hw =
1849 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1852 struct ixgbe_rx_queue *rxq;
1854 PMD_INIT_FUNC_TRACE();
1856 if (hw->mac.type == ixgbe_mac_82598EB) {
1857 ctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
1858 ctrl &= ~IXGBE_VLNCTRL_VME;
1859 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, ctrl);
1861 /* Other 10G NIC, the VLAN strip can be setup per queue in RXDCTL */
1862 for (i = 0; i < dev->data->nb_rx_queues; i++) {
1863 rxq = dev->data->rx_queues[i];
1864 ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(rxq->reg_idx));
1865 ctrl &= ~IXGBE_RXDCTL_VME;
1866 IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(rxq->reg_idx), ctrl);
1868 /* record those setting for HW strip per queue */
1869 ixgbe_vlan_hw_strip_bitmap_set(dev, i, 0);
1875 ixgbe_vlan_hw_strip_enable_all(struct rte_eth_dev *dev)
1877 struct ixgbe_hw *hw =
1878 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1881 struct ixgbe_rx_queue *rxq;
1883 PMD_INIT_FUNC_TRACE();
1885 if (hw->mac.type == ixgbe_mac_82598EB) {
1886 ctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
1887 ctrl |= IXGBE_VLNCTRL_VME;
1888 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, ctrl);
1890 /* Other 10G NIC, the VLAN strip can be setup per queue in RXDCTL */
1891 for (i = 0; i < dev->data->nb_rx_queues; i++) {
1892 rxq = dev->data->rx_queues[i];
1893 ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(rxq->reg_idx));
1894 ctrl |= IXGBE_RXDCTL_VME;
1895 IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(rxq->reg_idx), ctrl);
1897 /* record those setting for HW strip per queue */
1898 ixgbe_vlan_hw_strip_bitmap_set(dev, i, 1);
1904 ixgbe_vlan_hw_extend_disable(struct rte_eth_dev *dev)
1906 struct ixgbe_hw *hw =
1907 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1910 PMD_INIT_FUNC_TRACE();
1912 /* DMATXCTRL: Geric Double VLAN Disable */
1913 ctrl = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
1914 ctrl &= ~IXGBE_DMATXCTL_GDV;
1915 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, ctrl);
1917 /* CTRL_EXT: Global Double VLAN Disable */
1918 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
1919 ctrl &= ~IXGBE_EXTENDED_VLAN;
1920 IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl);
1925 ixgbe_vlan_hw_extend_enable(struct rte_eth_dev *dev)
1927 struct ixgbe_hw *hw =
1928 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1931 PMD_INIT_FUNC_TRACE();
1933 /* DMATXCTRL: Geric Double VLAN Enable */
1934 ctrl = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
1935 ctrl |= IXGBE_DMATXCTL_GDV;
1936 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, ctrl);
1938 /* CTRL_EXT: Global Double VLAN Enable */
1939 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
1940 ctrl |= IXGBE_EXTENDED_VLAN;
1941 IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl);
1943 /* Clear pooling mode of PFVTCTL. It's required by X550. */
1944 if (hw->mac.type == ixgbe_mac_X550 ||
1945 hw->mac.type == ixgbe_mac_X550EM_x ||
1946 hw->mac.type == ixgbe_mac_X550EM_a) {
1947 ctrl = IXGBE_READ_REG(hw, IXGBE_VT_CTL);
1948 ctrl &= ~IXGBE_VT_CTL_POOLING_MODE_MASK;
1949 IXGBE_WRITE_REG(hw, IXGBE_VT_CTL, ctrl);
1953 * VET EXT field in the EXVET register = 0x8100 by default
1954 * So no need to change. Same to VT field of DMATXCTL register
1959 ixgbe_vlan_offload_set(struct rte_eth_dev *dev, int mask)
1961 if (mask & ETH_VLAN_STRIP_MASK) {
1962 if (dev->data->dev_conf.rxmode.hw_vlan_strip)
1963 ixgbe_vlan_hw_strip_enable_all(dev);
1965 ixgbe_vlan_hw_strip_disable_all(dev);
1968 if (mask & ETH_VLAN_FILTER_MASK) {
1969 if (dev->data->dev_conf.rxmode.hw_vlan_filter)
1970 ixgbe_vlan_hw_filter_enable(dev);
1972 ixgbe_vlan_hw_filter_disable(dev);
1975 if (mask & ETH_VLAN_EXTEND_MASK) {
1976 if (dev->data->dev_conf.rxmode.hw_vlan_extend)
1977 ixgbe_vlan_hw_extend_enable(dev);
1979 ixgbe_vlan_hw_extend_disable(dev);
1984 ixgbe_vmdq_vlan_hw_filter_enable(struct rte_eth_dev *dev)
1986 struct ixgbe_hw *hw =
1987 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1988 /* VLNCTRL: enable vlan filtering and allow all vlan tags through */
1989 uint32_t vlanctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
1991 vlanctrl |= IXGBE_VLNCTRL_VFE; /* enable vlan filters */
1992 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlanctrl);
1996 ixgbe_check_vf_rss_rxq_num(struct rte_eth_dev *dev, uint16_t nb_rx_q)
1998 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
2003 RTE_ETH_DEV_SRIOV(dev).active = ETH_64_POOLS;
2006 RTE_ETH_DEV_SRIOV(dev).active = ETH_32_POOLS;
2012 RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool = nb_rx_q;
2013 RTE_ETH_DEV_SRIOV(dev).def_pool_q_idx = pci_dev->max_vfs * nb_rx_q;
2019 ixgbe_check_mq_mode(struct rte_eth_dev *dev)
2021 struct rte_eth_conf *dev_conf = &dev->data->dev_conf;
2022 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2023 uint16_t nb_rx_q = dev->data->nb_rx_queues;
2024 uint16_t nb_tx_q = dev->data->nb_tx_queues;
2026 if (RTE_ETH_DEV_SRIOV(dev).active != 0) {
2027 /* check multi-queue mode */
2028 switch (dev_conf->rxmode.mq_mode) {
2029 case ETH_MQ_RX_VMDQ_DCB:
2030 PMD_INIT_LOG(INFO, "ETH_MQ_RX_VMDQ_DCB mode supported in SRIOV");
2032 case ETH_MQ_RX_VMDQ_DCB_RSS:
2033 /* DCB/RSS VMDQ in SRIOV mode, not implement yet */
2034 PMD_INIT_LOG(ERR, "SRIOV active,"
2035 " unsupported mq_mode rx %d.",
2036 dev_conf->rxmode.mq_mode);
2039 case ETH_MQ_RX_VMDQ_RSS:
2040 dev->data->dev_conf.rxmode.mq_mode = ETH_MQ_RX_VMDQ_RSS;
2041 if (nb_rx_q <= RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool)
2042 if (ixgbe_check_vf_rss_rxq_num(dev, nb_rx_q)) {
2043 PMD_INIT_LOG(ERR, "SRIOV is active,"
2044 " invalid queue number"
2045 " for VMDQ RSS, allowed"
2046 " value are 1, 2 or 4.");
2050 case ETH_MQ_RX_VMDQ_ONLY:
2051 case ETH_MQ_RX_NONE:
2052 /* if nothing mq mode configure, use default scheme */
2053 dev->data->dev_conf.rxmode.mq_mode = ETH_MQ_RX_VMDQ_ONLY;
2054 if (RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool > 1)
2055 RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool = 1;
2057 default: /* ETH_MQ_RX_DCB, ETH_MQ_RX_DCB_RSS or ETH_MQ_TX_DCB*/
2058 /* SRIOV only works in VMDq enable mode */
2059 PMD_INIT_LOG(ERR, "SRIOV is active,"
2060 " wrong mq_mode rx %d.",
2061 dev_conf->rxmode.mq_mode);
2065 switch (dev_conf->txmode.mq_mode) {
2066 case ETH_MQ_TX_VMDQ_DCB:
2067 PMD_INIT_LOG(INFO, "ETH_MQ_TX_VMDQ_DCB mode supported in SRIOV");
2068 dev->data->dev_conf.txmode.mq_mode = ETH_MQ_TX_VMDQ_DCB;
2070 default: /* ETH_MQ_TX_VMDQ_ONLY or ETH_MQ_TX_NONE */
2071 dev->data->dev_conf.txmode.mq_mode = ETH_MQ_TX_VMDQ_ONLY;
2075 /* check valid queue number */
2076 if ((nb_rx_q > RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool) ||
2077 (nb_tx_q > RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool)) {
2078 PMD_INIT_LOG(ERR, "SRIOV is active,"
2079 " nb_rx_q=%d nb_tx_q=%d queue number"
2080 " must be less than or equal to %d.",
2082 RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool);
2086 if (dev_conf->rxmode.mq_mode == ETH_MQ_RX_VMDQ_DCB_RSS) {
2087 PMD_INIT_LOG(ERR, "VMDQ+DCB+RSS mq_mode is"
2091 /* check configuration for vmdb+dcb mode */
2092 if (dev_conf->rxmode.mq_mode == ETH_MQ_RX_VMDQ_DCB) {
2093 const struct rte_eth_vmdq_dcb_conf *conf;
2095 if (nb_rx_q != IXGBE_VMDQ_DCB_NB_QUEUES) {
2096 PMD_INIT_LOG(ERR, "VMDQ+DCB, nb_rx_q != %d.",
2097 IXGBE_VMDQ_DCB_NB_QUEUES);
2100 conf = &dev_conf->rx_adv_conf.vmdq_dcb_conf;
2101 if (!(conf->nb_queue_pools == ETH_16_POOLS ||
2102 conf->nb_queue_pools == ETH_32_POOLS)) {
2103 PMD_INIT_LOG(ERR, "VMDQ+DCB selected,"
2104 " nb_queue_pools must be %d or %d.",
2105 ETH_16_POOLS, ETH_32_POOLS);
2109 if (dev_conf->txmode.mq_mode == ETH_MQ_TX_VMDQ_DCB) {
2110 const struct rte_eth_vmdq_dcb_tx_conf *conf;
2112 if (nb_tx_q != IXGBE_VMDQ_DCB_NB_QUEUES) {
2113 PMD_INIT_LOG(ERR, "VMDQ+DCB, nb_tx_q != %d",
2114 IXGBE_VMDQ_DCB_NB_QUEUES);
2117 conf = &dev_conf->tx_adv_conf.vmdq_dcb_tx_conf;
2118 if (!(conf->nb_queue_pools == ETH_16_POOLS ||
2119 conf->nb_queue_pools == ETH_32_POOLS)) {
2120 PMD_INIT_LOG(ERR, "VMDQ+DCB selected,"
2121 " nb_queue_pools != %d and"
2122 " nb_queue_pools != %d.",
2123 ETH_16_POOLS, ETH_32_POOLS);
2128 /* For DCB mode check our configuration before we go further */
2129 if (dev_conf->rxmode.mq_mode == ETH_MQ_RX_DCB) {
2130 const struct rte_eth_dcb_rx_conf *conf;
2132 if (nb_rx_q != IXGBE_DCB_NB_QUEUES) {
2133 PMD_INIT_LOG(ERR, "DCB selected, nb_rx_q != %d.",
2134 IXGBE_DCB_NB_QUEUES);
2137 conf = &dev_conf->rx_adv_conf.dcb_rx_conf;
2138 if (!(conf->nb_tcs == ETH_4_TCS ||
2139 conf->nb_tcs == ETH_8_TCS)) {
2140 PMD_INIT_LOG(ERR, "DCB selected, nb_tcs != %d"
2141 " and nb_tcs != %d.",
2142 ETH_4_TCS, ETH_8_TCS);
2147 if (dev_conf->txmode.mq_mode == ETH_MQ_TX_DCB) {
2148 const struct rte_eth_dcb_tx_conf *conf;
2150 if (nb_tx_q != IXGBE_DCB_NB_QUEUES) {
2151 PMD_INIT_LOG(ERR, "DCB, nb_tx_q != %d.",
2152 IXGBE_DCB_NB_QUEUES);
2155 conf = &dev_conf->tx_adv_conf.dcb_tx_conf;
2156 if (!(conf->nb_tcs == ETH_4_TCS ||
2157 conf->nb_tcs == ETH_8_TCS)) {
2158 PMD_INIT_LOG(ERR, "DCB selected, nb_tcs != %d"
2159 " and nb_tcs != %d.",
2160 ETH_4_TCS, ETH_8_TCS);
2166 * When DCB/VT is off, maximum number of queues changes,
2167 * except for 82598EB, which remains constant.
2169 if (dev_conf->txmode.mq_mode == ETH_MQ_TX_NONE &&
2170 hw->mac.type != ixgbe_mac_82598EB) {
2171 if (nb_tx_q > IXGBE_NONE_MODE_TX_NB_QUEUES) {
2173 "Neither VT nor DCB are enabled, "
2175 IXGBE_NONE_MODE_TX_NB_QUEUES);
2184 ixgbe_dev_configure(struct rte_eth_dev *dev)
2186 struct ixgbe_interrupt *intr =
2187 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
2188 struct ixgbe_adapter *adapter =
2189 (struct ixgbe_adapter *)dev->data->dev_private;
2192 PMD_INIT_FUNC_TRACE();
2193 /* multipe queue mode checking */
2194 ret = ixgbe_check_mq_mode(dev);
2196 PMD_DRV_LOG(ERR, "ixgbe_check_mq_mode fails with %d.",
2201 /* set flag to update link status after init */
2202 intr->flags |= IXGBE_FLAG_NEED_LINK_UPDATE;
2205 * Initialize to TRUE. If any of Rx queues doesn't meet the bulk
2206 * allocation or vector Rx preconditions we will reset it.
2208 adapter->rx_bulk_alloc_allowed = true;
2209 adapter->rx_vec_allowed = true;
2215 ixgbe_dev_phy_intr_setup(struct rte_eth_dev *dev)
2217 struct ixgbe_hw *hw =
2218 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2219 struct ixgbe_interrupt *intr =
2220 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
2223 /* only set up it on X550EM_X */
2224 if (hw->mac.type == ixgbe_mac_X550EM_x) {
2225 gpie = IXGBE_READ_REG(hw, IXGBE_GPIE);
2226 gpie |= IXGBE_SDP0_GPIEN_X550EM_x;
2227 IXGBE_WRITE_REG(hw, IXGBE_GPIE, gpie);
2228 if (hw->phy.type == ixgbe_phy_x550em_ext_t)
2229 intr->mask |= IXGBE_EICR_GPI_SDP0_X550EM_x;
2234 * Configure device link speed and setup link.
2235 * It returns 0 on success.
2238 ixgbe_dev_start(struct rte_eth_dev *dev)
2240 struct ixgbe_hw *hw =
2241 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2242 struct ixgbe_vf_info *vfinfo =
2243 *IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private);
2244 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
2245 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
2246 uint32_t intr_vector = 0;
2247 int err, link_up = 0, negotiate = 0;
2252 uint32_t *link_speeds;
2254 PMD_INIT_FUNC_TRACE();
2256 /* IXGBE devices don't support:
2257 * - half duplex (checked afterwards for valid speeds)
2258 * - fixed speed: TODO implement
2260 if (dev->data->dev_conf.link_speeds & ETH_LINK_SPEED_FIXED) {
2261 PMD_INIT_LOG(ERR, "Invalid link_speeds for port %hhu; fix speed not supported",
2262 dev->data->port_id);
2266 /* disable uio/vfio intr/eventfd mapping */
2267 rte_intr_disable(intr_handle);
2270 hw->adapter_stopped = 0;
2271 ixgbe_stop_adapter(hw);
2273 /* reinitialize adapter
2274 * this calls reset and start
2276 status = ixgbe_pf_reset_hw(hw);
2279 hw->mac.ops.start_hw(hw);
2280 hw->mac.get_link_status = true;
2282 /* configure PF module if SRIOV enabled */
2283 ixgbe_pf_host_configure(dev);
2285 ixgbe_dev_phy_intr_setup(dev);
2287 /* check and configure queue intr-vector mapping */
2288 if ((rte_intr_cap_multiple(intr_handle) ||
2289 !RTE_ETH_DEV_SRIOV(dev).active) &&
2290 dev->data->dev_conf.intr_conf.rxq != 0) {
2291 intr_vector = dev->data->nb_rx_queues;
2292 if (intr_vector > IXGBE_MAX_INTR_QUEUE_NUM) {
2293 PMD_INIT_LOG(ERR, "At most %d intr queues supported",
2294 IXGBE_MAX_INTR_QUEUE_NUM);
2297 if (rte_intr_efd_enable(intr_handle, intr_vector))
2301 if (rte_intr_dp_is_en(intr_handle) && !intr_handle->intr_vec) {
2302 intr_handle->intr_vec =
2303 rte_zmalloc("intr_vec",
2304 dev->data->nb_rx_queues * sizeof(int), 0);
2305 if (intr_handle->intr_vec == NULL) {
2306 PMD_INIT_LOG(ERR, "Failed to allocate %d rx_queues"
2307 " intr_vec\n", dev->data->nb_rx_queues);
2312 /* confiugre msix for sleep until rx interrupt */
2313 ixgbe_configure_msix(dev);
2315 /* initialize transmission unit */
2316 ixgbe_dev_tx_init(dev);
2318 /* This can fail when allocating mbufs for descriptor rings */
2319 err = ixgbe_dev_rx_init(dev);
2321 PMD_INIT_LOG(ERR, "Unable to initialize RX hardware");
2325 mask = ETH_VLAN_STRIP_MASK | ETH_VLAN_FILTER_MASK |
2326 ETH_VLAN_EXTEND_MASK;
2327 ixgbe_vlan_offload_set(dev, mask);
2329 if (dev->data->dev_conf.rxmode.mq_mode == ETH_MQ_RX_VMDQ_ONLY) {
2330 /* Enable vlan filtering for VMDq */
2331 ixgbe_vmdq_vlan_hw_filter_enable(dev);
2334 /* Configure DCB hw */
2335 ixgbe_configure_dcb(dev);
2337 if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_NONE) {
2338 err = ixgbe_fdir_configure(dev);
2343 /* Restore vf rate limit */
2344 if (vfinfo != NULL) {
2345 for (vf = 0; vf < pci_dev->max_vfs; vf++)
2346 for (idx = 0; idx < IXGBE_MAX_QUEUE_NUM_PER_VF; idx++)
2347 if (vfinfo[vf].tx_rate[idx] != 0)
2348 ixgbe_set_vf_rate_limit(dev, vf,
2349 vfinfo[vf].tx_rate[idx],
2353 ixgbe_restore_statistics_mapping(dev);
2355 err = ixgbe_dev_rxtx_start(dev);
2357 PMD_INIT_LOG(ERR, "Unable to start rxtx queues");
2361 /* Skip link setup if loopback mode is enabled for 82599. */
2362 if (hw->mac.type == ixgbe_mac_82599EB &&
2363 dev->data->dev_conf.lpbk_mode == IXGBE_LPBK_82599_TX_RX)
2364 goto skip_link_setup;
2366 if (ixgbe_is_sfp(hw) && hw->phy.multispeed_fiber) {
2367 err = hw->mac.ops.setup_sfp(hw);
2372 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper) {
2373 /* Turn on the copper */
2374 ixgbe_set_phy_power(hw, true);
2376 /* Turn on the laser */
2377 ixgbe_enable_tx_laser(hw);
2380 err = ixgbe_check_link(hw, &speed, &link_up, 0);
2383 dev->data->dev_link.link_status = link_up;
2385 err = ixgbe_get_link_capabilities(hw, &speed, &negotiate);
2389 link_speeds = &dev->data->dev_conf.link_speeds;
2390 if (*link_speeds & ~(ETH_LINK_SPEED_100M | ETH_LINK_SPEED_1G |
2391 ETH_LINK_SPEED_10G)) {
2392 PMD_INIT_LOG(ERR, "Invalid link setting");
2397 if (*link_speeds == ETH_LINK_SPEED_AUTONEG) {
2398 speed = (hw->mac.type != ixgbe_mac_82598EB) ?
2399 IXGBE_LINK_SPEED_82599_AUTONEG :
2400 IXGBE_LINK_SPEED_82598_AUTONEG;
2402 if (*link_speeds & ETH_LINK_SPEED_10G)
2403 speed |= IXGBE_LINK_SPEED_10GB_FULL;
2404 if (*link_speeds & ETH_LINK_SPEED_1G)
2405 speed |= IXGBE_LINK_SPEED_1GB_FULL;
2406 if (*link_speeds & ETH_LINK_SPEED_100M)
2407 speed |= IXGBE_LINK_SPEED_100_FULL;
2410 err = ixgbe_setup_link(hw, speed, link_up);
2416 if (rte_intr_allow_others(intr_handle)) {
2417 /* check if lsc interrupt is enabled */
2418 if (dev->data->dev_conf.intr_conf.lsc != 0)
2419 ixgbe_dev_lsc_interrupt_setup(dev);
2420 ixgbe_dev_macsec_interrupt_setup(dev);
2422 rte_intr_callback_unregister(intr_handle,
2423 ixgbe_dev_interrupt_handler, dev);
2424 if (dev->data->dev_conf.intr_conf.lsc != 0)
2425 PMD_INIT_LOG(INFO, "lsc won't enable because of"
2426 " no intr multiplex\n");
2429 /* check if rxq interrupt is enabled */
2430 if (dev->data->dev_conf.intr_conf.rxq != 0 &&
2431 rte_intr_dp_is_en(intr_handle))
2432 ixgbe_dev_rxq_interrupt_setup(dev);
2434 /* enable uio/vfio intr/eventfd mapping */
2435 rte_intr_enable(intr_handle);
2437 /* resume enabled intr since hw reset */
2438 ixgbe_enable_intr(dev);
2443 PMD_INIT_LOG(ERR, "failure in ixgbe_dev_start(): %d", err);
2444 ixgbe_dev_clear_queues(dev);
2449 * Stop device: disable rx and tx functions to allow for reconfiguring.
2452 ixgbe_dev_stop(struct rte_eth_dev *dev)
2454 struct rte_eth_link link;
2455 struct ixgbe_hw *hw =
2456 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2457 struct ixgbe_vf_info *vfinfo =
2458 *IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private);
2459 struct ixgbe_filter_info *filter_info =
2460 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
2461 struct ixgbe_5tuple_filter *p_5tuple, *p_5tuple_next;
2462 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
2463 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
2466 PMD_INIT_FUNC_TRACE();
2468 /* disable interrupts */
2469 ixgbe_disable_intr(hw);
2472 ixgbe_pf_reset_hw(hw);
2473 hw->adapter_stopped = 0;
2476 ixgbe_stop_adapter(hw);
2478 for (vf = 0; vfinfo != NULL && vf < pci_dev->max_vfs; vf++)
2479 vfinfo[vf].clear_to_send = false;
2481 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper) {
2482 /* Turn off the copper */
2483 ixgbe_set_phy_power(hw, false);
2485 /* Turn off the laser */
2486 ixgbe_disable_tx_laser(hw);
2489 ixgbe_dev_clear_queues(dev);
2491 /* Clear stored conf */
2492 dev->data->scattered_rx = 0;
2495 /* Clear recorded link status */
2496 memset(&link, 0, sizeof(link));
2497 rte_ixgbe_dev_atomic_write_link_status(dev, &link);
2499 /* Remove all ntuple filters of the device */
2500 for (p_5tuple = TAILQ_FIRST(&filter_info->fivetuple_list);
2501 p_5tuple != NULL; p_5tuple = p_5tuple_next) {
2502 p_5tuple_next = TAILQ_NEXT(p_5tuple, entries);
2503 TAILQ_REMOVE(&filter_info->fivetuple_list,
2507 memset(filter_info->fivetuple_mask, 0,
2508 sizeof(uint32_t) * IXGBE_5TUPLE_ARRAY_SIZE);
2510 if (!rte_intr_allow_others(intr_handle))
2511 /* resume to the default handler */
2512 rte_intr_callback_register(intr_handle,
2513 ixgbe_dev_interrupt_handler,
2516 /* Clean datapath event and queue/vec mapping */
2517 rte_intr_efd_disable(intr_handle);
2518 if (intr_handle->intr_vec != NULL) {
2519 rte_free(intr_handle->intr_vec);
2520 intr_handle->intr_vec = NULL;
2525 * Set device link up: enable tx.
2528 ixgbe_dev_set_link_up(struct rte_eth_dev *dev)
2530 struct ixgbe_hw *hw =
2531 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2532 if (hw->mac.type == ixgbe_mac_82599EB) {
2533 #ifdef RTE_NIC_BYPASS
2534 if (hw->device_id == IXGBE_DEV_ID_82599_BYPASS) {
2535 /* Not suported in bypass mode */
2536 PMD_INIT_LOG(ERR, "Set link up is not supported "
2537 "by device id 0x%x", hw->device_id);
2543 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper) {
2544 /* Turn on the copper */
2545 ixgbe_set_phy_power(hw, true);
2547 /* Turn on the laser */
2548 ixgbe_enable_tx_laser(hw);
2555 * Set device link down: disable tx.
2558 ixgbe_dev_set_link_down(struct rte_eth_dev *dev)
2560 struct ixgbe_hw *hw =
2561 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2562 if (hw->mac.type == ixgbe_mac_82599EB) {
2563 #ifdef RTE_NIC_BYPASS
2564 if (hw->device_id == IXGBE_DEV_ID_82599_BYPASS) {
2565 /* Not suported in bypass mode */
2566 PMD_INIT_LOG(ERR, "Set link down is not supported "
2567 "by device id 0x%x", hw->device_id);
2573 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper) {
2574 /* Turn off the copper */
2575 ixgbe_set_phy_power(hw, false);
2577 /* Turn off the laser */
2578 ixgbe_disable_tx_laser(hw);
2585 * Reest and stop device.
2588 ixgbe_dev_close(struct rte_eth_dev *dev)
2590 struct ixgbe_hw *hw =
2591 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2593 PMD_INIT_FUNC_TRACE();
2595 ixgbe_pf_reset_hw(hw);
2597 ixgbe_dev_stop(dev);
2598 hw->adapter_stopped = 1;
2600 ixgbe_dev_free_queues(dev);
2602 ixgbe_disable_pcie_master(hw);
2604 /* reprogram the RAR[0] in case user changed it. */
2605 ixgbe_set_rar(hw, 0, hw->mac.addr, 0, IXGBE_RAH_AV);
2609 ixgbe_read_stats_registers(struct ixgbe_hw *hw,
2610 struct ixgbe_hw_stats *hw_stats,
2611 struct ixgbe_macsec_stats *macsec_stats,
2612 uint64_t *total_missed_rx, uint64_t *total_qbrc,
2613 uint64_t *total_qprc, uint64_t *total_qprdc)
2615 uint32_t bprc, lxon, lxoff, total;
2616 uint32_t delta_gprc = 0;
2618 /* Workaround for RX byte count not including CRC bytes when CRC
2619 + * strip is enabled. CRC bytes are removed from counters when crc_strip
2622 int crc_strip = (IXGBE_READ_REG(hw, IXGBE_HLREG0) &
2623 IXGBE_HLREG0_RXCRCSTRP);
2625 hw_stats->crcerrs += IXGBE_READ_REG(hw, IXGBE_CRCERRS);
2626 hw_stats->illerrc += IXGBE_READ_REG(hw, IXGBE_ILLERRC);
2627 hw_stats->errbc += IXGBE_READ_REG(hw, IXGBE_ERRBC);
2628 hw_stats->mspdc += IXGBE_READ_REG(hw, IXGBE_MSPDC);
2630 for (i = 0; i < 8; i++) {
2631 uint32_t mp = IXGBE_READ_REG(hw, IXGBE_MPC(i));
2633 /* global total per queue */
2634 hw_stats->mpc[i] += mp;
2635 /* Running comprehensive total for stats display */
2636 *total_missed_rx += hw_stats->mpc[i];
2637 if (hw->mac.type == ixgbe_mac_82598EB) {
2638 hw_stats->rnbc[i] +=
2639 IXGBE_READ_REG(hw, IXGBE_RNBC(i));
2640 hw_stats->pxonrxc[i] +=
2641 IXGBE_READ_REG(hw, IXGBE_PXONRXC(i));
2642 hw_stats->pxoffrxc[i] +=
2643 IXGBE_READ_REG(hw, IXGBE_PXOFFRXC(i));
2645 hw_stats->pxonrxc[i] +=
2646 IXGBE_READ_REG(hw, IXGBE_PXONRXCNT(i));
2647 hw_stats->pxoffrxc[i] +=
2648 IXGBE_READ_REG(hw, IXGBE_PXOFFRXCNT(i));
2649 hw_stats->pxon2offc[i] +=
2650 IXGBE_READ_REG(hw, IXGBE_PXON2OFFCNT(i));
2652 hw_stats->pxontxc[i] +=
2653 IXGBE_READ_REG(hw, IXGBE_PXONTXC(i));
2654 hw_stats->pxofftxc[i] +=
2655 IXGBE_READ_REG(hw, IXGBE_PXOFFTXC(i));
2657 for (i = 0; i < IXGBE_QUEUE_STAT_COUNTERS; i++) {
2658 uint32_t delta_qprc = IXGBE_READ_REG(hw, IXGBE_QPRC(i));
2659 uint32_t delta_qptc = IXGBE_READ_REG(hw, IXGBE_QPTC(i));
2660 uint32_t delta_qprdc = IXGBE_READ_REG(hw, IXGBE_QPRDC(i));
2662 delta_gprc += delta_qprc;
2664 hw_stats->qprc[i] += delta_qprc;
2665 hw_stats->qptc[i] += delta_qptc;
2667 hw_stats->qbrc[i] += IXGBE_READ_REG(hw, IXGBE_QBRC_L(i));
2668 hw_stats->qbrc[i] +=
2669 ((uint64_t)IXGBE_READ_REG(hw, IXGBE_QBRC_H(i)) << 32);
2671 hw_stats->qbrc[i] -= delta_qprc * ETHER_CRC_LEN;
2673 hw_stats->qbtc[i] += IXGBE_READ_REG(hw, IXGBE_QBTC_L(i));
2674 hw_stats->qbtc[i] +=
2675 ((uint64_t)IXGBE_READ_REG(hw, IXGBE_QBTC_H(i)) << 32);
2677 hw_stats->qprdc[i] += delta_qprdc;
2678 *total_qprdc += hw_stats->qprdc[i];
2680 *total_qprc += hw_stats->qprc[i];
2681 *total_qbrc += hw_stats->qbrc[i];
2683 hw_stats->mlfc += IXGBE_READ_REG(hw, IXGBE_MLFC);
2684 hw_stats->mrfc += IXGBE_READ_REG(hw, IXGBE_MRFC);
2685 hw_stats->rlec += IXGBE_READ_REG(hw, IXGBE_RLEC);
2688 * An errata states that gprc actually counts good + missed packets:
2689 * Workaround to set gprc to summated queue packet receives
2691 hw_stats->gprc = *total_qprc;
2693 if (hw->mac.type != ixgbe_mac_82598EB) {
2694 hw_stats->gorc += IXGBE_READ_REG(hw, IXGBE_GORCL);
2695 hw_stats->gorc += ((u64)IXGBE_READ_REG(hw, IXGBE_GORCH) << 32);
2696 hw_stats->gotc += IXGBE_READ_REG(hw, IXGBE_GOTCL);
2697 hw_stats->gotc += ((u64)IXGBE_READ_REG(hw, IXGBE_GOTCH) << 32);
2698 hw_stats->tor += IXGBE_READ_REG(hw, IXGBE_TORL);
2699 hw_stats->tor += ((u64)IXGBE_READ_REG(hw, IXGBE_TORH) << 32);
2700 hw_stats->lxonrxc += IXGBE_READ_REG(hw, IXGBE_LXONRXCNT);
2701 hw_stats->lxoffrxc += IXGBE_READ_REG(hw, IXGBE_LXOFFRXCNT);
2703 hw_stats->lxonrxc += IXGBE_READ_REG(hw, IXGBE_LXONRXC);
2704 hw_stats->lxoffrxc += IXGBE_READ_REG(hw, IXGBE_LXOFFRXC);
2705 /* 82598 only has a counter in the high register */
2706 hw_stats->gorc += IXGBE_READ_REG(hw, IXGBE_GORCH);
2707 hw_stats->gotc += IXGBE_READ_REG(hw, IXGBE_GOTCH);
2708 hw_stats->tor += IXGBE_READ_REG(hw, IXGBE_TORH);
2710 uint64_t old_tpr = hw_stats->tpr;
2712 hw_stats->tpr += IXGBE_READ_REG(hw, IXGBE_TPR);
2713 hw_stats->tpt += IXGBE_READ_REG(hw, IXGBE_TPT);
2716 hw_stats->gorc -= delta_gprc * ETHER_CRC_LEN;
2718 uint64_t delta_gptc = IXGBE_READ_REG(hw, IXGBE_GPTC);
2719 hw_stats->gptc += delta_gptc;
2720 hw_stats->gotc -= delta_gptc * ETHER_CRC_LEN;
2721 hw_stats->tor -= (hw_stats->tpr - old_tpr) * ETHER_CRC_LEN;
2724 * Workaround: mprc hardware is incorrectly counting
2725 * broadcasts, so for now we subtract those.
2727 bprc = IXGBE_READ_REG(hw, IXGBE_BPRC);
2728 hw_stats->bprc += bprc;
2729 hw_stats->mprc += IXGBE_READ_REG(hw, IXGBE_MPRC);
2730 if (hw->mac.type == ixgbe_mac_82598EB)
2731 hw_stats->mprc -= bprc;
2733 hw_stats->prc64 += IXGBE_READ_REG(hw, IXGBE_PRC64);
2734 hw_stats->prc127 += IXGBE_READ_REG(hw, IXGBE_PRC127);
2735 hw_stats->prc255 += IXGBE_READ_REG(hw, IXGBE_PRC255);
2736 hw_stats->prc511 += IXGBE_READ_REG(hw, IXGBE_PRC511);
2737 hw_stats->prc1023 += IXGBE_READ_REG(hw, IXGBE_PRC1023);
2738 hw_stats->prc1522 += IXGBE_READ_REG(hw, IXGBE_PRC1522);
2740 lxon = IXGBE_READ_REG(hw, IXGBE_LXONTXC);
2741 hw_stats->lxontxc += lxon;
2742 lxoff = IXGBE_READ_REG(hw, IXGBE_LXOFFTXC);
2743 hw_stats->lxofftxc += lxoff;
2744 total = lxon + lxoff;
2746 hw_stats->mptc += IXGBE_READ_REG(hw, IXGBE_MPTC);
2747 hw_stats->ptc64 += IXGBE_READ_REG(hw, IXGBE_PTC64);
2748 hw_stats->gptc -= total;
2749 hw_stats->mptc -= total;
2750 hw_stats->ptc64 -= total;
2751 hw_stats->gotc -= total * ETHER_MIN_LEN;
2753 hw_stats->ruc += IXGBE_READ_REG(hw, IXGBE_RUC);
2754 hw_stats->rfc += IXGBE_READ_REG(hw, IXGBE_RFC);
2755 hw_stats->roc += IXGBE_READ_REG(hw, IXGBE_ROC);
2756 hw_stats->rjc += IXGBE_READ_REG(hw, IXGBE_RJC);
2757 hw_stats->mngprc += IXGBE_READ_REG(hw, IXGBE_MNGPRC);
2758 hw_stats->mngpdc += IXGBE_READ_REG(hw, IXGBE_MNGPDC);
2759 hw_stats->mngptc += IXGBE_READ_REG(hw, IXGBE_MNGPTC);
2760 hw_stats->ptc127 += IXGBE_READ_REG(hw, IXGBE_PTC127);
2761 hw_stats->ptc255 += IXGBE_READ_REG(hw, IXGBE_PTC255);
2762 hw_stats->ptc511 += IXGBE_READ_REG(hw, IXGBE_PTC511);
2763 hw_stats->ptc1023 += IXGBE_READ_REG(hw, IXGBE_PTC1023);
2764 hw_stats->ptc1522 += IXGBE_READ_REG(hw, IXGBE_PTC1522);
2765 hw_stats->bptc += IXGBE_READ_REG(hw, IXGBE_BPTC);
2766 hw_stats->xec += IXGBE_READ_REG(hw, IXGBE_XEC);
2767 hw_stats->fccrc += IXGBE_READ_REG(hw, IXGBE_FCCRC);
2768 hw_stats->fclast += IXGBE_READ_REG(hw, IXGBE_FCLAST);
2769 /* Only read FCOE on 82599 */
2770 if (hw->mac.type != ixgbe_mac_82598EB) {
2771 hw_stats->fcoerpdc += IXGBE_READ_REG(hw, IXGBE_FCOERPDC);
2772 hw_stats->fcoeprc += IXGBE_READ_REG(hw, IXGBE_FCOEPRC);
2773 hw_stats->fcoeptc += IXGBE_READ_REG(hw, IXGBE_FCOEPTC);
2774 hw_stats->fcoedwrc += IXGBE_READ_REG(hw, IXGBE_FCOEDWRC);
2775 hw_stats->fcoedwtc += IXGBE_READ_REG(hw, IXGBE_FCOEDWTC);
2778 /* Flow Director Stats registers */
2779 hw_stats->fdirmatch += IXGBE_READ_REG(hw, IXGBE_FDIRMATCH);
2780 hw_stats->fdirmiss += IXGBE_READ_REG(hw, IXGBE_FDIRMISS);
2782 /* MACsec Stats registers */
2783 macsec_stats->out_pkts_untagged += IXGBE_READ_REG(hw, IXGBE_LSECTXUT);
2784 macsec_stats->out_pkts_encrypted +=
2785 IXGBE_READ_REG(hw, IXGBE_LSECTXPKTE);
2786 macsec_stats->out_pkts_protected +=
2787 IXGBE_READ_REG(hw, IXGBE_LSECTXPKTP);
2788 macsec_stats->out_octets_encrypted +=
2789 IXGBE_READ_REG(hw, IXGBE_LSECTXOCTE);
2790 macsec_stats->out_octets_protected +=
2791 IXGBE_READ_REG(hw, IXGBE_LSECTXOCTP);
2792 macsec_stats->in_pkts_untagged += IXGBE_READ_REG(hw, IXGBE_LSECRXUT);
2793 macsec_stats->in_pkts_badtag += IXGBE_READ_REG(hw, IXGBE_LSECRXBAD);
2794 macsec_stats->in_pkts_nosci += IXGBE_READ_REG(hw, IXGBE_LSECRXNOSCI);
2795 macsec_stats->in_pkts_unknownsci +=
2796 IXGBE_READ_REG(hw, IXGBE_LSECRXUNSCI);
2797 macsec_stats->in_octets_decrypted +=
2798 IXGBE_READ_REG(hw, IXGBE_LSECRXOCTD);
2799 macsec_stats->in_octets_validated +=
2800 IXGBE_READ_REG(hw, IXGBE_LSECRXOCTV);
2801 macsec_stats->in_pkts_unchecked += IXGBE_READ_REG(hw, IXGBE_LSECRXUNCH);
2802 macsec_stats->in_pkts_delayed += IXGBE_READ_REG(hw, IXGBE_LSECRXDELAY);
2803 macsec_stats->in_pkts_late += IXGBE_READ_REG(hw, IXGBE_LSECRXLATE);
2804 for (i = 0; i < 2; i++) {
2805 macsec_stats->in_pkts_ok +=
2806 IXGBE_READ_REG(hw, IXGBE_LSECRXOK(i));
2807 macsec_stats->in_pkts_invalid +=
2808 IXGBE_READ_REG(hw, IXGBE_LSECRXINV(i));
2809 macsec_stats->in_pkts_notvalid +=
2810 IXGBE_READ_REG(hw, IXGBE_LSECRXNV(i));
2812 macsec_stats->in_pkts_unusedsa += IXGBE_READ_REG(hw, IXGBE_LSECRXUNSA);
2813 macsec_stats->in_pkts_notusingsa +=
2814 IXGBE_READ_REG(hw, IXGBE_LSECRXNUSA);
2818 * This function is based on ixgbe_update_stats_counters() in ixgbe/ixgbe.c
2821 ixgbe_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
2823 struct ixgbe_hw *hw =
2824 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2825 struct ixgbe_hw_stats *hw_stats =
2826 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
2827 struct ixgbe_macsec_stats *macsec_stats =
2828 IXGBE_DEV_PRIVATE_TO_MACSEC_STATS(
2829 dev->data->dev_private);
2830 uint64_t total_missed_rx, total_qbrc, total_qprc, total_qprdc;
2833 total_missed_rx = 0;
2838 ixgbe_read_stats_registers(hw, hw_stats, macsec_stats, &total_missed_rx,
2839 &total_qbrc, &total_qprc, &total_qprdc);
2844 /* Fill out the rte_eth_stats statistics structure */
2845 stats->ipackets = total_qprc;
2846 stats->ibytes = total_qbrc;
2847 stats->opackets = hw_stats->gptc;
2848 stats->obytes = hw_stats->gotc;
2850 for (i = 0; i < IXGBE_QUEUE_STAT_COUNTERS; i++) {
2851 stats->q_ipackets[i] = hw_stats->qprc[i];
2852 stats->q_opackets[i] = hw_stats->qptc[i];
2853 stats->q_ibytes[i] = hw_stats->qbrc[i];
2854 stats->q_obytes[i] = hw_stats->qbtc[i];
2855 stats->q_errors[i] = hw_stats->qprdc[i];
2859 stats->imissed = total_missed_rx;
2860 stats->ierrors = hw_stats->crcerrs +
2876 ixgbe_dev_stats_reset(struct rte_eth_dev *dev)
2878 struct ixgbe_hw_stats *stats =
2879 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
2881 /* HW registers are cleared on read */
2882 ixgbe_dev_stats_get(dev, NULL);
2884 /* Reset software totals */
2885 memset(stats, 0, sizeof(*stats));
2888 /* This function calculates the number of xstats based on the current config */
2890 ixgbe_xstats_calc_num(void) {
2891 return IXGBE_NB_HW_STATS + IXGBE_NB_MACSEC_STATS +
2892 (IXGBE_NB_RXQ_PRIO_STATS * IXGBE_NB_RXQ_PRIO_VALUES) +
2893 (IXGBE_NB_TXQ_PRIO_STATS * IXGBE_NB_TXQ_PRIO_VALUES);
2896 static int ixgbe_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
2897 struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned limit)
2899 const unsigned cnt_stats = ixgbe_xstats_calc_num();
2900 unsigned stat, i, count;
2902 if (xstats_names != NULL) {
2905 /* Note: limit >= cnt_stats checked upstream
2906 * in rte_eth_xstats_names()
2909 /* Extended stats from ixgbe_hw_stats */
2910 for (i = 0; i < IXGBE_NB_HW_STATS; i++) {
2911 snprintf(xstats_names[count].name,
2912 sizeof(xstats_names[count].name),
2914 rte_ixgbe_stats_strings[i].name);
2919 for (i = 0; i < IXGBE_NB_MACSEC_STATS; i++) {
2920 snprintf(xstats_names[count].name,
2921 sizeof(xstats_names[count].name),
2923 rte_ixgbe_macsec_strings[i].name);
2927 /* RX Priority Stats */
2928 for (stat = 0; stat < IXGBE_NB_RXQ_PRIO_STATS; stat++) {
2929 for (i = 0; i < IXGBE_NB_RXQ_PRIO_VALUES; i++) {
2930 snprintf(xstats_names[count].name,
2931 sizeof(xstats_names[count].name),
2932 "rx_priority%u_%s", i,
2933 rte_ixgbe_rxq_strings[stat].name);
2938 /* TX Priority Stats */
2939 for (stat = 0; stat < IXGBE_NB_TXQ_PRIO_STATS; stat++) {
2940 for (i = 0; i < IXGBE_NB_TXQ_PRIO_VALUES; i++) {
2941 snprintf(xstats_names[count].name,
2942 sizeof(xstats_names[count].name),
2943 "tx_priority%u_%s", i,
2944 rte_ixgbe_txq_strings[stat].name);
2952 static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
2953 struct rte_eth_xstat_name *xstats_names, unsigned limit)
2957 if (limit < IXGBEVF_NB_XSTATS && xstats_names != NULL)
2960 if (xstats_names != NULL)
2961 for (i = 0; i < IXGBEVF_NB_XSTATS; i++)
2962 snprintf(xstats_names[i].name,
2963 sizeof(xstats_names[i].name),
2964 "%s", rte_ixgbevf_stats_strings[i].name);
2965 return IXGBEVF_NB_XSTATS;
2969 ixgbe_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
2972 struct ixgbe_hw *hw =
2973 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2974 struct ixgbe_hw_stats *hw_stats =
2975 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
2976 struct ixgbe_macsec_stats *macsec_stats =
2977 IXGBE_DEV_PRIVATE_TO_MACSEC_STATS(
2978 dev->data->dev_private);
2979 uint64_t total_missed_rx, total_qbrc, total_qprc, total_qprdc;
2980 unsigned i, stat, count = 0;
2982 count = ixgbe_xstats_calc_num();
2987 total_missed_rx = 0;
2992 ixgbe_read_stats_registers(hw, hw_stats, macsec_stats, &total_missed_rx,
2993 &total_qbrc, &total_qprc, &total_qprdc);
2995 /* If this is a reset xstats is NULL, and we have cleared the
2996 * registers by reading them.
3001 /* Extended stats from ixgbe_hw_stats */
3003 for (i = 0; i < IXGBE_NB_HW_STATS; i++) {
3004 xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
3005 rte_ixgbe_stats_strings[i].offset);
3006 xstats[count].id = count;
3011 for (i = 0; i < IXGBE_NB_MACSEC_STATS; i++) {
3012 xstats[count].value = *(uint64_t *)(((char *)macsec_stats) +
3013 rte_ixgbe_macsec_strings[i].offset);
3014 xstats[count].id = count;
3018 /* RX Priority Stats */
3019 for (stat = 0; stat < IXGBE_NB_RXQ_PRIO_STATS; stat++) {
3020 for (i = 0; i < IXGBE_NB_RXQ_PRIO_VALUES; i++) {
3021 xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
3022 rte_ixgbe_rxq_strings[stat].offset +
3023 (sizeof(uint64_t) * i));
3024 xstats[count].id = count;
3029 /* TX Priority Stats */
3030 for (stat = 0; stat < IXGBE_NB_TXQ_PRIO_STATS; stat++) {
3031 for (i = 0; i < IXGBE_NB_TXQ_PRIO_VALUES; i++) {
3032 xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
3033 rte_ixgbe_txq_strings[stat].offset +
3034 (sizeof(uint64_t) * i));
3035 xstats[count].id = count;
3043 ixgbe_dev_xstats_reset(struct rte_eth_dev *dev)
3045 struct ixgbe_hw_stats *stats =
3046 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3047 struct ixgbe_macsec_stats *macsec_stats =
3048 IXGBE_DEV_PRIVATE_TO_MACSEC_STATS(
3049 dev->data->dev_private);
3051 unsigned count = ixgbe_xstats_calc_num();
3053 /* HW registers are cleared on read */
3054 ixgbe_dev_xstats_get(dev, NULL, count);
3056 /* Reset software totals */
3057 memset(stats, 0, sizeof(*stats));
3058 memset(macsec_stats, 0, sizeof(*macsec_stats));
3062 ixgbevf_update_stats(struct rte_eth_dev *dev)
3064 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3065 struct ixgbevf_hw_stats *hw_stats = (struct ixgbevf_hw_stats *)
3066 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3068 /* Good Rx packet, include VF loopback */
3069 UPDATE_VF_STAT(IXGBE_VFGPRC,
3070 hw_stats->last_vfgprc, hw_stats->vfgprc);
3072 /* Good Rx octets, include VF loopback */
3073 UPDATE_VF_STAT_36BIT(IXGBE_VFGORC_LSB, IXGBE_VFGORC_MSB,
3074 hw_stats->last_vfgorc, hw_stats->vfgorc);
3076 /* Good Tx packet, include VF loopback */
3077 UPDATE_VF_STAT(IXGBE_VFGPTC,
3078 hw_stats->last_vfgptc, hw_stats->vfgptc);
3080 /* Good Tx octets, include VF loopback */
3081 UPDATE_VF_STAT_36BIT(IXGBE_VFGOTC_LSB, IXGBE_VFGOTC_MSB,
3082 hw_stats->last_vfgotc, hw_stats->vfgotc);
3084 /* Rx Multicst Packet */
3085 UPDATE_VF_STAT(IXGBE_VFMPRC,
3086 hw_stats->last_vfmprc, hw_stats->vfmprc);
3090 ixgbevf_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
3093 struct ixgbevf_hw_stats *hw_stats = (struct ixgbevf_hw_stats *)
3094 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3097 if (n < IXGBEVF_NB_XSTATS)
3098 return IXGBEVF_NB_XSTATS;
3100 ixgbevf_update_stats(dev);
3105 /* Extended stats */
3106 for (i = 0; i < IXGBEVF_NB_XSTATS; i++) {
3107 xstats[i].value = *(uint64_t *)(((char *)hw_stats) +
3108 rte_ixgbevf_stats_strings[i].offset);
3111 return IXGBEVF_NB_XSTATS;
3115 ixgbevf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
3117 struct ixgbevf_hw_stats *hw_stats = (struct ixgbevf_hw_stats *)
3118 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3120 ixgbevf_update_stats(dev);
3125 stats->ipackets = hw_stats->vfgprc;
3126 stats->ibytes = hw_stats->vfgorc;
3127 stats->opackets = hw_stats->vfgptc;
3128 stats->obytes = hw_stats->vfgotc;
3132 ixgbevf_dev_stats_reset(struct rte_eth_dev *dev)
3134 struct ixgbevf_hw_stats *hw_stats = (struct ixgbevf_hw_stats *)
3135 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3137 /* Sync HW register to the last stats */
3138 ixgbevf_dev_stats_get(dev, NULL);
3140 /* reset HW current stats*/
3141 hw_stats->vfgprc = 0;
3142 hw_stats->vfgorc = 0;
3143 hw_stats->vfgptc = 0;
3144 hw_stats->vfgotc = 0;
3148 ixgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
3150 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
3151 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3152 struct rte_eth_conf *dev_conf = &dev->data->dev_conf;
3154 dev_info->pci_dev = pci_dev;
3155 dev_info->max_rx_queues = (uint16_t)hw->mac.max_rx_queues;
3156 dev_info->max_tx_queues = (uint16_t)hw->mac.max_tx_queues;
3157 if (RTE_ETH_DEV_SRIOV(dev).active == 0) {
3159 * When DCB/VT is off, maximum number of queues changes,
3160 * except for 82598EB, which remains constant.
3162 if (dev_conf->txmode.mq_mode == ETH_MQ_TX_NONE &&
3163 hw->mac.type != ixgbe_mac_82598EB)
3164 dev_info->max_tx_queues = IXGBE_NONE_MODE_TX_NB_QUEUES;
3166 dev_info->min_rx_bufsize = 1024; /* cf BSIZEPACKET in SRRCTL register */
3167 dev_info->max_rx_pktlen = 15872; /* includes CRC, cf MAXFRS register */
3168 dev_info->max_mac_addrs = hw->mac.num_rar_entries;
3169 dev_info->max_hash_mac_addrs = IXGBE_VMDQ_NUM_UC_MAC;
3170 dev_info->max_vfs = pci_dev->max_vfs;
3171 if (hw->mac.type == ixgbe_mac_82598EB)
3172 dev_info->max_vmdq_pools = ETH_16_POOLS;
3174 dev_info->max_vmdq_pools = ETH_64_POOLS;
3175 dev_info->vmdq_queue_num = dev_info->max_rx_queues;
3176 dev_info->rx_offload_capa =
3177 DEV_RX_OFFLOAD_VLAN_STRIP |
3178 DEV_RX_OFFLOAD_IPV4_CKSUM |
3179 DEV_RX_OFFLOAD_UDP_CKSUM |
3180 DEV_RX_OFFLOAD_TCP_CKSUM;
3183 * RSC is only supported by 82599 and x540 PF devices in a non-SR-IOV
3186 if ((hw->mac.type == ixgbe_mac_82599EB ||
3187 hw->mac.type == ixgbe_mac_X540) &&
3188 !RTE_ETH_DEV_SRIOV(dev).active)
3189 dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_TCP_LRO;
3191 if (hw->mac.type == ixgbe_mac_82599EB ||
3192 hw->mac.type == ixgbe_mac_X540)
3193 dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_MACSEC_STRIP;
3195 if (hw->mac.type == ixgbe_mac_X550 ||
3196 hw->mac.type == ixgbe_mac_X550EM_x ||
3197 hw->mac.type == ixgbe_mac_X550EM_a)
3198 dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM;
3200 dev_info->tx_offload_capa =
3201 DEV_TX_OFFLOAD_VLAN_INSERT |
3202 DEV_TX_OFFLOAD_IPV4_CKSUM |
3203 DEV_TX_OFFLOAD_UDP_CKSUM |
3204 DEV_TX_OFFLOAD_TCP_CKSUM |
3205 DEV_TX_OFFLOAD_SCTP_CKSUM |
3206 DEV_TX_OFFLOAD_TCP_TSO;
3208 if (hw->mac.type == ixgbe_mac_82599EB ||
3209 hw->mac.type == ixgbe_mac_X540)
3210 dev_info->tx_offload_capa |= DEV_TX_OFFLOAD_MACSEC_INSERT;
3212 if (hw->mac.type == ixgbe_mac_X550 ||
3213 hw->mac.type == ixgbe_mac_X550EM_x ||
3214 hw->mac.type == ixgbe_mac_X550EM_a)
3215 dev_info->tx_offload_capa |= DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
3217 dev_info->default_rxconf = (struct rte_eth_rxconf) {
3219 .pthresh = IXGBE_DEFAULT_RX_PTHRESH,
3220 .hthresh = IXGBE_DEFAULT_RX_HTHRESH,
3221 .wthresh = IXGBE_DEFAULT_RX_WTHRESH,
3223 .rx_free_thresh = IXGBE_DEFAULT_RX_FREE_THRESH,
3227 dev_info->default_txconf = (struct rte_eth_txconf) {
3229 .pthresh = IXGBE_DEFAULT_TX_PTHRESH,
3230 .hthresh = IXGBE_DEFAULT_TX_HTHRESH,
3231 .wthresh = IXGBE_DEFAULT_TX_WTHRESH,
3233 .tx_free_thresh = IXGBE_DEFAULT_TX_FREE_THRESH,
3234 .tx_rs_thresh = IXGBE_DEFAULT_TX_RSBIT_THRESH,
3235 .txq_flags = ETH_TXQ_FLAGS_NOMULTSEGS |
3236 ETH_TXQ_FLAGS_NOOFFLOADS,
3239 dev_info->rx_desc_lim = rx_desc_lim;
3240 dev_info->tx_desc_lim = tx_desc_lim;
3242 dev_info->hash_key_size = IXGBE_HKEY_MAX_INDEX * sizeof(uint32_t);
3243 dev_info->reta_size = ixgbe_reta_size_get(hw->mac.type);
3244 dev_info->flow_type_rss_offloads = IXGBE_RSS_OFFLOAD_ALL;
3246 dev_info->speed_capa = ETH_LINK_SPEED_1G | ETH_LINK_SPEED_10G;
3247 if (hw->mac.type == ixgbe_mac_X540 ||
3248 hw->mac.type == ixgbe_mac_X540_vf ||
3249 hw->mac.type == ixgbe_mac_X550 ||
3250 hw->mac.type == ixgbe_mac_X550_vf) {
3251 dev_info->speed_capa |= ETH_LINK_SPEED_100M;
3255 static const uint32_t *
3256 ixgbe_dev_supported_ptypes_get(struct rte_eth_dev *dev)
3258 static const uint32_t ptypes[] = {
3259 /* For non-vec functions,
3260 * refers to ixgbe_rxd_pkt_info_to_pkt_type();
3261 * for vec functions,
3262 * refers to _recv_raw_pkts_vec().
3266 RTE_PTYPE_L3_IPV4_EXT,
3268 RTE_PTYPE_L3_IPV6_EXT,
3272 RTE_PTYPE_TUNNEL_IP,
3273 RTE_PTYPE_INNER_L3_IPV6,
3274 RTE_PTYPE_INNER_L3_IPV6_EXT,
3275 RTE_PTYPE_INNER_L4_TCP,
3276 RTE_PTYPE_INNER_L4_UDP,
3280 if (dev->rx_pkt_burst == ixgbe_recv_pkts ||
3281 dev->rx_pkt_burst == ixgbe_recv_pkts_lro_single_alloc ||
3282 dev->rx_pkt_burst == ixgbe_recv_pkts_lro_bulk_alloc ||
3283 dev->rx_pkt_burst == ixgbe_recv_pkts_bulk_alloc)
3289 ixgbevf_dev_info_get(struct rte_eth_dev *dev,
3290 struct rte_eth_dev_info *dev_info)
3292 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
3293 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3295 dev_info->pci_dev = pci_dev;
3296 dev_info->max_rx_queues = (uint16_t)hw->mac.max_rx_queues;
3297 dev_info->max_tx_queues = (uint16_t)hw->mac.max_tx_queues;
3298 dev_info->min_rx_bufsize = 1024; /* cf BSIZEPACKET in SRRCTL reg */
3299 dev_info->max_rx_pktlen = 15872; /* includes CRC, cf MAXFRS reg */
3300 dev_info->max_mac_addrs = hw->mac.num_rar_entries;
3301 dev_info->max_hash_mac_addrs = IXGBE_VMDQ_NUM_UC_MAC;
3302 dev_info->max_vfs = pci_dev->max_vfs;
3303 if (hw->mac.type == ixgbe_mac_82598EB)
3304 dev_info->max_vmdq_pools = ETH_16_POOLS;
3306 dev_info->max_vmdq_pools = ETH_64_POOLS;
3307 dev_info->rx_offload_capa = DEV_RX_OFFLOAD_VLAN_STRIP |
3308 DEV_RX_OFFLOAD_IPV4_CKSUM |
3309 DEV_RX_OFFLOAD_UDP_CKSUM |
3310 DEV_RX_OFFLOAD_TCP_CKSUM;
3311 dev_info->tx_offload_capa = DEV_TX_OFFLOAD_VLAN_INSERT |
3312 DEV_TX_OFFLOAD_IPV4_CKSUM |
3313 DEV_TX_OFFLOAD_UDP_CKSUM |
3314 DEV_TX_OFFLOAD_TCP_CKSUM |
3315 DEV_TX_OFFLOAD_SCTP_CKSUM |
3316 DEV_TX_OFFLOAD_TCP_TSO;
3318 dev_info->default_rxconf = (struct rte_eth_rxconf) {
3320 .pthresh = IXGBE_DEFAULT_RX_PTHRESH,
3321 .hthresh = IXGBE_DEFAULT_RX_HTHRESH,
3322 .wthresh = IXGBE_DEFAULT_RX_WTHRESH,
3324 .rx_free_thresh = IXGBE_DEFAULT_RX_FREE_THRESH,
3328 dev_info->default_txconf = (struct rte_eth_txconf) {
3330 .pthresh = IXGBE_DEFAULT_TX_PTHRESH,
3331 .hthresh = IXGBE_DEFAULT_TX_HTHRESH,
3332 .wthresh = IXGBE_DEFAULT_TX_WTHRESH,
3334 .tx_free_thresh = IXGBE_DEFAULT_TX_FREE_THRESH,
3335 .tx_rs_thresh = IXGBE_DEFAULT_TX_RSBIT_THRESH,
3336 .txq_flags = ETH_TXQ_FLAGS_NOMULTSEGS |
3337 ETH_TXQ_FLAGS_NOOFFLOADS,
3340 dev_info->rx_desc_lim = rx_desc_lim;
3341 dev_info->tx_desc_lim = tx_desc_lim;
3344 /* return 0 means link status changed, -1 means not changed */
3346 ixgbe_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
3348 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3349 struct rte_eth_link link, old;
3350 ixgbe_link_speed link_speed = IXGBE_LINK_SPEED_UNKNOWN;
3354 link.link_status = ETH_LINK_DOWN;
3355 link.link_speed = 0;
3356 link.link_duplex = ETH_LINK_HALF_DUPLEX;
3357 memset(&old, 0, sizeof(old));
3358 rte_ixgbe_dev_atomic_read_link_status(dev, &old);
3360 hw->mac.get_link_status = true;
3362 /* check if it needs to wait to complete, if lsc interrupt is enabled */
3363 if (wait_to_complete == 0 || dev->data->dev_conf.intr_conf.lsc != 0)
3364 diag = ixgbe_check_link(hw, &link_speed, &link_up, 0);
3366 diag = ixgbe_check_link(hw, &link_speed, &link_up, 1);
3369 link.link_speed = ETH_SPEED_NUM_100M;
3370 link.link_duplex = ETH_LINK_FULL_DUPLEX;
3371 rte_ixgbe_dev_atomic_write_link_status(dev, &link);
3372 if (link.link_status == old.link_status)
3378 rte_ixgbe_dev_atomic_write_link_status(dev, &link);
3379 if (link.link_status == old.link_status)
3383 link.link_status = ETH_LINK_UP;
3384 link.link_duplex = ETH_LINK_FULL_DUPLEX;
3386 switch (link_speed) {
3388 case IXGBE_LINK_SPEED_UNKNOWN:
3389 link.link_duplex = ETH_LINK_FULL_DUPLEX;
3390 link.link_speed = ETH_SPEED_NUM_100M;
3393 case IXGBE_LINK_SPEED_100_FULL:
3394 link.link_speed = ETH_SPEED_NUM_100M;
3397 case IXGBE_LINK_SPEED_1GB_FULL:
3398 link.link_speed = ETH_SPEED_NUM_1G;
3401 case IXGBE_LINK_SPEED_10GB_FULL:
3402 link.link_speed = ETH_SPEED_NUM_10G;
3405 rte_ixgbe_dev_atomic_write_link_status(dev, &link);
3407 if (link.link_status == old.link_status)
3414 ixgbe_dev_promiscuous_enable(struct rte_eth_dev *dev)
3416 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3419 fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
3420 fctrl |= (IXGBE_FCTRL_UPE | IXGBE_FCTRL_MPE);
3421 IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
3425 ixgbe_dev_promiscuous_disable(struct rte_eth_dev *dev)
3427 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3430 fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
3431 fctrl &= (~IXGBE_FCTRL_UPE);
3432 if (dev->data->all_multicast == 1)
3433 fctrl |= IXGBE_FCTRL_MPE;
3435 fctrl &= (~IXGBE_FCTRL_MPE);
3436 IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
3440 ixgbe_dev_allmulticast_enable(struct rte_eth_dev *dev)
3442 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3445 fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
3446 fctrl |= IXGBE_FCTRL_MPE;
3447 IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
3451 ixgbe_dev_allmulticast_disable(struct rte_eth_dev *dev)
3453 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3456 if (dev->data->promiscuous == 1)
3457 return; /* must remain in all_multicast mode */
3459 fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
3460 fctrl &= (~IXGBE_FCTRL_MPE);
3461 IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
3465 * It clears the interrupt causes and enables the interrupt.
3466 * It will be called once only during nic initialized.
3469 * Pointer to struct rte_eth_dev.
3472 * - On success, zero.
3473 * - On failure, a negative value.
3476 ixgbe_dev_lsc_interrupt_setup(struct rte_eth_dev *dev)
3478 struct ixgbe_interrupt *intr =
3479 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
3481 ixgbe_dev_link_status_print(dev);
3482 intr->mask |= IXGBE_EICR_LSC;
3488 * It clears the interrupt causes and enables the interrupt.
3489 * It will be called once only during nic initialized.
3492 * Pointer to struct rte_eth_dev.
3495 * - On success, zero.
3496 * - On failure, a negative value.
3499 ixgbe_dev_rxq_interrupt_setup(struct rte_eth_dev *dev)
3501 struct ixgbe_interrupt *intr =
3502 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
3504 intr->mask |= IXGBE_EICR_RTX_QUEUE;
3510 * It clears the interrupt causes and enables the interrupt.
3511 * It will be called once only during nic initialized.
3514 * Pointer to struct rte_eth_dev.
3517 * - On success, zero.
3518 * - On failure, a negative value.
3521 ixgbe_dev_macsec_interrupt_setup(struct rte_eth_dev *dev)
3523 struct ixgbe_interrupt *intr =
3524 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
3526 intr->mask |= IXGBE_EICR_LINKSEC;
3532 * It reads ICR and sets flag (IXGBE_EICR_LSC) for the link_update.
3535 * Pointer to struct rte_eth_dev.
3538 * - On success, zero.
3539 * - On failure, a negative value.
3542 ixgbe_dev_interrupt_get_status(struct rte_eth_dev *dev)
3545 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3546 struct ixgbe_interrupt *intr =
3547 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
3549 /* clear all cause mask */
3550 ixgbe_disable_intr(hw);
3552 /* read-on-clear nic registers here */
3553 eicr = IXGBE_READ_REG(hw, IXGBE_EICR);
3554 PMD_DRV_LOG(DEBUG, "eicr %x", eicr);
3558 /* set flag for async link update */
3559 if (eicr & IXGBE_EICR_LSC)
3560 intr->flags |= IXGBE_FLAG_NEED_LINK_UPDATE;
3562 if (eicr & IXGBE_EICR_MAILBOX)
3563 intr->flags |= IXGBE_FLAG_MAILBOX;
3565 if (eicr & IXGBE_EICR_LINKSEC)
3566 intr->flags |= IXGBE_FLAG_MACSEC;
3568 if (hw->mac.type == ixgbe_mac_X550EM_x &&
3569 hw->phy.type == ixgbe_phy_x550em_ext_t &&
3570 (eicr & IXGBE_EICR_GPI_SDP0_X550EM_x))
3571 intr->flags |= IXGBE_FLAG_PHY_INTERRUPT;
3577 * It gets and then prints the link status.
3580 * Pointer to struct rte_eth_dev.
3583 * - On success, zero.
3584 * - On failure, a negative value.
3587 ixgbe_dev_link_status_print(struct rte_eth_dev *dev)
3589 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
3590 struct rte_eth_link link;
3592 memset(&link, 0, sizeof(link));
3593 rte_ixgbe_dev_atomic_read_link_status(dev, &link);
3594 if (link.link_status) {
3595 PMD_INIT_LOG(INFO, "Port %d: Link Up - speed %u Mbps - %s",
3596 (int)(dev->data->port_id),
3597 (unsigned)link.link_speed,
3598 link.link_duplex == ETH_LINK_FULL_DUPLEX ?
3599 "full-duplex" : "half-duplex");
3601 PMD_INIT_LOG(INFO, " Port %d: Link Down",
3602 (int)(dev->data->port_id));
3604 PMD_INIT_LOG(DEBUG, "PCI Address: " PCI_PRI_FMT,
3605 pci_dev->addr.domain,
3607 pci_dev->addr.devid,
3608 pci_dev->addr.function);
3612 * It executes link_update after knowing an interrupt occurred.
3615 * Pointer to struct rte_eth_dev.
3618 * - On success, zero.
3619 * - On failure, a negative value.
3622 ixgbe_dev_interrupt_action(struct rte_eth_dev *dev,
3623 struct rte_intr_handle *intr_handle)
3625 struct ixgbe_interrupt *intr =
3626 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
3628 struct rte_eth_link link;
3629 int intr_enable_delay = false;
3630 struct ixgbe_hw *hw =
3631 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3633 PMD_DRV_LOG(DEBUG, "intr action type %d", intr->flags);
3635 if (intr->flags & IXGBE_FLAG_MAILBOX) {
3636 ixgbe_pf_mbx_process(dev);
3637 intr->flags &= ~IXGBE_FLAG_MAILBOX;
3640 if (intr->flags & IXGBE_FLAG_PHY_INTERRUPT) {
3641 ixgbe_handle_lasi(hw);
3642 intr->flags &= ~IXGBE_FLAG_PHY_INTERRUPT;
3645 if (intr->flags & IXGBE_FLAG_NEED_LINK_UPDATE) {
3646 /* get the link status before link update, for predicting later */
3647 memset(&link, 0, sizeof(link));
3648 rte_ixgbe_dev_atomic_read_link_status(dev, &link);
3650 ixgbe_dev_link_update(dev, 0);
3653 if (!link.link_status)
3654 /* handle it 1 sec later, wait it being stable */
3655 timeout = IXGBE_LINK_UP_CHECK_TIMEOUT;
3656 /* likely to down */
3658 /* handle it 4 sec later, wait it being stable */
3659 timeout = IXGBE_LINK_DOWN_CHECK_TIMEOUT;
3661 ixgbe_dev_link_status_print(dev);
3663 intr_enable_delay = true;
3666 if (intr_enable_delay) {
3667 if (rte_eal_alarm_set(timeout * 1000,
3668 ixgbe_dev_interrupt_delayed_handler, (void *)dev) < 0)
3669 PMD_DRV_LOG(ERR, "Error setting alarm");
3671 PMD_DRV_LOG(DEBUG, "enable intr immediately");
3672 ixgbe_enable_intr(dev);
3673 rte_intr_enable(intr_handle);
3681 * Interrupt handler which shall be registered for alarm callback for delayed
3682 * handling specific interrupt to wait for the stable nic state. As the
3683 * NIC interrupt state is not stable for ixgbe after link is just down,
3684 * it needs to wait 4 seconds to get the stable status.
3687 * Pointer to interrupt handle.
3689 * The address of parameter (struct rte_eth_dev *) regsitered before.
3695 ixgbe_dev_interrupt_delayed_handler(void *param)
3697 struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
3698 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
3699 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
3700 struct ixgbe_interrupt *intr =
3701 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
3702 struct ixgbe_hw *hw =
3703 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3706 eicr = IXGBE_READ_REG(hw, IXGBE_EICR);
3707 if (eicr & IXGBE_EICR_MAILBOX)
3708 ixgbe_pf_mbx_process(dev);
3710 if (intr->flags & IXGBE_FLAG_PHY_INTERRUPT) {
3711 ixgbe_handle_lasi(hw);
3712 intr->flags &= ~IXGBE_FLAG_PHY_INTERRUPT;
3715 if (intr->flags & IXGBE_FLAG_NEED_LINK_UPDATE) {
3716 ixgbe_dev_link_update(dev, 0);
3717 intr->flags &= ~IXGBE_FLAG_NEED_LINK_UPDATE;
3718 ixgbe_dev_link_status_print(dev);
3719 _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
3722 if (intr->flags & IXGBE_FLAG_MACSEC) {
3723 _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_MACSEC,
3725 intr->flags &= ~IXGBE_FLAG_MACSEC;
3728 PMD_DRV_LOG(DEBUG, "enable intr in delayed handler S[%08x]", eicr);
3729 ixgbe_enable_intr(dev);
3730 rte_intr_enable(intr_handle);
3734 * Interrupt handler triggered by NIC for handling
3735 * specific interrupt.
3738 * Pointer to interrupt handle.
3740 * The address of parameter (struct rte_eth_dev *) regsitered before.
3746 ixgbe_dev_interrupt_handler(struct rte_intr_handle *handle,
3749 struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
3751 ixgbe_dev_interrupt_get_status(dev);
3752 ixgbe_dev_interrupt_action(dev, handle);
3756 ixgbe_dev_led_on(struct rte_eth_dev *dev)
3758 struct ixgbe_hw *hw;
3760 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3761 return ixgbe_led_on(hw, 0) == IXGBE_SUCCESS ? 0 : -ENOTSUP;
3765 ixgbe_dev_led_off(struct rte_eth_dev *dev)
3767 struct ixgbe_hw *hw;
3769 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3770 return ixgbe_led_off(hw, 0) == IXGBE_SUCCESS ? 0 : -ENOTSUP;
3774 ixgbe_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
3776 struct ixgbe_hw *hw;
3782 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3784 fc_conf->pause_time = hw->fc.pause_time;
3785 fc_conf->high_water = hw->fc.high_water[0];
3786 fc_conf->low_water = hw->fc.low_water[0];
3787 fc_conf->send_xon = hw->fc.send_xon;
3788 fc_conf->autoneg = !hw->fc.disable_fc_autoneg;
3791 * Return rx_pause status according to actual setting of
3794 mflcn_reg = IXGBE_READ_REG(hw, IXGBE_MFLCN);
3795 if (mflcn_reg & (IXGBE_MFLCN_RPFCE | IXGBE_MFLCN_RFCE))
3801 * Return tx_pause status according to actual setting of
3804 fccfg_reg = IXGBE_READ_REG(hw, IXGBE_FCCFG);
3805 if (fccfg_reg & (IXGBE_FCCFG_TFCE_802_3X | IXGBE_FCCFG_TFCE_PRIORITY))
3810 if (rx_pause && tx_pause)
3811 fc_conf->mode = RTE_FC_FULL;
3813 fc_conf->mode = RTE_FC_RX_PAUSE;
3815 fc_conf->mode = RTE_FC_TX_PAUSE;
3817 fc_conf->mode = RTE_FC_NONE;
3823 ixgbe_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
3825 struct ixgbe_hw *hw;
3827 uint32_t rx_buf_size;
3828 uint32_t max_high_water;
3830 enum ixgbe_fc_mode rte_fcmode_2_ixgbe_fcmode[] = {
3837 PMD_INIT_FUNC_TRACE();
3839 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3840 rx_buf_size = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(0));
3841 PMD_INIT_LOG(DEBUG, "Rx packet buffer size = 0x%x", rx_buf_size);
3844 * At least reserve one Ethernet frame for watermark
3845 * high_water/low_water in kilo bytes for ixgbe
3847 max_high_water = (rx_buf_size - ETHER_MAX_LEN) >> IXGBE_RXPBSIZE_SHIFT;
3848 if ((fc_conf->high_water > max_high_water) ||
3849 (fc_conf->high_water < fc_conf->low_water)) {
3850 PMD_INIT_LOG(ERR, "Invalid high/low water setup value in KB");
3851 PMD_INIT_LOG(ERR, "High_water must <= 0x%x", max_high_water);
3855 hw->fc.requested_mode = rte_fcmode_2_ixgbe_fcmode[fc_conf->mode];
3856 hw->fc.pause_time = fc_conf->pause_time;
3857 hw->fc.high_water[0] = fc_conf->high_water;
3858 hw->fc.low_water[0] = fc_conf->low_water;
3859 hw->fc.send_xon = fc_conf->send_xon;
3860 hw->fc.disable_fc_autoneg = !fc_conf->autoneg;
3862 err = ixgbe_fc_enable(hw);
3864 /* Not negotiated is not an error case */
3865 if ((err == IXGBE_SUCCESS) || (err == IXGBE_ERR_FC_NOT_NEGOTIATED)) {
3867 /* check if we want to forward MAC frames - driver doesn't have native
3868 * capability to do that, so we'll write the registers ourselves */
3870 mflcn = IXGBE_READ_REG(hw, IXGBE_MFLCN);
3872 /* set or clear MFLCN.PMCF bit depending on configuration */
3873 if (fc_conf->mac_ctrl_frame_fwd != 0)
3874 mflcn |= IXGBE_MFLCN_PMCF;
3876 mflcn &= ~IXGBE_MFLCN_PMCF;
3878 IXGBE_WRITE_REG(hw, IXGBE_MFLCN, mflcn);
3879 IXGBE_WRITE_FLUSH(hw);
3884 PMD_INIT_LOG(ERR, "ixgbe_fc_enable = 0x%x", err);
3889 * ixgbe_pfc_enable_generic - Enable flow control
3890 * @hw: pointer to hardware structure
3891 * @tc_num: traffic class number
3892 * Enable flow control according to the current settings.
3895 ixgbe_dcb_pfc_enable_generic(struct ixgbe_hw *hw, uint8_t tc_num)
3898 uint32_t mflcn_reg, fccfg_reg;
3900 uint32_t fcrtl, fcrth;
3904 /* Validate the water mark configuration */
3905 if (!hw->fc.pause_time) {
3906 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
3910 /* Low water mark of zero causes XOFF floods */
3911 if (hw->fc.current_mode & ixgbe_fc_tx_pause) {
3912 /* High/Low water can not be 0 */
3913 if ((!hw->fc.high_water[tc_num]) || (!hw->fc.low_water[tc_num])) {
3914 PMD_INIT_LOG(ERR, "Invalid water mark configuration");
3915 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
3919 if (hw->fc.low_water[tc_num] >= hw->fc.high_water[tc_num]) {
3920 PMD_INIT_LOG(ERR, "Invalid water mark configuration");
3921 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
3925 /* Negotiate the fc mode to use */
3926 ixgbe_fc_autoneg(hw);
3928 /* Disable any previous flow control settings */
3929 mflcn_reg = IXGBE_READ_REG(hw, IXGBE_MFLCN);
3930 mflcn_reg &= ~(IXGBE_MFLCN_RPFCE_SHIFT | IXGBE_MFLCN_RFCE|IXGBE_MFLCN_RPFCE);
3932 fccfg_reg = IXGBE_READ_REG(hw, IXGBE_FCCFG);
3933 fccfg_reg &= ~(IXGBE_FCCFG_TFCE_802_3X | IXGBE_FCCFG_TFCE_PRIORITY);
3935 switch (hw->fc.current_mode) {
3938 * If the count of enabled RX Priority Flow control >1,
3939 * and the TX pause can not be disabled
3942 for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
3943 reg = IXGBE_READ_REG(hw, IXGBE_FCRTH_82599(i));
3944 if (reg & IXGBE_FCRTH_FCEN)
3948 fccfg_reg |= IXGBE_FCCFG_TFCE_PRIORITY;
3950 case ixgbe_fc_rx_pause:
3952 * Rx Flow control is enabled and Tx Flow control is
3953 * disabled by software override. Since there really
3954 * isn't a way to advertise that we are capable of RX
3955 * Pause ONLY, we will advertise that we support both
3956 * symmetric and asymmetric Rx PAUSE. Later, we will
3957 * disable the adapter's ability to send PAUSE frames.
3959 mflcn_reg |= IXGBE_MFLCN_RPFCE;
3961 * If the count of enabled RX Priority Flow control >1,
3962 * and the TX pause can not be disabled
3965 for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
3966 reg = IXGBE_READ_REG(hw, IXGBE_FCRTH_82599(i));
3967 if (reg & IXGBE_FCRTH_FCEN)
3971 fccfg_reg |= IXGBE_FCCFG_TFCE_PRIORITY;
3973 case ixgbe_fc_tx_pause:
3975 * Tx Flow control is enabled, and Rx Flow control is
3976 * disabled by software override.
3978 fccfg_reg |= IXGBE_FCCFG_TFCE_PRIORITY;
3981 /* Flow control (both Rx and Tx) is enabled by SW override. */
3982 mflcn_reg |= IXGBE_MFLCN_RPFCE;
3983 fccfg_reg |= IXGBE_FCCFG_TFCE_PRIORITY;
3986 PMD_DRV_LOG(DEBUG, "Flow control param set incorrectly");
3987 ret_val = IXGBE_ERR_CONFIG;
3991 /* Set 802.3x based flow control settings. */
3992 mflcn_reg |= IXGBE_MFLCN_DPF;
3993 IXGBE_WRITE_REG(hw, IXGBE_MFLCN, mflcn_reg);
3994 IXGBE_WRITE_REG(hw, IXGBE_FCCFG, fccfg_reg);
3996 /* Set up and enable Rx high/low water mark thresholds, enable XON. */
3997 if ((hw->fc.current_mode & ixgbe_fc_tx_pause) &&
3998 hw->fc.high_water[tc_num]) {
3999 fcrtl = (hw->fc.low_water[tc_num] << 10) | IXGBE_FCRTL_XONE;
4000 IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(tc_num), fcrtl);
4001 fcrth = (hw->fc.high_water[tc_num] << 10) | IXGBE_FCRTH_FCEN;
4003 IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(tc_num), 0);
4005 * In order to prevent Tx hangs when the internal Tx
4006 * switch is enabled we must set the high water mark
4007 * to the maximum FCRTH value. This allows the Tx
4008 * switch to function even under heavy Rx workloads.
4010 fcrth = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(tc_num)) - 32;
4012 IXGBE_WRITE_REG(hw, IXGBE_FCRTH_82599(tc_num), fcrth);
4014 /* Configure pause time (2 TCs per register) */
4015 reg = hw->fc.pause_time * 0x00010001;
4016 for (i = 0; i < (IXGBE_DCB_MAX_TRAFFIC_CLASS / 2); i++)
4017 IXGBE_WRITE_REG(hw, IXGBE_FCTTV(i), reg);
4019 /* Configure flow control refresh threshold value */
4020 IXGBE_WRITE_REG(hw, IXGBE_FCRTV, hw->fc.pause_time / 2);
4027 ixgbe_dcb_pfc_enable(struct rte_eth_dev *dev, uint8_t tc_num)
4029 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4030 int32_t ret_val = IXGBE_NOT_IMPLEMENTED;
4032 if (hw->mac.type != ixgbe_mac_82598EB) {
4033 ret_val = ixgbe_dcb_pfc_enable_generic(hw, tc_num);
4039 ixgbe_priority_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_pfc_conf *pfc_conf)
4042 uint32_t rx_buf_size;
4043 uint32_t max_high_water;
4045 uint8_t map[IXGBE_DCB_MAX_USER_PRIORITY] = { 0 };
4046 struct ixgbe_hw *hw =
4047 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4048 struct ixgbe_dcb_config *dcb_config =
4049 IXGBE_DEV_PRIVATE_TO_DCB_CFG(dev->data->dev_private);
4051 enum ixgbe_fc_mode rte_fcmode_2_ixgbe_fcmode[] = {
4058 PMD_INIT_FUNC_TRACE();
4060 ixgbe_dcb_unpack_map_cee(dcb_config, IXGBE_DCB_RX_CONFIG, map);
4061 tc_num = map[pfc_conf->priority];
4062 rx_buf_size = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(tc_num));
4063 PMD_INIT_LOG(DEBUG, "Rx packet buffer size = 0x%x", rx_buf_size);
4065 * At least reserve one Ethernet frame for watermark
4066 * high_water/low_water in kilo bytes for ixgbe
4068 max_high_water = (rx_buf_size - ETHER_MAX_LEN) >> IXGBE_RXPBSIZE_SHIFT;
4069 if ((pfc_conf->fc.high_water > max_high_water) ||
4070 (pfc_conf->fc.high_water <= pfc_conf->fc.low_water)) {
4071 PMD_INIT_LOG(ERR, "Invalid high/low water setup value in KB");
4072 PMD_INIT_LOG(ERR, "High_water must <= 0x%x", max_high_water);
4076 hw->fc.requested_mode = rte_fcmode_2_ixgbe_fcmode[pfc_conf->fc.mode];
4077 hw->fc.pause_time = pfc_conf->fc.pause_time;
4078 hw->fc.send_xon = pfc_conf->fc.send_xon;
4079 hw->fc.low_water[tc_num] = pfc_conf->fc.low_water;
4080 hw->fc.high_water[tc_num] = pfc_conf->fc.high_water;
4082 err = ixgbe_dcb_pfc_enable(dev, tc_num);
4084 /* Not negotiated is not an error case */
4085 if ((err == IXGBE_SUCCESS) || (err == IXGBE_ERR_FC_NOT_NEGOTIATED))
4088 PMD_INIT_LOG(ERR, "ixgbe_dcb_pfc_enable = 0x%x", err);
4093 ixgbe_dev_rss_reta_update(struct rte_eth_dev *dev,
4094 struct rte_eth_rss_reta_entry64 *reta_conf,
4097 uint16_t i, sp_reta_size;
4100 uint16_t idx, shift;
4101 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4104 PMD_INIT_FUNC_TRACE();
4106 if (!ixgbe_rss_update_sp(hw->mac.type)) {
4107 PMD_DRV_LOG(ERR, "RSS reta update is not supported on this "
4112 sp_reta_size = ixgbe_reta_size_get(hw->mac.type);
4113 if (reta_size != sp_reta_size) {
4114 PMD_DRV_LOG(ERR, "The size of hash lookup table configured "
4115 "(%d) doesn't match the number hardware can supported "
4116 "(%d)\n", reta_size, sp_reta_size);
4120 for (i = 0; i < reta_size; i += IXGBE_4_BIT_WIDTH) {
4121 idx = i / RTE_RETA_GROUP_SIZE;
4122 shift = i % RTE_RETA_GROUP_SIZE;
4123 mask = (uint8_t)((reta_conf[idx].mask >> shift) &
4127 reta_reg = ixgbe_reta_reg_get(hw->mac.type, i);
4128 if (mask == IXGBE_4_BIT_MASK)
4131 r = IXGBE_READ_REG(hw, reta_reg);
4132 for (j = 0, reta = 0; j < IXGBE_4_BIT_WIDTH; j++) {
4133 if (mask & (0x1 << j))
4134 reta |= reta_conf[idx].reta[shift + j] <<
4137 reta |= r & (IXGBE_8_BIT_MASK <<
4140 IXGBE_WRITE_REG(hw, reta_reg, reta);
4147 ixgbe_dev_rss_reta_query(struct rte_eth_dev *dev,
4148 struct rte_eth_rss_reta_entry64 *reta_conf,
4151 uint16_t i, sp_reta_size;
4154 uint16_t idx, shift;
4155 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4158 PMD_INIT_FUNC_TRACE();
4159 sp_reta_size = ixgbe_reta_size_get(hw->mac.type);
4160 if (reta_size != sp_reta_size) {
4161 PMD_DRV_LOG(ERR, "The size of hash lookup table configured "
4162 "(%d) doesn't match the number hardware can supported "
4163 "(%d)\n", reta_size, sp_reta_size);
4167 for (i = 0; i < reta_size; i += IXGBE_4_BIT_WIDTH) {
4168 idx = i / RTE_RETA_GROUP_SIZE;
4169 shift = i % RTE_RETA_GROUP_SIZE;
4170 mask = (uint8_t)((reta_conf[idx].mask >> shift) &
4175 reta_reg = ixgbe_reta_reg_get(hw->mac.type, i);
4176 reta = IXGBE_READ_REG(hw, reta_reg);
4177 for (j = 0; j < IXGBE_4_BIT_WIDTH; j++) {
4178 if (mask & (0x1 << j))
4179 reta_conf[idx].reta[shift + j] =
4180 ((reta >> (CHAR_BIT * j)) &
4189 ixgbe_add_rar(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
4190 uint32_t index, uint32_t pool)
4192 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4193 uint32_t enable_addr = 1;
4195 ixgbe_set_rar(hw, index, mac_addr->addr_bytes, pool, enable_addr);
4199 ixgbe_remove_rar(struct rte_eth_dev *dev, uint32_t index)
4201 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4203 ixgbe_clear_rar(hw, index);
4207 ixgbe_set_default_mac_addr(struct rte_eth_dev *dev, struct ether_addr *addr)
4209 ixgbe_remove_rar(dev, 0);
4211 ixgbe_add_rar(dev, addr, 0, 0);
4215 rte_pmd_ixgbe_set_vf_mac_addr(uint8_t port, uint16_t vf,
4216 struct ether_addr *mac_addr)
4218 struct ixgbe_hw *hw;
4219 struct ixgbe_vf_info *vfinfo;
4221 uint8_t *new_mac = (uint8_t *)(mac_addr);
4222 struct rte_eth_dev *dev;
4223 struct rte_eth_dev_info dev_info;
4225 RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
4227 dev = &rte_eth_devices[port];
4228 rte_eth_dev_info_get(port, &dev_info);
4230 if (vf >= dev_info.max_vfs)
4233 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4234 vfinfo = *(IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private));
4235 rar_entry = hw->mac.num_rar_entries - (vf + 1);
4237 if (is_valid_assigned_ether_addr((struct ether_addr *)new_mac)) {
4238 rte_memcpy(vfinfo[vf].vf_mac_addresses, new_mac,
4240 return hw->mac.ops.set_rar(hw, rar_entry, new_mac, vf,
4247 ixgbe_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
4251 struct ixgbe_hw *hw;
4252 struct rte_eth_dev_info dev_info;
4253 uint32_t frame_size = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
4255 ixgbe_dev_info_get(dev, &dev_info);
4257 /* check that mtu is within the allowed range */
4258 if ((mtu < ETHER_MIN_MTU) || (frame_size > dev_info.max_rx_pktlen))
4261 /* refuse mtu that requires the support of scattered packets when this
4262 * feature has not been enabled before.
4264 if (!dev->data->scattered_rx &&
4265 (frame_size + 2 * IXGBE_VLAN_TAG_SIZE >
4266 dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM))
4269 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4270 hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
4272 /* switch to jumbo mode if needed */
4273 if (frame_size > ETHER_MAX_LEN) {
4274 dev->data->dev_conf.rxmode.jumbo_frame = 1;
4275 hlreg0 |= IXGBE_HLREG0_JUMBOEN;
4277 dev->data->dev_conf.rxmode.jumbo_frame = 0;
4278 hlreg0 &= ~IXGBE_HLREG0_JUMBOEN;
4280 IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
4282 /* update max frame size */
4283 dev->data->dev_conf.rxmode.max_rx_pkt_len = frame_size;
4285 maxfrs = IXGBE_READ_REG(hw, IXGBE_MAXFRS);
4286 maxfrs &= 0x0000FFFF;
4287 maxfrs |= (dev->data->dev_conf.rxmode.max_rx_pkt_len << 16);
4288 IXGBE_WRITE_REG(hw, IXGBE_MAXFRS, maxfrs);
4294 * Virtual Function operations
4297 ixgbevf_intr_disable(struct ixgbe_hw *hw)
4299 PMD_INIT_FUNC_TRACE();
4301 /* Clear interrupt mask to stop from interrupts being generated */
4302 IXGBE_WRITE_REG(hw, IXGBE_VTEIMC, IXGBE_VF_IRQ_CLEAR_MASK);
4304 IXGBE_WRITE_FLUSH(hw);
4308 ixgbevf_intr_enable(struct ixgbe_hw *hw)
4310 PMD_INIT_FUNC_TRACE();
4312 /* VF enable interrupt autoclean */
4313 IXGBE_WRITE_REG(hw, IXGBE_VTEIAM, IXGBE_VF_IRQ_ENABLE_MASK);
4314 IXGBE_WRITE_REG(hw, IXGBE_VTEIAC, IXGBE_VF_IRQ_ENABLE_MASK);
4315 IXGBE_WRITE_REG(hw, IXGBE_VTEIMS, IXGBE_VF_IRQ_ENABLE_MASK);
4317 IXGBE_WRITE_FLUSH(hw);
4321 ixgbevf_dev_configure(struct rte_eth_dev *dev)
4323 struct rte_eth_conf *conf = &dev->data->dev_conf;
4324 struct ixgbe_adapter *adapter =
4325 (struct ixgbe_adapter *)dev->data->dev_private;
4327 PMD_INIT_LOG(DEBUG, "Configured Virtual Function port id: %d",
4328 dev->data->port_id);
4331 * VF has no ability to enable/disable HW CRC
4332 * Keep the persistent behavior the same as Host PF
4334 #ifndef RTE_LIBRTE_IXGBE_PF_DISABLE_STRIP_CRC
4335 if (!conf->rxmode.hw_strip_crc) {
4336 PMD_INIT_LOG(NOTICE, "VF can't disable HW CRC Strip");
4337 conf->rxmode.hw_strip_crc = 1;
4340 if (conf->rxmode.hw_strip_crc) {
4341 PMD_INIT_LOG(NOTICE, "VF can't enable HW CRC Strip");
4342 conf->rxmode.hw_strip_crc = 0;
4347 * Initialize to TRUE. If any of Rx queues doesn't meet the bulk
4348 * allocation or vector Rx preconditions we will reset it.
4350 adapter->rx_bulk_alloc_allowed = true;
4351 adapter->rx_vec_allowed = true;
4357 ixgbevf_dev_start(struct rte_eth_dev *dev)
4359 struct ixgbe_hw *hw =
4360 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4361 uint32_t intr_vector = 0;
4362 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
4363 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
4367 PMD_INIT_FUNC_TRACE();
4369 hw->mac.ops.reset_hw(hw);
4370 hw->mac.get_link_status = true;
4372 /* negotiate mailbox API version to use with the PF. */
4373 ixgbevf_negotiate_api(hw);
4375 ixgbevf_dev_tx_init(dev);
4377 /* This can fail when allocating mbufs for descriptor rings */
4378 err = ixgbevf_dev_rx_init(dev);
4380 PMD_INIT_LOG(ERR, "Unable to initialize RX hardware (%d)", err);
4381 ixgbe_dev_clear_queues(dev);
4386 ixgbevf_set_vfta_all(dev, 1);
4389 mask = ETH_VLAN_STRIP_MASK | ETH_VLAN_FILTER_MASK |
4390 ETH_VLAN_EXTEND_MASK;
4391 ixgbevf_vlan_offload_set(dev, mask);
4393 ixgbevf_dev_rxtx_start(dev);
4395 /* check and configure queue intr-vector mapping */
4396 if (dev->data->dev_conf.intr_conf.rxq != 0) {
4397 intr_vector = dev->data->nb_rx_queues;
4398 if (rte_intr_efd_enable(intr_handle, intr_vector))
4402 if (rte_intr_dp_is_en(intr_handle) && !intr_handle->intr_vec) {
4403 intr_handle->intr_vec =
4404 rte_zmalloc("intr_vec",
4405 dev->data->nb_rx_queues * sizeof(int), 0);
4406 if (intr_handle->intr_vec == NULL) {
4407 PMD_INIT_LOG(ERR, "Failed to allocate %d rx_queues"
4408 " intr_vec\n", dev->data->nb_rx_queues);
4412 ixgbevf_configure_msix(dev);
4414 rte_intr_enable(intr_handle);
4416 /* Re-enable interrupt for VF */
4417 ixgbevf_intr_enable(hw);
4423 ixgbevf_dev_stop(struct rte_eth_dev *dev)
4425 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4426 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
4427 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
4429 PMD_INIT_FUNC_TRACE();
4431 ixgbevf_intr_disable(hw);
4433 hw->adapter_stopped = 1;
4434 ixgbe_stop_adapter(hw);
4437 * Clear what we set, but we still keep shadow_vfta to
4438 * restore after device starts
4440 ixgbevf_set_vfta_all(dev, 0);
4442 /* Clear stored conf */
4443 dev->data->scattered_rx = 0;
4445 ixgbe_dev_clear_queues(dev);
4447 /* Clean datapath event and queue/vec mapping */
4448 rte_intr_efd_disable(intr_handle);
4449 if (intr_handle->intr_vec != NULL) {
4450 rte_free(intr_handle->intr_vec);
4451 intr_handle->intr_vec = NULL;
4456 ixgbevf_dev_close(struct rte_eth_dev *dev)
4458 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4460 PMD_INIT_FUNC_TRACE();
4464 ixgbevf_dev_stop(dev);
4466 ixgbe_dev_free_queues(dev);
4469 * Remove the VF MAC address ro ensure
4470 * that the VF traffic goes to the PF
4471 * after stop, close and detach of the VF
4473 ixgbevf_remove_mac_addr(dev, 0);
4476 static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on)
4478 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4479 struct ixgbe_vfta *shadow_vfta =
4480 IXGBE_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
4481 int i = 0, j = 0, vfta = 0, mask = 1;
4483 for (i = 0; i < IXGBE_VFTA_SIZE; i++) {
4484 vfta = shadow_vfta->vfta[i];
4487 for (j = 0; j < 32; j++) {
4489 ixgbe_set_vfta(hw, (i<<5)+j, 0,
4499 ixgbevf_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
4501 struct ixgbe_hw *hw =
4502 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4503 struct ixgbe_vfta *shadow_vfta =
4504 IXGBE_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
4505 uint32_t vid_idx = 0;
4506 uint32_t vid_bit = 0;
4509 PMD_INIT_FUNC_TRACE();
4511 /* vind is not used in VF driver, set to 0, check ixgbe_set_vfta_vf */
4512 ret = ixgbe_set_vfta(hw, vlan_id, 0, !!on, false);
4514 PMD_INIT_LOG(ERR, "Unable to set VF vlan");
4517 vid_idx = (uint32_t) ((vlan_id >> 5) & 0x7F);
4518 vid_bit = (uint32_t) (1 << (vlan_id & 0x1F));
4520 /* Save what we set and retore it after device reset */
4522 shadow_vfta->vfta[vid_idx] |= vid_bit;
4524 shadow_vfta->vfta[vid_idx] &= ~vid_bit;
4530 ixgbevf_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue, int on)
4532 struct ixgbe_hw *hw =
4533 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4536 PMD_INIT_FUNC_TRACE();
4538 if (queue >= hw->mac.max_rx_queues)
4541 ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(queue));
4543 ctrl |= IXGBE_RXDCTL_VME;
4545 ctrl &= ~IXGBE_RXDCTL_VME;
4546 IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(queue), ctrl);
4548 ixgbe_vlan_hw_strip_bitmap_set(dev, queue, on);
4552 ixgbevf_vlan_offload_set(struct rte_eth_dev *dev, int mask)
4554 struct ixgbe_hw *hw =
4555 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4559 /* VF function only support hw strip feature, others are not support */
4560 if (mask & ETH_VLAN_STRIP_MASK) {
4561 on = !!(dev->data->dev_conf.rxmode.hw_vlan_strip);
4563 for (i = 0; i < hw->mac.max_rx_queues; i++)
4564 ixgbevf_vlan_strip_queue_set(dev, i, on);
4569 ixgbe_vmdq_mode_check(struct ixgbe_hw *hw)
4573 /* we only need to do this if VMDq is enabled */
4574 reg_val = IXGBE_READ_REG(hw, IXGBE_VT_CTL);
4575 if (!(reg_val & IXGBE_VT_CTL_VT_ENABLE)) {
4576 PMD_INIT_LOG(ERR, "VMDq must be enabled for this setting");
4584 ixgbe_uta_vector(struct ixgbe_hw *hw, struct ether_addr *uc_addr)
4586 uint32_t vector = 0;
4588 switch (hw->mac.mc_filter_type) {
4589 case 0: /* use bits [47:36] of the address */
4590 vector = ((uc_addr->addr_bytes[4] >> 4) |
4591 (((uint16_t)uc_addr->addr_bytes[5]) << 4));
4593 case 1: /* use bits [46:35] of the address */
4594 vector = ((uc_addr->addr_bytes[4] >> 3) |
4595 (((uint16_t)uc_addr->addr_bytes[5]) << 5));
4597 case 2: /* use bits [45:34] of the address */
4598 vector = ((uc_addr->addr_bytes[4] >> 2) |
4599 (((uint16_t)uc_addr->addr_bytes[5]) << 6));
4601 case 3: /* use bits [43:32] of the address */
4602 vector = ((uc_addr->addr_bytes[4]) |
4603 (((uint16_t)uc_addr->addr_bytes[5]) << 8));
4605 default: /* Invalid mc_filter_type */
4609 /* vector can only be 12-bits or boundary will be exceeded */
4615 ixgbe_uc_hash_table_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
4623 const uint32_t ixgbe_uta_idx_mask = 0x7F;
4624 const uint32_t ixgbe_uta_bit_shift = 5;
4625 const uint32_t ixgbe_uta_bit_mask = (0x1 << ixgbe_uta_bit_shift) - 1;
4626 const uint32_t bit1 = 0x1;
4628 struct ixgbe_hw *hw =
4629 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4630 struct ixgbe_uta_info *uta_info =
4631 IXGBE_DEV_PRIVATE_TO_UTA(dev->data->dev_private);
4633 /* The UTA table only exists on 82599 hardware and newer */
4634 if (hw->mac.type < ixgbe_mac_82599EB)
4637 vector = ixgbe_uta_vector(hw, mac_addr);
4638 uta_idx = (vector >> ixgbe_uta_bit_shift) & ixgbe_uta_idx_mask;
4639 uta_shift = vector & ixgbe_uta_bit_mask;
4641 rc = ((uta_info->uta_shadow[uta_idx] >> uta_shift & bit1) != 0);
4645 reg_val = IXGBE_READ_REG(hw, IXGBE_UTA(uta_idx));
4647 uta_info->uta_in_use++;
4648 reg_val |= (bit1 << uta_shift);
4649 uta_info->uta_shadow[uta_idx] |= (bit1 << uta_shift);
4651 uta_info->uta_in_use--;
4652 reg_val &= ~(bit1 << uta_shift);
4653 uta_info->uta_shadow[uta_idx] &= ~(bit1 << uta_shift);
4656 IXGBE_WRITE_REG(hw, IXGBE_UTA(uta_idx), reg_val);
4658 if (uta_info->uta_in_use > 0)
4659 IXGBE_WRITE_REG(hw, IXGBE_MCSTCTRL,
4660 IXGBE_MCSTCTRL_MFE | hw->mac.mc_filter_type);
4662 IXGBE_WRITE_REG(hw, IXGBE_MCSTCTRL, hw->mac.mc_filter_type);
4668 ixgbe_uc_all_hash_table_set(struct rte_eth_dev *dev, uint8_t on)
4671 struct ixgbe_hw *hw =
4672 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4673 struct ixgbe_uta_info *uta_info =
4674 IXGBE_DEV_PRIVATE_TO_UTA(dev->data->dev_private);
4676 /* The UTA table only exists on 82599 hardware and newer */
4677 if (hw->mac.type < ixgbe_mac_82599EB)
4681 for (i = 0; i < ETH_VMDQ_NUM_UC_HASH_ARRAY; i++) {
4682 uta_info->uta_shadow[i] = ~0;
4683 IXGBE_WRITE_REG(hw, IXGBE_UTA(i), ~0);
4686 for (i = 0; i < ETH_VMDQ_NUM_UC_HASH_ARRAY; i++) {
4687 uta_info->uta_shadow[i] = 0;
4688 IXGBE_WRITE_REG(hw, IXGBE_UTA(i), 0);
4696 ixgbe_convert_vm_rx_mask_to_val(uint16_t rx_mask, uint32_t orig_val)
4698 uint32_t new_val = orig_val;
4700 if (rx_mask & ETH_VMDQ_ACCEPT_UNTAG)
4701 new_val |= IXGBE_VMOLR_AUPE;
4702 if (rx_mask & ETH_VMDQ_ACCEPT_HASH_MC)
4703 new_val |= IXGBE_VMOLR_ROMPE;
4704 if (rx_mask & ETH_VMDQ_ACCEPT_HASH_UC)
4705 new_val |= IXGBE_VMOLR_ROPE;
4706 if (rx_mask & ETH_VMDQ_ACCEPT_BROADCAST)
4707 new_val |= IXGBE_VMOLR_BAM;
4708 if (rx_mask & ETH_VMDQ_ACCEPT_MULTICAST)
4709 new_val |= IXGBE_VMOLR_MPE;
4715 ixgbe_set_pool_rx_mode(struct rte_eth_dev *dev, uint16_t pool,
4716 uint16_t rx_mask, uint8_t on)
4720 struct ixgbe_hw *hw =
4721 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4722 uint32_t vmolr = IXGBE_READ_REG(hw, IXGBE_VMOLR(pool));
4724 if (hw->mac.type == ixgbe_mac_82598EB) {
4725 PMD_INIT_LOG(ERR, "setting VF receive mode set should be done"
4726 " on 82599 hardware and newer");
4729 if (ixgbe_vmdq_mode_check(hw) < 0)
4732 val = ixgbe_convert_vm_rx_mask_to_val(rx_mask, val);
4739 IXGBE_WRITE_REG(hw, IXGBE_VMOLR(pool), vmolr);
4745 ixgbe_set_pool_rx(struct rte_eth_dev *dev, uint16_t pool, uint8_t on)
4749 const uint8_t bit1 = 0x1;
4751 struct ixgbe_hw *hw =
4752 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4754 if (ixgbe_vmdq_mode_check(hw) < 0)
4757 if (pool >= ETH_64_POOLS)
4760 /* for pool >= 32, set bit in PFVFRE[1], otherwise PFVFRE[0] */
4762 addr = IXGBE_VFRE(1);
4763 val = bit1 << (pool - 32);
4765 addr = IXGBE_VFRE(0);
4769 reg = IXGBE_READ_REG(hw, addr);
4776 IXGBE_WRITE_REG(hw, addr, reg);
4782 ixgbe_set_pool_tx(struct rte_eth_dev *dev, uint16_t pool, uint8_t on)
4786 const uint8_t bit1 = 0x1;
4788 struct ixgbe_hw *hw =
4789 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4791 if (ixgbe_vmdq_mode_check(hw) < 0)
4794 if (pool >= ETH_64_POOLS)
4797 /* for pool >= 32, set bit in PFVFTE[1], otherwise PFVFTE[0] */
4799 addr = IXGBE_VFTE(1);
4800 val = bit1 << (pool - 32);
4802 addr = IXGBE_VFTE(0);
4806 reg = IXGBE_READ_REG(hw, addr);
4813 IXGBE_WRITE_REG(hw, addr, reg);
4819 ixgbe_set_pool_vlan_filter(struct rte_eth_dev *dev, uint16_t vlan,
4820 uint64_t pool_mask, uint8_t vlan_on)
4824 struct ixgbe_hw *hw =
4825 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4827 if (ixgbe_vmdq_mode_check(hw) < 0)
4829 for (pool_idx = 0; pool_idx < ETH_64_POOLS; pool_idx++) {
4830 if (pool_mask & ((uint64_t)(1ULL << pool_idx))) {
4831 ret = hw->mac.ops.set_vfta(hw, vlan, pool_idx,
4842 rte_pmd_ixgbe_set_vf_vlan_anti_spoof(uint8_t port, uint16_t vf, uint8_t on)
4844 struct ixgbe_hw *hw;
4845 struct ixgbe_mac_info *mac;
4846 struct rte_eth_dev *dev;
4847 struct rte_eth_dev_info dev_info;
4849 RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
4851 dev = &rte_eth_devices[port];
4852 rte_eth_dev_info_get(port, &dev_info);
4854 if (vf >= dev_info.max_vfs)
4860 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4863 mac->ops.set_vlan_anti_spoofing(hw, on, vf);
4869 rte_pmd_ixgbe_set_vf_mac_anti_spoof(uint8_t port, uint16_t vf, uint8_t on)
4871 struct ixgbe_hw *hw;
4872 struct ixgbe_mac_info *mac;
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 (vf >= dev_info.max_vfs)
4887 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4889 mac->ops.set_mac_anti_spoofing(hw, on, vf);
4895 rte_pmd_ixgbe_set_vf_vlan_insert(uint8_t port, uint16_t vf, uint16_t vlan_id)
4897 struct ixgbe_hw *hw;
4899 struct rte_eth_dev *dev;
4900 struct rte_eth_dev_info dev_info;
4902 RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
4904 dev = &rte_eth_devices[port];
4905 rte_eth_dev_info_get(port, &dev_info);
4907 if (vf >= dev_info.max_vfs)
4913 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4914 ctrl = IXGBE_READ_REG(hw, IXGBE_VMVIR(vf));
4917 ctrl |= IXGBE_VMVIR_VLANA_DEFAULT;
4922 IXGBE_WRITE_REG(hw, IXGBE_VMVIR(vf), ctrl);
4928 rte_pmd_ixgbe_set_tx_loopback(uint8_t port, uint8_t on)
4930 struct ixgbe_hw *hw;
4932 struct rte_eth_dev *dev;
4934 RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
4936 dev = &rte_eth_devices[port];
4941 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4942 ctrl = IXGBE_READ_REG(hw, IXGBE_PFDTXGSWC);
4943 /* enable or disable VMDQ loopback */
4945 ctrl |= IXGBE_PFDTXGSWC_VT_LBEN;
4947 ctrl &= ~IXGBE_PFDTXGSWC_VT_LBEN;
4949 IXGBE_WRITE_REG(hw, IXGBE_PFDTXGSWC, ctrl);
4955 rte_pmd_ixgbe_set_all_queues_drop_en(uint8_t port, uint8_t on)
4957 struct ixgbe_hw *hw;
4960 int num_queues = (int)(IXGBE_QDE_IDX_MASK >> IXGBE_QDE_IDX_SHIFT);
4961 struct rte_eth_dev *dev;
4963 RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
4965 dev = &rte_eth_devices[port];
4970 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4971 for (i = 0; i <= num_queues; i++) {
4972 reg_value = IXGBE_QDE_WRITE |
4973 (i << IXGBE_QDE_IDX_SHIFT) |
4974 (on & IXGBE_QDE_ENABLE);
4975 IXGBE_WRITE_REG(hw, IXGBE_QDE, reg_value);
4982 rte_pmd_ixgbe_set_vf_split_drop_en(uint8_t port, uint16_t vf, uint8_t on)
4984 struct ixgbe_hw *hw;
4986 struct rte_eth_dev *dev;
4987 struct rte_eth_dev_info dev_info;
4989 RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
4991 dev = &rte_eth_devices[port];
4992 rte_eth_dev_info_get(port, &dev_info);
4994 /* only support VF's 0 to 63 */
4995 if ((vf >= dev_info.max_vfs) || (vf > 63))
5001 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5002 reg_value = IXGBE_READ_REG(hw, IXGBE_SRRCTL(vf));
5004 reg_value |= IXGBE_SRRCTL_DROP_EN;
5006 reg_value &= ~IXGBE_SRRCTL_DROP_EN;
5008 IXGBE_WRITE_REG(hw, IXGBE_SRRCTL(vf), reg_value);
5014 rte_pmd_ixgbe_set_vf_vlan_stripq(uint8_t port, uint16_t vf, uint8_t on)
5016 struct rte_eth_dev *dev;
5017 struct rte_eth_dev_info dev_info;
5018 uint16_t queues_per_pool;
5021 RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
5023 dev = &rte_eth_devices[port];
5024 rte_eth_dev_info_get(port, &dev_info);
5026 if (vf >= dev_info.max_vfs)
5032 RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_strip_queue_set, -ENOTSUP);
5034 /* The PF has 128 queue pairs and in SRIOV configuration
5035 * those queues will be assigned to VF's, so RXDCTL
5036 * registers will be dealing with queues which will be
5038 * Let's say we have SRIOV configured with 31 VF's then the
5039 * first 124 queues 0-123 will be allocated to VF's and only
5040 * the last 4 queues 123-127 will be assigned to the PF.
5043 queues_per_pool = dev_info.vmdq_queue_num / dev_info.max_vmdq_pools;
5045 for (q = 0; q < queues_per_pool; q++)
5046 (*dev->dev_ops->vlan_strip_queue_set)(dev,
5047 q + vf * queues_per_pool, on);
5051 #define IXGBE_MRCTL_VPME 0x01 /* Virtual Pool Mirroring. */
5052 #define IXGBE_MRCTL_UPME 0x02 /* Uplink Port Mirroring. */
5053 #define IXGBE_MRCTL_DPME 0x04 /* Downlink Port Mirroring. */
5054 #define IXGBE_MRCTL_VLME 0x08 /* VLAN Mirroring. */
5055 #define IXGBE_INVALID_MIRROR_TYPE(mirror_type) \
5056 ((mirror_type) & ~(uint8_t)(ETH_MIRROR_VIRTUAL_POOL_UP | \
5057 ETH_MIRROR_UPLINK_PORT | ETH_MIRROR_DOWNLINK_PORT | ETH_MIRROR_VLAN))
5060 ixgbe_mirror_rule_set(struct rte_eth_dev *dev,
5061 struct rte_eth_mirror_conf *mirror_conf,
5062 uint8_t rule_id, uint8_t on)
5064 uint32_t mr_ctl, vlvf;
5065 uint32_t mp_lsb = 0;
5066 uint32_t mv_msb = 0;
5067 uint32_t mv_lsb = 0;
5068 uint32_t mp_msb = 0;
5071 uint64_t vlan_mask = 0;
5073 const uint8_t pool_mask_offset = 32;
5074 const uint8_t vlan_mask_offset = 32;
5075 const uint8_t dst_pool_offset = 8;
5076 const uint8_t rule_mr_offset = 4;
5077 const uint8_t mirror_rule_mask = 0x0F;
5079 struct ixgbe_mirror_info *mr_info =
5080 (IXGBE_DEV_PRIVATE_TO_PFDATA(dev->data->dev_private));
5081 struct ixgbe_hw *hw =
5082 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5083 uint8_t mirror_type = 0;
5085 if (ixgbe_vmdq_mode_check(hw) < 0)
5088 if (rule_id >= IXGBE_MAX_MIRROR_RULES)
5091 if (IXGBE_INVALID_MIRROR_TYPE(mirror_conf->rule_type)) {
5092 PMD_DRV_LOG(ERR, "unsupported mirror type 0x%x.",
5093 mirror_conf->rule_type);
5097 if (mirror_conf->rule_type & ETH_MIRROR_VLAN) {
5098 mirror_type |= IXGBE_MRCTL_VLME;
5099 /* Check if vlan id is valid and find conresponding VLAN ID index in VLVF */
5100 for (i = 0; i < IXGBE_VLVF_ENTRIES; i++) {
5101 if (mirror_conf->vlan.vlan_mask & (1ULL << i)) {
5102 /* search vlan id related pool vlan filter index */
5103 reg_index = ixgbe_find_vlvf_slot(hw,
5104 mirror_conf->vlan.vlan_id[i],
5108 vlvf = IXGBE_READ_REG(hw, IXGBE_VLVF(reg_index));
5109 if ((vlvf & IXGBE_VLVF_VIEN) &&
5110 ((vlvf & IXGBE_VLVF_VLANID_MASK) ==
5111 mirror_conf->vlan.vlan_id[i]))
5112 vlan_mask |= (1ULL << reg_index);
5119 mv_lsb = vlan_mask & 0xFFFFFFFF;
5120 mv_msb = vlan_mask >> vlan_mask_offset;
5122 mr_info->mr_conf[rule_id].vlan.vlan_mask =
5123 mirror_conf->vlan.vlan_mask;
5124 for (i = 0; i < ETH_VMDQ_MAX_VLAN_FILTERS; i++) {
5125 if (mirror_conf->vlan.vlan_mask & (1ULL << i))
5126 mr_info->mr_conf[rule_id].vlan.vlan_id[i] =
5127 mirror_conf->vlan.vlan_id[i];
5132 mr_info->mr_conf[rule_id].vlan.vlan_mask = 0;
5133 for (i = 0; i < ETH_VMDQ_MAX_VLAN_FILTERS; i++)
5134 mr_info->mr_conf[rule_id].vlan.vlan_id[i] = 0;
5139 * if enable pool mirror, write related pool mask register,if disable
5140 * pool mirror, clear PFMRVM register
5142 if (mirror_conf->rule_type & ETH_MIRROR_VIRTUAL_POOL_UP) {
5143 mirror_type |= IXGBE_MRCTL_VPME;
5145 mp_lsb = mirror_conf->pool_mask & 0xFFFFFFFF;
5146 mp_msb = mirror_conf->pool_mask >> pool_mask_offset;
5147 mr_info->mr_conf[rule_id].pool_mask =
5148 mirror_conf->pool_mask;
5153 mr_info->mr_conf[rule_id].pool_mask = 0;
5156 if (mirror_conf->rule_type & ETH_MIRROR_UPLINK_PORT)
5157 mirror_type |= IXGBE_MRCTL_UPME;
5158 if (mirror_conf->rule_type & ETH_MIRROR_DOWNLINK_PORT)
5159 mirror_type |= IXGBE_MRCTL_DPME;
5161 /* read mirror control register and recalculate it */
5162 mr_ctl = IXGBE_READ_REG(hw, IXGBE_MRCTL(rule_id));
5165 mr_ctl |= mirror_type;
5166 mr_ctl &= mirror_rule_mask;
5167 mr_ctl |= mirror_conf->dst_pool << dst_pool_offset;
5169 mr_ctl &= ~(mirror_conf->rule_type & mirror_rule_mask);
5171 mr_info->mr_conf[rule_id].rule_type = mirror_conf->rule_type;
5172 mr_info->mr_conf[rule_id].dst_pool = mirror_conf->dst_pool;
5174 /* write mirrror control register */
5175 IXGBE_WRITE_REG(hw, IXGBE_MRCTL(rule_id), mr_ctl);
5177 /* write pool mirrror control register */
5178 if (mirror_conf->rule_type == ETH_MIRROR_VIRTUAL_POOL_UP) {
5179 IXGBE_WRITE_REG(hw, IXGBE_VMRVM(rule_id), mp_lsb);
5180 IXGBE_WRITE_REG(hw, IXGBE_VMRVM(rule_id + rule_mr_offset),
5183 /* write VLAN mirrror control register */
5184 if (mirror_conf->rule_type == ETH_MIRROR_VLAN) {
5185 IXGBE_WRITE_REG(hw, IXGBE_VMRVLAN(rule_id), mv_lsb);
5186 IXGBE_WRITE_REG(hw, IXGBE_VMRVLAN(rule_id + rule_mr_offset),
5194 ixgbe_mirror_rule_reset(struct rte_eth_dev *dev, uint8_t rule_id)
5197 uint32_t lsb_val = 0;
5198 uint32_t msb_val = 0;
5199 const uint8_t rule_mr_offset = 4;
5201 struct ixgbe_hw *hw =
5202 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5203 struct ixgbe_mirror_info *mr_info =
5204 (IXGBE_DEV_PRIVATE_TO_PFDATA(dev->data->dev_private));
5206 if (ixgbe_vmdq_mode_check(hw) < 0)
5209 memset(&mr_info->mr_conf[rule_id], 0,
5210 sizeof(struct rte_eth_mirror_conf));
5212 /* clear PFVMCTL register */
5213 IXGBE_WRITE_REG(hw, IXGBE_MRCTL(rule_id), mr_ctl);
5215 /* clear pool mask register */
5216 IXGBE_WRITE_REG(hw, IXGBE_VMRVM(rule_id), lsb_val);
5217 IXGBE_WRITE_REG(hw, IXGBE_VMRVM(rule_id + rule_mr_offset), msb_val);
5219 /* clear vlan mask register */
5220 IXGBE_WRITE_REG(hw, IXGBE_VMRVLAN(rule_id), lsb_val);
5221 IXGBE_WRITE_REG(hw, IXGBE_VMRVLAN(rule_id + rule_mr_offset), msb_val);
5227 ixgbevf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
5229 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
5230 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
5232 struct ixgbe_hw *hw =
5233 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5235 mask = IXGBE_READ_REG(hw, IXGBE_VTEIMS);
5236 mask |= (1 << IXGBE_MISC_VEC_ID);
5237 RTE_SET_USED(queue_id);
5238 IXGBE_WRITE_REG(hw, IXGBE_VTEIMS, mask);
5240 rte_intr_enable(intr_handle);
5246 ixgbevf_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id)
5249 struct ixgbe_hw *hw =
5250 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5252 mask = IXGBE_READ_REG(hw, IXGBE_VTEIMS);
5253 mask &= ~(1 << IXGBE_MISC_VEC_ID);
5254 RTE_SET_USED(queue_id);
5255 IXGBE_WRITE_REG(hw, IXGBE_VTEIMS, mask);
5261 ixgbe_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
5263 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
5264 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
5266 struct ixgbe_hw *hw =
5267 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5268 struct ixgbe_interrupt *intr =
5269 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
5271 if (queue_id < 16) {
5272 ixgbe_disable_intr(hw);
5273 intr->mask |= (1 << queue_id);
5274 ixgbe_enable_intr(dev);
5275 } else if (queue_id < 32) {
5276 mask = IXGBE_READ_REG(hw, IXGBE_EIMS_EX(0));
5277 mask &= (1 << queue_id);
5278 IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(0), mask);
5279 } else if (queue_id < 64) {
5280 mask = IXGBE_READ_REG(hw, IXGBE_EIMS_EX(1));
5281 mask &= (1 << (queue_id - 32));
5282 IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(1), mask);
5284 rte_intr_enable(intr_handle);
5290 ixgbe_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id)
5293 struct ixgbe_hw *hw =
5294 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5295 struct ixgbe_interrupt *intr =
5296 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
5298 if (queue_id < 16) {
5299 ixgbe_disable_intr(hw);
5300 intr->mask &= ~(1 << queue_id);
5301 ixgbe_enable_intr(dev);
5302 } else if (queue_id < 32) {
5303 mask = IXGBE_READ_REG(hw, IXGBE_EIMS_EX(0));
5304 mask &= ~(1 << queue_id);
5305 IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(0), mask);
5306 } else if (queue_id < 64) {
5307 mask = IXGBE_READ_REG(hw, IXGBE_EIMS_EX(1));
5308 mask &= ~(1 << (queue_id - 32));
5309 IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(1), mask);
5316 ixgbevf_set_ivar_map(struct ixgbe_hw *hw, int8_t direction,
5317 uint8_t queue, uint8_t msix_vector)
5321 if (direction == -1) {
5323 msix_vector |= IXGBE_IVAR_ALLOC_VAL;
5324 tmp = IXGBE_READ_REG(hw, IXGBE_VTIVAR_MISC);
5327 IXGBE_WRITE_REG(hw, IXGBE_VTIVAR_MISC, tmp);
5329 /* rx or tx cause */
5330 msix_vector |= IXGBE_IVAR_ALLOC_VAL;
5331 idx = ((16 * (queue & 1)) + (8 * direction));
5332 tmp = IXGBE_READ_REG(hw, IXGBE_VTIVAR(queue >> 1));
5333 tmp &= ~(0xFF << idx);
5334 tmp |= (msix_vector << idx);
5335 IXGBE_WRITE_REG(hw, IXGBE_VTIVAR(queue >> 1), tmp);
5340 * set the IVAR registers, mapping interrupt causes to vectors
5342 * pointer to ixgbe_hw struct
5344 * 0 for Rx, 1 for Tx, -1 for other causes
5346 * queue to map the corresponding interrupt to
5348 * the vector to map to the corresponding queue
5351 ixgbe_set_ivar_map(struct ixgbe_hw *hw, int8_t direction,
5352 uint8_t queue, uint8_t msix_vector)
5356 msix_vector |= IXGBE_IVAR_ALLOC_VAL;
5357 if (hw->mac.type == ixgbe_mac_82598EB) {
5358 if (direction == -1)
5360 idx = (((direction * 64) + queue) >> 2) & 0x1F;
5361 tmp = IXGBE_READ_REG(hw, IXGBE_IVAR(idx));
5362 tmp &= ~(0xFF << (8 * (queue & 0x3)));
5363 tmp |= (msix_vector << (8 * (queue & 0x3)));
5364 IXGBE_WRITE_REG(hw, IXGBE_IVAR(idx), tmp);
5365 } else if ((hw->mac.type == ixgbe_mac_82599EB) ||
5366 (hw->mac.type == ixgbe_mac_X540)) {
5367 if (direction == -1) {
5369 idx = ((queue & 1) * 8);
5370 tmp = IXGBE_READ_REG(hw, IXGBE_IVAR_MISC);
5371 tmp &= ~(0xFF << idx);
5372 tmp |= (msix_vector << idx);
5373 IXGBE_WRITE_REG(hw, IXGBE_IVAR_MISC, tmp);
5375 /* rx or tx causes */
5376 idx = ((16 * (queue & 1)) + (8 * direction));
5377 tmp = IXGBE_READ_REG(hw, IXGBE_IVAR(queue >> 1));
5378 tmp &= ~(0xFF << idx);
5379 tmp |= (msix_vector << idx);
5380 IXGBE_WRITE_REG(hw, IXGBE_IVAR(queue >> 1), tmp);
5386 ixgbevf_configure_msix(struct rte_eth_dev *dev)
5388 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
5389 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
5390 struct ixgbe_hw *hw =
5391 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5393 uint32_t vector_idx = IXGBE_MISC_VEC_ID;
5395 /* Configure VF other cause ivar */
5396 ixgbevf_set_ivar_map(hw, -1, 1, vector_idx);
5398 /* won't configure msix register if no mapping is done
5399 * between intr vector and event fd.
5401 if (!rte_intr_dp_is_en(intr_handle))
5404 /* Configure all RX queues of VF */
5405 for (q_idx = 0; q_idx < dev->data->nb_rx_queues; q_idx++) {
5406 /* Force all queue use vector 0,
5407 * as IXGBE_VF_MAXMSIVECOTR = 1
5409 ixgbevf_set_ivar_map(hw, 0, q_idx, vector_idx);
5410 intr_handle->intr_vec[q_idx] = vector_idx;
5415 * Sets up the hardware to properly generate MSI-X interrupts
5417 * board private structure
5420 ixgbe_configure_msix(struct rte_eth_dev *dev)
5422 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
5423 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
5424 struct ixgbe_hw *hw =
5425 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5426 uint32_t queue_id, base = IXGBE_MISC_VEC_ID;
5427 uint32_t vec = IXGBE_MISC_VEC_ID;
5431 /* won't configure msix register if no mapping is done
5432 * between intr vector and event fd
5434 if (!rte_intr_dp_is_en(intr_handle))
5437 if (rte_intr_allow_others(intr_handle))
5438 vec = base = IXGBE_RX_VEC_START;
5440 /* setup GPIE for MSI-x mode */
5441 gpie = IXGBE_READ_REG(hw, IXGBE_GPIE);
5442 gpie |= IXGBE_GPIE_MSIX_MODE | IXGBE_GPIE_PBA_SUPPORT |
5443 IXGBE_GPIE_OCD | IXGBE_GPIE_EIAME;
5444 /* auto clearing and auto setting corresponding bits in EIMS
5445 * when MSI-X interrupt is triggered
5447 if (hw->mac.type == ixgbe_mac_82598EB) {
5448 IXGBE_WRITE_REG(hw, IXGBE_EIAM, IXGBE_EICS_RTX_QUEUE);
5450 IXGBE_WRITE_REG(hw, IXGBE_EIAM_EX(0), 0xFFFFFFFF);
5451 IXGBE_WRITE_REG(hw, IXGBE_EIAM_EX(1), 0xFFFFFFFF);
5453 IXGBE_WRITE_REG(hw, IXGBE_GPIE, gpie);
5455 /* Populate the IVAR table and set the ITR values to the
5456 * corresponding register.
5458 for (queue_id = 0; queue_id < dev->data->nb_rx_queues;
5460 /* by default, 1:1 mapping */
5461 ixgbe_set_ivar_map(hw, 0, queue_id, vec);
5462 intr_handle->intr_vec[queue_id] = vec;
5463 if (vec < base + intr_handle->nb_efd - 1)
5467 switch (hw->mac.type) {
5468 case ixgbe_mac_82598EB:
5469 ixgbe_set_ivar_map(hw, -1, IXGBE_IVAR_OTHER_CAUSES_INDEX,
5472 case ixgbe_mac_82599EB:
5473 case ixgbe_mac_X540:
5474 ixgbe_set_ivar_map(hw, -1, 1, IXGBE_MISC_VEC_ID);
5479 IXGBE_WRITE_REG(hw, IXGBE_EITR(IXGBE_MISC_VEC_ID),
5480 IXGBE_MIN_INTER_INTERRUPT_INTERVAL_DEFAULT & 0xFFF);
5482 /* set up to autoclear timer, and the vectors */
5483 mask = IXGBE_EIMS_ENABLE_MASK;
5484 mask &= ~(IXGBE_EIMS_OTHER |
5485 IXGBE_EIMS_MAILBOX |
5488 IXGBE_WRITE_REG(hw, IXGBE_EIAC, mask);
5491 static int ixgbe_set_queue_rate_limit(struct rte_eth_dev *dev,
5492 uint16_t queue_idx, uint16_t tx_rate)
5494 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5495 uint32_t rf_dec, rf_int;
5497 uint16_t link_speed = dev->data->dev_link.link_speed;
5499 if (queue_idx >= hw->mac.max_tx_queues)
5503 /* Calculate the rate factor values to set */
5504 rf_int = (uint32_t)link_speed / (uint32_t)tx_rate;
5505 rf_dec = (uint32_t)link_speed % (uint32_t)tx_rate;
5506 rf_dec = (rf_dec << IXGBE_RTTBCNRC_RF_INT_SHIFT) / tx_rate;
5508 bcnrc_val = IXGBE_RTTBCNRC_RS_ENA;
5509 bcnrc_val |= ((rf_int << IXGBE_RTTBCNRC_RF_INT_SHIFT) &
5510 IXGBE_RTTBCNRC_RF_INT_MASK_M);
5511 bcnrc_val |= (rf_dec & IXGBE_RTTBCNRC_RF_DEC_MASK);
5517 * Set global transmit compensation time to the MMW_SIZE in RTTBCNRM
5518 * register. MMW_SIZE=0x014 if 9728-byte jumbo is supported, otherwise
5521 if ((dev->data->dev_conf.rxmode.jumbo_frame == 1) &&
5522 (dev->data->dev_conf.rxmode.max_rx_pkt_len >=
5523 IXGBE_MAX_JUMBO_FRAME_SIZE))
5524 IXGBE_WRITE_REG(hw, IXGBE_RTTBCNRM,
5525 IXGBE_MMW_SIZE_JUMBO_FRAME);
5527 IXGBE_WRITE_REG(hw, IXGBE_RTTBCNRM,
5528 IXGBE_MMW_SIZE_DEFAULT);
5530 /* Set RTTBCNRC of queue X */
5531 IXGBE_WRITE_REG(hw, IXGBE_RTTDQSEL, queue_idx);
5532 IXGBE_WRITE_REG(hw, IXGBE_RTTBCNRC, bcnrc_val);
5533 IXGBE_WRITE_FLUSH(hw);
5538 static int ixgbe_set_vf_rate_limit(struct rte_eth_dev *dev, uint16_t vf,
5539 uint16_t tx_rate, uint64_t q_msk)
5541 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
5542 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5543 struct ixgbe_vf_info *vfinfo =
5544 *(IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private));
5545 uint8_t nb_q_per_pool = RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool;
5546 uint32_t queue_stride =
5547 IXGBE_MAX_RX_QUEUE_NUM / RTE_ETH_DEV_SRIOV(dev).active;
5548 uint32_t queue_idx = vf * queue_stride, idx = 0, vf_idx;
5549 uint32_t queue_end = queue_idx + nb_q_per_pool - 1;
5550 uint16_t total_rate = 0;
5552 if (queue_end >= hw->mac.max_tx_queues)
5555 if (vfinfo != NULL) {
5556 for (vf_idx = 0; vf_idx < pci_dev->max_vfs; vf_idx++) {
5559 for (idx = 0; idx < RTE_DIM(vfinfo[vf_idx].tx_rate);
5561 total_rate += vfinfo[vf_idx].tx_rate[idx];
5566 /* Store tx_rate for this vf. */
5567 for (idx = 0; idx < nb_q_per_pool; idx++) {
5568 if (((uint64_t)0x1 << idx) & q_msk) {
5569 if (vfinfo[vf].tx_rate[idx] != tx_rate)
5570 vfinfo[vf].tx_rate[idx] = tx_rate;
5571 total_rate += tx_rate;
5575 if (total_rate > dev->data->dev_link.link_speed) {
5577 * Reset stored TX rate of the VF if it causes exceed
5580 memset(vfinfo[vf].tx_rate, 0, sizeof(vfinfo[vf].tx_rate));
5584 /* Set RTTBCNRC of each queue/pool for vf X */
5585 for (; queue_idx <= queue_end; queue_idx++) {
5587 ixgbe_set_queue_rate_limit(dev, queue_idx, tx_rate);
5595 ixgbevf_add_mac_addr(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
5596 __attribute__((unused)) uint32_t index,
5597 __attribute__((unused)) uint32_t pool)
5599 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5603 * On a 82599 VF, adding again the same MAC addr is not an idempotent
5604 * operation. Trap this case to avoid exhausting the [very limited]
5605 * set of PF resources used to store VF MAC addresses.
5607 if (memcmp(hw->mac.perm_addr, mac_addr, sizeof(struct ether_addr)) == 0)
5609 diag = ixgbevf_set_uc_addr_vf(hw, 2, mac_addr->addr_bytes);
5612 PMD_DRV_LOG(ERR, "Unable to add MAC address - diag=%d", diag);
5616 ixgbevf_remove_mac_addr(struct rte_eth_dev *dev, uint32_t index)
5618 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5619 struct ether_addr *perm_addr = (struct ether_addr *) hw->mac.perm_addr;
5620 struct ether_addr *mac_addr;
5625 * The IXGBE_VF_SET_MACVLAN command of the ixgbe-pf driver does
5626 * not support the deletion of a given MAC address.
5627 * Instead, it imposes to delete all MAC addresses, then to add again
5628 * all MAC addresses with the exception of the one to be deleted.
5630 (void) ixgbevf_set_uc_addr_vf(hw, 0, NULL);
5633 * Add again all MAC addresses, with the exception of the deleted one
5634 * and of the permanent MAC address.
5636 for (i = 0, mac_addr = dev->data->mac_addrs;
5637 i < hw->mac.num_rar_entries; i++, mac_addr++) {
5638 /* Skip the deleted MAC address */
5641 /* Skip NULL MAC addresses */
5642 if (is_zero_ether_addr(mac_addr))
5644 /* Skip the permanent MAC address */
5645 if (memcmp(perm_addr, mac_addr, sizeof(struct ether_addr)) == 0)
5647 diag = ixgbevf_set_uc_addr_vf(hw, 2, mac_addr->addr_bytes);
5650 "Adding again MAC address "
5651 "%02x:%02x:%02x:%02x:%02x:%02x failed "
5653 mac_addr->addr_bytes[0],
5654 mac_addr->addr_bytes[1],
5655 mac_addr->addr_bytes[2],
5656 mac_addr->addr_bytes[3],
5657 mac_addr->addr_bytes[4],
5658 mac_addr->addr_bytes[5],
5664 ixgbevf_set_default_mac_addr(struct rte_eth_dev *dev, struct ether_addr *addr)
5666 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5668 hw->mac.ops.set_rar(hw, 0, (void *)addr, 0, 0);
5671 #define MAC_TYPE_FILTER_SUP(type) do {\
5672 if ((type) != ixgbe_mac_82599EB && (type) != ixgbe_mac_X540 &&\
5673 (type) != ixgbe_mac_X550 && (type) != ixgbe_mac_X550EM_x &&\
5674 (type) != ixgbe_mac_X550EM_a)\
5679 ixgbe_syn_filter_set(struct rte_eth_dev *dev,
5680 struct rte_eth_syn_filter *filter,
5683 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5686 if (filter->queue >= IXGBE_MAX_RX_QUEUE_NUM)
5689 synqf = IXGBE_READ_REG(hw, IXGBE_SYNQF);
5692 if (synqf & IXGBE_SYN_FILTER_ENABLE)
5694 synqf = (uint32_t)(((filter->queue << IXGBE_SYN_FILTER_QUEUE_SHIFT) &
5695 IXGBE_SYN_FILTER_QUEUE) | IXGBE_SYN_FILTER_ENABLE);
5697 if (filter->hig_pri)
5698 synqf |= IXGBE_SYN_FILTER_SYNQFP;
5700 synqf &= ~IXGBE_SYN_FILTER_SYNQFP;
5702 if (!(synqf & IXGBE_SYN_FILTER_ENABLE))
5704 synqf &= ~(IXGBE_SYN_FILTER_QUEUE | IXGBE_SYN_FILTER_ENABLE);
5706 IXGBE_WRITE_REG(hw, IXGBE_SYNQF, synqf);
5707 IXGBE_WRITE_FLUSH(hw);
5712 ixgbe_syn_filter_get(struct rte_eth_dev *dev,
5713 struct rte_eth_syn_filter *filter)
5715 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5716 uint32_t synqf = IXGBE_READ_REG(hw, IXGBE_SYNQF);
5718 if (synqf & IXGBE_SYN_FILTER_ENABLE) {
5719 filter->hig_pri = (synqf & IXGBE_SYN_FILTER_SYNQFP) ? 1 : 0;
5720 filter->queue = (uint16_t)((synqf & IXGBE_SYN_FILTER_QUEUE) >> 1);
5727 ixgbe_syn_filter_handle(struct rte_eth_dev *dev,
5728 enum rte_filter_op filter_op,
5731 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5734 MAC_TYPE_FILTER_SUP(hw->mac.type);
5736 if (filter_op == RTE_ETH_FILTER_NOP)
5740 PMD_DRV_LOG(ERR, "arg shouldn't be NULL for operation %u",
5745 switch (filter_op) {
5746 case RTE_ETH_FILTER_ADD:
5747 ret = ixgbe_syn_filter_set(dev,
5748 (struct rte_eth_syn_filter *)arg,
5751 case RTE_ETH_FILTER_DELETE:
5752 ret = ixgbe_syn_filter_set(dev,
5753 (struct rte_eth_syn_filter *)arg,
5756 case RTE_ETH_FILTER_GET:
5757 ret = ixgbe_syn_filter_get(dev,
5758 (struct rte_eth_syn_filter *)arg);
5761 PMD_DRV_LOG(ERR, "unsupported operation %u\n", filter_op);
5770 static inline enum ixgbe_5tuple_protocol
5771 convert_protocol_type(uint8_t protocol_value)
5773 if (protocol_value == IPPROTO_TCP)
5774 return IXGBE_FILTER_PROTOCOL_TCP;
5775 else if (protocol_value == IPPROTO_UDP)
5776 return IXGBE_FILTER_PROTOCOL_UDP;
5777 else if (protocol_value == IPPROTO_SCTP)
5778 return IXGBE_FILTER_PROTOCOL_SCTP;
5780 return IXGBE_FILTER_PROTOCOL_NONE;
5784 * add a 5tuple filter
5787 * dev: Pointer to struct rte_eth_dev.
5788 * index: the index the filter allocates.
5789 * filter: ponter to the filter that will be added.
5790 * rx_queue: the queue id the filter assigned to.
5793 * - On success, zero.
5794 * - On failure, a negative value.
5797 ixgbe_add_5tuple_filter(struct rte_eth_dev *dev,
5798 struct ixgbe_5tuple_filter *filter)
5800 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5801 struct ixgbe_filter_info *filter_info =
5802 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
5804 uint32_t ftqf, sdpqf;
5805 uint32_t l34timir = 0;
5806 uint8_t mask = 0xff;
5809 * look for an unused 5tuple filter index,
5810 * and insert the filter to list.
5812 for (i = 0; i < IXGBE_MAX_FTQF_FILTERS; i++) {
5813 idx = i / (sizeof(uint32_t) * NBBY);
5814 shift = i % (sizeof(uint32_t) * NBBY);
5815 if (!(filter_info->fivetuple_mask[idx] & (1 << shift))) {
5816 filter_info->fivetuple_mask[idx] |= 1 << shift;
5818 TAILQ_INSERT_TAIL(&filter_info->fivetuple_list,
5824 if (i >= IXGBE_MAX_FTQF_FILTERS) {
5825 PMD_DRV_LOG(ERR, "5tuple filters are full.");
5829 sdpqf = (uint32_t)(filter->filter_info.dst_port <<
5830 IXGBE_SDPQF_DSTPORT_SHIFT);
5831 sdpqf = sdpqf | (filter->filter_info.src_port & IXGBE_SDPQF_SRCPORT);
5833 ftqf = (uint32_t)(filter->filter_info.proto &
5834 IXGBE_FTQF_PROTOCOL_MASK);
5835 ftqf |= (uint32_t)((filter->filter_info.priority &
5836 IXGBE_FTQF_PRIORITY_MASK) << IXGBE_FTQF_PRIORITY_SHIFT);
5837 if (filter->filter_info.src_ip_mask == 0) /* 0 means compare. */
5838 mask &= IXGBE_FTQF_SOURCE_ADDR_MASK;
5839 if (filter->filter_info.dst_ip_mask == 0)
5840 mask &= IXGBE_FTQF_DEST_ADDR_MASK;
5841 if (filter->filter_info.src_port_mask == 0)
5842 mask &= IXGBE_FTQF_SOURCE_PORT_MASK;
5843 if (filter->filter_info.dst_port_mask == 0)
5844 mask &= IXGBE_FTQF_DEST_PORT_MASK;
5845 if (filter->filter_info.proto_mask == 0)
5846 mask &= IXGBE_FTQF_PROTOCOL_COMP_MASK;
5847 ftqf |= mask << IXGBE_FTQF_5TUPLE_MASK_SHIFT;
5848 ftqf |= IXGBE_FTQF_POOL_MASK_EN;
5849 ftqf |= IXGBE_FTQF_QUEUE_ENABLE;
5851 IXGBE_WRITE_REG(hw, IXGBE_DAQF(i), filter->filter_info.dst_ip);
5852 IXGBE_WRITE_REG(hw, IXGBE_SAQF(i), filter->filter_info.src_ip);
5853 IXGBE_WRITE_REG(hw, IXGBE_SDPQF(i), sdpqf);
5854 IXGBE_WRITE_REG(hw, IXGBE_FTQF(i), ftqf);
5856 l34timir |= IXGBE_L34T_IMIR_RESERVE;
5857 l34timir |= (uint32_t)(filter->queue <<
5858 IXGBE_L34T_IMIR_QUEUE_SHIFT);
5859 IXGBE_WRITE_REG(hw, IXGBE_L34T_IMIR(i), l34timir);
5864 * remove a 5tuple filter
5867 * dev: Pointer to struct rte_eth_dev.
5868 * filter: the pointer of the filter will be removed.
5871 ixgbe_remove_5tuple_filter(struct rte_eth_dev *dev,
5872 struct ixgbe_5tuple_filter *filter)
5874 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5875 struct ixgbe_filter_info *filter_info =
5876 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
5877 uint16_t index = filter->index;
5879 filter_info->fivetuple_mask[index / (sizeof(uint32_t) * NBBY)] &=
5880 ~(1 << (index % (sizeof(uint32_t) * NBBY)));
5881 TAILQ_REMOVE(&filter_info->fivetuple_list, filter, entries);
5884 IXGBE_WRITE_REG(hw, IXGBE_DAQF(index), 0);
5885 IXGBE_WRITE_REG(hw, IXGBE_SAQF(index), 0);
5886 IXGBE_WRITE_REG(hw, IXGBE_SDPQF(index), 0);
5887 IXGBE_WRITE_REG(hw, IXGBE_FTQF(index), 0);
5888 IXGBE_WRITE_REG(hw, IXGBE_L34T_IMIR(index), 0);
5892 ixgbevf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
5894 struct ixgbe_hw *hw;
5895 uint32_t max_frame = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
5897 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5899 if ((mtu < ETHER_MIN_MTU) || (max_frame > ETHER_MAX_JUMBO_FRAME_LEN))
5902 /* refuse mtu that requires the support of scattered packets when this
5903 * feature has not been enabled before.
5905 if (!dev->data->scattered_rx &&
5906 (max_frame + 2 * IXGBE_VLAN_TAG_SIZE >
5907 dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM))
5911 * When supported by the underlying PF driver, use the IXGBE_VF_SET_MTU
5912 * request of the version 2.0 of the mailbox API.
5913 * For now, use the IXGBE_VF_SET_LPE request of the version 1.0
5914 * of the mailbox API.
5915 * This call to IXGBE_SET_LPE action won't work with ixgbe pf drivers
5916 * prior to 3.11.33 which contains the following change:
5917 * "ixgbe: Enable jumbo frames support w/ SR-IOV"
5919 ixgbevf_rlpml_set_vf(hw, max_frame);
5921 /* update max frame size */
5922 dev->data->dev_conf.rxmode.max_rx_pkt_len = max_frame;
5926 #define MAC_TYPE_FILTER_SUP_EXT(type) do {\
5927 if ((type) != ixgbe_mac_82599EB && (type) != ixgbe_mac_X540)\
5931 static inline struct ixgbe_5tuple_filter *
5932 ixgbe_5tuple_filter_lookup(struct ixgbe_5tuple_filter_list *filter_list,
5933 struct ixgbe_5tuple_filter_info *key)
5935 struct ixgbe_5tuple_filter *it;
5937 TAILQ_FOREACH(it, filter_list, entries) {
5938 if (memcmp(key, &it->filter_info,
5939 sizeof(struct ixgbe_5tuple_filter_info)) == 0) {
5946 /* translate elements in struct rte_eth_ntuple_filter to struct ixgbe_5tuple_filter_info*/
5948 ntuple_filter_to_5tuple(struct rte_eth_ntuple_filter *filter,
5949 struct ixgbe_5tuple_filter_info *filter_info)
5951 if (filter->queue >= IXGBE_MAX_RX_QUEUE_NUM ||
5952 filter->priority > IXGBE_5TUPLE_MAX_PRI ||
5953 filter->priority < IXGBE_5TUPLE_MIN_PRI)
5956 switch (filter->dst_ip_mask) {
5958 filter_info->dst_ip_mask = 0;
5959 filter_info->dst_ip = filter->dst_ip;
5962 filter_info->dst_ip_mask = 1;
5965 PMD_DRV_LOG(ERR, "invalid dst_ip mask.");
5969 switch (filter->src_ip_mask) {
5971 filter_info->src_ip_mask = 0;
5972 filter_info->src_ip = filter->src_ip;
5975 filter_info->src_ip_mask = 1;
5978 PMD_DRV_LOG(ERR, "invalid src_ip mask.");
5982 switch (filter->dst_port_mask) {
5984 filter_info->dst_port_mask = 0;
5985 filter_info->dst_port = filter->dst_port;
5988 filter_info->dst_port_mask = 1;
5991 PMD_DRV_LOG(ERR, "invalid dst_port mask.");
5995 switch (filter->src_port_mask) {
5997 filter_info->src_port_mask = 0;
5998 filter_info->src_port = filter->src_port;
6001 filter_info->src_port_mask = 1;
6004 PMD_DRV_LOG(ERR, "invalid src_port mask.");
6008 switch (filter->proto_mask) {
6010 filter_info->proto_mask = 0;
6011 filter_info->proto =
6012 convert_protocol_type(filter->proto);
6015 filter_info->proto_mask = 1;
6018 PMD_DRV_LOG(ERR, "invalid protocol mask.");
6022 filter_info->priority = (uint8_t)filter->priority;
6027 * add or delete a ntuple filter
6030 * dev: Pointer to struct rte_eth_dev.
6031 * ntuple_filter: Pointer to struct rte_eth_ntuple_filter
6032 * add: if true, add filter, if false, remove filter
6035 * - On success, zero.
6036 * - On failure, a negative value.
6039 ixgbe_add_del_ntuple_filter(struct rte_eth_dev *dev,
6040 struct rte_eth_ntuple_filter *ntuple_filter,
6043 struct ixgbe_filter_info *filter_info =
6044 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6045 struct ixgbe_5tuple_filter_info filter_5tuple;
6046 struct ixgbe_5tuple_filter *filter;
6049 if (ntuple_filter->flags != RTE_5TUPLE_FLAGS) {
6050 PMD_DRV_LOG(ERR, "only 5tuple is supported.");
6054 memset(&filter_5tuple, 0, sizeof(struct ixgbe_5tuple_filter_info));
6055 ret = ntuple_filter_to_5tuple(ntuple_filter, &filter_5tuple);
6059 filter = ixgbe_5tuple_filter_lookup(&filter_info->fivetuple_list,
6061 if (filter != NULL && add) {
6062 PMD_DRV_LOG(ERR, "filter exists.");
6065 if (filter == NULL && !add) {
6066 PMD_DRV_LOG(ERR, "filter doesn't exist.");
6071 filter = rte_zmalloc("ixgbe_5tuple_filter",
6072 sizeof(struct ixgbe_5tuple_filter), 0);
6075 (void)rte_memcpy(&filter->filter_info,
6077 sizeof(struct ixgbe_5tuple_filter_info));
6078 filter->queue = ntuple_filter->queue;
6079 ret = ixgbe_add_5tuple_filter(dev, filter);
6085 ixgbe_remove_5tuple_filter(dev, filter);
6091 * get a ntuple filter
6094 * dev: Pointer to struct rte_eth_dev.
6095 * ntuple_filter: Pointer to struct rte_eth_ntuple_filter
6098 * - On success, zero.
6099 * - On failure, a negative value.
6102 ixgbe_get_ntuple_filter(struct rte_eth_dev *dev,
6103 struct rte_eth_ntuple_filter *ntuple_filter)
6105 struct ixgbe_filter_info *filter_info =
6106 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6107 struct ixgbe_5tuple_filter_info filter_5tuple;
6108 struct ixgbe_5tuple_filter *filter;
6111 if (ntuple_filter->flags != RTE_5TUPLE_FLAGS) {
6112 PMD_DRV_LOG(ERR, "only 5tuple is supported.");
6116 memset(&filter_5tuple, 0, sizeof(struct ixgbe_5tuple_filter_info));
6117 ret = ntuple_filter_to_5tuple(ntuple_filter, &filter_5tuple);
6121 filter = ixgbe_5tuple_filter_lookup(&filter_info->fivetuple_list,
6123 if (filter == NULL) {
6124 PMD_DRV_LOG(ERR, "filter doesn't exist.");
6127 ntuple_filter->queue = filter->queue;
6132 * ixgbe_ntuple_filter_handle - Handle operations for ntuple filter.
6133 * @dev: pointer to rte_eth_dev structure
6134 * @filter_op:operation will be taken.
6135 * @arg: a pointer to specific structure corresponding to the filter_op
6138 * - On success, zero.
6139 * - On failure, a negative value.
6142 ixgbe_ntuple_filter_handle(struct rte_eth_dev *dev,
6143 enum rte_filter_op filter_op,
6146 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6149 MAC_TYPE_FILTER_SUP_EXT(hw->mac.type);
6151 if (filter_op == RTE_ETH_FILTER_NOP)
6155 PMD_DRV_LOG(ERR, "arg shouldn't be NULL for operation %u.",
6160 switch (filter_op) {
6161 case RTE_ETH_FILTER_ADD:
6162 ret = ixgbe_add_del_ntuple_filter(dev,
6163 (struct rte_eth_ntuple_filter *)arg,
6166 case RTE_ETH_FILTER_DELETE:
6167 ret = ixgbe_add_del_ntuple_filter(dev,
6168 (struct rte_eth_ntuple_filter *)arg,
6171 case RTE_ETH_FILTER_GET:
6172 ret = ixgbe_get_ntuple_filter(dev,
6173 (struct rte_eth_ntuple_filter *)arg);
6176 PMD_DRV_LOG(ERR, "unsupported operation %u.", filter_op);
6184 ixgbe_ethertype_filter_lookup(struct ixgbe_filter_info *filter_info,
6189 for (i = 0; i < IXGBE_MAX_ETQF_FILTERS; i++) {
6190 if (filter_info->ethertype_filters[i] == ethertype &&
6191 (filter_info->ethertype_mask & (1 << i)))
6198 ixgbe_ethertype_filter_insert(struct ixgbe_filter_info *filter_info,
6203 for (i = 0; i < IXGBE_MAX_ETQF_FILTERS; i++) {
6204 if (!(filter_info->ethertype_mask & (1 << i))) {
6205 filter_info->ethertype_mask |= 1 << i;
6206 filter_info->ethertype_filters[i] = ethertype;
6214 ixgbe_ethertype_filter_remove(struct ixgbe_filter_info *filter_info,
6217 if (idx >= IXGBE_MAX_ETQF_FILTERS)
6219 filter_info->ethertype_mask &= ~(1 << idx);
6220 filter_info->ethertype_filters[idx] = 0;
6225 ixgbe_add_del_ethertype_filter(struct rte_eth_dev *dev,
6226 struct rte_eth_ethertype_filter *filter,
6229 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6230 struct ixgbe_filter_info *filter_info =
6231 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6236 if (filter->queue >= IXGBE_MAX_RX_QUEUE_NUM)
6239 if (filter->ether_type == ETHER_TYPE_IPv4 ||
6240 filter->ether_type == ETHER_TYPE_IPv6) {
6241 PMD_DRV_LOG(ERR, "unsupported ether_type(0x%04x) in"
6242 " ethertype filter.", filter->ether_type);
6246 if (filter->flags & RTE_ETHTYPE_FLAGS_MAC) {
6247 PMD_DRV_LOG(ERR, "mac compare is unsupported.");
6250 if (filter->flags & RTE_ETHTYPE_FLAGS_DROP) {
6251 PMD_DRV_LOG(ERR, "drop option is unsupported.");
6255 ret = ixgbe_ethertype_filter_lookup(filter_info, filter->ether_type);
6256 if (ret >= 0 && add) {
6257 PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter exists.",
6258 filter->ether_type);
6261 if (ret < 0 && !add) {
6262 PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter doesn't exist.",
6263 filter->ether_type);
6268 ret = ixgbe_ethertype_filter_insert(filter_info,
6269 filter->ether_type);
6271 PMD_DRV_LOG(ERR, "ethertype filters are full.");
6274 etqf = IXGBE_ETQF_FILTER_EN;
6275 etqf |= (uint32_t)filter->ether_type;
6276 etqs |= (uint32_t)((filter->queue <<
6277 IXGBE_ETQS_RX_QUEUE_SHIFT) &
6278 IXGBE_ETQS_RX_QUEUE);
6279 etqs |= IXGBE_ETQS_QUEUE_EN;
6281 ret = ixgbe_ethertype_filter_remove(filter_info, (uint8_t)ret);
6285 IXGBE_WRITE_REG(hw, IXGBE_ETQF(ret), etqf);
6286 IXGBE_WRITE_REG(hw, IXGBE_ETQS(ret), etqs);
6287 IXGBE_WRITE_FLUSH(hw);
6293 ixgbe_get_ethertype_filter(struct rte_eth_dev *dev,
6294 struct rte_eth_ethertype_filter *filter)
6296 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6297 struct ixgbe_filter_info *filter_info =
6298 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6299 uint32_t etqf, etqs;
6302 ret = ixgbe_ethertype_filter_lookup(filter_info, filter->ether_type);
6304 PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter doesn't exist.",
6305 filter->ether_type);
6309 etqf = IXGBE_READ_REG(hw, IXGBE_ETQF(ret));
6310 if (etqf & IXGBE_ETQF_FILTER_EN) {
6311 etqs = IXGBE_READ_REG(hw, IXGBE_ETQS(ret));
6312 filter->ether_type = etqf & IXGBE_ETQF_ETHERTYPE;
6314 filter->queue = (etqs & IXGBE_ETQS_RX_QUEUE) >>
6315 IXGBE_ETQS_RX_QUEUE_SHIFT;
6322 * ixgbe_ethertype_filter_handle - Handle operations for ethertype filter.
6323 * @dev: pointer to rte_eth_dev structure
6324 * @filter_op:operation will be taken.
6325 * @arg: a pointer to specific structure corresponding to the filter_op
6328 ixgbe_ethertype_filter_handle(struct rte_eth_dev *dev,
6329 enum rte_filter_op filter_op,
6332 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6335 MAC_TYPE_FILTER_SUP(hw->mac.type);
6337 if (filter_op == RTE_ETH_FILTER_NOP)
6341 PMD_DRV_LOG(ERR, "arg shouldn't be NULL for operation %u.",
6346 switch (filter_op) {
6347 case RTE_ETH_FILTER_ADD:
6348 ret = ixgbe_add_del_ethertype_filter(dev,
6349 (struct rte_eth_ethertype_filter *)arg,
6352 case RTE_ETH_FILTER_DELETE:
6353 ret = ixgbe_add_del_ethertype_filter(dev,
6354 (struct rte_eth_ethertype_filter *)arg,
6357 case RTE_ETH_FILTER_GET:
6358 ret = ixgbe_get_ethertype_filter(dev,
6359 (struct rte_eth_ethertype_filter *)arg);
6362 PMD_DRV_LOG(ERR, "unsupported operation %u.", filter_op);
6370 ixgbe_dev_filter_ctrl(struct rte_eth_dev *dev,
6371 enum rte_filter_type filter_type,
6372 enum rte_filter_op filter_op,
6377 switch (filter_type) {
6378 case RTE_ETH_FILTER_NTUPLE:
6379 ret = ixgbe_ntuple_filter_handle(dev, filter_op, arg);
6381 case RTE_ETH_FILTER_ETHERTYPE:
6382 ret = ixgbe_ethertype_filter_handle(dev, filter_op, arg);
6384 case RTE_ETH_FILTER_SYN:
6385 ret = ixgbe_syn_filter_handle(dev, filter_op, arg);
6387 case RTE_ETH_FILTER_FDIR:
6388 ret = ixgbe_fdir_ctrl_func(dev, filter_op, arg);
6390 case RTE_ETH_FILTER_L2_TUNNEL:
6391 ret = ixgbe_dev_l2_tunnel_filter_handle(dev, filter_op, arg);
6394 PMD_DRV_LOG(WARNING, "Filter type (%d) not supported",
6403 ixgbe_dev_addr_list_itr(__attribute__((unused)) struct ixgbe_hw *hw,
6404 u8 **mc_addr_ptr, u32 *vmdq)
6409 mc_addr = *mc_addr_ptr;
6410 *mc_addr_ptr = (mc_addr + sizeof(struct ether_addr));
6415 ixgbe_dev_set_mc_addr_list(struct rte_eth_dev *dev,
6416 struct ether_addr *mc_addr_set,
6417 uint32_t nb_mc_addr)
6419 struct ixgbe_hw *hw;
6422 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6423 mc_addr_list = (u8 *)mc_addr_set;
6424 return ixgbe_update_mc_addr_list(hw, mc_addr_list, nb_mc_addr,
6425 ixgbe_dev_addr_list_itr, TRUE);
6429 ixgbe_read_systime_cyclecounter(struct rte_eth_dev *dev)
6431 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6432 uint64_t systime_cycles;
6434 switch (hw->mac.type) {
6435 case ixgbe_mac_X550:
6436 case ixgbe_mac_X550EM_x:
6437 case ixgbe_mac_X550EM_a:
6438 /* SYSTIMEL stores ns and SYSTIMEH stores seconds. */
6439 systime_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_SYSTIML);
6440 systime_cycles += (uint64_t)IXGBE_READ_REG(hw, IXGBE_SYSTIMH)
6444 systime_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_SYSTIML);
6445 systime_cycles |= (uint64_t)IXGBE_READ_REG(hw, IXGBE_SYSTIMH)
6449 return systime_cycles;
6453 ixgbe_read_rx_tstamp_cyclecounter(struct rte_eth_dev *dev)
6455 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6456 uint64_t rx_tstamp_cycles;
6458 switch (hw->mac.type) {
6459 case ixgbe_mac_X550:
6460 case ixgbe_mac_X550EM_x:
6461 case ixgbe_mac_X550EM_a:
6462 /* RXSTMPL stores ns and RXSTMPH stores seconds. */
6463 rx_tstamp_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_RXSTMPL);
6464 rx_tstamp_cycles += (uint64_t)IXGBE_READ_REG(hw, IXGBE_RXSTMPH)
6468 /* RXSTMPL stores ns and RXSTMPH stores seconds. */
6469 rx_tstamp_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_RXSTMPL);
6470 rx_tstamp_cycles |= (uint64_t)IXGBE_READ_REG(hw, IXGBE_RXSTMPH)
6474 return rx_tstamp_cycles;
6478 ixgbe_read_tx_tstamp_cyclecounter(struct rte_eth_dev *dev)
6480 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6481 uint64_t tx_tstamp_cycles;
6483 switch (hw->mac.type) {
6484 case ixgbe_mac_X550:
6485 case ixgbe_mac_X550EM_x:
6486 case ixgbe_mac_X550EM_a:
6487 /* TXSTMPL stores ns and TXSTMPH stores seconds. */
6488 tx_tstamp_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_TXSTMPL);
6489 tx_tstamp_cycles += (uint64_t)IXGBE_READ_REG(hw, IXGBE_TXSTMPH)
6493 /* TXSTMPL stores ns and TXSTMPH stores seconds. */
6494 tx_tstamp_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_TXSTMPL);
6495 tx_tstamp_cycles |= (uint64_t)IXGBE_READ_REG(hw, IXGBE_TXSTMPH)
6499 return tx_tstamp_cycles;
6503 ixgbe_start_timecounters(struct rte_eth_dev *dev)
6505 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6506 struct ixgbe_adapter *adapter =
6507 (struct ixgbe_adapter *)dev->data->dev_private;
6508 struct rte_eth_link link;
6509 uint32_t incval = 0;
6512 /* Get current link speed. */
6513 memset(&link, 0, sizeof(link));
6514 ixgbe_dev_link_update(dev, 1);
6515 rte_ixgbe_dev_atomic_read_link_status(dev, &link);
6517 switch (link.link_speed) {
6518 case ETH_SPEED_NUM_100M:
6519 incval = IXGBE_INCVAL_100;
6520 shift = IXGBE_INCVAL_SHIFT_100;
6522 case ETH_SPEED_NUM_1G:
6523 incval = IXGBE_INCVAL_1GB;
6524 shift = IXGBE_INCVAL_SHIFT_1GB;
6526 case ETH_SPEED_NUM_10G:
6528 incval = IXGBE_INCVAL_10GB;
6529 shift = IXGBE_INCVAL_SHIFT_10GB;
6533 switch (hw->mac.type) {
6534 case ixgbe_mac_X550:
6535 case ixgbe_mac_X550EM_x:
6536 case ixgbe_mac_X550EM_a:
6537 /* Independent of link speed. */
6539 /* Cycles read will be interpreted as ns. */
6542 case ixgbe_mac_X540:
6543 IXGBE_WRITE_REG(hw, IXGBE_TIMINCA, incval);
6545 case ixgbe_mac_82599EB:
6546 incval >>= IXGBE_INCVAL_SHIFT_82599;
6547 shift -= IXGBE_INCVAL_SHIFT_82599;
6548 IXGBE_WRITE_REG(hw, IXGBE_TIMINCA,
6549 (1 << IXGBE_INCPER_SHIFT_82599) | incval);
6552 /* Not supported. */
6556 memset(&adapter->systime_tc, 0, sizeof(struct rte_timecounter));
6557 memset(&adapter->rx_tstamp_tc, 0, sizeof(struct rte_timecounter));
6558 memset(&adapter->tx_tstamp_tc, 0, sizeof(struct rte_timecounter));
6560 adapter->systime_tc.cc_mask = IXGBE_CYCLECOUNTER_MASK;
6561 adapter->systime_tc.cc_shift = shift;
6562 adapter->systime_tc.nsec_mask = (1ULL << shift) - 1;
6564 adapter->rx_tstamp_tc.cc_mask = IXGBE_CYCLECOUNTER_MASK;
6565 adapter->rx_tstamp_tc.cc_shift = shift;
6566 adapter->rx_tstamp_tc.nsec_mask = (1ULL << shift) - 1;
6568 adapter->tx_tstamp_tc.cc_mask = IXGBE_CYCLECOUNTER_MASK;
6569 adapter->tx_tstamp_tc.cc_shift = shift;
6570 adapter->tx_tstamp_tc.nsec_mask = (1ULL << shift) - 1;
6574 ixgbe_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta)
6576 struct ixgbe_adapter *adapter =
6577 (struct ixgbe_adapter *)dev->data->dev_private;
6579 adapter->systime_tc.nsec += delta;
6580 adapter->rx_tstamp_tc.nsec += delta;
6581 adapter->tx_tstamp_tc.nsec += delta;
6587 ixgbe_timesync_write_time(struct rte_eth_dev *dev, const struct timespec *ts)
6590 struct ixgbe_adapter *adapter =
6591 (struct ixgbe_adapter *)dev->data->dev_private;
6593 ns = rte_timespec_to_ns(ts);
6594 /* Set the timecounters to a new value. */
6595 adapter->systime_tc.nsec = ns;
6596 adapter->rx_tstamp_tc.nsec = ns;
6597 adapter->tx_tstamp_tc.nsec = ns;
6603 ixgbe_timesync_read_time(struct rte_eth_dev *dev, struct timespec *ts)
6605 uint64_t ns, systime_cycles;
6606 struct ixgbe_adapter *adapter =
6607 (struct ixgbe_adapter *)dev->data->dev_private;
6609 systime_cycles = ixgbe_read_systime_cyclecounter(dev);
6610 ns = rte_timecounter_update(&adapter->systime_tc, systime_cycles);
6611 *ts = rte_ns_to_timespec(ns);
6617 ixgbe_timesync_enable(struct rte_eth_dev *dev)
6619 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6623 /* Stop the timesync system time. */
6624 IXGBE_WRITE_REG(hw, IXGBE_TIMINCA, 0x0);
6625 /* Reset the timesync system time value. */
6626 IXGBE_WRITE_REG(hw, IXGBE_SYSTIML, 0x0);
6627 IXGBE_WRITE_REG(hw, IXGBE_SYSTIMH, 0x0);
6629 /* Enable system time for platforms where it isn't on by default. */
6630 tsauxc = IXGBE_READ_REG(hw, IXGBE_TSAUXC);
6631 tsauxc &= ~IXGBE_TSAUXC_DISABLE_SYSTIME;
6632 IXGBE_WRITE_REG(hw, IXGBE_TSAUXC, tsauxc);
6634 ixgbe_start_timecounters(dev);
6636 /* Enable L2 filtering of IEEE1588/802.1AS Ethernet frame types. */
6637 IXGBE_WRITE_REG(hw, IXGBE_ETQF(IXGBE_ETQF_FILTER_1588),
6639 IXGBE_ETQF_FILTER_EN |
6642 /* Enable timestamping of received PTP packets. */
6643 tsync_ctl = IXGBE_READ_REG(hw, IXGBE_TSYNCRXCTL);
6644 tsync_ctl |= IXGBE_TSYNCRXCTL_ENABLED;
6645 IXGBE_WRITE_REG(hw, IXGBE_TSYNCRXCTL, tsync_ctl);
6647 /* Enable timestamping of transmitted PTP packets. */
6648 tsync_ctl = IXGBE_READ_REG(hw, IXGBE_TSYNCTXCTL);
6649 tsync_ctl |= IXGBE_TSYNCTXCTL_ENABLED;
6650 IXGBE_WRITE_REG(hw, IXGBE_TSYNCTXCTL, tsync_ctl);
6652 IXGBE_WRITE_FLUSH(hw);
6658 ixgbe_timesync_disable(struct rte_eth_dev *dev)
6660 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6663 /* Disable timestamping of transmitted PTP packets. */
6664 tsync_ctl = IXGBE_READ_REG(hw, IXGBE_TSYNCTXCTL);
6665 tsync_ctl &= ~IXGBE_TSYNCTXCTL_ENABLED;
6666 IXGBE_WRITE_REG(hw, IXGBE_TSYNCTXCTL, tsync_ctl);
6668 /* Disable timestamping of received PTP packets. */
6669 tsync_ctl = IXGBE_READ_REG(hw, IXGBE_TSYNCRXCTL);
6670 tsync_ctl &= ~IXGBE_TSYNCRXCTL_ENABLED;
6671 IXGBE_WRITE_REG(hw, IXGBE_TSYNCRXCTL, tsync_ctl);
6673 /* Disable L2 filtering of IEEE1588/802.1AS Ethernet frame types. */
6674 IXGBE_WRITE_REG(hw, IXGBE_ETQF(IXGBE_ETQF_FILTER_1588), 0);
6676 /* Stop incrementating the System Time registers. */
6677 IXGBE_WRITE_REG(hw, IXGBE_TIMINCA, 0);
6683 ixgbe_timesync_read_rx_timestamp(struct rte_eth_dev *dev,
6684 struct timespec *timestamp,
6685 uint32_t flags __rte_unused)
6687 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6688 struct ixgbe_adapter *adapter =
6689 (struct ixgbe_adapter *)dev->data->dev_private;
6690 uint32_t tsync_rxctl;
6691 uint64_t rx_tstamp_cycles;
6694 tsync_rxctl = IXGBE_READ_REG(hw, IXGBE_TSYNCRXCTL);
6695 if ((tsync_rxctl & IXGBE_TSYNCRXCTL_VALID) == 0)
6698 rx_tstamp_cycles = ixgbe_read_rx_tstamp_cyclecounter(dev);
6699 ns = rte_timecounter_update(&adapter->rx_tstamp_tc, rx_tstamp_cycles);
6700 *timestamp = rte_ns_to_timespec(ns);
6706 ixgbe_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
6707 struct timespec *timestamp)
6709 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6710 struct ixgbe_adapter *adapter =
6711 (struct ixgbe_adapter *)dev->data->dev_private;
6712 uint32_t tsync_txctl;
6713 uint64_t tx_tstamp_cycles;
6716 tsync_txctl = IXGBE_READ_REG(hw, IXGBE_TSYNCTXCTL);
6717 if ((tsync_txctl & IXGBE_TSYNCTXCTL_VALID) == 0)
6720 tx_tstamp_cycles = ixgbe_read_tx_tstamp_cyclecounter(dev);
6721 ns = rte_timecounter_update(&adapter->tx_tstamp_tc, tx_tstamp_cycles);
6722 *timestamp = rte_ns_to_timespec(ns);
6728 ixgbe_get_reg_length(struct rte_eth_dev *dev)
6730 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6733 const struct reg_info *reg_group;
6734 const struct reg_info **reg_set = (hw->mac.type == ixgbe_mac_82598EB) ?
6735 ixgbe_regs_mac_82598EB : ixgbe_regs_others;
6737 while ((reg_group = reg_set[g_ind++]))
6738 count += ixgbe_regs_group_count(reg_group);
6744 ixgbevf_get_reg_length(struct rte_eth_dev *dev __rte_unused)
6748 const struct reg_info *reg_group;
6750 while ((reg_group = ixgbevf_regs[g_ind++]))
6751 count += ixgbe_regs_group_count(reg_group);
6757 ixgbe_get_regs(struct rte_eth_dev *dev,
6758 struct rte_dev_reg_info *regs)
6760 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6761 uint32_t *data = regs->data;
6764 const struct reg_info *reg_group;
6765 const struct reg_info **reg_set = (hw->mac.type == ixgbe_mac_82598EB) ?
6766 ixgbe_regs_mac_82598EB : ixgbe_regs_others;
6769 regs->length = ixgbe_get_reg_length(dev);
6770 regs->width = sizeof(uint32_t);
6774 /* Support only full register dump */
6775 if ((regs->length == 0) ||
6776 (regs->length == (uint32_t)ixgbe_get_reg_length(dev))) {
6777 regs->version = hw->mac.type << 24 | hw->revision_id << 16 |
6779 while ((reg_group = reg_set[g_ind++]))
6780 count += ixgbe_read_regs_group(dev, &data[count],
6789 ixgbevf_get_regs(struct rte_eth_dev *dev,
6790 struct rte_dev_reg_info *regs)
6792 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6793 uint32_t *data = regs->data;
6796 const struct reg_info *reg_group;
6799 regs->length = ixgbevf_get_reg_length(dev);
6800 regs->width = sizeof(uint32_t);
6804 /* Support only full register dump */
6805 if ((regs->length == 0) ||
6806 (regs->length == (uint32_t)ixgbevf_get_reg_length(dev))) {
6807 regs->version = hw->mac.type << 24 | hw->revision_id << 16 |
6809 while ((reg_group = ixgbevf_regs[g_ind++]))
6810 count += ixgbe_read_regs_group(dev, &data[count],
6819 ixgbe_get_eeprom_length(struct rte_eth_dev *dev)
6821 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6823 /* Return unit is byte count */
6824 return hw->eeprom.word_size * 2;
6828 ixgbe_get_eeprom(struct rte_eth_dev *dev,
6829 struct rte_dev_eeprom_info *in_eeprom)
6831 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6832 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
6833 uint16_t *data = in_eeprom->data;
6836 first = in_eeprom->offset >> 1;
6837 length = in_eeprom->length >> 1;
6838 if ((first > hw->eeprom.word_size) ||
6839 ((first + length) > hw->eeprom.word_size))
6842 in_eeprom->magic = hw->vendor_id | (hw->device_id << 16);
6844 return eeprom->ops.read_buffer(hw, first, length, data);
6848 ixgbe_set_eeprom(struct rte_eth_dev *dev,
6849 struct rte_dev_eeprom_info *in_eeprom)
6851 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6852 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
6853 uint16_t *data = in_eeprom->data;
6856 first = in_eeprom->offset >> 1;
6857 length = in_eeprom->length >> 1;
6858 if ((first > hw->eeprom.word_size) ||
6859 ((first + length) > hw->eeprom.word_size))
6862 in_eeprom->magic = hw->vendor_id | (hw->device_id << 16);
6864 return eeprom->ops.write_buffer(hw, first, length, data);
6868 ixgbe_reta_size_get(enum ixgbe_mac_type mac_type) {
6870 case ixgbe_mac_X550:
6871 case ixgbe_mac_X550EM_x:
6872 case ixgbe_mac_X550EM_a:
6873 return ETH_RSS_RETA_SIZE_512;
6874 case ixgbe_mac_X550_vf:
6875 case ixgbe_mac_X550EM_x_vf:
6876 case ixgbe_mac_X550EM_a_vf:
6877 return ETH_RSS_RETA_SIZE_64;
6879 return ETH_RSS_RETA_SIZE_128;
6884 ixgbe_reta_reg_get(enum ixgbe_mac_type mac_type, uint16_t reta_idx) {
6886 case ixgbe_mac_X550:
6887 case ixgbe_mac_X550EM_x:
6888 case ixgbe_mac_X550EM_a:
6889 if (reta_idx < ETH_RSS_RETA_SIZE_128)
6890 return IXGBE_RETA(reta_idx >> 2);
6892 return IXGBE_ERETA((reta_idx - ETH_RSS_RETA_SIZE_128) >> 2);
6893 case ixgbe_mac_X550_vf:
6894 case ixgbe_mac_X550EM_x_vf:
6895 case ixgbe_mac_X550EM_a_vf:
6896 return IXGBE_VFRETA(reta_idx >> 2);
6898 return IXGBE_RETA(reta_idx >> 2);
6903 ixgbe_mrqc_reg_get(enum ixgbe_mac_type mac_type) {
6905 case ixgbe_mac_X550_vf:
6906 case ixgbe_mac_X550EM_x_vf:
6907 case ixgbe_mac_X550EM_a_vf:
6908 return IXGBE_VFMRQC;
6915 ixgbe_rssrk_reg_get(enum ixgbe_mac_type mac_type, uint8_t i) {
6917 case ixgbe_mac_X550_vf:
6918 case ixgbe_mac_X550EM_x_vf:
6919 case ixgbe_mac_X550EM_a_vf:
6920 return IXGBE_VFRSSRK(i);
6922 return IXGBE_RSSRK(i);
6927 ixgbe_rss_update_sp(enum ixgbe_mac_type mac_type) {
6929 case ixgbe_mac_82599_vf:
6930 case ixgbe_mac_X540_vf:
6938 ixgbe_dev_get_dcb_info(struct rte_eth_dev *dev,
6939 struct rte_eth_dcb_info *dcb_info)
6941 struct ixgbe_dcb_config *dcb_config =
6942 IXGBE_DEV_PRIVATE_TO_DCB_CFG(dev->data->dev_private);
6943 struct ixgbe_dcb_tc_config *tc;
6946 if (dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_DCB_FLAG)
6947 dcb_info->nb_tcs = dcb_config->num_tcs.pg_tcs;
6949 dcb_info->nb_tcs = 1;
6951 if (dcb_config->vt_mode) { /* vt is enabled*/
6952 struct rte_eth_vmdq_dcb_conf *vmdq_rx_conf =
6953 &dev->data->dev_conf.rx_adv_conf.vmdq_dcb_conf;
6954 for (i = 0; i < ETH_DCB_NUM_USER_PRIORITIES; i++)
6955 dcb_info->prio_tc[i] = vmdq_rx_conf->dcb_tc[i];
6956 for (i = 0; i < vmdq_rx_conf->nb_queue_pools; i++) {
6957 for (j = 0; j < dcb_info->nb_tcs; j++) {
6958 dcb_info->tc_queue.tc_rxq[i][j].base =
6959 i * dcb_info->nb_tcs + j;
6960 dcb_info->tc_queue.tc_rxq[i][j].nb_queue = 1;
6961 dcb_info->tc_queue.tc_txq[i][j].base =
6962 i * dcb_info->nb_tcs + j;
6963 dcb_info->tc_queue.tc_txq[i][j].nb_queue = 1;
6966 } else { /* vt is disabled*/
6967 struct rte_eth_dcb_rx_conf *rx_conf =
6968 &dev->data->dev_conf.rx_adv_conf.dcb_rx_conf;
6969 for (i = 0; i < ETH_DCB_NUM_USER_PRIORITIES; i++)
6970 dcb_info->prio_tc[i] = rx_conf->dcb_tc[i];
6971 if (dcb_info->nb_tcs == ETH_4_TCS) {
6972 for (i = 0; i < dcb_info->nb_tcs; i++) {
6973 dcb_info->tc_queue.tc_rxq[0][i].base = i * 32;
6974 dcb_info->tc_queue.tc_rxq[0][i].nb_queue = 16;
6976 dcb_info->tc_queue.tc_txq[0][0].base = 0;
6977 dcb_info->tc_queue.tc_txq[0][1].base = 64;
6978 dcb_info->tc_queue.tc_txq[0][2].base = 96;
6979 dcb_info->tc_queue.tc_txq[0][3].base = 112;
6980 dcb_info->tc_queue.tc_txq[0][0].nb_queue = 64;
6981 dcb_info->tc_queue.tc_txq[0][1].nb_queue = 32;
6982 dcb_info->tc_queue.tc_txq[0][2].nb_queue = 16;
6983 dcb_info->tc_queue.tc_txq[0][3].nb_queue = 16;
6984 } else if (dcb_info->nb_tcs == ETH_8_TCS) {
6985 for (i = 0; i < dcb_info->nb_tcs; i++) {
6986 dcb_info->tc_queue.tc_rxq[0][i].base = i * 16;
6987 dcb_info->tc_queue.tc_rxq[0][i].nb_queue = 16;
6989 dcb_info->tc_queue.tc_txq[0][0].base = 0;
6990 dcb_info->tc_queue.tc_txq[0][1].base = 32;
6991 dcb_info->tc_queue.tc_txq[0][2].base = 64;
6992 dcb_info->tc_queue.tc_txq[0][3].base = 80;
6993 dcb_info->tc_queue.tc_txq[0][4].base = 96;
6994 dcb_info->tc_queue.tc_txq[0][5].base = 104;
6995 dcb_info->tc_queue.tc_txq[0][6].base = 112;
6996 dcb_info->tc_queue.tc_txq[0][7].base = 120;
6997 dcb_info->tc_queue.tc_txq[0][0].nb_queue = 32;
6998 dcb_info->tc_queue.tc_txq[0][1].nb_queue = 32;
6999 dcb_info->tc_queue.tc_txq[0][2].nb_queue = 16;
7000 dcb_info->tc_queue.tc_txq[0][3].nb_queue = 16;
7001 dcb_info->tc_queue.tc_txq[0][4].nb_queue = 8;
7002 dcb_info->tc_queue.tc_txq[0][5].nb_queue = 8;
7003 dcb_info->tc_queue.tc_txq[0][6].nb_queue = 8;
7004 dcb_info->tc_queue.tc_txq[0][7].nb_queue = 8;
7007 for (i = 0; i < dcb_info->nb_tcs; i++) {
7008 tc = &dcb_config->tc_config[i];
7009 dcb_info->tc_bws[i] = tc->path[IXGBE_DCB_TX_CONFIG].bwg_percent;
7014 /* Update e-tag ether type */
7016 ixgbe_update_e_tag_eth_type(struct ixgbe_hw *hw,
7017 uint16_t ether_type)
7019 uint32_t etag_etype;
7021 if (hw->mac.type != ixgbe_mac_X550 &&
7022 hw->mac.type != ixgbe_mac_X550EM_x &&
7023 hw->mac.type != ixgbe_mac_X550EM_a) {
7027 etag_etype = IXGBE_READ_REG(hw, IXGBE_ETAG_ETYPE);
7028 etag_etype &= ~IXGBE_ETAG_ETYPE_MASK;
7029 etag_etype |= ether_type;
7030 IXGBE_WRITE_REG(hw, IXGBE_ETAG_ETYPE, etag_etype);
7031 IXGBE_WRITE_FLUSH(hw);
7036 /* Config l2 tunnel ether type */
7038 ixgbe_dev_l2_tunnel_eth_type_conf(struct rte_eth_dev *dev,
7039 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7042 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7044 if (l2_tunnel == NULL)
7047 switch (l2_tunnel->l2_tunnel_type) {
7048 case RTE_L2_TUNNEL_TYPE_E_TAG:
7049 ret = ixgbe_update_e_tag_eth_type(hw, l2_tunnel->ether_type);
7052 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7060 /* Enable e-tag tunnel */
7062 ixgbe_e_tag_enable(struct ixgbe_hw *hw)
7064 uint32_t etag_etype;
7066 if (hw->mac.type != ixgbe_mac_X550 &&
7067 hw->mac.type != ixgbe_mac_X550EM_x &&
7068 hw->mac.type != ixgbe_mac_X550EM_a) {
7072 etag_etype = IXGBE_READ_REG(hw, IXGBE_ETAG_ETYPE);
7073 etag_etype |= IXGBE_ETAG_ETYPE_VALID;
7074 IXGBE_WRITE_REG(hw, IXGBE_ETAG_ETYPE, etag_etype);
7075 IXGBE_WRITE_FLUSH(hw);
7080 /* Enable l2 tunnel */
7082 ixgbe_dev_l2_tunnel_enable(struct rte_eth_dev *dev,
7083 enum rte_eth_tunnel_type l2_tunnel_type)
7086 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7088 switch (l2_tunnel_type) {
7089 case RTE_L2_TUNNEL_TYPE_E_TAG:
7090 ret = ixgbe_e_tag_enable(hw);
7093 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7101 /* Disable e-tag tunnel */
7103 ixgbe_e_tag_disable(struct ixgbe_hw *hw)
7105 uint32_t etag_etype;
7107 if (hw->mac.type != ixgbe_mac_X550 &&
7108 hw->mac.type != ixgbe_mac_X550EM_x &&
7109 hw->mac.type != ixgbe_mac_X550EM_a) {
7113 etag_etype = IXGBE_READ_REG(hw, IXGBE_ETAG_ETYPE);
7114 etag_etype &= ~IXGBE_ETAG_ETYPE_VALID;
7115 IXGBE_WRITE_REG(hw, IXGBE_ETAG_ETYPE, etag_etype);
7116 IXGBE_WRITE_FLUSH(hw);
7121 /* Disable l2 tunnel */
7123 ixgbe_dev_l2_tunnel_disable(struct rte_eth_dev *dev,
7124 enum rte_eth_tunnel_type l2_tunnel_type)
7127 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7129 switch (l2_tunnel_type) {
7130 case RTE_L2_TUNNEL_TYPE_E_TAG:
7131 ret = ixgbe_e_tag_disable(hw);
7134 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7143 ixgbe_e_tag_filter_del(struct rte_eth_dev *dev,
7144 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7147 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7148 uint32_t i, rar_entries;
7149 uint32_t rar_low, rar_high;
7151 if (hw->mac.type != ixgbe_mac_X550 &&
7152 hw->mac.type != ixgbe_mac_X550EM_x &&
7153 hw->mac.type != ixgbe_mac_X550EM_a) {
7157 rar_entries = ixgbe_get_num_rx_addrs(hw);
7159 for (i = 1; i < rar_entries; i++) {
7160 rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(i));
7161 rar_low = IXGBE_READ_REG(hw, IXGBE_RAL(i));
7162 if ((rar_high & IXGBE_RAH_AV) &&
7163 (rar_high & IXGBE_RAH_ADTYPE) &&
7164 ((rar_low & IXGBE_RAL_ETAG_FILTER_MASK) ==
7165 l2_tunnel->tunnel_id)) {
7166 IXGBE_WRITE_REG(hw, IXGBE_RAL(i), 0);
7167 IXGBE_WRITE_REG(hw, IXGBE_RAH(i), 0);
7169 ixgbe_clear_vmdq(hw, i, IXGBE_CLEAR_VMDQ_ALL);
7179 ixgbe_e_tag_filter_add(struct rte_eth_dev *dev,
7180 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7183 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7184 uint32_t i, rar_entries;
7185 uint32_t rar_low, rar_high;
7187 if (hw->mac.type != ixgbe_mac_X550 &&
7188 hw->mac.type != ixgbe_mac_X550EM_x &&
7189 hw->mac.type != ixgbe_mac_X550EM_a) {
7193 /* One entry for one tunnel. Try to remove potential existing entry. */
7194 ixgbe_e_tag_filter_del(dev, l2_tunnel);
7196 rar_entries = ixgbe_get_num_rx_addrs(hw);
7198 for (i = 1; i < rar_entries; i++) {
7199 rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(i));
7200 if (rar_high & IXGBE_RAH_AV) {
7203 ixgbe_set_vmdq(hw, i, l2_tunnel->pool);
7204 rar_high = IXGBE_RAH_AV | IXGBE_RAH_ADTYPE;
7205 rar_low = l2_tunnel->tunnel_id;
7207 IXGBE_WRITE_REG(hw, IXGBE_RAL(i), rar_low);
7208 IXGBE_WRITE_REG(hw, IXGBE_RAH(i), rar_high);
7214 PMD_INIT_LOG(NOTICE, "The table of E-tag forwarding rule is full."
7215 " Please remove a rule before adding a new one.");
7219 /* Add l2 tunnel filter */
7221 ixgbe_dev_l2_tunnel_filter_add(struct rte_eth_dev *dev,
7222 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7226 switch (l2_tunnel->l2_tunnel_type) {
7227 case RTE_L2_TUNNEL_TYPE_E_TAG:
7228 ret = ixgbe_e_tag_filter_add(dev, l2_tunnel);
7231 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7239 /* Delete l2 tunnel filter */
7241 ixgbe_dev_l2_tunnel_filter_del(struct rte_eth_dev *dev,
7242 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7246 switch (l2_tunnel->l2_tunnel_type) {
7247 case RTE_L2_TUNNEL_TYPE_E_TAG:
7248 ret = ixgbe_e_tag_filter_del(dev, l2_tunnel);
7251 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7260 * ixgbe_dev_l2_tunnel_filter_handle - Handle operations for l2 tunnel filter.
7261 * @dev: pointer to rte_eth_dev structure
7262 * @filter_op:operation will be taken.
7263 * @arg: a pointer to specific structure corresponding to the filter_op
7266 ixgbe_dev_l2_tunnel_filter_handle(struct rte_eth_dev *dev,
7267 enum rte_filter_op filter_op,
7272 if (filter_op == RTE_ETH_FILTER_NOP)
7276 PMD_DRV_LOG(ERR, "arg shouldn't be NULL for operation %u.",
7281 switch (filter_op) {
7282 case RTE_ETH_FILTER_ADD:
7283 ret = ixgbe_dev_l2_tunnel_filter_add
7285 (struct rte_eth_l2_tunnel_conf *)arg);
7287 case RTE_ETH_FILTER_DELETE:
7288 ret = ixgbe_dev_l2_tunnel_filter_del
7290 (struct rte_eth_l2_tunnel_conf *)arg);
7293 PMD_DRV_LOG(ERR, "unsupported operation %u.", filter_op);
7301 ixgbe_e_tag_forwarding_en_dis(struct rte_eth_dev *dev, bool en)
7305 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7307 if (hw->mac.type != ixgbe_mac_X550 &&
7308 hw->mac.type != ixgbe_mac_X550EM_x &&
7309 hw->mac.type != ixgbe_mac_X550EM_a) {
7313 ctrl = IXGBE_READ_REG(hw, IXGBE_VT_CTL);
7314 ctrl &= ~IXGBE_VT_CTL_POOLING_MODE_MASK;
7316 ctrl |= IXGBE_VT_CTL_POOLING_MODE_ETAG;
7317 IXGBE_WRITE_REG(hw, IXGBE_VT_CTL, ctrl);
7322 /* Enable l2 tunnel forwarding */
7324 ixgbe_dev_l2_tunnel_forwarding_enable
7325 (struct rte_eth_dev *dev,
7326 enum rte_eth_tunnel_type l2_tunnel_type)
7330 switch (l2_tunnel_type) {
7331 case RTE_L2_TUNNEL_TYPE_E_TAG:
7332 ret = ixgbe_e_tag_forwarding_en_dis(dev, 1);
7335 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7343 /* Disable l2 tunnel forwarding */
7345 ixgbe_dev_l2_tunnel_forwarding_disable
7346 (struct rte_eth_dev *dev,
7347 enum rte_eth_tunnel_type l2_tunnel_type)
7351 switch (l2_tunnel_type) {
7352 case RTE_L2_TUNNEL_TYPE_E_TAG:
7353 ret = ixgbe_e_tag_forwarding_en_dis(dev, 0);
7356 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7365 ixgbe_e_tag_insertion_en_dis(struct rte_eth_dev *dev,
7366 struct rte_eth_l2_tunnel_conf *l2_tunnel,
7369 struct rte_pci_device *pci_dev = IXGBE_DEV_TO_PCI(dev);
7371 uint32_t vmtir, vmvir;
7372 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7374 if (l2_tunnel->vf_id >= pci_dev->max_vfs) {
7376 "VF id %u should be less than %u",
7382 if (hw->mac.type != ixgbe_mac_X550 &&
7383 hw->mac.type != ixgbe_mac_X550EM_x &&
7384 hw->mac.type != ixgbe_mac_X550EM_a) {
7389 vmtir = l2_tunnel->tunnel_id;
7393 IXGBE_WRITE_REG(hw, IXGBE_VMTIR(l2_tunnel->vf_id), vmtir);
7395 vmvir = IXGBE_READ_REG(hw, IXGBE_VMVIR(l2_tunnel->vf_id));
7396 vmvir &= ~IXGBE_VMVIR_TAGA_MASK;
7398 vmvir |= IXGBE_VMVIR_TAGA_ETAG_INSERT;
7399 IXGBE_WRITE_REG(hw, IXGBE_VMVIR(l2_tunnel->vf_id), vmvir);
7404 /* Enable l2 tunnel tag insertion */
7406 ixgbe_dev_l2_tunnel_insertion_enable(struct rte_eth_dev *dev,
7407 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7411 switch (l2_tunnel->l2_tunnel_type) {
7412 case RTE_L2_TUNNEL_TYPE_E_TAG:
7413 ret = ixgbe_e_tag_insertion_en_dis(dev, l2_tunnel, 1);
7416 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7424 /* Disable l2 tunnel tag insertion */
7426 ixgbe_dev_l2_tunnel_insertion_disable
7427 (struct rte_eth_dev *dev,
7428 struct rte_eth_l2_tunnel_conf *l2_tunnel)
7432 switch (l2_tunnel->l2_tunnel_type) {
7433 case RTE_L2_TUNNEL_TYPE_E_TAG:
7434 ret = ixgbe_e_tag_insertion_en_dis(dev, l2_tunnel, 0);
7437 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7446 ixgbe_e_tag_stripping_en_dis(struct rte_eth_dev *dev,
7451 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7453 if (hw->mac.type != ixgbe_mac_X550 &&
7454 hw->mac.type != ixgbe_mac_X550EM_x &&
7455 hw->mac.type != ixgbe_mac_X550EM_a) {
7459 qde = IXGBE_READ_REG(hw, IXGBE_QDE);
7461 qde |= IXGBE_QDE_STRIP_TAG;
7463 qde &= ~IXGBE_QDE_STRIP_TAG;
7464 qde &= ~IXGBE_QDE_READ;
7465 qde |= IXGBE_QDE_WRITE;
7466 IXGBE_WRITE_REG(hw, IXGBE_QDE, qde);
7471 /* Enable l2 tunnel tag stripping */
7473 ixgbe_dev_l2_tunnel_stripping_enable
7474 (struct rte_eth_dev *dev,
7475 enum rte_eth_tunnel_type l2_tunnel_type)
7479 switch (l2_tunnel_type) {
7480 case RTE_L2_TUNNEL_TYPE_E_TAG:
7481 ret = ixgbe_e_tag_stripping_en_dis(dev, 1);
7484 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7492 /* Disable l2 tunnel tag stripping */
7494 ixgbe_dev_l2_tunnel_stripping_disable
7495 (struct rte_eth_dev *dev,
7496 enum rte_eth_tunnel_type l2_tunnel_type)
7500 switch (l2_tunnel_type) {
7501 case RTE_L2_TUNNEL_TYPE_E_TAG:
7502 ret = ixgbe_e_tag_stripping_en_dis(dev, 0);
7505 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7513 /* Enable/disable l2 tunnel offload functions */
7515 ixgbe_dev_l2_tunnel_offload_set
7516 (struct rte_eth_dev *dev,
7517 struct rte_eth_l2_tunnel_conf *l2_tunnel,
7523 if (l2_tunnel == NULL)
7527 if (mask & ETH_L2_TUNNEL_ENABLE_MASK) {
7529 ret = ixgbe_dev_l2_tunnel_enable(
7531 l2_tunnel->l2_tunnel_type);
7533 ret = ixgbe_dev_l2_tunnel_disable(
7535 l2_tunnel->l2_tunnel_type);
7538 if (mask & ETH_L2_TUNNEL_INSERTION_MASK) {
7540 ret = ixgbe_dev_l2_tunnel_insertion_enable(
7544 ret = ixgbe_dev_l2_tunnel_insertion_disable(
7549 if (mask & ETH_L2_TUNNEL_STRIPPING_MASK) {
7551 ret = ixgbe_dev_l2_tunnel_stripping_enable(
7553 l2_tunnel->l2_tunnel_type);
7555 ret = ixgbe_dev_l2_tunnel_stripping_disable(
7557 l2_tunnel->l2_tunnel_type);
7560 if (mask & ETH_L2_TUNNEL_FORWARDING_MASK) {
7562 ret = ixgbe_dev_l2_tunnel_forwarding_enable(
7564 l2_tunnel->l2_tunnel_type);
7566 ret = ixgbe_dev_l2_tunnel_forwarding_disable(
7568 l2_tunnel->l2_tunnel_type);
7575 ixgbe_update_vxlan_port(struct ixgbe_hw *hw,
7578 IXGBE_WRITE_REG(hw, IXGBE_VXLANCTRL, port);
7579 IXGBE_WRITE_FLUSH(hw);
7584 /* There's only one register for VxLAN UDP port.
7585 * So, we cannot add several ports. Will update it.
7588 ixgbe_add_vxlan_port(struct ixgbe_hw *hw,
7592 PMD_DRV_LOG(ERR, "Add VxLAN port 0 is not allowed.");
7596 return ixgbe_update_vxlan_port(hw, port);
7599 /* We cannot delete the VxLAN port. For there's a register for VxLAN
7600 * UDP port, it must have a value.
7601 * So, will reset it to the original value 0.
7604 ixgbe_del_vxlan_port(struct ixgbe_hw *hw,
7609 cur_port = (uint16_t)IXGBE_READ_REG(hw, IXGBE_VXLANCTRL);
7611 if (cur_port != port) {
7612 PMD_DRV_LOG(ERR, "Port %u does not exist.", port);
7616 return ixgbe_update_vxlan_port(hw, 0);
7619 /* Add UDP tunneling port */
7621 ixgbe_dev_udp_tunnel_port_add(struct rte_eth_dev *dev,
7622 struct rte_eth_udp_tunnel *udp_tunnel)
7625 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7627 if (hw->mac.type != ixgbe_mac_X550 &&
7628 hw->mac.type != ixgbe_mac_X550EM_x &&
7629 hw->mac.type != ixgbe_mac_X550EM_a) {
7633 if (udp_tunnel == NULL)
7636 switch (udp_tunnel->prot_type) {
7637 case RTE_TUNNEL_TYPE_VXLAN:
7638 ret = ixgbe_add_vxlan_port(hw, udp_tunnel->udp_port);
7641 case RTE_TUNNEL_TYPE_GENEVE:
7642 case RTE_TUNNEL_TYPE_TEREDO:
7643 PMD_DRV_LOG(ERR, "Tunnel type is not supported now.");
7648 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7656 /* Remove UDP tunneling port */
7658 ixgbe_dev_udp_tunnel_port_del(struct rte_eth_dev *dev,
7659 struct rte_eth_udp_tunnel *udp_tunnel)
7662 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7664 if (hw->mac.type != ixgbe_mac_X550 &&
7665 hw->mac.type != ixgbe_mac_X550EM_x &&
7666 hw->mac.type != ixgbe_mac_X550EM_a) {
7670 if (udp_tunnel == NULL)
7673 switch (udp_tunnel->prot_type) {
7674 case RTE_TUNNEL_TYPE_VXLAN:
7675 ret = ixgbe_del_vxlan_port(hw, udp_tunnel->udp_port);
7677 case RTE_TUNNEL_TYPE_GENEVE:
7678 case RTE_TUNNEL_TYPE_TEREDO:
7679 PMD_DRV_LOG(ERR, "Tunnel type is not supported now.");
7683 PMD_DRV_LOG(ERR, "Invalid tunnel type");
7692 ixgbevf_dev_allmulticast_enable(struct rte_eth_dev *dev)
7694 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7696 hw->mac.ops.update_xcast_mode(hw, IXGBEVF_XCAST_MODE_ALLMULTI);
7700 ixgbevf_dev_allmulticast_disable(struct rte_eth_dev *dev)
7702 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7704 hw->mac.ops.update_xcast_mode(hw, IXGBEVF_XCAST_MODE_NONE);
7707 static void ixgbevf_mbx_process(struct rte_eth_dev *dev)
7709 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7712 if (ixgbe_read_mbx(hw, &in_msg, 1, 0))
7715 /* PF reset VF event */
7716 if (in_msg == IXGBE_PF_CONTROL_MSG)
7717 _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RESET, NULL);
7721 ixgbevf_dev_interrupt_get_status(struct rte_eth_dev *dev)
7724 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7725 struct ixgbe_interrupt *intr =
7726 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
7727 ixgbevf_intr_disable(hw);
7729 /* read-on-clear nic registers here */
7730 eicr = IXGBE_READ_REG(hw, IXGBE_VTEICR);
7733 /* only one misc vector supported - mailbox */
7734 eicr &= IXGBE_VTEICR_MASK;
7735 if (eicr == IXGBE_MISC_VEC_ID)
7736 intr->flags |= IXGBE_FLAG_MAILBOX;
7742 ixgbevf_dev_interrupt_action(struct rte_eth_dev *dev)
7744 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7745 struct ixgbe_interrupt *intr =
7746 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
7748 if (intr->flags & IXGBE_FLAG_MAILBOX) {
7749 ixgbevf_mbx_process(dev);
7750 intr->flags &= ~IXGBE_FLAG_MAILBOX;
7753 ixgbevf_intr_enable(hw);
7759 ixgbevf_dev_interrupt_handler(__rte_unused struct rte_intr_handle *handle,
7762 struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
7764 ixgbevf_dev_interrupt_get_status(dev);
7765 ixgbevf_dev_interrupt_action(dev);
7769 * ixgbe_disable_sec_tx_path_generic - Stops the transmit data path
7770 * @hw: pointer to hardware structure
7772 * Stops the transmit data path and waits for the HW to internally empty
7773 * the Tx security block
7775 int ixgbe_disable_sec_tx_path_generic(struct ixgbe_hw *hw)
7777 #define IXGBE_MAX_SECTX_POLL 40
7782 sectxreg = IXGBE_READ_REG(hw, IXGBE_SECTXCTRL);
7783 sectxreg |= IXGBE_SECTXCTRL_TX_DIS;
7784 IXGBE_WRITE_REG(hw, IXGBE_SECTXCTRL, sectxreg);
7785 for (i = 0; i < IXGBE_MAX_SECTX_POLL; i++) {
7786 sectxreg = IXGBE_READ_REG(hw, IXGBE_SECTXSTAT);
7787 if (sectxreg & IXGBE_SECTXSTAT_SECTX_RDY)
7789 /* Use interrupt-safe sleep just in case */
7793 /* For informational purposes only */
7794 if (i >= IXGBE_MAX_SECTX_POLL)
7795 PMD_DRV_LOG(DEBUG, "Tx unit being enabled before security "
7796 "path fully disabled. Continuing with init.\n");
7798 return IXGBE_SUCCESS;
7802 * ixgbe_enable_sec_tx_path_generic - Enables the transmit data path
7803 * @hw: pointer to hardware structure
7805 * Enables the transmit data path.
7807 int ixgbe_enable_sec_tx_path_generic(struct ixgbe_hw *hw)
7811 sectxreg = IXGBE_READ_REG(hw, IXGBE_SECTXCTRL);
7812 sectxreg &= ~IXGBE_SECTXCTRL_TX_DIS;
7813 IXGBE_WRITE_REG(hw, IXGBE_SECTXCTRL, sectxreg);
7814 IXGBE_WRITE_FLUSH(hw);
7816 return IXGBE_SUCCESS;
7820 rte_pmd_ixgbe_macsec_enable(uint8_t port, uint8_t en, uint8_t rp)
7822 struct ixgbe_hw *hw;
7823 struct rte_eth_dev *dev;
7826 RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
7828 dev = &rte_eth_devices[port];
7829 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7831 /* Stop the data paths */
7832 if (ixgbe_disable_sec_rx_path(hw) != IXGBE_SUCCESS)
7836 * As no ixgbe_disable_sec_rx_path equivalent is
7837 * implemented for tx in the base code, and we are
7838 * not allowed to modify the base code in DPDK, so
7839 * just call the hand-written one directly for now.
7840 * The hardware support has been checked by
7841 * ixgbe_disable_sec_rx_path().
7843 ixgbe_disable_sec_tx_path_generic(hw);
7845 /* Enable Ethernet CRC (required by MACsec offload) */
7846 ctrl = IXGBE_READ_REG(hw, IXGBE_HLREG0);
7847 ctrl |= IXGBE_HLREG0_TXCRCEN | IXGBE_HLREG0_RXCRCSTRP;
7848 IXGBE_WRITE_REG(hw, IXGBE_HLREG0, ctrl);
7850 /* Enable the TX and RX crypto engines */
7851 ctrl = IXGBE_READ_REG(hw, IXGBE_SECTXCTRL);
7852 ctrl &= ~IXGBE_SECTXCTRL_SECTX_DIS;
7853 IXGBE_WRITE_REG(hw, IXGBE_SECTXCTRL, ctrl);
7855 ctrl = IXGBE_READ_REG(hw, IXGBE_SECRXCTRL);
7856 ctrl &= ~IXGBE_SECRXCTRL_SECRX_DIS;
7857 IXGBE_WRITE_REG(hw, IXGBE_SECRXCTRL, ctrl);
7859 ctrl = IXGBE_READ_REG(hw, IXGBE_SECTXMINIFG);
7860 ctrl &= ~IXGBE_SECTX_MINSECIFG_MASK;
7862 IXGBE_WRITE_REG(hw, IXGBE_SECTXMINIFG, ctrl);
7864 /* Enable SA lookup */
7865 ctrl = IXGBE_READ_REG(hw, IXGBE_LSECTXCTRL);
7866 ctrl &= ~IXGBE_LSECTXCTRL_EN_MASK;
7867 ctrl |= en ? IXGBE_LSECTXCTRL_AUTH_ENCRYPT :
7868 IXGBE_LSECTXCTRL_AUTH;
7869 ctrl |= IXGBE_LSECTXCTRL_AISCI;
7870 ctrl &= ~IXGBE_LSECTXCTRL_PNTHRSH_MASK;
7871 ctrl |= IXGBE_MACSEC_PNTHRSH & IXGBE_LSECTXCTRL_PNTHRSH_MASK;
7872 IXGBE_WRITE_REG(hw, IXGBE_LSECTXCTRL, ctrl);
7874 ctrl = IXGBE_READ_REG(hw, IXGBE_LSECRXCTRL);
7875 ctrl &= ~IXGBE_LSECRXCTRL_EN_MASK;
7876 ctrl |= IXGBE_LSECRXCTRL_STRICT << IXGBE_LSECRXCTRL_EN_SHIFT;
7877 ctrl &= ~IXGBE_LSECRXCTRL_PLSH;
7879 ctrl |= IXGBE_LSECRXCTRL_RP;
7881 ctrl &= ~IXGBE_LSECRXCTRL_RP;
7882 IXGBE_WRITE_REG(hw, IXGBE_LSECRXCTRL, ctrl);
7884 /* Start the data paths */
7885 ixgbe_enable_sec_rx_path(hw);
7888 * As no ixgbe_enable_sec_rx_path equivalent is
7889 * implemented for tx in the base code, and we are
7890 * not allowed to modify the base code in DPDK, so
7891 * just call the hand-written one directly for now.
7893 ixgbe_enable_sec_tx_path_generic(hw);
7899 rte_pmd_ixgbe_macsec_disable(uint8_t port)
7901 struct ixgbe_hw *hw;
7902 struct rte_eth_dev *dev;
7905 RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
7907 dev = &rte_eth_devices[port];
7908 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7910 /* Stop the data paths */
7911 if (ixgbe_disable_sec_rx_path(hw) != IXGBE_SUCCESS)
7915 * As no ixgbe_disable_sec_rx_path equivalent is
7916 * implemented for tx in the base code, and we are
7917 * not allowed to modify the base code in DPDK, so
7918 * just call the hand-written one directly for now.
7919 * The hardware support has been checked by
7920 * ixgbe_disable_sec_rx_path().
7922 ixgbe_disable_sec_tx_path_generic(hw);
7924 /* Disable the TX and RX crypto engines */
7925 ctrl = IXGBE_READ_REG(hw, IXGBE_SECTXCTRL);
7926 ctrl |= IXGBE_SECTXCTRL_SECTX_DIS;
7927 IXGBE_WRITE_REG(hw, IXGBE_SECTXCTRL, ctrl);
7929 ctrl = IXGBE_READ_REG(hw, IXGBE_SECRXCTRL);
7930 ctrl |= IXGBE_SECRXCTRL_SECRX_DIS;
7931 IXGBE_WRITE_REG(hw, IXGBE_SECRXCTRL, ctrl);
7933 /* Disable SA lookup */
7934 ctrl = IXGBE_READ_REG(hw, IXGBE_LSECTXCTRL);
7935 ctrl &= ~IXGBE_LSECTXCTRL_EN_MASK;
7936 ctrl |= IXGBE_LSECTXCTRL_DISABLE;
7937 IXGBE_WRITE_REG(hw, IXGBE_LSECTXCTRL, ctrl);
7939 ctrl = IXGBE_READ_REG(hw, IXGBE_LSECRXCTRL);
7940 ctrl &= ~IXGBE_LSECRXCTRL_EN_MASK;
7941 ctrl |= IXGBE_LSECRXCTRL_DISABLE << IXGBE_LSECRXCTRL_EN_SHIFT;
7942 IXGBE_WRITE_REG(hw, IXGBE_LSECRXCTRL, ctrl);
7944 /* Start the data paths */
7945 ixgbe_enable_sec_rx_path(hw);
7948 * As no ixgbe_enable_sec_rx_path equivalent is
7949 * implemented for tx in the base code, and we are
7950 * not allowed to modify the base code in DPDK, so
7951 * just call the hand-written one directly for now.
7953 ixgbe_enable_sec_tx_path_generic(hw);
7959 rte_pmd_ixgbe_macsec_config_txsc(uint8_t port, uint8_t *mac)
7961 struct ixgbe_hw *hw;
7962 struct rte_eth_dev *dev;
7965 RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
7967 dev = &rte_eth_devices[port];
7968 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7970 ctrl = mac[0] | (mac[1] << 8) | (mac[2] << 16) | (mac[3] << 24);
7971 IXGBE_WRITE_REG(hw, IXGBE_LSECTXSCL, ctrl);
7973 ctrl = mac[4] | (mac[5] << 8);
7974 IXGBE_WRITE_REG(hw, IXGBE_LSECTXSCH, ctrl);
7980 rte_pmd_ixgbe_macsec_config_rxsc(uint8_t port, uint8_t *mac, uint16_t pi)
7982 struct ixgbe_hw *hw;
7983 struct rte_eth_dev *dev;
7986 RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
7988 dev = &rte_eth_devices[port];
7989 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7991 ctrl = mac[0] | (mac[1] << 8) | (mac[2] << 16) | (mac[3] << 24);
7992 IXGBE_WRITE_REG(hw, IXGBE_LSECRXSCL, ctrl);
7994 pi = rte_cpu_to_be_16(pi);
7995 ctrl = mac[4] | (mac[5] << 8) | (pi << 16);
7996 IXGBE_WRITE_REG(hw, IXGBE_LSECRXSCH, ctrl);
8002 rte_pmd_ixgbe_macsec_select_txsa(uint8_t port, uint8_t idx, uint8_t an,
8003 uint32_t pn, uint8_t *key)
8005 struct ixgbe_hw *hw;
8006 struct rte_eth_dev *dev;
8009 RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
8011 dev = &rte_eth_devices[port];
8012 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8014 if (idx != 0 && idx != 1)
8020 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8022 /* Set the PN and key */
8023 pn = rte_cpu_to_be_32(pn);
8025 IXGBE_WRITE_REG(hw, IXGBE_LSECTXPN0, pn);
8027 for (i = 0; i < 4; i++) {
8028 ctrl = (key[i * 4 + 0] << 0) |
8029 (key[i * 4 + 1] << 8) |
8030 (key[i * 4 + 2] << 16) |
8031 (key[i * 4 + 3] << 24);
8032 IXGBE_WRITE_REG(hw, IXGBE_LSECTXKEY0(i), ctrl);
8035 IXGBE_WRITE_REG(hw, IXGBE_LSECTXPN1, pn);
8037 for (i = 0; i < 4; i++) {
8038 ctrl = (key[i * 4 + 0] << 0) |
8039 (key[i * 4 + 1] << 8) |
8040 (key[i * 4 + 2] << 16) |
8041 (key[i * 4 + 3] << 24);
8042 IXGBE_WRITE_REG(hw, IXGBE_LSECTXKEY1(i), ctrl);
8046 /* Set AN and select the SA */
8047 ctrl = (an << idx * 2) | (idx << 4);
8048 IXGBE_WRITE_REG(hw, IXGBE_LSECTXSA, ctrl);
8054 rte_pmd_ixgbe_macsec_select_rxsa(uint8_t port, uint8_t idx, uint8_t an,
8055 uint32_t pn, uint8_t *key)
8057 struct ixgbe_hw *hw;
8058 struct rte_eth_dev *dev;
8061 RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
8063 dev = &rte_eth_devices[port];
8064 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8066 if (idx != 0 && idx != 1)
8073 pn = rte_cpu_to_be_32(pn);
8074 IXGBE_WRITE_REG(hw, IXGBE_LSECRXPN(idx), pn);
8077 for (i = 0; i < 4; i++) {
8078 ctrl = (key[i * 4 + 0] << 0) |
8079 (key[i * 4 + 1] << 8) |
8080 (key[i * 4 + 2] << 16) |
8081 (key[i * 4 + 3] << 24);
8082 IXGBE_WRITE_REG(hw, IXGBE_LSECRXKEY(idx, i), ctrl);
8085 /* Set the AN and validate the SA */
8086 ctrl = an | (1 << 2);
8087 IXGBE_WRITE_REG(hw, IXGBE_LSECRXSA(idx), ctrl);
8092 RTE_PMD_REGISTER_PCI(net_ixgbe, rte_ixgbe_pmd.pci_drv);
8093 RTE_PMD_REGISTER_PCI_TABLE(net_ixgbe, pci_id_ixgbe_map);
8094 RTE_PMD_REGISTER_KMOD_DEP(net_ixgbe, "* igb_uio | uio_pci_generic | vfio");
8095 RTE_PMD_REGISTER_PCI(net_ixgbe_vf, rte_ixgbevf_pmd.pci_drv);
8096 RTE_PMD_REGISTER_PCI_TABLE(net_ixgbe_vf, pci_id_ixgbevf_map);
8097 RTE_PMD_REGISTER_KMOD_DEP(net_ixgbe_vf, "* igb_uio | vfio");