4 * Copyright(c) 2010-2015 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"
76 * High threshold controlling when to start sending XOFF frames. Must be at
77 * least 8 bytes less than receive packet buffer size. This value is in units
80 #define IXGBE_FC_HI 0x80
83 * Low threshold controlling when to start sending XON frames. This value is
84 * in units of 1024 bytes.
86 #define IXGBE_FC_LO 0x40
88 /* Default minimum inter-interrupt interval for EITR configuration */
89 #define IXGBE_MIN_INTER_INTERRUPT_INTERVAL_DEFAULT 0x79E
91 /* Timer value included in XOFF frames. */
92 #define IXGBE_FC_PAUSE 0x680
94 #define IXGBE_LINK_DOWN_CHECK_TIMEOUT 4000 /* ms */
95 #define IXGBE_LINK_UP_CHECK_TIMEOUT 1000 /* ms */
96 #define IXGBE_VMDQ_NUM_UC_MAC 4096 /* Maximum nb. of UC MAC addr. */
98 #define IXGBE_MMW_SIZE_DEFAULT 0x4
99 #define IXGBE_MMW_SIZE_JUMBO_FRAME 0x14
100 #define IXGBE_MAX_RING_DESC 4096 /* replicate define from rxtx */
103 * Default values for RX/TX configuration
105 #define IXGBE_DEFAULT_RX_FREE_THRESH 32
106 #define IXGBE_DEFAULT_RX_PTHRESH 8
107 #define IXGBE_DEFAULT_RX_HTHRESH 8
108 #define IXGBE_DEFAULT_RX_WTHRESH 0
110 #define IXGBE_DEFAULT_TX_FREE_THRESH 32
111 #define IXGBE_DEFAULT_TX_PTHRESH 32
112 #define IXGBE_DEFAULT_TX_HTHRESH 0
113 #define IXGBE_DEFAULT_TX_WTHRESH 0
114 #define IXGBE_DEFAULT_TX_RSBIT_THRESH 32
116 /* Bit shift and mask */
117 #define IXGBE_4_BIT_WIDTH (CHAR_BIT / 2)
118 #define IXGBE_4_BIT_MASK RTE_LEN2MASK(IXGBE_4_BIT_WIDTH, uint8_t)
119 #define IXGBE_8_BIT_WIDTH CHAR_BIT
120 #define IXGBE_8_BIT_MASK UINT8_MAX
122 #define IXGBEVF_PMD_NAME "rte_ixgbevf_pmd" /* PMD name */
124 #define IXGBE_QUEUE_STAT_COUNTERS (sizeof(hw_stats->qprc) / sizeof(hw_stats->qprc[0]))
126 #define IXGBE_HKEY_MAX_INDEX 10
128 /* Additional timesync values. */
129 #define NSEC_PER_SEC 1000000000L
130 #define IXGBE_INCVAL_10GB 0x66666666
131 #define IXGBE_INCVAL_1GB 0x40000000
132 #define IXGBE_INCVAL_100 0x50000000
133 #define IXGBE_INCVAL_SHIFT_10GB 28
134 #define IXGBE_INCVAL_SHIFT_1GB 24
135 #define IXGBE_INCVAL_SHIFT_100 21
136 #define IXGBE_INCVAL_SHIFT_82599 7
137 #define IXGBE_INCPER_SHIFT_82599 24
139 #define IXGBE_CYCLECOUNTER_MASK 0xffffffffffffffffULL
141 #define IXGBE_VT_CTL_POOLING_MODE_MASK 0x00030000
142 #define IXGBE_VT_CTL_POOLING_MODE_ETAG 0x00010000
143 #define DEFAULT_ETAG_ETYPE 0x893f
144 #define IXGBE_ETAG_ETYPE 0x00005084
145 #define IXGBE_ETAG_ETYPE_MASK 0x0000ffff
146 #define IXGBE_ETAG_ETYPE_VALID 0x80000000
147 #define IXGBE_RAH_ADTYPE 0x40000000
148 #define IXGBE_RAL_ETAG_FILTER_MASK 0x00003fff
149 #define IXGBE_VMVIR_TAGA_MASK 0x18000000
150 #define IXGBE_VMVIR_TAGA_ETAG_INSERT 0x08000000
151 #define IXGBE_VMTIR(_i) (0x00017000 + ((_i) * 4)) /* 64 of these (0-63) */
152 #define IXGBE_QDE_STRIP_TAG 0x00000004
154 static int eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev);
155 static int eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev);
156 static int ixgbe_dev_configure(struct rte_eth_dev *dev);
157 static int ixgbe_dev_start(struct rte_eth_dev *dev);
158 static void ixgbe_dev_stop(struct rte_eth_dev *dev);
159 static int ixgbe_dev_set_link_up(struct rte_eth_dev *dev);
160 static int ixgbe_dev_set_link_down(struct rte_eth_dev *dev);
161 static void ixgbe_dev_close(struct rte_eth_dev *dev);
162 static void ixgbe_dev_promiscuous_enable(struct rte_eth_dev *dev);
163 static void ixgbe_dev_promiscuous_disable(struct rte_eth_dev *dev);
164 static void ixgbe_dev_allmulticast_enable(struct rte_eth_dev *dev);
165 static void ixgbe_dev_allmulticast_disable(struct rte_eth_dev *dev);
166 static int ixgbe_dev_link_update(struct rte_eth_dev *dev,
167 int wait_to_complete);
168 static void ixgbe_dev_stats_get(struct rte_eth_dev *dev,
169 struct rte_eth_stats *stats);
170 static int ixgbe_dev_xstats_get(struct rte_eth_dev *dev,
171 struct rte_eth_xstats *xstats, unsigned n);
172 static int ixgbevf_dev_xstats_get(struct rte_eth_dev *dev,
173 struct rte_eth_xstats *xstats, unsigned n);
174 static void ixgbe_dev_stats_reset(struct rte_eth_dev *dev);
175 static void ixgbe_dev_xstats_reset(struct rte_eth_dev *dev);
176 static int ixgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
180 static void ixgbe_dev_info_get(struct rte_eth_dev *dev,
181 struct rte_eth_dev_info *dev_info);
182 static void ixgbevf_dev_info_get(struct rte_eth_dev *dev,
183 struct rte_eth_dev_info *dev_info);
184 static int ixgbe_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
186 static int ixgbe_vlan_filter_set(struct rte_eth_dev *dev,
187 uint16_t vlan_id, int on);
188 static int ixgbe_vlan_tpid_set(struct rte_eth_dev *dev,
189 enum rte_vlan_type vlan_type,
191 static void ixgbe_vlan_hw_strip_bitmap_set(struct rte_eth_dev *dev,
192 uint16_t queue, bool on);
193 static void ixgbe_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue,
195 static void ixgbe_vlan_offload_set(struct rte_eth_dev *dev, int mask);
196 static void ixgbe_vlan_hw_strip_enable(struct rte_eth_dev *dev, uint16_t queue);
197 static void ixgbe_vlan_hw_strip_disable(struct rte_eth_dev *dev, uint16_t queue);
198 static void ixgbe_vlan_hw_extend_enable(struct rte_eth_dev *dev);
199 static void ixgbe_vlan_hw_extend_disable(struct rte_eth_dev *dev);
201 static int ixgbe_dev_led_on(struct rte_eth_dev *dev);
202 static int ixgbe_dev_led_off(struct rte_eth_dev *dev);
203 static int ixgbe_flow_ctrl_get(struct rte_eth_dev *dev,
204 struct rte_eth_fc_conf *fc_conf);
205 static int ixgbe_flow_ctrl_set(struct rte_eth_dev *dev,
206 struct rte_eth_fc_conf *fc_conf);
207 static int ixgbe_priority_flow_ctrl_set(struct rte_eth_dev *dev,
208 struct rte_eth_pfc_conf *pfc_conf);
209 static int ixgbe_dev_rss_reta_update(struct rte_eth_dev *dev,
210 struct rte_eth_rss_reta_entry64 *reta_conf,
212 static int ixgbe_dev_rss_reta_query(struct rte_eth_dev *dev,
213 struct rte_eth_rss_reta_entry64 *reta_conf,
215 static void ixgbe_dev_link_status_print(struct rte_eth_dev *dev);
216 static int ixgbe_dev_lsc_interrupt_setup(struct rte_eth_dev *dev);
217 static int ixgbe_dev_rxq_interrupt_setup(struct rte_eth_dev *dev);
218 static int ixgbe_dev_interrupt_get_status(struct rte_eth_dev *dev);
219 static int ixgbe_dev_interrupt_action(struct rte_eth_dev *dev);
220 static void ixgbe_dev_interrupt_handler(struct rte_intr_handle *handle,
222 static void ixgbe_dev_interrupt_delayed_handler(void *param);
223 static void ixgbe_add_rar(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
224 uint32_t index, uint32_t pool);
225 static void ixgbe_remove_rar(struct rte_eth_dev *dev, uint32_t index);
226 static void ixgbe_set_default_mac_addr(struct rte_eth_dev *dev,
227 struct ether_addr *mac_addr);
228 static void ixgbe_dcb_init(struct ixgbe_hw *hw,struct ixgbe_dcb_config *dcb_config);
230 /* For Virtual Function support */
231 static int eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev);
232 static int eth_ixgbevf_dev_uninit(struct rte_eth_dev *eth_dev);
233 static int ixgbevf_dev_configure(struct rte_eth_dev *dev);
234 static int ixgbevf_dev_start(struct rte_eth_dev *dev);
235 static void ixgbevf_dev_stop(struct rte_eth_dev *dev);
236 static void ixgbevf_dev_close(struct rte_eth_dev *dev);
237 static void ixgbevf_intr_disable(struct ixgbe_hw *hw);
238 static void ixgbevf_intr_enable(struct ixgbe_hw *hw);
239 static void ixgbevf_dev_stats_get(struct rte_eth_dev *dev,
240 struct rte_eth_stats *stats);
241 static void ixgbevf_dev_stats_reset(struct rte_eth_dev *dev);
242 static int ixgbevf_vlan_filter_set(struct rte_eth_dev *dev,
243 uint16_t vlan_id, int on);
244 static void ixgbevf_vlan_strip_queue_set(struct rte_eth_dev *dev,
245 uint16_t queue, int on);
246 static void ixgbevf_vlan_offload_set(struct rte_eth_dev *dev, int mask);
247 static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on);
248 static int ixgbevf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev,
250 static int ixgbevf_dev_rx_queue_intr_disable(struct rte_eth_dev *dev,
252 static void ixgbevf_set_ivar_map(struct ixgbe_hw *hw, int8_t direction,
253 uint8_t queue, uint8_t msix_vector);
254 static void ixgbevf_configure_msix(struct rte_eth_dev *dev);
256 /* For Eth VMDQ APIs support */
257 static int ixgbe_uc_hash_table_set(struct rte_eth_dev *dev, struct
258 ether_addr* mac_addr,uint8_t on);
259 static int ixgbe_uc_all_hash_table_set(struct rte_eth_dev *dev,uint8_t on);
260 static int ixgbe_set_pool_rx_mode(struct rte_eth_dev *dev, uint16_t pool,
261 uint16_t rx_mask, uint8_t on);
262 static int ixgbe_set_pool_rx(struct rte_eth_dev *dev,uint16_t pool,uint8_t on);
263 static int ixgbe_set_pool_tx(struct rte_eth_dev *dev,uint16_t pool,uint8_t on);
264 static int ixgbe_set_pool_vlan_filter(struct rte_eth_dev *dev, uint16_t vlan,
265 uint64_t pool_mask,uint8_t vlan_on);
266 static int ixgbe_mirror_rule_set(struct rte_eth_dev *dev,
267 struct rte_eth_mirror_conf *mirror_conf,
268 uint8_t rule_id, uint8_t on);
269 static int ixgbe_mirror_rule_reset(struct rte_eth_dev *dev,
271 static int ixgbe_dev_rx_queue_intr_enable(struct rte_eth_dev *dev,
273 static int ixgbe_dev_rx_queue_intr_disable(struct rte_eth_dev *dev,
275 static void ixgbe_set_ivar_map(struct ixgbe_hw *hw, int8_t direction,
276 uint8_t queue, uint8_t msix_vector);
277 static void ixgbe_configure_msix(struct rte_eth_dev *dev);
279 static int ixgbe_set_queue_rate_limit(struct rte_eth_dev *dev,
280 uint16_t queue_idx, uint16_t tx_rate);
281 static int ixgbe_set_vf_rate_limit(struct rte_eth_dev *dev, uint16_t vf,
282 uint16_t tx_rate, uint64_t q_msk);
284 static void ixgbevf_add_mac_addr(struct rte_eth_dev *dev,
285 struct ether_addr *mac_addr,
286 uint32_t index, uint32_t pool);
287 static void ixgbevf_remove_mac_addr(struct rte_eth_dev *dev, uint32_t index);
288 static void ixgbevf_set_default_mac_addr(struct rte_eth_dev *dev,
289 struct ether_addr *mac_addr);
290 static int ixgbe_syn_filter_set(struct rte_eth_dev *dev,
291 struct rte_eth_syn_filter *filter,
293 static int ixgbe_syn_filter_get(struct rte_eth_dev *dev,
294 struct rte_eth_syn_filter *filter);
295 static int ixgbe_syn_filter_handle(struct rte_eth_dev *dev,
296 enum rte_filter_op filter_op,
298 static int ixgbe_add_5tuple_filter(struct rte_eth_dev *dev,
299 struct ixgbe_5tuple_filter *filter);
300 static void ixgbe_remove_5tuple_filter(struct rte_eth_dev *dev,
301 struct ixgbe_5tuple_filter *filter);
302 static int ixgbe_add_del_ntuple_filter(struct rte_eth_dev *dev,
303 struct rte_eth_ntuple_filter *filter,
305 static int ixgbe_ntuple_filter_handle(struct rte_eth_dev *dev,
306 enum rte_filter_op filter_op,
308 static int ixgbe_get_ntuple_filter(struct rte_eth_dev *dev,
309 struct rte_eth_ntuple_filter *filter);
310 static int ixgbe_add_del_ethertype_filter(struct rte_eth_dev *dev,
311 struct rte_eth_ethertype_filter *filter,
313 static int ixgbe_ethertype_filter_handle(struct rte_eth_dev *dev,
314 enum rte_filter_op filter_op,
316 static int ixgbe_get_ethertype_filter(struct rte_eth_dev *dev,
317 struct rte_eth_ethertype_filter *filter);
318 static int ixgbe_dev_filter_ctrl(struct rte_eth_dev *dev,
319 enum rte_filter_type filter_type,
320 enum rte_filter_op filter_op,
322 static int ixgbevf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu);
324 static int ixgbe_dev_set_mc_addr_list(struct rte_eth_dev *dev,
325 struct ether_addr *mc_addr_set,
326 uint32_t nb_mc_addr);
327 static int ixgbe_dev_get_dcb_info(struct rte_eth_dev *dev,
328 struct rte_eth_dcb_info *dcb_info);
330 static int ixgbe_get_reg_length(struct rte_eth_dev *dev);
331 static int ixgbe_get_regs(struct rte_eth_dev *dev,
332 struct rte_dev_reg_info *regs);
333 static int ixgbe_get_eeprom_length(struct rte_eth_dev *dev);
334 static int ixgbe_get_eeprom(struct rte_eth_dev *dev,
335 struct rte_dev_eeprom_info *eeprom);
336 static int ixgbe_set_eeprom(struct rte_eth_dev *dev,
337 struct rte_dev_eeprom_info *eeprom);
339 static int ixgbevf_get_reg_length(struct rte_eth_dev *dev);
340 static int ixgbevf_get_regs(struct rte_eth_dev *dev,
341 struct rte_dev_reg_info *regs);
343 static int ixgbe_timesync_enable(struct rte_eth_dev *dev);
344 static int ixgbe_timesync_disable(struct rte_eth_dev *dev);
345 static int ixgbe_timesync_read_rx_timestamp(struct rte_eth_dev *dev,
346 struct timespec *timestamp,
348 static int ixgbe_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
349 struct timespec *timestamp);
350 static int ixgbe_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta);
351 static int ixgbe_timesync_read_time(struct rte_eth_dev *dev,
352 struct timespec *timestamp);
353 static int ixgbe_timesync_write_time(struct rte_eth_dev *dev,
354 const struct timespec *timestamp);
356 static int ixgbe_dev_l2_tunnel_eth_type_conf
357 (struct rte_eth_dev *dev, struct rte_eth_l2_tunnel_conf *l2_tunnel);
358 static int ixgbe_dev_l2_tunnel_offload_set
359 (struct rte_eth_dev *dev,
360 struct rte_eth_l2_tunnel_conf *l2_tunnel,
363 static int ixgbe_dev_l2_tunnel_filter_handle(struct rte_eth_dev *dev,
364 enum rte_filter_op filter_op,
367 static int ixgbe_dev_udp_tunnel_port_add(struct rte_eth_dev *dev,
368 struct rte_eth_udp_tunnel *udp_tunnel);
369 static int ixgbe_dev_udp_tunnel_port_del(struct rte_eth_dev *dev,
370 struct rte_eth_udp_tunnel *udp_tunnel);
373 * Define VF Stats MACRO for Non "cleared on read" register
375 #define UPDATE_VF_STAT(reg, last, cur) \
377 uint32_t latest = IXGBE_READ_REG(hw, reg); \
378 cur += (latest - last) & UINT_MAX; \
382 #define UPDATE_VF_STAT_36BIT(lsb, msb, last, cur) \
384 u64 new_lsb = IXGBE_READ_REG(hw, lsb); \
385 u64 new_msb = IXGBE_READ_REG(hw, msb); \
386 u64 latest = ((new_msb << 32) | new_lsb); \
387 cur += (0x1000000000LL + latest - last) & 0xFFFFFFFFFLL; \
391 #define IXGBE_SET_HWSTRIP(h, q) do{\
392 uint32_t idx = (q) / (sizeof ((h)->bitmap[0]) * NBBY); \
393 uint32_t bit = (q) % (sizeof ((h)->bitmap[0]) * NBBY); \
394 (h)->bitmap[idx] |= 1 << bit;\
397 #define IXGBE_CLEAR_HWSTRIP(h, q) do{\
398 uint32_t idx = (q) / (sizeof ((h)->bitmap[0]) * NBBY); \
399 uint32_t bit = (q) % (sizeof ((h)->bitmap[0]) * NBBY); \
400 (h)->bitmap[idx] &= ~(1 << bit);\
403 #define IXGBE_GET_HWSTRIP(h, q, r) do{\
404 uint32_t idx = (q) / (sizeof ((h)->bitmap[0]) * NBBY); \
405 uint32_t bit = (q) % (sizeof ((h)->bitmap[0]) * NBBY); \
406 (r) = (h)->bitmap[idx] >> bit & 1;\
410 * The set of PCI devices this driver supports
412 static const struct rte_pci_id pci_id_ixgbe_map[] = {
414 #define RTE_PCI_DEV_ID_DECL_IXGBE(vend, dev) {RTE_PCI_DEVICE(vend, dev)},
415 #include "rte_pci_dev_ids.h"
417 { .vendor_id = 0, /* sentinel */ },
422 * The set of PCI devices this driver supports (for 82599 VF)
424 static const struct rte_pci_id pci_id_ixgbevf_map[] = {
426 #define RTE_PCI_DEV_ID_DECL_IXGBEVF(vend, dev) {RTE_PCI_DEVICE(vend, dev)},
427 #include "rte_pci_dev_ids.h"
428 { .vendor_id = 0, /* sentinel */ },
432 static const struct rte_eth_desc_lim rx_desc_lim = {
433 .nb_max = IXGBE_MAX_RING_DESC,
434 .nb_min = IXGBE_MIN_RING_DESC,
435 .nb_align = IXGBE_RXD_ALIGN,
438 static const struct rte_eth_desc_lim tx_desc_lim = {
439 .nb_max = IXGBE_MAX_RING_DESC,
440 .nb_min = IXGBE_MIN_RING_DESC,
441 .nb_align = IXGBE_TXD_ALIGN,
444 static const struct eth_dev_ops ixgbe_eth_dev_ops = {
445 .dev_configure = ixgbe_dev_configure,
446 .dev_start = ixgbe_dev_start,
447 .dev_stop = ixgbe_dev_stop,
448 .dev_set_link_up = ixgbe_dev_set_link_up,
449 .dev_set_link_down = ixgbe_dev_set_link_down,
450 .dev_close = ixgbe_dev_close,
451 .promiscuous_enable = ixgbe_dev_promiscuous_enable,
452 .promiscuous_disable = ixgbe_dev_promiscuous_disable,
453 .allmulticast_enable = ixgbe_dev_allmulticast_enable,
454 .allmulticast_disable = ixgbe_dev_allmulticast_disable,
455 .link_update = ixgbe_dev_link_update,
456 .stats_get = ixgbe_dev_stats_get,
457 .xstats_get = ixgbe_dev_xstats_get,
458 .stats_reset = ixgbe_dev_stats_reset,
459 .xstats_reset = ixgbe_dev_xstats_reset,
460 .queue_stats_mapping_set = ixgbe_dev_queue_stats_mapping_set,
461 .dev_infos_get = ixgbe_dev_info_get,
462 .mtu_set = ixgbe_dev_mtu_set,
463 .vlan_filter_set = ixgbe_vlan_filter_set,
464 .vlan_tpid_set = ixgbe_vlan_tpid_set,
465 .vlan_offload_set = ixgbe_vlan_offload_set,
466 .vlan_strip_queue_set = ixgbe_vlan_strip_queue_set,
467 .rx_queue_start = ixgbe_dev_rx_queue_start,
468 .rx_queue_stop = ixgbe_dev_rx_queue_stop,
469 .tx_queue_start = ixgbe_dev_tx_queue_start,
470 .tx_queue_stop = ixgbe_dev_tx_queue_stop,
471 .rx_queue_setup = ixgbe_dev_rx_queue_setup,
472 .rx_queue_intr_enable = ixgbe_dev_rx_queue_intr_enable,
473 .rx_queue_intr_disable = ixgbe_dev_rx_queue_intr_disable,
474 .rx_queue_release = ixgbe_dev_rx_queue_release,
475 .rx_queue_count = ixgbe_dev_rx_queue_count,
476 .rx_descriptor_done = ixgbe_dev_rx_descriptor_done,
477 .tx_queue_setup = ixgbe_dev_tx_queue_setup,
478 .tx_queue_release = ixgbe_dev_tx_queue_release,
479 .dev_led_on = ixgbe_dev_led_on,
480 .dev_led_off = ixgbe_dev_led_off,
481 .flow_ctrl_get = ixgbe_flow_ctrl_get,
482 .flow_ctrl_set = ixgbe_flow_ctrl_set,
483 .priority_flow_ctrl_set = ixgbe_priority_flow_ctrl_set,
484 .mac_addr_add = ixgbe_add_rar,
485 .mac_addr_remove = ixgbe_remove_rar,
486 .mac_addr_set = ixgbe_set_default_mac_addr,
487 .uc_hash_table_set = ixgbe_uc_hash_table_set,
488 .uc_all_hash_table_set = ixgbe_uc_all_hash_table_set,
489 .mirror_rule_set = ixgbe_mirror_rule_set,
490 .mirror_rule_reset = ixgbe_mirror_rule_reset,
491 .set_vf_rx_mode = ixgbe_set_pool_rx_mode,
492 .set_vf_rx = ixgbe_set_pool_rx,
493 .set_vf_tx = ixgbe_set_pool_tx,
494 .set_vf_vlan_filter = ixgbe_set_pool_vlan_filter,
495 .set_queue_rate_limit = ixgbe_set_queue_rate_limit,
496 .set_vf_rate_limit = ixgbe_set_vf_rate_limit,
497 .reta_update = ixgbe_dev_rss_reta_update,
498 .reta_query = ixgbe_dev_rss_reta_query,
499 #ifdef RTE_NIC_BYPASS
500 .bypass_init = ixgbe_bypass_init,
501 .bypass_state_set = ixgbe_bypass_state_store,
502 .bypass_state_show = ixgbe_bypass_state_show,
503 .bypass_event_set = ixgbe_bypass_event_store,
504 .bypass_event_show = ixgbe_bypass_event_show,
505 .bypass_wd_timeout_set = ixgbe_bypass_wd_timeout_store,
506 .bypass_wd_timeout_show = ixgbe_bypass_wd_timeout_show,
507 .bypass_ver_show = ixgbe_bypass_ver_show,
508 .bypass_wd_reset = ixgbe_bypass_wd_reset,
509 #endif /* RTE_NIC_BYPASS */
510 .rss_hash_update = ixgbe_dev_rss_hash_update,
511 .rss_hash_conf_get = ixgbe_dev_rss_hash_conf_get,
512 .filter_ctrl = ixgbe_dev_filter_ctrl,
513 .set_mc_addr_list = ixgbe_dev_set_mc_addr_list,
514 .rxq_info_get = ixgbe_rxq_info_get,
515 .txq_info_get = ixgbe_txq_info_get,
516 .timesync_enable = ixgbe_timesync_enable,
517 .timesync_disable = ixgbe_timesync_disable,
518 .timesync_read_rx_timestamp = ixgbe_timesync_read_rx_timestamp,
519 .timesync_read_tx_timestamp = ixgbe_timesync_read_tx_timestamp,
520 .get_reg_length = ixgbe_get_reg_length,
521 .get_reg = ixgbe_get_regs,
522 .get_eeprom_length = ixgbe_get_eeprom_length,
523 .get_eeprom = ixgbe_get_eeprom,
524 .set_eeprom = ixgbe_set_eeprom,
525 .get_dcb_info = ixgbe_dev_get_dcb_info,
526 .timesync_adjust_time = ixgbe_timesync_adjust_time,
527 .timesync_read_time = ixgbe_timesync_read_time,
528 .timesync_write_time = ixgbe_timesync_write_time,
529 .l2_tunnel_eth_type_conf = ixgbe_dev_l2_tunnel_eth_type_conf,
530 .l2_tunnel_offload_set = ixgbe_dev_l2_tunnel_offload_set,
531 .udp_tunnel_port_add = ixgbe_dev_udp_tunnel_port_add,
532 .udp_tunnel_port_del = ixgbe_dev_udp_tunnel_port_del,
536 * dev_ops for virtual function, bare necessities for basic vf
537 * operation have been implemented
539 static const struct eth_dev_ops ixgbevf_eth_dev_ops = {
540 .dev_configure = ixgbevf_dev_configure,
541 .dev_start = ixgbevf_dev_start,
542 .dev_stop = ixgbevf_dev_stop,
543 .link_update = ixgbe_dev_link_update,
544 .stats_get = ixgbevf_dev_stats_get,
545 .xstats_get = ixgbevf_dev_xstats_get,
546 .stats_reset = ixgbevf_dev_stats_reset,
547 .xstats_reset = ixgbevf_dev_stats_reset,
548 .dev_close = ixgbevf_dev_close,
549 .dev_infos_get = ixgbevf_dev_info_get,
550 .mtu_set = ixgbevf_dev_set_mtu,
551 .vlan_filter_set = ixgbevf_vlan_filter_set,
552 .vlan_strip_queue_set = ixgbevf_vlan_strip_queue_set,
553 .vlan_offload_set = ixgbevf_vlan_offload_set,
554 .rx_queue_setup = ixgbe_dev_rx_queue_setup,
555 .rx_queue_release = ixgbe_dev_rx_queue_release,
556 .rx_descriptor_done = ixgbe_dev_rx_descriptor_done,
557 .tx_queue_setup = ixgbe_dev_tx_queue_setup,
558 .tx_queue_release = ixgbe_dev_tx_queue_release,
559 .rx_queue_intr_enable = ixgbevf_dev_rx_queue_intr_enable,
560 .rx_queue_intr_disable = ixgbevf_dev_rx_queue_intr_disable,
561 .mac_addr_add = ixgbevf_add_mac_addr,
562 .mac_addr_remove = ixgbevf_remove_mac_addr,
563 .set_mc_addr_list = ixgbe_dev_set_mc_addr_list,
564 .rxq_info_get = ixgbe_rxq_info_get,
565 .txq_info_get = ixgbe_txq_info_get,
566 .mac_addr_set = ixgbevf_set_default_mac_addr,
567 .get_reg_length = ixgbevf_get_reg_length,
568 .get_reg = ixgbevf_get_regs,
569 .reta_update = ixgbe_dev_rss_reta_update,
570 .reta_query = ixgbe_dev_rss_reta_query,
571 .rss_hash_update = ixgbe_dev_rss_hash_update,
572 .rss_hash_conf_get = ixgbe_dev_rss_hash_conf_get,
575 /* store statistics names and its offset in stats structure */
576 struct rte_ixgbe_xstats_name_off {
577 char name[RTE_ETH_XSTATS_NAME_SIZE];
581 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_stats_strings[] = {
582 {"rx_crc_errors", offsetof(struct ixgbe_hw_stats, crcerrs)},
583 {"rx_illegal_byte_errors", offsetof(struct ixgbe_hw_stats, illerrc)},
584 {"rx_error_bytes", offsetof(struct ixgbe_hw_stats, errbc)},
585 {"mac_local_errors", offsetof(struct ixgbe_hw_stats, mlfc)},
586 {"mac_remote_errors", offsetof(struct ixgbe_hw_stats, mrfc)},
587 {"rx_length_errors", offsetof(struct ixgbe_hw_stats, rlec)},
588 {"tx_xon_packets", offsetof(struct ixgbe_hw_stats, lxontxc)},
589 {"rx_xon_packets", offsetof(struct ixgbe_hw_stats, lxonrxc)},
590 {"tx_xoff_packets", offsetof(struct ixgbe_hw_stats, lxofftxc)},
591 {"rx_xoff_packets", offsetof(struct ixgbe_hw_stats, lxoffrxc)},
592 {"rx_size_64_packets", offsetof(struct ixgbe_hw_stats, prc64)},
593 {"rx_size_65_to_127_packets", offsetof(struct ixgbe_hw_stats, prc127)},
594 {"rx_size_128_to_255_packets", offsetof(struct ixgbe_hw_stats, prc255)},
595 {"rx_size_256_to_511_packets", offsetof(struct ixgbe_hw_stats, prc511)},
596 {"rx_size_512_to_1023_packets", offsetof(struct ixgbe_hw_stats,
598 {"rx_size_1024_to_max_packets", offsetof(struct ixgbe_hw_stats,
600 {"rx_broadcast_packets", offsetof(struct ixgbe_hw_stats, bprc)},
601 {"rx_multicast_packets", offsetof(struct ixgbe_hw_stats, mprc)},
602 {"rx_fragment_errors", offsetof(struct ixgbe_hw_stats, rfc)},
603 {"rx_undersize_errors", offsetof(struct ixgbe_hw_stats, ruc)},
604 {"rx_oversize_errors", offsetof(struct ixgbe_hw_stats, roc)},
605 {"rx_jabber_errors", offsetof(struct ixgbe_hw_stats, rjc)},
606 {"rx_management_packets", offsetof(struct ixgbe_hw_stats, mngprc)},
607 {"rx_management_dropped", offsetof(struct ixgbe_hw_stats, mngpdc)},
608 {"tx_management_packets", offsetof(struct ixgbe_hw_stats, mngptc)},
609 {"rx_total_packets", offsetof(struct ixgbe_hw_stats, tpr)},
610 {"rx_total_bytes", offsetof(struct ixgbe_hw_stats, tor)},
611 {"tx_total_packets", offsetof(struct ixgbe_hw_stats, tpt)},
612 {"tx_size_64_packets", offsetof(struct ixgbe_hw_stats, ptc64)},
613 {"tx_size_65_to_127_packets", offsetof(struct ixgbe_hw_stats, ptc127)},
614 {"tx_size_128_to_255_packets", offsetof(struct ixgbe_hw_stats, ptc255)},
615 {"tx_size_256_to_511_packets", offsetof(struct ixgbe_hw_stats, ptc511)},
616 {"tx_size_512_to_1023_packets", offsetof(struct ixgbe_hw_stats,
618 {"tx_size_1024_to_max_packets", offsetof(struct ixgbe_hw_stats,
620 {"tx_multicast_packets", offsetof(struct ixgbe_hw_stats, mptc)},
621 {"tx_broadcast_packets", offsetof(struct ixgbe_hw_stats, bptc)},
622 {"rx_mac_short_packet_dropped", offsetof(struct ixgbe_hw_stats, mspdc)},
623 {"rx_l3_l4_xsum_error", offsetof(struct ixgbe_hw_stats, xec)},
625 {"flow_director_added_filters", offsetof(struct ixgbe_hw_stats,
627 {"flow_director_removed_filters", offsetof(struct ixgbe_hw_stats,
629 {"flow_director_filter_add_errors", offsetof(struct ixgbe_hw_stats,
631 {"flow_director_filter_remove_errors", offsetof(struct ixgbe_hw_stats,
633 {"flow_director_matched_filters", offsetof(struct ixgbe_hw_stats,
635 {"flow_director_missed_filters", offsetof(struct ixgbe_hw_stats,
638 {"rx_fcoe_crc_errors", offsetof(struct ixgbe_hw_stats, fccrc)},
639 {"rx_fcoe_dropped", offsetof(struct ixgbe_hw_stats, fcoerpdc)},
640 {"rx_fcoe_mbuf_allocation_errors", offsetof(struct ixgbe_hw_stats,
642 {"rx_fcoe_packets", offsetof(struct ixgbe_hw_stats, fcoeprc)},
643 {"tx_fcoe_packets", offsetof(struct ixgbe_hw_stats, fcoeptc)},
644 {"rx_fcoe_bytes", offsetof(struct ixgbe_hw_stats, fcoedwrc)},
645 {"tx_fcoe_bytes", offsetof(struct ixgbe_hw_stats, fcoedwtc)},
646 {"rx_fcoe_no_direct_data_placement", offsetof(struct ixgbe_hw_stats,
648 {"rx_fcoe_no_direct_data_placement_ext_buff",
649 offsetof(struct ixgbe_hw_stats, fcoe_noddp_ext_buff)},
651 {"tx_flow_control_xon_packets", offsetof(struct ixgbe_hw_stats,
653 {"rx_flow_control_xon_packets", offsetof(struct ixgbe_hw_stats,
655 {"tx_flow_control_xoff_packets", offsetof(struct ixgbe_hw_stats,
657 {"rx_flow_control_xoff_packets", offsetof(struct ixgbe_hw_stats,
659 {"rx_total_missed_packets", offsetof(struct ixgbe_hw_stats, mpctotal)},
662 #define IXGBE_NB_HW_STATS (sizeof(rte_ixgbe_stats_strings) / \
663 sizeof(rte_ixgbe_stats_strings[0]))
665 /* Per-queue statistics */
666 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_rxq_strings[] = {
667 {"mbuf_allocation_errors", offsetof(struct ixgbe_hw_stats, rnbc)},
668 {"dropped", offsetof(struct ixgbe_hw_stats, mpc)},
669 {"xon_packets", offsetof(struct ixgbe_hw_stats, pxonrxc)},
670 {"xoff_packets", offsetof(struct ixgbe_hw_stats, pxoffrxc)},
673 #define IXGBE_NB_RXQ_PRIO_STATS (sizeof(rte_ixgbe_rxq_strings) / \
674 sizeof(rte_ixgbe_rxq_strings[0]))
676 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_txq_strings[] = {
677 {"xon_packets", offsetof(struct ixgbe_hw_stats, pxontxc)},
678 {"xoff_packets", offsetof(struct ixgbe_hw_stats, pxofftxc)},
679 {"xon_to_xoff_packets", offsetof(struct ixgbe_hw_stats,
683 #define IXGBE_NB_TXQ_PRIO_STATS (sizeof(rte_ixgbe_txq_strings) / \
684 sizeof(rte_ixgbe_txq_strings[0]))
686 static const struct rte_ixgbe_xstats_name_off rte_ixgbevf_stats_strings[] = {
687 {"rx_multicast_packets", offsetof(struct ixgbevf_hw_stats, vfmprc)},
690 #define IXGBEVF_NB_XSTATS (sizeof(rte_ixgbevf_stats_strings) / \
691 sizeof(rte_ixgbevf_stats_strings[0]))
694 * Atomically reads the link status information from global
695 * structure rte_eth_dev.
698 * - Pointer to the structure rte_eth_dev to read from.
699 * - Pointer to the buffer to be saved with the link status.
702 * - On success, zero.
703 * - On failure, negative value.
706 rte_ixgbe_dev_atomic_read_link_status(struct rte_eth_dev *dev,
707 struct rte_eth_link *link)
709 struct rte_eth_link *dst = link;
710 struct rte_eth_link *src = &(dev->data->dev_link);
712 if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
713 *(uint64_t *)src) == 0)
720 * Atomically writes the link status information into global
721 * structure rte_eth_dev.
724 * - Pointer to the structure rte_eth_dev to read from.
725 * - Pointer to the buffer to be saved with the link status.
728 * - On success, zero.
729 * - On failure, negative value.
732 rte_ixgbe_dev_atomic_write_link_status(struct rte_eth_dev *dev,
733 struct rte_eth_link *link)
735 struct rte_eth_link *dst = &(dev->data->dev_link);
736 struct rte_eth_link *src = link;
738 if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
739 *(uint64_t *)src) == 0)
746 * This function is the same as ixgbe_is_sfp() in base/ixgbe.h.
749 ixgbe_is_sfp(struct ixgbe_hw *hw)
751 switch (hw->phy.type) {
752 case ixgbe_phy_sfp_avago:
753 case ixgbe_phy_sfp_ftl:
754 case ixgbe_phy_sfp_intel:
755 case ixgbe_phy_sfp_unknown:
756 case ixgbe_phy_sfp_passive_tyco:
757 case ixgbe_phy_sfp_passive_unknown:
764 static inline int32_t
765 ixgbe_pf_reset_hw(struct ixgbe_hw *hw)
770 status = ixgbe_reset_hw(hw);
772 ctrl_ext = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
773 /* Set PF Reset Done bit so PF/VF Mail Ops can work */
774 ctrl_ext |= IXGBE_CTRL_EXT_PFRSTD;
775 IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl_ext);
776 IXGBE_WRITE_FLUSH(hw);
782 ixgbe_enable_intr(struct rte_eth_dev *dev)
784 struct ixgbe_interrupt *intr =
785 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
786 struct ixgbe_hw *hw =
787 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
789 IXGBE_WRITE_REG(hw, IXGBE_EIMS, intr->mask);
790 IXGBE_WRITE_FLUSH(hw);
794 * This function is based on ixgbe_disable_intr() in base/ixgbe.h.
797 ixgbe_disable_intr(struct ixgbe_hw *hw)
799 PMD_INIT_FUNC_TRACE();
801 if (hw->mac.type == ixgbe_mac_82598EB) {
802 IXGBE_WRITE_REG(hw, IXGBE_EIMC, ~0);
804 IXGBE_WRITE_REG(hw, IXGBE_EIMC, 0xFFFF0000);
805 IXGBE_WRITE_REG(hw, IXGBE_EIMC_EX(0), ~0);
806 IXGBE_WRITE_REG(hw, IXGBE_EIMC_EX(1), ~0);
808 IXGBE_WRITE_FLUSH(hw);
812 * This function resets queue statistics mapping registers.
813 * From Niantic datasheet, Initialization of Statistics section:
814 * "...if software requires the queue counters, the RQSMR and TQSM registers
815 * must be re-programmed following a device reset.
818 ixgbe_reset_qstat_mappings(struct ixgbe_hw *hw)
822 for (i = 0; i != IXGBE_NB_STAT_MAPPING_REGS; i++) {
823 IXGBE_WRITE_REG(hw, IXGBE_RQSMR(i), 0);
824 IXGBE_WRITE_REG(hw, IXGBE_TQSM(i), 0);
830 ixgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
835 #define QSM_REG_NB_BITS_PER_QMAP_FIELD 8
836 #define NB_QMAP_FIELDS_PER_QSM_REG 4
837 #define QMAP_FIELD_RESERVED_BITS_MASK 0x0f
839 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
840 struct ixgbe_stat_mapping_registers *stat_mappings =
841 IXGBE_DEV_PRIVATE_TO_STAT_MAPPINGS(eth_dev->data->dev_private);
842 uint32_t qsmr_mask = 0;
843 uint32_t clearing_mask = QMAP_FIELD_RESERVED_BITS_MASK;
847 if ((hw->mac.type != ixgbe_mac_82599EB) &&
848 (hw->mac.type != ixgbe_mac_X540) &&
849 (hw->mac.type != ixgbe_mac_X550) &&
850 (hw->mac.type != ixgbe_mac_X550EM_x))
853 PMD_INIT_LOG(DEBUG, "Setting port %d, %s queue_id %d to stat index %d",
854 (int)(eth_dev->data->port_id), is_rx ? "RX" : "TX",
857 n = (uint8_t)(queue_id / NB_QMAP_FIELDS_PER_QSM_REG);
858 if (n >= IXGBE_NB_STAT_MAPPING_REGS) {
859 PMD_INIT_LOG(ERR, "Nb of stat mapping registers exceeded");
862 offset = (uint8_t)(queue_id % NB_QMAP_FIELDS_PER_QSM_REG);
864 /* Now clear any previous stat_idx set */
865 clearing_mask <<= (QSM_REG_NB_BITS_PER_QMAP_FIELD * offset);
867 stat_mappings->tqsm[n] &= ~clearing_mask;
869 stat_mappings->rqsmr[n] &= ~clearing_mask;
871 q_map = (uint32_t)stat_idx;
872 q_map &= QMAP_FIELD_RESERVED_BITS_MASK;
873 qsmr_mask = q_map << (QSM_REG_NB_BITS_PER_QMAP_FIELD * offset);
875 stat_mappings->tqsm[n] |= qsmr_mask;
877 stat_mappings->rqsmr[n] |= qsmr_mask;
879 PMD_INIT_LOG(DEBUG, "Set port %d, %s queue_id %d to stat index %d",
880 (int)(eth_dev->data->port_id), is_rx ? "RX" : "TX",
882 PMD_INIT_LOG(DEBUG, "%s[%d] = 0x%08x", is_rx ? "RQSMR" : "TQSM", n,
883 is_rx ? stat_mappings->rqsmr[n] : stat_mappings->tqsm[n]);
885 /* Now write the mapping in the appropriate register */
887 PMD_INIT_LOG(DEBUG, "Write 0x%x to RX IXGBE stat mapping reg:%d",
888 stat_mappings->rqsmr[n], n);
889 IXGBE_WRITE_REG(hw, IXGBE_RQSMR(n), stat_mappings->rqsmr[n]);
892 PMD_INIT_LOG(DEBUG, "Write 0x%x to TX IXGBE stat mapping reg:%d",
893 stat_mappings->tqsm[n], n);
894 IXGBE_WRITE_REG(hw, IXGBE_TQSM(n), stat_mappings->tqsm[n]);
900 ixgbe_restore_statistics_mapping(struct rte_eth_dev * dev)
902 struct ixgbe_stat_mapping_registers *stat_mappings =
903 IXGBE_DEV_PRIVATE_TO_STAT_MAPPINGS(dev->data->dev_private);
904 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
907 /* write whatever was in stat mapping table to the NIC */
908 for (i = 0; i < IXGBE_NB_STAT_MAPPING_REGS; i++) {
910 IXGBE_WRITE_REG(hw, IXGBE_RQSMR(i), stat_mappings->rqsmr[i]);
913 IXGBE_WRITE_REG(hw, IXGBE_TQSM(i), stat_mappings->tqsm[i]);
918 ixgbe_dcb_init(struct ixgbe_hw *hw,struct ixgbe_dcb_config *dcb_config)
921 struct ixgbe_dcb_tc_config *tc;
922 uint8_t dcb_max_tc = IXGBE_DCB_MAX_TRAFFIC_CLASS;
924 dcb_config->num_tcs.pg_tcs = dcb_max_tc;
925 dcb_config->num_tcs.pfc_tcs = dcb_max_tc;
926 for (i = 0; i < dcb_max_tc; i++) {
927 tc = &dcb_config->tc_config[i];
928 tc->path[IXGBE_DCB_TX_CONFIG].bwg_id = i;
929 tc->path[IXGBE_DCB_TX_CONFIG].bwg_percent =
930 (uint8_t)(100/dcb_max_tc + (i & 1));
931 tc->path[IXGBE_DCB_RX_CONFIG].bwg_id = i;
932 tc->path[IXGBE_DCB_RX_CONFIG].bwg_percent =
933 (uint8_t)(100/dcb_max_tc + (i & 1));
934 tc->pfc = ixgbe_dcb_pfc_disabled;
937 /* Initialize default user to priority mapping, UPx->TC0 */
938 tc = &dcb_config->tc_config[0];
939 tc->path[IXGBE_DCB_TX_CONFIG].up_to_tc_bitmap = 0xFF;
940 tc->path[IXGBE_DCB_RX_CONFIG].up_to_tc_bitmap = 0xFF;
941 for (i = 0; i< IXGBE_DCB_MAX_BW_GROUP; i++) {
942 dcb_config->bw_percentage[IXGBE_DCB_TX_CONFIG][i] = 100;
943 dcb_config->bw_percentage[IXGBE_DCB_RX_CONFIG][i] = 100;
945 dcb_config->rx_pba_cfg = ixgbe_dcb_pba_equal;
946 dcb_config->pfc_mode_enable = false;
947 dcb_config->vt_mode = true;
948 dcb_config->round_robin_enable = false;
949 /* support all DCB capabilities in 82599 */
950 dcb_config->support.capabilities = 0xFF;
952 /*we only support 4 Tcs for X540, X550 */
953 if (hw->mac.type == ixgbe_mac_X540 ||
954 hw->mac.type == ixgbe_mac_X550 ||
955 hw->mac.type == ixgbe_mac_X550EM_x) {
956 dcb_config->num_tcs.pg_tcs = 4;
957 dcb_config->num_tcs.pfc_tcs = 4;
962 * Ensure that all locks are released before first NVM or PHY access
965 ixgbe_swfw_lock_reset(struct ixgbe_hw *hw)
970 * Phy lock should not fail in this early stage. If this is the case,
971 * it is due to an improper exit of the application.
972 * So force the release of the faulty lock. Release of common lock
973 * is done automatically by swfw_sync function.
975 mask = IXGBE_GSSR_PHY0_SM << hw->bus.func;
976 if (ixgbe_acquire_swfw_semaphore(hw, mask) < 0) {
977 PMD_DRV_LOG(DEBUG, "SWFW phy%d lock released", hw->bus.func);
979 ixgbe_release_swfw_semaphore(hw, mask);
982 * These ones are more tricky since they are common to all ports; but
983 * swfw_sync retries last long enough (1s) to be almost sure that if
984 * lock can not be taken it is due to an improper lock of the
987 mask = IXGBE_GSSR_EEP_SM | IXGBE_GSSR_MAC_CSR_SM | IXGBE_GSSR_SW_MNG_SM;
988 if (ixgbe_acquire_swfw_semaphore(hw, mask) < 0) {
989 PMD_DRV_LOG(DEBUG, "SWFW common locks released");
991 ixgbe_release_swfw_semaphore(hw, mask);
995 * This function is based on code in ixgbe_attach() in base/ixgbe.c.
996 * It returns 0 on success.
999 eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev)
1001 struct rte_pci_device *pci_dev;
1002 struct ixgbe_hw *hw =
1003 IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
1004 struct ixgbe_vfta * shadow_vfta =
1005 IXGBE_DEV_PRIVATE_TO_VFTA(eth_dev->data->dev_private);
1006 struct ixgbe_hwstrip *hwstrip =
1007 IXGBE_DEV_PRIVATE_TO_HWSTRIP_BITMAP(eth_dev->data->dev_private);
1008 struct ixgbe_dcb_config *dcb_config =
1009 IXGBE_DEV_PRIVATE_TO_DCB_CFG(eth_dev->data->dev_private);
1010 struct ixgbe_filter_info *filter_info =
1011 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(eth_dev->data->dev_private);
1016 PMD_INIT_FUNC_TRACE();
1018 eth_dev->dev_ops = &ixgbe_eth_dev_ops;
1019 eth_dev->rx_pkt_burst = &ixgbe_recv_pkts;
1020 eth_dev->tx_pkt_burst = &ixgbe_xmit_pkts;
1023 * For secondary processes, we don't initialise any further as primary
1024 * has already done this work. Only check we don't need a different
1025 * RX and TX function.
1027 if (rte_eal_process_type() != RTE_PROC_PRIMARY){
1028 struct ixgbe_tx_queue *txq;
1029 /* TX queue function in primary, set by last queue initialized
1030 * Tx queue may not initialized by primary process */
1031 if (eth_dev->data->tx_queues) {
1032 txq = eth_dev->data->tx_queues[eth_dev->data->nb_tx_queues-1];
1033 ixgbe_set_tx_function(eth_dev, txq);
1035 /* Use default TX function if we get here */
1036 PMD_INIT_LOG(NOTICE, "No TX queues configured yet. "
1037 "Using default TX function.");
1040 ixgbe_set_rx_function(eth_dev);
1044 pci_dev = eth_dev->pci_dev;
1046 rte_eth_copy_pci_info(eth_dev, pci_dev);
1048 /* Vendor and Device ID need to be set before init of shared code */
1049 hw->device_id = pci_dev->id.device_id;
1050 hw->vendor_id = pci_dev->id.vendor_id;
1051 hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
1052 hw->allow_unsupported_sfp = 1;
1054 /* Initialize the shared code (base driver) */
1055 #ifdef RTE_NIC_BYPASS
1056 diag = ixgbe_bypass_init_shared_code(hw);
1058 diag = ixgbe_init_shared_code(hw);
1059 #endif /* RTE_NIC_BYPASS */
1061 if (diag != IXGBE_SUCCESS) {
1062 PMD_INIT_LOG(ERR, "Shared code init failed: %d", diag);
1066 /* pick up the PCI bus settings for reporting later */
1067 ixgbe_get_bus_info(hw);
1069 /* Unlock any pending hardware semaphore */
1070 ixgbe_swfw_lock_reset(hw);
1072 /* Initialize DCB configuration*/
1073 memset(dcb_config, 0, sizeof(struct ixgbe_dcb_config));
1074 ixgbe_dcb_init(hw,dcb_config);
1075 /* Get Hardware Flow Control setting */
1076 hw->fc.requested_mode = ixgbe_fc_full;
1077 hw->fc.current_mode = ixgbe_fc_full;
1078 hw->fc.pause_time = IXGBE_FC_PAUSE;
1079 for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
1080 hw->fc.low_water[i] = IXGBE_FC_LO;
1081 hw->fc.high_water[i] = IXGBE_FC_HI;
1083 hw->fc.send_xon = 1;
1085 /* Make sure we have a good EEPROM before we read from it */
1086 diag = ixgbe_validate_eeprom_checksum(hw, &csum);
1087 if (diag != IXGBE_SUCCESS) {
1088 PMD_INIT_LOG(ERR, "The EEPROM checksum is not valid: %d", diag);
1092 #ifdef RTE_NIC_BYPASS
1093 diag = ixgbe_bypass_init_hw(hw);
1095 diag = ixgbe_init_hw(hw);
1096 #endif /* RTE_NIC_BYPASS */
1099 * Devices with copper phys will fail to initialise if ixgbe_init_hw()
1100 * is called too soon after the kernel driver unbinding/binding occurs.
1101 * The failure occurs in ixgbe_identify_phy_generic() for all devices,
1102 * but for non-copper devies, ixgbe_identify_sfp_module_generic() is
1103 * also called. See ixgbe_identify_phy_82599(). The reason for the
1104 * failure is not known, and only occuts when virtualisation features
1105 * are disabled in the bios. A delay of 100ms was found to be enough by
1106 * trial-and-error, and is doubled to be safe.
1108 if (diag && (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper)) {
1110 diag = ixgbe_init_hw(hw);
1113 if (diag == IXGBE_ERR_EEPROM_VERSION) {
1114 PMD_INIT_LOG(ERR, "This device is a pre-production adapter/"
1115 "LOM. Please be aware there may be issues associated "
1116 "with your hardware.");
1117 PMD_INIT_LOG(ERR, "If you are experiencing problems "
1118 "please contact your Intel or hardware representative "
1119 "who provided you with this hardware.");
1120 } else if (diag == IXGBE_ERR_SFP_NOT_SUPPORTED)
1121 PMD_INIT_LOG(ERR, "Unsupported SFP+ Module");
1123 PMD_INIT_LOG(ERR, "Hardware Initialization Failure: %d", diag);
1127 /* Reset the hw statistics */
1128 ixgbe_dev_stats_reset(eth_dev);
1130 /* disable interrupt */
1131 ixgbe_disable_intr(hw);
1133 /* reset mappings for queue statistics hw counters*/
1134 ixgbe_reset_qstat_mappings(hw);
1136 /* Allocate memory for storing MAC addresses */
1137 eth_dev->data->mac_addrs = rte_zmalloc("ixgbe", ETHER_ADDR_LEN *
1138 hw->mac.num_rar_entries, 0);
1139 if (eth_dev->data->mac_addrs == NULL) {
1141 "Failed to allocate %u bytes needed to store "
1143 ETHER_ADDR_LEN * hw->mac.num_rar_entries);
1146 /* Copy the permanent MAC address */
1147 ether_addr_copy((struct ether_addr *) hw->mac.perm_addr,
1148 ð_dev->data->mac_addrs[0]);
1150 /* Allocate memory for storing hash filter MAC addresses */
1151 eth_dev->data->hash_mac_addrs = rte_zmalloc("ixgbe", ETHER_ADDR_LEN *
1152 IXGBE_VMDQ_NUM_UC_MAC, 0);
1153 if (eth_dev->data->hash_mac_addrs == NULL) {
1155 "Failed to allocate %d bytes needed to store MAC addresses",
1156 ETHER_ADDR_LEN * IXGBE_VMDQ_NUM_UC_MAC);
1160 /* initialize the vfta */
1161 memset(shadow_vfta, 0, sizeof(*shadow_vfta));
1163 /* initialize the hw strip bitmap*/
1164 memset(hwstrip, 0, sizeof(*hwstrip));
1166 /* initialize PF if max_vfs not zero */
1167 ixgbe_pf_host_init(eth_dev);
1169 ctrl_ext = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
1170 /* let hardware know driver is loaded */
1171 ctrl_ext |= IXGBE_CTRL_EXT_DRV_LOAD;
1172 /* Set PF Reset Done bit so PF/VF Mail Ops can work */
1173 ctrl_ext |= IXGBE_CTRL_EXT_PFRSTD;
1174 IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl_ext);
1175 IXGBE_WRITE_FLUSH(hw);
1177 if (ixgbe_is_sfp(hw) && hw->phy.sfp_type != ixgbe_sfp_type_not_present)
1178 PMD_INIT_LOG(DEBUG, "MAC: %d, PHY: %d, SFP+: %d",
1179 (int) hw->mac.type, (int) hw->phy.type,
1180 (int) hw->phy.sfp_type);
1182 PMD_INIT_LOG(DEBUG, "MAC: %d, PHY: %d",
1183 (int) hw->mac.type, (int) hw->phy.type);
1185 PMD_INIT_LOG(DEBUG, "port %d vendorID=0x%x deviceID=0x%x",
1186 eth_dev->data->port_id, pci_dev->id.vendor_id,
1187 pci_dev->id.device_id);
1189 rte_intr_callback_register(&pci_dev->intr_handle,
1190 ixgbe_dev_interrupt_handler,
1193 /* enable uio/vfio intr/eventfd mapping */
1194 rte_intr_enable(&pci_dev->intr_handle);
1196 /* enable support intr */
1197 ixgbe_enable_intr(eth_dev);
1199 /* initialize 5tuple filter list */
1200 TAILQ_INIT(&filter_info->fivetuple_list);
1201 memset(filter_info->fivetuple_mask, 0,
1202 sizeof(uint32_t) * IXGBE_5TUPLE_ARRAY_SIZE);
1208 eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev)
1210 struct rte_pci_device *pci_dev;
1211 struct ixgbe_hw *hw;
1213 PMD_INIT_FUNC_TRACE();
1215 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
1218 hw = IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
1219 pci_dev = eth_dev->pci_dev;
1221 if (hw->adapter_stopped == 0)
1222 ixgbe_dev_close(eth_dev);
1224 eth_dev->dev_ops = NULL;
1225 eth_dev->rx_pkt_burst = NULL;
1226 eth_dev->tx_pkt_burst = NULL;
1228 /* Unlock any pending hardware semaphore */
1229 ixgbe_swfw_lock_reset(hw);
1231 /* disable uio intr before callback unregister */
1232 rte_intr_disable(&(pci_dev->intr_handle));
1233 rte_intr_callback_unregister(&(pci_dev->intr_handle),
1234 ixgbe_dev_interrupt_handler, (void *)eth_dev);
1236 /* uninitialize PF if max_vfs not zero */
1237 ixgbe_pf_host_uninit(eth_dev);
1239 rte_free(eth_dev->data->mac_addrs);
1240 eth_dev->data->mac_addrs = NULL;
1242 rte_free(eth_dev->data->hash_mac_addrs);
1243 eth_dev->data->hash_mac_addrs = NULL;
1249 * Negotiate mailbox API version with the PF.
1250 * After reset API version is always set to the basic one (ixgbe_mbox_api_10).
1251 * Then we try to negotiate starting with the most recent one.
1252 * If all negotiation attempts fail, then we will proceed with
1253 * the default one (ixgbe_mbox_api_10).
1256 ixgbevf_negotiate_api(struct ixgbe_hw *hw)
1260 /* start with highest supported, proceed down */
1261 static const enum ixgbe_pfvf_api_rev sup_ver[] = {
1267 i != RTE_DIM(sup_ver) &&
1268 ixgbevf_negotiate_api_version(hw, sup_ver[i]) != 0;
1274 generate_random_mac_addr(struct ether_addr *mac_addr)
1278 /* Set Organizationally Unique Identifier (OUI) prefix. */
1279 mac_addr->addr_bytes[0] = 0x00;
1280 mac_addr->addr_bytes[1] = 0x09;
1281 mac_addr->addr_bytes[2] = 0xC0;
1282 /* Force indication of locally assigned MAC address. */
1283 mac_addr->addr_bytes[0] |= ETHER_LOCAL_ADMIN_ADDR;
1284 /* Generate the last 3 bytes of the MAC address with a random number. */
1285 random = rte_rand();
1286 memcpy(&mac_addr->addr_bytes[3], &random, 3);
1290 * Virtual Function device init
1293 eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev)
1297 struct rte_pci_device *pci_dev;
1298 struct ixgbe_hw *hw =
1299 IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
1300 struct ixgbe_vfta * shadow_vfta =
1301 IXGBE_DEV_PRIVATE_TO_VFTA(eth_dev->data->dev_private);
1302 struct ixgbe_hwstrip *hwstrip =
1303 IXGBE_DEV_PRIVATE_TO_HWSTRIP_BITMAP(eth_dev->data->dev_private);
1304 struct ether_addr *perm_addr = (struct ether_addr *) hw->mac.perm_addr;
1306 PMD_INIT_FUNC_TRACE();
1308 eth_dev->dev_ops = &ixgbevf_eth_dev_ops;
1309 eth_dev->rx_pkt_burst = &ixgbe_recv_pkts;
1310 eth_dev->tx_pkt_burst = &ixgbe_xmit_pkts;
1312 /* for secondary processes, we don't initialise any further as primary
1313 * has already done this work. Only check we don't need a different
1315 if (rte_eal_process_type() != RTE_PROC_PRIMARY){
1316 if (eth_dev->data->scattered_rx)
1317 eth_dev->rx_pkt_burst = ixgbe_recv_pkts_lro_single_alloc;
1321 pci_dev = eth_dev->pci_dev;
1323 rte_eth_copy_pci_info(eth_dev, pci_dev);
1325 hw->device_id = pci_dev->id.device_id;
1326 hw->vendor_id = pci_dev->id.vendor_id;
1327 hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
1329 /* initialize the vfta */
1330 memset(shadow_vfta, 0, sizeof(*shadow_vfta));
1332 /* initialize the hw strip bitmap*/
1333 memset(hwstrip, 0, sizeof(*hwstrip));
1335 /* Initialize the shared code (base driver) */
1336 diag = ixgbe_init_shared_code(hw);
1337 if (diag != IXGBE_SUCCESS) {
1338 PMD_INIT_LOG(ERR, "Shared code init failed for ixgbevf: %d", diag);
1342 /* init_mailbox_params */
1343 hw->mbx.ops.init_params(hw);
1345 /* Reset the hw statistics */
1346 ixgbevf_dev_stats_reset(eth_dev);
1348 /* Disable the interrupts for VF */
1349 ixgbevf_intr_disable(hw);
1351 hw->mac.num_rar_entries = 128; /* The MAX of the underlying PF */
1352 diag = hw->mac.ops.reset_hw(hw);
1355 * The VF reset operation returns the IXGBE_ERR_INVALID_MAC_ADDR when
1356 * the underlying PF driver has not assigned a MAC address to the VF.
1357 * In this case, assign a random MAC address.
1359 if ((diag != IXGBE_SUCCESS) && (diag != IXGBE_ERR_INVALID_MAC_ADDR)) {
1360 PMD_INIT_LOG(ERR, "VF Initialization Failure: %d", diag);
1364 /* negotiate mailbox API version to use with the PF. */
1365 ixgbevf_negotiate_api(hw);
1367 /* Get Rx/Tx queue count via mailbox, which is ready after reset_hw */
1368 ixgbevf_get_queues(hw, &tcs, &tc);
1370 /* Allocate memory for storing MAC addresses */
1371 eth_dev->data->mac_addrs = rte_zmalloc("ixgbevf", ETHER_ADDR_LEN *
1372 hw->mac.num_rar_entries, 0);
1373 if (eth_dev->data->mac_addrs == NULL) {
1375 "Failed to allocate %u bytes needed to store "
1377 ETHER_ADDR_LEN * hw->mac.num_rar_entries);
1381 /* Generate a random MAC address, if none was assigned by PF. */
1382 if (is_zero_ether_addr(perm_addr)) {
1383 generate_random_mac_addr(perm_addr);
1384 diag = ixgbe_set_rar_vf(hw, 1, perm_addr->addr_bytes, 0, 1);
1386 rte_free(eth_dev->data->mac_addrs);
1387 eth_dev->data->mac_addrs = NULL;
1390 PMD_INIT_LOG(INFO, "\tVF MAC address not assigned by Host PF");
1391 PMD_INIT_LOG(INFO, "\tAssign randomly generated MAC address "
1392 "%02x:%02x:%02x:%02x:%02x:%02x",
1393 perm_addr->addr_bytes[0],
1394 perm_addr->addr_bytes[1],
1395 perm_addr->addr_bytes[2],
1396 perm_addr->addr_bytes[3],
1397 perm_addr->addr_bytes[4],
1398 perm_addr->addr_bytes[5]);
1401 /* Copy the permanent MAC address */
1402 ether_addr_copy(perm_addr, ð_dev->data->mac_addrs[0]);
1404 /* reset the hardware with the new settings */
1405 diag = hw->mac.ops.start_hw(hw);
1411 PMD_INIT_LOG(ERR, "VF Initialization Failure: %d", diag);
1415 PMD_INIT_LOG(DEBUG, "port %d vendorID=0x%x deviceID=0x%x mac.type=%s",
1416 eth_dev->data->port_id, pci_dev->id.vendor_id,
1417 pci_dev->id.device_id, "ixgbe_mac_82599_vf");
1422 /* Virtual Function device uninit */
1425 eth_ixgbevf_dev_uninit(struct rte_eth_dev *eth_dev)
1427 struct ixgbe_hw *hw;
1430 PMD_INIT_FUNC_TRACE();
1432 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
1435 hw = IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
1437 if (hw->adapter_stopped == 0)
1438 ixgbevf_dev_close(eth_dev);
1440 eth_dev->dev_ops = NULL;
1441 eth_dev->rx_pkt_burst = NULL;
1442 eth_dev->tx_pkt_burst = NULL;
1444 /* Disable the interrupts for VF */
1445 ixgbevf_intr_disable(hw);
1447 for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
1448 ixgbe_dev_rx_queue_release(eth_dev->data->rx_queues[i]);
1449 eth_dev->data->rx_queues[i] = NULL;
1451 eth_dev->data->nb_rx_queues = 0;
1453 for (i = 0; i < eth_dev->data->nb_tx_queues; i++) {
1454 ixgbe_dev_tx_queue_release(eth_dev->data->tx_queues[i]);
1455 eth_dev->data->tx_queues[i] = NULL;
1457 eth_dev->data->nb_tx_queues = 0;
1459 rte_free(eth_dev->data->mac_addrs);
1460 eth_dev->data->mac_addrs = NULL;
1465 static struct eth_driver rte_ixgbe_pmd = {
1467 .name = "rte_ixgbe_pmd",
1468 .id_table = pci_id_ixgbe_map,
1469 .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
1470 RTE_PCI_DRV_DETACHABLE,
1472 .eth_dev_init = eth_ixgbe_dev_init,
1473 .eth_dev_uninit = eth_ixgbe_dev_uninit,
1474 .dev_private_size = sizeof(struct ixgbe_adapter),
1478 * virtual function driver struct
1480 static struct eth_driver rte_ixgbevf_pmd = {
1482 .name = "rte_ixgbevf_pmd",
1483 .id_table = pci_id_ixgbevf_map,
1484 .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
1486 .eth_dev_init = eth_ixgbevf_dev_init,
1487 .eth_dev_uninit = eth_ixgbevf_dev_uninit,
1488 .dev_private_size = sizeof(struct ixgbe_adapter),
1492 * Driver initialization routine.
1493 * Invoked once at EAL init time.
1494 * Register itself as the [Poll Mode] Driver of PCI IXGBE devices.
1497 rte_ixgbe_pmd_init(const char *name __rte_unused, const char *params __rte_unused)
1499 PMD_INIT_FUNC_TRACE();
1501 rte_eth_driver_register(&rte_ixgbe_pmd);
1506 * VF Driver initialization routine.
1507 * Invoked one at EAL init time.
1508 * Register itself as the [Virtual Poll Mode] Driver of PCI niantic devices.
1511 rte_ixgbevf_pmd_init(const char *name __rte_unused, const char *param __rte_unused)
1513 PMD_INIT_FUNC_TRACE();
1515 rte_eth_driver_register(&rte_ixgbevf_pmd);
1520 ixgbe_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
1522 struct ixgbe_hw *hw =
1523 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1524 struct ixgbe_vfta * shadow_vfta =
1525 IXGBE_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
1530 vid_idx = (uint32_t) ((vlan_id >> 5) & 0x7F);
1531 vid_bit = (uint32_t) (1 << (vlan_id & 0x1F));
1532 vfta = IXGBE_READ_REG(hw, IXGBE_VFTA(vid_idx));
1537 IXGBE_WRITE_REG(hw, IXGBE_VFTA(vid_idx), vfta);
1539 /* update local VFTA copy */
1540 shadow_vfta->vfta[vid_idx] = vfta;
1546 ixgbe_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue, int on)
1549 ixgbe_vlan_hw_strip_enable(dev, queue);
1551 ixgbe_vlan_hw_strip_disable(dev, queue);
1555 ixgbe_vlan_tpid_set(struct rte_eth_dev *dev,
1556 enum rte_vlan_type vlan_type,
1559 struct ixgbe_hw *hw =
1560 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1563 switch (vlan_type) {
1564 case ETH_VLAN_TYPE_INNER:
1565 /* Only the high 16-bits is valid */
1566 IXGBE_WRITE_REG(hw, IXGBE_EXVET, tpid << 16);
1570 PMD_DRV_LOG(ERR, "Unsupported vlan type %d\n", vlan_type);
1578 ixgbe_vlan_hw_filter_disable(struct rte_eth_dev *dev)
1580 struct ixgbe_hw *hw =
1581 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1584 PMD_INIT_FUNC_TRACE();
1586 /* Filter Table Disable */
1587 vlnctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
1588 vlnctrl &= ~IXGBE_VLNCTRL_VFE;
1590 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlnctrl);
1594 ixgbe_vlan_hw_filter_enable(struct rte_eth_dev *dev)
1596 struct ixgbe_hw *hw =
1597 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1598 struct ixgbe_vfta * shadow_vfta =
1599 IXGBE_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
1603 PMD_INIT_FUNC_TRACE();
1605 /* Filter Table Enable */
1606 vlnctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
1607 vlnctrl &= ~IXGBE_VLNCTRL_CFIEN;
1608 vlnctrl |= IXGBE_VLNCTRL_VFE;
1610 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlnctrl);
1612 /* write whatever is in local vfta copy */
1613 for (i = 0; i < IXGBE_VFTA_SIZE; i++)
1614 IXGBE_WRITE_REG(hw, IXGBE_VFTA(i), shadow_vfta->vfta[i]);
1618 ixgbe_vlan_hw_strip_bitmap_set(struct rte_eth_dev *dev, uint16_t queue, bool on)
1620 struct ixgbe_hwstrip *hwstrip =
1621 IXGBE_DEV_PRIVATE_TO_HWSTRIP_BITMAP(dev->data->dev_private);
1623 if (queue >= IXGBE_MAX_RX_QUEUE_NUM)
1627 IXGBE_SET_HWSTRIP(hwstrip, queue);
1629 IXGBE_CLEAR_HWSTRIP(hwstrip, queue);
1633 ixgbe_vlan_hw_strip_disable(struct rte_eth_dev *dev, uint16_t queue)
1635 struct ixgbe_hw *hw =
1636 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1639 PMD_INIT_FUNC_TRACE();
1641 if (hw->mac.type == ixgbe_mac_82598EB) {
1642 /* No queue level support */
1643 PMD_INIT_LOG(NOTICE, "82598EB not support queue level hw strip");
1647 /* Other 10G NIC, the VLAN strip can be setup per queue in RXDCTL */
1648 ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(queue));
1649 ctrl &= ~IXGBE_RXDCTL_VME;
1650 IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(queue), ctrl);
1652 /* record those setting for HW strip per queue */
1653 ixgbe_vlan_hw_strip_bitmap_set(dev, queue, 0);
1657 ixgbe_vlan_hw_strip_enable(struct rte_eth_dev *dev, uint16_t queue)
1659 struct ixgbe_hw *hw =
1660 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1663 PMD_INIT_FUNC_TRACE();
1665 if (hw->mac.type == ixgbe_mac_82598EB) {
1666 /* No queue level supported */
1667 PMD_INIT_LOG(NOTICE, "82598EB not support queue level hw strip");
1671 /* Other 10G NIC, the VLAN strip can be setup per queue in RXDCTL */
1672 ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(queue));
1673 ctrl |= IXGBE_RXDCTL_VME;
1674 IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(queue), ctrl);
1676 /* record those setting for HW strip per queue */
1677 ixgbe_vlan_hw_strip_bitmap_set(dev, queue, 1);
1681 ixgbe_vlan_hw_strip_disable_all(struct rte_eth_dev *dev)
1683 struct ixgbe_hw *hw =
1684 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1688 PMD_INIT_FUNC_TRACE();
1690 if (hw->mac.type == ixgbe_mac_82598EB) {
1691 ctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
1692 ctrl &= ~IXGBE_VLNCTRL_VME;
1693 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, ctrl);
1696 /* Other 10G NIC, the VLAN strip can be setup per queue in RXDCTL */
1697 for (i = 0; i < dev->data->nb_rx_queues; i++) {
1698 ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(i));
1699 ctrl &= ~IXGBE_RXDCTL_VME;
1700 IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(i), ctrl);
1702 /* record those setting for HW strip per queue */
1703 ixgbe_vlan_hw_strip_bitmap_set(dev, i, 0);
1709 ixgbe_vlan_hw_strip_enable_all(struct rte_eth_dev *dev)
1711 struct ixgbe_hw *hw =
1712 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1716 PMD_INIT_FUNC_TRACE();
1718 if (hw->mac.type == ixgbe_mac_82598EB) {
1719 ctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
1720 ctrl |= IXGBE_VLNCTRL_VME;
1721 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, ctrl);
1724 /* Other 10G NIC, the VLAN strip can be setup per queue in RXDCTL */
1725 for (i = 0; i < dev->data->nb_rx_queues; i++) {
1726 ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(i));
1727 ctrl |= IXGBE_RXDCTL_VME;
1728 IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(i), ctrl);
1730 /* record those setting for HW strip per queue */
1731 ixgbe_vlan_hw_strip_bitmap_set(dev, i, 1);
1737 ixgbe_vlan_hw_extend_disable(struct rte_eth_dev *dev)
1739 struct ixgbe_hw *hw =
1740 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1743 PMD_INIT_FUNC_TRACE();
1745 /* DMATXCTRL: Geric Double VLAN Disable */
1746 ctrl = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
1747 ctrl &= ~IXGBE_DMATXCTL_GDV;
1748 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, ctrl);
1750 /* CTRL_EXT: Global Double VLAN Disable */
1751 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
1752 ctrl &= ~IXGBE_EXTENDED_VLAN;
1753 IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl);
1758 ixgbe_vlan_hw_extend_enable(struct rte_eth_dev *dev)
1760 struct ixgbe_hw *hw =
1761 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1764 PMD_INIT_FUNC_TRACE();
1766 /* DMATXCTRL: Geric Double VLAN Enable */
1767 ctrl = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
1768 ctrl |= IXGBE_DMATXCTL_GDV;
1769 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, ctrl);
1771 /* CTRL_EXT: Global Double VLAN Enable */
1772 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
1773 ctrl |= IXGBE_EXTENDED_VLAN;
1774 IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl);
1776 /* Clear pooling mode of PFVTCTL. It's required by X550. */
1777 if (hw->mac.type == ixgbe_mac_X550 ||
1778 hw->mac.type == ixgbe_mac_X550EM_x) {
1779 ctrl = IXGBE_READ_REG(hw, IXGBE_VT_CTL);
1780 ctrl &= ~IXGBE_VT_CTL_POOLING_MODE_MASK;
1781 IXGBE_WRITE_REG(hw, IXGBE_VT_CTL, ctrl);
1785 * VET EXT field in the EXVET register = 0x8100 by default
1786 * So no need to change. Same to VT field of DMATXCTL register
1791 ixgbe_vlan_offload_set(struct rte_eth_dev *dev, int mask)
1793 if (mask & ETH_VLAN_STRIP_MASK) {
1794 if (dev->data->dev_conf.rxmode.hw_vlan_strip)
1795 ixgbe_vlan_hw_strip_enable_all(dev);
1797 ixgbe_vlan_hw_strip_disable_all(dev);
1800 if (mask & ETH_VLAN_FILTER_MASK) {
1801 if (dev->data->dev_conf.rxmode.hw_vlan_filter)
1802 ixgbe_vlan_hw_filter_enable(dev);
1804 ixgbe_vlan_hw_filter_disable(dev);
1807 if (mask & ETH_VLAN_EXTEND_MASK) {
1808 if (dev->data->dev_conf.rxmode.hw_vlan_extend)
1809 ixgbe_vlan_hw_extend_enable(dev);
1811 ixgbe_vlan_hw_extend_disable(dev);
1816 ixgbe_vmdq_vlan_hw_filter_enable(struct rte_eth_dev *dev)
1818 struct ixgbe_hw *hw =
1819 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1820 /* VLNCTRL: enable vlan filtering and allow all vlan tags through */
1821 uint32_t vlanctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
1822 vlanctrl |= IXGBE_VLNCTRL_VFE; /* enable vlan filters */
1823 IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlanctrl);
1827 ixgbe_check_vf_rss_rxq_num(struct rte_eth_dev *dev, uint16_t nb_rx_q)
1832 RTE_ETH_DEV_SRIOV(dev).active = ETH_64_POOLS;
1835 RTE_ETH_DEV_SRIOV(dev).active = ETH_32_POOLS;
1841 RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool = nb_rx_q;
1842 RTE_ETH_DEV_SRIOV(dev).def_pool_q_idx = dev->pci_dev->max_vfs * nb_rx_q;
1848 ixgbe_check_mq_mode(struct rte_eth_dev *dev)
1850 struct rte_eth_conf *dev_conf = &dev->data->dev_conf;
1851 uint16_t nb_rx_q = dev->data->nb_rx_queues;
1852 uint16_t nb_tx_q = dev->data->nb_rx_queues;
1854 if (RTE_ETH_DEV_SRIOV(dev).active != 0) {
1855 /* check multi-queue mode */
1856 switch (dev_conf->rxmode.mq_mode) {
1857 case ETH_MQ_RX_VMDQ_DCB:
1858 case ETH_MQ_RX_VMDQ_DCB_RSS:
1859 /* DCB/RSS VMDQ in SRIOV mode, not implement yet */
1860 PMD_INIT_LOG(ERR, "SRIOV active,"
1861 " unsupported mq_mode rx %d.",
1862 dev_conf->rxmode.mq_mode);
1865 case ETH_MQ_RX_VMDQ_RSS:
1866 dev->data->dev_conf.rxmode.mq_mode = ETH_MQ_RX_VMDQ_RSS;
1867 if (nb_rx_q <= RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool)
1868 if (ixgbe_check_vf_rss_rxq_num(dev, nb_rx_q)) {
1869 PMD_INIT_LOG(ERR, "SRIOV is active,"
1870 " invalid queue number"
1871 " for VMDQ RSS, allowed"
1872 " value are 1, 2 or 4.");
1876 case ETH_MQ_RX_VMDQ_ONLY:
1877 case ETH_MQ_RX_NONE:
1878 /* if nothing mq mode configure, use default scheme */
1879 dev->data->dev_conf.rxmode.mq_mode = ETH_MQ_RX_VMDQ_ONLY;
1880 if (RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool > 1)
1881 RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool = 1;
1883 default: /* ETH_MQ_RX_DCB, ETH_MQ_RX_DCB_RSS or ETH_MQ_TX_DCB*/
1884 /* SRIOV only works in VMDq enable mode */
1885 PMD_INIT_LOG(ERR, "SRIOV is active,"
1886 " wrong mq_mode rx %d.",
1887 dev_conf->rxmode.mq_mode);
1891 switch (dev_conf->txmode.mq_mode) {
1892 case ETH_MQ_TX_VMDQ_DCB:
1893 /* DCB VMDQ in SRIOV mode, not implement yet */
1894 PMD_INIT_LOG(ERR, "SRIOV is active,"
1895 " unsupported VMDQ mq_mode tx %d.",
1896 dev_conf->txmode.mq_mode);
1898 default: /* ETH_MQ_TX_VMDQ_ONLY or ETH_MQ_TX_NONE */
1899 dev->data->dev_conf.txmode.mq_mode = ETH_MQ_TX_VMDQ_ONLY;
1903 /* check valid queue number */
1904 if ((nb_rx_q > RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool) ||
1905 (nb_tx_q > RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool)) {
1906 PMD_INIT_LOG(ERR, "SRIOV is active,"
1907 " queue number must less equal to %d.",
1908 RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool);
1912 /* check configuration for vmdb+dcb mode */
1913 if (dev_conf->rxmode.mq_mode == ETH_MQ_RX_VMDQ_DCB) {
1914 const struct rte_eth_vmdq_dcb_conf *conf;
1916 if (nb_rx_q != IXGBE_VMDQ_DCB_NB_QUEUES) {
1917 PMD_INIT_LOG(ERR, "VMDQ+DCB, nb_rx_q != %d.",
1918 IXGBE_VMDQ_DCB_NB_QUEUES);
1921 conf = &dev_conf->rx_adv_conf.vmdq_dcb_conf;
1922 if (!(conf->nb_queue_pools == ETH_16_POOLS ||
1923 conf->nb_queue_pools == ETH_32_POOLS)) {
1924 PMD_INIT_LOG(ERR, "VMDQ+DCB selected,"
1925 " nb_queue_pools must be %d or %d.",
1926 ETH_16_POOLS, ETH_32_POOLS);
1930 if (dev_conf->txmode.mq_mode == ETH_MQ_TX_VMDQ_DCB) {
1931 const struct rte_eth_vmdq_dcb_tx_conf *conf;
1933 if (nb_tx_q != IXGBE_VMDQ_DCB_NB_QUEUES) {
1934 PMD_INIT_LOG(ERR, "VMDQ+DCB, nb_tx_q != %d",
1935 IXGBE_VMDQ_DCB_NB_QUEUES);
1938 conf = &dev_conf->tx_adv_conf.vmdq_dcb_tx_conf;
1939 if (!(conf->nb_queue_pools == ETH_16_POOLS ||
1940 conf->nb_queue_pools == ETH_32_POOLS)) {
1941 PMD_INIT_LOG(ERR, "VMDQ+DCB selected,"
1942 " nb_queue_pools != %d and"
1943 " nb_queue_pools != %d.",
1944 ETH_16_POOLS, ETH_32_POOLS);
1949 /* For DCB mode check our configuration before we go further */
1950 if (dev_conf->rxmode.mq_mode == ETH_MQ_RX_DCB) {
1951 const struct rte_eth_dcb_rx_conf *conf;
1953 if (nb_rx_q != IXGBE_DCB_NB_QUEUES) {
1954 PMD_INIT_LOG(ERR, "DCB selected, nb_rx_q != %d.",
1955 IXGBE_DCB_NB_QUEUES);
1958 conf = &dev_conf->rx_adv_conf.dcb_rx_conf;
1959 if (!(conf->nb_tcs == ETH_4_TCS ||
1960 conf->nb_tcs == ETH_8_TCS)) {
1961 PMD_INIT_LOG(ERR, "DCB selected, nb_tcs != %d"
1962 " and nb_tcs != %d.",
1963 ETH_4_TCS, ETH_8_TCS);
1968 if (dev_conf->txmode.mq_mode == ETH_MQ_TX_DCB) {
1969 const struct rte_eth_dcb_tx_conf *conf;
1971 if (nb_tx_q != IXGBE_DCB_NB_QUEUES) {
1972 PMD_INIT_LOG(ERR, "DCB, nb_tx_q != %d.",
1973 IXGBE_DCB_NB_QUEUES);
1976 conf = &dev_conf->tx_adv_conf.dcb_tx_conf;
1977 if (!(conf->nb_tcs == ETH_4_TCS ||
1978 conf->nb_tcs == ETH_8_TCS)) {
1979 PMD_INIT_LOG(ERR, "DCB selected, nb_tcs != %d"
1980 " and nb_tcs != %d.",
1981 ETH_4_TCS, ETH_8_TCS);
1990 ixgbe_dev_configure(struct rte_eth_dev *dev)
1992 struct ixgbe_interrupt *intr =
1993 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
1994 struct ixgbe_adapter *adapter =
1995 (struct ixgbe_adapter *)dev->data->dev_private;
1998 PMD_INIT_FUNC_TRACE();
1999 /* multipe queue mode checking */
2000 ret = ixgbe_check_mq_mode(dev);
2002 PMD_DRV_LOG(ERR, "ixgbe_check_mq_mode fails with %d.",
2007 /* set flag to update link status after init */
2008 intr->flags |= IXGBE_FLAG_NEED_LINK_UPDATE;
2011 * Initialize to TRUE. If any of Rx queues doesn't meet the bulk
2012 * allocation or vector Rx preconditions we will reset it.
2014 adapter->rx_bulk_alloc_allowed = true;
2015 adapter->rx_vec_allowed = true;
2021 * Configure device link speed and setup link.
2022 * It returns 0 on success.
2025 ixgbe_dev_start(struct rte_eth_dev *dev)
2027 struct ixgbe_hw *hw =
2028 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2029 struct ixgbe_vf_info *vfinfo =
2030 *IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private);
2031 struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;
2032 uint32_t intr_vector = 0;
2033 int err, link_up = 0, negotiate = 0;
2039 PMD_INIT_FUNC_TRACE();
2041 /* IXGBE devices don't support half duplex */
2042 if ((dev->data->dev_conf.link_duplex != ETH_LINK_AUTONEG_DUPLEX) &&
2043 (dev->data->dev_conf.link_duplex != ETH_LINK_FULL_DUPLEX)) {
2044 PMD_INIT_LOG(ERR, "Invalid link_duplex (%hu) for port %hhu",
2045 dev->data->dev_conf.link_duplex,
2046 dev->data->port_id);
2050 /* disable uio/vfio intr/eventfd mapping */
2051 rte_intr_disable(intr_handle);
2054 hw->adapter_stopped = 0;
2055 ixgbe_stop_adapter(hw);
2057 /* reinitialize adapter
2058 * this calls reset and start */
2059 status = ixgbe_pf_reset_hw(hw);
2062 hw->mac.ops.start_hw(hw);
2063 hw->mac.get_link_status = true;
2065 /* configure PF module if SRIOV enabled */
2066 ixgbe_pf_host_configure(dev);
2068 /* check and configure queue intr-vector mapping */
2069 if ((rte_intr_cap_multiple(intr_handle) ||
2070 !RTE_ETH_DEV_SRIOV(dev).active) &&
2071 dev->data->dev_conf.intr_conf.rxq != 0) {
2072 intr_vector = dev->data->nb_rx_queues;
2073 if (rte_intr_efd_enable(intr_handle, intr_vector))
2077 if (rte_intr_dp_is_en(intr_handle) && !intr_handle->intr_vec) {
2078 intr_handle->intr_vec =
2079 rte_zmalloc("intr_vec",
2080 dev->data->nb_rx_queues * sizeof(int), 0);
2081 if (intr_handle->intr_vec == NULL) {
2082 PMD_INIT_LOG(ERR, "Failed to allocate %d rx_queues"
2083 " intr_vec\n", dev->data->nb_rx_queues);
2088 /* confiugre msix for sleep until rx interrupt */
2089 ixgbe_configure_msix(dev);
2091 /* initialize transmission unit */
2092 ixgbe_dev_tx_init(dev);
2094 /* This can fail when allocating mbufs for descriptor rings */
2095 err = ixgbe_dev_rx_init(dev);
2097 PMD_INIT_LOG(ERR, "Unable to initialize RX hardware");
2101 err = ixgbe_dev_rxtx_start(dev);
2103 PMD_INIT_LOG(ERR, "Unable to start rxtx queues");
2107 /* Skip link setup if loopback mode is enabled for 82599. */
2108 if (hw->mac.type == ixgbe_mac_82599EB &&
2109 dev->data->dev_conf.lpbk_mode == IXGBE_LPBK_82599_TX_RX)
2110 goto skip_link_setup;
2112 if (ixgbe_is_sfp(hw) && hw->phy.multispeed_fiber) {
2113 err = hw->mac.ops.setup_sfp(hw);
2118 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper) {
2119 /* Turn on the copper */
2120 ixgbe_set_phy_power(hw, true);
2122 /* Turn on the laser */
2123 ixgbe_enable_tx_laser(hw);
2126 err = ixgbe_check_link(hw, &speed, &link_up, 0);
2129 dev->data->dev_link.link_status = link_up;
2131 err = ixgbe_get_link_capabilities(hw, &speed, &negotiate);
2135 switch(dev->data->dev_conf.link_speed) {
2136 case ETH_LINK_SPEED_AUTONEG:
2137 speed = (hw->mac.type != ixgbe_mac_82598EB) ?
2138 IXGBE_LINK_SPEED_82599_AUTONEG :
2139 IXGBE_LINK_SPEED_82598_AUTONEG;
2141 case ETH_LINK_SPEED_100:
2143 * Invalid for 82598 but error will be detected by
2144 * ixgbe_setup_link()
2146 speed = IXGBE_LINK_SPEED_100_FULL;
2148 case ETH_LINK_SPEED_1000:
2149 speed = IXGBE_LINK_SPEED_1GB_FULL;
2151 case ETH_LINK_SPEED_10000:
2152 speed = IXGBE_LINK_SPEED_10GB_FULL;
2155 PMD_INIT_LOG(ERR, "Invalid link_speed (%hu) for port %hhu",
2156 dev->data->dev_conf.link_speed,
2157 dev->data->port_id);
2161 err = ixgbe_setup_link(hw, speed, link_up);
2167 if (rte_intr_allow_others(intr_handle)) {
2168 /* check if lsc interrupt is enabled */
2169 if (dev->data->dev_conf.intr_conf.lsc != 0)
2170 ixgbe_dev_lsc_interrupt_setup(dev);
2172 rte_intr_callback_unregister(intr_handle,
2173 ixgbe_dev_interrupt_handler,
2175 if (dev->data->dev_conf.intr_conf.lsc != 0)
2176 PMD_INIT_LOG(INFO, "lsc won't enable because of"
2177 " no intr multiplex\n");
2180 /* check if rxq interrupt is enabled */
2181 if (dev->data->dev_conf.intr_conf.rxq != 0 &&
2182 rte_intr_dp_is_en(intr_handle))
2183 ixgbe_dev_rxq_interrupt_setup(dev);
2185 /* enable uio/vfio intr/eventfd mapping */
2186 rte_intr_enable(intr_handle);
2188 /* resume enabled intr since hw reset */
2189 ixgbe_enable_intr(dev);
2191 mask = ETH_VLAN_STRIP_MASK | ETH_VLAN_FILTER_MASK | \
2192 ETH_VLAN_EXTEND_MASK;
2193 ixgbe_vlan_offload_set(dev, mask);
2195 if (dev->data->dev_conf.rxmode.mq_mode == ETH_MQ_RX_VMDQ_ONLY) {
2196 /* Enable vlan filtering for VMDq */
2197 ixgbe_vmdq_vlan_hw_filter_enable(dev);
2200 /* Configure DCB hw */
2201 ixgbe_configure_dcb(dev);
2203 if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_NONE) {
2204 err = ixgbe_fdir_configure(dev);
2209 /* Restore vf rate limit */
2210 if (vfinfo != NULL) {
2211 for (vf = 0; vf < dev->pci_dev->max_vfs; vf++)
2212 for (idx = 0; idx < IXGBE_MAX_QUEUE_NUM_PER_VF; idx++)
2213 if (vfinfo[vf].tx_rate[idx] != 0)
2214 ixgbe_set_vf_rate_limit(dev, vf,
2215 vfinfo[vf].tx_rate[idx],
2219 ixgbe_restore_statistics_mapping(dev);
2224 PMD_INIT_LOG(ERR, "failure in ixgbe_dev_start(): %d", err);
2225 ixgbe_dev_clear_queues(dev);
2230 * Stop device: disable rx and tx functions to allow for reconfiguring.
2233 ixgbe_dev_stop(struct rte_eth_dev *dev)
2235 struct rte_eth_link link;
2236 struct ixgbe_hw *hw =
2237 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2238 struct ixgbe_vf_info *vfinfo =
2239 *IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private);
2240 struct ixgbe_filter_info *filter_info =
2241 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
2242 struct ixgbe_5tuple_filter *p_5tuple, *p_5tuple_next;
2243 struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;
2246 PMD_INIT_FUNC_TRACE();
2248 /* disable interrupts */
2249 ixgbe_disable_intr(hw);
2252 ixgbe_pf_reset_hw(hw);
2253 hw->adapter_stopped = 0;
2256 ixgbe_stop_adapter(hw);
2258 for (vf = 0; vfinfo != NULL &&
2259 vf < dev->pci_dev->max_vfs; vf++)
2260 vfinfo[vf].clear_to_send = false;
2262 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper) {
2263 /* Turn off the copper */
2264 ixgbe_set_phy_power(hw, false);
2266 /* Turn off the laser */
2267 ixgbe_disable_tx_laser(hw);
2270 ixgbe_dev_clear_queues(dev);
2272 /* Clear stored conf */
2273 dev->data->scattered_rx = 0;
2276 /* Clear recorded link status */
2277 memset(&link, 0, sizeof(link));
2278 rte_ixgbe_dev_atomic_write_link_status(dev, &link);
2280 /* Remove all ntuple filters of the device */
2281 for (p_5tuple = TAILQ_FIRST(&filter_info->fivetuple_list);
2282 p_5tuple != NULL; p_5tuple = p_5tuple_next) {
2283 p_5tuple_next = TAILQ_NEXT(p_5tuple, entries);
2284 TAILQ_REMOVE(&filter_info->fivetuple_list,
2288 memset(filter_info->fivetuple_mask, 0,
2289 sizeof(uint32_t) * IXGBE_5TUPLE_ARRAY_SIZE);
2291 if (!rte_intr_allow_others(intr_handle))
2292 /* resume to the default handler */
2293 rte_intr_callback_register(intr_handle,
2294 ixgbe_dev_interrupt_handler,
2297 /* Clean datapath event and queue/vec mapping */
2298 rte_intr_efd_disable(intr_handle);
2299 if (intr_handle->intr_vec != NULL) {
2300 rte_free(intr_handle->intr_vec);
2301 intr_handle->intr_vec = NULL;
2306 * Set device link up: enable tx.
2309 ixgbe_dev_set_link_up(struct rte_eth_dev *dev)
2311 struct ixgbe_hw *hw =
2312 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2313 if (hw->mac.type == ixgbe_mac_82599EB) {
2314 #ifdef RTE_NIC_BYPASS
2315 if (hw->device_id == IXGBE_DEV_ID_82599_BYPASS) {
2316 /* Not suported in bypass mode */
2317 PMD_INIT_LOG(ERR, "Set link up is not supported "
2318 "by device id 0x%x", hw->device_id);
2324 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper) {
2325 /* Turn on the copper */
2326 ixgbe_set_phy_power(hw, true);
2328 /* Turn on the laser */
2329 ixgbe_enable_tx_laser(hw);
2336 * Set device link down: disable tx.
2339 ixgbe_dev_set_link_down(struct rte_eth_dev *dev)
2341 struct ixgbe_hw *hw =
2342 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2343 if (hw->mac.type == ixgbe_mac_82599EB) {
2344 #ifdef RTE_NIC_BYPASS
2345 if (hw->device_id == IXGBE_DEV_ID_82599_BYPASS) {
2346 /* Not suported in bypass mode */
2347 PMD_INIT_LOG(ERR, "Set link down is not supported "
2348 "by device id 0x%x", hw->device_id);
2354 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper) {
2355 /* Turn off the copper */
2356 ixgbe_set_phy_power(hw, false);
2358 /* Turn off the laser */
2359 ixgbe_disable_tx_laser(hw);
2366 * Reest and stop device.
2369 ixgbe_dev_close(struct rte_eth_dev *dev)
2371 struct ixgbe_hw *hw =
2372 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2374 PMD_INIT_FUNC_TRACE();
2376 ixgbe_pf_reset_hw(hw);
2378 ixgbe_dev_stop(dev);
2379 hw->adapter_stopped = 1;
2381 ixgbe_dev_free_queues(dev);
2383 ixgbe_disable_pcie_master(hw);
2385 /* reprogram the RAR[0] in case user changed it. */
2386 ixgbe_set_rar(hw, 0, hw->mac.addr, 0, IXGBE_RAH_AV);
2390 ixgbe_read_stats_registers(struct ixgbe_hw *hw,
2391 struct ixgbe_hw_stats *hw_stats,
2392 uint64_t *total_missed_rx, uint64_t *total_qbrc,
2393 uint64_t *total_qprc, uint64_t *total_qprdc)
2395 uint32_t bprc, lxon, lxoff, total;
2396 uint32_t delta_gprc = 0;
2398 /* Workaround for RX byte count not including CRC bytes when CRC
2399 + * strip is enabled. CRC bytes are removed from counters when crc_strip
2402 int crc_strip = (IXGBE_READ_REG(hw, IXGBE_HLREG0) &
2403 IXGBE_HLREG0_RXCRCSTRP);
2405 hw_stats->crcerrs += IXGBE_READ_REG(hw, IXGBE_CRCERRS);
2406 hw_stats->illerrc += IXGBE_READ_REG(hw, IXGBE_ILLERRC);
2407 hw_stats->errbc += IXGBE_READ_REG(hw, IXGBE_ERRBC);
2408 hw_stats->mspdc += IXGBE_READ_REG(hw, IXGBE_MSPDC);
2410 for (i = 0; i < 8; i++) {
2412 mp = IXGBE_READ_REG(hw, IXGBE_MPC(i));
2413 /* global total per queue */
2414 hw_stats->mpc[i] += mp;
2415 /* Running comprehensive total for stats display */
2416 *total_missed_rx += hw_stats->mpc[i];
2417 if (hw->mac.type == ixgbe_mac_82598EB) {
2418 hw_stats->rnbc[i] +=
2419 IXGBE_READ_REG(hw, IXGBE_RNBC(i));
2420 hw_stats->pxonrxc[i] +=
2421 IXGBE_READ_REG(hw, IXGBE_PXONRXC(i));
2422 hw_stats->pxoffrxc[i] +=
2423 IXGBE_READ_REG(hw, IXGBE_PXOFFRXC(i));
2425 hw_stats->pxonrxc[i] +=
2426 IXGBE_READ_REG(hw, IXGBE_PXONRXCNT(i));
2427 hw_stats->pxoffrxc[i] +=
2428 IXGBE_READ_REG(hw, IXGBE_PXOFFRXCNT(i));
2429 hw_stats->pxon2offc[i] +=
2430 IXGBE_READ_REG(hw, IXGBE_PXON2OFFCNT(i));
2432 hw_stats->pxontxc[i] +=
2433 IXGBE_READ_REG(hw, IXGBE_PXONTXC(i));
2434 hw_stats->pxofftxc[i] +=
2435 IXGBE_READ_REG(hw, IXGBE_PXOFFTXC(i));
2437 for (i = 0; i < IXGBE_QUEUE_STAT_COUNTERS; i++) {
2438 uint32_t delta_qprc = IXGBE_READ_REG(hw, IXGBE_QPRC(i));
2439 uint32_t delta_qptc = IXGBE_READ_REG(hw, IXGBE_QPTC(i));
2440 uint32_t delta_qprdc = IXGBE_READ_REG(hw, IXGBE_QPRDC(i));
2442 delta_gprc += delta_qprc;
2444 hw_stats->qprc[i] += delta_qprc;
2445 hw_stats->qptc[i] += delta_qptc;
2447 hw_stats->qbrc[i] += IXGBE_READ_REG(hw, IXGBE_QBRC_L(i));
2448 hw_stats->qbrc[i] +=
2449 ((uint64_t)IXGBE_READ_REG(hw, IXGBE_QBRC_H(i)) << 32);
2451 hw_stats->qbrc[i] -= delta_qprc * ETHER_CRC_LEN;
2453 hw_stats->qbtc[i] += IXGBE_READ_REG(hw, IXGBE_QBTC_L(i));
2454 hw_stats->qbtc[i] +=
2455 ((uint64_t)IXGBE_READ_REG(hw, IXGBE_QBTC_H(i)) << 32);
2457 hw_stats->qprdc[i] += delta_qprdc;
2458 *total_qprdc += hw_stats->qprdc[i];
2460 *total_qprc += hw_stats->qprc[i];
2461 *total_qbrc += hw_stats->qbrc[i];
2463 hw_stats->mlfc += IXGBE_READ_REG(hw, IXGBE_MLFC);
2464 hw_stats->mrfc += IXGBE_READ_REG(hw, IXGBE_MRFC);
2465 hw_stats->rlec += IXGBE_READ_REG(hw, IXGBE_RLEC);
2468 * An errata states that gprc actually counts good + missed packets:
2469 * Workaround to set gprc to summated queue packet receives
2471 hw_stats->gprc = *total_qprc;
2473 if (hw->mac.type != ixgbe_mac_82598EB) {
2474 hw_stats->gorc += IXGBE_READ_REG(hw, IXGBE_GORCL);
2475 hw_stats->gorc += ((u64)IXGBE_READ_REG(hw, IXGBE_GORCH) << 32);
2476 hw_stats->gotc += IXGBE_READ_REG(hw, IXGBE_GOTCL);
2477 hw_stats->gotc += ((u64)IXGBE_READ_REG(hw, IXGBE_GOTCH) << 32);
2478 hw_stats->tor += IXGBE_READ_REG(hw, IXGBE_TORL);
2479 hw_stats->tor += ((u64)IXGBE_READ_REG(hw, IXGBE_TORH) << 32);
2480 hw_stats->lxonrxc += IXGBE_READ_REG(hw, IXGBE_LXONRXCNT);
2481 hw_stats->lxoffrxc += IXGBE_READ_REG(hw, IXGBE_LXOFFRXCNT);
2483 hw_stats->lxonrxc += IXGBE_READ_REG(hw, IXGBE_LXONRXC);
2484 hw_stats->lxoffrxc += IXGBE_READ_REG(hw, IXGBE_LXOFFRXC);
2485 /* 82598 only has a counter in the high register */
2486 hw_stats->gorc += IXGBE_READ_REG(hw, IXGBE_GORCH);
2487 hw_stats->gotc += IXGBE_READ_REG(hw, IXGBE_GOTCH);
2488 hw_stats->tor += IXGBE_READ_REG(hw, IXGBE_TORH);
2490 uint64_t old_tpr = hw_stats->tpr;
2492 hw_stats->tpr += IXGBE_READ_REG(hw, IXGBE_TPR);
2493 hw_stats->tpt += IXGBE_READ_REG(hw, IXGBE_TPT);
2496 hw_stats->gorc -= delta_gprc * ETHER_CRC_LEN;
2498 uint64_t delta_gptc = IXGBE_READ_REG(hw, IXGBE_GPTC);
2499 hw_stats->gptc += delta_gptc;
2500 hw_stats->gotc -= delta_gptc * ETHER_CRC_LEN;
2501 hw_stats->tor -= (hw_stats->tpr - old_tpr) * ETHER_CRC_LEN;
2504 * Workaround: mprc hardware is incorrectly counting
2505 * broadcasts, so for now we subtract those.
2507 bprc = IXGBE_READ_REG(hw, IXGBE_BPRC);
2508 hw_stats->bprc += bprc;
2509 hw_stats->mprc += IXGBE_READ_REG(hw, IXGBE_MPRC);
2510 if (hw->mac.type == ixgbe_mac_82598EB)
2511 hw_stats->mprc -= bprc;
2513 hw_stats->prc64 += IXGBE_READ_REG(hw, IXGBE_PRC64);
2514 hw_stats->prc127 += IXGBE_READ_REG(hw, IXGBE_PRC127);
2515 hw_stats->prc255 += IXGBE_READ_REG(hw, IXGBE_PRC255);
2516 hw_stats->prc511 += IXGBE_READ_REG(hw, IXGBE_PRC511);
2517 hw_stats->prc1023 += IXGBE_READ_REG(hw, IXGBE_PRC1023);
2518 hw_stats->prc1522 += IXGBE_READ_REG(hw, IXGBE_PRC1522);
2520 lxon = IXGBE_READ_REG(hw, IXGBE_LXONTXC);
2521 hw_stats->lxontxc += lxon;
2522 lxoff = IXGBE_READ_REG(hw, IXGBE_LXOFFTXC);
2523 hw_stats->lxofftxc += lxoff;
2524 total = lxon + lxoff;
2526 hw_stats->mptc += IXGBE_READ_REG(hw, IXGBE_MPTC);
2527 hw_stats->ptc64 += IXGBE_READ_REG(hw, IXGBE_PTC64);
2528 hw_stats->gptc -= total;
2529 hw_stats->mptc -= total;
2530 hw_stats->ptc64 -= total;
2531 hw_stats->gotc -= total * ETHER_MIN_LEN;
2533 hw_stats->ruc += IXGBE_READ_REG(hw, IXGBE_RUC);
2534 hw_stats->rfc += IXGBE_READ_REG(hw, IXGBE_RFC);
2535 hw_stats->roc += IXGBE_READ_REG(hw, IXGBE_ROC);
2536 hw_stats->rjc += IXGBE_READ_REG(hw, IXGBE_RJC);
2537 hw_stats->mngprc += IXGBE_READ_REG(hw, IXGBE_MNGPRC);
2538 hw_stats->mngpdc += IXGBE_READ_REG(hw, IXGBE_MNGPDC);
2539 hw_stats->mngptc += IXGBE_READ_REG(hw, IXGBE_MNGPTC);
2540 hw_stats->ptc127 += IXGBE_READ_REG(hw, IXGBE_PTC127);
2541 hw_stats->ptc255 += IXGBE_READ_REG(hw, IXGBE_PTC255);
2542 hw_stats->ptc511 += IXGBE_READ_REG(hw, IXGBE_PTC511);
2543 hw_stats->ptc1023 += IXGBE_READ_REG(hw, IXGBE_PTC1023);
2544 hw_stats->ptc1522 += IXGBE_READ_REG(hw, IXGBE_PTC1522);
2545 hw_stats->bptc += IXGBE_READ_REG(hw, IXGBE_BPTC);
2546 hw_stats->xec += IXGBE_READ_REG(hw, IXGBE_XEC);
2547 hw_stats->fccrc += IXGBE_READ_REG(hw, IXGBE_FCCRC);
2548 hw_stats->fclast += IXGBE_READ_REG(hw, IXGBE_FCLAST);
2549 /* Only read FCOE on 82599 */
2550 if (hw->mac.type != ixgbe_mac_82598EB) {
2551 hw_stats->fcoerpdc += IXGBE_READ_REG(hw, IXGBE_FCOERPDC);
2552 hw_stats->fcoeprc += IXGBE_READ_REG(hw, IXGBE_FCOEPRC);
2553 hw_stats->fcoeptc += IXGBE_READ_REG(hw, IXGBE_FCOEPTC);
2554 hw_stats->fcoedwrc += IXGBE_READ_REG(hw, IXGBE_FCOEDWRC);
2555 hw_stats->fcoedwtc += IXGBE_READ_REG(hw, IXGBE_FCOEDWTC);
2558 /* Flow Director Stats registers */
2559 hw_stats->fdirmatch += IXGBE_READ_REG(hw, IXGBE_FDIRMATCH);
2560 hw_stats->fdirmiss += IXGBE_READ_REG(hw, IXGBE_FDIRMISS);
2564 * This function is based on ixgbe_update_stats_counters() in ixgbe/ixgbe.c
2567 ixgbe_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
2569 struct ixgbe_hw *hw =
2570 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2571 struct ixgbe_hw_stats *hw_stats =
2572 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
2573 uint64_t total_missed_rx, total_qbrc, total_qprc, total_qprdc;
2576 total_missed_rx = 0;
2581 ixgbe_read_stats_registers(hw, hw_stats, &total_missed_rx, &total_qbrc,
2582 &total_qprc, &total_qprdc);
2587 /* Fill out the rte_eth_stats statistics structure */
2588 stats->ipackets = total_qprc;
2589 stats->ibytes = total_qbrc;
2590 stats->opackets = hw_stats->gptc;
2591 stats->obytes = hw_stats->gotc;
2593 for (i = 0; i < IXGBE_QUEUE_STAT_COUNTERS; i++) {
2594 stats->q_ipackets[i] = hw_stats->qprc[i];
2595 stats->q_opackets[i] = hw_stats->qptc[i];
2596 stats->q_ibytes[i] = hw_stats->qbrc[i];
2597 stats->q_obytes[i] = hw_stats->qbtc[i];
2598 stats->q_errors[i] = hw_stats->qprdc[i];
2602 stats->imissed = total_missed_rx;
2603 stats->ierrors = hw_stats->crcerrs +
2620 ixgbe_dev_stats_reset(struct rte_eth_dev *dev)
2622 struct ixgbe_hw_stats *stats =
2623 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
2625 /* HW registers are cleared on read */
2626 ixgbe_dev_stats_get(dev, NULL);
2628 /* Reset software totals */
2629 memset(stats, 0, sizeof(*stats));
2632 /* This function calculates the number of xstats based on the current config */
2634 ixgbe_xstats_calc_num(void) {
2635 return IXGBE_NB_HW_STATS + (IXGBE_NB_RXQ_PRIO_STATS * 8) +
2636 (IXGBE_NB_TXQ_PRIO_STATS * 8);
2640 ixgbe_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats *xstats,
2643 struct ixgbe_hw *hw =
2644 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2645 struct ixgbe_hw_stats *hw_stats =
2646 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
2647 uint64_t total_missed_rx, total_qbrc, total_qprc, total_qprdc;
2648 unsigned i, stat, count = 0;
2650 count = ixgbe_xstats_calc_num();
2655 total_missed_rx = 0;
2660 ixgbe_read_stats_registers(hw, hw_stats, &total_missed_rx, &total_qbrc,
2661 &total_qprc, &total_qprdc);
2663 /* If this is a reset xstats is NULL, and we have cleared the
2664 * registers by reading them.
2669 /* Extended stats from ixgbe_hw_stats */
2671 for (i = 0; i < IXGBE_NB_HW_STATS; i++) {
2672 snprintf(xstats[count].name, sizeof(xstats[count].name), "%s",
2673 rte_ixgbe_stats_strings[i].name);
2674 xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
2675 rte_ixgbe_stats_strings[i].offset);
2679 /* RX Priority Stats */
2680 for (stat = 0; stat < IXGBE_NB_RXQ_PRIO_STATS; stat++) {
2681 for (i = 0; i < 8; i++) {
2682 snprintf(xstats[count].name, sizeof(xstats[count].name),
2683 "rx_priority%u_%s", i,
2684 rte_ixgbe_rxq_strings[stat].name);
2685 xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
2686 rte_ixgbe_rxq_strings[stat].offset +
2687 (sizeof(uint64_t) * i));
2692 /* TX Priority Stats */
2693 for (stat = 0; stat < IXGBE_NB_TXQ_PRIO_STATS; stat++) {
2694 for (i = 0; i < 8; i++) {
2695 snprintf(xstats[count].name, sizeof(xstats[count].name),
2696 "tx_priority%u_%s", i,
2697 rte_ixgbe_txq_strings[stat].name);
2698 xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
2699 rte_ixgbe_txq_strings[stat].offset +
2700 (sizeof(uint64_t) * i));
2709 ixgbe_dev_xstats_reset(struct rte_eth_dev *dev)
2711 struct ixgbe_hw_stats *stats =
2712 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
2714 unsigned count = ixgbe_xstats_calc_num();
2716 /* HW registers are cleared on read */
2717 ixgbe_dev_xstats_get(dev, NULL, count);
2719 /* Reset software totals */
2720 memset(stats, 0, sizeof(*stats));
2724 ixgbevf_update_stats(struct rte_eth_dev *dev)
2726 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2727 struct ixgbevf_hw_stats *hw_stats = (struct ixgbevf_hw_stats*)
2728 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
2730 /* Good Rx packet, include VF loopback */
2731 UPDATE_VF_STAT(IXGBE_VFGPRC,
2732 hw_stats->last_vfgprc, hw_stats->vfgprc);
2734 /* Good Rx octets, include VF loopback */
2735 UPDATE_VF_STAT_36BIT(IXGBE_VFGORC_LSB, IXGBE_VFGORC_MSB,
2736 hw_stats->last_vfgorc, hw_stats->vfgorc);
2738 /* Good Tx packet, include VF loopback */
2739 UPDATE_VF_STAT(IXGBE_VFGPTC,
2740 hw_stats->last_vfgptc, hw_stats->vfgptc);
2742 /* Good Tx octets, include VF loopback */
2743 UPDATE_VF_STAT_36BIT(IXGBE_VFGOTC_LSB, IXGBE_VFGOTC_MSB,
2744 hw_stats->last_vfgotc, hw_stats->vfgotc);
2746 /* Rx Multicst Packet */
2747 UPDATE_VF_STAT(IXGBE_VFMPRC,
2748 hw_stats->last_vfmprc, hw_stats->vfmprc);
2752 ixgbevf_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats *xstats,
2755 struct ixgbevf_hw_stats *hw_stats = (struct ixgbevf_hw_stats *)
2756 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
2759 if (n < IXGBEVF_NB_XSTATS)
2760 return IXGBEVF_NB_XSTATS;
2762 ixgbevf_update_stats(dev);
2767 /* Extended stats */
2768 for (i = 0; i < IXGBEVF_NB_XSTATS; i++) {
2769 snprintf(xstats[i].name, sizeof(xstats[i].name),
2770 "%s", rte_ixgbevf_stats_strings[i].name);
2771 xstats[i].value = *(uint64_t *)(((char *)hw_stats) +
2772 rte_ixgbevf_stats_strings[i].offset);
2775 return IXGBEVF_NB_XSTATS;
2779 ixgbevf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
2781 struct ixgbevf_hw_stats *hw_stats = (struct ixgbevf_hw_stats *)
2782 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
2784 ixgbevf_update_stats(dev);
2789 stats->ipackets = hw_stats->vfgprc;
2790 stats->ibytes = hw_stats->vfgorc;
2791 stats->opackets = hw_stats->vfgptc;
2792 stats->obytes = hw_stats->vfgotc;
2793 stats->imcasts = hw_stats->vfmprc;
2794 /* stats->imcasts should be removed as imcasts is deprecated */
2798 ixgbevf_dev_stats_reset(struct rte_eth_dev *dev)
2800 struct ixgbevf_hw_stats *hw_stats = (struct ixgbevf_hw_stats*)
2801 IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
2803 /* Sync HW register to the last stats */
2804 ixgbevf_dev_stats_get(dev, NULL);
2806 /* reset HW current stats*/
2807 hw_stats->vfgprc = 0;
2808 hw_stats->vfgorc = 0;
2809 hw_stats->vfgptc = 0;
2810 hw_stats->vfgotc = 0;
2811 hw_stats->vfmprc = 0;
2816 ixgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
2818 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2820 dev_info->max_rx_queues = (uint16_t)hw->mac.max_rx_queues;
2821 dev_info->max_tx_queues = (uint16_t)hw->mac.max_tx_queues;
2822 dev_info->min_rx_bufsize = 1024; /* cf BSIZEPACKET in SRRCTL register */
2823 dev_info->max_rx_pktlen = 15872; /* includes CRC, cf MAXFRS register */
2824 dev_info->max_mac_addrs = hw->mac.num_rar_entries;
2825 dev_info->max_hash_mac_addrs = IXGBE_VMDQ_NUM_UC_MAC;
2826 dev_info->max_vfs = dev->pci_dev->max_vfs;
2827 if (hw->mac.type == ixgbe_mac_82598EB)
2828 dev_info->max_vmdq_pools = ETH_16_POOLS;
2830 dev_info->max_vmdq_pools = ETH_64_POOLS;
2831 dev_info->vmdq_queue_num = dev_info->max_rx_queues;
2832 dev_info->rx_offload_capa =
2833 DEV_RX_OFFLOAD_VLAN_STRIP |
2834 DEV_RX_OFFLOAD_IPV4_CKSUM |
2835 DEV_RX_OFFLOAD_UDP_CKSUM |
2836 DEV_RX_OFFLOAD_TCP_CKSUM;
2839 * RSC is only supported by 82599 and x540 PF devices in a non-SR-IOV
2842 if ((hw->mac.type == ixgbe_mac_82599EB ||
2843 hw->mac.type == ixgbe_mac_X540) &&
2844 !RTE_ETH_DEV_SRIOV(dev).active)
2845 dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_TCP_LRO;
2847 if (hw->mac.type == ixgbe_mac_X550 ||
2848 hw->mac.type == ixgbe_mac_X550EM_x)
2849 dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM;
2851 dev_info->tx_offload_capa =
2852 DEV_TX_OFFLOAD_VLAN_INSERT |
2853 DEV_TX_OFFLOAD_IPV4_CKSUM |
2854 DEV_TX_OFFLOAD_UDP_CKSUM |
2855 DEV_TX_OFFLOAD_TCP_CKSUM |
2856 DEV_TX_OFFLOAD_SCTP_CKSUM |
2857 DEV_TX_OFFLOAD_TCP_TSO;
2859 if (hw->mac.type == ixgbe_mac_X550 ||
2860 hw->mac.type == ixgbe_mac_X550EM_x)
2861 dev_info->tx_offload_capa |= DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
2863 dev_info->default_rxconf = (struct rte_eth_rxconf) {
2865 .pthresh = IXGBE_DEFAULT_RX_PTHRESH,
2866 .hthresh = IXGBE_DEFAULT_RX_HTHRESH,
2867 .wthresh = IXGBE_DEFAULT_RX_WTHRESH,
2869 .rx_free_thresh = IXGBE_DEFAULT_RX_FREE_THRESH,
2873 dev_info->default_txconf = (struct rte_eth_txconf) {
2875 .pthresh = IXGBE_DEFAULT_TX_PTHRESH,
2876 .hthresh = IXGBE_DEFAULT_TX_HTHRESH,
2877 .wthresh = IXGBE_DEFAULT_TX_WTHRESH,
2879 .tx_free_thresh = IXGBE_DEFAULT_TX_FREE_THRESH,
2880 .tx_rs_thresh = IXGBE_DEFAULT_TX_RSBIT_THRESH,
2881 .txq_flags = ETH_TXQ_FLAGS_NOMULTSEGS |
2882 ETH_TXQ_FLAGS_NOOFFLOADS,
2885 dev_info->rx_desc_lim = rx_desc_lim;
2886 dev_info->tx_desc_lim = tx_desc_lim;
2888 dev_info->hash_key_size = IXGBE_HKEY_MAX_INDEX * sizeof(uint32_t);
2889 dev_info->reta_size = ixgbe_reta_size_get(hw->mac.type);
2890 dev_info->flow_type_rss_offloads = IXGBE_RSS_OFFLOAD_ALL;
2894 ixgbevf_dev_info_get(struct rte_eth_dev *dev,
2895 struct rte_eth_dev_info *dev_info)
2897 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2899 dev_info->max_rx_queues = (uint16_t)hw->mac.max_rx_queues;
2900 dev_info->max_tx_queues = (uint16_t)hw->mac.max_tx_queues;
2901 dev_info->min_rx_bufsize = 1024; /* cf BSIZEPACKET in SRRCTL reg */
2902 dev_info->max_rx_pktlen = 15872; /* includes CRC, cf MAXFRS reg */
2903 dev_info->max_mac_addrs = hw->mac.num_rar_entries;
2904 dev_info->max_hash_mac_addrs = IXGBE_VMDQ_NUM_UC_MAC;
2905 dev_info->max_vfs = dev->pci_dev->max_vfs;
2906 if (hw->mac.type == ixgbe_mac_82598EB)
2907 dev_info->max_vmdq_pools = ETH_16_POOLS;
2909 dev_info->max_vmdq_pools = ETH_64_POOLS;
2910 dev_info->rx_offload_capa = DEV_RX_OFFLOAD_VLAN_STRIP |
2911 DEV_RX_OFFLOAD_IPV4_CKSUM |
2912 DEV_RX_OFFLOAD_UDP_CKSUM |
2913 DEV_RX_OFFLOAD_TCP_CKSUM;
2914 dev_info->tx_offload_capa = DEV_TX_OFFLOAD_VLAN_INSERT |
2915 DEV_TX_OFFLOAD_IPV4_CKSUM |
2916 DEV_TX_OFFLOAD_UDP_CKSUM |
2917 DEV_TX_OFFLOAD_TCP_CKSUM |
2918 DEV_TX_OFFLOAD_SCTP_CKSUM |
2919 DEV_TX_OFFLOAD_TCP_TSO;
2921 dev_info->default_rxconf = (struct rte_eth_rxconf) {
2923 .pthresh = IXGBE_DEFAULT_RX_PTHRESH,
2924 .hthresh = IXGBE_DEFAULT_RX_HTHRESH,
2925 .wthresh = IXGBE_DEFAULT_RX_WTHRESH,
2927 .rx_free_thresh = IXGBE_DEFAULT_RX_FREE_THRESH,
2931 dev_info->default_txconf = (struct rte_eth_txconf) {
2933 .pthresh = IXGBE_DEFAULT_TX_PTHRESH,
2934 .hthresh = IXGBE_DEFAULT_TX_HTHRESH,
2935 .wthresh = IXGBE_DEFAULT_TX_WTHRESH,
2937 .tx_free_thresh = IXGBE_DEFAULT_TX_FREE_THRESH,
2938 .tx_rs_thresh = IXGBE_DEFAULT_TX_RSBIT_THRESH,
2939 .txq_flags = ETH_TXQ_FLAGS_NOMULTSEGS |
2940 ETH_TXQ_FLAGS_NOOFFLOADS,
2943 dev_info->rx_desc_lim = rx_desc_lim;
2944 dev_info->tx_desc_lim = tx_desc_lim;
2947 /* return 0 means link status changed, -1 means not changed */
2949 ixgbe_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
2951 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2952 struct rte_eth_link link, old;
2953 ixgbe_link_speed link_speed = IXGBE_LINK_SPEED_UNKNOWN;
2957 link.link_status = 0;
2958 link.link_speed = 0;
2959 link.link_duplex = 0;
2960 memset(&old, 0, sizeof(old));
2961 rte_ixgbe_dev_atomic_read_link_status(dev, &old);
2963 hw->mac.get_link_status = true;
2965 /* check if it needs to wait to complete, if lsc interrupt is enabled */
2966 if (wait_to_complete == 0 || dev->data->dev_conf.intr_conf.lsc != 0)
2967 diag = ixgbe_check_link(hw, &link_speed, &link_up, 0);
2969 diag = ixgbe_check_link(hw, &link_speed, &link_up, 1);
2972 link.link_speed = ETH_LINK_SPEED_100;
2973 link.link_duplex = ETH_LINK_HALF_DUPLEX;
2974 rte_ixgbe_dev_atomic_write_link_status(dev, &link);
2975 if (link.link_status == old.link_status)
2981 rte_ixgbe_dev_atomic_write_link_status(dev, &link);
2982 if (link.link_status == old.link_status)
2986 link.link_status = 1;
2987 link.link_duplex = ETH_LINK_FULL_DUPLEX;
2989 switch (link_speed) {
2991 case IXGBE_LINK_SPEED_UNKNOWN:
2992 link.link_duplex = ETH_LINK_HALF_DUPLEX;
2993 link.link_speed = ETH_LINK_SPEED_100;
2996 case IXGBE_LINK_SPEED_100_FULL:
2997 link.link_speed = ETH_LINK_SPEED_100;
3000 case IXGBE_LINK_SPEED_1GB_FULL:
3001 link.link_speed = ETH_LINK_SPEED_1000;
3004 case IXGBE_LINK_SPEED_10GB_FULL:
3005 link.link_speed = ETH_LINK_SPEED_10000;
3008 rte_ixgbe_dev_atomic_write_link_status(dev, &link);
3010 if (link.link_status == old.link_status)
3017 ixgbe_dev_promiscuous_enable(struct rte_eth_dev *dev)
3019 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3022 fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
3023 fctrl |= (IXGBE_FCTRL_UPE | IXGBE_FCTRL_MPE);
3024 IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
3028 ixgbe_dev_promiscuous_disable(struct rte_eth_dev *dev)
3030 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3033 fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
3034 fctrl &= (~IXGBE_FCTRL_UPE);
3035 if (dev->data->all_multicast == 1)
3036 fctrl |= IXGBE_FCTRL_MPE;
3038 fctrl &= (~IXGBE_FCTRL_MPE);
3039 IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
3043 ixgbe_dev_allmulticast_enable(struct rte_eth_dev *dev)
3045 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3048 fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
3049 fctrl |= IXGBE_FCTRL_MPE;
3050 IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
3054 ixgbe_dev_allmulticast_disable(struct rte_eth_dev *dev)
3056 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3059 if (dev->data->promiscuous == 1)
3060 return; /* must remain in all_multicast mode */
3062 fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
3063 fctrl &= (~IXGBE_FCTRL_MPE);
3064 IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
3068 * It clears the interrupt causes and enables the interrupt.
3069 * It will be called once only during nic initialized.
3072 * Pointer to struct rte_eth_dev.
3075 * - On success, zero.
3076 * - On failure, a negative value.
3079 ixgbe_dev_lsc_interrupt_setup(struct rte_eth_dev *dev)
3081 struct ixgbe_interrupt *intr =
3082 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
3084 ixgbe_dev_link_status_print(dev);
3085 intr->mask |= IXGBE_EICR_LSC;
3091 * It clears the interrupt causes and enables the interrupt.
3092 * It will be called once only during nic initialized.
3095 * Pointer to struct rte_eth_dev.
3098 * - On success, zero.
3099 * - On failure, a negative value.
3102 ixgbe_dev_rxq_interrupt_setup(struct rte_eth_dev *dev)
3104 struct ixgbe_interrupt *intr =
3105 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
3107 intr->mask |= IXGBE_EICR_RTX_QUEUE;
3113 * It reads ICR and sets flag (IXGBE_EICR_LSC) for the link_update.
3116 * Pointer to struct rte_eth_dev.
3119 * - On success, zero.
3120 * - On failure, a negative value.
3123 ixgbe_dev_interrupt_get_status(struct rte_eth_dev *dev)
3126 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3127 struct ixgbe_interrupt *intr =
3128 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
3130 /* clear all cause mask */
3131 ixgbe_disable_intr(hw);
3133 /* read-on-clear nic registers here */
3134 eicr = IXGBE_READ_REG(hw, IXGBE_EICR);
3135 PMD_DRV_LOG(DEBUG, "eicr %x", eicr);
3139 /* set flag for async link update */
3140 if (eicr & IXGBE_EICR_LSC)
3141 intr->flags |= IXGBE_FLAG_NEED_LINK_UPDATE;
3143 if (eicr & IXGBE_EICR_MAILBOX)
3144 intr->flags |= IXGBE_FLAG_MAILBOX;
3150 * It gets and then prints the link status.
3153 * Pointer to struct rte_eth_dev.
3156 * - On success, zero.
3157 * - On failure, a negative value.
3160 ixgbe_dev_link_status_print(struct rte_eth_dev *dev)
3162 struct rte_eth_link link;
3164 memset(&link, 0, sizeof(link));
3165 rte_ixgbe_dev_atomic_read_link_status(dev, &link);
3166 if (link.link_status) {
3167 PMD_INIT_LOG(INFO, "Port %d: Link Up - speed %u Mbps - %s",
3168 (int)(dev->data->port_id),
3169 (unsigned)link.link_speed,
3170 link.link_duplex == ETH_LINK_FULL_DUPLEX ?
3171 "full-duplex" : "half-duplex");
3173 PMD_INIT_LOG(INFO, " Port %d: Link Down",
3174 (int)(dev->data->port_id));
3176 PMD_INIT_LOG(DEBUG, "PCI Address: %04d:%02d:%02d:%d",
3177 dev->pci_dev->addr.domain,
3178 dev->pci_dev->addr.bus,
3179 dev->pci_dev->addr.devid,
3180 dev->pci_dev->addr.function);
3184 * It executes link_update after knowing an interrupt occurred.
3187 * Pointer to struct rte_eth_dev.
3190 * - On success, zero.
3191 * - On failure, a negative value.
3194 ixgbe_dev_interrupt_action(struct rte_eth_dev *dev)
3196 struct ixgbe_interrupt *intr =
3197 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
3199 struct rte_eth_link link;
3200 int intr_enable_delay = false;
3202 PMD_DRV_LOG(DEBUG, "intr action type %d", intr->flags);
3204 if (intr->flags & IXGBE_FLAG_MAILBOX) {
3205 ixgbe_pf_mbx_process(dev);
3206 intr->flags &= ~IXGBE_FLAG_MAILBOX;
3209 if (intr->flags & IXGBE_FLAG_NEED_LINK_UPDATE) {
3210 /* get the link status before link update, for predicting later */
3211 memset(&link, 0, sizeof(link));
3212 rte_ixgbe_dev_atomic_read_link_status(dev, &link);
3214 ixgbe_dev_link_update(dev, 0);
3217 if (!link.link_status)
3218 /* handle it 1 sec later, wait it being stable */
3219 timeout = IXGBE_LINK_UP_CHECK_TIMEOUT;
3220 /* likely to down */
3222 /* handle it 4 sec later, wait it being stable */
3223 timeout = IXGBE_LINK_DOWN_CHECK_TIMEOUT;
3225 ixgbe_dev_link_status_print(dev);
3227 intr_enable_delay = true;
3230 if (intr_enable_delay) {
3231 if (rte_eal_alarm_set(timeout * 1000,
3232 ixgbe_dev_interrupt_delayed_handler, (void*)dev) < 0)
3233 PMD_DRV_LOG(ERR, "Error setting alarm");
3235 PMD_DRV_LOG(DEBUG, "enable intr immediately");
3236 ixgbe_enable_intr(dev);
3237 rte_intr_enable(&(dev->pci_dev->intr_handle));
3245 * Interrupt handler which shall be registered for alarm callback for delayed
3246 * handling specific interrupt to wait for the stable nic state. As the
3247 * NIC interrupt state is not stable for ixgbe after link is just down,
3248 * it needs to wait 4 seconds to get the stable status.
3251 * Pointer to interrupt handle.
3253 * The address of parameter (struct rte_eth_dev *) regsitered before.
3259 ixgbe_dev_interrupt_delayed_handler(void *param)
3261 struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
3262 struct ixgbe_interrupt *intr =
3263 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
3264 struct ixgbe_hw *hw =
3265 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3268 eicr = IXGBE_READ_REG(hw, IXGBE_EICR);
3269 if (eicr & IXGBE_EICR_MAILBOX)
3270 ixgbe_pf_mbx_process(dev);
3272 if (intr->flags & IXGBE_FLAG_NEED_LINK_UPDATE) {
3273 ixgbe_dev_link_update(dev, 0);
3274 intr->flags &= ~IXGBE_FLAG_NEED_LINK_UPDATE;
3275 ixgbe_dev_link_status_print(dev);
3276 _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC);
3279 PMD_DRV_LOG(DEBUG, "enable intr in delayed handler S[%08x]", eicr);
3280 ixgbe_enable_intr(dev);
3281 rte_intr_enable(&(dev->pci_dev->intr_handle));
3285 * Interrupt handler triggered by NIC for handling
3286 * specific interrupt.
3289 * Pointer to interrupt handle.
3291 * The address of parameter (struct rte_eth_dev *) regsitered before.
3297 ixgbe_dev_interrupt_handler(__rte_unused struct rte_intr_handle *handle,
3300 struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
3302 ixgbe_dev_interrupt_get_status(dev);
3303 ixgbe_dev_interrupt_action(dev);
3307 ixgbe_dev_led_on(struct rte_eth_dev *dev)
3309 struct ixgbe_hw *hw;
3311 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3312 return ixgbe_led_on(hw, 0) == IXGBE_SUCCESS ? 0 : -ENOTSUP;
3316 ixgbe_dev_led_off(struct rte_eth_dev *dev)
3318 struct ixgbe_hw *hw;
3320 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3321 return ixgbe_led_off(hw, 0) == IXGBE_SUCCESS ? 0 : -ENOTSUP;
3325 ixgbe_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
3327 struct ixgbe_hw *hw;
3333 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3335 fc_conf->pause_time = hw->fc.pause_time;
3336 fc_conf->high_water = hw->fc.high_water[0];
3337 fc_conf->low_water = hw->fc.low_water[0];
3338 fc_conf->send_xon = hw->fc.send_xon;
3339 fc_conf->autoneg = !hw->fc.disable_fc_autoneg;
3342 * Return rx_pause status according to actual setting of
3345 mflcn_reg = IXGBE_READ_REG(hw, IXGBE_MFLCN);
3346 if (mflcn_reg & (IXGBE_MFLCN_RPFCE | IXGBE_MFLCN_RFCE))
3352 * Return tx_pause status according to actual setting of
3355 fccfg_reg = IXGBE_READ_REG(hw, IXGBE_FCCFG);
3356 if (fccfg_reg & (IXGBE_FCCFG_TFCE_802_3X | IXGBE_FCCFG_TFCE_PRIORITY))
3361 if (rx_pause && tx_pause)
3362 fc_conf->mode = RTE_FC_FULL;
3364 fc_conf->mode = RTE_FC_RX_PAUSE;
3366 fc_conf->mode = RTE_FC_TX_PAUSE;
3368 fc_conf->mode = RTE_FC_NONE;
3374 ixgbe_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
3376 struct ixgbe_hw *hw;
3378 uint32_t rx_buf_size;
3379 uint32_t max_high_water;
3381 enum ixgbe_fc_mode rte_fcmode_2_ixgbe_fcmode[] = {
3388 PMD_INIT_FUNC_TRACE();
3390 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3391 rx_buf_size = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(0));
3392 PMD_INIT_LOG(DEBUG, "Rx packet buffer size = 0x%x", rx_buf_size);
3395 * At least reserve one Ethernet frame for watermark
3396 * high_water/low_water in kilo bytes for ixgbe
3398 max_high_water = (rx_buf_size - ETHER_MAX_LEN) >> IXGBE_RXPBSIZE_SHIFT;
3399 if ((fc_conf->high_water > max_high_water) ||
3400 (fc_conf->high_water < fc_conf->low_water)) {
3401 PMD_INIT_LOG(ERR, "Invalid high/low water setup value in KB");
3402 PMD_INIT_LOG(ERR, "High_water must <= 0x%x", max_high_water);
3406 hw->fc.requested_mode = rte_fcmode_2_ixgbe_fcmode[fc_conf->mode];
3407 hw->fc.pause_time = fc_conf->pause_time;
3408 hw->fc.high_water[0] = fc_conf->high_water;
3409 hw->fc.low_water[0] = fc_conf->low_water;
3410 hw->fc.send_xon = fc_conf->send_xon;
3411 hw->fc.disable_fc_autoneg = !fc_conf->autoneg;
3413 err = ixgbe_fc_enable(hw);
3415 /* Not negotiated is not an error case */
3416 if ((err == IXGBE_SUCCESS) || (err == IXGBE_ERR_FC_NOT_NEGOTIATED)) {
3418 /* check if we want to forward MAC frames - driver doesn't have native
3419 * capability to do that, so we'll write the registers ourselves */
3421 mflcn = IXGBE_READ_REG(hw, IXGBE_MFLCN);
3423 /* set or clear MFLCN.PMCF bit depending on configuration */
3424 if (fc_conf->mac_ctrl_frame_fwd != 0)
3425 mflcn |= IXGBE_MFLCN_PMCF;
3427 mflcn &= ~IXGBE_MFLCN_PMCF;
3429 IXGBE_WRITE_REG(hw, IXGBE_MFLCN, mflcn);
3430 IXGBE_WRITE_FLUSH(hw);
3435 PMD_INIT_LOG(ERR, "ixgbe_fc_enable = 0x%x", err);
3440 * ixgbe_pfc_enable_generic - Enable flow control
3441 * @hw: pointer to hardware structure
3442 * @tc_num: traffic class number
3443 * Enable flow control according to the current settings.
3446 ixgbe_dcb_pfc_enable_generic(struct ixgbe_hw *hw,uint8_t tc_num)
3449 uint32_t mflcn_reg, fccfg_reg;
3451 uint32_t fcrtl, fcrth;
3455 /* Validate the water mark configuration */
3456 if (!hw->fc.pause_time) {
3457 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
3461 /* Low water mark of zero causes XOFF floods */
3462 if (hw->fc.current_mode & ixgbe_fc_tx_pause) {
3463 /* High/Low water can not be 0 */
3464 if ((!hw->fc.high_water[tc_num]) || (!hw->fc.low_water[tc_num])) {
3465 PMD_INIT_LOG(ERR, "Invalid water mark configuration");
3466 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
3470 if (hw->fc.low_water[tc_num] >= hw->fc.high_water[tc_num]) {
3471 PMD_INIT_LOG(ERR, "Invalid water mark configuration");
3472 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
3476 /* Negotiate the fc mode to use */
3477 ixgbe_fc_autoneg(hw);
3479 /* Disable any previous flow control settings */
3480 mflcn_reg = IXGBE_READ_REG(hw, IXGBE_MFLCN);
3481 mflcn_reg &= ~(IXGBE_MFLCN_RPFCE_SHIFT | IXGBE_MFLCN_RFCE|IXGBE_MFLCN_RPFCE);
3483 fccfg_reg = IXGBE_READ_REG(hw, IXGBE_FCCFG);
3484 fccfg_reg &= ~(IXGBE_FCCFG_TFCE_802_3X | IXGBE_FCCFG_TFCE_PRIORITY);
3486 switch (hw->fc.current_mode) {
3489 * If the count of enabled RX Priority Flow control >1,
3490 * and the TX pause can not be disabled
3493 for (i =0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
3494 reg = IXGBE_READ_REG(hw, IXGBE_FCRTH_82599(i));
3495 if (reg & IXGBE_FCRTH_FCEN)
3499 fccfg_reg |=IXGBE_FCCFG_TFCE_PRIORITY;
3501 case ixgbe_fc_rx_pause:
3503 * Rx Flow control is enabled and Tx Flow control is
3504 * disabled by software override. Since there really
3505 * isn't a way to advertise that we are capable of RX
3506 * Pause ONLY, we will advertise that we support both
3507 * symmetric and asymmetric Rx PAUSE. Later, we will
3508 * disable the adapter's ability to send PAUSE frames.
3510 mflcn_reg |= IXGBE_MFLCN_RPFCE;
3512 * If the count of enabled RX Priority Flow control >1,
3513 * and the TX pause can not be disabled
3516 for (i =0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
3517 reg = IXGBE_READ_REG(hw, IXGBE_FCRTH_82599(i));
3518 if (reg & IXGBE_FCRTH_FCEN)
3522 fccfg_reg |=IXGBE_FCCFG_TFCE_PRIORITY;
3524 case ixgbe_fc_tx_pause:
3526 * Tx Flow control is enabled, and Rx Flow control is
3527 * disabled by software override.
3529 fccfg_reg |=IXGBE_FCCFG_TFCE_PRIORITY;
3532 /* Flow control (both Rx and Tx) is enabled by SW override. */
3533 mflcn_reg |= IXGBE_MFLCN_RPFCE;
3534 fccfg_reg |= IXGBE_FCCFG_TFCE_PRIORITY;
3537 PMD_DRV_LOG(DEBUG, "Flow control param set incorrectly");
3538 ret_val = IXGBE_ERR_CONFIG;
3543 /* Set 802.3x based flow control settings. */
3544 mflcn_reg |= IXGBE_MFLCN_DPF;
3545 IXGBE_WRITE_REG(hw, IXGBE_MFLCN, mflcn_reg);
3546 IXGBE_WRITE_REG(hw, IXGBE_FCCFG, fccfg_reg);
3548 /* Set up and enable Rx high/low water mark thresholds, enable XON. */
3549 if ((hw->fc.current_mode & ixgbe_fc_tx_pause) &&
3550 hw->fc.high_water[tc_num]) {
3551 fcrtl = (hw->fc.low_water[tc_num] << 10) | IXGBE_FCRTL_XONE;
3552 IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(tc_num), fcrtl);
3553 fcrth = (hw->fc.high_water[tc_num] << 10) | IXGBE_FCRTH_FCEN;
3555 IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(tc_num), 0);
3557 * In order to prevent Tx hangs when the internal Tx
3558 * switch is enabled we must set the high water mark
3559 * to the maximum FCRTH value. This allows the Tx
3560 * switch to function even under heavy Rx workloads.
3562 fcrth = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(tc_num)) - 32;
3564 IXGBE_WRITE_REG(hw, IXGBE_FCRTH_82599(tc_num), fcrth);
3566 /* Configure pause time (2 TCs per register) */
3567 reg = hw->fc.pause_time * 0x00010001;
3568 for (i = 0; i < (IXGBE_DCB_MAX_TRAFFIC_CLASS / 2); i++)
3569 IXGBE_WRITE_REG(hw, IXGBE_FCTTV(i), reg);
3571 /* Configure flow control refresh threshold value */
3572 IXGBE_WRITE_REG(hw, IXGBE_FCRTV, hw->fc.pause_time / 2);
3579 ixgbe_dcb_pfc_enable(struct rte_eth_dev *dev,uint8_t tc_num)
3581 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3582 int32_t ret_val = IXGBE_NOT_IMPLEMENTED;
3584 if (hw->mac.type != ixgbe_mac_82598EB) {
3585 ret_val = ixgbe_dcb_pfc_enable_generic(hw,tc_num);
3591 ixgbe_priority_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_pfc_conf *pfc_conf)
3594 uint32_t rx_buf_size;
3595 uint32_t max_high_water;
3597 uint8_t map[IXGBE_DCB_MAX_USER_PRIORITY] = { 0 };
3598 struct ixgbe_hw *hw =
3599 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3600 struct ixgbe_dcb_config *dcb_config =
3601 IXGBE_DEV_PRIVATE_TO_DCB_CFG(dev->data->dev_private);
3603 enum ixgbe_fc_mode rte_fcmode_2_ixgbe_fcmode[] = {
3610 PMD_INIT_FUNC_TRACE();
3612 ixgbe_dcb_unpack_map_cee(dcb_config, IXGBE_DCB_RX_CONFIG, map);
3613 tc_num = map[pfc_conf->priority];
3614 rx_buf_size = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(tc_num));
3615 PMD_INIT_LOG(DEBUG, "Rx packet buffer size = 0x%x", rx_buf_size);
3617 * At least reserve one Ethernet frame for watermark
3618 * high_water/low_water in kilo bytes for ixgbe
3620 max_high_water = (rx_buf_size - ETHER_MAX_LEN) >> IXGBE_RXPBSIZE_SHIFT;
3621 if ((pfc_conf->fc.high_water > max_high_water) ||
3622 (pfc_conf->fc.high_water <= pfc_conf->fc.low_water)) {
3623 PMD_INIT_LOG(ERR, "Invalid high/low water setup value in KB");
3624 PMD_INIT_LOG(ERR, "High_water must <= 0x%x", max_high_water);
3628 hw->fc.requested_mode = rte_fcmode_2_ixgbe_fcmode[pfc_conf->fc.mode];
3629 hw->fc.pause_time = pfc_conf->fc.pause_time;
3630 hw->fc.send_xon = pfc_conf->fc.send_xon;
3631 hw->fc.low_water[tc_num] = pfc_conf->fc.low_water;
3632 hw->fc.high_water[tc_num] = pfc_conf->fc.high_water;
3634 err = ixgbe_dcb_pfc_enable(dev,tc_num);
3636 /* Not negotiated is not an error case */
3637 if ((err == IXGBE_SUCCESS) || (err == IXGBE_ERR_FC_NOT_NEGOTIATED))
3640 PMD_INIT_LOG(ERR, "ixgbe_dcb_pfc_enable = 0x%x", err);
3645 ixgbe_dev_rss_reta_update(struct rte_eth_dev *dev,
3646 struct rte_eth_rss_reta_entry64 *reta_conf,
3651 uint16_t idx, shift;
3652 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3653 uint16_t sp_reta_size;
3656 PMD_INIT_FUNC_TRACE();
3658 if (!ixgbe_rss_update_sp(hw->mac.type)) {
3659 PMD_DRV_LOG(ERR, "RSS reta update is not supported on this "
3664 sp_reta_size = ixgbe_reta_size_get(hw->mac.type);
3665 if (reta_size != sp_reta_size) {
3666 PMD_DRV_LOG(ERR, "The size of hash lookup table configured "
3667 "(%d) doesn't match the number hardware can supported "
3668 "(%d)\n", reta_size, sp_reta_size);
3672 for (i = 0; i < reta_size; i += IXGBE_4_BIT_WIDTH) {
3673 idx = i / RTE_RETA_GROUP_SIZE;
3674 shift = i % RTE_RETA_GROUP_SIZE;
3675 mask = (uint8_t)((reta_conf[idx].mask >> shift) &
3679 reta_reg = ixgbe_reta_reg_get(hw->mac.type, i);
3680 if (mask == IXGBE_4_BIT_MASK)
3683 r = IXGBE_READ_REG(hw, reta_reg);
3684 for (j = 0, reta = 0; j < IXGBE_4_BIT_WIDTH; j++) {
3685 if (mask & (0x1 << j))
3686 reta |= reta_conf[idx].reta[shift + j] <<
3689 reta |= r & (IXGBE_8_BIT_MASK <<
3692 IXGBE_WRITE_REG(hw, reta_reg, reta);
3699 ixgbe_dev_rss_reta_query(struct rte_eth_dev *dev,
3700 struct rte_eth_rss_reta_entry64 *reta_conf,
3705 uint16_t idx, shift;
3706 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3707 uint16_t sp_reta_size;
3710 PMD_INIT_FUNC_TRACE();
3711 sp_reta_size = ixgbe_reta_size_get(hw->mac.type);
3712 if (reta_size != sp_reta_size) {
3713 PMD_DRV_LOG(ERR, "The size of hash lookup table configured "
3714 "(%d) doesn't match the number hardware can supported "
3715 "(%d)\n", reta_size, sp_reta_size);
3719 for (i = 0; i < reta_size; i += IXGBE_4_BIT_WIDTH) {
3720 idx = i / RTE_RETA_GROUP_SIZE;
3721 shift = i % RTE_RETA_GROUP_SIZE;
3722 mask = (uint8_t)((reta_conf[idx].mask >> shift) &
3727 reta_reg = ixgbe_reta_reg_get(hw->mac.type, i);
3728 reta = IXGBE_READ_REG(hw, reta_reg);
3729 for (j = 0; j < IXGBE_4_BIT_WIDTH; j++) {
3730 if (mask & (0x1 << j))
3731 reta_conf[idx].reta[shift + j] =
3732 ((reta >> (CHAR_BIT * j)) &
3741 ixgbe_add_rar(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
3742 uint32_t index, uint32_t pool)
3744 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3745 uint32_t enable_addr = 1;
3747 ixgbe_set_rar(hw, index, mac_addr->addr_bytes, pool, enable_addr);
3751 ixgbe_remove_rar(struct rte_eth_dev *dev, uint32_t index)
3753 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3755 ixgbe_clear_rar(hw, index);
3759 ixgbe_set_default_mac_addr(struct rte_eth_dev *dev, struct ether_addr *addr)
3761 ixgbe_remove_rar(dev, 0);
3763 ixgbe_add_rar(dev, addr, 0, 0);
3767 ixgbe_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
3771 struct ixgbe_hw *hw;
3772 struct rte_eth_dev_info dev_info;
3773 uint32_t frame_size = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
3775 ixgbe_dev_info_get(dev, &dev_info);
3777 /* check that mtu is within the allowed range */
3778 if ((mtu < ETHER_MIN_MTU) || (frame_size > dev_info.max_rx_pktlen))
3781 /* refuse mtu that requires the support of scattered packets when this
3782 * feature has not been enabled before. */
3783 if (!dev->data->scattered_rx &&
3784 (frame_size + 2 * IXGBE_VLAN_TAG_SIZE >
3785 dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM))
3788 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3789 hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
3791 /* switch to jumbo mode if needed */
3792 if (frame_size > ETHER_MAX_LEN) {
3793 dev->data->dev_conf.rxmode.jumbo_frame = 1;
3794 hlreg0 |= IXGBE_HLREG0_JUMBOEN;
3796 dev->data->dev_conf.rxmode.jumbo_frame = 0;
3797 hlreg0 &= ~IXGBE_HLREG0_JUMBOEN;
3799 IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
3801 /* update max frame size */
3802 dev->data->dev_conf.rxmode.max_rx_pkt_len = frame_size;
3804 maxfrs = IXGBE_READ_REG(hw, IXGBE_MAXFRS);
3805 maxfrs &= 0x0000FFFF;
3806 maxfrs |= (dev->data->dev_conf.rxmode.max_rx_pkt_len << 16);
3807 IXGBE_WRITE_REG(hw, IXGBE_MAXFRS, maxfrs);
3813 * Virtual Function operations
3816 ixgbevf_intr_disable(struct ixgbe_hw *hw)
3818 PMD_INIT_FUNC_TRACE();
3820 /* Clear interrupt mask to stop from interrupts being generated */
3821 IXGBE_WRITE_REG(hw, IXGBE_VTEIMC, IXGBE_VF_IRQ_CLEAR_MASK);
3823 IXGBE_WRITE_FLUSH(hw);
3827 ixgbevf_intr_enable(struct ixgbe_hw *hw)
3829 PMD_INIT_FUNC_TRACE();
3831 /* VF enable interrupt autoclean */
3832 IXGBE_WRITE_REG(hw, IXGBE_VTEIAM, IXGBE_VF_IRQ_ENABLE_MASK);
3833 IXGBE_WRITE_REG(hw, IXGBE_VTEIAC, IXGBE_VF_IRQ_ENABLE_MASK);
3834 IXGBE_WRITE_REG(hw, IXGBE_VTEIMS, IXGBE_VF_IRQ_ENABLE_MASK);
3836 IXGBE_WRITE_FLUSH(hw);
3840 ixgbevf_dev_configure(struct rte_eth_dev *dev)
3842 struct rte_eth_conf* conf = &dev->data->dev_conf;
3843 struct ixgbe_adapter *adapter =
3844 (struct ixgbe_adapter *)dev->data->dev_private;
3846 PMD_INIT_LOG(DEBUG, "Configured Virtual Function port id: %d",
3847 dev->data->port_id);
3850 * VF has no ability to enable/disable HW CRC
3851 * Keep the persistent behavior the same as Host PF
3853 #ifndef RTE_LIBRTE_IXGBE_PF_DISABLE_STRIP_CRC
3854 if (!conf->rxmode.hw_strip_crc) {
3855 PMD_INIT_LOG(NOTICE, "VF can't disable HW CRC Strip");
3856 conf->rxmode.hw_strip_crc = 1;
3859 if (conf->rxmode.hw_strip_crc) {
3860 PMD_INIT_LOG(NOTICE, "VF can't enable HW CRC Strip");
3861 conf->rxmode.hw_strip_crc = 0;
3866 * Initialize to TRUE. If any of Rx queues doesn't meet the bulk
3867 * allocation or vector Rx preconditions we will reset it.
3869 adapter->rx_bulk_alloc_allowed = true;
3870 adapter->rx_vec_allowed = true;
3876 ixgbevf_dev_start(struct rte_eth_dev *dev)
3878 struct ixgbe_hw *hw =
3879 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3880 uint32_t intr_vector = 0;
3881 struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;
3885 PMD_INIT_FUNC_TRACE();
3887 hw->mac.ops.reset_hw(hw);
3888 hw->mac.get_link_status = true;
3890 /* negotiate mailbox API version to use with the PF. */
3891 ixgbevf_negotiate_api(hw);
3893 ixgbevf_dev_tx_init(dev);
3895 /* This can fail when allocating mbufs for descriptor rings */
3896 err = ixgbevf_dev_rx_init(dev);
3898 PMD_INIT_LOG(ERR, "Unable to initialize RX hardware (%d)", err);
3899 ixgbe_dev_clear_queues(dev);
3904 ixgbevf_set_vfta_all(dev,1);
3907 mask = ETH_VLAN_STRIP_MASK | ETH_VLAN_FILTER_MASK | \
3908 ETH_VLAN_EXTEND_MASK;
3909 ixgbevf_vlan_offload_set(dev, mask);
3911 ixgbevf_dev_rxtx_start(dev);
3913 /* check and configure queue intr-vector mapping */
3914 if (dev->data->dev_conf.intr_conf.rxq != 0) {
3915 intr_vector = dev->data->nb_rx_queues;
3916 if (rte_intr_efd_enable(intr_handle, intr_vector))
3920 if (rte_intr_dp_is_en(intr_handle) && !intr_handle->intr_vec) {
3921 intr_handle->intr_vec =
3922 rte_zmalloc("intr_vec",
3923 dev->data->nb_rx_queues * sizeof(int), 0);
3924 if (intr_handle->intr_vec == NULL) {
3925 PMD_INIT_LOG(ERR, "Failed to allocate %d rx_queues"
3926 " intr_vec\n", dev->data->nb_rx_queues);
3930 ixgbevf_configure_msix(dev);
3932 rte_intr_enable(intr_handle);
3934 /* Re-enable interrupt for VF */
3935 ixgbevf_intr_enable(hw);
3941 ixgbevf_dev_stop(struct rte_eth_dev *dev)
3943 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3944 struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;
3946 PMD_INIT_FUNC_TRACE();
3948 hw->adapter_stopped = 1;
3949 ixgbe_stop_adapter(hw);
3952 * Clear what we set, but we still keep shadow_vfta to
3953 * restore after device starts
3955 ixgbevf_set_vfta_all(dev,0);
3957 /* Clear stored conf */
3958 dev->data->scattered_rx = 0;
3960 ixgbe_dev_clear_queues(dev);
3962 /* Clean datapath event and queue/vec mapping */
3963 rte_intr_efd_disable(intr_handle);
3964 if (intr_handle->intr_vec != NULL) {
3965 rte_free(intr_handle->intr_vec);
3966 intr_handle->intr_vec = NULL;
3971 ixgbevf_dev_close(struct rte_eth_dev *dev)
3973 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3975 PMD_INIT_FUNC_TRACE();
3979 ixgbevf_dev_stop(dev);
3981 ixgbe_dev_free_queues(dev);
3983 /* reprogram the RAR[0] in case user changed it. */
3984 ixgbe_set_rar(hw, 0, hw->mac.addr, 0, IXGBE_RAH_AV);
3987 static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on)
3989 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3990 struct ixgbe_vfta * shadow_vfta =
3991 IXGBE_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
3992 int i = 0, j = 0, vfta = 0, mask = 1;
3994 for (i = 0; i < IXGBE_VFTA_SIZE; i++){
3995 vfta = shadow_vfta->vfta[i];
3998 for (j = 0; j < 32; j++){
4000 ixgbe_set_vfta(hw, (i<<5)+j, 0, on);
4009 ixgbevf_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
4011 struct ixgbe_hw *hw =
4012 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4013 struct ixgbe_vfta * shadow_vfta =
4014 IXGBE_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
4015 uint32_t vid_idx = 0;
4016 uint32_t vid_bit = 0;
4019 PMD_INIT_FUNC_TRACE();
4021 /* vind is not used in VF driver, set to 0, check ixgbe_set_vfta_vf */
4022 ret = ixgbe_set_vfta(hw, vlan_id, 0, !!on);
4024 PMD_INIT_LOG(ERR, "Unable to set VF vlan");
4027 vid_idx = (uint32_t) ((vlan_id >> 5) & 0x7F);
4028 vid_bit = (uint32_t) (1 << (vlan_id & 0x1F));
4030 /* Save what we set and retore it after device reset */
4032 shadow_vfta->vfta[vid_idx] |= vid_bit;
4034 shadow_vfta->vfta[vid_idx] &= ~vid_bit;
4040 ixgbevf_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue, int on)
4042 struct ixgbe_hw *hw =
4043 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4046 PMD_INIT_FUNC_TRACE();
4048 if (queue >= hw->mac.max_rx_queues)
4051 ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(queue));
4053 ctrl |= IXGBE_RXDCTL_VME;
4055 ctrl &= ~IXGBE_RXDCTL_VME;
4056 IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(queue), ctrl);
4058 ixgbe_vlan_hw_strip_bitmap_set( dev, queue, on);
4062 ixgbevf_vlan_offload_set(struct rte_eth_dev *dev, int mask)
4064 struct ixgbe_hw *hw =
4065 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4069 /* VF function only support hw strip feature, others are not support */
4070 if (mask & ETH_VLAN_STRIP_MASK) {
4071 on = !!(dev->data->dev_conf.rxmode.hw_vlan_strip);
4073 for (i = 0; i < hw->mac.max_rx_queues; i++)
4074 ixgbevf_vlan_strip_queue_set(dev,i,on);
4079 ixgbe_vmdq_mode_check(struct ixgbe_hw *hw)
4083 /* we only need to do this if VMDq is enabled */
4084 reg_val = IXGBE_READ_REG(hw, IXGBE_VT_CTL);
4085 if (!(reg_val & IXGBE_VT_CTL_VT_ENABLE)) {
4086 PMD_INIT_LOG(ERR, "VMDq must be enabled for this setting");
4094 ixgbe_uta_vector(struct ixgbe_hw *hw, struct ether_addr* uc_addr)
4096 uint32_t vector = 0;
4097 switch (hw->mac.mc_filter_type) {
4098 case 0: /* use bits [47:36] of the address */
4099 vector = ((uc_addr->addr_bytes[4] >> 4) |
4100 (((uint16_t)uc_addr->addr_bytes[5]) << 4));
4102 case 1: /* use bits [46:35] of the address */
4103 vector = ((uc_addr->addr_bytes[4] >> 3) |
4104 (((uint16_t)uc_addr->addr_bytes[5]) << 5));
4106 case 2: /* use bits [45:34] of the address */
4107 vector = ((uc_addr->addr_bytes[4] >> 2) |
4108 (((uint16_t)uc_addr->addr_bytes[5]) << 6));
4110 case 3: /* use bits [43:32] of the address */
4111 vector = ((uc_addr->addr_bytes[4]) |
4112 (((uint16_t)uc_addr->addr_bytes[5]) << 8));
4114 default: /* Invalid mc_filter_type */
4118 /* vector can only be 12-bits or boundary will be exceeded */
4124 ixgbe_uc_hash_table_set(struct rte_eth_dev *dev,struct ether_addr* mac_addr,
4132 const uint32_t ixgbe_uta_idx_mask = 0x7F;
4133 const uint32_t ixgbe_uta_bit_shift = 5;
4134 const uint32_t ixgbe_uta_bit_mask = (0x1 << ixgbe_uta_bit_shift) - 1;
4135 const uint32_t bit1 = 0x1;
4137 struct ixgbe_hw *hw =
4138 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4139 struct ixgbe_uta_info *uta_info =
4140 IXGBE_DEV_PRIVATE_TO_UTA(dev->data->dev_private);
4142 /* The UTA table only exists on 82599 hardware and newer */
4143 if (hw->mac.type < ixgbe_mac_82599EB)
4146 vector = ixgbe_uta_vector(hw,mac_addr);
4147 uta_idx = (vector >> ixgbe_uta_bit_shift) & ixgbe_uta_idx_mask;
4148 uta_shift = vector & ixgbe_uta_bit_mask;
4150 rc = ((uta_info->uta_shadow[uta_idx] >> uta_shift & bit1) != 0);
4154 reg_val = IXGBE_READ_REG(hw, IXGBE_UTA(uta_idx));
4156 uta_info->uta_in_use++;
4157 reg_val |= (bit1 << uta_shift);
4158 uta_info->uta_shadow[uta_idx] |= (bit1 << uta_shift);
4160 uta_info->uta_in_use--;
4161 reg_val &= ~(bit1 << uta_shift);
4162 uta_info->uta_shadow[uta_idx] &= ~(bit1 << uta_shift);
4165 IXGBE_WRITE_REG(hw, IXGBE_UTA(uta_idx), reg_val);
4167 if (uta_info->uta_in_use > 0)
4168 IXGBE_WRITE_REG(hw, IXGBE_MCSTCTRL,
4169 IXGBE_MCSTCTRL_MFE | hw->mac.mc_filter_type);
4171 IXGBE_WRITE_REG(hw, IXGBE_MCSTCTRL,hw->mac.mc_filter_type);
4177 ixgbe_uc_all_hash_table_set(struct rte_eth_dev *dev, uint8_t on)
4180 struct ixgbe_hw *hw =
4181 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4182 struct ixgbe_uta_info *uta_info =
4183 IXGBE_DEV_PRIVATE_TO_UTA(dev->data->dev_private);
4185 /* The UTA table only exists on 82599 hardware and newer */
4186 if (hw->mac.type < ixgbe_mac_82599EB)
4190 for (i = 0; i < ETH_VMDQ_NUM_UC_HASH_ARRAY; i++) {
4191 uta_info->uta_shadow[i] = ~0;
4192 IXGBE_WRITE_REG(hw, IXGBE_UTA(i), ~0);
4195 for (i = 0; i < ETH_VMDQ_NUM_UC_HASH_ARRAY; i++) {
4196 uta_info->uta_shadow[i] = 0;
4197 IXGBE_WRITE_REG(hw, IXGBE_UTA(i), 0);
4205 ixgbe_convert_vm_rx_mask_to_val(uint16_t rx_mask, uint32_t orig_val)
4207 uint32_t new_val = orig_val;
4209 if (rx_mask & ETH_VMDQ_ACCEPT_UNTAG)
4210 new_val |= IXGBE_VMOLR_AUPE;
4211 if (rx_mask & ETH_VMDQ_ACCEPT_HASH_MC)
4212 new_val |= IXGBE_VMOLR_ROMPE;
4213 if (rx_mask & ETH_VMDQ_ACCEPT_HASH_UC)
4214 new_val |= IXGBE_VMOLR_ROPE;
4215 if (rx_mask & ETH_VMDQ_ACCEPT_BROADCAST)
4216 new_val |= IXGBE_VMOLR_BAM;
4217 if (rx_mask & ETH_VMDQ_ACCEPT_MULTICAST)
4218 new_val |= IXGBE_VMOLR_MPE;
4224 ixgbe_set_pool_rx_mode(struct rte_eth_dev *dev, uint16_t pool,
4225 uint16_t rx_mask, uint8_t on)
4229 struct ixgbe_hw *hw =
4230 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4231 uint32_t vmolr = IXGBE_READ_REG(hw, IXGBE_VMOLR(pool));
4233 if (hw->mac.type == ixgbe_mac_82598EB) {
4234 PMD_INIT_LOG(ERR, "setting VF receive mode set should be done"
4235 " on 82599 hardware and newer");
4238 if (ixgbe_vmdq_mode_check(hw) < 0)
4241 val = ixgbe_convert_vm_rx_mask_to_val(rx_mask, val);
4248 IXGBE_WRITE_REG(hw, IXGBE_VMOLR(pool), vmolr);
4254 ixgbe_set_pool_rx(struct rte_eth_dev *dev, uint16_t pool, uint8_t on)
4258 const uint8_t bit1 = 0x1;
4260 struct ixgbe_hw *hw =
4261 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4263 if (ixgbe_vmdq_mode_check(hw) < 0)
4266 addr = IXGBE_VFRE(pool >= ETH_64_POOLS/2);
4267 reg = IXGBE_READ_REG(hw, addr);
4275 IXGBE_WRITE_REG(hw, addr,reg);
4281 ixgbe_set_pool_tx(struct rte_eth_dev *dev, uint16_t pool, uint8_t on)
4285 const uint8_t bit1 = 0x1;
4287 struct ixgbe_hw *hw =
4288 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4290 if (ixgbe_vmdq_mode_check(hw) < 0)
4293 addr = IXGBE_VFTE(pool >= ETH_64_POOLS/2);
4294 reg = IXGBE_READ_REG(hw, addr);
4302 IXGBE_WRITE_REG(hw, addr,reg);
4308 ixgbe_set_pool_vlan_filter(struct rte_eth_dev *dev, uint16_t vlan,
4309 uint64_t pool_mask, uint8_t vlan_on)
4313 struct ixgbe_hw *hw =
4314 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4316 if (ixgbe_vmdq_mode_check(hw) < 0)
4318 for (pool_idx = 0; pool_idx < ETH_64_POOLS; pool_idx++) {
4319 if (pool_mask & ((uint64_t)(1ULL << pool_idx)))
4320 ret = hw->mac.ops.set_vfta(hw,vlan,pool_idx,vlan_on);
4328 #define IXGBE_MRCTL_VPME 0x01 /* Virtual Pool Mirroring. */
4329 #define IXGBE_MRCTL_UPME 0x02 /* Uplink Port Mirroring. */
4330 #define IXGBE_MRCTL_DPME 0x04 /* Downlink Port Mirroring. */
4331 #define IXGBE_MRCTL_VLME 0x08 /* VLAN Mirroring. */
4332 #define IXGBE_INVALID_MIRROR_TYPE(mirror_type) \
4333 ((mirror_type) & ~(uint8_t)(ETH_MIRROR_VIRTUAL_POOL_UP | \
4334 ETH_MIRROR_UPLINK_PORT | ETH_MIRROR_DOWNLINK_PORT | ETH_MIRROR_VLAN))
4337 ixgbe_mirror_rule_set(struct rte_eth_dev *dev,
4338 struct rte_eth_mirror_conf *mirror_conf,
4339 uint8_t rule_id, uint8_t on)
4341 uint32_t mr_ctl,vlvf;
4342 uint32_t mp_lsb = 0;
4343 uint32_t mv_msb = 0;
4344 uint32_t mv_lsb = 0;
4345 uint32_t mp_msb = 0;
4348 uint64_t vlan_mask = 0;
4350 const uint8_t pool_mask_offset = 32;
4351 const uint8_t vlan_mask_offset = 32;
4352 const uint8_t dst_pool_offset = 8;
4353 const uint8_t rule_mr_offset = 4;
4354 const uint8_t mirror_rule_mask= 0x0F;
4356 struct ixgbe_mirror_info *mr_info =
4357 (IXGBE_DEV_PRIVATE_TO_PFDATA(dev->data->dev_private));
4358 struct ixgbe_hw *hw =
4359 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4360 uint8_t mirror_type = 0;
4362 if (ixgbe_vmdq_mode_check(hw) < 0)
4365 if (rule_id >= IXGBE_MAX_MIRROR_RULES)
4368 if (IXGBE_INVALID_MIRROR_TYPE(mirror_conf->rule_type)) {
4369 PMD_DRV_LOG(ERR, "unsupported mirror type 0x%x.",
4370 mirror_conf->rule_type);
4374 if (mirror_conf->rule_type & ETH_MIRROR_VLAN) {
4375 mirror_type |= IXGBE_MRCTL_VLME;
4376 /* Check if vlan id is valid and find conresponding VLAN ID index in VLVF */
4377 for (i = 0;i < IXGBE_VLVF_ENTRIES; i++) {
4378 if (mirror_conf->vlan.vlan_mask & (1ULL << i)) {
4379 /* search vlan id related pool vlan filter index */
4380 reg_index = ixgbe_find_vlvf_slot(hw,
4381 mirror_conf->vlan.vlan_id[i]);
4384 vlvf = IXGBE_READ_REG(hw, IXGBE_VLVF(reg_index));
4385 if ((vlvf & IXGBE_VLVF_VIEN) &&
4386 ((vlvf & IXGBE_VLVF_VLANID_MASK) ==
4387 mirror_conf->vlan.vlan_id[i]))
4388 vlan_mask |= (1ULL << reg_index);
4395 mv_lsb = vlan_mask & 0xFFFFFFFF;
4396 mv_msb = vlan_mask >> vlan_mask_offset;
4398 mr_info->mr_conf[rule_id].vlan.vlan_mask =
4399 mirror_conf->vlan.vlan_mask;
4400 for (i = 0; i < ETH_VMDQ_MAX_VLAN_FILTERS; i++) {
4401 if (mirror_conf->vlan.vlan_mask & (1ULL << i))
4402 mr_info->mr_conf[rule_id].vlan.vlan_id[i] =
4403 mirror_conf->vlan.vlan_id[i];
4408 mr_info->mr_conf[rule_id].vlan.vlan_mask = 0;
4409 for (i = 0; i < ETH_VMDQ_MAX_VLAN_FILTERS; i++)
4410 mr_info->mr_conf[rule_id].vlan.vlan_id[i] = 0;
4415 * if enable pool mirror, write related pool mask register,if disable
4416 * pool mirror, clear PFMRVM register
4418 if (mirror_conf->rule_type & ETH_MIRROR_VIRTUAL_POOL_UP) {
4419 mirror_type |= IXGBE_MRCTL_VPME;
4421 mp_lsb = mirror_conf->pool_mask & 0xFFFFFFFF;
4422 mp_msb = mirror_conf->pool_mask >> pool_mask_offset;
4423 mr_info->mr_conf[rule_id].pool_mask =
4424 mirror_conf->pool_mask;
4429 mr_info->mr_conf[rule_id].pool_mask = 0;
4432 if (mirror_conf->rule_type & ETH_MIRROR_UPLINK_PORT)
4433 mirror_type |= IXGBE_MRCTL_UPME;
4434 if (mirror_conf->rule_type & ETH_MIRROR_DOWNLINK_PORT)
4435 mirror_type |= IXGBE_MRCTL_DPME;
4437 /* read mirror control register and recalculate it */
4438 mr_ctl = IXGBE_READ_REG(hw, IXGBE_MRCTL(rule_id));
4441 mr_ctl |= mirror_type;
4442 mr_ctl &= mirror_rule_mask;
4443 mr_ctl |= mirror_conf->dst_pool << dst_pool_offset;
4445 mr_ctl &= ~(mirror_conf->rule_type & mirror_rule_mask);
4447 mr_info->mr_conf[rule_id].rule_type = mirror_conf->rule_type;
4448 mr_info->mr_conf[rule_id].dst_pool = mirror_conf->dst_pool;
4450 /* write mirrror control register */
4451 IXGBE_WRITE_REG(hw, IXGBE_MRCTL(rule_id), mr_ctl);
4453 /* write pool mirrror control register */
4454 if (mirror_conf->rule_type == ETH_MIRROR_VIRTUAL_POOL_UP) {
4455 IXGBE_WRITE_REG(hw, IXGBE_VMRVM(rule_id), mp_lsb);
4456 IXGBE_WRITE_REG(hw, IXGBE_VMRVM(rule_id + rule_mr_offset),
4459 /* write VLAN mirrror control register */
4460 if (mirror_conf->rule_type == ETH_MIRROR_VLAN) {
4461 IXGBE_WRITE_REG(hw, IXGBE_VMRVLAN(rule_id), mv_lsb);
4462 IXGBE_WRITE_REG(hw, IXGBE_VMRVLAN(rule_id + rule_mr_offset),
4470 ixgbe_mirror_rule_reset(struct rte_eth_dev *dev, uint8_t rule_id)
4473 uint32_t lsb_val = 0;
4474 uint32_t msb_val = 0;
4475 const uint8_t rule_mr_offset = 4;
4477 struct ixgbe_hw *hw =
4478 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4479 struct ixgbe_mirror_info *mr_info =
4480 (IXGBE_DEV_PRIVATE_TO_PFDATA(dev->data->dev_private));
4482 if (ixgbe_vmdq_mode_check(hw) < 0)
4485 memset(&mr_info->mr_conf[rule_id], 0,
4486 sizeof(struct rte_eth_mirror_conf));
4488 /* clear PFVMCTL register */
4489 IXGBE_WRITE_REG(hw, IXGBE_MRCTL(rule_id), mr_ctl);
4491 /* clear pool mask register */
4492 IXGBE_WRITE_REG(hw, IXGBE_VMRVM(rule_id), lsb_val);
4493 IXGBE_WRITE_REG(hw, IXGBE_VMRVM(rule_id + rule_mr_offset), msb_val);
4495 /* clear vlan mask register */
4496 IXGBE_WRITE_REG(hw, IXGBE_VMRVLAN(rule_id), lsb_val);
4497 IXGBE_WRITE_REG(hw, IXGBE_VMRVLAN(rule_id + rule_mr_offset), msb_val);
4503 ixgbevf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
4506 struct ixgbe_hw *hw =
4507 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4509 mask = IXGBE_READ_REG(hw, IXGBE_VTEIMS);
4510 mask |= (1 << IXGBE_MISC_VEC_ID);
4511 RTE_SET_USED(queue_id);
4512 IXGBE_WRITE_REG(hw, IXGBE_VTEIMS, mask);
4514 rte_intr_enable(&dev->pci_dev->intr_handle);
4520 ixgbevf_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id)
4523 struct ixgbe_hw *hw =
4524 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4526 mask = IXGBE_READ_REG(hw, IXGBE_VTEIMS);
4527 mask &= ~(1 << IXGBE_MISC_VEC_ID);
4528 RTE_SET_USED(queue_id);
4529 IXGBE_WRITE_REG(hw, IXGBE_VTEIMS, mask);
4535 ixgbe_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
4538 struct ixgbe_hw *hw =
4539 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4540 struct ixgbe_interrupt *intr =
4541 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
4543 if (queue_id < 16) {
4544 ixgbe_disable_intr(hw);
4545 intr->mask |= (1 << queue_id);
4546 ixgbe_enable_intr(dev);
4547 } else if (queue_id < 32) {
4548 mask = IXGBE_READ_REG(hw, IXGBE_EIMS_EX(0));
4549 mask &= (1 << queue_id);
4550 IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(0), mask);
4551 } else if (queue_id < 64) {
4552 mask = IXGBE_READ_REG(hw, IXGBE_EIMS_EX(1));
4553 mask &= (1 << (queue_id - 32));
4554 IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(1), mask);
4556 rte_intr_enable(&dev->pci_dev->intr_handle);
4562 ixgbe_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id)
4565 struct ixgbe_hw *hw =
4566 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4567 struct ixgbe_interrupt *intr =
4568 IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
4570 if (queue_id < 16) {
4571 ixgbe_disable_intr(hw);
4572 intr->mask &= ~(1 << queue_id);
4573 ixgbe_enable_intr(dev);
4574 } else if (queue_id < 32) {
4575 mask = IXGBE_READ_REG(hw, IXGBE_EIMS_EX(0));
4576 mask &= ~(1 << queue_id);
4577 IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(0), mask);
4578 } else if (queue_id < 64) {
4579 mask = IXGBE_READ_REG(hw, IXGBE_EIMS_EX(1));
4580 mask &= ~(1 << (queue_id - 32));
4581 IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(1), mask);
4588 ixgbevf_set_ivar_map(struct ixgbe_hw *hw, int8_t direction,
4589 uint8_t queue, uint8_t msix_vector)
4593 if (direction == -1) {
4595 msix_vector |= IXGBE_IVAR_ALLOC_VAL;
4596 tmp = IXGBE_READ_REG(hw, IXGBE_VTIVAR_MISC);
4599 IXGBE_WRITE_REG(hw, IXGBE_VTIVAR_MISC, tmp);
4601 /* rx or tx cause */
4602 msix_vector |= IXGBE_IVAR_ALLOC_VAL;
4603 idx = ((16 * (queue & 1)) + (8 * direction));
4604 tmp = IXGBE_READ_REG(hw, IXGBE_VTIVAR(queue >> 1));
4605 tmp &= ~(0xFF << idx);
4606 tmp |= (msix_vector << idx);
4607 IXGBE_WRITE_REG(hw, IXGBE_VTIVAR(queue >> 1), tmp);
4612 * set the IVAR registers, mapping interrupt causes to vectors
4614 * pointer to ixgbe_hw struct
4616 * 0 for Rx, 1 for Tx, -1 for other causes
4618 * queue to map the corresponding interrupt to
4620 * the vector to map to the corresponding queue
4623 ixgbe_set_ivar_map(struct ixgbe_hw *hw, int8_t direction,
4624 uint8_t queue, uint8_t msix_vector)
4628 msix_vector |= IXGBE_IVAR_ALLOC_VAL;
4629 if (hw->mac.type == ixgbe_mac_82598EB) {
4630 if (direction == -1)
4632 idx = (((direction * 64) + queue) >> 2) & 0x1F;
4633 tmp = IXGBE_READ_REG(hw, IXGBE_IVAR(idx));
4634 tmp &= ~(0xFF << (8 * (queue & 0x3)));
4635 tmp |= (msix_vector << (8 * (queue & 0x3)));
4636 IXGBE_WRITE_REG(hw, IXGBE_IVAR(idx), tmp);
4637 } else if ((hw->mac.type == ixgbe_mac_82599EB) ||
4638 (hw->mac.type == ixgbe_mac_X540)) {
4639 if (direction == -1) {
4641 idx = ((queue & 1) * 8);
4642 tmp = IXGBE_READ_REG(hw, IXGBE_IVAR_MISC);
4643 tmp &= ~(0xFF << idx);
4644 tmp |= (msix_vector << idx);
4645 IXGBE_WRITE_REG(hw, IXGBE_IVAR_MISC, tmp);
4647 /* rx or tx causes */
4648 idx = ((16 * (queue & 1)) + (8 * direction));
4649 tmp = IXGBE_READ_REG(hw, IXGBE_IVAR(queue >> 1));
4650 tmp &= ~(0xFF << idx);
4651 tmp |= (msix_vector << idx);
4652 IXGBE_WRITE_REG(hw, IXGBE_IVAR(queue >> 1), tmp);
4658 ixgbevf_configure_msix(struct rte_eth_dev *dev)
4660 struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;
4661 struct ixgbe_hw *hw =
4662 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4664 uint32_t vector_idx = IXGBE_MISC_VEC_ID;
4666 /* won't configure msix register if no mapping is done
4667 * between intr vector and event fd.
4669 if (!rte_intr_dp_is_en(intr_handle))
4672 /* Configure all RX queues of VF */
4673 for (q_idx = 0; q_idx < dev->data->nb_rx_queues; q_idx++) {
4674 /* Force all queue use vector 0,
4675 * as IXGBE_VF_MAXMSIVECOTR = 1
4677 ixgbevf_set_ivar_map(hw, 0, q_idx, vector_idx);
4678 intr_handle->intr_vec[q_idx] = vector_idx;
4681 /* Configure VF other cause ivar */
4682 ixgbevf_set_ivar_map(hw, -1, 1, vector_idx);
4686 * Sets up the hardware to properly generate MSI-X interrupts
4688 * board private structure
4691 ixgbe_configure_msix(struct rte_eth_dev *dev)
4693 struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;
4694 struct ixgbe_hw *hw =
4695 IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4696 uint32_t queue_id, base = IXGBE_MISC_VEC_ID;
4697 uint32_t vec = IXGBE_MISC_VEC_ID;
4701 /* won't configure msix register if no mapping is done
4702 * between intr vector and event fd
4704 if (!rte_intr_dp_is_en(intr_handle))
4707 if (rte_intr_allow_others(intr_handle))
4708 vec = base = IXGBE_RX_VEC_START;
4710 /* setup GPIE for MSI-x mode */
4711 gpie = IXGBE_READ_REG(hw, IXGBE_GPIE);
4712 gpie |= IXGBE_GPIE_MSIX_MODE | IXGBE_GPIE_PBA_SUPPORT |
4713 IXGBE_GPIE_OCD | IXGBE_GPIE_EIAME;
4714 /* auto clearing and auto setting corresponding bits in EIMS
4715 * when MSI-X interrupt is triggered
4717 if (hw->mac.type == ixgbe_mac_82598EB) {
4718 IXGBE_WRITE_REG(hw, IXGBE_EIAM, IXGBE_EICS_RTX_QUEUE);
4720 IXGBE_WRITE_REG(hw, IXGBE_EIAM_EX(0), 0xFFFFFFFF);
4721 IXGBE_WRITE_REG(hw, IXGBE_EIAM_EX(1), 0xFFFFFFFF);
4723 IXGBE_WRITE_REG(hw, IXGBE_GPIE, gpie);
4725 /* Populate the IVAR table and set the ITR values to the
4726 * corresponding register.
4728 for (queue_id = 0; queue_id < dev->data->nb_rx_queues;
4730 /* by default, 1:1 mapping */
4731 ixgbe_set_ivar_map(hw, 0, queue_id, vec);
4732 intr_handle->intr_vec[queue_id] = vec;
4733 if (vec < base + intr_handle->nb_efd - 1)
4737 switch (hw->mac.type) {
4738 case ixgbe_mac_82598EB:
4739 ixgbe_set_ivar_map(hw, -1, IXGBE_IVAR_OTHER_CAUSES_INDEX,
4742 case ixgbe_mac_82599EB:
4743 case ixgbe_mac_X540:
4744 ixgbe_set_ivar_map(hw, -1, 1, IXGBE_MISC_VEC_ID);
4749 IXGBE_WRITE_REG(hw, IXGBE_EITR(IXGBE_MISC_VEC_ID),
4750 IXGBE_MIN_INTER_INTERRUPT_INTERVAL_DEFAULT & 0xFFF);
4752 /* set up to autoclear timer, and the vectors */
4753 mask = IXGBE_EIMS_ENABLE_MASK;
4754 mask &= ~(IXGBE_EIMS_OTHER |
4755 IXGBE_EIMS_MAILBOX |
4758 IXGBE_WRITE_REG(hw, IXGBE_EIAC, mask);
4761 static int ixgbe_set_queue_rate_limit(struct rte_eth_dev *dev,
4762 uint16_t queue_idx, uint16_t tx_rate)
4764 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4765 uint32_t rf_dec, rf_int;
4767 uint16_t link_speed = dev->data->dev_link.link_speed;
4769 if (queue_idx >= hw->mac.max_tx_queues)
4773 /* Calculate the rate factor values to set */
4774 rf_int = (uint32_t)link_speed / (uint32_t)tx_rate;
4775 rf_dec = (uint32_t)link_speed % (uint32_t)tx_rate;
4776 rf_dec = (rf_dec << IXGBE_RTTBCNRC_RF_INT_SHIFT) / tx_rate;
4778 bcnrc_val = IXGBE_RTTBCNRC_RS_ENA;
4779 bcnrc_val |= ((rf_int << IXGBE_RTTBCNRC_RF_INT_SHIFT) &
4780 IXGBE_RTTBCNRC_RF_INT_MASK_M);
4781 bcnrc_val |= (rf_dec & IXGBE_RTTBCNRC_RF_DEC_MASK);
4787 * Set global transmit compensation time to the MMW_SIZE in RTTBCNRM
4788 * register. MMW_SIZE=0x014 if 9728-byte jumbo is supported, otherwise
4791 if ((dev->data->dev_conf.rxmode.jumbo_frame == 1) &&
4792 (dev->data->dev_conf.rxmode.max_rx_pkt_len >=
4793 IXGBE_MAX_JUMBO_FRAME_SIZE))
4794 IXGBE_WRITE_REG(hw, IXGBE_RTTBCNRM,
4795 IXGBE_MMW_SIZE_JUMBO_FRAME);
4797 IXGBE_WRITE_REG(hw, IXGBE_RTTBCNRM,
4798 IXGBE_MMW_SIZE_DEFAULT);
4800 /* Set RTTBCNRC of queue X */
4801 IXGBE_WRITE_REG(hw, IXGBE_RTTDQSEL, queue_idx);
4802 IXGBE_WRITE_REG(hw, IXGBE_RTTBCNRC, bcnrc_val);
4803 IXGBE_WRITE_FLUSH(hw);
4808 static int ixgbe_set_vf_rate_limit(struct rte_eth_dev *dev, uint16_t vf,
4809 uint16_t tx_rate, uint64_t q_msk)
4811 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4812 struct ixgbe_vf_info *vfinfo =
4813 *(IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private));
4814 uint8_t nb_q_per_pool = RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool;
4815 uint32_t queue_stride =
4816 IXGBE_MAX_RX_QUEUE_NUM / RTE_ETH_DEV_SRIOV(dev).active;
4817 uint32_t queue_idx = vf * queue_stride, idx = 0, vf_idx;
4818 uint32_t queue_end = queue_idx + nb_q_per_pool - 1;
4819 uint16_t total_rate = 0;
4821 if (queue_end >= hw->mac.max_tx_queues)
4824 if (vfinfo != NULL) {
4825 for (vf_idx = 0; vf_idx < dev->pci_dev->max_vfs; vf_idx++) {
4828 for (idx = 0; idx < RTE_DIM(vfinfo[vf_idx].tx_rate);
4830 total_rate += vfinfo[vf_idx].tx_rate[idx];
4835 /* Store tx_rate for this vf. */
4836 for (idx = 0; idx < nb_q_per_pool; idx++) {
4837 if (((uint64_t)0x1 << idx) & q_msk) {
4838 if (vfinfo[vf].tx_rate[idx] != tx_rate)
4839 vfinfo[vf].tx_rate[idx] = tx_rate;
4840 total_rate += tx_rate;
4844 if (total_rate > dev->data->dev_link.link_speed) {
4846 * Reset stored TX rate of the VF if it causes exceed
4849 memset(vfinfo[vf].tx_rate, 0, sizeof(vfinfo[vf].tx_rate));
4853 /* Set RTTBCNRC of each queue/pool for vf X */
4854 for (; queue_idx <= queue_end; queue_idx++) {
4856 ixgbe_set_queue_rate_limit(dev, queue_idx, tx_rate);
4864 ixgbevf_add_mac_addr(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
4865 __attribute__((unused)) uint32_t index,
4866 __attribute__((unused)) uint32_t pool)
4868 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4872 * On a 82599 VF, adding again the same MAC addr is not an idempotent
4873 * operation. Trap this case to avoid exhausting the [very limited]
4874 * set of PF resources used to store VF MAC addresses.
4876 if (memcmp(hw->mac.perm_addr, mac_addr, sizeof(struct ether_addr)) == 0)
4878 diag = ixgbevf_set_uc_addr_vf(hw, 2, mac_addr->addr_bytes);
4881 PMD_DRV_LOG(ERR, "Unable to add MAC address - diag=%d", diag);
4885 ixgbevf_remove_mac_addr(struct rte_eth_dev *dev, uint32_t index)
4887 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4888 struct ether_addr *perm_addr = (struct ether_addr *) hw->mac.perm_addr;
4889 struct ether_addr *mac_addr;
4894 * The IXGBE_VF_SET_MACVLAN command of the ixgbe-pf driver does
4895 * not support the deletion of a given MAC address.
4896 * Instead, it imposes to delete all MAC addresses, then to add again
4897 * all MAC addresses with the exception of the one to be deleted.
4899 (void) ixgbevf_set_uc_addr_vf(hw, 0, NULL);
4902 * Add again all MAC addresses, with the exception of the deleted one
4903 * and of the permanent MAC address.
4905 for (i = 0, mac_addr = dev->data->mac_addrs;
4906 i < hw->mac.num_rar_entries; i++, mac_addr++) {
4907 /* Skip the deleted MAC address */
4910 /* Skip NULL MAC addresses */
4911 if (is_zero_ether_addr(mac_addr))
4913 /* Skip the permanent MAC address */
4914 if (memcmp(perm_addr, mac_addr, sizeof(struct ether_addr)) == 0)
4916 diag = ixgbevf_set_uc_addr_vf(hw, 2, mac_addr->addr_bytes);
4919 "Adding again MAC address "
4920 "%02x:%02x:%02x:%02x:%02x:%02x failed "
4922 mac_addr->addr_bytes[0],
4923 mac_addr->addr_bytes[1],
4924 mac_addr->addr_bytes[2],
4925 mac_addr->addr_bytes[3],
4926 mac_addr->addr_bytes[4],
4927 mac_addr->addr_bytes[5],
4933 ixgbevf_set_default_mac_addr(struct rte_eth_dev *dev, struct ether_addr *addr)
4935 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4937 hw->mac.ops.set_rar(hw, 0, (void *)addr, 0, 0);
4940 #define MAC_TYPE_FILTER_SUP(type) do {\
4941 if ((type) != ixgbe_mac_82599EB && (type) != ixgbe_mac_X540 &&\
4942 (type) != ixgbe_mac_X550)\
4947 ixgbe_syn_filter_set(struct rte_eth_dev *dev,
4948 struct rte_eth_syn_filter *filter,
4951 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4954 if (filter->queue >= IXGBE_MAX_RX_QUEUE_NUM)
4957 synqf = IXGBE_READ_REG(hw, IXGBE_SYNQF);
4960 if (synqf & IXGBE_SYN_FILTER_ENABLE)
4962 synqf = (uint32_t)(((filter->queue << IXGBE_SYN_FILTER_QUEUE_SHIFT) &
4963 IXGBE_SYN_FILTER_QUEUE) | IXGBE_SYN_FILTER_ENABLE);
4965 if (filter->hig_pri)
4966 synqf |= IXGBE_SYN_FILTER_SYNQFP;
4968 synqf &= ~IXGBE_SYN_FILTER_SYNQFP;
4970 if (!(synqf & IXGBE_SYN_FILTER_ENABLE))
4972 synqf &= ~(IXGBE_SYN_FILTER_QUEUE | IXGBE_SYN_FILTER_ENABLE);
4974 IXGBE_WRITE_REG(hw, IXGBE_SYNQF, synqf);
4975 IXGBE_WRITE_FLUSH(hw);
4980 ixgbe_syn_filter_get(struct rte_eth_dev *dev,
4981 struct rte_eth_syn_filter *filter)
4983 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4984 uint32_t synqf = IXGBE_READ_REG(hw, IXGBE_SYNQF);
4986 if (synqf & IXGBE_SYN_FILTER_ENABLE) {
4987 filter->hig_pri = (synqf & IXGBE_SYN_FILTER_SYNQFP) ? 1 : 0;
4988 filter->queue = (uint16_t)((synqf & IXGBE_SYN_FILTER_QUEUE) >> 1);
4995 ixgbe_syn_filter_handle(struct rte_eth_dev *dev,
4996 enum rte_filter_op filter_op,
4999 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5002 MAC_TYPE_FILTER_SUP(hw->mac.type);
5004 if (filter_op == RTE_ETH_FILTER_NOP)
5008 PMD_DRV_LOG(ERR, "arg shouldn't be NULL for operation %u",
5013 switch (filter_op) {
5014 case RTE_ETH_FILTER_ADD:
5015 ret = ixgbe_syn_filter_set(dev,
5016 (struct rte_eth_syn_filter *)arg,
5019 case RTE_ETH_FILTER_DELETE:
5020 ret = ixgbe_syn_filter_set(dev,
5021 (struct rte_eth_syn_filter *)arg,
5024 case RTE_ETH_FILTER_GET:
5025 ret = ixgbe_syn_filter_get(dev,
5026 (struct rte_eth_syn_filter *)arg);
5029 PMD_DRV_LOG(ERR, "unsupported operation %u\n", filter_op);
5038 static inline enum ixgbe_5tuple_protocol
5039 convert_protocol_type(uint8_t protocol_value)
5041 if (protocol_value == IPPROTO_TCP)
5042 return IXGBE_FILTER_PROTOCOL_TCP;
5043 else if (protocol_value == IPPROTO_UDP)
5044 return IXGBE_FILTER_PROTOCOL_UDP;
5045 else if (protocol_value == IPPROTO_SCTP)
5046 return IXGBE_FILTER_PROTOCOL_SCTP;
5048 return IXGBE_FILTER_PROTOCOL_NONE;
5052 * add a 5tuple filter
5055 * dev: Pointer to struct rte_eth_dev.
5056 * index: the index the filter allocates.
5057 * filter: ponter to the filter that will be added.
5058 * rx_queue: the queue id the filter assigned to.
5061 * - On success, zero.
5062 * - On failure, a negative value.
5065 ixgbe_add_5tuple_filter(struct rte_eth_dev *dev,
5066 struct ixgbe_5tuple_filter *filter)
5068 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5069 struct ixgbe_filter_info *filter_info =
5070 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
5072 uint32_t ftqf, sdpqf;
5073 uint32_t l34timir = 0;
5074 uint8_t mask = 0xff;
5077 * look for an unused 5tuple filter index,
5078 * and insert the filter to list.
5080 for (i = 0; i < IXGBE_MAX_FTQF_FILTERS; i++) {
5081 idx = i / (sizeof(uint32_t) * NBBY);
5082 shift = i % (sizeof(uint32_t) * NBBY);
5083 if (!(filter_info->fivetuple_mask[idx] & (1 << shift))) {
5084 filter_info->fivetuple_mask[idx] |= 1 << shift;
5086 TAILQ_INSERT_TAIL(&filter_info->fivetuple_list,
5092 if (i >= IXGBE_MAX_FTQF_FILTERS) {
5093 PMD_DRV_LOG(ERR, "5tuple filters are full.");
5097 sdpqf = (uint32_t)(filter->filter_info.dst_port <<
5098 IXGBE_SDPQF_DSTPORT_SHIFT);
5099 sdpqf = sdpqf | (filter->filter_info.src_port & IXGBE_SDPQF_SRCPORT);
5101 ftqf = (uint32_t)(filter->filter_info.proto &
5102 IXGBE_FTQF_PROTOCOL_MASK);
5103 ftqf |= (uint32_t)((filter->filter_info.priority &
5104 IXGBE_FTQF_PRIORITY_MASK) << IXGBE_FTQF_PRIORITY_SHIFT);
5105 if (filter->filter_info.src_ip_mask == 0) /* 0 means compare. */
5106 mask &= IXGBE_FTQF_SOURCE_ADDR_MASK;
5107 if (filter->filter_info.dst_ip_mask == 0)
5108 mask &= IXGBE_FTQF_DEST_ADDR_MASK;
5109 if (filter->filter_info.src_port_mask == 0)
5110 mask &= IXGBE_FTQF_SOURCE_PORT_MASK;
5111 if (filter->filter_info.dst_port_mask == 0)
5112 mask &= IXGBE_FTQF_DEST_PORT_MASK;
5113 if (filter->filter_info.proto_mask == 0)
5114 mask &= IXGBE_FTQF_PROTOCOL_COMP_MASK;
5115 ftqf |= mask << IXGBE_FTQF_5TUPLE_MASK_SHIFT;
5116 ftqf |= IXGBE_FTQF_POOL_MASK_EN;
5117 ftqf |= IXGBE_FTQF_QUEUE_ENABLE;
5119 IXGBE_WRITE_REG(hw, IXGBE_DAQF(i), filter->filter_info.dst_ip);
5120 IXGBE_WRITE_REG(hw, IXGBE_SAQF(i), filter->filter_info.src_ip);
5121 IXGBE_WRITE_REG(hw, IXGBE_SDPQF(i), sdpqf);
5122 IXGBE_WRITE_REG(hw, IXGBE_FTQF(i), ftqf);
5124 l34timir |= IXGBE_L34T_IMIR_RESERVE;
5125 l34timir |= (uint32_t)(filter->queue <<
5126 IXGBE_L34T_IMIR_QUEUE_SHIFT);
5127 IXGBE_WRITE_REG(hw, IXGBE_L34T_IMIR(i), l34timir);
5132 * remove a 5tuple filter
5135 * dev: Pointer to struct rte_eth_dev.
5136 * filter: the pointer of the filter will be removed.
5139 ixgbe_remove_5tuple_filter(struct rte_eth_dev *dev,
5140 struct ixgbe_5tuple_filter *filter)
5142 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5143 struct ixgbe_filter_info *filter_info =
5144 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
5145 uint16_t index = filter->index;
5147 filter_info->fivetuple_mask[index / (sizeof(uint32_t) * NBBY)] &=
5148 ~(1 << (index % (sizeof(uint32_t) * NBBY)));
5149 TAILQ_REMOVE(&filter_info->fivetuple_list, filter, entries);
5152 IXGBE_WRITE_REG(hw, IXGBE_DAQF(index), 0);
5153 IXGBE_WRITE_REG(hw, IXGBE_SAQF(index), 0);
5154 IXGBE_WRITE_REG(hw, IXGBE_SDPQF(index), 0);
5155 IXGBE_WRITE_REG(hw, IXGBE_FTQF(index), 0);
5156 IXGBE_WRITE_REG(hw, IXGBE_L34T_IMIR(index), 0);
5160 ixgbevf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
5162 struct ixgbe_hw *hw;
5163 uint32_t max_frame = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
5165 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5167 if ((mtu < ETHER_MIN_MTU) || (max_frame > ETHER_MAX_JUMBO_FRAME_LEN))
5170 /* refuse mtu that requires the support of scattered packets when this
5171 * feature has not been enabled before. */
5172 if (!dev->data->scattered_rx &&
5173 (max_frame + 2 * IXGBE_VLAN_TAG_SIZE >
5174 dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM))
5178 * When supported by the underlying PF driver, use the IXGBE_VF_SET_MTU
5179 * request of the version 2.0 of the mailbox API.
5180 * For now, use the IXGBE_VF_SET_LPE request of the version 1.0
5181 * of the mailbox API.
5182 * This call to IXGBE_SET_LPE action won't work with ixgbe pf drivers
5183 * prior to 3.11.33 which contains the following change:
5184 * "ixgbe: Enable jumbo frames support w/ SR-IOV"
5186 ixgbevf_rlpml_set_vf(hw, max_frame);
5188 /* update max frame size */
5189 dev->data->dev_conf.rxmode.max_rx_pkt_len = max_frame;
5193 #define MAC_TYPE_FILTER_SUP_EXT(type) do {\
5194 if ((type) != ixgbe_mac_82599EB && (type) != ixgbe_mac_X540)\
5198 static inline struct ixgbe_5tuple_filter *
5199 ixgbe_5tuple_filter_lookup(struct ixgbe_5tuple_filter_list *filter_list,
5200 struct ixgbe_5tuple_filter_info *key)
5202 struct ixgbe_5tuple_filter *it;
5204 TAILQ_FOREACH(it, filter_list, entries) {
5205 if (memcmp(key, &it->filter_info,
5206 sizeof(struct ixgbe_5tuple_filter_info)) == 0) {
5213 /* translate elements in struct rte_eth_ntuple_filter to struct ixgbe_5tuple_filter_info*/
5215 ntuple_filter_to_5tuple(struct rte_eth_ntuple_filter *filter,
5216 struct ixgbe_5tuple_filter_info *filter_info)
5218 if (filter->queue >= IXGBE_MAX_RX_QUEUE_NUM ||
5219 filter->priority > IXGBE_5TUPLE_MAX_PRI ||
5220 filter->priority < IXGBE_5TUPLE_MIN_PRI)
5223 switch (filter->dst_ip_mask) {
5225 filter_info->dst_ip_mask = 0;
5226 filter_info->dst_ip = filter->dst_ip;
5229 filter_info->dst_ip_mask = 1;
5232 PMD_DRV_LOG(ERR, "invalid dst_ip mask.");
5236 switch (filter->src_ip_mask) {
5238 filter_info->src_ip_mask = 0;
5239 filter_info->src_ip = filter->src_ip;
5242 filter_info->src_ip_mask = 1;
5245 PMD_DRV_LOG(ERR, "invalid src_ip mask.");
5249 switch (filter->dst_port_mask) {
5251 filter_info->dst_port_mask = 0;
5252 filter_info->dst_port = filter->dst_port;
5255 filter_info->dst_port_mask = 1;
5258 PMD_DRV_LOG(ERR, "invalid dst_port mask.");
5262 switch (filter->src_port_mask) {
5264 filter_info->src_port_mask = 0;
5265 filter_info->src_port = filter->src_port;
5268 filter_info->src_port_mask = 1;
5271 PMD_DRV_LOG(ERR, "invalid src_port mask.");
5275 switch (filter->proto_mask) {
5277 filter_info->proto_mask = 0;
5278 filter_info->proto =
5279 convert_protocol_type(filter->proto);
5282 filter_info->proto_mask = 1;
5285 PMD_DRV_LOG(ERR, "invalid protocol mask.");
5289 filter_info->priority = (uint8_t)filter->priority;
5294 * add or delete a ntuple filter
5297 * dev: Pointer to struct rte_eth_dev.
5298 * ntuple_filter: Pointer to struct rte_eth_ntuple_filter
5299 * add: if true, add filter, if false, remove filter
5302 * - On success, zero.
5303 * - On failure, a negative value.
5306 ixgbe_add_del_ntuple_filter(struct rte_eth_dev *dev,
5307 struct rte_eth_ntuple_filter *ntuple_filter,
5310 struct ixgbe_filter_info *filter_info =
5311 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
5312 struct ixgbe_5tuple_filter_info filter_5tuple;
5313 struct ixgbe_5tuple_filter *filter;
5316 if (ntuple_filter->flags != RTE_5TUPLE_FLAGS) {
5317 PMD_DRV_LOG(ERR, "only 5tuple is supported.");
5321 memset(&filter_5tuple, 0, sizeof(struct ixgbe_5tuple_filter_info));
5322 ret = ntuple_filter_to_5tuple(ntuple_filter, &filter_5tuple);
5326 filter = ixgbe_5tuple_filter_lookup(&filter_info->fivetuple_list,
5328 if (filter != NULL && add) {
5329 PMD_DRV_LOG(ERR, "filter exists.");
5332 if (filter == NULL && !add) {
5333 PMD_DRV_LOG(ERR, "filter doesn't exist.");
5338 filter = rte_zmalloc("ixgbe_5tuple_filter",
5339 sizeof(struct ixgbe_5tuple_filter), 0);
5342 (void)rte_memcpy(&filter->filter_info,
5344 sizeof(struct ixgbe_5tuple_filter_info));
5345 filter->queue = ntuple_filter->queue;
5346 ret = ixgbe_add_5tuple_filter(dev, filter);
5352 ixgbe_remove_5tuple_filter(dev, filter);
5358 * get a ntuple filter
5361 * dev: Pointer to struct rte_eth_dev.
5362 * ntuple_filter: Pointer to struct rte_eth_ntuple_filter
5365 * - On success, zero.
5366 * - On failure, a negative value.
5369 ixgbe_get_ntuple_filter(struct rte_eth_dev *dev,
5370 struct rte_eth_ntuple_filter *ntuple_filter)
5372 struct ixgbe_filter_info *filter_info =
5373 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
5374 struct ixgbe_5tuple_filter_info filter_5tuple;
5375 struct ixgbe_5tuple_filter *filter;
5378 if (ntuple_filter->flags != RTE_5TUPLE_FLAGS) {
5379 PMD_DRV_LOG(ERR, "only 5tuple is supported.");
5383 memset(&filter_5tuple, 0, sizeof(struct ixgbe_5tuple_filter_info));
5384 ret = ntuple_filter_to_5tuple(ntuple_filter, &filter_5tuple);
5388 filter = ixgbe_5tuple_filter_lookup(&filter_info->fivetuple_list,
5390 if (filter == NULL) {
5391 PMD_DRV_LOG(ERR, "filter doesn't exist.");
5394 ntuple_filter->queue = filter->queue;
5399 * ixgbe_ntuple_filter_handle - Handle operations for ntuple filter.
5400 * @dev: pointer to rte_eth_dev structure
5401 * @filter_op:operation will be taken.
5402 * @arg: a pointer to specific structure corresponding to the filter_op
5405 * - On success, zero.
5406 * - On failure, a negative value.
5409 ixgbe_ntuple_filter_handle(struct rte_eth_dev *dev,
5410 enum rte_filter_op filter_op,
5413 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5416 MAC_TYPE_FILTER_SUP_EXT(hw->mac.type);
5418 if (filter_op == RTE_ETH_FILTER_NOP)
5422 PMD_DRV_LOG(ERR, "arg shouldn't be NULL for operation %u.",
5427 switch (filter_op) {
5428 case RTE_ETH_FILTER_ADD:
5429 ret = ixgbe_add_del_ntuple_filter(dev,
5430 (struct rte_eth_ntuple_filter *)arg,
5433 case RTE_ETH_FILTER_DELETE:
5434 ret = ixgbe_add_del_ntuple_filter(dev,
5435 (struct rte_eth_ntuple_filter *)arg,
5438 case RTE_ETH_FILTER_GET:
5439 ret = ixgbe_get_ntuple_filter(dev,
5440 (struct rte_eth_ntuple_filter *)arg);
5443 PMD_DRV_LOG(ERR, "unsupported operation %u.", filter_op);
5451 ixgbe_ethertype_filter_lookup(struct ixgbe_filter_info *filter_info,
5456 for (i = 0; i < IXGBE_MAX_ETQF_FILTERS; i++) {
5457 if (filter_info->ethertype_filters[i] == ethertype &&
5458 (filter_info->ethertype_mask & (1 << i)))
5465 ixgbe_ethertype_filter_insert(struct ixgbe_filter_info *filter_info,
5470 for (i = 0; i < IXGBE_MAX_ETQF_FILTERS; i++) {
5471 if (!(filter_info->ethertype_mask & (1 << i))) {
5472 filter_info->ethertype_mask |= 1 << i;
5473 filter_info->ethertype_filters[i] = ethertype;
5481 ixgbe_ethertype_filter_remove(struct ixgbe_filter_info *filter_info,
5484 if (idx >= IXGBE_MAX_ETQF_FILTERS)
5486 filter_info->ethertype_mask &= ~(1 << idx);
5487 filter_info->ethertype_filters[idx] = 0;
5492 ixgbe_add_del_ethertype_filter(struct rte_eth_dev *dev,
5493 struct rte_eth_ethertype_filter *filter,
5496 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5497 struct ixgbe_filter_info *filter_info =
5498 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
5503 if (filter->queue >= IXGBE_MAX_RX_QUEUE_NUM)
5506 if (filter->ether_type == ETHER_TYPE_IPv4 ||
5507 filter->ether_type == ETHER_TYPE_IPv6) {
5508 PMD_DRV_LOG(ERR, "unsupported ether_type(0x%04x) in"
5509 " ethertype filter.", filter->ether_type);
5513 if (filter->flags & RTE_ETHTYPE_FLAGS_MAC) {
5514 PMD_DRV_LOG(ERR, "mac compare is unsupported.");
5517 if (filter->flags & RTE_ETHTYPE_FLAGS_DROP) {
5518 PMD_DRV_LOG(ERR, "drop option is unsupported.");
5522 ret = ixgbe_ethertype_filter_lookup(filter_info, filter->ether_type);
5523 if (ret >= 0 && add) {
5524 PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter exists.",
5525 filter->ether_type);
5528 if (ret < 0 && !add) {
5529 PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter doesn't exist.",
5530 filter->ether_type);
5535 ret = ixgbe_ethertype_filter_insert(filter_info,
5536 filter->ether_type);
5538 PMD_DRV_LOG(ERR, "ethertype filters are full.");
5541 etqf = IXGBE_ETQF_FILTER_EN;
5542 etqf |= (uint32_t)filter->ether_type;
5543 etqs |= (uint32_t)((filter->queue <<
5544 IXGBE_ETQS_RX_QUEUE_SHIFT) &
5545 IXGBE_ETQS_RX_QUEUE);
5546 etqs |= IXGBE_ETQS_QUEUE_EN;
5548 ret = ixgbe_ethertype_filter_remove(filter_info, (uint8_t)ret);
5552 IXGBE_WRITE_REG(hw, IXGBE_ETQF(ret), etqf);
5553 IXGBE_WRITE_REG(hw, IXGBE_ETQS(ret), etqs);
5554 IXGBE_WRITE_FLUSH(hw);
5560 ixgbe_get_ethertype_filter(struct rte_eth_dev *dev,
5561 struct rte_eth_ethertype_filter *filter)
5563 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5564 struct ixgbe_filter_info *filter_info =
5565 IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
5566 uint32_t etqf, etqs;
5569 ret = ixgbe_ethertype_filter_lookup(filter_info, filter->ether_type);
5571 PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter doesn't exist.",
5572 filter->ether_type);
5576 etqf = IXGBE_READ_REG(hw, IXGBE_ETQF(ret));
5577 if (etqf & IXGBE_ETQF_FILTER_EN) {
5578 etqs = IXGBE_READ_REG(hw, IXGBE_ETQS(ret));
5579 filter->ether_type = etqf & IXGBE_ETQF_ETHERTYPE;
5581 filter->queue = (etqs & IXGBE_ETQS_RX_QUEUE) >>
5582 IXGBE_ETQS_RX_QUEUE_SHIFT;
5589 * ixgbe_ethertype_filter_handle - Handle operations for ethertype filter.
5590 * @dev: pointer to rte_eth_dev structure
5591 * @filter_op:operation will be taken.
5592 * @arg: a pointer to specific structure corresponding to the filter_op
5595 ixgbe_ethertype_filter_handle(struct rte_eth_dev *dev,
5596 enum rte_filter_op filter_op,
5599 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5602 MAC_TYPE_FILTER_SUP(hw->mac.type);
5604 if (filter_op == RTE_ETH_FILTER_NOP)
5608 PMD_DRV_LOG(ERR, "arg shouldn't be NULL for operation %u.",
5613 switch (filter_op) {
5614 case RTE_ETH_FILTER_ADD:
5615 ret = ixgbe_add_del_ethertype_filter(dev,
5616 (struct rte_eth_ethertype_filter *)arg,
5619 case RTE_ETH_FILTER_DELETE:
5620 ret = ixgbe_add_del_ethertype_filter(dev,
5621 (struct rte_eth_ethertype_filter *)arg,
5624 case RTE_ETH_FILTER_GET:
5625 ret = ixgbe_get_ethertype_filter(dev,
5626 (struct rte_eth_ethertype_filter *)arg);
5629 PMD_DRV_LOG(ERR, "unsupported operation %u.", filter_op);
5637 ixgbe_dev_filter_ctrl(struct rte_eth_dev *dev,
5638 enum rte_filter_type filter_type,
5639 enum rte_filter_op filter_op,
5644 switch (filter_type) {
5645 case RTE_ETH_FILTER_NTUPLE:
5646 ret = ixgbe_ntuple_filter_handle(dev, filter_op, arg);
5648 case RTE_ETH_FILTER_ETHERTYPE:
5649 ret = ixgbe_ethertype_filter_handle(dev, filter_op, arg);
5651 case RTE_ETH_FILTER_SYN:
5652 ret = ixgbe_syn_filter_handle(dev, filter_op, arg);
5654 case RTE_ETH_FILTER_FDIR:
5655 ret = ixgbe_fdir_ctrl_func(dev, filter_op, arg);
5657 case RTE_ETH_FILTER_L2_TUNNEL:
5658 ret = ixgbe_dev_l2_tunnel_filter_handle(dev, filter_op, arg);
5661 PMD_DRV_LOG(WARNING, "Filter type (%d) not supported",
5670 ixgbe_dev_addr_list_itr(__attribute__((unused)) struct ixgbe_hw *hw,
5671 u8 **mc_addr_ptr, u32 *vmdq)
5676 mc_addr = *mc_addr_ptr;
5677 *mc_addr_ptr = (mc_addr + sizeof(struct ether_addr));
5682 ixgbe_dev_set_mc_addr_list(struct rte_eth_dev *dev,
5683 struct ether_addr *mc_addr_set,
5684 uint32_t nb_mc_addr)
5686 struct ixgbe_hw *hw;
5689 hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5690 mc_addr_list = (u8 *)mc_addr_set;
5691 return ixgbe_update_mc_addr_list(hw, mc_addr_list, nb_mc_addr,
5692 ixgbe_dev_addr_list_itr, TRUE);
5696 ixgbe_read_systime_cyclecounter(struct rte_eth_dev *dev)
5698 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5699 uint64_t systime_cycles;
5701 switch (hw->mac.type) {
5702 case ixgbe_mac_X550:
5703 /* SYSTIMEL stores ns and SYSTIMEH stores seconds. */
5704 systime_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_SYSTIML);
5705 systime_cycles += (uint64_t)IXGBE_READ_REG(hw, IXGBE_SYSTIMH)
5709 systime_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_SYSTIML);
5710 systime_cycles |= (uint64_t)IXGBE_READ_REG(hw, IXGBE_SYSTIMH)
5714 return systime_cycles;
5718 ixgbe_read_rx_tstamp_cyclecounter(struct rte_eth_dev *dev)
5720 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5721 uint64_t rx_tstamp_cycles;
5723 switch (hw->mac.type) {
5724 case ixgbe_mac_X550:
5725 /* RXSTMPL stores ns and RXSTMPH stores seconds. */
5726 rx_tstamp_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_RXSTMPL);
5727 rx_tstamp_cycles += (uint64_t)IXGBE_READ_REG(hw, IXGBE_RXSTMPH)
5731 /* RXSTMPL stores ns and RXSTMPH stores seconds. */
5732 rx_tstamp_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_RXSTMPL);
5733 rx_tstamp_cycles |= (uint64_t)IXGBE_READ_REG(hw, IXGBE_RXSTMPH)
5737 return rx_tstamp_cycles;
5741 ixgbe_read_tx_tstamp_cyclecounter(struct rte_eth_dev *dev)
5743 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5744 uint64_t tx_tstamp_cycles;
5746 switch (hw->mac.type) {
5747 case ixgbe_mac_X550:
5748 /* TXSTMPL stores ns and TXSTMPH stores seconds. */
5749 tx_tstamp_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_TXSTMPL);
5750 tx_tstamp_cycles += (uint64_t)IXGBE_READ_REG(hw, IXGBE_TXSTMPH)
5754 /* TXSTMPL stores ns and TXSTMPH stores seconds. */
5755 tx_tstamp_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_TXSTMPL);
5756 tx_tstamp_cycles |= (uint64_t)IXGBE_READ_REG(hw, IXGBE_TXSTMPH)
5760 return tx_tstamp_cycles;
5764 ixgbe_start_timecounters(struct rte_eth_dev *dev)
5766 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5767 struct ixgbe_adapter *adapter =
5768 (struct ixgbe_adapter *)dev->data->dev_private;
5769 struct rte_eth_link link;
5770 uint32_t incval = 0;
5773 /* Get current link speed. */
5774 memset(&link, 0, sizeof(link));
5775 ixgbe_dev_link_update(dev, 1);
5776 rte_ixgbe_dev_atomic_read_link_status(dev, &link);
5778 switch (link.link_speed) {
5779 case ETH_LINK_SPEED_100:
5780 incval = IXGBE_INCVAL_100;
5781 shift = IXGBE_INCVAL_SHIFT_100;
5783 case ETH_LINK_SPEED_1000:
5784 incval = IXGBE_INCVAL_1GB;
5785 shift = IXGBE_INCVAL_SHIFT_1GB;
5787 case ETH_LINK_SPEED_10000:
5789 incval = IXGBE_INCVAL_10GB;
5790 shift = IXGBE_INCVAL_SHIFT_10GB;
5794 switch (hw->mac.type) {
5795 case ixgbe_mac_X550:
5796 /* Independent of link speed. */
5798 /* Cycles read will be interpreted as ns. */
5801 case ixgbe_mac_X540:
5802 IXGBE_WRITE_REG(hw, IXGBE_TIMINCA, incval);
5804 case ixgbe_mac_82599EB:
5805 incval >>= IXGBE_INCVAL_SHIFT_82599;
5806 shift -= IXGBE_INCVAL_SHIFT_82599;
5807 IXGBE_WRITE_REG(hw, IXGBE_TIMINCA,
5808 (1 << IXGBE_INCPER_SHIFT_82599) | incval);
5811 /* Not supported. */
5815 memset(&adapter->systime_tc, 0, sizeof(struct rte_timecounter));
5816 memset(&adapter->rx_tstamp_tc, 0, sizeof(struct rte_timecounter));
5817 memset(&adapter->tx_tstamp_tc, 0, sizeof(struct rte_timecounter));
5819 adapter->systime_tc.cc_mask = IXGBE_CYCLECOUNTER_MASK;
5820 adapter->systime_tc.cc_shift = shift;
5821 adapter->systime_tc.nsec_mask = (1ULL << shift) - 1;
5823 adapter->rx_tstamp_tc.cc_mask = IXGBE_CYCLECOUNTER_MASK;
5824 adapter->rx_tstamp_tc.cc_shift = shift;
5825 adapter->rx_tstamp_tc.nsec_mask = (1ULL << shift) - 1;
5827 adapter->tx_tstamp_tc.cc_mask = IXGBE_CYCLECOUNTER_MASK;
5828 adapter->tx_tstamp_tc.cc_shift = shift;
5829 adapter->tx_tstamp_tc.nsec_mask = (1ULL << shift) - 1;
5833 ixgbe_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta)
5835 struct ixgbe_adapter *adapter =
5836 (struct ixgbe_adapter *)dev->data->dev_private;
5838 adapter->systime_tc.nsec += delta;
5839 adapter->rx_tstamp_tc.nsec += delta;
5840 adapter->tx_tstamp_tc.nsec += delta;
5846 ixgbe_timesync_write_time(struct rte_eth_dev *dev, const struct timespec *ts)
5849 struct ixgbe_adapter *adapter =
5850 (struct ixgbe_adapter *)dev->data->dev_private;
5852 ns = rte_timespec_to_ns(ts);
5853 /* Set the timecounters to a new value. */
5854 adapter->systime_tc.nsec = ns;
5855 adapter->rx_tstamp_tc.nsec = ns;
5856 adapter->tx_tstamp_tc.nsec = ns;
5862 ixgbe_timesync_read_time(struct rte_eth_dev *dev, struct timespec *ts)
5864 uint64_t ns, systime_cycles;
5865 struct ixgbe_adapter *adapter =
5866 (struct ixgbe_adapter *)dev->data->dev_private;
5868 systime_cycles = ixgbe_read_systime_cyclecounter(dev);
5869 ns = rte_timecounter_update(&adapter->systime_tc, systime_cycles);
5870 *ts = rte_ns_to_timespec(ns);
5876 ixgbe_timesync_enable(struct rte_eth_dev *dev)
5878 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5882 /* Stop the timesync system time. */
5883 IXGBE_WRITE_REG(hw, IXGBE_TIMINCA, 0x0);
5884 /* Reset the timesync system time value. */
5885 IXGBE_WRITE_REG(hw, IXGBE_SYSTIML, 0x0);
5886 IXGBE_WRITE_REG(hw, IXGBE_SYSTIMH, 0x0);
5888 /* Enable system time for platforms where it isn't on by default. */
5889 tsauxc = IXGBE_READ_REG(hw, IXGBE_TSAUXC);
5890 tsauxc &= ~IXGBE_TSAUXC_DISABLE_SYSTIME;
5891 IXGBE_WRITE_REG(hw, IXGBE_TSAUXC, tsauxc);
5893 ixgbe_start_timecounters(dev);
5895 /* Enable L2 filtering of IEEE1588/802.1AS Ethernet frame types. */
5896 IXGBE_WRITE_REG(hw, IXGBE_ETQF(IXGBE_ETQF_FILTER_1588),
5898 IXGBE_ETQF_FILTER_EN |
5901 /* Enable timestamping of received PTP packets. */
5902 tsync_ctl = IXGBE_READ_REG(hw, IXGBE_TSYNCRXCTL);
5903 tsync_ctl |= IXGBE_TSYNCRXCTL_ENABLED;
5904 IXGBE_WRITE_REG(hw, IXGBE_TSYNCRXCTL, tsync_ctl);
5906 /* Enable timestamping of transmitted PTP packets. */
5907 tsync_ctl = IXGBE_READ_REG(hw, IXGBE_TSYNCTXCTL);
5908 tsync_ctl |= IXGBE_TSYNCTXCTL_ENABLED;
5909 IXGBE_WRITE_REG(hw, IXGBE_TSYNCTXCTL, tsync_ctl);
5911 IXGBE_WRITE_FLUSH(hw);
5917 ixgbe_timesync_disable(struct rte_eth_dev *dev)
5919 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5922 /* Disable timestamping of transmitted PTP packets. */
5923 tsync_ctl = IXGBE_READ_REG(hw, IXGBE_TSYNCTXCTL);
5924 tsync_ctl &= ~IXGBE_TSYNCTXCTL_ENABLED;
5925 IXGBE_WRITE_REG(hw, IXGBE_TSYNCTXCTL, tsync_ctl);
5927 /* Disable timestamping of received PTP packets. */
5928 tsync_ctl = IXGBE_READ_REG(hw, IXGBE_TSYNCRXCTL);
5929 tsync_ctl &= ~IXGBE_TSYNCRXCTL_ENABLED;
5930 IXGBE_WRITE_REG(hw, IXGBE_TSYNCRXCTL, tsync_ctl);
5932 /* Disable L2 filtering of IEEE1588/802.1AS Ethernet frame types. */
5933 IXGBE_WRITE_REG(hw, IXGBE_ETQF(IXGBE_ETQF_FILTER_1588), 0);
5935 /* Stop incrementating the System Time registers. */
5936 IXGBE_WRITE_REG(hw, IXGBE_TIMINCA, 0);
5942 ixgbe_timesync_read_rx_timestamp(struct rte_eth_dev *dev,
5943 struct timespec *timestamp,
5944 uint32_t flags __rte_unused)
5946 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5947 struct ixgbe_adapter *adapter =
5948 (struct ixgbe_adapter *)dev->data->dev_private;
5949 uint32_t tsync_rxctl;
5950 uint64_t rx_tstamp_cycles;
5953 tsync_rxctl = IXGBE_READ_REG(hw, IXGBE_TSYNCRXCTL);
5954 if ((tsync_rxctl & IXGBE_TSYNCRXCTL_VALID) == 0)
5957 rx_tstamp_cycles = ixgbe_read_rx_tstamp_cyclecounter(dev);
5958 ns = rte_timecounter_update(&adapter->rx_tstamp_tc, rx_tstamp_cycles);
5959 *timestamp = rte_ns_to_timespec(ns);
5965 ixgbe_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
5966 struct timespec *timestamp)
5968 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5969 struct ixgbe_adapter *adapter =
5970 (struct ixgbe_adapter *)dev->data->dev_private;
5971 uint32_t tsync_txctl;
5972 uint64_t tx_tstamp_cycles;
5975 tsync_txctl = IXGBE_READ_REG(hw, IXGBE_TSYNCTXCTL);
5976 if ((tsync_txctl & IXGBE_TSYNCTXCTL_VALID) == 0)
5979 tx_tstamp_cycles = ixgbe_read_tx_tstamp_cyclecounter(dev);
5980 ns = rte_timecounter_update(&adapter->tx_tstamp_tc, tx_tstamp_cycles);
5981 *timestamp = rte_ns_to_timespec(ns);
5987 ixgbe_get_reg_length(struct rte_eth_dev *dev)
5989 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5992 const struct reg_info *reg_group;
5993 const struct reg_info **reg_set = (hw->mac.type == ixgbe_mac_82598EB) ?
5994 ixgbe_regs_mac_82598EB : ixgbe_regs_others;
5996 while ((reg_group = reg_set[g_ind++]))
5997 count += ixgbe_regs_group_count(reg_group);
6003 ixgbevf_get_reg_length(struct rte_eth_dev *dev __rte_unused)
6007 const struct reg_info *reg_group;
6009 while ((reg_group = ixgbevf_regs[g_ind++]))
6010 count += ixgbe_regs_group_count(reg_group);
6016 ixgbe_get_regs(struct rte_eth_dev *dev,
6017 struct rte_dev_reg_info *regs)
6019 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6020 uint32_t *data = regs->data;
6023 const struct reg_info *reg_group;
6024 const struct reg_info **reg_set = (hw->mac.type == ixgbe_mac_82598EB) ?
6025 ixgbe_regs_mac_82598EB : ixgbe_regs_others;
6027 /* Support only full register dump */
6028 if ((regs->length == 0) ||
6029 (regs->length == (uint32_t)ixgbe_get_reg_length(dev))) {
6030 regs->version = hw->mac.type << 24 | hw->revision_id << 16 |
6032 while ((reg_group = reg_set[g_ind++]))
6033 count += ixgbe_read_regs_group(dev, &data[count],
6042 ixgbevf_get_regs(struct rte_eth_dev *dev,
6043 struct rte_dev_reg_info *regs)
6045 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6046 uint32_t *data = regs->data;
6049 const struct reg_info *reg_group;
6051 /* Support only full register dump */
6052 if ((regs->length == 0) ||
6053 (regs->length == (uint32_t)ixgbevf_get_reg_length(dev))) {
6054 regs->version = hw->mac.type << 24 | hw->revision_id << 16 |
6056 while ((reg_group = ixgbevf_regs[g_ind++]))
6057 count += ixgbe_read_regs_group(dev, &data[count],
6066 ixgbe_get_eeprom_length(struct rte_eth_dev *dev)
6068 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6070 /* Return unit is byte count */
6071 return hw->eeprom.word_size * 2;
6075 ixgbe_get_eeprom(struct rte_eth_dev *dev,
6076 struct rte_dev_eeprom_info *in_eeprom)
6078 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6079 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
6080 uint16_t *data = in_eeprom->data;
6083 first = in_eeprom->offset >> 1;
6084 length = in_eeprom->length >> 1;
6085 if ((first > hw->eeprom.word_size) ||
6086 ((first + length) > hw->eeprom.word_size))
6089 in_eeprom->magic = hw->vendor_id | (hw->device_id << 16);
6091 return eeprom->ops.read_buffer(hw, first, length, data);
6095 ixgbe_set_eeprom(struct rte_eth_dev *dev,
6096 struct rte_dev_eeprom_info *in_eeprom)
6098 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6099 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
6100 uint16_t *data = in_eeprom->data;
6103 first = in_eeprom->offset >> 1;
6104 length = in_eeprom->length >> 1;
6105 if ((first > hw->eeprom.word_size) ||
6106 ((first + length) > hw->eeprom.word_size))
6109 in_eeprom->magic = hw->vendor_id | (hw->device_id << 16);
6111 return eeprom->ops.write_buffer(hw, first, length, data);
6115 ixgbe_reta_size_get(enum ixgbe_mac_type mac_type) {
6117 case ixgbe_mac_X550:
6118 case ixgbe_mac_X550EM_x:
6119 return ETH_RSS_RETA_SIZE_512;
6120 case ixgbe_mac_X550_vf:
6121 case ixgbe_mac_X550EM_x_vf:
6122 return ETH_RSS_RETA_SIZE_64;
6124 return ETH_RSS_RETA_SIZE_128;
6129 ixgbe_reta_reg_get(enum ixgbe_mac_type mac_type, uint16_t reta_idx) {
6131 case ixgbe_mac_X550:
6132 case ixgbe_mac_X550EM_x:
6133 if (reta_idx < ETH_RSS_RETA_SIZE_128)
6134 return IXGBE_RETA(reta_idx >> 2);
6136 return IXGBE_ERETA((reta_idx - ETH_RSS_RETA_SIZE_128) >> 2);
6137 case ixgbe_mac_X550_vf:
6138 case ixgbe_mac_X550EM_x_vf:
6139 return IXGBE_VFRETA(reta_idx >> 2);
6141 return IXGBE_RETA(reta_idx >> 2);
6146 ixgbe_mrqc_reg_get(enum ixgbe_mac_type mac_type) {
6148 case ixgbe_mac_X550_vf:
6149 case ixgbe_mac_X550EM_x_vf:
6150 return IXGBE_VFMRQC;
6157 ixgbe_rssrk_reg_get(enum ixgbe_mac_type mac_type, uint8_t i) {
6159 case ixgbe_mac_X550_vf:
6160 case ixgbe_mac_X550EM_x_vf:
6161 return IXGBE_VFRSSRK(i);
6163 return IXGBE_RSSRK(i);
6168 ixgbe_rss_update_sp(enum ixgbe_mac_type mac_type) {
6170 case ixgbe_mac_82599_vf:
6171 case ixgbe_mac_X540_vf:
6179 ixgbe_dev_get_dcb_info(struct rte_eth_dev *dev,
6180 struct rte_eth_dcb_info *dcb_info)
6182 struct ixgbe_dcb_config *dcb_config =
6183 IXGBE_DEV_PRIVATE_TO_DCB_CFG(dev->data->dev_private);
6184 struct ixgbe_dcb_tc_config *tc;
6187 if (dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_DCB_FLAG)
6188 dcb_info->nb_tcs = dcb_config->num_tcs.pg_tcs;
6190 dcb_info->nb_tcs = 1;
6192 if (dcb_config->vt_mode) { /* vt is enabled*/
6193 struct rte_eth_vmdq_dcb_conf *vmdq_rx_conf =
6194 &dev->data->dev_conf.rx_adv_conf.vmdq_dcb_conf;
6195 for (i = 0; i < ETH_DCB_NUM_USER_PRIORITIES; i++)
6196 dcb_info->prio_tc[i] = vmdq_rx_conf->dcb_tc[i];
6197 for (i = 0; i < vmdq_rx_conf->nb_queue_pools; i++) {
6198 for (j = 0; j < dcb_info->nb_tcs; j++) {
6199 dcb_info->tc_queue.tc_rxq[i][j].base =
6200 i * dcb_info->nb_tcs + j;
6201 dcb_info->tc_queue.tc_rxq[i][j].nb_queue = 1;
6202 dcb_info->tc_queue.tc_txq[i][j].base =
6203 i * dcb_info->nb_tcs + j;
6204 dcb_info->tc_queue.tc_txq[i][j].nb_queue = 1;
6207 } else { /* vt is disabled*/
6208 struct rte_eth_dcb_rx_conf *rx_conf =
6209 &dev->data->dev_conf.rx_adv_conf.dcb_rx_conf;
6210 for (i = 0; i < ETH_DCB_NUM_USER_PRIORITIES; i++)
6211 dcb_info->prio_tc[i] = rx_conf->dcb_tc[i];
6212 if (dcb_info->nb_tcs == ETH_4_TCS) {
6213 for (i = 0; i < dcb_info->nb_tcs; i++) {
6214 dcb_info->tc_queue.tc_rxq[0][i].base = i * 32;
6215 dcb_info->tc_queue.tc_rxq[0][i].nb_queue = 16;
6217 dcb_info->tc_queue.tc_txq[0][0].base = 0;
6218 dcb_info->tc_queue.tc_txq[0][1].base = 64;
6219 dcb_info->tc_queue.tc_txq[0][2].base = 96;
6220 dcb_info->tc_queue.tc_txq[0][3].base = 112;
6221 dcb_info->tc_queue.tc_txq[0][0].nb_queue = 64;
6222 dcb_info->tc_queue.tc_txq[0][1].nb_queue = 32;
6223 dcb_info->tc_queue.tc_txq[0][2].nb_queue = 16;
6224 dcb_info->tc_queue.tc_txq[0][3].nb_queue = 16;
6225 } else if (dcb_info->nb_tcs == ETH_8_TCS) {
6226 for (i = 0; i < dcb_info->nb_tcs; i++) {
6227 dcb_info->tc_queue.tc_rxq[0][i].base = i * 16;
6228 dcb_info->tc_queue.tc_rxq[0][i].nb_queue = 16;
6230 dcb_info->tc_queue.tc_txq[0][0].base = 0;
6231 dcb_info->tc_queue.tc_txq[0][1].base = 32;
6232 dcb_info->tc_queue.tc_txq[0][2].base = 64;
6233 dcb_info->tc_queue.tc_txq[0][3].base = 80;
6234 dcb_info->tc_queue.tc_txq[0][4].base = 96;
6235 dcb_info->tc_queue.tc_txq[0][5].base = 104;
6236 dcb_info->tc_queue.tc_txq[0][6].base = 112;
6237 dcb_info->tc_queue.tc_txq[0][7].base = 120;
6238 dcb_info->tc_queue.tc_txq[0][0].nb_queue = 32;
6239 dcb_info->tc_queue.tc_txq[0][1].nb_queue = 32;
6240 dcb_info->tc_queue.tc_txq[0][2].nb_queue = 16;
6241 dcb_info->tc_queue.tc_txq[0][3].nb_queue = 16;
6242 dcb_info->tc_queue.tc_txq[0][4].nb_queue = 8;
6243 dcb_info->tc_queue.tc_txq[0][5].nb_queue = 8;
6244 dcb_info->tc_queue.tc_txq[0][6].nb_queue = 8;
6245 dcb_info->tc_queue.tc_txq[0][7].nb_queue = 8;
6248 for (i = 0; i < dcb_info->nb_tcs; i++) {
6249 tc = &dcb_config->tc_config[i];
6250 dcb_info->tc_bws[i] = tc->path[IXGBE_DCB_TX_CONFIG].bwg_percent;
6255 /* Update e-tag ether type */
6257 ixgbe_update_e_tag_eth_type(struct ixgbe_hw *hw,
6258 uint16_t ether_type)
6260 uint32_t etag_etype;
6262 if (hw->mac.type != ixgbe_mac_X550 &&
6263 hw->mac.type != ixgbe_mac_X550EM_x) {
6267 etag_etype = IXGBE_READ_REG(hw, IXGBE_ETAG_ETYPE);
6268 etag_etype &= ~IXGBE_ETAG_ETYPE_MASK;
6269 etag_etype |= ether_type;
6270 IXGBE_WRITE_REG(hw, IXGBE_ETAG_ETYPE, etag_etype);
6271 IXGBE_WRITE_FLUSH(hw);
6276 /* Config l2 tunnel ether type */
6278 ixgbe_dev_l2_tunnel_eth_type_conf(struct rte_eth_dev *dev,
6279 struct rte_eth_l2_tunnel_conf *l2_tunnel)
6282 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6284 if (l2_tunnel == NULL)
6287 switch (l2_tunnel->l2_tunnel_type) {
6288 case RTE_L2_TUNNEL_TYPE_E_TAG:
6289 ret = ixgbe_update_e_tag_eth_type(hw, l2_tunnel->ether_type);
6292 PMD_DRV_LOG(ERR, "Invalid tunnel type");
6300 /* Enable e-tag tunnel */
6302 ixgbe_e_tag_enable(struct ixgbe_hw *hw)
6304 uint32_t etag_etype;
6306 if (hw->mac.type != ixgbe_mac_X550 &&
6307 hw->mac.type != ixgbe_mac_X550EM_x) {
6311 etag_etype = IXGBE_READ_REG(hw, IXGBE_ETAG_ETYPE);
6312 etag_etype |= IXGBE_ETAG_ETYPE_VALID;
6313 IXGBE_WRITE_REG(hw, IXGBE_ETAG_ETYPE, etag_etype);
6314 IXGBE_WRITE_FLUSH(hw);
6319 /* Enable l2 tunnel */
6321 ixgbe_dev_l2_tunnel_enable(struct rte_eth_dev *dev,
6322 enum rte_eth_tunnel_type l2_tunnel_type)
6325 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6327 switch (l2_tunnel_type) {
6328 case RTE_L2_TUNNEL_TYPE_E_TAG:
6329 ret = ixgbe_e_tag_enable(hw);
6332 PMD_DRV_LOG(ERR, "Invalid tunnel type");
6340 /* Disable e-tag tunnel */
6342 ixgbe_e_tag_disable(struct ixgbe_hw *hw)
6344 uint32_t etag_etype;
6346 if (hw->mac.type != ixgbe_mac_X550 &&
6347 hw->mac.type != ixgbe_mac_X550EM_x) {
6351 etag_etype = IXGBE_READ_REG(hw, IXGBE_ETAG_ETYPE);
6352 etag_etype &= ~IXGBE_ETAG_ETYPE_VALID;
6353 IXGBE_WRITE_REG(hw, IXGBE_ETAG_ETYPE, etag_etype);
6354 IXGBE_WRITE_FLUSH(hw);
6359 /* Disable l2 tunnel */
6361 ixgbe_dev_l2_tunnel_disable(struct rte_eth_dev *dev,
6362 enum rte_eth_tunnel_type l2_tunnel_type)
6365 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6367 switch (l2_tunnel_type) {
6368 case RTE_L2_TUNNEL_TYPE_E_TAG:
6369 ret = ixgbe_e_tag_disable(hw);
6372 PMD_DRV_LOG(ERR, "Invalid tunnel type");
6381 ixgbe_e_tag_filter_del(struct rte_eth_dev *dev,
6382 struct rte_eth_l2_tunnel_conf *l2_tunnel)
6385 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6386 uint32_t i, rar_entries;
6387 uint32_t rar_low, rar_high;
6389 if (hw->mac.type != ixgbe_mac_X550 &&
6390 hw->mac.type != ixgbe_mac_X550EM_x) {
6394 rar_entries = ixgbe_get_num_rx_addrs(hw);
6396 for (i = 1; i < rar_entries; i++) {
6397 rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(i));
6398 rar_low = IXGBE_READ_REG(hw, IXGBE_RAL(i));
6399 if ((rar_high & IXGBE_RAH_AV) &&
6400 (rar_high & IXGBE_RAH_ADTYPE) &&
6401 ((rar_low & IXGBE_RAL_ETAG_FILTER_MASK) ==
6402 l2_tunnel->tunnel_id)) {
6403 IXGBE_WRITE_REG(hw, IXGBE_RAL(i), 0);
6404 IXGBE_WRITE_REG(hw, IXGBE_RAH(i), 0);
6406 ixgbe_clear_vmdq(hw, i, IXGBE_CLEAR_VMDQ_ALL);
6416 ixgbe_e_tag_filter_add(struct rte_eth_dev *dev,
6417 struct rte_eth_l2_tunnel_conf *l2_tunnel)
6420 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6421 uint32_t i, rar_entries;
6422 uint32_t rar_low, rar_high;
6424 if (hw->mac.type != ixgbe_mac_X550 &&
6425 hw->mac.type != ixgbe_mac_X550EM_x) {
6429 /* One entry for one tunnel. Try to remove potential existing entry. */
6430 ixgbe_e_tag_filter_del(dev, l2_tunnel);
6432 rar_entries = ixgbe_get_num_rx_addrs(hw);
6434 for (i = 1; i < rar_entries; i++) {
6435 rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(i));
6436 if (rar_high & IXGBE_RAH_AV) {
6439 ixgbe_set_vmdq(hw, i, l2_tunnel->pool);
6440 rar_high = IXGBE_RAH_AV | IXGBE_RAH_ADTYPE;
6441 rar_low = l2_tunnel->tunnel_id;
6443 IXGBE_WRITE_REG(hw, IXGBE_RAL(i), rar_low);
6444 IXGBE_WRITE_REG(hw, IXGBE_RAH(i), rar_high);
6450 PMD_INIT_LOG(NOTICE, "The table of E-tag forwarding rule is full."
6451 " Please remove a rule before adding a new one.");
6455 /* Add l2 tunnel filter */
6457 ixgbe_dev_l2_tunnel_filter_add(struct rte_eth_dev *dev,
6458 struct rte_eth_l2_tunnel_conf *l2_tunnel)
6462 switch (l2_tunnel->l2_tunnel_type) {
6463 case RTE_L2_TUNNEL_TYPE_E_TAG:
6464 ret = ixgbe_e_tag_filter_add(dev, l2_tunnel);
6467 PMD_DRV_LOG(ERR, "Invalid tunnel type");
6475 /* Delete l2 tunnel filter */
6477 ixgbe_dev_l2_tunnel_filter_del(struct rte_eth_dev *dev,
6478 struct rte_eth_l2_tunnel_conf *l2_tunnel)
6482 switch (l2_tunnel->l2_tunnel_type) {
6483 case RTE_L2_TUNNEL_TYPE_E_TAG:
6484 ret = ixgbe_e_tag_filter_del(dev, l2_tunnel);
6487 PMD_DRV_LOG(ERR, "Invalid tunnel type");
6496 * ixgbe_dev_l2_tunnel_filter_handle - Handle operations for l2 tunnel filter.
6497 * @dev: pointer to rte_eth_dev structure
6498 * @filter_op:operation will be taken.
6499 * @arg: a pointer to specific structure corresponding to the filter_op
6502 ixgbe_dev_l2_tunnel_filter_handle(struct rte_eth_dev *dev,
6503 enum rte_filter_op filter_op,
6508 if (filter_op == RTE_ETH_FILTER_NOP)
6512 PMD_DRV_LOG(ERR, "arg shouldn't be NULL for operation %u.",
6517 switch (filter_op) {
6518 case RTE_ETH_FILTER_ADD:
6519 ret = ixgbe_dev_l2_tunnel_filter_add
6521 (struct rte_eth_l2_tunnel_conf *)arg);
6523 case RTE_ETH_FILTER_DELETE:
6524 ret = ixgbe_dev_l2_tunnel_filter_del
6526 (struct rte_eth_l2_tunnel_conf *)arg);
6529 PMD_DRV_LOG(ERR, "unsupported operation %u.", filter_op);
6537 ixgbe_e_tag_forwarding_en_dis(struct rte_eth_dev *dev, bool en)
6541 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6543 if (hw->mac.type != ixgbe_mac_X550 &&
6544 hw->mac.type != ixgbe_mac_X550EM_x) {
6548 ctrl = IXGBE_READ_REG(hw, IXGBE_VT_CTL);
6549 ctrl &= ~IXGBE_VT_CTL_POOLING_MODE_MASK;
6551 ctrl |= IXGBE_VT_CTL_POOLING_MODE_ETAG;
6552 IXGBE_WRITE_REG(hw, IXGBE_VT_CTL, ctrl);
6557 /* Enable l2 tunnel forwarding */
6559 ixgbe_dev_l2_tunnel_forwarding_enable
6560 (struct rte_eth_dev *dev,
6561 enum rte_eth_tunnel_type l2_tunnel_type)
6565 switch (l2_tunnel_type) {
6566 case RTE_L2_TUNNEL_TYPE_E_TAG:
6567 ret = ixgbe_e_tag_forwarding_en_dis(dev, 1);
6570 PMD_DRV_LOG(ERR, "Invalid tunnel type");
6578 /* Disable l2 tunnel forwarding */
6580 ixgbe_dev_l2_tunnel_forwarding_disable
6581 (struct rte_eth_dev *dev,
6582 enum rte_eth_tunnel_type l2_tunnel_type)
6586 switch (l2_tunnel_type) {
6587 case RTE_L2_TUNNEL_TYPE_E_TAG:
6588 ret = ixgbe_e_tag_forwarding_en_dis(dev, 0);
6591 PMD_DRV_LOG(ERR, "Invalid tunnel type");
6600 ixgbe_e_tag_insertion_en_dis(struct rte_eth_dev *dev,
6601 struct rte_eth_l2_tunnel_conf *l2_tunnel,
6605 uint32_t vmtir, vmvir;
6606 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6608 if (l2_tunnel->vf_id >= dev->pci_dev->max_vfs) {
6610 "VF id %u should be less than %u",
6612 dev->pci_dev->max_vfs);
6616 if (hw->mac.type != ixgbe_mac_X550 &&
6617 hw->mac.type != ixgbe_mac_X550EM_x) {
6622 vmtir = l2_tunnel->tunnel_id;
6626 IXGBE_WRITE_REG(hw, IXGBE_VMTIR(l2_tunnel->vf_id), vmtir);
6628 vmvir = IXGBE_READ_REG(hw, IXGBE_VMVIR(l2_tunnel->vf_id));
6629 vmvir &= ~IXGBE_VMVIR_TAGA_MASK;
6631 vmvir |= IXGBE_VMVIR_TAGA_ETAG_INSERT;
6632 IXGBE_WRITE_REG(hw, IXGBE_VMVIR(l2_tunnel->vf_id), vmvir);
6637 /* Enable l2 tunnel tag insertion */
6639 ixgbe_dev_l2_tunnel_insertion_enable(struct rte_eth_dev *dev,
6640 struct rte_eth_l2_tunnel_conf *l2_tunnel)
6644 switch (l2_tunnel->l2_tunnel_type) {
6645 case RTE_L2_TUNNEL_TYPE_E_TAG:
6646 ret = ixgbe_e_tag_insertion_en_dis(dev, l2_tunnel, 1);
6649 PMD_DRV_LOG(ERR, "Invalid tunnel type");
6657 /* Disable l2 tunnel tag insertion */
6659 ixgbe_dev_l2_tunnel_insertion_disable
6660 (struct rte_eth_dev *dev,
6661 struct rte_eth_l2_tunnel_conf *l2_tunnel)
6665 switch (l2_tunnel->l2_tunnel_type) {
6666 case RTE_L2_TUNNEL_TYPE_E_TAG:
6667 ret = ixgbe_e_tag_insertion_en_dis(dev, l2_tunnel, 0);
6670 PMD_DRV_LOG(ERR, "Invalid tunnel type");
6679 ixgbe_e_tag_stripping_en_dis(struct rte_eth_dev *dev,
6684 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6686 if (hw->mac.type != ixgbe_mac_X550 &&
6687 hw->mac.type != ixgbe_mac_X550EM_x) {
6691 qde = IXGBE_READ_REG(hw, IXGBE_QDE);
6693 qde |= IXGBE_QDE_STRIP_TAG;
6695 qde &= ~IXGBE_QDE_STRIP_TAG;
6696 qde &= ~IXGBE_QDE_READ;
6697 qde |= IXGBE_QDE_WRITE;
6698 IXGBE_WRITE_REG(hw, IXGBE_QDE, qde);
6703 /* Enable l2 tunnel tag stripping */
6705 ixgbe_dev_l2_tunnel_stripping_enable
6706 (struct rte_eth_dev *dev,
6707 enum rte_eth_tunnel_type l2_tunnel_type)
6711 switch (l2_tunnel_type) {
6712 case RTE_L2_TUNNEL_TYPE_E_TAG:
6713 ret = ixgbe_e_tag_stripping_en_dis(dev, 1);
6716 PMD_DRV_LOG(ERR, "Invalid tunnel type");
6724 /* Disable l2 tunnel tag stripping */
6726 ixgbe_dev_l2_tunnel_stripping_disable
6727 (struct rte_eth_dev *dev,
6728 enum rte_eth_tunnel_type l2_tunnel_type)
6732 switch (l2_tunnel_type) {
6733 case RTE_L2_TUNNEL_TYPE_E_TAG:
6734 ret = ixgbe_e_tag_stripping_en_dis(dev, 0);
6737 PMD_DRV_LOG(ERR, "Invalid tunnel type");
6745 /* Enable/disable l2 tunnel offload functions */
6747 ixgbe_dev_l2_tunnel_offload_set
6748 (struct rte_eth_dev *dev,
6749 struct rte_eth_l2_tunnel_conf *l2_tunnel,
6755 if (l2_tunnel == NULL)
6759 if (mask & ETH_L2_TUNNEL_ENABLE_MASK) {
6761 ret = ixgbe_dev_l2_tunnel_enable(
6763 l2_tunnel->l2_tunnel_type);
6765 ret = ixgbe_dev_l2_tunnel_disable(
6767 l2_tunnel->l2_tunnel_type);
6770 if (mask & ETH_L2_TUNNEL_INSERTION_MASK) {
6772 ret = ixgbe_dev_l2_tunnel_insertion_enable(
6776 ret = ixgbe_dev_l2_tunnel_insertion_disable(
6781 if (mask & ETH_L2_TUNNEL_STRIPPING_MASK) {
6783 ret = ixgbe_dev_l2_tunnel_stripping_enable(
6785 l2_tunnel->l2_tunnel_type);
6787 ret = ixgbe_dev_l2_tunnel_stripping_disable(
6789 l2_tunnel->l2_tunnel_type);
6792 if (mask & ETH_L2_TUNNEL_FORWARDING_MASK) {
6794 ret = ixgbe_dev_l2_tunnel_forwarding_enable(
6796 l2_tunnel->l2_tunnel_type);
6798 ret = ixgbe_dev_l2_tunnel_forwarding_disable(
6800 l2_tunnel->l2_tunnel_type);
6807 ixgbe_update_vxlan_port(struct ixgbe_hw *hw,
6810 IXGBE_WRITE_REG(hw, IXGBE_VXLANCTRL, port);
6811 IXGBE_WRITE_FLUSH(hw);
6816 /* There's only one register for VxLAN UDP port.
6817 * So, we cannot add several ports. Will update it.
6820 ixgbe_add_vxlan_port(struct ixgbe_hw *hw,
6824 PMD_DRV_LOG(ERR, "Add VxLAN port 0 is not allowed.");
6828 return ixgbe_update_vxlan_port(hw, port);
6831 /* We cannot delete the VxLAN port. For there's a register for VxLAN
6832 * UDP port, it must have a value.
6833 * So, will reset it to the original value 0.
6836 ixgbe_del_vxlan_port(struct ixgbe_hw *hw,
6841 cur_port = (uint16_t)IXGBE_READ_REG(hw, IXGBE_VXLANCTRL);
6843 if (cur_port != port) {
6844 PMD_DRV_LOG(ERR, "Port %u does not exist.", port);
6848 return ixgbe_update_vxlan_port(hw, 0);
6851 /* Add UDP tunneling port */
6853 ixgbe_dev_udp_tunnel_port_add(struct rte_eth_dev *dev,
6854 struct rte_eth_udp_tunnel *udp_tunnel)
6857 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6859 if (hw->mac.type != ixgbe_mac_X550 &&
6860 hw->mac.type != ixgbe_mac_X550EM_x) {
6864 if (udp_tunnel == NULL)
6867 switch (udp_tunnel->prot_type) {
6868 case RTE_TUNNEL_TYPE_VXLAN:
6869 ret = ixgbe_add_vxlan_port(hw, udp_tunnel->udp_port);
6872 case RTE_TUNNEL_TYPE_GENEVE:
6873 case RTE_TUNNEL_TYPE_TEREDO:
6874 PMD_DRV_LOG(ERR, "Tunnel type is not supported now.");
6879 PMD_DRV_LOG(ERR, "Invalid tunnel type");
6887 /* Remove UDP tunneling port */
6889 ixgbe_dev_udp_tunnel_port_del(struct rte_eth_dev *dev,
6890 struct rte_eth_udp_tunnel *udp_tunnel)
6893 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6895 if (hw->mac.type != ixgbe_mac_X550 &&
6896 hw->mac.type != ixgbe_mac_X550EM_x) {
6900 if (udp_tunnel == NULL)
6903 switch (udp_tunnel->prot_type) {
6904 case RTE_TUNNEL_TYPE_VXLAN:
6905 ret = ixgbe_del_vxlan_port(hw, udp_tunnel->udp_port);
6907 case RTE_TUNNEL_TYPE_GENEVE:
6908 case RTE_TUNNEL_TYPE_TEREDO:
6909 PMD_DRV_LOG(ERR, "Tunnel type is not supported now.");
6913 PMD_DRV_LOG(ERR, "Invalid tunnel type");
6921 static struct rte_driver rte_ixgbe_driver = {
6923 .init = rte_ixgbe_pmd_init,
6926 static struct rte_driver rte_ixgbevf_driver = {
6928 .init = rte_ixgbevf_pmd_init,
6931 PMD_REGISTER_DRIVER(rte_ixgbe_driver);
6932 PMD_REGISTER_DRIVER(rte_ixgbevf_driver);