18691632fSRavi Kumar /* SPDX-License-Identifier: BSD-3-Clause 28691632fSRavi Kumar * Copyright(c) 2018 Advanced Micro Devices, Inc. All rights reserved. 38691632fSRavi Kumar * Copyright(c) 2018 Synopsys, Inc. All rights reserved. 48691632fSRavi Kumar */ 58691632fSRavi Kumar 69e890103SRavi Kumar #include "axgbe_rxtx.h" 78691632fSRavi Kumar #include "axgbe_ethdev.h" 8572890efSRavi Kumar #include "axgbe_common.h" 9572890efSRavi Kumar #include "axgbe_phy.h" 10*df4867cdSChandu Babu N #include "axgbe_regs.h" 118691632fSRavi Kumar 128691632fSRavi Kumar static int eth_axgbe_dev_init(struct rte_eth_dev *eth_dev); 138691632fSRavi Kumar static int eth_axgbe_dev_uninit(struct rte_eth_dev *eth_dev); 147c4158a5SRavi Kumar static int axgbe_dev_configure(struct rte_eth_dev *dev); 157c4158a5SRavi Kumar static int axgbe_dev_start(struct rte_eth_dev *dev); 167c4158a5SRavi Kumar static void axgbe_dev_stop(struct rte_eth_dev *dev); 17456ff159SRavi Kumar static void axgbe_dev_interrupt_handler(void *param); 189e890103SRavi Kumar static void axgbe_dev_close(struct rte_eth_dev *dev); 199039c812SAndrew Rybchenko static int axgbe_dev_promiscuous_enable(struct rte_eth_dev *dev); 209039c812SAndrew Rybchenko static int axgbe_dev_promiscuous_disable(struct rte_eth_dev *dev); 21ca041cd4SIvan Ilchenko static int axgbe_dev_allmulticast_enable(struct rte_eth_dev *dev); 22ca041cd4SIvan Ilchenko static int axgbe_dev_allmulticast_disable(struct rte_eth_dev *dev); 2344d45ffeSRavi Kumar static int axgbe_dev_link_update(struct rte_eth_dev *dev, 2444d45ffeSRavi Kumar int wait_to_complete); 25*df4867cdSChandu Babu N static int axgbe_dev_get_regs(struct rte_eth_dev *dev, 26*df4867cdSChandu Babu N struct rte_dev_reg_info *regs); 273e730511SRavi Kumar static int axgbe_dev_stats_get(struct rte_eth_dev *dev, 283e730511SRavi Kumar struct rte_eth_stats *stats); 299970a9adSIgor Romanov static int axgbe_dev_stats_reset(struct rte_eth_dev *dev); 309d1ef6b2SChandu Babu N static int axgbe_dev_xstats_get(struct rte_eth_dev *dev, 319d1ef6b2SChandu Babu N struct rte_eth_xstat *stats, 329d1ef6b2SChandu Babu N unsigned int n); 339d1ef6b2SChandu Babu N static int 349d1ef6b2SChandu Babu N axgbe_dev_xstats_get_names(struct rte_eth_dev *dev, 359d1ef6b2SChandu Babu N struct rte_eth_xstat_name *xstats_names, 369d1ef6b2SChandu Babu N unsigned int size); 379d1ef6b2SChandu Babu N static int 389d1ef6b2SChandu Babu N axgbe_dev_xstats_get_by_id(struct rte_eth_dev *dev, 399d1ef6b2SChandu Babu N const uint64_t *ids, 409d1ef6b2SChandu Babu N uint64_t *values, 419d1ef6b2SChandu Babu N unsigned int n); 429d1ef6b2SChandu Babu N static int 439d1ef6b2SChandu Babu N axgbe_dev_xstats_get_names_by_id(struct rte_eth_dev *dev, 449d1ef6b2SChandu Babu N struct rte_eth_xstat_name *xstats_names, 459d1ef6b2SChandu Babu N const uint64_t *ids, 469d1ef6b2SChandu Babu N unsigned int size); 479d1ef6b2SChandu Babu N static int axgbe_dev_xstats_reset(struct rte_eth_dev *dev); 48bdad90d1SIvan Ilchenko static int axgbe_dev_info_get(struct rte_eth_dev *dev, 499e890103SRavi Kumar struct rte_eth_dev_info *dev_info); 508691632fSRavi Kumar 519d1ef6b2SChandu Babu N struct axgbe_xstats { 529d1ef6b2SChandu Babu N char name[RTE_ETH_XSTATS_NAME_SIZE]; 539d1ef6b2SChandu Babu N int offset; 549d1ef6b2SChandu Babu N }; 559d1ef6b2SChandu Babu N 569d1ef6b2SChandu Babu N #define AXGMAC_MMC_STAT(_string, _var) \ 579d1ef6b2SChandu Babu N { _string, \ 589d1ef6b2SChandu Babu N offsetof(struct axgbe_mmc_stats, _var), \ 599d1ef6b2SChandu Babu N } 609d1ef6b2SChandu Babu N 619d1ef6b2SChandu Babu N static const struct axgbe_xstats axgbe_xstats_strings[] = { 629d1ef6b2SChandu Babu N AXGMAC_MMC_STAT("tx_bytes", txoctetcount_gb), 639d1ef6b2SChandu Babu N AXGMAC_MMC_STAT("tx_packets", txframecount_gb), 649d1ef6b2SChandu Babu N AXGMAC_MMC_STAT("tx_unicast_packets", txunicastframes_gb), 659d1ef6b2SChandu Babu N AXGMAC_MMC_STAT("tx_broadcast_packets", txbroadcastframes_gb), 669d1ef6b2SChandu Babu N AXGMAC_MMC_STAT("tx_multicast_packets", txmulticastframes_gb), 679d1ef6b2SChandu Babu N AXGMAC_MMC_STAT("tx_vlan_packets", txvlanframes_g), 689d1ef6b2SChandu Babu N AXGMAC_MMC_STAT("tx_64_byte_packets", tx64octets_gb), 699d1ef6b2SChandu Babu N AXGMAC_MMC_STAT("tx_65_to_127_byte_packets", tx65to127octets_gb), 709d1ef6b2SChandu Babu N AXGMAC_MMC_STAT("tx_128_to_255_byte_packets", tx128to255octets_gb), 719d1ef6b2SChandu Babu N AXGMAC_MMC_STAT("tx_256_to_511_byte_packets", tx256to511octets_gb), 729d1ef6b2SChandu Babu N AXGMAC_MMC_STAT("tx_512_to_1023_byte_packets", tx512to1023octets_gb), 739d1ef6b2SChandu Babu N AXGMAC_MMC_STAT("tx_1024_to_max_byte_packets", tx1024tomaxoctets_gb), 749d1ef6b2SChandu Babu N AXGMAC_MMC_STAT("tx_underflow_errors", txunderflowerror), 759d1ef6b2SChandu Babu N AXGMAC_MMC_STAT("tx_pause_frames", txpauseframes), 769d1ef6b2SChandu Babu N 779d1ef6b2SChandu Babu N AXGMAC_MMC_STAT("rx_bytes", rxoctetcount_gb), 789d1ef6b2SChandu Babu N AXGMAC_MMC_STAT("rx_packets", rxframecount_gb), 799d1ef6b2SChandu Babu N AXGMAC_MMC_STAT("rx_unicast_packets", rxunicastframes_g), 809d1ef6b2SChandu Babu N AXGMAC_MMC_STAT("rx_broadcast_packets", rxbroadcastframes_g), 819d1ef6b2SChandu Babu N AXGMAC_MMC_STAT("rx_multicast_packets", rxmulticastframes_g), 829d1ef6b2SChandu Babu N AXGMAC_MMC_STAT("rx_vlan_packets", rxvlanframes_gb), 839d1ef6b2SChandu Babu N AXGMAC_MMC_STAT("rx_64_byte_packets", rx64octets_gb), 849d1ef6b2SChandu Babu N AXGMAC_MMC_STAT("rx_65_to_127_byte_packets", rx65to127octets_gb), 859d1ef6b2SChandu Babu N AXGMAC_MMC_STAT("rx_128_to_255_byte_packets", rx128to255octets_gb), 869d1ef6b2SChandu Babu N AXGMAC_MMC_STAT("rx_256_to_511_byte_packets", rx256to511octets_gb), 879d1ef6b2SChandu Babu N AXGMAC_MMC_STAT("rx_512_to_1023_byte_packets", rx512to1023octets_gb), 889d1ef6b2SChandu Babu N AXGMAC_MMC_STAT("rx_1024_to_max_byte_packets", rx1024tomaxoctets_gb), 899d1ef6b2SChandu Babu N AXGMAC_MMC_STAT("rx_undersize_packets", rxundersize_g), 909d1ef6b2SChandu Babu N AXGMAC_MMC_STAT("rx_oversize_packets", rxoversize_g), 919d1ef6b2SChandu Babu N AXGMAC_MMC_STAT("rx_crc_errors", rxcrcerror), 929d1ef6b2SChandu Babu N AXGMAC_MMC_STAT("rx_crc_errors_small_packets", rxrunterror), 939d1ef6b2SChandu Babu N AXGMAC_MMC_STAT("rx_crc_errors_giant_packets", rxjabbererror), 949d1ef6b2SChandu Babu N AXGMAC_MMC_STAT("rx_length_errors", rxlengtherror), 959d1ef6b2SChandu Babu N AXGMAC_MMC_STAT("rx_out_of_range_errors", rxoutofrangetype), 969d1ef6b2SChandu Babu N AXGMAC_MMC_STAT("rx_fifo_overflow_errors", rxfifooverflow), 979d1ef6b2SChandu Babu N AXGMAC_MMC_STAT("rx_watchdog_errors", rxwatchdogerror), 989d1ef6b2SChandu Babu N AXGMAC_MMC_STAT("rx_pause_frames", rxpauseframes), 999d1ef6b2SChandu Babu N }; 1009d1ef6b2SChandu Babu N 1019d1ef6b2SChandu Babu N #define AXGBE_XSTATS_COUNT ARRAY_SIZE(axgbe_xstats_strings) 1029d1ef6b2SChandu Babu N 1038691632fSRavi Kumar /* The set of PCI devices this driver supports */ 1048691632fSRavi Kumar #define AMD_PCI_VENDOR_ID 0x1022 105991e0b1dSSelwin Sebastian #define AMD_PCI_RV_ROOT_COMPLEX_ID 0x15d0 1068691632fSRavi Kumar #define AMD_PCI_AXGBE_DEVICE_V2A 0x1458 1078691632fSRavi Kumar #define AMD_PCI_AXGBE_DEVICE_V2B 0x1459 1088691632fSRavi Kumar 1098691632fSRavi Kumar int axgbe_logtype_init; 1108691632fSRavi Kumar int axgbe_logtype_driver; 1118691632fSRavi Kumar 1128691632fSRavi Kumar static const struct rte_pci_id pci_id_axgbe_map[] = { 1138691632fSRavi Kumar {RTE_PCI_DEVICE(AMD_PCI_VENDOR_ID, AMD_PCI_AXGBE_DEVICE_V2A)}, 1148691632fSRavi Kumar {RTE_PCI_DEVICE(AMD_PCI_VENDOR_ID, AMD_PCI_AXGBE_DEVICE_V2B)}, 1158691632fSRavi Kumar { .vendor_id = 0, }, 1168691632fSRavi Kumar }; 1178691632fSRavi Kumar 118572890efSRavi Kumar static struct axgbe_version_data axgbe_v2a = { 1194ac7516bSRavi Kumar .init_function_ptrs_phy_impl = axgbe_init_function_ptrs_phy_v2, 120572890efSRavi Kumar .xpcs_access = AXGBE_XPCS_ACCESS_V2, 121572890efSRavi Kumar .mmc_64bit = 1, 122572890efSRavi Kumar .tx_max_fifo_size = 229376, 123572890efSRavi Kumar .rx_max_fifo_size = 229376, 124572890efSRavi Kumar .tx_tstamp_workaround = 1, 125572890efSRavi Kumar .ecc_support = 1, 126572890efSRavi Kumar .i2c_support = 1, 12700072056SRavi Kumar .an_cdr_workaround = 1, 128572890efSRavi Kumar }; 129572890efSRavi Kumar 130572890efSRavi Kumar static struct axgbe_version_data axgbe_v2b = { 1314ac7516bSRavi Kumar .init_function_ptrs_phy_impl = axgbe_init_function_ptrs_phy_v2, 132572890efSRavi Kumar .xpcs_access = AXGBE_XPCS_ACCESS_V2, 133572890efSRavi Kumar .mmc_64bit = 1, 134572890efSRavi Kumar .tx_max_fifo_size = 65536, 135572890efSRavi Kumar .rx_max_fifo_size = 65536, 136572890efSRavi Kumar .tx_tstamp_workaround = 1, 137572890efSRavi Kumar .ecc_support = 1, 138572890efSRavi Kumar .i2c_support = 1, 13900072056SRavi Kumar .an_cdr_workaround = 1, 140572890efSRavi Kumar }; 141572890efSRavi Kumar 1429e890103SRavi Kumar static const struct rte_eth_desc_lim rx_desc_lim = { 1439e890103SRavi Kumar .nb_max = AXGBE_MAX_RING_DESC, 1449e890103SRavi Kumar .nb_min = AXGBE_MIN_RING_DESC, 1459e890103SRavi Kumar .nb_align = 8, 1469e890103SRavi Kumar }; 1479e890103SRavi Kumar 1489e890103SRavi Kumar static const struct rte_eth_desc_lim tx_desc_lim = { 1499e890103SRavi Kumar .nb_max = AXGBE_MAX_RING_DESC, 1509e890103SRavi Kumar .nb_min = AXGBE_MIN_RING_DESC, 1519e890103SRavi Kumar .nb_align = 8, 1529e890103SRavi Kumar }; 1539e890103SRavi Kumar 1549e890103SRavi Kumar static const struct eth_dev_ops axgbe_eth_dev_ops = { 1557c4158a5SRavi Kumar .dev_configure = axgbe_dev_configure, 1567c4158a5SRavi Kumar .dev_start = axgbe_dev_start, 1577c4158a5SRavi Kumar .dev_stop = axgbe_dev_stop, 1589e890103SRavi Kumar .dev_close = axgbe_dev_close, 159fa3e0440SRavi Kumar .promiscuous_enable = axgbe_dev_promiscuous_enable, 160fa3e0440SRavi Kumar .promiscuous_disable = axgbe_dev_promiscuous_disable, 161fa3e0440SRavi Kumar .allmulticast_enable = axgbe_dev_allmulticast_enable, 162fa3e0440SRavi Kumar .allmulticast_disable = axgbe_dev_allmulticast_disable, 16344d45ffeSRavi Kumar .link_update = axgbe_dev_link_update, 164*df4867cdSChandu Babu N .get_reg = axgbe_dev_get_regs, 1653e730511SRavi Kumar .stats_get = axgbe_dev_stats_get, 1663e730511SRavi Kumar .stats_reset = axgbe_dev_stats_reset, 1679d1ef6b2SChandu Babu N .xstats_get = axgbe_dev_xstats_get, 1689d1ef6b2SChandu Babu N .xstats_reset = axgbe_dev_xstats_reset, 1699d1ef6b2SChandu Babu N .xstats_get_names = axgbe_dev_xstats_get_names, 1709d1ef6b2SChandu Babu N .xstats_get_names_by_id = axgbe_dev_xstats_get_names_by_id, 1719d1ef6b2SChandu Babu N .xstats_get_by_id = axgbe_dev_xstats_get_by_id, 1729e890103SRavi Kumar .dev_infos_get = axgbe_dev_info_get, 1739e890103SRavi Kumar .rx_queue_setup = axgbe_dev_rx_queue_setup, 1749e890103SRavi Kumar .rx_queue_release = axgbe_dev_rx_queue_release, 1759e890103SRavi Kumar .tx_queue_setup = axgbe_dev_tx_queue_setup, 1769e890103SRavi Kumar .tx_queue_release = axgbe_dev_tx_queue_release, 1779e890103SRavi Kumar }; 1789e890103SRavi Kumar 1797c4158a5SRavi Kumar static int axgbe_phy_reset(struct axgbe_port *pdata) 1807c4158a5SRavi Kumar { 1817c4158a5SRavi Kumar pdata->phy_link = -1; 1827c4158a5SRavi Kumar pdata->phy_speed = SPEED_UNKNOWN; 1837c4158a5SRavi Kumar return pdata->phy_if.phy_reset(pdata); 1847c4158a5SRavi Kumar } 1857c4158a5SRavi Kumar 186456ff159SRavi Kumar /* 187456ff159SRavi Kumar * Interrupt handler triggered by NIC for handling 188456ff159SRavi Kumar * specific interrupt. 189456ff159SRavi Kumar * 190456ff159SRavi Kumar * @param handle 191456ff159SRavi Kumar * Pointer to interrupt handle. 192456ff159SRavi Kumar * @param param 193456ff159SRavi Kumar * The address of parameter (struct rte_eth_dev *) regsitered before. 194456ff159SRavi Kumar * 195456ff159SRavi Kumar * @return 196456ff159SRavi Kumar * void 197456ff159SRavi Kumar */ 198456ff159SRavi Kumar static void 199456ff159SRavi Kumar axgbe_dev_interrupt_handler(void *param) 200456ff159SRavi Kumar { 201456ff159SRavi Kumar struct rte_eth_dev *dev = (struct rte_eth_dev *)param; 202456ff159SRavi Kumar struct axgbe_port *pdata = dev->data->dev_private; 2038590b93dSRavi Kumar unsigned int dma_isr, dma_ch_isr; 204456ff159SRavi Kumar 205456ff159SRavi Kumar pdata->phy_if.an_isr(pdata); 2068590b93dSRavi Kumar /*DMA related interrupts*/ 2078590b93dSRavi Kumar dma_isr = AXGMAC_IOREAD(pdata, DMA_ISR); 2084216cdc0SChandu Babu N PMD_DRV_LOG(DEBUG, "DMA_ISR=%#010x\n", dma_isr); 2098590b93dSRavi Kumar if (dma_isr) { 2108590b93dSRavi Kumar if (dma_isr & 1) { 2118590b93dSRavi Kumar dma_ch_isr = 2128590b93dSRavi Kumar AXGMAC_DMA_IOREAD((struct axgbe_rx_queue *) 2138590b93dSRavi Kumar pdata->rx_queues[0], 2148590b93dSRavi Kumar DMA_CH_SR); 2154216cdc0SChandu Babu N PMD_DRV_LOG(DEBUG, "DMA_CH0_ISR=%#010x\n", dma_ch_isr); 2168590b93dSRavi Kumar AXGMAC_DMA_IOWRITE((struct axgbe_rx_queue *) 2178590b93dSRavi Kumar pdata->rx_queues[0], 2188590b93dSRavi Kumar DMA_CH_SR, dma_ch_isr); 2198590b93dSRavi Kumar } 2208590b93dSRavi Kumar } 2216bee9d5fSNithin Dabilpuram /* Unmask interrupts since disabled after generation */ 2226bee9d5fSNithin Dabilpuram rte_intr_ack(&pdata->pci_dev->intr_handle); 223456ff159SRavi Kumar } 224456ff159SRavi Kumar 2257c4158a5SRavi Kumar /* 2267c4158a5SRavi Kumar * Configure device link speed and setup link. 2277c4158a5SRavi Kumar * It returns 0 on success. 2287c4158a5SRavi Kumar */ 2297c4158a5SRavi Kumar static int 2307c4158a5SRavi Kumar axgbe_dev_configure(struct rte_eth_dev *dev) 2317c4158a5SRavi Kumar { 2327c4158a5SRavi Kumar struct axgbe_port *pdata = dev->data->dev_private; 2337c4158a5SRavi Kumar /* Checksum offload to hardware */ 2347c4158a5SRavi Kumar pdata->rx_csum_enable = dev->data->dev_conf.rxmode.offloads & 2357c4158a5SRavi Kumar DEV_RX_OFFLOAD_CHECKSUM; 2367c4158a5SRavi Kumar return 0; 2377c4158a5SRavi Kumar } 2387c4158a5SRavi Kumar 2397c4158a5SRavi Kumar static int 2407c4158a5SRavi Kumar axgbe_dev_rx_mq_config(struct rte_eth_dev *dev) 2417c4158a5SRavi Kumar { 2420bc212a8SStephen Hemminger struct axgbe_port *pdata = dev->data->dev_private; 2437c4158a5SRavi Kumar 2447c4158a5SRavi Kumar if (dev->data->dev_conf.rxmode.mq_mode == ETH_MQ_RX_RSS) 2457c4158a5SRavi Kumar pdata->rss_enable = 1; 2467c4158a5SRavi Kumar else if (dev->data->dev_conf.rxmode.mq_mode == ETH_MQ_RX_NONE) 2477c4158a5SRavi Kumar pdata->rss_enable = 0; 2487c4158a5SRavi Kumar else 2497c4158a5SRavi Kumar return -1; 2507c4158a5SRavi Kumar return 0; 2517c4158a5SRavi Kumar } 2527c4158a5SRavi Kumar 2537c4158a5SRavi Kumar static int 2547c4158a5SRavi Kumar axgbe_dev_start(struct rte_eth_dev *dev) 2557c4158a5SRavi Kumar { 2560bc212a8SStephen Hemminger struct axgbe_port *pdata = dev->data->dev_private; 2577c4158a5SRavi Kumar int ret; 2587c4158a5SRavi Kumar 2590bc212a8SStephen Hemminger PMD_INIT_FUNC_TRACE(); 2600bc212a8SStephen Hemminger 2617c4158a5SRavi Kumar /* Multiqueue RSS */ 2627c4158a5SRavi Kumar ret = axgbe_dev_rx_mq_config(dev); 2637c4158a5SRavi Kumar if (ret) { 2647c4158a5SRavi Kumar PMD_DRV_LOG(ERR, "Unable to config RX MQ\n"); 2657c4158a5SRavi Kumar return ret; 2667c4158a5SRavi Kumar } 2677c4158a5SRavi Kumar ret = axgbe_phy_reset(pdata); 2687c4158a5SRavi Kumar if (ret) { 2697c4158a5SRavi Kumar PMD_DRV_LOG(ERR, "phy reset failed\n"); 2707c4158a5SRavi Kumar return ret; 2717c4158a5SRavi Kumar } 2727c4158a5SRavi Kumar ret = pdata->hw_if.init(pdata); 2737c4158a5SRavi Kumar if (ret) { 2747c4158a5SRavi Kumar PMD_DRV_LOG(ERR, "dev_init failed\n"); 2757c4158a5SRavi Kumar return ret; 2767c4158a5SRavi Kumar } 2777c4158a5SRavi Kumar 2787c4158a5SRavi Kumar /* enable uio/vfio intr/eventfd mapping */ 2797c4158a5SRavi Kumar rte_intr_enable(&pdata->pci_dev->intr_handle); 2807c4158a5SRavi Kumar 2817c4158a5SRavi Kumar /* phy start*/ 2827c4158a5SRavi Kumar pdata->phy_if.phy_start(pdata); 2838590b93dSRavi Kumar axgbe_dev_enable_tx(dev); 2848590b93dSRavi Kumar axgbe_dev_enable_rx(dev); 2857c4158a5SRavi Kumar 2867c4158a5SRavi Kumar axgbe_clear_bit(AXGBE_STOPPED, &pdata->dev_state); 2877c4158a5SRavi Kumar axgbe_clear_bit(AXGBE_DOWN, &pdata->dev_state); 2887c4158a5SRavi Kumar return 0; 2897c4158a5SRavi Kumar } 2907c4158a5SRavi Kumar 2917c4158a5SRavi Kumar /* Stop device: disable rx and tx functions to allow for reconfiguring. */ 2927c4158a5SRavi Kumar static void 2937c4158a5SRavi Kumar axgbe_dev_stop(struct rte_eth_dev *dev) 2947c4158a5SRavi Kumar { 2957c4158a5SRavi Kumar struct axgbe_port *pdata = dev->data->dev_private; 2967c4158a5SRavi Kumar 2970bc212a8SStephen Hemminger PMD_INIT_FUNC_TRACE(); 2980bc212a8SStephen Hemminger 2997c4158a5SRavi Kumar rte_intr_disable(&pdata->pci_dev->intr_handle); 3007c4158a5SRavi Kumar 3017c4158a5SRavi Kumar if (axgbe_test_bit(AXGBE_STOPPED, &pdata->dev_state)) 3027c4158a5SRavi Kumar return; 3037c4158a5SRavi Kumar 3047c4158a5SRavi Kumar axgbe_set_bit(AXGBE_STOPPED, &pdata->dev_state); 3058590b93dSRavi Kumar axgbe_dev_disable_tx(dev); 3068590b93dSRavi Kumar axgbe_dev_disable_rx(dev); 3077c4158a5SRavi Kumar 3087c4158a5SRavi Kumar pdata->phy_if.phy_stop(pdata); 3097c4158a5SRavi Kumar pdata->hw_if.exit(pdata); 3107c4158a5SRavi Kumar memset(&dev->data->dev_link, 0, sizeof(struct rte_eth_link)); 3117c4158a5SRavi Kumar axgbe_set_bit(AXGBE_DOWN, &pdata->dev_state); 3127c4158a5SRavi Kumar } 3137c4158a5SRavi Kumar 3149e890103SRavi Kumar /* Clear all resources like TX/RX queues. */ 3159e890103SRavi Kumar static void 3169e890103SRavi Kumar axgbe_dev_close(struct rte_eth_dev *dev) 3179e890103SRavi Kumar { 3189e890103SRavi Kumar axgbe_dev_clear_queues(dev); 3199e890103SRavi Kumar } 3209e890103SRavi Kumar 3219039c812SAndrew Rybchenko static int 322fa3e0440SRavi Kumar axgbe_dev_promiscuous_enable(struct rte_eth_dev *dev) 323fa3e0440SRavi Kumar { 324fa3e0440SRavi Kumar struct axgbe_port *pdata = dev->data->dev_private; 325fa3e0440SRavi Kumar 3260bc212a8SStephen Hemminger PMD_INIT_FUNC_TRACE(); 3270bc212a8SStephen Hemminger 328fa3e0440SRavi Kumar AXGMAC_IOWRITE_BITS(pdata, MAC_PFR, PR, 1); 3299039c812SAndrew Rybchenko 3309039c812SAndrew Rybchenko return 0; 331fa3e0440SRavi Kumar } 332fa3e0440SRavi Kumar 3339039c812SAndrew Rybchenko static int 334fa3e0440SRavi Kumar axgbe_dev_promiscuous_disable(struct rte_eth_dev *dev) 335fa3e0440SRavi Kumar { 336fa3e0440SRavi Kumar struct axgbe_port *pdata = dev->data->dev_private; 337fa3e0440SRavi Kumar 3380bc212a8SStephen Hemminger PMD_INIT_FUNC_TRACE(); 3390bc212a8SStephen Hemminger 340fa3e0440SRavi Kumar AXGMAC_IOWRITE_BITS(pdata, MAC_PFR, PR, 0); 3419039c812SAndrew Rybchenko 3429039c812SAndrew Rybchenko return 0; 343fa3e0440SRavi Kumar } 344fa3e0440SRavi Kumar 345ca041cd4SIvan Ilchenko static int 346fa3e0440SRavi Kumar axgbe_dev_allmulticast_enable(struct rte_eth_dev *dev) 347fa3e0440SRavi Kumar { 348fa3e0440SRavi Kumar struct axgbe_port *pdata = dev->data->dev_private; 349fa3e0440SRavi Kumar 3500bc212a8SStephen Hemminger PMD_INIT_FUNC_TRACE(); 3510bc212a8SStephen Hemminger 352fa3e0440SRavi Kumar if (AXGMAC_IOREAD_BITS(pdata, MAC_PFR, PM)) 353ca041cd4SIvan Ilchenko return 0; 354fa3e0440SRavi Kumar AXGMAC_IOWRITE_BITS(pdata, MAC_PFR, PM, 1); 355ca041cd4SIvan Ilchenko 356ca041cd4SIvan Ilchenko return 0; 357fa3e0440SRavi Kumar } 358fa3e0440SRavi Kumar 359ca041cd4SIvan Ilchenko static int 360fa3e0440SRavi Kumar axgbe_dev_allmulticast_disable(struct rte_eth_dev *dev) 361fa3e0440SRavi Kumar { 362fa3e0440SRavi Kumar struct axgbe_port *pdata = dev->data->dev_private; 363fa3e0440SRavi Kumar 3640bc212a8SStephen Hemminger PMD_INIT_FUNC_TRACE(); 3650bc212a8SStephen Hemminger 366fa3e0440SRavi Kumar if (!AXGMAC_IOREAD_BITS(pdata, MAC_PFR, PM)) 367ca041cd4SIvan Ilchenko return 0; 368fa3e0440SRavi Kumar AXGMAC_IOWRITE_BITS(pdata, MAC_PFR, PM, 0); 369ca041cd4SIvan Ilchenko 370ca041cd4SIvan Ilchenko return 0; 371fa3e0440SRavi Kumar } 372fa3e0440SRavi Kumar 37344d45ffeSRavi Kumar /* return 0 means link status changed, -1 means not changed */ 37444d45ffeSRavi Kumar static int 37544d45ffeSRavi Kumar axgbe_dev_link_update(struct rte_eth_dev *dev, 37644d45ffeSRavi Kumar int wait_to_complete __rte_unused) 37744d45ffeSRavi Kumar { 37844d45ffeSRavi Kumar struct axgbe_port *pdata = dev->data->dev_private; 37944d45ffeSRavi Kumar struct rte_eth_link link; 38044d45ffeSRavi Kumar int ret = 0; 38144d45ffeSRavi Kumar 38244d45ffeSRavi Kumar PMD_INIT_FUNC_TRACE(); 38344d45ffeSRavi Kumar rte_delay_ms(800); 38444d45ffeSRavi Kumar 38544d45ffeSRavi Kumar pdata->phy_if.phy_status(pdata); 38644d45ffeSRavi Kumar 38744d45ffeSRavi Kumar memset(&link, 0, sizeof(struct rte_eth_link)); 38844d45ffeSRavi Kumar link.link_duplex = pdata->phy.duplex; 38944d45ffeSRavi Kumar link.link_status = pdata->phy_link; 39044d45ffeSRavi Kumar link.link_speed = pdata->phy_speed; 39144d45ffeSRavi Kumar link.link_autoneg = !(dev->data->dev_conf.link_speeds & 39244d45ffeSRavi Kumar ETH_LINK_SPEED_FIXED); 39344d45ffeSRavi Kumar ret = rte_eth_linkstatus_set(dev, &link); 39444d45ffeSRavi Kumar if (ret == -1) 39544d45ffeSRavi Kumar PMD_DRV_LOG(ERR, "No change in link status\n"); 39644d45ffeSRavi Kumar 39744d45ffeSRavi Kumar return ret; 39844d45ffeSRavi Kumar } 39944d45ffeSRavi Kumar 400*df4867cdSChandu Babu N static int 401*df4867cdSChandu Babu N axgbe_dev_get_regs(struct rte_eth_dev *dev, struct rte_dev_reg_info *regs) 402*df4867cdSChandu Babu N { 403*df4867cdSChandu Babu N struct axgbe_port *pdata = dev->data->dev_private; 404*df4867cdSChandu Babu N 405*df4867cdSChandu Babu N if (regs->data == NULL) { 406*df4867cdSChandu Babu N regs->length = axgbe_regs_get_count(pdata); 407*df4867cdSChandu Babu N regs->width = sizeof(uint32_t); 408*df4867cdSChandu Babu N return 0; 409*df4867cdSChandu Babu N } 410*df4867cdSChandu Babu N 411*df4867cdSChandu Babu N /* Only full register dump is supported */ 412*df4867cdSChandu Babu N if (regs->length && 413*df4867cdSChandu Babu N regs->length != (uint32_t)axgbe_regs_get_count(pdata)) 414*df4867cdSChandu Babu N return -ENOTSUP; 415*df4867cdSChandu Babu N 416*df4867cdSChandu Babu N regs->version = pdata->pci_dev->id.vendor_id << 16 | 417*df4867cdSChandu Babu N pdata->pci_dev->id.device_id; 418*df4867cdSChandu Babu N axgbe_regs_dump(pdata, regs->data); 419*df4867cdSChandu Babu N return 0; 420*df4867cdSChandu Babu N } 4219d1ef6b2SChandu Babu N static void axgbe_read_mmc_stats(struct axgbe_port *pdata) 4229d1ef6b2SChandu Babu N { 4239d1ef6b2SChandu Babu N struct axgbe_mmc_stats *stats = &pdata->mmc_stats; 4249d1ef6b2SChandu Babu N 4259d1ef6b2SChandu Babu N /* Freeze counters */ 4269d1ef6b2SChandu Babu N AXGMAC_IOWRITE_BITS(pdata, MMC_CR, MCF, 1); 4279d1ef6b2SChandu Babu N 4289d1ef6b2SChandu Babu N /* Tx counters */ 4299d1ef6b2SChandu Babu N stats->txoctetcount_gb += 4309d1ef6b2SChandu Babu N AXGMAC_IOREAD(pdata, MMC_TXOCTETCOUNT_GB_LO); 4319d1ef6b2SChandu Babu N stats->txoctetcount_gb += 4329d1ef6b2SChandu Babu N ((uint64_t)AXGMAC_IOREAD(pdata, MMC_TXOCTETCOUNT_GB_HI) << 32); 4339d1ef6b2SChandu Babu N 4349d1ef6b2SChandu Babu N stats->txframecount_gb += 4359d1ef6b2SChandu Babu N AXGMAC_IOREAD(pdata, MMC_TXFRAMECOUNT_GB_LO); 4369d1ef6b2SChandu Babu N stats->txframecount_gb += 4379d1ef6b2SChandu Babu N ((uint64_t)AXGMAC_IOREAD(pdata, MMC_TXFRAMECOUNT_GB_HI) << 32); 4389d1ef6b2SChandu Babu N 4399d1ef6b2SChandu Babu N stats->txbroadcastframes_g += 4409d1ef6b2SChandu Babu N AXGMAC_IOREAD(pdata, MMC_TXBROADCASTFRAMES_G_LO); 4419d1ef6b2SChandu Babu N stats->txbroadcastframes_g += 4429d1ef6b2SChandu Babu N ((uint64_t)AXGMAC_IOREAD(pdata, MMC_TXBROADCASTFRAMES_G_HI) << 32); 4439d1ef6b2SChandu Babu N 4449d1ef6b2SChandu Babu N stats->txmulticastframes_g += 4459d1ef6b2SChandu Babu N AXGMAC_IOREAD(pdata, MMC_TXMULTICASTFRAMES_G_LO); 4469d1ef6b2SChandu Babu N stats->txmulticastframes_g += 4479d1ef6b2SChandu Babu N ((uint64_t)AXGMAC_IOREAD(pdata, MMC_TXMULTICASTFRAMES_G_HI) << 32); 4489d1ef6b2SChandu Babu N 4499d1ef6b2SChandu Babu N stats->tx64octets_gb += 4509d1ef6b2SChandu Babu N AXGMAC_IOREAD(pdata, MMC_TX64OCTETS_GB_LO); 4519d1ef6b2SChandu Babu N stats->tx64octets_gb += 4529d1ef6b2SChandu Babu N ((uint64_t)AXGMAC_IOREAD(pdata, MMC_TX64OCTETS_GB_HI) << 32); 4539d1ef6b2SChandu Babu N 4549d1ef6b2SChandu Babu N stats->tx65to127octets_gb += 4559d1ef6b2SChandu Babu N AXGMAC_IOREAD(pdata, MMC_TX65TO127OCTETS_GB_LO); 4569d1ef6b2SChandu Babu N stats->tx65to127octets_gb += 4579d1ef6b2SChandu Babu N ((uint64_t)AXGMAC_IOREAD(pdata, MMC_TX65TO127OCTETS_GB_HI) << 32); 4589d1ef6b2SChandu Babu N 4599d1ef6b2SChandu Babu N stats->tx128to255octets_gb += 4609d1ef6b2SChandu Babu N AXGMAC_IOREAD(pdata, MMC_TX128TO255OCTETS_GB_LO); 4619d1ef6b2SChandu Babu N stats->tx128to255octets_gb += 4629d1ef6b2SChandu Babu N ((uint64_t)AXGMAC_IOREAD(pdata, MMC_TX128TO255OCTETS_GB_HI) << 32); 4639d1ef6b2SChandu Babu N 4649d1ef6b2SChandu Babu N stats->tx256to511octets_gb += 4659d1ef6b2SChandu Babu N AXGMAC_IOREAD(pdata, MMC_TX256TO511OCTETS_GB_LO); 4669d1ef6b2SChandu Babu N stats->tx256to511octets_gb += 4679d1ef6b2SChandu Babu N ((uint64_t)AXGMAC_IOREAD(pdata, MMC_TX256TO511OCTETS_GB_HI) << 32); 4689d1ef6b2SChandu Babu N 4699d1ef6b2SChandu Babu N stats->tx512to1023octets_gb += 4709d1ef6b2SChandu Babu N AXGMAC_IOREAD(pdata, MMC_TX512TO1023OCTETS_GB_LO); 4719d1ef6b2SChandu Babu N stats->tx512to1023octets_gb += 4729d1ef6b2SChandu Babu N ((uint64_t)AXGMAC_IOREAD(pdata, MMC_TX512TO1023OCTETS_GB_HI) << 32); 4739d1ef6b2SChandu Babu N 4749d1ef6b2SChandu Babu N stats->tx1024tomaxoctets_gb += 4759d1ef6b2SChandu Babu N AXGMAC_IOREAD(pdata, MMC_TX1024TOMAXOCTETS_GB_LO); 4769d1ef6b2SChandu Babu N stats->tx1024tomaxoctets_gb += 4779d1ef6b2SChandu Babu N ((uint64_t)AXGMAC_IOREAD(pdata, MMC_TX1024TOMAXOCTETS_GB_HI) << 32); 4789d1ef6b2SChandu Babu N 4799d1ef6b2SChandu Babu N stats->txunicastframes_gb += 4809d1ef6b2SChandu Babu N AXGMAC_IOREAD(pdata, MMC_TXUNICASTFRAMES_GB_LO); 4819d1ef6b2SChandu Babu N stats->txunicastframes_gb += 4829d1ef6b2SChandu Babu N ((uint64_t)AXGMAC_IOREAD(pdata, MMC_TXUNICASTFRAMES_GB_HI) << 32); 4839d1ef6b2SChandu Babu N 4849d1ef6b2SChandu Babu N stats->txmulticastframes_gb += 4859d1ef6b2SChandu Babu N AXGMAC_IOREAD(pdata, MMC_TXMULTICASTFRAMES_GB_LO); 4869d1ef6b2SChandu Babu N stats->txmulticastframes_gb += 4879d1ef6b2SChandu Babu N ((uint64_t)AXGMAC_IOREAD(pdata, MMC_TXMULTICASTFRAMES_GB_HI) << 32); 4889d1ef6b2SChandu Babu N 4899d1ef6b2SChandu Babu N stats->txbroadcastframes_g += 4909d1ef6b2SChandu Babu N AXGMAC_IOREAD(pdata, MMC_TXBROADCASTFRAMES_GB_LO); 4919d1ef6b2SChandu Babu N stats->txbroadcastframes_g += 4929d1ef6b2SChandu Babu N ((uint64_t)AXGMAC_IOREAD(pdata, MMC_TXBROADCASTFRAMES_GB_HI) << 32); 4939d1ef6b2SChandu Babu N 4949d1ef6b2SChandu Babu N stats->txunderflowerror += 4959d1ef6b2SChandu Babu N AXGMAC_IOREAD(pdata, MMC_TXUNDERFLOWERROR_LO); 4969d1ef6b2SChandu Babu N stats->txunderflowerror += 4979d1ef6b2SChandu Babu N ((uint64_t)AXGMAC_IOREAD(pdata, MMC_TXUNDERFLOWERROR_HI) << 32); 4989d1ef6b2SChandu Babu N 4999d1ef6b2SChandu Babu N stats->txoctetcount_g += 5009d1ef6b2SChandu Babu N AXGMAC_IOREAD(pdata, MMC_TXOCTETCOUNT_G_LO); 5019d1ef6b2SChandu Babu N stats->txoctetcount_g += 5029d1ef6b2SChandu Babu N ((uint64_t)AXGMAC_IOREAD(pdata, MMC_TXOCTETCOUNT_G_HI) << 32); 5039d1ef6b2SChandu Babu N 5049d1ef6b2SChandu Babu N stats->txframecount_g += 5059d1ef6b2SChandu Babu N AXGMAC_IOREAD(pdata, MMC_TXFRAMECOUNT_G_LO); 5069d1ef6b2SChandu Babu N stats->txframecount_g += 5079d1ef6b2SChandu Babu N ((uint64_t)AXGMAC_IOREAD(pdata, MMC_TXFRAMECOUNT_G_HI) << 32); 5089d1ef6b2SChandu Babu N 5099d1ef6b2SChandu Babu N stats->txpauseframes += 5109d1ef6b2SChandu Babu N AXGMAC_IOREAD(pdata, MMC_TXPAUSEFRAMES_LO); 5119d1ef6b2SChandu Babu N stats->txpauseframes += 5129d1ef6b2SChandu Babu N ((uint64_t)AXGMAC_IOREAD(pdata, MMC_TXPAUSEFRAMES_HI) << 32); 5139d1ef6b2SChandu Babu N 5149d1ef6b2SChandu Babu N stats->txvlanframes_g += 5159d1ef6b2SChandu Babu N AXGMAC_IOREAD(pdata, MMC_TXVLANFRAMES_G_LO); 5169d1ef6b2SChandu Babu N stats->txvlanframes_g += 5179d1ef6b2SChandu Babu N ((uint64_t)AXGMAC_IOREAD(pdata, MMC_TXVLANFRAMES_G_HI) << 32); 5189d1ef6b2SChandu Babu N 5199d1ef6b2SChandu Babu N /* Rx counters */ 5209d1ef6b2SChandu Babu N stats->rxframecount_gb += 5219d1ef6b2SChandu Babu N AXGMAC_IOREAD(pdata, MMC_RXFRAMECOUNT_GB_LO); 5229d1ef6b2SChandu Babu N stats->rxframecount_gb += 5239d1ef6b2SChandu Babu N ((uint64_t)AXGMAC_IOREAD(pdata, MMC_RXFRAMECOUNT_GB_HI) << 32); 5249d1ef6b2SChandu Babu N 5259d1ef6b2SChandu Babu N stats->rxoctetcount_gb += 5269d1ef6b2SChandu Babu N AXGMAC_IOREAD(pdata, MMC_RXOCTETCOUNT_GB_LO); 5279d1ef6b2SChandu Babu N stats->rxoctetcount_gb += 5289d1ef6b2SChandu Babu N ((uint64_t)AXGMAC_IOREAD(pdata, MMC_RXOCTETCOUNT_GB_HI) << 32); 5299d1ef6b2SChandu Babu N 5309d1ef6b2SChandu Babu N stats->rxoctetcount_g += 5319d1ef6b2SChandu Babu N AXGMAC_IOREAD(pdata, MMC_RXOCTETCOUNT_G_LO); 5329d1ef6b2SChandu Babu N stats->rxoctetcount_g += 5339d1ef6b2SChandu Babu N ((uint64_t)AXGMAC_IOREAD(pdata, MMC_RXOCTETCOUNT_G_HI) << 32); 5349d1ef6b2SChandu Babu N 5359d1ef6b2SChandu Babu N stats->rxbroadcastframes_g += 5369d1ef6b2SChandu Babu N AXGMAC_IOREAD(pdata, MMC_RXBROADCASTFRAMES_G_LO); 5379d1ef6b2SChandu Babu N stats->rxbroadcastframes_g += 5389d1ef6b2SChandu Babu N ((uint64_t)AXGMAC_IOREAD(pdata, MMC_RXBROADCASTFRAMES_G_HI) << 32); 5399d1ef6b2SChandu Babu N 5409d1ef6b2SChandu Babu N stats->rxmulticastframes_g += 5419d1ef6b2SChandu Babu N AXGMAC_IOREAD(pdata, MMC_RXMULTICASTFRAMES_G_LO); 5429d1ef6b2SChandu Babu N stats->rxmulticastframes_g += 5439d1ef6b2SChandu Babu N ((uint64_t)AXGMAC_IOREAD(pdata, MMC_RXMULTICASTFRAMES_G_HI) << 32); 5449d1ef6b2SChandu Babu N 5459d1ef6b2SChandu Babu N stats->rxcrcerror += 5469d1ef6b2SChandu Babu N AXGMAC_IOREAD(pdata, MMC_RXCRCERROR_LO); 5479d1ef6b2SChandu Babu N stats->rxcrcerror += 5489d1ef6b2SChandu Babu N ((uint64_t)AXGMAC_IOREAD(pdata, MMC_RXCRCERROR_HI) << 32); 5499d1ef6b2SChandu Babu N 5509d1ef6b2SChandu Babu N stats->rxrunterror += 5519d1ef6b2SChandu Babu N AXGMAC_IOREAD(pdata, MMC_RXRUNTERROR); 5529d1ef6b2SChandu Babu N 5539d1ef6b2SChandu Babu N stats->rxjabbererror += 5549d1ef6b2SChandu Babu N AXGMAC_IOREAD(pdata, MMC_RXJABBERERROR); 5559d1ef6b2SChandu Babu N 5569d1ef6b2SChandu Babu N stats->rxundersize_g += 5579d1ef6b2SChandu Babu N AXGMAC_IOREAD(pdata, MMC_RXUNDERSIZE_G); 5589d1ef6b2SChandu Babu N 5599d1ef6b2SChandu Babu N stats->rxoversize_g += 5609d1ef6b2SChandu Babu N AXGMAC_IOREAD(pdata, MMC_RXOVERSIZE_G); 5619d1ef6b2SChandu Babu N 5629d1ef6b2SChandu Babu N stats->rx64octets_gb += 5639d1ef6b2SChandu Babu N AXGMAC_IOREAD(pdata, MMC_RX64OCTETS_GB_LO); 5649d1ef6b2SChandu Babu N stats->rx64octets_gb += 5659d1ef6b2SChandu Babu N ((uint64_t)AXGMAC_IOREAD(pdata, MMC_RX64OCTETS_GB_HI) << 32); 5669d1ef6b2SChandu Babu N 5679d1ef6b2SChandu Babu N stats->rx65to127octets_gb += 5689d1ef6b2SChandu Babu N AXGMAC_IOREAD(pdata, MMC_RX65TO127OCTETS_GB_LO); 5699d1ef6b2SChandu Babu N stats->rx65to127octets_gb += 5709d1ef6b2SChandu Babu N ((uint64_t)AXGMAC_IOREAD(pdata, MMC_RX65TO127OCTETS_GB_HI) << 32); 5719d1ef6b2SChandu Babu N 5729d1ef6b2SChandu Babu N stats->rx128to255octets_gb += 5739d1ef6b2SChandu Babu N AXGMAC_IOREAD(pdata, MMC_RX128TO255OCTETS_GB_LO); 5749d1ef6b2SChandu Babu N stats->rx128to255octets_gb += 5759d1ef6b2SChandu Babu N ((uint64_t)AXGMAC_IOREAD(pdata, MMC_RX128TO255OCTETS_GB_HI) << 32); 5769d1ef6b2SChandu Babu N 5779d1ef6b2SChandu Babu N stats->rx256to511octets_gb += 5789d1ef6b2SChandu Babu N AXGMAC_IOREAD(pdata, MMC_RX256TO511OCTETS_GB_LO); 5799d1ef6b2SChandu Babu N stats->rx256to511octets_gb += 5809d1ef6b2SChandu Babu N ((uint64_t)AXGMAC_IOREAD(pdata, MMC_RX256TO511OCTETS_GB_HI) << 32); 5819d1ef6b2SChandu Babu N 5829d1ef6b2SChandu Babu N stats->rx512to1023octets_gb += 5839d1ef6b2SChandu Babu N AXGMAC_IOREAD(pdata, MMC_RX512TO1023OCTETS_GB_LO); 5849d1ef6b2SChandu Babu N stats->rx512to1023octets_gb += 5859d1ef6b2SChandu Babu N ((uint64_t)AXGMAC_IOREAD(pdata, MMC_RX512TO1023OCTETS_GB_HI) << 32); 5869d1ef6b2SChandu Babu N 5879d1ef6b2SChandu Babu N stats->rx1024tomaxoctets_gb += 5889d1ef6b2SChandu Babu N AXGMAC_IOREAD(pdata, MMC_RX1024TOMAXOCTETS_GB_LO); 5899d1ef6b2SChandu Babu N stats->rx1024tomaxoctets_gb += 5909d1ef6b2SChandu Babu N ((uint64_t)AXGMAC_IOREAD(pdata, MMC_RX1024TOMAXOCTETS_GB_HI) << 32); 5919d1ef6b2SChandu Babu N 5929d1ef6b2SChandu Babu N stats->rxunicastframes_g += 5939d1ef6b2SChandu Babu N AXGMAC_IOREAD(pdata, MMC_RXUNICASTFRAMES_G_LO); 5949d1ef6b2SChandu Babu N stats->rxunicastframes_g += 5959d1ef6b2SChandu Babu N ((uint64_t)AXGMAC_IOREAD(pdata, MMC_RXUNICASTFRAMES_G_HI) << 32); 5969d1ef6b2SChandu Babu N 5979d1ef6b2SChandu Babu N stats->rxlengtherror += 5989d1ef6b2SChandu Babu N AXGMAC_IOREAD(pdata, MMC_RXLENGTHERROR_LO); 5999d1ef6b2SChandu Babu N stats->rxlengtherror += 6009d1ef6b2SChandu Babu N ((uint64_t)AXGMAC_IOREAD(pdata, MMC_RXLENGTHERROR_HI) << 32); 6019d1ef6b2SChandu Babu N 6029d1ef6b2SChandu Babu N stats->rxoutofrangetype += 6039d1ef6b2SChandu Babu N AXGMAC_IOREAD(pdata, MMC_RXOUTOFRANGETYPE_LO); 6049d1ef6b2SChandu Babu N stats->rxoutofrangetype += 6059d1ef6b2SChandu Babu N ((uint64_t)AXGMAC_IOREAD(pdata, MMC_RXOUTOFRANGETYPE_HI) << 32); 6069d1ef6b2SChandu Babu N 6079d1ef6b2SChandu Babu N stats->rxpauseframes += 6089d1ef6b2SChandu Babu N AXGMAC_IOREAD(pdata, MMC_RXPAUSEFRAMES_LO); 6099d1ef6b2SChandu Babu N stats->rxpauseframes += 6109d1ef6b2SChandu Babu N ((uint64_t)AXGMAC_IOREAD(pdata, MMC_RXPAUSEFRAMES_HI) << 32); 6119d1ef6b2SChandu Babu N 6129d1ef6b2SChandu Babu N stats->rxfifooverflow += 6139d1ef6b2SChandu Babu N AXGMAC_IOREAD(pdata, MMC_RXFIFOOVERFLOW_LO); 6149d1ef6b2SChandu Babu N stats->rxfifooverflow += 6159d1ef6b2SChandu Babu N ((uint64_t)AXGMAC_IOREAD(pdata, MMC_RXFIFOOVERFLOW_HI) << 32); 6169d1ef6b2SChandu Babu N 6179d1ef6b2SChandu Babu N stats->rxvlanframes_gb += 6189d1ef6b2SChandu Babu N AXGMAC_IOREAD(pdata, MMC_RXVLANFRAMES_GB_LO); 6199d1ef6b2SChandu Babu N stats->rxvlanframes_gb += 6209d1ef6b2SChandu Babu N ((uint64_t)AXGMAC_IOREAD(pdata, MMC_RXVLANFRAMES_GB_HI) << 32); 6219d1ef6b2SChandu Babu N 6229d1ef6b2SChandu Babu N stats->rxwatchdogerror += 6239d1ef6b2SChandu Babu N AXGMAC_IOREAD(pdata, MMC_RXWATCHDOGERROR); 6249d1ef6b2SChandu Babu N 6259d1ef6b2SChandu Babu N /* Un-freeze counters */ 6269d1ef6b2SChandu Babu N AXGMAC_IOWRITE_BITS(pdata, MMC_CR, MCF, 0); 6279d1ef6b2SChandu Babu N } 6289d1ef6b2SChandu Babu N 6299d1ef6b2SChandu Babu N static int 6309d1ef6b2SChandu Babu N axgbe_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *stats, 6319d1ef6b2SChandu Babu N unsigned int n) 6329d1ef6b2SChandu Babu N { 6339d1ef6b2SChandu Babu N struct axgbe_port *pdata = dev->data->dev_private; 6349d1ef6b2SChandu Babu N unsigned int i; 6359d1ef6b2SChandu Babu N 6369d1ef6b2SChandu Babu N if (!stats) 6379d1ef6b2SChandu Babu N return 0; 6389d1ef6b2SChandu Babu N 6399d1ef6b2SChandu Babu N axgbe_read_mmc_stats(pdata); 6409d1ef6b2SChandu Babu N 6419d1ef6b2SChandu Babu N for (i = 0; i < n && i < AXGBE_XSTATS_COUNT; i++) { 6429d1ef6b2SChandu Babu N stats[i].id = i; 6439d1ef6b2SChandu Babu N stats[i].value = *(u64 *)((uint8_t *)&pdata->mmc_stats + 6449d1ef6b2SChandu Babu N axgbe_xstats_strings[i].offset); 6459d1ef6b2SChandu Babu N } 6469d1ef6b2SChandu Babu N 6479d1ef6b2SChandu Babu N return i; 6489d1ef6b2SChandu Babu N } 6499d1ef6b2SChandu Babu N 6509d1ef6b2SChandu Babu N static int 6519d1ef6b2SChandu Babu N axgbe_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, 6529d1ef6b2SChandu Babu N struct rte_eth_xstat_name *xstats_names, 6539d1ef6b2SChandu Babu N unsigned int n) 6549d1ef6b2SChandu Babu N { 6559d1ef6b2SChandu Babu N unsigned int i; 6569d1ef6b2SChandu Babu N 6579d1ef6b2SChandu Babu N if (n >= AXGBE_XSTATS_COUNT && xstats_names) { 6589d1ef6b2SChandu Babu N for (i = 0; i < AXGBE_XSTATS_COUNT; ++i) { 6599d1ef6b2SChandu Babu N snprintf(xstats_names[i].name, 6609d1ef6b2SChandu Babu N RTE_ETH_XSTATS_NAME_SIZE, "%s", 6619d1ef6b2SChandu Babu N axgbe_xstats_strings[i].name); 6629d1ef6b2SChandu Babu N } 6639d1ef6b2SChandu Babu N } 6649d1ef6b2SChandu Babu N 6659d1ef6b2SChandu Babu N return AXGBE_XSTATS_COUNT; 6669d1ef6b2SChandu Babu N } 6679d1ef6b2SChandu Babu N 6689d1ef6b2SChandu Babu N static int 6699d1ef6b2SChandu Babu N axgbe_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, 6709d1ef6b2SChandu Babu N uint64_t *values, unsigned int n) 6719d1ef6b2SChandu Babu N { 6729d1ef6b2SChandu Babu N unsigned int i; 6739d1ef6b2SChandu Babu N uint64_t values_copy[AXGBE_XSTATS_COUNT]; 6749d1ef6b2SChandu Babu N 6759d1ef6b2SChandu Babu N if (!ids) { 6769d1ef6b2SChandu Babu N struct axgbe_port *pdata = dev->data->dev_private; 6779d1ef6b2SChandu Babu N 6789d1ef6b2SChandu Babu N if (n < AXGBE_XSTATS_COUNT) 6799d1ef6b2SChandu Babu N return AXGBE_XSTATS_COUNT; 6809d1ef6b2SChandu Babu N 6819d1ef6b2SChandu Babu N axgbe_read_mmc_stats(pdata); 6829d1ef6b2SChandu Babu N 6839d1ef6b2SChandu Babu N for (i = 0; i < AXGBE_XSTATS_COUNT; i++) { 6849d1ef6b2SChandu Babu N values[i] = *(u64 *)((uint8_t *)&pdata->mmc_stats + 6859d1ef6b2SChandu Babu N axgbe_xstats_strings[i].offset); 6869d1ef6b2SChandu Babu N } 6879d1ef6b2SChandu Babu N 6889d1ef6b2SChandu Babu N return i; 6899d1ef6b2SChandu Babu N } 6909d1ef6b2SChandu Babu N 6919d1ef6b2SChandu Babu N axgbe_dev_xstats_get_by_id(dev, NULL, values_copy, AXGBE_XSTATS_COUNT); 6929d1ef6b2SChandu Babu N 6939d1ef6b2SChandu Babu N for (i = 0; i < n; i++) { 6949d1ef6b2SChandu Babu N if (ids[i] >= AXGBE_XSTATS_COUNT) { 6959d1ef6b2SChandu Babu N PMD_DRV_LOG(ERR, "id value isn't valid\n"); 6969d1ef6b2SChandu Babu N return -1; 6979d1ef6b2SChandu Babu N } 6989d1ef6b2SChandu Babu N values[i] = values_copy[ids[i]]; 6999d1ef6b2SChandu Babu N } 7009d1ef6b2SChandu Babu N return n; 7019d1ef6b2SChandu Babu N } 7029d1ef6b2SChandu Babu N 7039d1ef6b2SChandu Babu N static int 7049d1ef6b2SChandu Babu N axgbe_dev_xstats_get_names_by_id(struct rte_eth_dev *dev, 7059d1ef6b2SChandu Babu N struct rte_eth_xstat_name *xstats_names, 7069d1ef6b2SChandu Babu N const uint64_t *ids, 7079d1ef6b2SChandu Babu N unsigned int size) 7089d1ef6b2SChandu Babu N { 7099d1ef6b2SChandu Babu N struct rte_eth_xstat_name xstats_names_copy[AXGBE_XSTATS_COUNT]; 7109d1ef6b2SChandu Babu N unsigned int i; 7119d1ef6b2SChandu Babu N 7129d1ef6b2SChandu Babu N if (!ids) 7139d1ef6b2SChandu Babu N return axgbe_dev_xstats_get_names(dev, xstats_names, size); 7149d1ef6b2SChandu Babu N 7159d1ef6b2SChandu Babu N axgbe_dev_xstats_get_names(dev, xstats_names_copy, size); 7169d1ef6b2SChandu Babu N 7179d1ef6b2SChandu Babu N for (i = 0; i < size; i++) { 7189d1ef6b2SChandu Babu N if (ids[i] >= AXGBE_XSTATS_COUNT) { 7199d1ef6b2SChandu Babu N PMD_DRV_LOG(ERR, "id value isn't valid\n"); 7209d1ef6b2SChandu Babu N return -1; 7219d1ef6b2SChandu Babu N } 7229d1ef6b2SChandu Babu N strcpy(xstats_names[i].name, xstats_names_copy[ids[i]].name); 7239d1ef6b2SChandu Babu N } 7249d1ef6b2SChandu Babu N return size; 7259d1ef6b2SChandu Babu N } 7269d1ef6b2SChandu Babu N 7279d1ef6b2SChandu Babu N static int 7289d1ef6b2SChandu Babu N axgbe_dev_xstats_reset(struct rte_eth_dev *dev) 7299d1ef6b2SChandu Babu N { 7309d1ef6b2SChandu Babu N struct axgbe_port *pdata = dev->data->dev_private; 7319d1ef6b2SChandu Babu N struct axgbe_mmc_stats *stats = &pdata->mmc_stats; 7329d1ef6b2SChandu Babu N 7339d1ef6b2SChandu Babu N /* MMC registers are configured for reset on read */ 7349d1ef6b2SChandu Babu N axgbe_read_mmc_stats(pdata); 7359d1ef6b2SChandu Babu N 7369d1ef6b2SChandu Babu N /* Reset stats */ 7379d1ef6b2SChandu Babu N memset(stats, 0, sizeof(*stats)); 7389d1ef6b2SChandu Babu N 7399d1ef6b2SChandu Babu N return 0; 7409d1ef6b2SChandu Babu N } 7419d1ef6b2SChandu Babu N 7423e730511SRavi Kumar static int 7433e730511SRavi Kumar axgbe_dev_stats_get(struct rte_eth_dev *dev, 7443e730511SRavi Kumar struct rte_eth_stats *stats) 7453e730511SRavi Kumar { 7463e730511SRavi Kumar struct axgbe_rx_queue *rxq; 7473e730511SRavi Kumar struct axgbe_tx_queue *txq; 7489d1ef6b2SChandu Babu N struct axgbe_port *pdata = dev->data->dev_private; 7499d1ef6b2SChandu Babu N struct axgbe_mmc_stats *mmc_stats = &pdata->mmc_stats; 7503e730511SRavi Kumar unsigned int i; 7513e730511SRavi Kumar 7529d1ef6b2SChandu Babu N axgbe_read_mmc_stats(pdata); 7539d1ef6b2SChandu Babu N 7549d1ef6b2SChandu Babu N stats->imissed = mmc_stats->rxfifooverflow; 7559d1ef6b2SChandu Babu N 7563e730511SRavi Kumar for (i = 0; i < dev->data->nb_rx_queues; i++) { 7573e730511SRavi Kumar rxq = dev->data->rx_queues[i]; 7583e730511SRavi Kumar stats->q_ipackets[i] = rxq->pkts; 7593e730511SRavi Kumar stats->ipackets += rxq->pkts; 7603e730511SRavi Kumar stats->q_ibytes[i] = rxq->bytes; 7613e730511SRavi Kumar stats->ibytes += rxq->bytes; 7629d1ef6b2SChandu Babu N stats->rx_nombuf += rxq->rx_mbuf_alloc_failed; 7639d1ef6b2SChandu Babu N stats->q_errors[i] = rxq->errors + rxq->rx_mbuf_alloc_failed; 7649d1ef6b2SChandu Babu N stats->ierrors += rxq->errors; 7653e730511SRavi Kumar } 7669d1ef6b2SChandu Babu N 7673e730511SRavi Kumar for (i = 0; i < dev->data->nb_tx_queues; i++) { 7683e730511SRavi Kumar txq = dev->data->tx_queues[i]; 7693e730511SRavi Kumar stats->q_opackets[i] = txq->pkts; 7703e730511SRavi Kumar stats->opackets += txq->pkts; 7713e730511SRavi Kumar stats->q_obytes[i] = txq->bytes; 7723e730511SRavi Kumar stats->obytes += txq->bytes; 7739d1ef6b2SChandu Babu N stats->oerrors += txq->errors; 7743e730511SRavi Kumar } 7753e730511SRavi Kumar 7763e730511SRavi Kumar return 0; 7773e730511SRavi Kumar } 7783e730511SRavi Kumar 7799970a9adSIgor Romanov static int 7803e730511SRavi Kumar axgbe_dev_stats_reset(struct rte_eth_dev *dev) 7813e730511SRavi Kumar { 7823e730511SRavi Kumar struct axgbe_rx_queue *rxq; 7833e730511SRavi Kumar struct axgbe_tx_queue *txq; 7843e730511SRavi Kumar unsigned int i; 7853e730511SRavi Kumar 7863e730511SRavi Kumar for (i = 0; i < dev->data->nb_rx_queues; i++) { 7873e730511SRavi Kumar rxq = dev->data->rx_queues[i]; 7883e730511SRavi Kumar rxq->pkts = 0; 7893e730511SRavi Kumar rxq->bytes = 0; 7903e730511SRavi Kumar rxq->errors = 0; 7919d1ef6b2SChandu Babu N rxq->rx_mbuf_alloc_failed = 0; 7923e730511SRavi Kumar } 7933e730511SRavi Kumar for (i = 0; i < dev->data->nb_tx_queues; i++) { 7943e730511SRavi Kumar txq = dev->data->tx_queues[i]; 7953e730511SRavi Kumar txq->pkts = 0; 7963e730511SRavi Kumar txq->bytes = 0; 7973e730511SRavi Kumar txq->errors = 0; 7983e730511SRavi Kumar } 7999970a9adSIgor Romanov 8009970a9adSIgor Romanov return 0; 8013e730511SRavi Kumar } 8023e730511SRavi Kumar 803bdad90d1SIvan Ilchenko static int 804cd8c7c7cSFerruh Yigit axgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) 8059e890103SRavi Kumar { 8069e890103SRavi Kumar struct axgbe_port *pdata = dev->data->dev_private; 8079e890103SRavi Kumar 8089e890103SRavi Kumar dev_info->max_rx_queues = pdata->rx_ring_count; 8099e890103SRavi Kumar dev_info->max_tx_queues = pdata->tx_ring_count; 8109e890103SRavi Kumar dev_info->min_rx_bufsize = AXGBE_RX_MIN_BUF_SIZE; 8119e890103SRavi Kumar dev_info->max_rx_pktlen = AXGBE_RX_MAX_BUF_SIZE; 8129e890103SRavi Kumar dev_info->max_mac_addrs = AXGBE_MAX_MAC_ADDRS; 8139e890103SRavi Kumar dev_info->speed_capa = ETH_LINK_SPEED_10G; 8149e890103SRavi Kumar 8159e890103SRavi Kumar dev_info->rx_offload_capa = 8169e890103SRavi Kumar DEV_RX_OFFLOAD_IPV4_CKSUM | 8179e890103SRavi Kumar DEV_RX_OFFLOAD_UDP_CKSUM | 81870815c9eSFerruh Yigit DEV_RX_OFFLOAD_TCP_CKSUM | 81970815c9eSFerruh Yigit DEV_RX_OFFLOAD_KEEP_CRC; 8209e890103SRavi Kumar 8219e890103SRavi Kumar dev_info->tx_offload_capa = 8229e890103SRavi Kumar DEV_TX_OFFLOAD_IPV4_CKSUM | 8239e890103SRavi Kumar DEV_TX_OFFLOAD_UDP_CKSUM | 8249e890103SRavi Kumar DEV_TX_OFFLOAD_TCP_CKSUM; 8259e890103SRavi Kumar 8269e890103SRavi Kumar if (pdata->hw_feat.rss) { 8279e890103SRavi Kumar dev_info->flow_type_rss_offloads = AXGBE_RSS_OFFLOAD; 8289e890103SRavi Kumar dev_info->reta_size = pdata->hw_feat.hash_table_size; 8299e890103SRavi Kumar dev_info->hash_key_size = AXGBE_RSS_HASH_KEY_SIZE; 8309e890103SRavi Kumar } 8319e890103SRavi Kumar 8329e890103SRavi Kumar dev_info->rx_desc_lim = rx_desc_lim; 8339e890103SRavi Kumar dev_info->tx_desc_lim = tx_desc_lim; 8349e890103SRavi Kumar 8359e890103SRavi Kumar dev_info->default_rxconf = (struct rte_eth_rxconf) { 8369e890103SRavi Kumar .rx_free_thresh = AXGBE_RX_FREE_THRESH, 8379e890103SRavi Kumar }; 8389e890103SRavi Kumar 8399e890103SRavi Kumar dev_info->default_txconf = (struct rte_eth_txconf) { 8409e890103SRavi Kumar .tx_free_thresh = AXGBE_TX_FREE_THRESH, 8419e890103SRavi Kumar }; 842bdad90d1SIvan Ilchenko 843bdad90d1SIvan Ilchenko return 0; 8449e890103SRavi Kumar } 8459e890103SRavi Kumar 846572890efSRavi Kumar static void axgbe_get_all_hw_features(struct axgbe_port *pdata) 847572890efSRavi Kumar { 848572890efSRavi Kumar unsigned int mac_hfr0, mac_hfr1, mac_hfr2; 849572890efSRavi Kumar struct axgbe_hw_features *hw_feat = &pdata->hw_feat; 850572890efSRavi Kumar 851572890efSRavi Kumar mac_hfr0 = AXGMAC_IOREAD(pdata, MAC_HWF0R); 852572890efSRavi Kumar mac_hfr1 = AXGMAC_IOREAD(pdata, MAC_HWF1R); 853572890efSRavi Kumar mac_hfr2 = AXGMAC_IOREAD(pdata, MAC_HWF2R); 854572890efSRavi Kumar 855572890efSRavi Kumar memset(hw_feat, 0, sizeof(*hw_feat)); 856572890efSRavi Kumar 857572890efSRavi Kumar hw_feat->version = AXGMAC_IOREAD(pdata, MAC_VR); 858572890efSRavi Kumar 859572890efSRavi Kumar /* Hardware feature register 0 */ 860572890efSRavi Kumar hw_feat->gmii = AXGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, GMIISEL); 861572890efSRavi Kumar hw_feat->vlhash = AXGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, VLHASH); 862572890efSRavi Kumar hw_feat->sma = AXGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, SMASEL); 863572890efSRavi Kumar hw_feat->rwk = AXGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, RWKSEL); 864572890efSRavi Kumar hw_feat->mgk = AXGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, MGKSEL); 865572890efSRavi Kumar hw_feat->mmc = AXGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, MMCSEL); 866572890efSRavi Kumar hw_feat->aoe = AXGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, ARPOFFSEL); 867572890efSRavi Kumar hw_feat->ts = AXGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, TSSEL); 868572890efSRavi Kumar hw_feat->eee = AXGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, EEESEL); 869572890efSRavi Kumar hw_feat->tx_coe = AXGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, TXCOESEL); 870572890efSRavi Kumar hw_feat->rx_coe = AXGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, RXCOESEL); 871572890efSRavi Kumar hw_feat->addn_mac = AXGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, 872572890efSRavi Kumar ADDMACADRSEL); 873572890efSRavi Kumar hw_feat->ts_src = AXGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, TSSTSSEL); 874572890efSRavi Kumar hw_feat->sa_vlan_ins = AXGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, SAVLANINS); 875572890efSRavi Kumar 876572890efSRavi Kumar /* Hardware feature register 1 */ 877572890efSRavi Kumar hw_feat->rx_fifo_size = AXGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, 878572890efSRavi Kumar RXFIFOSIZE); 879572890efSRavi Kumar hw_feat->tx_fifo_size = AXGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, 880572890efSRavi Kumar TXFIFOSIZE); 881572890efSRavi Kumar hw_feat->adv_ts_hi = AXGMAC_GET_BITS(mac_hfr1, 882572890efSRavi Kumar MAC_HWF1R, ADVTHWORD); 883572890efSRavi Kumar hw_feat->dma_width = AXGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, ADDR64); 884572890efSRavi Kumar hw_feat->dcb = AXGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, DCBEN); 885572890efSRavi Kumar hw_feat->sph = AXGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, SPHEN); 886572890efSRavi Kumar hw_feat->tso = AXGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, TSOEN); 887572890efSRavi Kumar hw_feat->dma_debug = AXGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, DBGMEMA); 888572890efSRavi Kumar hw_feat->rss = AXGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, RSSEN); 889572890efSRavi Kumar hw_feat->tc_cnt = AXGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, NUMTC); 890572890efSRavi Kumar hw_feat->hash_table_size = AXGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, 891572890efSRavi Kumar HASHTBLSZ); 892572890efSRavi Kumar hw_feat->l3l4_filter_num = AXGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, 893572890efSRavi Kumar L3L4FNUM); 894572890efSRavi Kumar 895572890efSRavi Kumar /* Hardware feature register 2 */ 896572890efSRavi Kumar hw_feat->rx_q_cnt = AXGMAC_GET_BITS(mac_hfr2, MAC_HWF2R, RXQCNT); 897572890efSRavi Kumar hw_feat->tx_q_cnt = AXGMAC_GET_BITS(mac_hfr2, MAC_HWF2R, TXQCNT); 898572890efSRavi Kumar hw_feat->rx_ch_cnt = AXGMAC_GET_BITS(mac_hfr2, MAC_HWF2R, RXCHCNT); 899572890efSRavi Kumar hw_feat->tx_ch_cnt = AXGMAC_GET_BITS(mac_hfr2, MAC_HWF2R, TXCHCNT); 900572890efSRavi Kumar hw_feat->pps_out_num = AXGMAC_GET_BITS(mac_hfr2, MAC_HWF2R, PPSOUTNUM); 901572890efSRavi Kumar hw_feat->aux_snap_num = AXGMAC_GET_BITS(mac_hfr2, MAC_HWF2R, 902572890efSRavi Kumar AUXSNAPNUM); 903572890efSRavi Kumar 904572890efSRavi Kumar /* Translate the Hash Table size into actual number */ 905572890efSRavi Kumar switch (hw_feat->hash_table_size) { 906572890efSRavi Kumar case 0: 907572890efSRavi Kumar break; 908572890efSRavi Kumar case 1: 909572890efSRavi Kumar hw_feat->hash_table_size = 64; 910572890efSRavi Kumar break; 911572890efSRavi Kumar case 2: 912572890efSRavi Kumar hw_feat->hash_table_size = 128; 913572890efSRavi Kumar break; 914572890efSRavi Kumar case 3: 915572890efSRavi Kumar hw_feat->hash_table_size = 256; 916572890efSRavi Kumar break; 917572890efSRavi Kumar } 918572890efSRavi Kumar 919572890efSRavi Kumar /* Translate the address width setting into actual number */ 920572890efSRavi Kumar switch (hw_feat->dma_width) { 921572890efSRavi Kumar case 0: 922572890efSRavi Kumar hw_feat->dma_width = 32; 923572890efSRavi Kumar break; 924572890efSRavi Kumar case 1: 925572890efSRavi Kumar hw_feat->dma_width = 40; 926572890efSRavi Kumar break; 927572890efSRavi Kumar case 2: 928572890efSRavi Kumar hw_feat->dma_width = 48; 929572890efSRavi Kumar break; 930572890efSRavi Kumar default: 931572890efSRavi Kumar hw_feat->dma_width = 32; 932572890efSRavi Kumar } 933572890efSRavi Kumar 934572890efSRavi Kumar /* The Queue, Channel and TC counts are zero based so increment them 935572890efSRavi Kumar * to get the actual number 936572890efSRavi Kumar */ 937572890efSRavi Kumar hw_feat->rx_q_cnt++; 938572890efSRavi Kumar hw_feat->tx_q_cnt++; 939572890efSRavi Kumar hw_feat->rx_ch_cnt++; 940572890efSRavi Kumar hw_feat->tx_ch_cnt++; 941572890efSRavi Kumar hw_feat->tc_cnt++; 942572890efSRavi Kumar 943572890efSRavi Kumar /* Translate the fifo sizes into actual numbers */ 944572890efSRavi Kumar hw_feat->rx_fifo_size = 1 << (hw_feat->rx_fifo_size + 7); 945572890efSRavi Kumar hw_feat->tx_fifo_size = 1 << (hw_feat->tx_fifo_size + 7); 946572890efSRavi Kumar } 947572890efSRavi Kumar 948572890efSRavi Kumar static void axgbe_init_all_fptrs(struct axgbe_port *pdata) 949572890efSRavi Kumar { 950572890efSRavi Kumar axgbe_init_function_ptrs_dev(&pdata->hw_if); 9514ac7516bSRavi Kumar axgbe_init_function_ptrs_phy(&pdata->phy_if); 9524ac7516bSRavi Kumar axgbe_init_function_ptrs_i2c(&pdata->i2c_if); 9534ac7516bSRavi Kumar pdata->vdata->init_function_ptrs_phy_impl(&pdata->phy_if); 954572890efSRavi Kumar } 955572890efSRavi Kumar 956572890efSRavi Kumar static void axgbe_set_counts(struct axgbe_port *pdata) 957572890efSRavi Kumar { 958572890efSRavi Kumar /* Set all the function pointers */ 959572890efSRavi Kumar axgbe_init_all_fptrs(pdata); 960572890efSRavi Kumar 961572890efSRavi Kumar /* Populate the hardware features */ 962572890efSRavi Kumar axgbe_get_all_hw_features(pdata); 963572890efSRavi Kumar 964572890efSRavi Kumar /* Set default max values if not provided */ 965572890efSRavi Kumar if (!pdata->tx_max_channel_count) 966572890efSRavi Kumar pdata->tx_max_channel_count = pdata->hw_feat.tx_ch_cnt; 967572890efSRavi Kumar if (!pdata->rx_max_channel_count) 968572890efSRavi Kumar pdata->rx_max_channel_count = pdata->hw_feat.rx_ch_cnt; 969572890efSRavi Kumar 970572890efSRavi Kumar if (!pdata->tx_max_q_count) 971572890efSRavi Kumar pdata->tx_max_q_count = pdata->hw_feat.tx_q_cnt; 972572890efSRavi Kumar if (!pdata->rx_max_q_count) 973572890efSRavi Kumar pdata->rx_max_q_count = pdata->hw_feat.rx_q_cnt; 974572890efSRavi Kumar 975572890efSRavi Kumar /* Calculate the number of Tx and Rx rings to be created 976572890efSRavi Kumar * -Tx (DMA) Channels map 1-to-1 to Tx Queues so set 977572890efSRavi Kumar * the number of Tx queues to the number of Tx channels 978572890efSRavi Kumar * enabled 979572890efSRavi Kumar * -Rx (DMA) Channels do not map 1-to-1 so use the actual 980572890efSRavi Kumar * number of Rx queues or maximum allowed 981572890efSRavi Kumar */ 982572890efSRavi Kumar pdata->tx_ring_count = RTE_MIN(pdata->hw_feat.tx_ch_cnt, 983572890efSRavi Kumar pdata->tx_max_channel_count); 984572890efSRavi Kumar pdata->tx_ring_count = RTE_MIN(pdata->tx_ring_count, 985572890efSRavi Kumar pdata->tx_max_q_count); 986572890efSRavi Kumar 987572890efSRavi Kumar pdata->tx_q_count = pdata->tx_ring_count; 988572890efSRavi Kumar 989572890efSRavi Kumar pdata->rx_ring_count = RTE_MIN(pdata->hw_feat.rx_ch_cnt, 990572890efSRavi Kumar pdata->rx_max_channel_count); 991572890efSRavi Kumar 992572890efSRavi Kumar pdata->rx_q_count = RTE_MIN(pdata->hw_feat.rx_q_cnt, 993572890efSRavi Kumar pdata->rx_max_q_count); 994572890efSRavi Kumar } 995572890efSRavi Kumar 996572890efSRavi Kumar static void axgbe_default_config(struct axgbe_port *pdata) 997572890efSRavi Kumar { 998572890efSRavi Kumar pdata->pblx8 = DMA_PBL_X8_ENABLE; 999572890efSRavi Kumar pdata->tx_sf_mode = MTL_TSF_ENABLE; 1000572890efSRavi Kumar pdata->tx_threshold = MTL_TX_THRESHOLD_64; 1001572890efSRavi Kumar pdata->tx_pbl = DMA_PBL_32; 1002572890efSRavi Kumar pdata->tx_osp_mode = DMA_OSP_ENABLE; 1003572890efSRavi Kumar pdata->rx_sf_mode = MTL_RSF_ENABLE; 1004572890efSRavi Kumar pdata->rx_threshold = MTL_RX_THRESHOLD_64; 1005572890efSRavi Kumar pdata->rx_pbl = DMA_PBL_32; 1006572890efSRavi Kumar pdata->pause_autoneg = 1; 1007572890efSRavi Kumar pdata->tx_pause = 0; 1008572890efSRavi Kumar pdata->rx_pause = 0; 1009572890efSRavi Kumar pdata->phy_speed = SPEED_UNKNOWN; 1010572890efSRavi Kumar pdata->power_down = 0; 1011572890efSRavi Kumar } 1012572890efSRavi Kumar 1013991e0b1dSSelwin Sebastian static int 1014991e0b1dSSelwin Sebastian pci_device_cmp(const struct rte_device *dev, const void *_pci_id) 1015991e0b1dSSelwin Sebastian { 1016991e0b1dSSelwin Sebastian const struct rte_pci_device *pdev = RTE_DEV_TO_PCI_CONST(dev); 1017991e0b1dSSelwin Sebastian const struct rte_pci_id *pcid = _pci_id; 1018991e0b1dSSelwin Sebastian 1019991e0b1dSSelwin Sebastian if (pdev->id.vendor_id == AMD_PCI_VENDOR_ID && 1020991e0b1dSSelwin Sebastian pdev->id.device_id == pcid->device_id) 1021991e0b1dSSelwin Sebastian return 0; 1022991e0b1dSSelwin Sebastian return 1; 1023991e0b1dSSelwin Sebastian } 1024991e0b1dSSelwin Sebastian 1025991e0b1dSSelwin Sebastian static bool 1026991e0b1dSSelwin Sebastian pci_search_device(int device_id) 1027991e0b1dSSelwin Sebastian { 1028991e0b1dSSelwin Sebastian struct rte_bus *pci_bus; 1029991e0b1dSSelwin Sebastian struct rte_pci_id dev_id; 1030991e0b1dSSelwin Sebastian 1031991e0b1dSSelwin Sebastian dev_id.device_id = device_id; 1032991e0b1dSSelwin Sebastian pci_bus = rte_bus_find_by_name("pci"); 1033991e0b1dSSelwin Sebastian return (pci_bus != NULL) && 1034991e0b1dSSelwin Sebastian (pci_bus->find_device(NULL, pci_device_cmp, &dev_id) != NULL); 1035991e0b1dSSelwin Sebastian } 1036991e0b1dSSelwin Sebastian 10378691632fSRavi Kumar /* 10388691632fSRavi Kumar * It returns 0 on success. 10398691632fSRavi Kumar */ 10408691632fSRavi Kumar static int 10418691632fSRavi Kumar eth_axgbe_dev_init(struct rte_eth_dev *eth_dev) 10428691632fSRavi Kumar { 10438691632fSRavi Kumar PMD_INIT_FUNC_TRACE(); 10448691632fSRavi Kumar struct axgbe_port *pdata; 10458691632fSRavi Kumar struct rte_pci_device *pci_dev; 1046572890efSRavi Kumar uint32_t reg, mac_lo, mac_hi; 1047572890efSRavi Kumar int ret; 10488691632fSRavi Kumar 10499e890103SRavi Kumar eth_dev->dev_ops = &axgbe_eth_dev_ops; 10508590b93dSRavi Kumar eth_dev->rx_pkt_burst = &axgbe_recv_pkts; 10519e890103SRavi Kumar 10528691632fSRavi Kumar /* 10538691632fSRavi Kumar * For secondary processes, we don't initialise any further as primary 10548691632fSRavi Kumar * has already done this work. 10558691632fSRavi Kumar */ 10568691632fSRavi Kumar if (rte_eal_process_type() != RTE_PROC_PRIMARY) 10578691632fSRavi Kumar return 0; 10588691632fSRavi Kumar 10590bc212a8SStephen Hemminger pdata = eth_dev->data->dev_private; 1060572890efSRavi Kumar /* initial state */ 1061572890efSRavi Kumar axgbe_set_bit(AXGBE_DOWN, &pdata->dev_state); 1062572890efSRavi Kumar axgbe_set_bit(AXGBE_STOPPED, &pdata->dev_state); 10638691632fSRavi Kumar pdata->eth_dev = eth_dev; 10648691632fSRavi Kumar 10658691632fSRavi Kumar pci_dev = RTE_DEV_TO_PCI(eth_dev->device); 10668691632fSRavi Kumar pdata->pci_dev = pci_dev; 10678691632fSRavi Kumar 1068991e0b1dSSelwin Sebastian /* 1069991e0b1dSSelwin Sebastian * Use root complex device ID to differentiate RV AXGBE vs SNOWY AXGBE 1070991e0b1dSSelwin Sebastian */ 1071991e0b1dSSelwin Sebastian if (pci_search_device(AMD_PCI_RV_ROOT_COMPLEX_ID)) { 1072991e0b1dSSelwin Sebastian pdata->xpcs_window_def_reg = PCS_V2_RV_WINDOW_DEF; 1073991e0b1dSSelwin Sebastian pdata->xpcs_window_sel_reg = PCS_V2_RV_WINDOW_SELECT; 1074991e0b1dSSelwin Sebastian } else { 1075991e0b1dSSelwin Sebastian pdata->xpcs_window_def_reg = PCS_V2_WINDOW_DEF; 1076991e0b1dSSelwin Sebastian pdata->xpcs_window_sel_reg = PCS_V2_WINDOW_SELECT; 1077991e0b1dSSelwin Sebastian } 1078991e0b1dSSelwin Sebastian 1079572890efSRavi Kumar pdata->xgmac_regs = 10807784d0d3SRavi Kumar (void *)pci_dev->mem_resource[AXGBE_AXGMAC_BAR].addr; 10817784d0d3SRavi Kumar pdata->xprop_regs = (void *)((uint8_t *)pdata->xgmac_regs 10827784d0d3SRavi Kumar + AXGBE_MAC_PROP_OFFSET); 10837784d0d3SRavi Kumar pdata->xi2c_regs = (void *)((uint8_t *)pdata->xgmac_regs 10847784d0d3SRavi Kumar + AXGBE_I2C_CTRL_OFFSET); 10857784d0d3SRavi Kumar pdata->xpcs_regs = (void *)pci_dev->mem_resource[AXGBE_XPCS_BAR].addr; 1086572890efSRavi Kumar 1087572890efSRavi Kumar /* version specific driver data*/ 1088572890efSRavi Kumar if (pci_dev->id.device_id == AMD_PCI_AXGBE_DEVICE_V2A) 1089572890efSRavi Kumar pdata->vdata = &axgbe_v2a; 1090572890efSRavi Kumar else 1091572890efSRavi Kumar pdata->vdata = &axgbe_v2b; 1092572890efSRavi Kumar 1093572890efSRavi Kumar /* Configure the PCS indirect addressing support */ 1094991e0b1dSSelwin Sebastian reg = XPCS32_IOREAD(pdata, pdata->xpcs_window_def_reg); 1095572890efSRavi Kumar pdata->xpcs_window = XPCS_GET_BITS(reg, PCS_V2_WINDOW_DEF, OFFSET); 1096572890efSRavi Kumar pdata->xpcs_window <<= 6; 1097572890efSRavi Kumar pdata->xpcs_window_size = XPCS_GET_BITS(reg, PCS_V2_WINDOW_DEF, SIZE); 1098572890efSRavi Kumar pdata->xpcs_window_size = 1 << (pdata->xpcs_window_size + 7); 1099572890efSRavi Kumar pdata->xpcs_window_mask = pdata->xpcs_window_size - 1; 1100991e0b1dSSelwin Sebastian 1101572890efSRavi Kumar PMD_INIT_LOG(DEBUG, 1102572890efSRavi Kumar "xpcs window :%x, size :%x, mask :%x ", pdata->xpcs_window, 1103572890efSRavi Kumar pdata->xpcs_window_size, pdata->xpcs_window_mask); 1104572890efSRavi Kumar XP_IOWRITE(pdata, XP_INT_EN, 0x1fffff); 1105572890efSRavi Kumar 1106572890efSRavi Kumar /* Retrieve the MAC address */ 1107572890efSRavi Kumar mac_lo = XP_IOREAD(pdata, XP_MAC_ADDR_LO); 1108572890efSRavi Kumar mac_hi = XP_IOREAD(pdata, XP_MAC_ADDR_HI); 1109572890efSRavi Kumar pdata->mac_addr.addr_bytes[0] = mac_lo & 0xff; 1110572890efSRavi Kumar pdata->mac_addr.addr_bytes[1] = (mac_lo >> 8) & 0xff; 1111572890efSRavi Kumar pdata->mac_addr.addr_bytes[2] = (mac_lo >> 16) & 0xff; 1112572890efSRavi Kumar pdata->mac_addr.addr_bytes[3] = (mac_lo >> 24) & 0xff; 1113572890efSRavi Kumar pdata->mac_addr.addr_bytes[4] = mac_hi & 0xff; 1114572890efSRavi Kumar pdata->mac_addr.addr_bytes[5] = (mac_hi >> 8) & 0xff; 1115572890efSRavi Kumar 1116572890efSRavi Kumar eth_dev->data->mac_addrs = rte_zmalloc("axgbe_mac_addr", 111735b2d13fSOlivier Matz RTE_ETHER_ADDR_LEN, 0); 1118572890efSRavi Kumar if (!eth_dev->data->mac_addrs) { 1119572890efSRavi Kumar PMD_INIT_LOG(ERR, 1120572890efSRavi Kumar "Failed to alloc %u bytes needed to store MAC addr tbl", 112135b2d13fSOlivier Matz RTE_ETHER_ADDR_LEN); 1122572890efSRavi Kumar return -ENOMEM; 1123572890efSRavi Kumar } 1124572890efSRavi Kumar 1125538da7a1SOlivier Matz if (!rte_is_valid_assigned_ether_addr(&pdata->mac_addr)) 1126538da7a1SOlivier Matz rte_eth_random_addr(pdata->mac_addr.addr_bytes); 1127572890efSRavi Kumar 1128572890efSRavi Kumar /* Copy the permanent MAC address */ 1129538da7a1SOlivier Matz rte_ether_addr_copy(&pdata->mac_addr, ð_dev->data->mac_addrs[0]); 1130572890efSRavi Kumar 1131572890efSRavi Kumar /* Clock settings */ 1132572890efSRavi Kumar pdata->sysclk_rate = AXGBE_V2_DMA_CLOCK_FREQ; 1133572890efSRavi Kumar pdata->ptpclk_rate = AXGBE_V2_PTP_CLOCK_FREQ; 1134572890efSRavi Kumar 1135572890efSRavi Kumar /* Set the DMA coherency values */ 1136572890efSRavi Kumar pdata->coherent = 1; 1137572890efSRavi Kumar pdata->axdomain = AXGBE_DMA_OS_AXDOMAIN; 1138572890efSRavi Kumar pdata->arcache = AXGBE_DMA_OS_ARCACHE; 1139572890efSRavi Kumar pdata->awcache = AXGBE_DMA_OS_AWCACHE; 1140572890efSRavi Kumar 1141572890efSRavi Kumar /* Set the maximum channels and queues */ 1142572890efSRavi Kumar reg = XP_IOREAD(pdata, XP_PROP_1); 1143572890efSRavi Kumar pdata->tx_max_channel_count = XP_GET_BITS(reg, XP_PROP_1, MAX_TX_DMA); 1144572890efSRavi Kumar pdata->rx_max_channel_count = XP_GET_BITS(reg, XP_PROP_1, MAX_RX_DMA); 1145572890efSRavi Kumar pdata->tx_max_q_count = XP_GET_BITS(reg, XP_PROP_1, MAX_TX_QUEUES); 1146572890efSRavi Kumar pdata->rx_max_q_count = XP_GET_BITS(reg, XP_PROP_1, MAX_RX_QUEUES); 1147572890efSRavi Kumar 1148572890efSRavi Kumar /* Set the hardware channel and queue counts */ 1149572890efSRavi Kumar axgbe_set_counts(pdata); 1150572890efSRavi Kumar 1151572890efSRavi Kumar /* Set the maximum fifo amounts */ 1152572890efSRavi Kumar reg = XP_IOREAD(pdata, XP_PROP_2); 1153572890efSRavi Kumar pdata->tx_max_fifo_size = XP_GET_BITS(reg, XP_PROP_2, TX_FIFO_SIZE); 1154572890efSRavi Kumar pdata->tx_max_fifo_size *= 16384; 1155572890efSRavi Kumar pdata->tx_max_fifo_size = RTE_MIN(pdata->tx_max_fifo_size, 1156572890efSRavi Kumar pdata->vdata->tx_max_fifo_size); 1157572890efSRavi Kumar pdata->rx_max_fifo_size = XP_GET_BITS(reg, XP_PROP_2, RX_FIFO_SIZE); 1158572890efSRavi Kumar pdata->rx_max_fifo_size *= 16384; 1159572890efSRavi Kumar pdata->rx_max_fifo_size = RTE_MIN(pdata->rx_max_fifo_size, 1160572890efSRavi Kumar pdata->vdata->rx_max_fifo_size); 1161572890efSRavi Kumar /* Issue software reset to DMA */ 1162572890efSRavi Kumar ret = pdata->hw_if.exit(pdata); 1163572890efSRavi Kumar if (ret) 1164572890efSRavi Kumar PMD_DRV_LOG(ERR, "hw_if->exit EBUSY error\n"); 1165572890efSRavi Kumar 1166572890efSRavi Kumar /* Set default configuration data */ 1167572890efSRavi Kumar axgbe_default_config(pdata); 1168572890efSRavi Kumar 1169572890efSRavi Kumar /* Set default max values if not provided */ 1170572890efSRavi Kumar if (!pdata->tx_max_fifo_size) 1171572890efSRavi Kumar pdata->tx_max_fifo_size = pdata->hw_feat.tx_fifo_size; 1172572890efSRavi Kumar if (!pdata->rx_max_fifo_size) 1173572890efSRavi Kumar pdata->rx_max_fifo_size = pdata->hw_feat.rx_fifo_size; 1174572890efSRavi Kumar 11759e890103SRavi Kumar pdata->tx_desc_count = AXGBE_MAX_RING_DESC; 11769e890103SRavi Kumar pdata->rx_desc_count = AXGBE_MAX_RING_DESC; 1177572890efSRavi Kumar pthread_mutex_init(&pdata->xpcs_mutex, NULL); 1178572890efSRavi Kumar pthread_mutex_init(&pdata->i2c_mutex, NULL); 1179572890efSRavi Kumar pthread_mutex_init(&pdata->an_mutex, NULL); 1180572890efSRavi Kumar pthread_mutex_init(&pdata->phy_mutex, NULL); 1181572890efSRavi Kumar 11824ac7516bSRavi Kumar ret = pdata->phy_if.phy_init(pdata); 11834ac7516bSRavi Kumar if (ret) { 11844ac7516bSRavi Kumar rte_free(eth_dev->data->mac_addrs); 1185e7f2fa88SDavid Marchand eth_dev->data->mac_addrs = NULL; 11864ac7516bSRavi Kumar return ret; 11874ac7516bSRavi Kumar } 11884ac7516bSRavi Kumar 1189456ff159SRavi Kumar rte_intr_callback_register(&pci_dev->intr_handle, 1190456ff159SRavi Kumar axgbe_dev_interrupt_handler, 1191456ff159SRavi Kumar (void *)eth_dev); 11928691632fSRavi Kumar PMD_INIT_LOG(DEBUG, "port %d vendorID=0x%x deviceID=0x%x", 11938691632fSRavi Kumar eth_dev->data->port_id, pci_dev->id.vendor_id, 11948691632fSRavi Kumar pci_dev->id.device_id); 11958691632fSRavi Kumar 11968691632fSRavi Kumar return 0; 11978691632fSRavi Kumar } 11988691632fSRavi Kumar 11998691632fSRavi Kumar static int 1200572890efSRavi Kumar eth_axgbe_dev_uninit(struct rte_eth_dev *eth_dev) 12018691632fSRavi Kumar { 1202456ff159SRavi Kumar struct rte_pci_device *pci_dev; 1203456ff159SRavi Kumar 12048691632fSRavi Kumar PMD_INIT_FUNC_TRACE(); 12058691632fSRavi Kumar 1206572890efSRavi Kumar if (rte_eal_process_type() != RTE_PROC_PRIMARY) 1207572890efSRavi Kumar return 0; 1208572890efSRavi Kumar 1209456ff159SRavi Kumar pci_dev = RTE_DEV_TO_PCI(eth_dev->device); 12109e890103SRavi Kumar eth_dev->dev_ops = NULL; 12118590b93dSRavi Kumar eth_dev->rx_pkt_burst = NULL; 12128590b93dSRavi Kumar eth_dev->tx_pkt_burst = NULL; 12139e890103SRavi Kumar axgbe_dev_clear_queues(eth_dev); 1214572890efSRavi Kumar 1215456ff159SRavi Kumar /* disable uio intr before callback unregister */ 1216456ff159SRavi Kumar rte_intr_disable(&pci_dev->intr_handle); 1217456ff159SRavi Kumar rte_intr_callback_unregister(&pci_dev->intr_handle, 1218456ff159SRavi Kumar axgbe_dev_interrupt_handler, 1219456ff159SRavi Kumar (void *)eth_dev); 1220456ff159SRavi Kumar 12218691632fSRavi Kumar return 0; 12228691632fSRavi Kumar } 12238691632fSRavi Kumar 12248691632fSRavi Kumar static int eth_axgbe_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, 12258691632fSRavi Kumar struct rte_pci_device *pci_dev) 12268691632fSRavi Kumar { 12278691632fSRavi Kumar return rte_eth_dev_pci_generic_probe(pci_dev, 12288691632fSRavi Kumar sizeof(struct axgbe_port), eth_axgbe_dev_init); 12298691632fSRavi Kumar } 12308691632fSRavi Kumar 12318691632fSRavi Kumar static int eth_axgbe_pci_remove(struct rte_pci_device *pci_dev) 12328691632fSRavi Kumar { 12338691632fSRavi Kumar return rte_eth_dev_pci_generic_remove(pci_dev, eth_axgbe_dev_uninit); 12348691632fSRavi Kumar } 12358691632fSRavi Kumar 12368691632fSRavi Kumar static struct rte_pci_driver rte_axgbe_pmd = { 12378691632fSRavi Kumar .id_table = pci_id_axgbe_map, 12388691632fSRavi Kumar .drv_flags = RTE_PCI_DRV_NEED_MAPPING, 12398691632fSRavi Kumar .probe = eth_axgbe_pci_probe, 12408691632fSRavi Kumar .remove = eth_axgbe_pci_remove, 12418691632fSRavi Kumar }; 12428691632fSRavi Kumar 12438691632fSRavi Kumar RTE_PMD_REGISTER_PCI(net_axgbe, rte_axgbe_pmd); 12448691632fSRavi Kumar RTE_PMD_REGISTER_PCI_TABLE(net_axgbe, pci_id_axgbe_map); 12458691632fSRavi Kumar RTE_PMD_REGISTER_KMOD_DEP(net_axgbe, "* igb_uio | uio_pci_generic | vfio-pci"); 12468691632fSRavi Kumar 1247f8e99896SThomas Monjalon RTE_INIT(axgbe_init_log) 12488691632fSRavi Kumar { 12498691632fSRavi Kumar axgbe_logtype_init = rte_log_register("pmd.net.axgbe.init"); 12508691632fSRavi Kumar if (axgbe_logtype_init >= 0) 12518691632fSRavi Kumar rte_log_set_level(axgbe_logtype_init, RTE_LOG_NOTICE); 12528691632fSRavi Kumar axgbe_logtype_driver = rte_log_register("pmd.net.axgbe.driver"); 12538691632fSRavi Kumar if (axgbe_logtype_driver >= 0) 12548691632fSRavi Kumar rte_log_set_level(axgbe_logtype_driver, RTE_LOG_NOTICE); 12558691632fSRavi Kumar } 1256