1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2020
9 #include <rte_common.h>
10 #include <rte_ethdev_pci.h>
12 #include <rte_interrupts.h>
14 #include <rte_debug.h>
16 #include <rte_memory.h>
18 #include <rte_alarm.h>
20 #include "txgbe_logs.h"
21 #include "base/txgbe.h"
22 #include "txgbe_ethdev.h"
23 #include "txgbe_rxtx.h"
24 #include "txgbe_regs_group.h"
26 static const struct reg_info txgbe_regs_general[] = {
27 {TXGBE_RST, 1, 1, "TXGBE_RST"},
28 {TXGBE_STAT, 1, 1, "TXGBE_STAT"},
29 {TXGBE_PORTCTL, 1, 1, "TXGBE_PORTCTL"},
30 {TXGBE_SDP, 1, 1, "TXGBE_SDP"},
31 {TXGBE_SDPCTL, 1, 1, "TXGBE_SDPCTL"},
32 {TXGBE_LEDCTL, 1, 1, "TXGBE_LEDCTL"},
36 static const struct reg_info txgbe_regs_nvm[] = {
40 static const struct reg_info txgbe_regs_interrupt[] = {
44 static const struct reg_info txgbe_regs_fctl_others[] = {
48 static const struct reg_info txgbe_regs_rxdma[] = {
52 static const struct reg_info txgbe_regs_rx[] = {
56 static struct reg_info txgbe_regs_tx[] = {
60 static const struct reg_info txgbe_regs_wakeup[] = {
64 static const struct reg_info txgbe_regs_dcb[] = {
68 static const struct reg_info txgbe_regs_mac[] = {
72 static const struct reg_info txgbe_regs_diagnostic[] = {
77 static const struct reg_info *txgbe_regs_others[] = {
81 txgbe_regs_fctl_others,
88 txgbe_regs_diagnostic,
91 static int txgbe_l2_tn_filter_init(struct rte_eth_dev *eth_dev);
92 static int txgbe_l2_tn_filter_uninit(struct rte_eth_dev *eth_dev);
93 static int txgbe_dev_set_link_up(struct rte_eth_dev *dev);
94 static int txgbe_dev_set_link_down(struct rte_eth_dev *dev);
95 static int txgbe_dev_close(struct rte_eth_dev *dev);
96 static int txgbe_dev_link_update(struct rte_eth_dev *dev,
97 int wait_to_complete);
98 static int txgbe_dev_stats_reset(struct rte_eth_dev *dev);
99 static void txgbe_vlan_hw_strip_enable(struct rte_eth_dev *dev, uint16_t queue);
100 static void txgbe_vlan_hw_strip_disable(struct rte_eth_dev *dev,
103 static void txgbe_dev_link_status_print(struct rte_eth_dev *dev);
104 static int txgbe_dev_lsc_interrupt_setup(struct rte_eth_dev *dev, uint8_t on);
105 static int txgbe_dev_macsec_interrupt_setup(struct rte_eth_dev *dev);
106 static int txgbe_dev_rxq_interrupt_setup(struct rte_eth_dev *dev);
107 static int txgbe_dev_interrupt_get_status(struct rte_eth_dev *dev);
108 static int txgbe_dev_interrupt_action(struct rte_eth_dev *dev,
109 struct rte_intr_handle *handle);
110 static void txgbe_dev_interrupt_handler(void *param);
111 static void txgbe_dev_interrupt_delayed_handler(void *param);
112 static void txgbe_configure_msix(struct rte_eth_dev *dev);
114 static int txgbe_filter_restore(struct rte_eth_dev *dev);
115 static void txgbe_l2_tunnel_conf(struct rte_eth_dev *dev);
117 #define TXGBE_SET_HWSTRIP(h, q) do {\
118 uint32_t idx = (q) / (sizeof((h)->bitmap[0]) * NBBY); \
119 uint32_t bit = (q) % (sizeof((h)->bitmap[0]) * NBBY); \
120 (h)->bitmap[idx] |= 1 << bit;\
123 #define TXGBE_CLEAR_HWSTRIP(h, q) do {\
124 uint32_t idx = (q) / (sizeof((h)->bitmap[0]) * NBBY); \
125 uint32_t bit = (q) % (sizeof((h)->bitmap[0]) * NBBY); \
126 (h)->bitmap[idx] &= ~(1 << bit);\
129 #define TXGBE_GET_HWSTRIP(h, q, r) do {\
130 uint32_t idx = (q) / (sizeof((h)->bitmap[0]) * NBBY); \
131 uint32_t bit = (q) % (sizeof((h)->bitmap[0]) * NBBY); \
132 (r) = (h)->bitmap[idx] >> bit & 1;\
136 * The set of PCI devices this driver supports
138 static const struct rte_pci_id pci_id_txgbe_map[] = {
139 { RTE_PCI_DEVICE(PCI_VENDOR_ID_WANGXUN, TXGBE_DEV_ID_RAPTOR_SFP) },
140 { RTE_PCI_DEVICE(PCI_VENDOR_ID_WANGXUN, TXGBE_DEV_ID_WX1820_SFP) },
141 { .vendor_id = 0, /* sentinel */ },
144 static const struct rte_eth_desc_lim rx_desc_lim = {
145 .nb_max = TXGBE_RING_DESC_MAX,
146 .nb_min = TXGBE_RING_DESC_MIN,
147 .nb_align = TXGBE_RXD_ALIGN,
150 static const struct rte_eth_desc_lim tx_desc_lim = {
151 .nb_max = TXGBE_RING_DESC_MAX,
152 .nb_min = TXGBE_RING_DESC_MIN,
153 .nb_align = TXGBE_TXD_ALIGN,
154 .nb_seg_max = TXGBE_TX_MAX_SEG,
155 .nb_mtu_seg_max = TXGBE_TX_MAX_SEG,
158 static const struct eth_dev_ops txgbe_eth_dev_ops;
160 #define HW_XSTAT(m) {#m, offsetof(struct txgbe_hw_stats, m)}
161 #define HW_XSTAT_NAME(m, n) {n, offsetof(struct txgbe_hw_stats, m)}
162 static const struct rte_txgbe_xstats_name_off rte_txgbe_stats_strings[] = {
164 HW_XSTAT(mng_bmc2host_packets),
165 HW_XSTAT(mng_host2bmc_packets),
167 HW_XSTAT(rx_packets),
168 HW_XSTAT(tx_packets),
171 HW_XSTAT(rx_total_bytes),
172 HW_XSTAT(rx_total_packets),
173 HW_XSTAT(tx_total_packets),
174 HW_XSTAT(rx_total_missed_packets),
175 HW_XSTAT(rx_broadcast_packets),
176 HW_XSTAT(rx_multicast_packets),
177 HW_XSTAT(rx_management_packets),
178 HW_XSTAT(tx_management_packets),
179 HW_XSTAT(rx_management_dropped),
182 HW_XSTAT(rx_crc_errors),
183 HW_XSTAT(rx_illegal_byte_errors),
184 HW_XSTAT(rx_error_bytes),
185 HW_XSTAT(rx_mac_short_packet_dropped),
186 HW_XSTAT(rx_length_errors),
187 HW_XSTAT(rx_undersize_errors),
188 HW_XSTAT(rx_fragment_errors),
189 HW_XSTAT(rx_oversize_errors),
190 HW_XSTAT(rx_jabber_errors),
191 HW_XSTAT(rx_l3_l4_xsum_error),
192 HW_XSTAT(mac_local_errors),
193 HW_XSTAT(mac_remote_errors),
196 HW_XSTAT(flow_director_added_filters),
197 HW_XSTAT(flow_director_removed_filters),
198 HW_XSTAT(flow_director_filter_add_errors),
199 HW_XSTAT(flow_director_filter_remove_errors),
200 HW_XSTAT(flow_director_matched_filters),
201 HW_XSTAT(flow_director_missed_filters),
204 HW_XSTAT(rx_fcoe_crc_errors),
205 HW_XSTAT(rx_fcoe_mbuf_allocation_errors),
206 HW_XSTAT(rx_fcoe_dropped),
207 HW_XSTAT(rx_fcoe_packets),
208 HW_XSTAT(tx_fcoe_packets),
209 HW_XSTAT(rx_fcoe_bytes),
210 HW_XSTAT(tx_fcoe_bytes),
211 HW_XSTAT(rx_fcoe_no_ddp),
212 HW_XSTAT(rx_fcoe_no_ddp_ext_buff),
215 HW_XSTAT(tx_macsec_pkts_untagged),
216 HW_XSTAT(tx_macsec_pkts_encrypted),
217 HW_XSTAT(tx_macsec_pkts_protected),
218 HW_XSTAT(tx_macsec_octets_encrypted),
219 HW_XSTAT(tx_macsec_octets_protected),
220 HW_XSTAT(rx_macsec_pkts_untagged),
221 HW_XSTAT(rx_macsec_pkts_badtag),
222 HW_XSTAT(rx_macsec_pkts_nosci),
223 HW_XSTAT(rx_macsec_pkts_unknownsci),
224 HW_XSTAT(rx_macsec_octets_decrypted),
225 HW_XSTAT(rx_macsec_octets_validated),
226 HW_XSTAT(rx_macsec_sc_pkts_unchecked),
227 HW_XSTAT(rx_macsec_sc_pkts_delayed),
228 HW_XSTAT(rx_macsec_sc_pkts_late),
229 HW_XSTAT(rx_macsec_sa_pkts_ok),
230 HW_XSTAT(rx_macsec_sa_pkts_invalid),
231 HW_XSTAT(rx_macsec_sa_pkts_notvalid),
232 HW_XSTAT(rx_macsec_sa_pkts_unusedsa),
233 HW_XSTAT(rx_macsec_sa_pkts_notusingsa),
236 HW_XSTAT(rx_size_64_packets),
237 HW_XSTAT(rx_size_65_to_127_packets),
238 HW_XSTAT(rx_size_128_to_255_packets),
239 HW_XSTAT(rx_size_256_to_511_packets),
240 HW_XSTAT(rx_size_512_to_1023_packets),
241 HW_XSTAT(rx_size_1024_to_max_packets),
242 HW_XSTAT(tx_size_64_packets),
243 HW_XSTAT(tx_size_65_to_127_packets),
244 HW_XSTAT(tx_size_128_to_255_packets),
245 HW_XSTAT(tx_size_256_to_511_packets),
246 HW_XSTAT(tx_size_512_to_1023_packets),
247 HW_XSTAT(tx_size_1024_to_max_packets),
250 HW_XSTAT(tx_xon_packets),
251 HW_XSTAT(rx_xon_packets),
252 HW_XSTAT(tx_xoff_packets),
253 HW_XSTAT(rx_xoff_packets),
255 HW_XSTAT_NAME(tx_xon_packets, "tx_flow_control_xon_packets"),
256 HW_XSTAT_NAME(rx_xon_packets, "rx_flow_control_xon_packets"),
257 HW_XSTAT_NAME(tx_xoff_packets, "tx_flow_control_xoff_packets"),
258 HW_XSTAT_NAME(rx_xoff_packets, "rx_flow_control_xoff_packets"),
261 #define TXGBE_NB_HW_STATS (sizeof(rte_txgbe_stats_strings) / \
262 sizeof(rte_txgbe_stats_strings[0]))
264 /* Per-priority statistics */
265 #define UP_XSTAT(m) {#m, offsetof(struct txgbe_hw_stats, up[0].m)}
266 static const struct rte_txgbe_xstats_name_off rte_txgbe_up_strings[] = {
267 UP_XSTAT(rx_up_packets),
268 UP_XSTAT(tx_up_packets),
269 UP_XSTAT(rx_up_bytes),
270 UP_XSTAT(tx_up_bytes),
271 UP_XSTAT(rx_up_drop_packets),
273 UP_XSTAT(tx_up_xon_packets),
274 UP_XSTAT(rx_up_xon_packets),
275 UP_XSTAT(tx_up_xoff_packets),
276 UP_XSTAT(rx_up_xoff_packets),
277 UP_XSTAT(rx_up_dropped),
278 UP_XSTAT(rx_up_mbuf_alloc_errors),
279 UP_XSTAT(tx_up_xon2off_packets),
282 #define TXGBE_NB_UP_STATS (sizeof(rte_txgbe_up_strings) / \
283 sizeof(rte_txgbe_up_strings[0]))
285 /* Per-queue statistics */
286 #define QP_XSTAT(m) {#m, offsetof(struct txgbe_hw_stats, qp[0].m)}
287 static const struct rte_txgbe_xstats_name_off rte_txgbe_qp_strings[] = {
288 QP_XSTAT(rx_qp_packets),
289 QP_XSTAT(tx_qp_packets),
290 QP_XSTAT(rx_qp_bytes),
291 QP_XSTAT(tx_qp_bytes),
292 QP_XSTAT(rx_qp_mc_packets),
295 #define TXGBE_NB_QP_STATS (sizeof(rte_txgbe_qp_strings) / \
296 sizeof(rte_txgbe_qp_strings[0]))
299 txgbe_is_sfp(struct txgbe_hw *hw)
301 switch (hw->phy.type) {
302 case txgbe_phy_sfp_avago:
303 case txgbe_phy_sfp_ftl:
304 case txgbe_phy_sfp_intel:
305 case txgbe_phy_sfp_unknown:
306 case txgbe_phy_sfp_tyco_passive:
307 case txgbe_phy_sfp_unknown_passive:
314 static inline int32_t
315 txgbe_pf_reset_hw(struct txgbe_hw *hw)
320 status = hw->mac.reset_hw(hw);
322 ctrl_ext = rd32(hw, TXGBE_PORTCTL);
323 /* Set PF Reset Done bit so PF/VF Mail Ops can work */
324 ctrl_ext |= TXGBE_PORTCTL_RSTDONE;
325 wr32(hw, TXGBE_PORTCTL, ctrl_ext);
328 if (status == TXGBE_ERR_SFP_NOT_PRESENT)
334 txgbe_enable_intr(struct rte_eth_dev *dev)
336 struct txgbe_interrupt *intr = TXGBE_DEV_INTR(dev);
337 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
339 wr32(hw, TXGBE_IENMISC, intr->mask_misc);
340 wr32(hw, TXGBE_IMC(0), TXGBE_IMC_MASK);
341 wr32(hw, TXGBE_IMC(1), TXGBE_IMC_MASK);
346 txgbe_disable_intr(struct txgbe_hw *hw)
348 PMD_INIT_FUNC_TRACE();
350 wr32(hw, TXGBE_IENMISC, ~BIT_MASK32);
351 wr32(hw, TXGBE_IMS(0), TXGBE_IMC_MASK);
352 wr32(hw, TXGBE_IMS(1), TXGBE_IMC_MASK);
357 txgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
362 struct txgbe_hw *hw = TXGBE_DEV_HW(eth_dev);
363 struct txgbe_stat_mappings *stat_mappings =
364 TXGBE_DEV_STAT_MAPPINGS(eth_dev);
365 uint32_t qsmr_mask = 0;
366 uint32_t clearing_mask = QMAP_FIELD_RESERVED_BITS_MASK;
370 if (hw->mac.type != txgbe_mac_raptor)
373 if (stat_idx & !QMAP_FIELD_RESERVED_BITS_MASK)
376 PMD_INIT_LOG(DEBUG, "Setting port %d, %s queue_id %d to stat index %d",
377 (int)(eth_dev->data->port_id), is_rx ? "RX" : "TX",
380 n = (uint8_t)(queue_id / NB_QMAP_FIELDS_PER_QSM_REG);
381 if (n >= TXGBE_NB_STAT_MAPPING) {
382 PMD_INIT_LOG(ERR, "Nb of stat mapping registers exceeded");
385 offset = (uint8_t)(queue_id % NB_QMAP_FIELDS_PER_QSM_REG);
387 /* Now clear any previous stat_idx set */
388 clearing_mask <<= (QSM_REG_NB_BITS_PER_QMAP_FIELD * offset);
390 stat_mappings->tqsm[n] &= ~clearing_mask;
392 stat_mappings->rqsm[n] &= ~clearing_mask;
394 q_map = (uint32_t)stat_idx;
395 q_map &= QMAP_FIELD_RESERVED_BITS_MASK;
396 qsmr_mask = q_map << (QSM_REG_NB_BITS_PER_QMAP_FIELD * offset);
398 stat_mappings->tqsm[n] |= qsmr_mask;
400 stat_mappings->rqsm[n] |= qsmr_mask;
402 PMD_INIT_LOG(DEBUG, "Set port %d, %s queue_id %d to stat index %d",
403 (int)(eth_dev->data->port_id), is_rx ? "RX" : "TX",
405 PMD_INIT_LOG(DEBUG, "%s[%d] = 0x%08x", is_rx ? "RQSMR" : "TQSM", n,
406 is_rx ? stat_mappings->rqsm[n] : stat_mappings->tqsm[n]);
411 txgbe_dcb_init(struct txgbe_hw *hw, struct txgbe_dcb_config *dcb_config)
415 struct txgbe_dcb_tc_config *tc;
417 UNREFERENCED_PARAMETER(hw);
419 dcb_config->num_tcs.pg_tcs = TXGBE_DCB_TC_MAX;
420 dcb_config->num_tcs.pfc_tcs = TXGBE_DCB_TC_MAX;
421 bwgp = (u8)(100 / TXGBE_DCB_TC_MAX);
422 for (i = 0; i < TXGBE_DCB_TC_MAX; i++) {
423 tc = &dcb_config->tc_config[i];
424 tc->path[TXGBE_DCB_TX_CONFIG].bwg_id = i;
425 tc->path[TXGBE_DCB_TX_CONFIG].bwg_percent = bwgp + (i & 1);
426 tc->path[TXGBE_DCB_RX_CONFIG].bwg_id = i;
427 tc->path[TXGBE_DCB_RX_CONFIG].bwg_percent = bwgp + (i & 1);
428 tc->pfc = txgbe_dcb_pfc_disabled;
431 /* Initialize default user to priority mapping, UPx->TC0 */
432 tc = &dcb_config->tc_config[0];
433 tc->path[TXGBE_DCB_TX_CONFIG].up_to_tc_bitmap = 0xFF;
434 tc->path[TXGBE_DCB_RX_CONFIG].up_to_tc_bitmap = 0xFF;
435 for (i = 0; i < TXGBE_DCB_BWG_MAX; i++) {
436 dcb_config->bw_percentage[i][TXGBE_DCB_TX_CONFIG] = 100;
437 dcb_config->bw_percentage[i][TXGBE_DCB_RX_CONFIG] = 100;
439 dcb_config->rx_pba_cfg = txgbe_dcb_pba_equal;
440 dcb_config->pfc_mode_enable = false;
441 dcb_config->vt_mode = true;
442 dcb_config->round_robin_enable = false;
443 /* support all DCB capabilities */
444 dcb_config->support.capabilities = 0xFF;
448 * Ensure that all locks are released before first NVM or PHY access
451 txgbe_swfw_lock_reset(struct txgbe_hw *hw)
456 * These ones are more tricky since they are common to all ports; but
457 * swfw_sync retries last long enough (1s) to be almost sure that if
458 * lock can not be taken it is due to an improper lock of the
461 mask = TXGBE_MNGSEM_SWPHY |
463 TXGBE_MNGSEM_SWFLASH;
464 if (hw->mac.acquire_swfw_sync(hw, mask) < 0)
465 PMD_DRV_LOG(DEBUG, "SWFW common locks released");
467 hw->mac.release_swfw_sync(hw, mask);
471 eth_txgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused)
473 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
474 struct txgbe_hw *hw = TXGBE_DEV_HW(eth_dev);
475 struct txgbe_vfta *shadow_vfta = TXGBE_DEV_VFTA(eth_dev);
476 struct txgbe_hwstrip *hwstrip = TXGBE_DEV_HWSTRIP(eth_dev);
477 struct txgbe_dcb_config *dcb_config = TXGBE_DEV_DCB_CONFIG(eth_dev);
478 struct txgbe_filter_info *filter_info = TXGBE_DEV_FILTER(eth_dev);
479 struct txgbe_bw_conf *bw_conf = TXGBE_DEV_BW_CONF(eth_dev);
480 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
481 const struct rte_memzone *mz;
486 PMD_INIT_FUNC_TRACE();
488 eth_dev->dev_ops = &txgbe_eth_dev_ops;
489 eth_dev->rx_queue_count = txgbe_dev_rx_queue_count;
490 eth_dev->rx_descriptor_status = txgbe_dev_rx_descriptor_status;
491 eth_dev->tx_descriptor_status = txgbe_dev_tx_descriptor_status;
492 eth_dev->rx_pkt_burst = &txgbe_recv_pkts;
493 eth_dev->tx_pkt_burst = &txgbe_xmit_pkts;
494 eth_dev->tx_pkt_prepare = &txgbe_prep_pkts;
497 * For secondary processes, we don't initialise any further as primary
498 * has already done this work. Only check we don't need a different
499 * RX and TX function.
501 if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
502 struct txgbe_tx_queue *txq;
503 /* TX queue function in primary, set by last queue initialized
504 * Tx queue may not initialized by primary process
506 if (eth_dev->data->tx_queues) {
507 uint16_t nb_tx_queues = eth_dev->data->nb_tx_queues;
508 txq = eth_dev->data->tx_queues[nb_tx_queues - 1];
509 txgbe_set_tx_function(eth_dev, txq);
511 /* Use default TX function if we get here */
512 PMD_INIT_LOG(NOTICE, "No TX queues configured yet. "
513 "Using default TX function.");
516 txgbe_set_rx_function(eth_dev);
521 rte_eth_copy_pci_info(eth_dev, pci_dev);
523 /* Vendor and Device ID need to be set before init of shared code */
524 hw->device_id = pci_dev->id.device_id;
525 hw->vendor_id = pci_dev->id.vendor_id;
526 hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
527 hw->allow_unsupported_sfp = 1;
529 /* Reserve memory for interrupt status block */
530 mz = rte_eth_dma_zone_reserve(eth_dev, "txgbe_driver", -1,
531 16, TXGBE_ALIGN, SOCKET_ID_ANY);
535 hw->isb_dma = TMZ_PADDR(mz);
536 hw->isb_mem = TMZ_VADDR(mz);
538 /* Initialize the shared code (base driver) */
539 err = txgbe_init_shared_code(hw);
541 PMD_INIT_LOG(ERR, "Shared code init failed: %d", err);
545 /* Unlock any pending hardware semaphore */
546 txgbe_swfw_lock_reset(hw);
548 /* Initialize DCB configuration*/
549 memset(dcb_config, 0, sizeof(struct txgbe_dcb_config));
550 txgbe_dcb_init(hw, dcb_config);
552 /* Get Hardware Flow Control setting */
553 hw->fc.requested_mode = txgbe_fc_full;
554 hw->fc.current_mode = txgbe_fc_full;
555 hw->fc.pause_time = TXGBE_FC_PAUSE_TIME;
556 for (i = 0; i < TXGBE_DCB_TC_MAX; i++) {
557 hw->fc.low_water[i] = TXGBE_FC_XON_LOTH;
558 hw->fc.high_water[i] = TXGBE_FC_XOFF_HITH;
562 err = hw->rom.init_params(hw);
564 PMD_INIT_LOG(ERR, "The EEPROM init failed: %d", err);
568 /* Make sure we have a good EEPROM before we read from it */
569 err = hw->rom.validate_checksum(hw, &csum);
571 PMD_INIT_LOG(ERR, "The EEPROM checksum is not valid: %d", err);
575 err = hw->mac.init_hw(hw);
578 * Devices with copper phys will fail to initialise if txgbe_init_hw()
579 * is called too soon after the kernel driver unbinding/binding occurs.
580 * The failure occurs in txgbe_identify_phy() for all devices,
581 * but for non-copper devies, txgbe_identify_sfp_module() is
582 * also called. See txgbe_identify_phy(). The reason for the
583 * failure is not known, and only occuts when virtualisation features
584 * are disabled in the bios. A delay of 200ms was found to be enough by
585 * trial-and-error, and is doubled to be safe.
587 if (err && hw->phy.media_type == txgbe_media_type_copper) {
589 err = hw->mac.init_hw(hw);
592 if (err == TXGBE_ERR_SFP_NOT_PRESENT)
595 if (err == TXGBE_ERR_EEPROM_VERSION) {
596 PMD_INIT_LOG(ERR, "This device is a pre-production adapter/"
597 "LOM. Please be aware there may be issues associated "
598 "with your hardware.");
599 PMD_INIT_LOG(ERR, "If you are experiencing problems "
600 "please contact your hardware representative "
601 "who provided you with this hardware.");
602 } else if (err == TXGBE_ERR_SFP_NOT_SUPPORTED) {
603 PMD_INIT_LOG(ERR, "Unsupported SFP+ Module");
606 PMD_INIT_LOG(ERR, "Hardware Initialization Failure: %d", err);
610 /* Reset the hw statistics */
611 txgbe_dev_stats_reset(eth_dev);
613 /* disable interrupt */
614 txgbe_disable_intr(hw);
616 /* Allocate memory for storing MAC addresses */
617 eth_dev->data->mac_addrs = rte_zmalloc("txgbe", RTE_ETHER_ADDR_LEN *
618 hw->mac.num_rar_entries, 0);
619 if (eth_dev->data->mac_addrs == NULL) {
621 "Failed to allocate %u bytes needed to store "
623 RTE_ETHER_ADDR_LEN * hw->mac.num_rar_entries);
627 /* Copy the permanent MAC address */
628 rte_ether_addr_copy((struct rte_ether_addr *)hw->mac.perm_addr,
629 ð_dev->data->mac_addrs[0]);
631 /* Allocate memory for storing hash filter MAC addresses */
632 eth_dev->data->hash_mac_addrs = rte_zmalloc("txgbe",
633 RTE_ETHER_ADDR_LEN * TXGBE_VMDQ_NUM_UC_MAC, 0);
634 if (eth_dev->data->hash_mac_addrs == NULL) {
636 "Failed to allocate %d bytes needed to store MAC addresses",
637 RTE_ETHER_ADDR_LEN * TXGBE_VMDQ_NUM_UC_MAC);
641 /* initialize the vfta */
642 memset(shadow_vfta, 0, sizeof(*shadow_vfta));
644 /* initialize the hw strip bitmap*/
645 memset(hwstrip, 0, sizeof(*hwstrip));
647 /* initialize PF if max_vfs not zero */
648 ret = txgbe_pf_host_init(eth_dev);
650 rte_free(eth_dev->data->mac_addrs);
651 eth_dev->data->mac_addrs = NULL;
652 rte_free(eth_dev->data->hash_mac_addrs);
653 eth_dev->data->hash_mac_addrs = NULL;
657 ctrl_ext = rd32(hw, TXGBE_PORTCTL);
658 /* let hardware know driver is loaded */
659 ctrl_ext |= TXGBE_PORTCTL_DRVLOAD;
660 /* Set PF Reset Done bit so PF/VF Mail Ops can work */
661 ctrl_ext |= TXGBE_PORTCTL_RSTDONE;
662 wr32(hw, TXGBE_PORTCTL, ctrl_ext);
665 if (txgbe_is_sfp(hw) && hw->phy.sfp_type != txgbe_sfp_type_not_present)
666 PMD_INIT_LOG(DEBUG, "MAC: %d, PHY: %d, SFP+: %d",
667 (int)hw->mac.type, (int)hw->phy.type,
668 (int)hw->phy.sfp_type);
670 PMD_INIT_LOG(DEBUG, "MAC: %d, PHY: %d",
671 (int)hw->mac.type, (int)hw->phy.type);
673 PMD_INIT_LOG(DEBUG, "port %d vendorID=0x%x deviceID=0x%x",
674 eth_dev->data->port_id, pci_dev->id.vendor_id,
675 pci_dev->id.device_id);
677 rte_intr_callback_register(intr_handle,
678 txgbe_dev_interrupt_handler, eth_dev);
680 /* enable uio/vfio intr/eventfd mapping */
681 rte_intr_enable(intr_handle);
683 /* enable support intr */
684 txgbe_enable_intr(eth_dev);
686 /* initialize filter info */
687 memset(filter_info, 0,
688 sizeof(struct txgbe_filter_info));
690 /* initialize 5tuple filter list */
691 TAILQ_INIT(&filter_info->fivetuple_list);
693 /* initialize l2 tunnel filter list & hash */
694 txgbe_l2_tn_filter_init(eth_dev);
696 /* initialize bandwidth configuration info */
697 memset(bw_conf, 0, sizeof(struct txgbe_bw_conf));
703 eth_txgbe_dev_uninit(struct rte_eth_dev *eth_dev)
705 PMD_INIT_FUNC_TRACE();
707 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
710 txgbe_dev_close(eth_dev);
715 static int txgbe_ntuple_filter_uninit(struct rte_eth_dev *eth_dev)
717 struct txgbe_filter_info *filter_info = TXGBE_DEV_FILTER(eth_dev);
718 struct txgbe_5tuple_filter *p_5tuple;
720 while ((p_5tuple = TAILQ_FIRST(&filter_info->fivetuple_list))) {
721 TAILQ_REMOVE(&filter_info->fivetuple_list,
726 memset(filter_info->fivetuple_mask, 0,
727 sizeof(uint32_t) * TXGBE_5TUPLE_ARRAY_SIZE);
732 static int txgbe_l2_tn_filter_uninit(struct rte_eth_dev *eth_dev)
734 struct txgbe_l2_tn_info *l2_tn_info = TXGBE_DEV_L2_TN(eth_dev);
735 struct txgbe_l2_tn_filter *l2_tn_filter;
737 if (l2_tn_info->hash_map)
738 rte_free(l2_tn_info->hash_map);
739 if (l2_tn_info->hash_handle)
740 rte_hash_free(l2_tn_info->hash_handle);
742 while ((l2_tn_filter = TAILQ_FIRST(&l2_tn_info->l2_tn_list))) {
743 TAILQ_REMOVE(&l2_tn_info->l2_tn_list,
746 rte_free(l2_tn_filter);
752 static int txgbe_l2_tn_filter_init(struct rte_eth_dev *eth_dev)
754 struct txgbe_l2_tn_info *l2_tn_info = TXGBE_DEV_L2_TN(eth_dev);
755 char l2_tn_hash_name[RTE_HASH_NAMESIZE];
756 struct rte_hash_parameters l2_tn_hash_params = {
757 .name = l2_tn_hash_name,
758 .entries = TXGBE_MAX_L2_TN_FILTER_NUM,
759 .key_len = sizeof(struct txgbe_l2_tn_key),
760 .hash_func = rte_hash_crc,
761 .hash_func_init_val = 0,
762 .socket_id = rte_socket_id(),
765 TAILQ_INIT(&l2_tn_info->l2_tn_list);
766 snprintf(l2_tn_hash_name, RTE_HASH_NAMESIZE,
767 "l2_tn_%s", TDEV_NAME(eth_dev));
768 l2_tn_info->hash_handle = rte_hash_create(&l2_tn_hash_params);
769 if (!l2_tn_info->hash_handle) {
770 PMD_INIT_LOG(ERR, "Failed to create L2 TN hash table!");
773 l2_tn_info->hash_map = rte_zmalloc("txgbe",
774 sizeof(struct txgbe_l2_tn_filter *) *
775 TXGBE_MAX_L2_TN_FILTER_NUM,
777 if (!l2_tn_info->hash_map) {
779 "Failed to allocate memory for L2 TN hash map!");
782 l2_tn_info->e_tag_en = FALSE;
783 l2_tn_info->e_tag_fwd_en = FALSE;
784 l2_tn_info->e_tag_ether_type = RTE_ETHER_TYPE_ETAG;
790 eth_txgbe_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
791 struct rte_pci_device *pci_dev)
793 struct rte_eth_dev *pf_ethdev;
794 struct rte_eth_devargs eth_da;
797 if (pci_dev->device.devargs) {
798 retval = rte_eth_devargs_parse(pci_dev->device.devargs->args,
803 memset(ð_da, 0, sizeof(eth_da));
806 retval = rte_eth_dev_create(&pci_dev->device, pci_dev->device.name,
807 sizeof(struct txgbe_adapter),
808 eth_dev_pci_specific_init, pci_dev,
809 eth_txgbe_dev_init, NULL);
811 if (retval || eth_da.nb_representor_ports < 1)
814 pf_ethdev = rte_eth_dev_allocated(pci_dev->device.name);
815 if (pf_ethdev == NULL)
821 static int eth_txgbe_pci_remove(struct rte_pci_device *pci_dev)
823 struct rte_eth_dev *ethdev;
825 ethdev = rte_eth_dev_allocated(pci_dev->device.name);
829 return rte_eth_dev_destroy(ethdev, eth_txgbe_dev_uninit);
832 static struct rte_pci_driver rte_txgbe_pmd = {
833 .id_table = pci_id_txgbe_map,
834 .drv_flags = RTE_PCI_DRV_NEED_MAPPING |
835 RTE_PCI_DRV_INTR_LSC,
836 .probe = eth_txgbe_pci_probe,
837 .remove = eth_txgbe_pci_remove,
841 txgbe_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
843 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
844 struct txgbe_vfta *shadow_vfta = TXGBE_DEV_VFTA(dev);
849 vid_idx = (uint32_t)((vlan_id >> 5) & 0x7F);
850 vid_bit = (uint32_t)(1 << (vlan_id & 0x1F));
851 vfta = rd32(hw, TXGBE_VLANTBL(vid_idx));
856 wr32(hw, TXGBE_VLANTBL(vid_idx), vfta);
858 /* update local VFTA copy */
859 shadow_vfta->vfta[vid_idx] = vfta;
865 txgbe_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue, int on)
867 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
868 struct txgbe_rx_queue *rxq;
870 uint32_t rxcfg, rxbal, rxbah;
873 txgbe_vlan_hw_strip_enable(dev, queue);
875 txgbe_vlan_hw_strip_disable(dev, queue);
877 rxq = dev->data->rx_queues[queue];
878 rxbal = rd32(hw, TXGBE_RXBAL(rxq->reg_idx));
879 rxbah = rd32(hw, TXGBE_RXBAH(rxq->reg_idx));
880 rxcfg = rd32(hw, TXGBE_RXCFG(rxq->reg_idx));
881 if (rxq->offloads & DEV_RX_OFFLOAD_VLAN_STRIP) {
882 restart = (rxcfg & TXGBE_RXCFG_ENA) &&
883 !(rxcfg & TXGBE_RXCFG_VLAN);
884 rxcfg |= TXGBE_RXCFG_VLAN;
886 restart = (rxcfg & TXGBE_RXCFG_ENA) &&
887 (rxcfg & TXGBE_RXCFG_VLAN);
888 rxcfg &= ~TXGBE_RXCFG_VLAN;
890 rxcfg &= ~TXGBE_RXCFG_ENA;
893 /* set vlan strip for ring */
894 txgbe_dev_rx_queue_stop(dev, queue);
895 wr32(hw, TXGBE_RXBAL(rxq->reg_idx), rxbal);
896 wr32(hw, TXGBE_RXBAH(rxq->reg_idx), rxbah);
897 wr32(hw, TXGBE_RXCFG(rxq->reg_idx), rxcfg);
898 txgbe_dev_rx_queue_start(dev, queue);
903 txgbe_vlan_tpid_set(struct rte_eth_dev *dev,
904 enum rte_vlan_type vlan_type,
907 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
909 uint32_t portctrl, vlan_ext, qinq;
911 portctrl = rd32(hw, TXGBE_PORTCTL);
913 vlan_ext = (portctrl & TXGBE_PORTCTL_VLANEXT);
914 qinq = vlan_ext && (portctrl & TXGBE_PORTCTL_QINQ);
916 case ETH_VLAN_TYPE_INNER:
918 wr32m(hw, TXGBE_VLANCTL,
919 TXGBE_VLANCTL_TPID_MASK,
920 TXGBE_VLANCTL_TPID(tpid));
921 wr32m(hw, TXGBE_DMATXCTRL,
922 TXGBE_DMATXCTRL_TPID_MASK,
923 TXGBE_DMATXCTRL_TPID(tpid));
926 PMD_DRV_LOG(ERR, "Inner type is not supported"
931 wr32m(hw, TXGBE_TAGTPID(0),
932 TXGBE_TAGTPID_LSB_MASK,
933 TXGBE_TAGTPID_LSB(tpid));
936 case ETH_VLAN_TYPE_OUTER:
938 /* Only the high 16-bits is valid */
939 wr32m(hw, TXGBE_EXTAG,
940 TXGBE_EXTAG_VLAN_MASK,
941 TXGBE_EXTAG_VLAN(tpid));
943 wr32m(hw, TXGBE_VLANCTL,
944 TXGBE_VLANCTL_TPID_MASK,
945 TXGBE_VLANCTL_TPID(tpid));
946 wr32m(hw, TXGBE_DMATXCTRL,
947 TXGBE_DMATXCTRL_TPID_MASK,
948 TXGBE_DMATXCTRL_TPID(tpid));
952 wr32m(hw, TXGBE_TAGTPID(0),
953 TXGBE_TAGTPID_MSB_MASK,
954 TXGBE_TAGTPID_MSB(tpid));
958 PMD_DRV_LOG(ERR, "Unsupported VLAN type %d", vlan_type);
966 txgbe_vlan_hw_filter_disable(struct rte_eth_dev *dev)
968 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
971 PMD_INIT_FUNC_TRACE();
973 /* Filter Table Disable */
974 vlnctrl = rd32(hw, TXGBE_VLANCTL);
975 vlnctrl &= ~TXGBE_VLANCTL_VFE;
976 wr32(hw, TXGBE_VLANCTL, vlnctrl);
980 txgbe_vlan_hw_filter_enable(struct rte_eth_dev *dev)
982 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
983 struct txgbe_vfta *shadow_vfta = TXGBE_DEV_VFTA(dev);
987 PMD_INIT_FUNC_TRACE();
989 /* Filter Table Enable */
990 vlnctrl = rd32(hw, TXGBE_VLANCTL);
991 vlnctrl &= ~TXGBE_VLANCTL_CFIENA;
992 vlnctrl |= TXGBE_VLANCTL_VFE;
993 wr32(hw, TXGBE_VLANCTL, vlnctrl);
995 /* write whatever is in local vfta copy */
996 for (i = 0; i < TXGBE_VFTA_SIZE; i++)
997 wr32(hw, TXGBE_VLANTBL(i), shadow_vfta->vfta[i]);
1001 txgbe_vlan_hw_strip_bitmap_set(struct rte_eth_dev *dev, uint16_t queue, bool on)
1003 struct txgbe_hwstrip *hwstrip = TXGBE_DEV_HWSTRIP(dev);
1004 struct txgbe_rx_queue *rxq;
1006 if (queue >= TXGBE_MAX_RX_QUEUE_NUM)
1010 TXGBE_SET_HWSTRIP(hwstrip, queue);
1012 TXGBE_CLEAR_HWSTRIP(hwstrip, queue);
1014 if (queue >= dev->data->nb_rx_queues)
1017 rxq = dev->data->rx_queues[queue];
1020 rxq->vlan_flags = PKT_RX_VLAN | PKT_RX_VLAN_STRIPPED;
1021 rxq->offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
1023 rxq->vlan_flags = PKT_RX_VLAN;
1024 rxq->offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
1029 txgbe_vlan_hw_strip_disable(struct rte_eth_dev *dev, uint16_t queue)
1031 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1034 PMD_INIT_FUNC_TRACE();
1036 ctrl = rd32(hw, TXGBE_RXCFG(queue));
1037 ctrl &= ~TXGBE_RXCFG_VLAN;
1038 wr32(hw, TXGBE_RXCFG(queue), ctrl);
1040 /* record those setting for HW strip per queue */
1041 txgbe_vlan_hw_strip_bitmap_set(dev, queue, 0);
1045 txgbe_vlan_hw_strip_enable(struct rte_eth_dev *dev, uint16_t queue)
1047 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1050 PMD_INIT_FUNC_TRACE();
1052 ctrl = rd32(hw, TXGBE_RXCFG(queue));
1053 ctrl |= TXGBE_RXCFG_VLAN;
1054 wr32(hw, TXGBE_RXCFG(queue), ctrl);
1056 /* record those setting for HW strip per queue */
1057 txgbe_vlan_hw_strip_bitmap_set(dev, queue, 1);
1061 txgbe_vlan_hw_extend_disable(struct rte_eth_dev *dev)
1063 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1066 PMD_INIT_FUNC_TRACE();
1068 ctrl = rd32(hw, TXGBE_PORTCTL);
1069 ctrl &= ~TXGBE_PORTCTL_VLANEXT;
1070 ctrl &= ~TXGBE_PORTCTL_QINQ;
1071 wr32(hw, TXGBE_PORTCTL, ctrl);
1075 txgbe_vlan_hw_extend_enable(struct rte_eth_dev *dev)
1077 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1078 struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
1079 struct rte_eth_txmode *txmode = &dev->data->dev_conf.txmode;
1082 PMD_INIT_FUNC_TRACE();
1084 ctrl = rd32(hw, TXGBE_PORTCTL);
1085 ctrl |= TXGBE_PORTCTL_VLANEXT;
1086 if (rxmode->offloads & DEV_RX_OFFLOAD_QINQ_STRIP ||
1087 txmode->offloads & DEV_TX_OFFLOAD_QINQ_INSERT)
1088 ctrl |= TXGBE_PORTCTL_QINQ;
1089 wr32(hw, TXGBE_PORTCTL, ctrl);
1093 txgbe_vlan_hw_strip_config(struct rte_eth_dev *dev)
1095 struct txgbe_rx_queue *rxq;
1098 PMD_INIT_FUNC_TRACE();
1100 for (i = 0; i < dev->data->nb_rx_queues; i++) {
1101 rxq = dev->data->rx_queues[i];
1103 if (rxq->offloads & DEV_RX_OFFLOAD_VLAN_STRIP)
1104 txgbe_vlan_strip_queue_set(dev, i, 1);
1106 txgbe_vlan_strip_queue_set(dev, i, 0);
1111 txgbe_config_vlan_strip_on_all_queues(struct rte_eth_dev *dev, int mask)
1114 struct rte_eth_rxmode *rxmode;
1115 struct txgbe_rx_queue *rxq;
1117 if (mask & ETH_VLAN_STRIP_MASK) {
1118 rxmode = &dev->data->dev_conf.rxmode;
1119 if (rxmode->offloads & DEV_RX_OFFLOAD_VLAN_STRIP)
1120 for (i = 0; i < dev->data->nb_rx_queues; i++) {
1121 rxq = dev->data->rx_queues[i];
1122 rxq->offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
1125 for (i = 0; i < dev->data->nb_rx_queues; i++) {
1126 rxq = dev->data->rx_queues[i];
1127 rxq->offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
1133 txgbe_vlan_offload_config(struct rte_eth_dev *dev, int mask)
1135 struct rte_eth_rxmode *rxmode;
1136 rxmode = &dev->data->dev_conf.rxmode;
1138 if (mask & ETH_VLAN_STRIP_MASK)
1139 txgbe_vlan_hw_strip_config(dev);
1141 if (mask & ETH_VLAN_FILTER_MASK) {
1142 if (rxmode->offloads & DEV_RX_OFFLOAD_VLAN_FILTER)
1143 txgbe_vlan_hw_filter_enable(dev);
1145 txgbe_vlan_hw_filter_disable(dev);
1148 if (mask & ETH_VLAN_EXTEND_MASK) {
1149 if (rxmode->offloads & DEV_RX_OFFLOAD_VLAN_EXTEND)
1150 txgbe_vlan_hw_extend_enable(dev);
1152 txgbe_vlan_hw_extend_disable(dev);
1159 txgbe_vlan_offload_set(struct rte_eth_dev *dev, int mask)
1161 txgbe_config_vlan_strip_on_all_queues(dev, mask);
1163 txgbe_vlan_offload_config(dev, mask);
1169 txgbe_vmdq_vlan_hw_filter_enable(struct rte_eth_dev *dev)
1171 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1172 /* VLNCTL: enable vlan filtering and allow all vlan tags through */
1173 uint32_t vlanctrl = rd32(hw, TXGBE_VLANCTL);
1175 vlanctrl |= TXGBE_VLANCTL_VFE; /* enable vlan filters */
1176 wr32(hw, TXGBE_VLANCTL, vlanctrl);
1180 txgbe_check_vf_rss_rxq_num(struct rte_eth_dev *dev, uint16_t nb_rx_q)
1182 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
1187 RTE_ETH_DEV_SRIOV(dev).active = ETH_64_POOLS;
1190 RTE_ETH_DEV_SRIOV(dev).active = ETH_32_POOLS;
1196 RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool =
1197 TXGBE_MAX_RX_QUEUE_NUM / RTE_ETH_DEV_SRIOV(dev).active;
1198 RTE_ETH_DEV_SRIOV(dev).def_pool_q_idx =
1199 pci_dev->max_vfs * RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool;
1204 txgbe_check_mq_mode(struct rte_eth_dev *dev)
1206 struct rte_eth_conf *dev_conf = &dev->data->dev_conf;
1207 uint16_t nb_rx_q = dev->data->nb_rx_queues;
1208 uint16_t nb_tx_q = dev->data->nb_tx_queues;
1210 if (RTE_ETH_DEV_SRIOV(dev).active != 0) {
1211 /* check multi-queue mode */
1212 switch (dev_conf->rxmode.mq_mode) {
1213 case ETH_MQ_RX_VMDQ_DCB:
1214 PMD_INIT_LOG(INFO, "ETH_MQ_RX_VMDQ_DCB mode supported in SRIOV");
1216 case ETH_MQ_RX_VMDQ_DCB_RSS:
1217 /* DCB/RSS VMDQ in SRIOV mode, not implement yet */
1218 PMD_INIT_LOG(ERR, "SRIOV active,"
1219 " unsupported mq_mode rx %d.",
1220 dev_conf->rxmode.mq_mode);
1223 case ETH_MQ_RX_VMDQ_RSS:
1224 dev->data->dev_conf.rxmode.mq_mode = ETH_MQ_RX_VMDQ_RSS;
1225 if (nb_rx_q <= RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool)
1226 if (txgbe_check_vf_rss_rxq_num(dev, nb_rx_q)) {
1227 PMD_INIT_LOG(ERR, "SRIOV is active,"
1228 " invalid queue number"
1229 " for VMDQ RSS, allowed"
1230 " value are 1, 2 or 4.");
1234 case ETH_MQ_RX_VMDQ_ONLY:
1235 case ETH_MQ_RX_NONE:
1236 /* if nothing mq mode configure, use default scheme */
1237 dev->data->dev_conf.rxmode.mq_mode =
1238 ETH_MQ_RX_VMDQ_ONLY;
1240 default: /* ETH_MQ_RX_DCB, ETH_MQ_RX_DCB_RSS or ETH_MQ_TX_DCB*/
1241 /* SRIOV only works in VMDq enable mode */
1242 PMD_INIT_LOG(ERR, "SRIOV is active,"
1243 " wrong mq_mode rx %d.",
1244 dev_conf->rxmode.mq_mode);
1248 switch (dev_conf->txmode.mq_mode) {
1249 case ETH_MQ_TX_VMDQ_DCB:
1250 PMD_INIT_LOG(INFO, "ETH_MQ_TX_VMDQ_DCB mode supported in SRIOV");
1251 dev->data->dev_conf.txmode.mq_mode = ETH_MQ_TX_VMDQ_DCB;
1253 default: /* ETH_MQ_TX_VMDQ_ONLY or ETH_MQ_TX_NONE */
1254 dev->data->dev_conf.txmode.mq_mode =
1255 ETH_MQ_TX_VMDQ_ONLY;
1259 /* check valid queue number */
1260 if ((nb_rx_q > RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool) ||
1261 (nb_tx_q > RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool)) {
1262 PMD_INIT_LOG(ERR, "SRIOV is active,"
1263 " nb_rx_q=%d nb_tx_q=%d queue number"
1264 " must be less than or equal to %d.",
1266 RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool);
1270 if (dev_conf->rxmode.mq_mode == ETH_MQ_RX_VMDQ_DCB_RSS) {
1271 PMD_INIT_LOG(ERR, "VMDQ+DCB+RSS mq_mode is"
1275 /* check configuration for vmdb+dcb mode */
1276 if (dev_conf->rxmode.mq_mode == ETH_MQ_RX_VMDQ_DCB) {
1277 const struct rte_eth_vmdq_dcb_conf *conf;
1279 if (nb_rx_q != TXGBE_VMDQ_DCB_NB_QUEUES) {
1280 PMD_INIT_LOG(ERR, "VMDQ+DCB, nb_rx_q != %d.",
1281 TXGBE_VMDQ_DCB_NB_QUEUES);
1284 conf = &dev_conf->rx_adv_conf.vmdq_dcb_conf;
1285 if (!(conf->nb_queue_pools == ETH_16_POOLS ||
1286 conf->nb_queue_pools == ETH_32_POOLS)) {
1287 PMD_INIT_LOG(ERR, "VMDQ+DCB selected,"
1288 " nb_queue_pools must be %d or %d.",
1289 ETH_16_POOLS, ETH_32_POOLS);
1293 if (dev_conf->txmode.mq_mode == ETH_MQ_TX_VMDQ_DCB) {
1294 const struct rte_eth_vmdq_dcb_tx_conf *conf;
1296 if (nb_tx_q != TXGBE_VMDQ_DCB_NB_QUEUES) {
1297 PMD_INIT_LOG(ERR, "VMDQ+DCB, nb_tx_q != %d",
1298 TXGBE_VMDQ_DCB_NB_QUEUES);
1301 conf = &dev_conf->tx_adv_conf.vmdq_dcb_tx_conf;
1302 if (!(conf->nb_queue_pools == ETH_16_POOLS ||
1303 conf->nb_queue_pools == ETH_32_POOLS)) {
1304 PMD_INIT_LOG(ERR, "VMDQ+DCB selected,"
1305 " nb_queue_pools != %d and"
1306 " nb_queue_pools != %d.",
1307 ETH_16_POOLS, ETH_32_POOLS);
1312 /* For DCB mode check our configuration before we go further */
1313 if (dev_conf->rxmode.mq_mode == ETH_MQ_RX_DCB) {
1314 const struct rte_eth_dcb_rx_conf *conf;
1316 conf = &dev_conf->rx_adv_conf.dcb_rx_conf;
1317 if (!(conf->nb_tcs == ETH_4_TCS ||
1318 conf->nb_tcs == ETH_8_TCS)) {
1319 PMD_INIT_LOG(ERR, "DCB selected, nb_tcs != %d"
1320 " and nb_tcs != %d.",
1321 ETH_4_TCS, ETH_8_TCS);
1326 if (dev_conf->txmode.mq_mode == ETH_MQ_TX_DCB) {
1327 const struct rte_eth_dcb_tx_conf *conf;
1329 conf = &dev_conf->tx_adv_conf.dcb_tx_conf;
1330 if (!(conf->nb_tcs == ETH_4_TCS ||
1331 conf->nb_tcs == ETH_8_TCS)) {
1332 PMD_INIT_LOG(ERR, "DCB selected, nb_tcs != %d"
1333 " and nb_tcs != %d.",
1334 ETH_4_TCS, ETH_8_TCS);
1343 txgbe_dev_configure(struct rte_eth_dev *dev)
1345 struct txgbe_interrupt *intr = TXGBE_DEV_INTR(dev);
1346 struct txgbe_adapter *adapter = TXGBE_DEV_ADAPTER(dev);
1349 PMD_INIT_FUNC_TRACE();
1351 if (dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_RSS_FLAG)
1352 dev->data->dev_conf.rxmode.offloads |= DEV_RX_OFFLOAD_RSS_HASH;
1354 /* multiple queue mode checking */
1355 ret = txgbe_check_mq_mode(dev);
1357 PMD_DRV_LOG(ERR, "txgbe_check_mq_mode fails with %d.",
1362 /* set flag to update link status after init */
1363 intr->flags |= TXGBE_FLAG_NEED_LINK_UPDATE;
1366 * Initialize to TRUE. If any of Rx queues doesn't meet the bulk
1367 * allocation Rx preconditions we will reset it.
1369 adapter->rx_bulk_alloc_allowed = true;
1375 txgbe_dev_phy_intr_setup(struct rte_eth_dev *dev)
1377 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1378 struct txgbe_interrupt *intr = TXGBE_DEV_INTR(dev);
1381 gpie = rd32(hw, TXGBE_GPIOINTEN);
1382 gpie |= TXGBE_GPIOBIT_6;
1383 wr32(hw, TXGBE_GPIOINTEN, gpie);
1384 intr->mask_misc |= TXGBE_ICRMISC_GPIO;
1388 txgbe_set_vf_rate_limit(struct rte_eth_dev *dev, uint16_t vf,
1389 uint16_t tx_rate, uint64_t q_msk)
1391 struct txgbe_hw *hw;
1392 struct txgbe_vf_info *vfinfo;
1393 struct rte_eth_link link;
1394 uint8_t nb_q_per_pool;
1395 uint32_t queue_stride;
1396 uint32_t queue_idx, idx = 0, vf_idx;
1398 uint16_t total_rate = 0;
1399 struct rte_pci_device *pci_dev;
1402 pci_dev = RTE_ETH_DEV_TO_PCI(dev);
1403 ret = rte_eth_link_get_nowait(dev->data->port_id, &link);
1407 if (vf >= pci_dev->max_vfs)
1410 if (tx_rate > link.link_speed)
1416 hw = TXGBE_DEV_HW(dev);
1417 vfinfo = *(TXGBE_DEV_VFDATA(dev));
1418 nb_q_per_pool = RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool;
1419 queue_stride = TXGBE_MAX_RX_QUEUE_NUM / RTE_ETH_DEV_SRIOV(dev).active;
1420 queue_idx = vf * queue_stride;
1421 queue_end = queue_idx + nb_q_per_pool - 1;
1422 if (queue_end >= hw->mac.max_tx_queues)
1426 for (vf_idx = 0; vf_idx < pci_dev->max_vfs; vf_idx++) {
1429 for (idx = 0; idx < RTE_DIM(vfinfo[vf_idx].tx_rate);
1431 total_rate += vfinfo[vf_idx].tx_rate[idx];
1437 /* Store tx_rate for this vf. */
1438 for (idx = 0; idx < nb_q_per_pool; idx++) {
1439 if (((uint64_t)0x1 << idx) & q_msk) {
1440 if (vfinfo[vf].tx_rate[idx] != tx_rate)
1441 vfinfo[vf].tx_rate[idx] = tx_rate;
1442 total_rate += tx_rate;
1446 if (total_rate > dev->data->dev_link.link_speed) {
1447 /* Reset stored TX rate of the VF if it causes exceed
1450 memset(vfinfo[vf].tx_rate, 0, sizeof(vfinfo[vf].tx_rate));
1454 /* Set ARBTXRATE of each queue/pool for vf X */
1455 for (; queue_idx <= queue_end; queue_idx++) {
1457 txgbe_set_queue_rate_limit(dev, queue_idx, tx_rate);
1465 * Configure device link speed and setup link.
1466 * It returns 0 on success.
1469 txgbe_dev_start(struct rte_eth_dev *dev)
1471 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1472 struct txgbe_hw_stats *hw_stats = TXGBE_DEV_STATS(dev);
1473 struct txgbe_vf_info *vfinfo = *TXGBE_DEV_VFDATA(dev);
1474 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
1475 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
1476 uint32_t intr_vector = 0;
1478 bool link_up = false, negotiate = 0;
1480 uint32_t allowed_speeds = 0;
1484 uint32_t *link_speeds;
1486 PMD_INIT_FUNC_TRACE();
1488 /* TXGBE devices don't support:
1489 * - half duplex (checked afterwards for valid speeds)
1490 * - fixed speed: TODO implement
1492 if (dev->data->dev_conf.link_speeds & ETH_LINK_SPEED_FIXED) {
1494 "Invalid link_speeds for port %u, fix speed not supported",
1495 dev->data->port_id);
1499 /* Stop the link setup handler before resetting the HW. */
1500 rte_eal_alarm_cancel(txgbe_dev_setup_link_alarm_handler, dev);
1502 /* disable uio/vfio intr/eventfd mapping */
1503 rte_intr_disable(intr_handle);
1506 hw->adapter_stopped = 0;
1509 /* reinitialize adapter
1510 * this calls reset and start
1512 hw->nb_rx_queues = dev->data->nb_rx_queues;
1513 hw->nb_tx_queues = dev->data->nb_tx_queues;
1514 status = txgbe_pf_reset_hw(hw);
1517 hw->mac.start_hw(hw);
1518 hw->mac.get_link_status = true;
1520 /* configure PF module if SRIOV enabled */
1521 txgbe_pf_host_configure(dev);
1523 txgbe_dev_phy_intr_setup(dev);
1525 /* check and configure queue intr-vector mapping */
1526 if ((rte_intr_cap_multiple(intr_handle) ||
1527 !RTE_ETH_DEV_SRIOV(dev).active) &&
1528 dev->data->dev_conf.intr_conf.rxq != 0) {
1529 intr_vector = dev->data->nb_rx_queues;
1530 if (rte_intr_efd_enable(intr_handle, intr_vector))
1534 if (rte_intr_dp_is_en(intr_handle) && !intr_handle->intr_vec) {
1535 intr_handle->intr_vec =
1536 rte_zmalloc("intr_vec",
1537 dev->data->nb_rx_queues * sizeof(int), 0);
1538 if (intr_handle->intr_vec == NULL) {
1539 PMD_INIT_LOG(ERR, "Failed to allocate %d rx_queues"
1540 " intr_vec", dev->data->nb_rx_queues);
1545 /* confiugre msix for sleep until rx interrupt */
1546 txgbe_configure_msix(dev);
1548 /* initialize transmission unit */
1549 txgbe_dev_tx_init(dev);
1551 /* This can fail when allocating mbufs for descriptor rings */
1552 err = txgbe_dev_rx_init(dev);
1554 PMD_INIT_LOG(ERR, "Unable to initialize RX hardware");
1558 mask = ETH_VLAN_STRIP_MASK | ETH_VLAN_FILTER_MASK |
1559 ETH_VLAN_EXTEND_MASK;
1560 err = txgbe_vlan_offload_config(dev, mask);
1562 PMD_INIT_LOG(ERR, "Unable to set VLAN offload");
1566 if (dev->data->dev_conf.rxmode.mq_mode == ETH_MQ_RX_VMDQ_ONLY) {
1567 /* Enable vlan filtering for VMDq */
1568 txgbe_vmdq_vlan_hw_filter_enable(dev);
1571 /* Configure DCB hw */
1572 txgbe_configure_pb(dev);
1573 txgbe_configure_port(dev);
1574 txgbe_configure_dcb(dev);
1576 /* Restore vf rate limit */
1577 if (vfinfo != NULL) {
1578 for (vf = 0; vf < pci_dev->max_vfs; vf++)
1579 for (idx = 0; idx < TXGBE_MAX_QUEUE_NUM_PER_VF; idx++)
1580 if (vfinfo[vf].tx_rate[idx] != 0)
1581 txgbe_set_vf_rate_limit(dev, vf,
1582 vfinfo[vf].tx_rate[idx],
1586 err = txgbe_dev_rxtx_start(dev);
1588 PMD_INIT_LOG(ERR, "Unable to start rxtx queues");
1592 /* Skip link setup if loopback mode is enabled. */
1593 if (hw->mac.type == txgbe_mac_raptor &&
1594 dev->data->dev_conf.lpbk_mode)
1595 goto skip_link_setup;
1597 if (txgbe_is_sfp(hw) && hw->phy.multispeed_fiber) {
1598 err = hw->mac.setup_sfp(hw);
1603 if (hw->phy.media_type == txgbe_media_type_copper) {
1604 /* Turn on the copper */
1605 hw->phy.set_phy_power(hw, true);
1607 /* Turn on the laser */
1608 hw->mac.enable_tx_laser(hw);
1611 err = hw->mac.check_link(hw, &speed, &link_up, 0);
1614 dev->data->dev_link.link_status = link_up;
1616 err = hw->mac.get_link_capabilities(hw, &speed, &negotiate);
1620 allowed_speeds = ETH_LINK_SPEED_100M | ETH_LINK_SPEED_1G |
1623 link_speeds = &dev->data->dev_conf.link_speeds;
1624 if (*link_speeds & ~allowed_speeds) {
1625 PMD_INIT_LOG(ERR, "Invalid link setting");
1630 if (*link_speeds == ETH_LINK_SPEED_AUTONEG) {
1631 speed = (TXGBE_LINK_SPEED_100M_FULL |
1632 TXGBE_LINK_SPEED_1GB_FULL |
1633 TXGBE_LINK_SPEED_10GB_FULL);
1635 if (*link_speeds & ETH_LINK_SPEED_10G)
1636 speed |= TXGBE_LINK_SPEED_10GB_FULL;
1637 if (*link_speeds & ETH_LINK_SPEED_5G)
1638 speed |= TXGBE_LINK_SPEED_5GB_FULL;
1639 if (*link_speeds & ETH_LINK_SPEED_2_5G)
1640 speed |= TXGBE_LINK_SPEED_2_5GB_FULL;
1641 if (*link_speeds & ETH_LINK_SPEED_1G)
1642 speed |= TXGBE_LINK_SPEED_1GB_FULL;
1643 if (*link_speeds & ETH_LINK_SPEED_100M)
1644 speed |= TXGBE_LINK_SPEED_100M_FULL;
1647 err = hw->mac.setup_link(hw, speed, link_up);
1653 if (rte_intr_allow_others(intr_handle)) {
1654 /* check if lsc interrupt is enabled */
1655 if (dev->data->dev_conf.intr_conf.lsc != 0)
1656 txgbe_dev_lsc_interrupt_setup(dev, TRUE);
1658 txgbe_dev_lsc_interrupt_setup(dev, FALSE);
1659 txgbe_dev_macsec_interrupt_setup(dev);
1660 txgbe_set_ivar_map(hw, -1, 1, TXGBE_MISC_VEC_ID);
1662 rte_intr_callback_unregister(intr_handle,
1663 txgbe_dev_interrupt_handler, dev);
1664 if (dev->data->dev_conf.intr_conf.lsc != 0)
1665 PMD_INIT_LOG(INFO, "lsc won't enable because of"
1666 " no intr multiplex");
1669 /* check if rxq interrupt is enabled */
1670 if (dev->data->dev_conf.intr_conf.rxq != 0 &&
1671 rte_intr_dp_is_en(intr_handle))
1672 txgbe_dev_rxq_interrupt_setup(dev);
1674 /* enable uio/vfio intr/eventfd mapping */
1675 rte_intr_enable(intr_handle);
1677 /* resume enabled intr since hw reset */
1678 txgbe_enable_intr(dev);
1679 txgbe_l2_tunnel_conf(dev);
1680 txgbe_filter_restore(dev);
1683 * Update link status right before return, because it may
1684 * start link configuration process in a separate thread.
1686 txgbe_dev_link_update(dev, 0);
1688 wr32m(hw, TXGBE_LEDCTL, 0xFFFFFFFF, TXGBE_LEDCTL_ORD_MASK);
1690 txgbe_read_stats_registers(hw, hw_stats);
1691 hw->offset_loaded = 1;
1696 PMD_INIT_LOG(ERR, "failure in dev start: %d", err);
1697 txgbe_dev_clear_queues(dev);
1702 * Stop device: disable rx and tx functions to allow for reconfiguring.
1705 txgbe_dev_stop(struct rte_eth_dev *dev)
1707 struct rte_eth_link link;
1708 struct txgbe_adapter *adapter = TXGBE_DEV_ADAPTER(dev);
1709 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1710 struct txgbe_vf_info *vfinfo = *TXGBE_DEV_VFDATA(dev);
1711 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
1712 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
1715 if (hw->adapter_stopped)
1718 PMD_INIT_FUNC_TRACE();
1720 rte_eal_alarm_cancel(txgbe_dev_setup_link_alarm_handler, dev);
1722 /* disable interrupts */
1723 txgbe_disable_intr(hw);
1726 txgbe_pf_reset_hw(hw);
1727 hw->adapter_stopped = 0;
1732 for (vf = 0; vfinfo != NULL && vf < pci_dev->max_vfs; vf++)
1733 vfinfo[vf].clear_to_send = false;
1735 if (hw->phy.media_type == txgbe_media_type_copper) {
1736 /* Turn off the copper */
1737 hw->phy.set_phy_power(hw, false);
1739 /* Turn off the laser */
1740 hw->mac.disable_tx_laser(hw);
1743 txgbe_dev_clear_queues(dev);
1745 /* Clear stored conf */
1746 dev->data->scattered_rx = 0;
1749 /* Clear recorded link status */
1750 memset(&link, 0, sizeof(link));
1751 rte_eth_linkstatus_set(dev, &link);
1753 if (!rte_intr_allow_others(intr_handle))
1754 /* resume to the default handler */
1755 rte_intr_callback_register(intr_handle,
1756 txgbe_dev_interrupt_handler,
1759 /* Clean datapath event and queue/vec mapping */
1760 rte_intr_efd_disable(intr_handle);
1761 if (intr_handle->intr_vec != NULL) {
1762 rte_free(intr_handle->intr_vec);
1763 intr_handle->intr_vec = NULL;
1766 adapter->rss_reta_updated = 0;
1767 wr32m(hw, TXGBE_LEDCTL, 0xFFFFFFFF, TXGBE_LEDCTL_SEL_MASK);
1769 hw->adapter_stopped = true;
1770 dev->data->dev_started = 0;
1776 * Set device link up: enable tx.
1779 txgbe_dev_set_link_up(struct rte_eth_dev *dev)
1781 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1783 if (hw->phy.media_type == txgbe_media_type_copper) {
1784 /* Turn on the copper */
1785 hw->phy.set_phy_power(hw, true);
1787 /* Turn on the laser */
1788 hw->mac.enable_tx_laser(hw);
1789 txgbe_dev_link_update(dev, 0);
1796 * Set device link down: disable tx.
1799 txgbe_dev_set_link_down(struct rte_eth_dev *dev)
1801 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1803 if (hw->phy.media_type == txgbe_media_type_copper) {
1804 /* Turn off the copper */
1805 hw->phy.set_phy_power(hw, false);
1807 /* Turn off the laser */
1808 hw->mac.disable_tx_laser(hw);
1809 txgbe_dev_link_update(dev, 0);
1816 * Reset and stop device.
1819 txgbe_dev_close(struct rte_eth_dev *dev)
1821 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1822 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
1823 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
1827 PMD_INIT_FUNC_TRACE();
1829 txgbe_pf_reset_hw(hw);
1831 ret = txgbe_dev_stop(dev);
1833 txgbe_dev_free_queues(dev);
1835 /* reprogram the RAR[0] in case user changed it. */
1836 txgbe_set_rar(hw, 0, hw->mac.addr, 0, true);
1838 /* Unlock any pending hardware semaphore */
1839 txgbe_swfw_lock_reset(hw);
1841 /* disable uio intr before callback unregister */
1842 rte_intr_disable(intr_handle);
1845 ret = rte_intr_callback_unregister(intr_handle,
1846 txgbe_dev_interrupt_handler, dev);
1847 if (ret >= 0 || ret == -ENOENT) {
1849 } else if (ret != -EAGAIN) {
1851 "intr callback unregister failed: %d",
1855 } while (retries++ < (10 + TXGBE_LINK_UP_TIME));
1857 /* cancel the delay handler before remove dev */
1858 rte_eal_alarm_cancel(txgbe_dev_interrupt_delayed_handler, dev);
1860 /* uninitialize PF if max_vfs not zero */
1861 txgbe_pf_host_uninit(dev);
1863 rte_free(dev->data->mac_addrs);
1864 dev->data->mac_addrs = NULL;
1866 rte_free(dev->data->hash_mac_addrs);
1867 dev->data->hash_mac_addrs = NULL;
1869 /* remove all the L2 tunnel filters & hash */
1870 txgbe_l2_tn_filter_uninit(dev);
1872 /* Remove all ntuple filters of the device */
1873 txgbe_ntuple_filter_uninit(dev);
1882 txgbe_dev_reset(struct rte_eth_dev *dev)
1886 /* When a DPDK PMD PF begin to reset PF port, it should notify all
1887 * its VF to make them align with it. The detailed notification
1888 * mechanism is PMD specific. As to txgbe PF, it is rather complex.
1889 * To avoid unexpected behavior in VF, currently reset of PF with
1890 * SR-IOV activation is not supported. It might be supported later.
1892 if (dev->data->sriov.active)
1895 ret = eth_txgbe_dev_uninit(dev);
1899 ret = eth_txgbe_dev_init(dev, NULL);
1904 #define UPDATE_QP_COUNTER_32bit(reg, last_counter, counter) \
1906 uint32_t current_counter = rd32(hw, reg); \
1907 if (current_counter < last_counter) \
1908 current_counter += 0x100000000LL; \
1909 if (!hw->offset_loaded) \
1910 last_counter = current_counter; \
1911 counter = current_counter - last_counter; \
1912 counter &= 0xFFFFFFFFLL; \
1915 #define UPDATE_QP_COUNTER_36bit(reg_lsb, reg_msb, last_counter, counter) \
1917 uint64_t current_counter_lsb = rd32(hw, reg_lsb); \
1918 uint64_t current_counter_msb = rd32(hw, reg_msb); \
1919 uint64_t current_counter = (current_counter_msb << 32) | \
1920 current_counter_lsb; \
1921 if (current_counter < last_counter) \
1922 current_counter += 0x1000000000LL; \
1923 if (!hw->offset_loaded) \
1924 last_counter = current_counter; \
1925 counter = current_counter - last_counter; \
1926 counter &= 0xFFFFFFFFFLL; \
1930 txgbe_read_stats_registers(struct txgbe_hw *hw,
1931 struct txgbe_hw_stats *hw_stats)
1936 for (i = 0; i < hw->nb_rx_queues; i++) {
1937 UPDATE_QP_COUNTER_32bit(TXGBE_QPRXPKT(i),
1938 hw->qp_last[i].rx_qp_packets,
1939 hw_stats->qp[i].rx_qp_packets);
1940 UPDATE_QP_COUNTER_36bit(TXGBE_QPRXOCTL(i), TXGBE_QPRXOCTH(i),
1941 hw->qp_last[i].rx_qp_bytes,
1942 hw_stats->qp[i].rx_qp_bytes);
1943 UPDATE_QP_COUNTER_32bit(TXGBE_QPRXMPKT(i),
1944 hw->qp_last[i].rx_qp_mc_packets,
1945 hw_stats->qp[i].rx_qp_mc_packets);
1948 for (i = 0; i < hw->nb_tx_queues; i++) {
1949 UPDATE_QP_COUNTER_32bit(TXGBE_QPTXPKT(i),
1950 hw->qp_last[i].tx_qp_packets,
1951 hw_stats->qp[i].tx_qp_packets);
1952 UPDATE_QP_COUNTER_36bit(TXGBE_QPTXOCTL(i), TXGBE_QPTXOCTH(i),
1953 hw->qp_last[i].tx_qp_bytes,
1954 hw_stats->qp[i].tx_qp_bytes);
1957 for (i = 0; i < TXGBE_MAX_UP; i++) {
1958 hw_stats->up[i].rx_up_xon_packets +=
1959 rd32(hw, TXGBE_PBRXUPXON(i));
1960 hw_stats->up[i].rx_up_xoff_packets +=
1961 rd32(hw, TXGBE_PBRXUPXOFF(i));
1962 hw_stats->up[i].tx_up_xon_packets +=
1963 rd32(hw, TXGBE_PBTXUPXON(i));
1964 hw_stats->up[i].tx_up_xoff_packets +=
1965 rd32(hw, TXGBE_PBTXUPXOFF(i));
1966 hw_stats->up[i].tx_up_xon2off_packets +=
1967 rd32(hw, TXGBE_PBTXUPOFF(i));
1968 hw_stats->up[i].rx_up_dropped +=
1969 rd32(hw, TXGBE_PBRXMISS(i));
1971 hw_stats->rx_xon_packets += rd32(hw, TXGBE_PBRXLNKXON);
1972 hw_stats->rx_xoff_packets += rd32(hw, TXGBE_PBRXLNKXOFF);
1973 hw_stats->tx_xon_packets += rd32(hw, TXGBE_PBTXLNKXON);
1974 hw_stats->tx_xoff_packets += rd32(hw, TXGBE_PBTXLNKXOFF);
1977 hw_stats->rx_packets += rd32(hw, TXGBE_DMARXPKT);
1978 hw_stats->tx_packets += rd32(hw, TXGBE_DMATXPKT);
1980 hw_stats->rx_bytes += rd64(hw, TXGBE_DMARXOCTL);
1981 hw_stats->tx_bytes += rd64(hw, TXGBE_DMATXOCTL);
1982 hw_stats->rx_drop_packets += rd32(hw, TXGBE_PBRXDROP);
1985 hw_stats->rx_crc_errors += rd64(hw, TXGBE_MACRXERRCRCL);
1986 hw_stats->rx_multicast_packets += rd64(hw, TXGBE_MACRXMPKTL);
1987 hw_stats->tx_multicast_packets += rd64(hw, TXGBE_MACTXMPKTL);
1989 hw_stats->rx_total_packets += rd64(hw, TXGBE_MACRXPKTL);
1990 hw_stats->tx_total_packets += rd64(hw, TXGBE_MACTXPKTL);
1991 hw_stats->rx_total_bytes += rd64(hw, TXGBE_MACRXGBOCTL);
1993 hw_stats->rx_broadcast_packets += rd64(hw, TXGBE_MACRXOCTL);
1994 hw_stats->tx_broadcast_packets += rd32(hw, TXGBE_MACTXOCTL);
1996 hw_stats->rx_size_64_packets += rd64(hw, TXGBE_MACRX1TO64L);
1997 hw_stats->rx_size_65_to_127_packets += rd64(hw, TXGBE_MACRX65TO127L);
1998 hw_stats->rx_size_128_to_255_packets += rd64(hw, TXGBE_MACRX128TO255L);
1999 hw_stats->rx_size_256_to_511_packets += rd64(hw, TXGBE_MACRX256TO511L);
2000 hw_stats->rx_size_512_to_1023_packets +=
2001 rd64(hw, TXGBE_MACRX512TO1023L);
2002 hw_stats->rx_size_1024_to_max_packets +=
2003 rd64(hw, TXGBE_MACRX1024TOMAXL);
2004 hw_stats->tx_size_64_packets += rd64(hw, TXGBE_MACTX1TO64L);
2005 hw_stats->tx_size_65_to_127_packets += rd64(hw, TXGBE_MACTX65TO127L);
2006 hw_stats->tx_size_128_to_255_packets += rd64(hw, TXGBE_MACTX128TO255L);
2007 hw_stats->tx_size_256_to_511_packets += rd64(hw, TXGBE_MACTX256TO511L);
2008 hw_stats->tx_size_512_to_1023_packets +=
2009 rd64(hw, TXGBE_MACTX512TO1023L);
2010 hw_stats->tx_size_1024_to_max_packets +=
2011 rd64(hw, TXGBE_MACTX1024TOMAXL);
2013 hw_stats->rx_undersize_errors += rd64(hw, TXGBE_MACRXERRLENL);
2014 hw_stats->rx_oversize_errors += rd32(hw, TXGBE_MACRXOVERSIZE);
2015 hw_stats->rx_jabber_errors += rd32(hw, TXGBE_MACRXJABBER);
2018 hw_stats->mng_bmc2host_packets = rd32(hw, TXGBE_MNGBMC2OS);
2019 hw_stats->mng_host2bmc_packets = rd32(hw, TXGBE_MNGOS2BMC);
2020 hw_stats->rx_management_packets = rd32(hw, TXGBE_DMARXMNG);
2021 hw_stats->tx_management_packets = rd32(hw, TXGBE_DMATXMNG);
2024 hw_stats->rx_fcoe_crc_errors += rd32(hw, TXGBE_FCOECRC);
2025 hw_stats->rx_fcoe_mbuf_allocation_errors += rd32(hw, TXGBE_FCOELAST);
2026 hw_stats->rx_fcoe_dropped += rd32(hw, TXGBE_FCOERPDC);
2027 hw_stats->rx_fcoe_packets += rd32(hw, TXGBE_FCOEPRC);
2028 hw_stats->tx_fcoe_packets += rd32(hw, TXGBE_FCOEPTC);
2029 hw_stats->rx_fcoe_bytes += rd32(hw, TXGBE_FCOEDWRC);
2030 hw_stats->tx_fcoe_bytes += rd32(hw, TXGBE_FCOEDWTC);
2032 /* Flow Director Stats */
2033 hw_stats->flow_director_matched_filters += rd32(hw, TXGBE_FDIRMATCH);
2034 hw_stats->flow_director_missed_filters += rd32(hw, TXGBE_FDIRMISS);
2035 hw_stats->flow_director_added_filters +=
2036 TXGBE_FDIRUSED_ADD(rd32(hw, TXGBE_FDIRUSED));
2037 hw_stats->flow_director_removed_filters +=
2038 TXGBE_FDIRUSED_REM(rd32(hw, TXGBE_FDIRUSED));
2039 hw_stats->flow_director_filter_add_errors +=
2040 TXGBE_FDIRFAIL_ADD(rd32(hw, TXGBE_FDIRFAIL));
2041 hw_stats->flow_director_filter_remove_errors +=
2042 TXGBE_FDIRFAIL_REM(rd32(hw, TXGBE_FDIRFAIL));
2045 hw_stats->tx_macsec_pkts_untagged += rd32(hw, TXGBE_LSECTX_UTPKT);
2046 hw_stats->tx_macsec_pkts_encrypted +=
2047 rd32(hw, TXGBE_LSECTX_ENCPKT);
2048 hw_stats->tx_macsec_pkts_protected +=
2049 rd32(hw, TXGBE_LSECTX_PROTPKT);
2050 hw_stats->tx_macsec_octets_encrypted +=
2051 rd32(hw, TXGBE_LSECTX_ENCOCT);
2052 hw_stats->tx_macsec_octets_protected +=
2053 rd32(hw, TXGBE_LSECTX_PROTOCT);
2054 hw_stats->rx_macsec_pkts_untagged += rd32(hw, TXGBE_LSECRX_UTPKT);
2055 hw_stats->rx_macsec_pkts_badtag += rd32(hw, TXGBE_LSECRX_BTPKT);
2056 hw_stats->rx_macsec_pkts_nosci += rd32(hw, TXGBE_LSECRX_NOSCIPKT);
2057 hw_stats->rx_macsec_pkts_unknownsci += rd32(hw, TXGBE_LSECRX_UNSCIPKT);
2058 hw_stats->rx_macsec_octets_decrypted += rd32(hw, TXGBE_LSECRX_DECOCT);
2059 hw_stats->rx_macsec_octets_validated += rd32(hw, TXGBE_LSECRX_VLDOCT);
2060 hw_stats->rx_macsec_sc_pkts_unchecked +=
2061 rd32(hw, TXGBE_LSECRX_UNCHKPKT);
2062 hw_stats->rx_macsec_sc_pkts_delayed += rd32(hw, TXGBE_LSECRX_DLYPKT);
2063 hw_stats->rx_macsec_sc_pkts_late += rd32(hw, TXGBE_LSECRX_LATEPKT);
2064 for (i = 0; i < 2; i++) {
2065 hw_stats->rx_macsec_sa_pkts_ok +=
2066 rd32(hw, TXGBE_LSECRX_OKPKT(i));
2067 hw_stats->rx_macsec_sa_pkts_invalid +=
2068 rd32(hw, TXGBE_LSECRX_INVPKT(i));
2069 hw_stats->rx_macsec_sa_pkts_notvalid +=
2070 rd32(hw, TXGBE_LSECRX_BADPKT(i));
2072 hw_stats->rx_macsec_sa_pkts_unusedsa +=
2073 rd32(hw, TXGBE_LSECRX_INVSAPKT);
2074 hw_stats->rx_macsec_sa_pkts_notusingsa +=
2075 rd32(hw, TXGBE_LSECRX_BADSAPKT);
2077 hw_stats->rx_total_missed_packets = 0;
2078 for (i = 0; i < TXGBE_MAX_UP; i++) {
2079 hw_stats->rx_total_missed_packets +=
2080 hw_stats->up[i].rx_up_dropped;
2085 txgbe_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
2087 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
2088 struct txgbe_hw_stats *hw_stats = TXGBE_DEV_STATS(dev);
2089 struct txgbe_stat_mappings *stat_mappings =
2090 TXGBE_DEV_STAT_MAPPINGS(dev);
2093 txgbe_read_stats_registers(hw, hw_stats);
2098 /* Fill out the rte_eth_stats statistics structure */
2099 stats->ipackets = hw_stats->rx_packets;
2100 stats->ibytes = hw_stats->rx_bytes;
2101 stats->opackets = hw_stats->tx_packets;
2102 stats->obytes = hw_stats->tx_bytes;
2104 memset(&stats->q_ipackets, 0, sizeof(stats->q_ipackets));
2105 memset(&stats->q_opackets, 0, sizeof(stats->q_opackets));
2106 memset(&stats->q_ibytes, 0, sizeof(stats->q_ibytes));
2107 memset(&stats->q_obytes, 0, sizeof(stats->q_obytes));
2108 memset(&stats->q_errors, 0, sizeof(stats->q_errors));
2109 for (i = 0; i < TXGBE_MAX_QP; i++) {
2110 uint32_t n = i / NB_QMAP_FIELDS_PER_QSM_REG;
2111 uint32_t offset = (i % NB_QMAP_FIELDS_PER_QSM_REG) * 8;
2114 q_map = (stat_mappings->rqsm[n] >> offset)
2115 & QMAP_FIELD_RESERVED_BITS_MASK;
2116 j = (q_map < RTE_ETHDEV_QUEUE_STAT_CNTRS
2117 ? q_map : q_map % RTE_ETHDEV_QUEUE_STAT_CNTRS);
2118 stats->q_ipackets[j] += hw_stats->qp[i].rx_qp_packets;
2119 stats->q_ibytes[j] += hw_stats->qp[i].rx_qp_bytes;
2121 q_map = (stat_mappings->tqsm[n] >> offset)
2122 & QMAP_FIELD_RESERVED_BITS_MASK;
2123 j = (q_map < RTE_ETHDEV_QUEUE_STAT_CNTRS
2124 ? q_map : q_map % RTE_ETHDEV_QUEUE_STAT_CNTRS);
2125 stats->q_opackets[j] += hw_stats->qp[i].tx_qp_packets;
2126 stats->q_obytes[j] += hw_stats->qp[i].tx_qp_bytes;
2130 stats->imissed = hw_stats->rx_total_missed_packets;
2131 stats->ierrors = hw_stats->rx_crc_errors +
2132 hw_stats->rx_mac_short_packet_dropped +
2133 hw_stats->rx_length_errors +
2134 hw_stats->rx_undersize_errors +
2135 hw_stats->rx_oversize_errors +
2136 hw_stats->rx_drop_packets +
2137 hw_stats->rx_illegal_byte_errors +
2138 hw_stats->rx_error_bytes +
2139 hw_stats->rx_fragment_errors +
2140 hw_stats->rx_fcoe_crc_errors +
2141 hw_stats->rx_fcoe_mbuf_allocation_errors;
2149 txgbe_dev_stats_reset(struct rte_eth_dev *dev)
2151 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
2152 struct txgbe_hw_stats *hw_stats = TXGBE_DEV_STATS(dev);
2154 /* HW registers are cleared on read */
2155 hw->offset_loaded = 0;
2156 txgbe_dev_stats_get(dev, NULL);
2157 hw->offset_loaded = 1;
2159 /* Reset software totals */
2160 memset(hw_stats, 0, sizeof(*hw_stats));
2165 /* This function calculates the number of xstats based on the current config */
2167 txgbe_xstats_calc_num(struct rte_eth_dev *dev)
2169 int nb_queues = max(dev->data->nb_rx_queues, dev->data->nb_tx_queues);
2170 return TXGBE_NB_HW_STATS +
2171 TXGBE_NB_UP_STATS * TXGBE_MAX_UP +
2172 TXGBE_NB_QP_STATS * nb_queues;
2176 txgbe_get_name_by_id(uint32_t id, char *name, uint32_t size)
2180 /* Extended stats from txgbe_hw_stats */
2181 if (id < TXGBE_NB_HW_STATS) {
2182 snprintf(name, size, "[hw]%s",
2183 rte_txgbe_stats_strings[id].name);
2186 id -= TXGBE_NB_HW_STATS;
2188 /* Priority Stats */
2189 if (id < TXGBE_NB_UP_STATS * TXGBE_MAX_UP) {
2190 nb = id / TXGBE_NB_UP_STATS;
2191 st = id % TXGBE_NB_UP_STATS;
2192 snprintf(name, size, "[p%u]%s", nb,
2193 rte_txgbe_up_strings[st].name);
2196 id -= TXGBE_NB_UP_STATS * TXGBE_MAX_UP;
2199 if (id < TXGBE_NB_QP_STATS * TXGBE_MAX_QP) {
2200 nb = id / TXGBE_NB_QP_STATS;
2201 st = id % TXGBE_NB_QP_STATS;
2202 snprintf(name, size, "[q%u]%s", nb,
2203 rte_txgbe_qp_strings[st].name);
2206 id -= TXGBE_NB_QP_STATS * TXGBE_MAX_QP;
2208 return -(int)(id + 1);
2212 txgbe_get_offset_by_id(uint32_t id, uint32_t *offset)
2216 /* Extended stats from txgbe_hw_stats */
2217 if (id < TXGBE_NB_HW_STATS) {
2218 *offset = rte_txgbe_stats_strings[id].offset;
2221 id -= TXGBE_NB_HW_STATS;
2223 /* Priority Stats */
2224 if (id < TXGBE_NB_UP_STATS * TXGBE_MAX_UP) {
2225 nb = id / TXGBE_NB_UP_STATS;
2226 st = id % TXGBE_NB_UP_STATS;
2227 *offset = rte_txgbe_up_strings[st].offset +
2228 nb * (TXGBE_NB_UP_STATS * sizeof(uint64_t));
2231 id -= TXGBE_NB_UP_STATS * TXGBE_MAX_UP;
2234 if (id < TXGBE_NB_QP_STATS * TXGBE_MAX_QP) {
2235 nb = id / TXGBE_NB_QP_STATS;
2236 st = id % TXGBE_NB_QP_STATS;
2237 *offset = rte_txgbe_qp_strings[st].offset +
2238 nb * (TXGBE_NB_QP_STATS * sizeof(uint64_t));
2245 static int txgbe_dev_xstats_get_names(struct rte_eth_dev *dev,
2246 struct rte_eth_xstat_name *xstats_names, unsigned int limit)
2248 unsigned int i, count;
2250 count = txgbe_xstats_calc_num(dev);
2251 if (xstats_names == NULL)
2254 /* Note: limit >= cnt_stats checked upstream
2255 * in rte_eth_xstats_names()
2257 limit = min(limit, count);
2259 /* Extended stats from txgbe_hw_stats */
2260 for (i = 0; i < limit; i++) {
2261 if (txgbe_get_name_by_id(i, xstats_names[i].name,
2262 sizeof(xstats_names[i].name))) {
2263 PMD_INIT_LOG(WARNING, "id value %d isn't valid", i);
2271 static int txgbe_dev_xstats_get_names_by_id(struct rte_eth_dev *dev,
2272 struct rte_eth_xstat_name *xstats_names,
2273 const uint64_t *ids,
2279 return txgbe_dev_xstats_get_names(dev, xstats_names, limit);
2281 for (i = 0; i < limit; i++) {
2282 if (txgbe_get_name_by_id(ids[i], xstats_names[i].name,
2283 sizeof(xstats_names[i].name))) {
2284 PMD_INIT_LOG(WARNING, "id value %d isn't valid", i);
2293 txgbe_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
2296 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
2297 struct txgbe_hw_stats *hw_stats = TXGBE_DEV_STATS(dev);
2298 unsigned int i, count;
2300 txgbe_read_stats_registers(hw, hw_stats);
2302 /* If this is a reset xstats is NULL, and we have cleared the
2303 * registers by reading them.
2305 count = txgbe_xstats_calc_num(dev);
2309 limit = min(limit, txgbe_xstats_calc_num(dev));
2311 /* Extended stats from txgbe_hw_stats */
2312 for (i = 0; i < limit; i++) {
2313 uint32_t offset = 0;
2315 if (txgbe_get_offset_by_id(i, &offset)) {
2316 PMD_INIT_LOG(WARNING, "id value %d isn't valid", i);
2319 xstats[i].value = *(uint64_t *)(((char *)hw_stats) + offset);
2327 txgbe_dev_xstats_get_(struct rte_eth_dev *dev, uint64_t *values,
2330 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
2331 struct txgbe_hw_stats *hw_stats = TXGBE_DEV_STATS(dev);
2332 unsigned int i, count;
2334 txgbe_read_stats_registers(hw, hw_stats);
2336 /* If this is a reset xstats is NULL, and we have cleared the
2337 * registers by reading them.
2339 count = txgbe_xstats_calc_num(dev);
2343 limit = min(limit, txgbe_xstats_calc_num(dev));
2345 /* Extended stats from txgbe_hw_stats */
2346 for (i = 0; i < limit; i++) {
2349 if (txgbe_get_offset_by_id(i, &offset)) {
2350 PMD_INIT_LOG(WARNING, "id value %d isn't valid", i);
2353 values[i] = *(uint64_t *)(((char *)hw_stats) + offset);
2360 txgbe_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids,
2361 uint64_t *values, unsigned int limit)
2363 struct txgbe_hw_stats *hw_stats = TXGBE_DEV_STATS(dev);
2367 return txgbe_dev_xstats_get_(dev, values, limit);
2369 for (i = 0; i < limit; i++) {
2372 if (txgbe_get_offset_by_id(ids[i], &offset)) {
2373 PMD_INIT_LOG(WARNING, "id value %d isn't valid", i);
2376 values[i] = *(uint64_t *)(((char *)hw_stats) + offset);
2383 txgbe_dev_xstats_reset(struct rte_eth_dev *dev)
2385 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
2386 struct txgbe_hw_stats *hw_stats = TXGBE_DEV_STATS(dev);
2388 /* HW registers are cleared on read */
2389 hw->offset_loaded = 0;
2390 txgbe_read_stats_registers(hw, hw_stats);
2391 hw->offset_loaded = 1;
2393 /* Reset software totals */
2394 memset(hw_stats, 0, sizeof(*hw_stats));
2400 txgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size)
2402 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
2403 u16 eeprom_verh, eeprom_verl;
2407 hw->rom.readw_sw(hw, TXGBE_EEPROM_VERSION_H, &eeprom_verh);
2408 hw->rom.readw_sw(hw, TXGBE_EEPROM_VERSION_L, &eeprom_verl);
2410 etrack_id = (eeprom_verh << 16) | eeprom_verl;
2411 ret = snprintf(fw_version, fw_size, "0x%08x", etrack_id);
2413 ret += 1; /* add the size of '\0' */
2414 if (fw_size < (u32)ret)
2421 txgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
2423 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
2424 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
2426 dev_info->max_rx_queues = (uint16_t)hw->mac.max_rx_queues;
2427 dev_info->max_tx_queues = (uint16_t)hw->mac.max_tx_queues;
2428 dev_info->min_rx_bufsize = 1024;
2429 dev_info->max_rx_pktlen = 15872;
2430 dev_info->max_mac_addrs = hw->mac.num_rar_entries;
2431 dev_info->max_hash_mac_addrs = TXGBE_VMDQ_NUM_UC_MAC;
2432 dev_info->max_vfs = pci_dev->max_vfs;
2433 dev_info->max_vmdq_pools = ETH_64_POOLS;
2434 dev_info->vmdq_queue_num = dev_info->max_rx_queues;
2435 dev_info->rx_queue_offload_capa = txgbe_get_rx_queue_offloads(dev);
2436 dev_info->rx_offload_capa = (txgbe_get_rx_port_offloads(dev) |
2437 dev_info->rx_queue_offload_capa);
2438 dev_info->tx_queue_offload_capa = txgbe_get_tx_queue_offloads(dev);
2439 dev_info->tx_offload_capa = txgbe_get_tx_port_offloads(dev);
2441 dev_info->default_rxconf = (struct rte_eth_rxconf) {
2443 .pthresh = TXGBE_DEFAULT_RX_PTHRESH,
2444 .hthresh = TXGBE_DEFAULT_RX_HTHRESH,
2445 .wthresh = TXGBE_DEFAULT_RX_WTHRESH,
2447 .rx_free_thresh = TXGBE_DEFAULT_RX_FREE_THRESH,
2452 dev_info->default_txconf = (struct rte_eth_txconf) {
2454 .pthresh = TXGBE_DEFAULT_TX_PTHRESH,
2455 .hthresh = TXGBE_DEFAULT_TX_HTHRESH,
2456 .wthresh = TXGBE_DEFAULT_TX_WTHRESH,
2458 .tx_free_thresh = TXGBE_DEFAULT_TX_FREE_THRESH,
2462 dev_info->rx_desc_lim = rx_desc_lim;
2463 dev_info->tx_desc_lim = tx_desc_lim;
2465 dev_info->hash_key_size = TXGBE_HKEY_MAX_INDEX * sizeof(uint32_t);
2466 dev_info->reta_size = ETH_RSS_RETA_SIZE_128;
2467 dev_info->flow_type_rss_offloads = TXGBE_RSS_OFFLOAD_ALL;
2469 dev_info->speed_capa = ETH_LINK_SPEED_1G | ETH_LINK_SPEED_10G;
2470 dev_info->speed_capa |= ETH_LINK_SPEED_100M;
2472 /* Driver-preferred Rx/Tx parameters */
2473 dev_info->default_rxportconf.burst_size = 32;
2474 dev_info->default_txportconf.burst_size = 32;
2475 dev_info->default_rxportconf.nb_queues = 1;
2476 dev_info->default_txportconf.nb_queues = 1;
2477 dev_info->default_rxportconf.ring_size = 256;
2478 dev_info->default_txportconf.ring_size = 256;
2484 txgbe_dev_supported_ptypes_get(struct rte_eth_dev *dev)
2486 if (dev->rx_pkt_burst == txgbe_recv_pkts ||
2487 dev->rx_pkt_burst == txgbe_recv_pkts_lro_single_alloc ||
2488 dev->rx_pkt_burst == txgbe_recv_pkts_lro_bulk_alloc ||
2489 dev->rx_pkt_burst == txgbe_recv_pkts_bulk_alloc)
2490 return txgbe_get_supported_ptypes();
2496 txgbe_dev_setup_link_alarm_handler(void *param)
2498 struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
2499 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
2500 struct txgbe_interrupt *intr = TXGBE_DEV_INTR(dev);
2502 bool autoneg = false;
2504 speed = hw->phy.autoneg_advertised;
2506 hw->mac.get_link_capabilities(hw, &speed, &autoneg);
2508 hw->mac.setup_link(hw, speed, true);
2510 intr->flags &= ~TXGBE_FLAG_NEED_LINK_CONFIG;
2513 /* return 0 means link status changed, -1 means not changed */
2515 txgbe_dev_link_update_share(struct rte_eth_dev *dev,
2516 int wait_to_complete)
2518 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
2519 struct rte_eth_link link;
2520 u32 link_speed = TXGBE_LINK_SPEED_UNKNOWN;
2521 struct txgbe_interrupt *intr = TXGBE_DEV_INTR(dev);
2526 memset(&link, 0, sizeof(link));
2527 link.link_status = ETH_LINK_DOWN;
2528 link.link_speed = ETH_SPEED_NUM_NONE;
2529 link.link_duplex = ETH_LINK_HALF_DUPLEX;
2530 link.link_autoneg = ETH_LINK_AUTONEG;
2532 hw->mac.get_link_status = true;
2534 if (intr->flags & TXGBE_FLAG_NEED_LINK_CONFIG)
2535 return rte_eth_linkstatus_set(dev, &link);
2537 /* check if it needs to wait to complete, if lsc interrupt is enabled */
2538 if (wait_to_complete == 0 || dev->data->dev_conf.intr_conf.lsc != 0)
2541 err = hw->mac.check_link(hw, &link_speed, &link_up, wait);
2544 link.link_speed = ETH_SPEED_NUM_100M;
2545 link.link_duplex = ETH_LINK_FULL_DUPLEX;
2546 return rte_eth_linkstatus_set(dev, &link);
2550 if (hw->phy.media_type == txgbe_media_type_fiber) {
2551 intr->flags |= TXGBE_FLAG_NEED_LINK_CONFIG;
2552 rte_eal_alarm_set(10,
2553 txgbe_dev_setup_link_alarm_handler, dev);
2555 return rte_eth_linkstatus_set(dev, &link);
2558 intr->flags &= ~TXGBE_FLAG_NEED_LINK_CONFIG;
2559 link.link_status = ETH_LINK_UP;
2560 link.link_duplex = ETH_LINK_FULL_DUPLEX;
2562 switch (link_speed) {
2564 case TXGBE_LINK_SPEED_UNKNOWN:
2565 link.link_duplex = ETH_LINK_FULL_DUPLEX;
2566 link.link_speed = ETH_SPEED_NUM_100M;
2569 case TXGBE_LINK_SPEED_100M_FULL:
2570 link.link_speed = ETH_SPEED_NUM_100M;
2573 case TXGBE_LINK_SPEED_1GB_FULL:
2574 link.link_speed = ETH_SPEED_NUM_1G;
2577 case TXGBE_LINK_SPEED_2_5GB_FULL:
2578 link.link_speed = ETH_SPEED_NUM_2_5G;
2581 case TXGBE_LINK_SPEED_5GB_FULL:
2582 link.link_speed = ETH_SPEED_NUM_5G;
2585 case TXGBE_LINK_SPEED_10GB_FULL:
2586 link.link_speed = ETH_SPEED_NUM_10G;
2590 return rte_eth_linkstatus_set(dev, &link);
2594 txgbe_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
2596 return txgbe_dev_link_update_share(dev, wait_to_complete);
2600 txgbe_dev_promiscuous_enable(struct rte_eth_dev *dev)
2602 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
2605 fctrl = rd32(hw, TXGBE_PSRCTL);
2606 fctrl |= (TXGBE_PSRCTL_UCP | TXGBE_PSRCTL_MCP);
2607 wr32(hw, TXGBE_PSRCTL, fctrl);
2613 txgbe_dev_promiscuous_disable(struct rte_eth_dev *dev)
2615 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
2618 fctrl = rd32(hw, TXGBE_PSRCTL);
2619 fctrl &= (~TXGBE_PSRCTL_UCP);
2620 if (dev->data->all_multicast == 1)
2621 fctrl |= TXGBE_PSRCTL_MCP;
2623 fctrl &= (~TXGBE_PSRCTL_MCP);
2624 wr32(hw, TXGBE_PSRCTL, fctrl);
2630 txgbe_dev_allmulticast_enable(struct rte_eth_dev *dev)
2632 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
2635 fctrl = rd32(hw, TXGBE_PSRCTL);
2636 fctrl |= TXGBE_PSRCTL_MCP;
2637 wr32(hw, TXGBE_PSRCTL, fctrl);
2643 txgbe_dev_allmulticast_disable(struct rte_eth_dev *dev)
2645 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
2648 if (dev->data->promiscuous == 1)
2649 return 0; /* must remain in all_multicast mode */
2651 fctrl = rd32(hw, TXGBE_PSRCTL);
2652 fctrl &= (~TXGBE_PSRCTL_MCP);
2653 wr32(hw, TXGBE_PSRCTL, fctrl);
2659 * It clears the interrupt causes and enables the interrupt.
2660 * It will be called once only during nic initialized.
2663 * Pointer to struct rte_eth_dev.
2665 * Enable or Disable.
2668 * - On success, zero.
2669 * - On failure, a negative value.
2672 txgbe_dev_lsc_interrupt_setup(struct rte_eth_dev *dev, uint8_t on)
2674 struct txgbe_interrupt *intr = TXGBE_DEV_INTR(dev);
2676 txgbe_dev_link_status_print(dev);
2678 intr->mask_misc |= TXGBE_ICRMISC_LSC;
2680 intr->mask_misc &= ~TXGBE_ICRMISC_LSC;
2686 * It clears the interrupt causes and enables the interrupt.
2687 * It will be called once only during nic initialized.
2690 * Pointer to struct rte_eth_dev.
2693 * - On success, zero.
2694 * - On failure, a negative value.
2697 txgbe_dev_rxq_interrupt_setup(struct rte_eth_dev *dev)
2699 struct txgbe_interrupt *intr = TXGBE_DEV_INTR(dev);
2701 intr->mask[0] |= TXGBE_ICR_MASK;
2702 intr->mask[1] |= TXGBE_ICR_MASK;
2708 * It clears the interrupt causes and enables the interrupt.
2709 * It will be called once only during nic initialized.
2712 * Pointer to struct rte_eth_dev.
2715 * - On success, zero.
2716 * - On failure, a negative value.
2719 txgbe_dev_macsec_interrupt_setup(struct rte_eth_dev *dev)
2721 struct txgbe_interrupt *intr = TXGBE_DEV_INTR(dev);
2723 intr->mask_misc |= TXGBE_ICRMISC_LNKSEC;
2729 * It reads ICR and sets flag (TXGBE_ICRMISC_LSC) for the link_update.
2732 * Pointer to struct rte_eth_dev.
2735 * - On success, zero.
2736 * - On failure, a negative value.
2739 txgbe_dev_interrupt_get_status(struct rte_eth_dev *dev)
2742 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
2743 struct txgbe_interrupt *intr = TXGBE_DEV_INTR(dev);
2745 /* clear all cause mask */
2746 txgbe_disable_intr(hw);
2748 /* read-on-clear nic registers here */
2749 eicr = ((u32 *)hw->isb_mem)[TXGBE_ISB_MISC];
2750 PMD_DRV_LOG(DEBUG, "eicr %x", eicr);
2754 /* set flag for async link update */
2755 if (eicr & TXGBE_ICRMISC_LSC)
2756 intr->flags |= TXGBE_FLAG_NEED_LINK_UPDATE;
2758 if (eicr & TXGBE_ICRMISC_VFMBX)
2759 intr->flags |= TXGBE_FLAG_MAILBOX;
2761 if (eicr & TXGBE_ICRMISC_LNKSEC)
2762 intr->flags |= TXGBE_FLAG_MACSEC;
2764 if (eicr & TXGBE_ICRMISC_GPIO)
2765 intr->flags |= TXGBE_FLAG_PHY_INTERRUPT;
2771 * It gets and then prints the link status.
2774 * Pointer to struct rte_eth_dev.
2777 * - On success, zero.
2778 * - On failure, a negative value.
2781 txgbe_dev_link_status_print(struct rte_eth_dev *dev)
2783 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
2784 struct rte_eth_link link;
2786 rte_eth_linkstatus_get(dev, &link);
2788 if (link.link_status) {
2789 PMD_INIT_LOG(INFO, "Port %d: Link Up - speed %u Mbps - %s",
2790 (int)(dev->data->port_id),
2791 (unsigned int)link.link_speed,
2792 link.link_duplex == ETH_LINK_FULL_DUPLEX ?
2793 "full-duplex" : "half-duplex");
2795 PMD_INIT_LOG(INFO, " Port %d: Link Down",
2796 (int)(dev->data->port_id));
2798 PMD_INIT_LOG(DEBUG, "PCI Address: " PCI_PRI_FMT,
2799 pci_dev->addr.domain,
2801 pci_dev->addr.devid,
2802 pci_dev->addr.function);
2806 * It executes link_update after knowing an interrupt occurred.
2809 * Pointer to struct rte_eth_dev.
2812 * - On success, zero.
2813 * - On failure, a negative value.
2816 txgbe_dev_interrupt_action(struct rte_eth_dev *dev,
2817 struct rte_intr_handle *intr_handle)
2819 struct txgbe_interrupt *intr = TXGBE_DEV_INTR(dev);
2821 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
2823 PMD_DRV_LOG(DEBUG, "intr action type %d", intr->flags);
2825 if (intr->flags & TXGBE_FLAG_MAILBOX) {
2826 txgbe_pf_mbx_process(dev);
2827 intr->flags &= ~TXGBE_FLAG_MAILBOX;
2830 if (intr->flags & TXGBE_FLAG_PHY_INTERRUPT) {
2831 hw->phy.handle_lasi(hw);
2832 intr->flags &= ~TXGBE_FLAG_PHY_INTERRUPT;
2835 if (intr->flags & TXGBE_FLAG_NEED_LINK_UPDATE) {
2836 struct rte_eth_link link;
2838 /*get the link status before link update, for predicting later*/
2839 rte_eth_linkstatus_get(dev, &link);
2841 txgbe_dev_link_update(dev, 0);
2844 if (!link.link_status)
2845 /* handle it 1 sec later, wait it being stable */
2846 timeout = TXGBE_LINK_UP_CHECK_TIMEOUT;
2847 /* likely to down */
2849 /* handle it 4 sec later, wait it being stable */
2850 timeout = TXGBE_LINK_DOWN_CHECK_TIMEOUT;
2852 txgbe_dev_link_status_print(dev);
2853 if (rte_eal_alarm_set(timeout * 1000,
2854 txgbe_dev_interrupt_delayed_handler,
2856 PMD_DRV_LOG(ERR, "Error setting alarm");
2858 /* remember original mask */
2859 intr->mask_misc_orig = intr->mask_misc;
2860 /* only disable lsc interrupt */
2861 intr->mask_misc &= ~TXGBE_ICRMISC_LSC;
2865 PMD_DRV_LOG(DEBUG, "enable intr immediately");
2866 txgbe_enable_intr(dev);
2867 rte_intr_enable(intr_handle);
2873 * Interrupt handler which shall be registered for alarm callback for delayed
2874 * handling specific interrupt to wait for the stable nic state. As the
2875 * NIC interrupt state is not stable for txgbe after link is just down,
2876 * it needs to wait 4 seconds to get the stable status.
2879 * Pointer to interrupt handle.
2881 * The address of parameter (struct rte_eth_dev *) registered before.
2887 txgbe_dev_interrupt_delayed_handler(void *param)
2889 struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
2890 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
2891 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
2892 struct txgbe_interrupt *intr = TXGBE_DEV_INTR(dev);
2893 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
2896 txgbe_disable_intr(hw);
2898 eicr = ((u32 *)hw->isb_mem)[TXGBE_ISB_MISC];
2899 if (eicr & TXGBE_ICRMISC_VFMBX)
2900 txgbe_pf_mbx_process(dev);
2902 if (intr->flags & TXGBE_FLAG_PHY_INTERRUPT) {
2903 hw->phy.handle_lasi(hw);
2904 intr->flags &= ~TXGBE_FLAG_PHY_INTERRUPT;
2907 if (intr->flags & TXGBE_FLAG_NEED_LINK_UPDATE) {
2908 txgbe_dev_link_update(dev, 0);
2909 intr->flags &= ~TXGBE_FLAG_NEED_LINK_UPDATE;
2910 txgbe_dev_link_status_print(dev);
2911 rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC,
2915 if (intr->flags & TXGBE_FLAG_MACSEC) {
2916 rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_MACSEC,
2918 intr->flags &= ~TXGBE_FLAG_MACSEC;
2921 /* restore original mask */
2922 intr->mask_misc = intr->mask_misc_orig;
2923 intr->mask_misc_orig = 0;
2925 PMD_DRV_LOG(DEBUG, "enable intr in delayed handler S[%08x]", eicr);
2926 txgbe_enable_intr(dev);
2927 rte_intr_enable(intr_handle);
2931 * Interrupt handler triggered by NIC for handling
2932 * specific interrupt.
2935 * Pointer to interrupt handle.
2937 * The address of parameter (struct rte_eth_dev *) registered before.
2943 txgbe_dev_interrupt_handler(void *param)
2945 struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
2947 txgbe_dev_interrupt_get_status(dev);
2948 txgbe_dev_interrupt_action(dev, dev->intr_handle);
2952 txgbe_dev_led_on(struct rte_eth_dev *dev)
2954 struct txgbe_hw *hw;
2956 hw = TXGBE_DEV_HW(dev);
2957 return txgbe_led_on(hw, 4) == 0 ? 0 : -ENOTSUP;
2961 txgbe_dev_led_off(struct rte_eth_dev *dev)
2963 struct txgbe_hw *hw;
2965 hw = TXGBE_DEV_HW(dev);
2966 return txgbe_led_off(hw, 4) == 0 ? 0 : -ENOTSUP;
2970 txgbe_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
2972 struct txgbe_hw *hw;
2978 hw = TXGBE_DEV_HW(dev);
2980 fc_conf->pause_time = hw->fc.pause_time;
2981 fc_conf->high_water = hw->fc.high_water[0];
2982 fc_conf->low_water = hw->fc.low_water[0];
2983 fc_conf->send_xon = hw->fc.send_xon;
2984 fc_conf->autoneg = !hw->fc.disable_fc_autoneg;
2987 * Return rx_pause status according to actual setting of
2990 mflcn_reg = rd32(hw, TXGBE_RXFCCFG);
2991 if (mflcn_reg & (TXGBE_RXFCCFG_FC | TXGBE_RXFCCFG_PFC))
2997 * Return tx_pause status according to actual setting of
3000 fccfg_reg = rd32(hw, TXGBE_TXFCCFG);
3001 if (fccfg_reg & (TXGBE_TXFCCFG_FC | TXGBE_TXFCCFG_PFC))
3006 if (rx_pause && tx_pause)
3007 fc_conf->mode = RTE_FC_FULL;
3009 fc_conf->mode = RTE_FC_RX_PAUSE;
3011 fc_conf->mode = RTE_FC_TX_PAUSE;
3013 fc_conf->mode = RTE_FC_NONE;
3019 txgbe_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
3021 struct txgbe_hw *hw;
3023 uint32_t rx_buf_size;
3024 uint32_t max_high_water;
3025 enum txgbe_fc_mode rte_fcmode_2_txgbe_fcmode[] = {
3032 PMD_INIT_FUNC_TRACE();
3034 hw = TXGBE_DEV_HW(dev);
3035 rx_buf_size = rd32(hw, TXGBE_PBRXSIZE(0));
3036 PMD_INIT_LOG(DEBUG, "Rx packet buffer size = 0x%x", rx_buf_size);
3039 * At least reserve one Ethernet frame for watermark
3040 * high_water/low_water in kilo bytes for txgbe
3042 max_high_water = (rx_buf_size - RTE_ETHER_MAX_LEN) >> 10;
3043 if (fc_conf->high_water > max_high_water ||
3044 fc_conf->high_water < fc_conf->low_water) {
3045 PMD_INIT_LOG(ERR, "Invalid high/low water setup value in KB");
3046 PMD_INIT_LOG(ERR, "High_water must <= 0x%x", max_high_water);
3050 hw->fc.requested_mode = rte_fcmode_2_txgbe_fcmode[fc_conf->mode];
3051 hw->fc.pause_time = fc_conf->pause_time;
3052 hw->fc.high_water[0] = fc_conf->high_water;
3053 hw->fc.low_water[0] = fc_conf->low_water;
3054 hw->fc.send_xon = fc_conf->send_xon;
3055 hw->fc.disable_fc_autoneg = !fc_conf->autoneg;
3057 err = txgbe_fc_enable(hw);
3059 /* Not negotiated is not an error case */
3060 if (err == 0 || err == TXGBE_ERR_FC_NOT_NEGOTIATED) {
3061 wr32m(hw, TXGBE_MACRXFLT, TXGBE_MACRXFLT_CTL_MASK,
3062 (fc_conf->mac_ctrl_frame_fwd
3063 ? TXGBE_MACRXFLT_CTL_NOPS : TXGBE_MACRXFLT_CTL_DROP));
3069 PMD_INIT_LOG(ERR, "txgbe_fc_enable = 0x%x", err);
3074 txgbe_priority_flow_ctrl_set(struct rte_eth_dev *dev,
3075 struct rte_eth_pfc_conf *pfc_conf)
3078 uint32_t rx_buf_size;
3079 uint32_t max_high_water;
3081 uint8_t map[TXGBE_DCB_UP_MAX] = { 0 };
3082 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
3083 struct txgbe_dcb_config *dcb_config = TXGBE_DEV_DCB_CONFIG(dev);
3085 enum txgbe_fc_mode rte_fcmode_2_txgbe_fcmode[] = {
3092 PMD_INIT_FUNC_TRACE();
3094 txgbe_dcb_unpack_map_cee(dcb_config, TXGBE_DCB_RX_CONFIG, map);
3095 tc_num = map[pfc_conf->priority];
3096 rx_buf_size = rd32(hw, TXGBE_PBRXSIZE(tc_num));
3097 PMD_INIT_LOG(DEBUG, "Rx packet buffer size = 0x%x", rx_buf_size);
3099 * At least reserve one Ethernet frame for watermark
3100 * high_water/low_water in kilo bytes for txgbe
3102 max_high_water = (rx_buf_size - RTE_ETHER_MAX_LEN) >> 10;
3103 if (pfc_conf->fc.high_water > max_high_water ||
3104 pfc_conf->fc.high_water <= pfc_conf->fc.low_water) {
3105 PMD_INIT_LOG(ERR, "Invalid high/low water setup value in KB");
3106 PMD_INIT_LOG(ERR, "High_water must <= 0x%x", max_high_water);
3110 hw->fc.requested_mode = rte_fcmode_2_txgbe_fcmode[pfc_conf->fc.mode];
3111 hw->fc.pause_time = pfc_conf->fc.pause_time;
3112 hw->fc.send_xon = pfc_conf->fc.send_xon;
3113 hw->fc.low_water[tc_num] = pfc_conf->fc.low_water;
3114 hw->fc.high_water[tc_num] = pfc_conf->fc.high_water;
3116 err = txgbe_dcb_pfc_enable(hw, tc_num);
3118 /* Not negotiated is not an error case */
3119 if (err == 0 || err == TXGBE_ERR_FC_NOT_NEGOTIATED)
3122 PMD_INIT_LOG(ERR, "txgbe_dcb_pfc_enable = 0x%x", err);
3127 txgbe_dev_rss_reta_update(struct rte_eth_dev *dev,
3128 struct rte_eth_rss_reta_entry64 *reta_conf,
3133 uint16_t idx, shift;
3134 struct txgbe_adapter *adapter = TXGBE_DEV_ADAPTER(dev);
3135 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
3137 PMD_INIT_FUNC_TRACE();
3139 if (!txgbe_rss_update_sp(hw->mac.type)) {
3140 PMD_DRV_LOG(ERR, "RSS reta update is not supported on this "
3145 if (reta_size != ETH_RSS_RETA_SIZE_128) {
3146 PMD_DRV_LOG(ERR, "The size of hash lookup table configured "
3147 "(%d) doesn't match the number hardware can supported "
3148 "(%d)", reta_size, ETH_RSS_RETA_SIZE_128);
3152 for (i = 0; i < reta_size; i += 4) {
3153 idx = i / RTE_RETA_GROUP_SIZE;
3154 shift = i % RTE_RETA_GROUP_SIZE;
3155 mask = (uint8_t)RS64(reta_conf[idx].mask, shift, 0xF);
3159 reta = rd32a(hw, TXGBE_REG_RSSTBL, i >> 2);
3160 for (j = 0; j < 4; j++) {
3161 if (RS8(mask, j, 0x1)) {
3162 reta &= ~(MS32(8 * j, 0xFF));
3163 reta |= LS32(reta_conf[idx].reta[shift + j],
3167 wr32a(hw, TXGBE_REG_RSSTBL, i >> 2, reta);
3169 adapter->rss_reta_updated = 1;
3175 txgbe_dev_rss_reta_query(struct rte_eth_dev *dev,
3176 struct rte_eth_rss_reta_entry64 *reta_conf,
3179 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
3182 uint16_t idx, shift;
3184 PMD_INIT_FUNC_TRACE();
3186 if (reta_size != ETH_RSS_RETA_SIZE_128) {
3187 PMD_DRV_LOG(ERR, "The size of hash lookup table configured "
3188 "(%d) doesn't match the number hardware can supported "
3189 "(%d)", reta_size, ETH_RSS_RETA_SIZE_128);
3193 for (i = 0; i < reta_size; i += 4) {
3194 idx = i / RTE_RETA_GROUP_SIZE;
3195 shift = i % RTE_RETA_GROUP_SIZE;
3196 mask = (uint8_t)RS64(reta_conf[idx].mask, shift, 0xF);
3200 reta = rd32a(hw, TXGBE_REG_RSSTBL, i >> 2);
3201 for (j = 0; j < 4; j++) {
3202 if (RS8(mask, j, 0x1))
3203 reta_conf[idx].reta[shift + j] =
3204 (uint16_t)RS32(reta, 8 * j, 0xFF);
3212 txgbe_add_rar(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr,
3213 uint32_t index, uint32_t pool)
3215 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
3216 uint32_t enable_addr = 1;
3218 return txgbe_set_rar(hw, index, mac_addr->addr_bytes,
3223 txgbe_remove_rar(struct rte_eth_dev *dev, uint32_t index)
3225 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
3227 txgbe_clear_rar(hw, index);
3231 txgbe_set_default_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *addr)
3233 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
3235 txgbe_remove_rar(dev, 0);
3236 txgbe_add_rar(dev, addr, 0, pci_dev->max_vfs);
3242 txgbe_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
3244 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
3245 struct rte_eth_dev_info dev_info;
3246 uint32_t frame_size = mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN;
3247 struct rte_eth_dev_data *dev_data = dev->data;
3250 ret = txgbe_dev_info_get(dev, &dev_info);
3254 /* check that mtu is within the allowed range */
3255 if (mtu < RTE_ETHER_MIN_MTU || frame_size > dev_info.max_rx_pktlen)
3258 /* If device is started, refuse mtu that requires the support of
3259 * scattered packets when this feature has not been enabled before.
3261 if (dev_data->dev_started && !dev_data->scattered_rx &&
3262 (frame_size + 2 * TXGBE_VLAN_TAG_SIZE >
3263 dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM)) {
3264 PMD_INIT_LOG(ERR, "Stop port first.");
3268 /* update max frame size */
3269 dev->data->dev_conf.rxmode.max_rx_pkt_len = frame_size;
3272 wr32m(hw, TXGBE_FRMSZ, TXGBE_FRMSZ_MAX_MASK,
3273 TXGBE_FRAME_SIZE_MAX);
3275 wr32m(hw, TXGBE_FRMSZ, TXGBE_FRMSZ_MAX_MASK,
3276 TXGBE_FRMSZ_MAX(frame_size));
3282 txgbe_uta_vector(struct txgbe_hw *hw, struct rte_ether_addr *uc_addr)
3284 uint32_t vector = 0;
3286 switch (hw->mac.mc_filter_type) {
3287 case 0: /* use bits [47:36] of the address */
3288 vector = ((uc_addr->addr_bytes[4] >> 4) |
3289 (((uint16_t)uc_addr->addr_bytes[5]) << 4));
3291 case 1: /* use bits [46:35] of the address */
3292 vector = ((uc_addr->addr_bytes[4] >> 3) |
3293 (((uint16_t)uc_addr->addr_bytes[5]) << 5));
3295 case 2: /* use bits [45:34] of the address */
3296 vector = ((uc_addr->addr_bytes[4] >> 2) |
3297 (((uint16_t)uc_addr->addr_bytes[5]) << 6));
3299 case 3: /* use bits [43:32] of the address */
3300 vector = ((uc_addr->addr_bytes[4]) |
3301 (((uint16_t)uc_addr->addr_bytes[5]) << 8));
3303 default: /* Invalid mc_filter_type */
3307 /* vector can only be 12-bits or boundary will be exceeded */
3313 txgbe_uc_hash_table_set(struct rte_eth_dev *dev,
3314 struct rte_ether_addr *mac_addr, uint8_t on)
3322 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
3323 struct txgbe_uta_info *uta_info = TXGBE_DEV_UTA_INFO(dev);
3325 /* The UTA table only exists on pf hardware */
3326 if (hw->mac.type < txgbe_mac_raptor)
3329 vector = txgbe_uta_vector(hw, mac_addr);
3330 uta_idx = (vector >> 5) & 0x7F;
3331 uta_mask = 0x1UL << (vector & 0x1F);
3333 if (!!on == !!(uta_info->uta_shadow[uta_idx] & uta_mask))
3336 reg_val = rd32(hw, TXGBE_UCADDRTBL(uta_idx));
3338 uta_info->uta_in_use++;
3339 reg_val |= uta_mask;
3340 uta_info->uta_shadow[uta_idx] |= uta_mask;
3342 uta_info->uta_in_use--;
3343 reg_val &= ~uta_mask;
3344 uta_info->uta_shadow[uta_idx] &= ~uta_mask;
3347 wr32(hw, TXGBE_UCADDRTBL(uta_idx), reg_val);
3349 psrctl = rd32(hw, TXGBE_PSRCTL);
3350 if (uta_info->uta_in_use > 0)
3351 psrctl |= TXGBE_PSRCTL_UCHFENA;
3353 psrctl &= ~TXGBE_PSRCTL_UCHFENA;
3355 psrctl &= ~TXGBE_PSRCTL_ADHF12_MASK;
3356 psrctl |= TXGBE_PSRCTL_ADHF12(hw->mac.mc_filter_type);
3357 wr32(hw, TXGBE_PSRCTL, psrctl);
3363 txgbe_uc_all_hash_table_set(struct rte_eth_dev *dev, uint8_t on)
3365 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
3366 struct txgbe_uta_info *uta_info = TXGBE_DEV_UTA_INFO(dev);
3370 /* The UTA table only exists on pf hardware */
3371 if (hw->mac.type < txgbe_mac_raptor)
3375 for (i = 0; i < ETH_VMDQ_NUM_UC_HASH_ARRAY; i++) {
3376 uta_info->uta_shadow[i] = ~0;
3377 wr32(hw, TXGBE_UCADDRTBL(i), ~0);
3380 for (i = 0; i < ETH_VMDQ_NUM_UC_HASH_ARRAY; i++) {
3381 uta_info->uta_shadow[i] = 0;
3382 wr32(hw, TXGBE_UCADDRTBL(i), 0);
3386 psrctl = rd32(hw, TXGBE_PSRCTL);
3388 psrctl |= TXGBE_PSRCTL_UCHFENA;
3390 psrctl &= ~TXGBE_PSRCTL_UCHFENA;
3392 psrctl &= ~TXGBE_PSRCTL_ADHF12_MASK;
3393 psrctl |= TXGBE_PSRCTL_ADHF12(hw->mac.mc_filter_type);
3394 wr32(hw, TXGBE_PSRCTL, psrctl);
3400 txgbe_convert_vm_rx_mask_to_val(uint16_t rx_mask, uint32_t orig_val)
3402 uint32_t new_val = orig_val;
3404 if (rx_mask & ETH_VMDQ_ACCEPT_UNTAG)
3405 new_val |= TXGBE_POOLETHCTL_UTA;
3406 if (rx_mask & ETH_VMDQ_ACCEPT_HASH_MC)
3407 new_val |= TXGBE_POOLETHCTL_MCHA;
3408 if (rx_mask & ETH_VMDQ_ACCEPT_HASH_UC)
3409 new_val |= TXGBE_POOLETHCTL_UCHA;
3410 if (rx_mask & ETH_VMDQ_ACCEPT_BROADCAST)
3411 new_val |= TXGBE_POOLETHCTL_BCA;
3412 if (rx_mask & ETH_VMDQ_ACCEPT_MULTICAST)
3413 new_val |= TXGBE_POOLETHCTL_MCP;
3419 txgbe_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
3421 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
3422 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
3424 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
3426 if (queue_id < 32) {
3427 mask = rd32(hw, TXGBE_IMS(0));
3428 mask &= (1 << queue_id);
3429 wr32(hw, TXGBE_IMS(0), mask);
3430 } else if (queue_id < 64) {
3431 mask = rd32(hw, TXGBE_IMS(1));
3432 mask &= (1 << (queue_id - 32));
3433 wr32(hw, TXGBE_IMS(1), mask);
3435 rte_intr_enable(intr_handle);
3441 txgbe_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id)
3444 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
3446 if (queue_id < 32) {
3447 mask = rd32(hw, TXGBE_IMS(0));
3448 mask &= ~(1 << queue_id);
3449 wr32(hw, TXGBE_IMS(0), mask);
3450 } else if (queue_id < 64) {
3451 mask = rd32(hw, TXGBE_IMS(1));
3452 mask &= ~(1 << (queue_id - 32));
3453 wr32(hw, TXGBE_IMS(1), mask);
3460 * set the IVAR registers, mapping interrupt causes to vectors
3462 * pointer to txgbe_hw struct
3464 * 0 for Rx, 1 for Tx, -1 for other causes
3466 * queue to map the corresponding interrupt to
3468 * the vector to map to the corresponding queue
3471 txgbe_set_ivar_map(struct txgbe_hw *hw, int8_t direction,
3472 uint8_t queue, uint8_t msix_vector)
3476 if (direction == -1) {
3478 msix_vector |= TXGBE_IVARMISC_VLD;
3480 tmp = rd32(hw, TXGBE_IVARMISC);
3481 tmp &= ~(0xFF << idx);
3482 tmp |= (msix_vector << idx);
3483 wr32(hw, TXGBE_IVARMISC, tmp);
3485 /* rx or tx causes */
3486 /* Workround for ICR lost */
3487 idx = ((16 * (queue & 1)) + (8 * direction));
3488 tmp = rd32(hw, TXGBE_IVAR(queue >> 1));
3489 tmp &= ~(0xFF << idx);
3490 tmp |= (msix_vector << idx);
3491 wr32(hw, TXGBE_IVAR(queue >> 1), tmp);
3496 * Sets up the hardware to properly generate MSI-X interrupts
3498 * board private structure
3501 txgbe_configure_msix(struct rte_eth_dev *dev)
3503 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
3504 struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
3505 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
3506 uint32_t queue_id, base = TXGBE_MISC_VEC_ID;
3507 uint32_t vec = TXGBE_MISC_VEC_ID;
3510 /* won't configure msix register if no mapping is done
3511 * between intr vector and event fd
3512 * but if misx has been enabled already, need to configure
3513 * auto clean, auto mask and throttling.
3515 gpie = rd32(hw, TXGBE_GPIE);
3516 if (!rte_intr_dp_is_en(intr_handle) &&
3517 !(gpie & TXGBE_GPIE_MSIX))
3520 if (rte_intr_allow_others(intr_handle)) {
3521 base = TXGBE_RX_VEC_START;
3525 /* setup GPIE for MSI-x mode */
3526 gpie = rd32(hw, TXGBE_GPIE);
3527 gpie |= TXGBE_GPIE_MSIX;
3528 wr32(hw, TXGBE_GPIE, gpie);
3530 /* Populate the IVAR table and set the ITR values to the
3531 * corresponding register.
3533 if (rte_intr_dp_is_en(intr_handle)) {
3534 for (queue_id = 0; queue_id < dev->data->nb_rx_queues;
3536 /* by default, 1:1 mapping */
3537 txgbe_set_ivar_map(hw, 0, queue_id, vec);
3538 intr_handle->intr_vec[queue_id] = vec;
3539 if (vec < base + intr_handle->nb_efd - 1)
3543 txgbe_set_ivar_map(hw, -1, 1, TXGBE_MISC_VEC_ID);
3545 wr32(hw, TXGBE_ITR(TXGBE_MISC_VEC_ID),
3546 TXGBE_ITR_IVAL_10G(TXGBE_QUEUE_ITR_INTERVAL_DEFAULT)
3551 txgbe_set_queue_rate_limit(struct rte_eth_dev *dev,
3552 uint16_t queue_idx, uint16_t tx_rate)
3554 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
3557 if (queue_idx >= hw->mac.max_tx_queues)
3561 bcnrc_val = TXGBE_ARBTXRATE_MAX(tx_rate);
3562 bcnrc_val |= TXGBE_ARBTXRATE_MIN(tx_rate / 2);
3568 * Set global transmit compensation time to the MMW_SIZE in ARBTXMMW
3569 * register. MMW_SIZE=0x014 if 9728-byte jumbo is supported.
3571 wr32(hw, TXGBE_ARBTXMMW, 0x14);
3573 /* Set ARBTXRATE of queue X */
3574 wr32(hw, TXGBE_ARBPOOLIDX, queue_idx);
3575 wr32(hw, TXGBE_ARBTXRATE, bcnrc_val);
3582 txgbe_syn_filter_set(struct rte_eth_dev *dev,
3583 struct rte_eth_syn_filter *filter,
3586 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
3587 struct txgbe_filter_info *filter_info = TXGBE_DEV_FILTER(dev);
3591 if (filter->queue >= TXGBE_MAX_RX_QUEUE_NUM)
3594 syn_info = filter_info->syn_info;
3597 if (syn_info & TXGBE_SYNCLS_ENA)
3599 synqf = (uint32_t)TXGBE_SYNCLS_QPID(filter->queue);
3600 synqf |= TXGBE_SYNCLS_ENA;
3602 if (filter->hig_pri)
3603 synqf |= TXGBE_SYNCLS_HIPRIO;
3605 synqf &= ~TXGBE_SYNCLS_HIPRIO;
3607 synqf = rd32(hw, TXGBE_SYNCLS);
3608 if (!(syn_info & TXGBE_SYNCLS_ENA))
3610 synqf &= ~(TXGBE_SYNCLS_QPID_MASK | TXGBE_SYNCLS_ENA);
3613 filter_info->syn_info = synqf;
3614 wr32(hw, TXGBE_SYNCLS, synqf);
3619 static inline enum txgbe_5tuple_protocol
3620 convert_protocol_type(uint8_t protocol_value)
3622 if (protocol_value == IPPROTO_TCP)
3623 return TXGBE_5TF_PROT_TCP;
3624 else if (protocol_value == IPPROTO_UDP)
3625 return TXGBE_5TF_PROT_UDP;
3626 else if (protocol_value == IPPROTO_SCTP)
3627 return TXGBE_5TF_PROT_SCTP;
3629 return TXGBE_5TF_PROT_NONE;
3632 /* inject a 5-tuple filter to HW */
3634 txgbe_inject_5tuple_filter(struct rte_eth_dev *dev,
3635 struct txgbe_5tuple_filter *filter)
3637 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
3639 uint32_t ftqf, sdpqf;
3640 uint32_t l34timir = 0;
3641 uint32_t mask = TXGBE_5TFCTL0_MASK;
3644 sdpqf = TXGBE_5TFPORT_DST(be_to_le16(filter->filter_info.dst_port));
3645 sdpqf |= TXGBE_5TFPORT_SRC(be_to_le16(filter->filter_info.src_port));
3647 ftqf = TXGBE_5TFCTL0_PROTO(filter->filter_info.proto);
3648 ftqf |= TXGBE_5TFCTL0_PRI(filter->filter_info.priority);
3649 if (filter->filter_info.src_ip_mask == 0) /* 0 means compare. */
3650 mask &= ~TXGBE_5TFCTL0_MSADDR;
3651 if (filter->filter_info.dst_ip_mask == 0)
3652 mask &= ~TXGBE_5TFCTL0_MDADDR;
3653 if (filter->filter_info.src_port_mask == 0)
3654 mask &= ~TXGBE_5TFCTL0_MSPORT;
3655 if (filter->filter_info.dst_port_mask == 0)
3656 mask &= ~TXGBE_5TFCTL0_MDPORT;
3657 if (filter->filter_info.proto_mask == 0)
3658 mask &= ~TXGBE_5TFCTL0_MPROTO;
3660 ftqf |= TXGBE_5TFCTL0_MPOOL;
3661 ftqf |= TXGBE_5TFCTL0_ENA;
3663 wr32(hw, TXGBE_5TFDADDR(i), be_to_le32(filter->filter_info.dst_ip));
3664 wr32(hw, TXGBE_5TFSADDR(i), be_to_le32(filter->filter_info.src_ip));
3665 wr32(hw, TXGBE_5TFPORT(i), sdpqf);
3666 wr32(hw, TXGBE_5TFCTL0(i), ftqf);
3668 l34timir |= TXGBE_5TFCTL1_QP(filter->queue);
3669 wr32(hw, TXGBE_5TFCTL1(i), l34timir);
3673 * add a 5tuple filter
3676 * dev: Pointer to struct rte_eth_dev.
3677 * index: the index the filter allocates.
3678 * filter: pointer to the filter that will be added.
3679 * rx_queue: the queue id the filter assigned to.
3682 * - On success, zero.
3683 * - On failure, a negative value.
3686 txgbe_add_5tuple_filter(struct rte_eth_dev *dev,
3687 struct txgbe_5tuple_filter *filter)
3689 struct txgbe_filter_info *filter_info = TXGBE_DEV_FILTER(dev);
3693 * look for an unused 5tuple filter index,
3694 * and insert the filter to list.
3696 for (i = 0; i < TXGBE_MAX_FTQF_FILTERS; i++) {
3697 idx = i / (sizeof(uint32_t) * NBBY);
3698 shift = i % (sizeof(uint32_t) * NBBY);
3699 if (!(filter_info->fivetuple_mask[idx] & (1 << shift))) {
3700 filter_info->fivetuple_mask[idx] |= 1 << shift;
3702 TAILQ_INSERT_TAIL(&filter_info->fivetuple_list,
3708 if (i >= TXGBE_MAX_FTQF_FILTERS) {
3709 PMD_DRV_LOG(ERR, "5tuple filters are full.");
3713 txgbe_inject_5tuple_filter(dev, filter);
3719 * remove a 5tuple filter
3722 * dev: Pointer to struct rte_eth_dev.
3723 * filter: the pointer of the filter will be removed.
3726 txgbe_remove_5tuple_filter(struct rte_eth_dev *dev,
3727 struct txgbe_5tuple_filter *filter)
3729 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
3730 struct txgbe_filter_info *filter_info = TXGBE_DEV_FILTER(dev);
3731 uint16_t index = filter->index;
3733 filter_info->fivetuple_mask[index / (sizeof(uint32_t) * NBBY)] &=
3734 ~(1 << (index % (sizeof(uint32_t) * NBBY)));
3735 TAILQ_REMOVE(&filter_info->fivetuple_list, filter, entries);
3738 wr32(hw, TXGBE_5TFDADDR(index), 0);
3739 wr32(hw, TXGBE_5TFSADDR(index), 0);
3740 wr32(hw, TXGBE_5TFPORT(index), 0);
3741 wr32(hw, TXGBE_5TFCTL0(index), 0);
3742 wr32(hw, TXGBE_5TFCTL1(index), 0);
3745 static inline struct txgbe_5tuple_filter *
3746 txgbe_5tuple_filter_lookup(struct txgbe_5tuple_filter_list *filter_list,
3747 struct txgbe_5tuple_filter_info *key)
3749 struct txgbe_5tuple_filter *it;
3751 TAILQ_FOREACH(it, filter_list, entries) {
3752 if (memcmp(key, &it->filter_info,
3753 sizeof(struct txgbe_5tuple_filter_info)) == 0) {
3760 /* translate elements in struct rte_eth_ntuple_filter
3761 * to struct txgbe_5tuple_filter_info
3764 ntuple_filter_to_5tuple(struct rte_eth_ntuple_filter *filter,
3765 struct txgbe_5tuple_filter_info *filter_info)
3767 if (filter->queue >= TXGBE_MAX_RX_QUEUE_NUM ||
3768 filter->priority > TXGBE_5TUPLE_MAX_PRI ||
3769 filter->priority < TXGBE_5TUPLE_MIN_PRI)
3772 switch (filter->dst_ip_mask) {
3774 filter_info->dst_ip_mask = 0;
3775 filter_info->dst_ip = filter->dst_ip;
3778 filter_info->dst_ip_mask = 1;
3781 PMD_DRV_LOG(ERR, "invalid dst_ip mask.");
3785 switch (filter->src_ip_mask) {
3787 filter_info->src_ip_mask = 0;
3788 filter_info->src_ip = filter->src_ip;
3791 filter_info->src_ip_mask = 1;
3794 PMD_DRV_LOG(ERR, "invalid src_ip mask.");
3798 switch (filter->dst_port_mask) {
3800 filter_info->dst_port_mask = 0;
3801 filter_info->dst_port = filter->dst_port;
3804 filter_info->dst_port_mask = 1;
3807 PMD_DRV_LOG(ERR, "invalid dst_port mask.");
3811 switch (filter->src_port_mask) {
3813 filter_info->src_port_mask = 0;
3814 filter_info->src_port = filter->src_port;
3817 filter_info->src_port_mask = 1;
3820 PMD_DRV_LOG(ERR, "invalid src_port mask.");
3824 switch (filter->proto_mask) {
3826 filter_info->proto_mask = 0;
3827 filter_info->proto =
3828 convert_protocol_type(filter->proto);
3831 filter_info->proto_mask = 1;
3834 PMD_DRV_LOG(ERR, "invalid protocol mask.");
3838 filter_info->priority = (uint8_t)filter->priority;
3843 * add or delete a ntuple filter
3846 * dev: Pointer to struct rte_eth_dev.
3847 * ntuple_filter: Pointer to struct rte_eth_ntuple_filter
3848 * add: if true, add filter, if false, remove filter
3851 * - On success, zero.
3852 * - On failure, a negative value.
3855 txgbe_add_del_ntuple_filter(struct rte_eth_dev *dev,
3856 struct rte_eth_ntuple_filter *ntuple_filter,
3859 struct txgbe_filter_info *filter_info = TXGBE_DEV_FILTER(dev);
3860 struct txgbe_5tuple_filter_info filter_5tuple;
3861 struct txgbe_5tuple_filter *filter;
3864 if (ntuple_filter->flags != RTE_5TUPLE_FLAGS) {
3865 PMD_DRV_LOG(ERR, "only 5tuple is supported.");
3869 memset(&filter_5tuple, 0, sizeof(struct txgbe_5tuple_filter_info));
3870 ret = ntuple_filter_to_5tuple(ntuple_filter, &filter_5tuple);
3874 filter = txgbe_5tuple_filter_lookup(&filter_info->fivetuple_list,
3876 if (filter != NULL && add) {
3877 PMD_DRV_LOG(ERR, "filter exists.");
3880 if (filter == NULL && !add) {
3881 PMD_DRV_LOG(ERR, "filter doesn't exist.");
3886 filter = rte_zmalloc("txgbe_5tuple_filter",
3887 sizeof(struct txgbe_5tuple_filter), 0);
3890 rte_memcpy(&filter->filter_info,
3892 sizeof(struct txgbe_5tuple_filter_info));
3893 filter->queue = ntuple_filter->queue;
3894 ret = txgbe_add_5tuple_filter(dev, filter);
3900 txgbe_remove_5tuple_filter(dev, filter);
3907 txgbe_add_del_ethertype_filter(struct rte_eth_dev *dev,
3908 struct rte_eth_ethertype_filter *filter,
3911 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
3912 struct txgbe_filter_info *filter_info = TXGBE_DEV_FILTER(dev);
3916 struct txgbe_ethertype_filter ethertype_filter;
3918 if (filter->queue >= TXGBE_MAX_RX_QUEUE_NUM)
3921 if (filter->ether_type == RTE_ETHER_TYPE_IPV4 ||
3922 filter->ether_type == RTE_ETHER_TYPE_IPV6) {
3923 PMD_DRV_LOG(ERR, "unsupported ether_type(0x%04x) in"
3924 " ethertype filter.", filter->ether_type);
3928 if (filter->flags & RTE_ETHTYPE_FLAGS_MAC) {
3929 PMD_DRV_LOG(ERR, "mac compare is unsupported.");
3932 if (filter->flags & RTE_ETHTYPE_FLAGS_DROP) {
3933 PMD_DRV_LOG(ERR, "drop option is unsupported.");
3937 ret = txgbe_ethertype_filter_lookup(filter_info, filter->ether_type);
3938 if (ret >= 0 && add) {
3939 PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter exists.",
3940 filter->ether_type);
3943 if (ret < 0 && !add) {
3944 PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter doesn't exist.",
3945 filter->ether_type);
3950 etqf = TXGBE_ETFLT_ENA;
3951 etqf |= TXGBE_ETFLT_ETID(filter->ether_type);
3952 etqs |= TXGBE_ETCLS_QPID(filter->queue);
3953 etqs |= TXGBE_ETCLS_QENA;
3955 ethertype_filter.ethertype = filter->ether_type;
3956 ethertype_filter.etqf = etqf;
3957 ethertype_filter.etqs = etqs;
3958 ethertype_filter.conf = FALSE;
3959 ret = txgbe_ethertype_filter_insert(filter_info,
3962 PMD_DRV_LOG(ERR, "ethertype filters are full.");
3966 ret = txgbe_ethertype_filter_remove(filter_info, (uint8_t)ret);
3970 wr32(hw, TXGBE_ETFLT(ret), etqf);
3971 wr32(hw, TXGBE_ETCLS(ret), etqs);
3978 txgbe_dev_filter_ctrl(__rte_unused struct rte_eth_dev *dev,
3979 enum rte_filter_type filter_type,
3980 enum rte_filter_op filter_op,
3985 switch (filter_type) {
3986 case RTE_ETH_FILTER_GENERIC:
3987 if (filter_op != RTE_ETH_FILTER_GET)
3989 *(const void **)arg = &txgbe_flow_ops;
3992 PMD_DRV_LOG(WARNING, "Filter type (%d) not supported",
4002 txgbe_dev_addr_list_itr(__rte_unused struct txgbe_hw *hw,
4003 u8 **mc_addr_ptr, u32 *vmdq)
4008 mc_addr = *mc_addr_ptr;
4009 *mc_addr_ptr = (mc_addr + sizeof(struct rte_ether_addr));
4014 txgbe_dev_set_mc_addr_list(struct rte_eth_dev *dev,
4015 struct rte_ether_addr *mc_addr_set,
4016 uint32_t nb_mc_addr)
4018 struct txgbe_hw *hw;
4021 hw = TXGBE_DEV_HW(dev);
4022 mc_addr_list = (u8 *)mc_addr_set;
4023 return txgbe_update_mc_addr_list(hw, mc_addr_list, nb_mc_addr,
4024 txgbe_dev_addr_list_itr, TRUE);
4028 txgbe_read_systime_cyclecounter(struct rte_eth_dev *dev)
4030 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
4031 uint64_t systime_cycles;
4033 systime_cycles = (uint64_t)rd32(hw, TXGBE_TSTIMEL);
4034 systime_cycles |= (uint64_t)rd32(hw, TXGBE_TSTIMEH) << 32;
4036 return systime_cycles;
4040 txgbe_read_rx_tstamp_cyclecounter(struct rte_eth_dev *dev)
4042 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
4043 uint64_t rx_tstamp_cycles;
4045 /* TSRXSTMPL stores ns and TSRXSTMPH stores seconds. */
4046 rx_tstamp_cycles = (uint64_t)rd32(hw, TXGBE_TSRXSTMPL);
4047 rx_tstamp_cycles |= (uint64_t)rd32(hw, TXGBE_TSRXSTMPH) << 32;
4049 return rx_tstamp_cycles;
4053 txgbe_read_tx_tstamp_cyclecounter(struct rte_eth_dev *dev)
4055 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
4056 uint64_t tx_tstamp_cycles;
4058 /* TSTXSTMPL stores ns and TSTXSTMPH stores seconds. */
4059 tx_tstamp_cycles = (uint64_t)rd32(hw, TXGBE_TSTXSTMPL);
4060 tx_tstamp_cycles |= (uint64_t)rd32(hw, TXGBE_TSTXSTMPH) << 32;
4062 return tx_tstamp_cycles;
4066 txgbe_start_timecounters(struct rte_eth_dev *dev)
4068 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
4069 struct txgbe_adapter *adapter = TXGBE_DEV_ADAPTER(dev);
4070 struct rte_eth_link link;
4071 uint32_t incval = 0;
4074 /* Get current link speed. */
4075 txgbe_dev_link_update(dev, 1);
4076 rte_eth_linkstatus_get(dev, &link);
4078 switch (link.link_speed) {
4079 case ETH_SPEED_NUM_100M:
4080 incval = TXGBE_INCVAL_100;
4081 shift = TXGBE_INCVAL_SHIFT_100;
4083 case ETH_SPEED_NUM_1G:
4084 incval = TXGBE_INCVAL_1GB;
4085 shift = TXGBE_INCVAL_SHIFT_1GB;
4087 case ETH_SPEED_NUM_10G:
4089 incval = TXGBE_INCVAL_10GB;
4090 shift = TXGBE_INCVAL_SHIFT_10GB;
4094 wr32(hw, TXGBE_TSTIMEINC, TXGBE_TSTIMEINC_VP(incval, 2));
4096 memset(&adapter->systime_tc, 0, sizeof(struct rte_timecounter));
4097 memset(&adapter->rx_tstamp_tc, 0, sizeof(struct rte_timecounter));
4098 memset(&adapter->tx_tstamp_tc, 0, sizeof(struct rte_timecounter));
4100 adapter->systime_tc.cc_mask = TXGBE_CYCLECOUNTER_MASK;
4101 adapter->systime_tc.cc_shift = shift;
4102 adapter->systime_tc.nsec_mask = (1ULL << shift) - 1;
4104 adapter->rx_tstamp_tc.cc_mask = TXGBE_CYCLECOUNTER_MASK;
4105 adapter->rx_tstamp_tc.cc_shift = shift;
4106 adapter->rx_tstamp_tc.nsec_mask = (1ULL << shift) - 1;
4108 adapter->tx_tstamp_tc.cc_mask = TXGBE_CYCLECOUNTER_MASK;
4109 adapter->tx_tstamp_tc.cc_shift = shift;
4110 adapter->tx_tstamp_tc.nsec_mask = (1ULL << shift) - 1;
4114 txgbe_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta)
4116 struct txgbe_adapter *adapter = TXGBE_DEV_ADAPTER(dev);
4118 adapter->systime_tc.nsec += delta;
4119 adapter->rx_tstamp_tc.nsec += delta;
4120 adapter->tx_tstamp_tc.nsec += delta;
4126 txgbe_timesync_write_time(struct rte_eth_dev *dev, const struct timespec *ts)
4129 struct txgbe_adapter *adapter = TXGBE_DEV_ADAPTER(dev);
4131 ns = rte_timespec_to_ns(ts);
4132 /* Set the timecounters to a new value. */
4133 adapter->systime_tc.nsec = ns;
4134 adapter->rx_tstamp_tc.nsec = ns;
4135 adapter->tx_tstamp_tc.nsec = ns;
4141 txgbe_timesync_read_time(struct rte_eth_dev *dev, struct timespec *ts)
4143 uint64_t ns, systime_cycles;
4144 struct txgbe_adapter *adapter = TXGBE_DEV_ADAPTER(dev);
4146 systime_cycles = txgbe_read_systime_cyclecounter(dev);
4147 ns = rte_timecounter_update(&adapter->systime_tc, systime_cycles);
4148 *ts = rte_ns_to_timespec(ns);
4154 txgbe_timesync_enable(struct rte_eth_dev *dev)
4156 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
4159 /* Stop the timesync system time. */
4160 wr32(hw, TXGBE_TSTIMEINC, 0x0);
4161 /* Reset the timesync system time value. */
4162 wr32(hw, TXGBE_TSTIMEL, 0x0);
4163 wr32(hw, TXGBE_TSTIMEH, 0x0);
4165 txgbe_start_timecounters(dev);
4167 /* Enable L2 filtering of IEEE1588/802.1AS Ethernet frame types. */
4168 wr32(hw, TXGBE_ETFLT(TXGBE_ETF_ID_1588),
4169 RTE_ETHER_TYPE_1588 | TXGBE_ETFLT_ENA | TXGBE_ETFLT_1588);
4171 /* Enable timestamping of received PTP packets. */
4172 tsync_ctl = rd32(hw, TXGBE_TSRXCTL);
4173 tsync_ctl |= TXGBE_TSRXCTL_ENA;
4174 wr32(hw, TXGBE_TSRXCTL, tsync_ctl);
4176 /* Enable timestamping of transmitted PTP packets. */
4177 tsync_ctl = rd32(hw, TXGBE_TSTXCTL);
4178 tsync_ctl |= TXGBE_TSTXCTL_ENA;
4179 wr32(hw, TXGBE_TSTXCTL, tsync_ctl);
4187 txgbe_timesync_disable(struct rte_eth_dev *dev)
4189 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
4192 /* Disable timestamping of transmitted PTP packets. */
4193 tsync_ctl = rd32(hw, TXGBE_TSTXCTL);
4194 tsync_ctl &= ~TXGBE_TSTXCTL_ENA;
4195 wr32(hw, TXGBE_TSTXCTL, tsync_ctl);
4197 /* Disable timestamping of received PTP packets. */
4198 tsync_ctl = rd32(hw, TXGBE_TSRXCTL);
4199 tsync_ctl &= ~TXGBE_TSRXCTL_ENA;
4200 wr32(hw, TXGBE_TSRXCTL, tsync_ctl);
4202 /* Disable L2 filtering of IEEE1588/802.1AS Ethernet frame types. */
4203 wr32(hw, TXGBE_ETFLT(TXGBE_ETF_ID_1588), 0);
4205 /* Stop incrementating the System Time registers. */
4206 wr32(hw, TXGBE_TSTIMEINC, 0);
4212 txgbe_timesync_read_rx_timestamp(struct rte_eth_dev *dev,
4213 struct timespec *timestamp,
4214 uint32_t flags __rte_unused)
4216 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
4217 struct txgbe_adapter *adapter = TXGBE_DEV_ADAPTER(dev);
4218 uint32_t tsync_rxctl;
4219 uint64_t rx_tstamp_cycles;
4222 tsync_rxctl = rd32(hw, TXGBE_TSRXCTL);
4223 if ((tsync_rxctl & TXGBE_TSRXCTL_VLD) == 0)
4226 rx_tstamp_cycles = txgbe_read_rx_tstamp_cyclecounter(dev);
4227 ns = rte_timecounter_update(&adapter->rx_tstamp_tc, rx_tstamp_cycles);
4228 *timestamp = rte_ns_to_timespec(ns);
4234 txgbe_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
4235 struct timespec *timestamp)
4237 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
4238 struct txgbe_adapter *adapter = TXGBE_DEV_ADAPTER(dev);
4239 uint32_t tsync_txctl;
4240 uint64_t tx_tstamp_cycles;
4243 tsync_txctl = rd32(hw, TXGBE_TSTXCTL);
4244 if ((tsync_txctl & TXGBE_TSTXCTL_VLD) == 0)
4247 tx_tstamp_cycles = txgbe_read_tx_tstamp_cyclecounter(dev);
4248 ns = rte_timecounter_update(&adapter->tx_tstamp_tc, tx_tstamp_cycles);
4249 *timestamp = rte_ns_to_timespec(ns);
4255 txgbe_get_reg_length(struct rte_eth_dev *dev __rte_unused)
4259 const struct reg_info *reg_group;
4260 const struct reg_info **reg_set = txgbe_regs_others;
4262 while ((reg_group = reg_set[g_ind++]))
4263 count += txgbe_regs_group_count(reg_group);
4269 txgbe_get_regs(struct rte_eth_dev *dev,
4270 struct rte_dev_reg_info *regs)
4272 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
4273 uint32_t *data = regs->data;
4276 const struct reg_info *reg_group;
4277 const struct reg_info **reg_set = txgbe_regs_others;
4280 regs->length = txgbe_get_reg_length(dev);
4281 regs->width = sizeof(uint32_t);
4285 /* Support only full register dump */
4286 if (regs->length == 0 ||
4287 regs->length == (uint32_t)txgbe_get_reg_length(dev)) {
4288 regs->version = hw->mac.type << 24 |
4289 hw->revision_id << 16 |
4291 while ((reg_group = reg_set[g_ind++]))
4292 count += txgbe_read_regs_group(dev, &data[count],
4301 txgbe_get_eeprom_length(struct rte_eth_dev *dev)
4303 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
4305 /* Return unit is byte count */
4306 return hw->rom.word_size * 2;
4310 txgbe_get_eeprom(struct rte_eth_dev *dev,
4311 struct rte_dev_eeprom_info *in_eeprom)
4313 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
4314 struct txgbe_rom_info *eeprom = &hw->rom;
4315 uint16_t *data = in_eeprom->data;
4318 first = in_eeprom->offset >> 1;
4319 length = in_eeprom->length >> 1;
4320 if (first > hw->rom.word_size ||
4321 ((first + length) > hw->rom.word_size))
4324 in_eeprom->magic = hw->vendor_id | (hw->device_id << 16);
4326 return eeprom->readw_buffer(hw, first, length, data);
4330 txgbe_set_eeprom(struct rte_eth_dev *dev,
4331 struct rte_dev_eeprom_info *in_eeprom)
4333 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
4334 struct txgbe_rom_info *eeprom = &hw->rom;
4335 uint16_t *data = in_eeprom->data;
4338 first = in_eeprom->offset >> 1;
4339 length = in_eeprom->length >> 1;
4340 if (first > hw->rom.word_size ||
4341 ((first + length) > hw->rom.word_size))
4344 in_eeprom->magic = hw->vendor_id | (hw->device_id << 16);
4346 return eeprom->writew_buffer(hw, first, length, data);
4350 txgbe_get_module_info(struct rte_eth_dev *dev,
4351 struct rte_eth_dev_module_info *modinfo)
4353 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
4355 uint8_t sff8472_rev, addr_mode;
4356 bool page_swap = false;
4358 /* Check whether we support SFF-8472 or not */
4359 status = hw->phy.read_i2c_eeprom(hw,
4360 TXGBE_SFF_SFF_8472_COMP,
4365 /* addressing mode is not supported */
4366 status = hw->phy.read_i2c_eeprom(hw,
4367 TXGBE_SFF_SFF_8472_SWAP,
4372 if (addr_mode & TXGBE_SFF_ADDRESSING_MODE) {
4374 "Address change required to access page 0xA2, "
4375 "but not supported. Please report the module "
4376 "type to the driver maintainers.");
4380 if (sff8472_rev == TXGBE_SFF_SFF_8472_UNSUP || page_swap) {
4381 /* We have a SFP, but it does not support SFF-8472 */
4382 modinfo->type = RTE_ETH_MODULE_SFF_8079;
4383 modinfo->eeprom_len = RTE_ETH_MODULE_SFF_8079_LEN;
4385 /* We have a SFP which supports a revision of SFF-8472. */
4386 modinfo->type = RTE_ETH_MODULE_SFF_8472;
4387 modinfo->eeprom_len = RTE_ETH_MODULE_SFF_8472_LEN;
4394 txgbe_get_module_eeprom(struct rte_eth_dev *dev,
4395 struct rte_dev_eeprom_info *info)
4397 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
4398 uint32_t status = TXGBE_ERR_PHY_ADDR_INVALID;
4399 uint8_t databyte = 0xFF;
4400 uint8_t *data = info->data;
4403 if (info->length == 0)
4406 for (i = info->offset; i < info->offset + info->length; i++) {
4407 if (i < RTE_ETH_MODULE_SFF_8079_LEN)
4408 status = hw->phy.read_i2c_eeprom(hw, i, &databyte);
4410 status = hw->phy.read_i2c_sff8472(hw, i, &databyte);
4415 data[i - info->offset] = databyte;
4422 txgbe_rss_update_sp(enum txgbe_mac_type mac_type)
4425 case txgbe_mac_raptor:
4433 txgbe_dev_get_dcb_info(struct rte_eth_dev *dev,
4434 struct rte_eth_dcb_info *dcb_info)
4436 struct txgbe_dcb_config *dcb_config = TXGBE_DEV_DCB_CONFIG(dev);
4437 struct txgbe_dcb_tc_config *tc;
4438 struct rte_eth_dcb_tc_queue_mapping *tc_queue;
4442 if (dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_DCB_FLAG)
4443 dcb_info->nb_tcs = dcb_config->num_tcs.pg_tcs;
4445 dcb_info->nb_tcs = 1;
4447 tc_queue = &dcb_info->tc_queue;
4448 nb_tcs = dcb_info->nb_tcs;
4450 if (dcb_config->vt_mode) { /* vt is enabled */
4451 struct rte_eth_vmdq_dcb_conf *vmdq_rx_conf =
4452 &dev->data->dev_conf.rx_adv_conf.vmdq_dcb_conf;
4453 for (i = 0; i < ETH_DCB_NUM_USER_PRIORITIES; i++)
4454 dcb_info->prio_tc[i] = vmdq_rx_conf->dcb_tc[i];
4455 if (RTE_ETH_DEV_SRIOV(dev).active > 0) {
4456 for (j = 0; j < nb_tcs; j++) {
4457 tc_queue->tc_rxq[0][j].base = j;
4458 tc_queue->tc_rxq[0][j].nb_queue = 1;
4459 tc_queue->tc_txq[0][j].base = j;
4460 tc_queue->tc_txq[0][j].nb_queue = 1;
4463 for (i = 0; i < vmdq_rx_conf->nb_queue_pools; i++) {
4464 for (j = 0; j < nb_tcs; j++) {
4465 tc_queue->tc_rxq[i][j].base =
4467 tc_queue->tc_rxq[i][j].nb_queue = 1;
4468 tc_queue->tc_txq[i][j].base =
4470 tc_queue->tc_txq[i][j].nb_queue = 1;
4474 } else { /* vt is disabled */
4475 struct rte_eth_dcb_rx_conf *rx_conf =
4476 &dev->data->dev_conf.rx_adv_conf.dcb_rx_conf;
4477 for (i = 0; i < ETH_DCB_NUM_USER_PRIORITIES; i++)
4478 dcb_info->prio_tc[i] = rx_conf->dcb_tc[i];
4479 if (dcb_info->nb_tcs == ETH_4_TCS) {
4480 for (i = 0; i < dcb_info->nb_tcs; i++) {
4481 dcb_info->tc_queue.tc_rxq[0][i].base = i * 32;
4482 dcb_info->tc_queue.tc_rxq[0][i].nb_queue = 16;
4484 dcb_info->tc_queue.tc_txq[0][0].base = 0;
4485 dcb_info->tc_queue.tc_txq[0][1].base = 64;
4486 dcb_info->tc_queue.tc_txq[0][2].base = 96;
4487 dcb_info->tc_queue.tc_txq[0][3].base = 112;
4488 dcb_info->tc_queue.tc_txq[0][0].nb_queue = 64;
4489 dcb_info->tc_queue.tc_txq[0][1].nb_queue = 32;
4490 dcb_info->tc_queue.tc_txq[0][2].nb_queue = 16;
4491 dcb_info->tc_queue.tc_txq[0][3].nb_queue = 16;
4492 } else if (dcb_info->nb_tcs == ETH_8_TCS) {
4493 for (i = 0; i < dcb_info->nb_tcs; i++) {
4494 dcb_info->tc_queue.tc_rxq[0][i].base = i * 16;
4495 dcb_info->tc_queue.tc_rxq[0][i].nb_queue = 16;
4497 dcb_info->tc_queue.tc_txq[0][0].base = 0;
4498 dcb_info->tc_queue.tc_txq[0][1].base = 32;
4499 dcb_info->tc_queue.tc_txq[0][2].base = 64;
4500 dcb_info->tc_queue.tc_txq[0][3].base = 80;
4501 dcb_info->tc_queue.tc_txq[0][4].base = 96;
4502 dcb_info->tc_queue.tc_txq[0][5].base = 104;
4503 dcb_info->tc_queue.tc_txq[0][6].base = 112;
4504 dcb_info->tc_queue.tc_txq[0][7].base = 120;
4505 dcb_info->tc_queue.tc_txq[0][0].nb_queue = 32;
4506 dcb_info->tc_queue.tc_txq[0][1].nb_queue = 32;
4507 dcb_info->tc_queue.tc_txq[0][2].nb_queue = 16;
4508 dcb_info->tc_queue.tc_txq[0][3].nb_queue = 16;
4509 dcb_info->tc_queue.tc_txq[0][4].nb_queue = 8;
4510 dcb_info->tc_queue.tc_txq[0][5].nb_queue = 8;
4511 dcb_info->tc_queue.tc_txq[0][6].nb_queue = 8;
4512 dcb_info->tc_queue.tc_txq[0][7].nb_queue = 8;
4515 for (i = 0; i < dcb_info->nb_tcs; i++) {
4516 tc = &dcb_config->tc_config[i];
4517 dcb_info->tc_bws[i] = tc->path[TXGBE_DCB_TX_CONFIG].bwg_percent;
4522 /* Update e-tag ether type */
4524 txgbe_update_e_tag_eth_type(struct txgbe_hw *hw,
4525 uint16_t ether_type)
4527 uint32_t etag_etype;
4529 etag_etype = rd32(hw, TXGBE_EXTAG);
4530 etag_etype &= ~TXGBE_EXTAG_ETAG_MASK;
4531 etag_etype |= ether_type;
4532 wr32(hw, TXGBE_EXTAG, etag_etype);
4538 /* Enable e-tag tunnel */
4540 txgbe_e_tag_enable(struct txgbe_hw *hw)
4542 uint32_t etag_etype;
4544 etag_etype = rd32(hw, TXGBE_PORTCTL);
4545 etag_etype |= TXGBE_PORTCTL_ETAG;
4546 wr32(hw, TXGBE_PORTCTL, etag_etype);
4553 txgbe_e_tag_forwarding_en_dis(struct rte_eth_dev *dev, bool en)
4557 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
4559 ctrl = rd32(hw, TXGBE_POOLCTL);
4560 ctrl &= ~TXGBE_POOLCTL_MODE_MASK;
4562 ctrl |= TXGBE_PSRPOOL_MODE_ETAG;
4563 wr32(hw, TXGBE_POOLCTL, ctrl);
4568 /* restore n-tuple filter */
4570 txgbe_ntuple_filter_restore(struct rte_eth_dev *dev)
4572 struct txgbe_filter_info *filter_info = TXGBE_DEV_FILTER(dev);
4573 struct txgbe_5tuple_filter *node;
4575 TAILQ_FOREACH(node, &filter_info->fivetuple_list, entries) {
4576 txgbe_inject_5tuple_filter(dev, node);
4580 /* restore ethernet type filter */
4582 txgbe_ethertype_filter_restore(struct rte_eth_dev *dev)
4584 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
4585 struct txgbe_filter_info *filter_info = TXGBE_DEV_FILTER(dev);
4588 for (i = 0; i < TXGBE_ETF_ID_MAX; i++) {
4589 if (filter_info->ethertype_mask & (1 << i)) {
4590 wr32(hw, TXGBE_ETFLT(i),
4591 filter_info->ethertype_filters[i].etqf);
4592 wr32(hw, TXGBE_ETCLS(i),
4593 filter_info->ethertype_filters[i].etqs);
4599 /* restore SYN filter */
4601 txgbe_syn_filter_restore(struct rte_eth_dev *dev)
4603 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
4604 struct txgbe_filter_info *filter_info = TXGBE_DEV_FILTER(dev);
4607 synqf = filter_info->syn_info;
4609 if (synqf & TXGBE_SYNCLS_ENA) {
4610 wr32(hw, TXGBE_SYNCLS, synqf);
4616 txgbe_filter_restore(struct rte_eth_dev *dev)
4618 txgbe_ntuple_filter_restore(dev);
4619 txgbe_ethertype_filter_restore(dev);
4620 txgbe_syn_filter_restore(dev);
4626 txgbe_l2_tunnel_conf(struct rte_eth_dev *dev)
4628 struct txgbe_l2_tn_info *l2_tn_info = TXGBE_DEV_L2_TN(dev);
4629 struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
4631 if (l2_tn_info->e_tag_en)
4632 (void)txgbe_e_tag_enable(hw);
4634 if (l2_tn_info->e_tag_fwd_en)
4635 (void)txgbe_e_tag_forwarding_en_dis(dev, 1);
4637 (void)txgbe_update_e_tag_eth_type(hw, l2_tn_info->e_tag_ether_type);
4640 static const struct eth_dev_ops txgbe_eth_dev_ops = {
4641 .dev_configure = txgbe_dev_configure,
4642 .dev_infos_get = txgbe_dev_info_get,
4643 .dev_start = txgbe_dev_start,
4644 .dev_stop = txgbe_dev_stop,
4645 .dev_set_link_up = txgbe_dev_set_link_up,
4646 .dev_set_link_down = txgbe_dev_set_link_down,
4647 .dev_close = txgbe_dev_close,
4648 .dev_reset = txgbe_dev_reset,
4649 .promiscuous_enable = txgbe_dev_promiscuous_enable,
4650 .promiscuous_disable = txgbe_dev_promiscuous_disable,
4651 .allmulticast_enable = txgbe_dev_allmulticast_enable,
4652 .allmulticast_disable = txgbe_dev_allmulticast_disable,
4653 .link_update = txgbe_dev_link_update,
4654 .stats_get = txgbe_dev_stats_get,
4655 .xstats_get = txgbe_dev_xstats_get,
4656 .xstats_get_by_id = txgbe_dev_xstats_get_by_id,
4657 .stats_reset = txgbe_dev_stats_reset,
4658 .xstats_reset = txgbe_dev_xstats_reset,
4659 .xstats_get_names = txgbe_dev_xstats_get_names,
4660 .xstats_get_names_by_id = txgbe_dev_xstats_get_names_by_id,
4661 .queue_stats_mapping_set = txgbe_dev_queue_stats_mapping_set,
4662 .fw_version_get = txgbe_fw_version_get,
4663 .dev_supported_ptypes_get = txgbe_dev_supported_ptypes_get,
4664 .mtu_set = txgbe_dev_mtu_set,
4665 .vlan_filter_set = txgbe_vlan_filter_set,
4666 .vlan_tpid_set = txgbe_vlan_tpid_set,
4667 .vlan_offload_set = txgbe_vlan_offload_set,
4668 .vlan_strip_queue_set = txgbe_vlan_strip_queue_set,
4669 .rx_queue_start = txgbe_dev_rx_queue_start,
4670 .rx_queue_stop = txgbe_dev_rx_queue_stop,
4671 .tx_queue_start = txgbe_dev_tx_queue_start,
4672 .tx_queue_stop = txgbe_dev_tx_queue_stop,
4673 .rx_queue_setup = txgbe_dev_rx_queue_setup,
4674 .rx_queue_intr_enable = txgbe_dev_rx_queue_intr_enable,
4675 .rx_queue_intr_disable = txgbe_dev_rx_queue_intr_disable,
4676 .rx_queue_release = txgbe_dev_rx_queue_release,
4677 .tx_queue_setup = txgbe_dev_tx_queue_setup,
4678 .tx_queue_release = txgbe_dev_tx_queue_release,
4679 .dev_led_on = txgbe_dev_led_on,
4680 .dev_led_off = txgbe_dev_led_off,
4681 .flow_ctrl_get = txgbe_flow_ctrl_get,
4682 .flow_ctrl_set = txgbe_flow_ctrl_set,
4683 .priority_flow_ctrl_set = txgbe_priority_flow_ctrl_set,
4684 .mac_addr_add = txgbe_add_rar,
4685 .mac_addr_remove = txgbe_remove_rar,
4686 .mac_addr_set = txgbe_set_default_mac_addr,
4687 .uc_hash_table_set = txgbe_uc_hash_table_set,
4688 .uc_all_hash_table_set = txgbe_uc_all_hash_table_set,
4689 .set_queue_rate_limit = txgbe_set_queue_rate_limit,
4690 .reta_update = txgbe_dev_rss_reta_update,
4691 .reta_query = txgbe_dev_rss_reta_query,
4692 .rss_hash_update = txgbe_dev_rss_hash_update,
4693 .rss_hash_conf_get = txgbe_dev_rss_hash_conf_get,
4694 .filter_ctrl = txgbe_dev_filter_ctrl,
4695 .set_mc_addr_list = txgbe_dev_set_mc_addr_list,
4696 .rxq_info_get = txgbe_rxq_info_get,
4697 .txq_info_get = txgbe_txq_info_get,
4698 .timesync_enable = txgbe_timesync_enable,
4699 .timesync_disable = txgbe_timesync_disable,
4700 .timesync_read_rx_timestamp = txgbe_timesync_read_rx_timestamp,
4701 .timesync_read_tx_timestamp = txgbe_timesync_read_tx_timestamp,
4702 .get_reg = txgbe_get_regs,
4703 .get_eeprom_length = txgbe_get_eeprom_length,
4704 .get_eeprom = txgbe_get_eeprom,
4705 .set_eeprom = txgbe_set_eeprom,
4706 .get_module_info = txgbe_get_module_info,
4707 .get_module_eeprom = txgbe_get_module_eeprom,
4708 .get_dcb_info = txgbe_dev_get_dcb_info,
4709 .timesync_adjust_time = txgbe_timesync_adjust_time,
4710 .timesync_read_time = txgbe_timesync_read_time,
4711 .timesync_write_time = txgbe_timesync_write_time,
4712 .tx_done_cleanup = txgbe_dev_tx_done_cleanup,
4715 RTE_PMD_REGISTER_PCI(net_txgbe, rte_txgbe_pmd);
4716 RTE_PMD_REGISTER_PCI_TABLE(net_txgbe, pci_id_txgbe_map);
4717 RTE_PMD_REGISTER_KMOD_DEP(net_txgbe, "* igb_uio | uio_pci_generic | vfio-pci");
4719 RTE_LOG_REGISTER(txgbe_logtype_init, pmd.net.txgbe.init, NOTICE);
4720 RTE_LOG_REGISTER(txgbe_logtype_driver, pmd.net.txgbe.driver, NOTICE);
4722 #ifdef RTE_LIBRTE_TXGBE_DEBUG_RX
4723 RTE_LOG_REGISTER(txgbe_logtype_rx, pmd.net.txgbe.rx, DEBUG);
4725 #ifdef RTE_LIBRTE_TXGBE_DEBUG_TX
4726 RTE_LOG_REGISTER(txgbe_logtype_tx, pmd.net.txgbe.tx, DEBUG);
4729 #ifdef RTE_LIBRTE_TXGBE_DEBUG_TX_FREE
4730 RTE_LOG_REGISTER(txgbe_logtype_tx_free, pmd.net.txgbe.tx_free, DEBUG);