X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fatlantic%2Fatl_ethdev.c;h=b0716773addb6d3c53edce0d56c4da50dce40c81;hb=57ddbf7edd9c5041603e224fbbb62c11ce423135;hp=3c1b349dfa0dbed664c4eea29c8909f5af3a7848;hpb=6bee9d5f456a61a427384c815f6827aad83e3c06;p=dpdk.git diff --git a/drivers/net/atlantic/atl_ethdev.c b/drivers/net/atlantic/atl_ethdev.c index 3c1b349dfa..b0716773ad 100644 --- a/drivers/net/atlantic/atl_ethdev.c +++ b/drivers/net/atlantic/atl_ethdev.c @@ -15,19 +15,17 @@ #include "hw_atl/hw_atl_b0_internal.h" static int eth_atl_dev_init(struct rte_eth_dev *eth_dev); -static int eth_atl_dev_uninit(struct rte_eth_dev *eth_dev); - static int atl_dev_configure(struct rte_eth_dev *dev); static int atl_dev_start(struct rte_eth_dev *dev); -static void atl_dev_stop(struct rte_eth_dev *dev); +static int atl_dev_stop(struct rte_eth_dev *dev); static int atl_dev_set_link_up(struct rte_eth_dev *dev); static int atl_dev_set_link_down(struct rte_eth_dev *dev); -static void atl_dev_close(struct rte_eth_dev *dev); +static int atl_dev_close(struct rte_eth_dev *dev); static int atl_dev_reset(struct rte_eth_dev *dev); -static void atl_dev_promiscuous_enable(struct rte_eth_dev *dev); -static void atl_dev_promiscuous_disable(struct rte_eth_dev *dev); -static void atl_dev_allmulticast_enable(struct rte_eth_dev *dev); -static void atl_dev_allmulticast_disable(struct rte_eth_dev *dev); +static int atl_dev_promiscuous_enable(struct rte_eth_dev *dev); +static int atl_dev_promiscuous_disable(struct rte_eth_dev *dev); +static int atl_dev_allmulticast_enable(struct rte_eth_dev *dev); +static int atl_dev_allmulticast_disable(struct rte_eth_dev *dev); static int atl_dev_link_update(struct rte_eth_dev *dev, int wait); static int atl_dev_xstats_get_names(struct rte_eth_dev *dev __rte_unused, @@ -40,14 +38,11 @@ static int atl_dev_stats_get(struct rte_eth_dev *dev, static int atl_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *stats, unsigned int n); -static void atl_dev_stats_reset(struct rte_eth_dev *dev); +static int atl_dev_stats_reset(struct rte_eth_dev *dev); static int atl_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size); -static void atl_dev_info_get(struct rte_eth_dev *dev, - struct rte_eth_dev_info *dev_info); - static const uint32_t *atl_dev_supported_ptypes_get(struct rte_eth_dev *dev); static int atl_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu); @@ -120,12 +115,9 @@ static int eth_atl_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, struct rte_pci_device *pci_dev); static int eth_atl_pci_remove(struct rte_pci_device *pci_dev); -static void atl_dev_info_get(struct rte_eth_dev *dev, +static int atl_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info); -int atl_logtype_init; -int atl_logtype_driver; - /* * The set of PCI devices this driver supports */ @@ -319,10 +311,6 @@ static const struct eth_dev_ops atl_eth_dev_ops = { .rx_queue_intr_enable = atl_dev_rx_queue_intr_enable, .rx_queue_intr_disable = atl_dev_rx_queue_intr_disable, - .rx_queue_count = atl_rx_queue_count, - .rx_descriptor_status = atl_dev_rx_descriptor_status, - .tx_descriptor_status = atl_dev_tx_descriptor_status, - /* EEPROM */ .get_eeprom_length = atl_dev_get_eeprom_length, .get_eeprom = atl_dev_get_eeprom, @@ -379,6 +367,11 @@ eth_atl_dev_init(struct rte_eth_dev *eth_dev) PMD_INIT_FUNC_TRACE(); eth_dev->dev_ops = &atl_eth_dev_ops; + + eth_dev->rx_queue_count = atl_rx_queue_count; + eth_dev->rx_descriptor_status = atl_dev_rx_descriptor_status; + eth_dev->tx_descriptor_status = atl_dev_tx_descriptor_status; + eth_dev->rx_pkt_burst = &atl_recv_pkts; eth_dev->tx_pkt_burst = &atl_xmit_pkts; eth_dev->tx_pkt_prepare = &atl_prep_pkts; @@ -387,6 +380,8 @@ eth_atl_dev_init(struct rte_eth_dev *eth_dev) if (rte_eal_process_type() != RTE_PROC_PRIMARY) return 0; + eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS; + /* Vendor and Device ID need to be set before init of shared code */ hw->device_id = pci_dev->id.device_id; hw->vendor_id = pci_dev->id.vendor_id; @@ -410,6 +405,8 @@ eth_atl_dev_init(struct rte_eth_dev *eth_dev) hw->aq_nic_cfg = &adapter->hw_cfg; + pthread_mutex_init(&hw->mbox_mutex, NULL); + /* disable interrupt */ atl_disable_intr(hw); @@ -445,38 +442,6 @@ eth_atl_dev_init(struct rte_eth_dev *eth_dev) return err; } -static int -eth_atl_dev_uninit(struct rte_eth_dev *eth_dev) -{ - struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); - struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; - struct aq_hw_s *hw; - - PMD_INIT_FUNC_TRACE(); - - if (rte_eal_process_type() != RTE_PROC_PRIMARY) - return -EPERM; - - hw = ATL_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); - - if (hw->adapter_stopped == 0) - atl_dev_close(eth_dev); - - eth_dev->dev_ops = NULL; - eth_dev->rx_pkt_burst = NULL; - eth_dev->tx_pkt_burst = NULL; - - /* disable uio intr before callback unregister */ - rte_intr_disable(intr_handle); - rte_intr_callback_unregister(intr_handle, - atl_dev_interrupt_handler, eth_dev); - - rte_free(eth_dev->data->mac_addrs); - eth_dev->data->mac_addrs = NULL; - - return 0; -} - static int eth_atl_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, struct rte_pci_device *pci_dev) @@ -488,7 +453,7 @@ eth_atl_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, static int eth_atl_pci_remove(struct rte_pci_device *pci_dev) { - return rte_eth_dev_pci_generic_remove(pci_dev, eth_atl_dev_uninit); + return rte_eth_dev_pci_generic_remove(pci_dev, atl_dev_close); } static int @@ -636,7 +601,7 @@ error: /* * Stop device: disable rx and tx functions to allow for reconfiguring. */ -static void +static int atl_dev_stop(struct rte_eth_dev *dev) { struct rte_eth_link link; @@ -646,6 +611,7 @@ atl_dev_stop(struct rte_eth_dev *dev) struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; PMD_INIT_FUNC_TRACE(); + dev->data->dev_started = 0; /* disable interrupts */ atl_disable_intr(hw); @@ -676,6 +642,8 @@ atl_dev_stop(struct rte_eth_dev *dev) rte_free(intr_handle->intr_vec); intr_handle->intr_vec = NULL; } + + return 0; } /* @@ -720,14 +688,33 @@ atl_dev_set_link_down(struct rte_eth_dev *dev) /* * Reset and stop device. */ -static void +static int atl_dev_close(struct rte_eth_dev *dev) { + struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); + struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; + struct aq_hw_s *hw; + int ret; + PMD_INIT_FUNC_TRACE(); - atl_dev_stop(dev); + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return 0; + + hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private); + + ret = atl_dev_stop(dev); atl_free_queues(dev); + + /* disable uio intr before callback unregister */ + rte_intr_disable(intr_handle); + rte_intr_callback_unregister(intr_handle, + atl_dev_interrupt_handler, dev); + + pthread_mutex_destroy(&hw->mbox_mutex); + + return ret; } static int @@ -735,7 +722,7 @@ atl_dev_reset(struct rte_eth_dev *dev) { int ret; - ret = eth_atl_dev_uninit(dev); + ret = atl_dev_close(dev); if (ret) return ret; @@ -978,7 +965,7 @@ atl_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) return 0; } -static void +static int atl_dev_stats_reset(struct rte_eth_dev *dev) { struct atl_adapter *adapter = ATL_DEV_TO_ADAPTER(dev); @@ -990,6 +977,28 @@ atl_dev_stats_reset(struct rte_eth_dev *dev) memset(&hw->curr_stats, 0, sizeof(hw->curr_stats)); memset(&adapter->sw_stats, 0, sizeof(adapter->sw_stats)); + + return 0; +} + +static int +atl_dev_xstats_get_count(struct rte_eth_dev *dev) +{ + struct atl_adapter *adapter = + (struct atl_adapter *)dev->data->dev_private; + + struct aq_hw_s *hw = &adapter->hw; + unsigned int i, count = 0; + + for (i = 0; i < RTE_DIM(atl_xstats_tbl); i++) { + if (atl_xstats_tbl[i].type == XSTATS_TYPE_MACSEC && + ((hw->caps_lo & BIT(CAPS_LO_MACSEC)) == 0)) + continue; + + count++; + } + + return count; } static int @@ -998,15 +1007,17 @@ atl_dev_xstats_get_names(struct rte_eth_dev *dev __rte_unused, unsigned int size) { unsigned int i; + unsigned int count = atl_dev_xstats_get_count(dev); - if (!xstats_names) - return RTE_DIM(atl_xstats_tbl); - - for (i = 0; i < size && i < RTE_DIM(atl_xstats_tbl); i++) - strlcpy(xstats_names[i].name, atl_xstats_tbl[i].name, - RTE_ETH_XSTATS_NAME_SIZE); + if (xstats_names) { + for (i = 0; i < size && i < count; i++) { + snprintf(xstats_names[i].name, + RTE_ETH_XSTATS_NAME_SIZE, "%s", + atl_xstats_tbl[i].name); + } + } - return i; + return count; } static int @@ -1020,9 +1031,10 @@ atl_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *stats, struct macsec_msg_fw_response resp = { 0 }; int err = -1; unsigned int i; + unsigned int count = atl_dev_xstats_get_count(dev); if (!stats) - return 0; + return count; if (hw->aq_fw_ops->send_macsec_req != NULL) { req.ingress_sa_index = 0xff; @@ -1035,7 +1047,7 @@ atl_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *stats, err = hw->aq_fw_ops->send_macsec_req(hw, &msg, &resp); } - for (i = 0; i < n && i < RTE_DIM(atl_xstats_tbl); i++) { + for (i = 0; i < n && i < count; i++) { stats[i].id = i; switch (atl_xstats_tbl[i].type) { @@ -1044,14 +1056,15 @@ atl_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *stats, atl_xstats_tbl[i].offset); break; case XSTATS_TYPE_MACSEC: - if (err) - goto done; - stats[i].value = *(u64 *)((uint8_t *)&resp.stats + - atl_xstats_tbl[i].offset); + if (!err) { + stats[i].value = + *(u64 *)((uint8_t *)&resp.stats + + atl_xstats_tbl[i].offset); + } break; } } -done: + return i; } @@ -1077,7 +1090,7 @@ atl_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size) return 0; } -static void +static int atl_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) { struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); @@ -1118,6 +1131,8 @@ atl_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) dev_info->speed_capa |= ETH_LINK_SPEED_100M; dev_info->speed_capa |= ETH_LINK_SPEED_2_5G; dev_info->speed_capa |= ETH_LINK_SPEED_5G; + + return 0; } static const uint32_t * @@ -1208,39 +1223,47 @@ atl_dev_link_update(struct rte_eth_dev *dev, int wait __rte_unused) return 0; } -static void +static int atl_dev_promiscuous_enable(struct rte_eth_dev *dev) { struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private); hw_atl_rpfl2promiscuous_mode_en_set(hw, true); + + return 0; } -static void +static int atl_dev_promiscuous_disable(struct rte_eth_dev *dev) { struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private); hw_atl_rpfl2promiscuous_mode_en_set(hw, false); + + return 0; } -static void +static int atl_dev_allmulticast_enable(struct rte_eth_dev *dev) { struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private); hw_atl_rpfl2_accept_all_mc_packets_set(hw, true); + + return 0; } -static void +static int atl_dev_allmulticast_disable(struct rte_eth_dev *dev) { struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private); if (dev->data->promiscuous == 1) - return; /* must remain in all_multicast mode */ + return 0; /* must remain in all_multicast mode */ hw_atl_rpfl2_accept_all_mc_packets_set(hw, false); + + return 0; } /** @@ -1360,8 +1383,7 @@ atl_dev_interrupt_action(struct rte_eth_dev *dev, /* Notify userapp if link status changed */ if (!atl_dev_link_update(dev, 0)) { atl_dev_link_status_print(dev); - _rte_eth_dev_callback_process(dev, - RTE_ETH_EVENT_INTR_LSC, NULL); + rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL); } else { if (hw->aq_fw_ops->send_macsec_req == NULL) goto done; @@ -1387,7 +1409,7 @@ atl_dev_interrupt_action(struct rte_eth_dev *dev, resp.stats.egress_expired || resp.stats.ingress_expired) { PMD_DRV_LOG(INFO, "RTE_ETH_EVENT_MACSEC"); - _rte_eth_dev_callback_process(dev, + rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_MACSEC, NULL); } } @@ -1511,11 +1533,11 @@ atl_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) if (fc == AQ_NIC_FC_OFF) fc_conf->mode = RTE_FC_NONE; - else if (fc & (AQ_NIC_FC_RX | AQ_NIC_FC_TX)) + else if ((fc & AQ_NIC_FC_RX) && (fc & AQ_NIC_FC_TX)) fc_conf->mode = RTE_FC_FULL; else if (fc & AQ_NIC_FC_RX) fc_conf->mode = RTE_FC_RX_PAUSE; - else if (fc & AQ_NIC_FC_RX) + else if (fc & AQ_NIC_FC_TX) fc_conf->mode = RTE_FC_TX_PAUSE; return 0; @@ -1603,9 +1625,12 @@ static int atl_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) { struct rte_eth_dev_info dev_info; + int ret; uint32_t frame_size = mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN; - atl_dev_info_get(dev, &dev_info); + ret = atl_dev_info_get(dev, &dev_info); + if (ret != 0) + return ret; if (mtu < RTE_ETHER_MIN_MTU || frame_size > dev_info.max_rx_pktlen) return -EINVAL; @@ -1889,13 +1914,5 @@ is_atlantic_supported(struct rte_eth_dev *dev) RTE_PMD_REGISTER_PCI(net_atlantic, rte_atl_pmd); RTE_PMD_REGISTER_PCI_TABLE(net_atlantic, pci_id_atl_map); RTE_PMD_REGISTER_KMOD_DEP(net_atlantic, "* igb_uio | uio_pci_generic"); - -RTE_INIT(atl_init_log) -{ - atl_logtype_init = rte_log_register("pmd.net.atlantic.init"); - if (atl_logtype_init >= 0) - rte_log_set_level(atl_logtype_init, RTE_LOG_NOTICE); - atl_logtype_driver = rte_log_register("pmd.net.atlantic.driver"); - if (atl_logtype_driver >= 0) - rte_log_set_level(atl_logtype_driver, RTE_LOG_NOTICE); -} +RTE_LOG_REGISTER(atl_logtype_init, pmd.net.atlantic.init, NOTICE); +RTE_LOG_REGISTER(atl_logtype_driver, pmd.net.atlantic.driver, NOTICE);