X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fionic%2Fionic_ethdev.c;h=fd7cd510e67d903c28e10c3b3de0688fdbef5645;hb=77a72b4d9dc003f46dd3ad5ef4e011af7128fffb;hp=f0a5913d7691a3e9c7057071bcc6fa27f8a90dc5;hpb=64b08152a5792fc54d62588d66a5ee4859d84970;p=dpdk.git diff --git a/drivers/net/ionic/ionic_ethdev.c b/drivers/net/ionic/ionic_ethdev.c index f0a5913d76..fd7cd510e6 100644 --- a/drivers/net/ionic/ionic_ethdev.c +++ b/drivers/net/ionic/ionic_ethdev.c @@ -24,12 +24,10 @@ static int ionic_dev_info_get(struct rte_eth_dev *eth_dev, static int ionic_dev_configure(struct rte_eth_dev *dev); static int ionic_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu); static int ionic_dev_start(struct rte_eth_dev *dev); -static void ionic_dev_stop(struct rte_eth_dev *dev); -static void ionic_dev_close(struct rte_eth_dev *dev); +static int ionic_dev_stop(struct rte_eth_dev *dev); +static int ionic_dev_close(struct rte_eth_dev *dev); static int ionic_dev_set_link_up(struct rte_eth_dev *dev); static int ionic_dev_set_link_down(struct rte_eth_dev *dev); -static int ionic_dev_link_update(struct rte_eth_dev *eth_dev, - int wait_to_complete); static int ionic_flow_ctrl_get(struct rte_eth_dev *eth_dev, struct rte_eth_fc_conf *fc_conf); static int ionic_flow_ctrl_set(struct rte_eth_dev *eth_dev, @@ -56,8 +54,8 @@ static int ionic_dev_xstats_get_names(struct rte_eth_dev *dev, static int ionic_dev_xstats_get_names_by_id(struct rte_eth_dev *dev, struct rte_eth_xstat_name *xstats_names, const uint64_t *ids, unsigned int limit); - -int ionic_logtype; +static int ionic_dev_fw_version_get(struct rte_eth_dev *eth_dev, + char *fw_version, size_t fw_size); static const struct rte_pci_id pci_id_ionic_map[] = { { RTE_PCI_DEVICE(IONIC_PENSANDO_VENDOR_ID, IONIC_DEV_ID_ETH_PF) }, @@ -122,6 +120,7 @@ static const struct eth_dev_ops ionic_eth_dev_ops = { .xstats_reset = ionic_dev_xstats_reset, .xstats_get_names = ionic_dev_xstats_get_names, .xstats_get_names_by_id = ionic_dev_xstats_get_names_by_id, + .fw_version_get = ionic_dev_fw_version_get, }; struct rte_ionic_xstats_name_off { @@ -211,6 +210,23 @@ static const struct rte_ionic_xstats_name_off rte_ionic_xstats_strings[] = { #define IONIC_NB_HW_STATS (sizeof(rte_ionic_xstats_strings) / \ sizeof(rte_ionic_xstats_strings[0])) +static int +ionic_dev_fw_version_get(struct rte_eth_dev *eth_dev, + char *fw_version, size_t fw_size) +{ + struct ionic_lif *lif = IONIC_ETH_DEV_TO_LIF(eth_dev); + struct ionic_adapter *adapter = lif->adapter; + + if (fw_version == NULL || fw_size <= 0) + return -EINVAL; + + snprintf(fw_version, fw_size, "%s", + adapter->fw_version); + fw_version[fw_size - 1] = '\0'; + + return 0; +} + /* * Set device link up, enable tx. */ @@ -218,21 +234,17 @@ static int ionic_dev_set_link_up(struct rte_eth_dev *eth_dev) { struct ionic_lif *lif = IONIC_ETH_DEV_TO_LIF(eth_dev); - struct ionic_adapter *adapter = lif->adapter; - struct ionic_dev *idev = &adapter->idev; int err; IONIC_PRINT_CALL(); - ionic_dev_cmd_port_state(idev, IONIC_PORT_ADMIN_STATE_UP); + err = ionic_lif_start(lif); + if (err) + IONIC_PRINT(ERR, "Could not start lif to set link up"); - err = ionic_dev_cmd_wait_check(idev, IONIC_DEVCMD_TIMEOUT); - if (err) { - IONIC_PRINT(WARNING, "Failed to bring port UP"); - return err; - } + ionic_dev_link_update(lif->eth_dev, 0); - return 0; + return err; } /* @@ -242,24 +254,17 @@ static int ionic_dev_set_link_down(struct rte_eth_dev *eth_dev) { struct ionic_lif *lif = IONIC_ETH_DEV_TO_LIF(eth_dev); - struct ionic_adapter *adapter = lif->adapter; - struct ionic_dev *idev = &adapter->idev; - int err; IONIC_PRINT_CALL(); - ionic_dev_cmd_port_state(idev, IONIC_PORT_ADMIN_STATE_DOWN); + ionic_lif_stop(lif); - err = ionic_dev_cmd_wait_check(idev, IONIC_DEVCMD_TIMEOUT); - if (err) { - IONIC_PRINT(WARNING, "Failed to bring port DOWN"); - return err; - } + ionic_dev_link_update(lif->eth_dev, 0); return 0; } -static int +int ionic_dev_link_update(struct rte_eth_dev *eth_dev, int wait_to_complete __rte_unused) { @@ -273,7 +278,8 @@ ionic_dev_link_update(struct rte_eth_dev *eth_dev, memset(&link, 0, sizeof(link)); link.link_autoneg = ETH_LINK_AUTONEG; - if (!adapter->link_up) { + if (!adapter->link_up || + !(lif->state & IONIC_LIF_F_UP)) { /* Interface is down */ link.link_status = ETH_LINK_DOWN; link.link_duplex = ETH_LINK_HALF_DUPLEX; @@ -321,14 +327,11 @@ static void ionic_dev_interrupt_handler(void *param) { struct ionic_adapter *adapter = (struct ionic_adapter *)param; - uint32_t i; IONIC_PRINT(DEBUG, "->"); - for (i = 0; i < adapter->nlifs; i++) { - if (adapter->lifs[i]) - ionic_notifyq_handler(adapter->lifs[i], -1); - } + if (adapter->lif) + ionic_notifyq_handler(adapter->lif, -1); } static int @@ -553,7 +556,7 @@ ionic_dev_rss_reta_update(struct rte_eth_dev *eth_dev, if (reta_size != ident->lif.eth.rss_ind_tbl_sz) { IONIC_PRINT(ERR, "The size of hash lookup table configured " - "(%d) doesn't match the number hardware can supported " + "(%d) does not match the number hardware can support " "(%d)", reta_size, ident->lif.eth.rss_ind_tbl_sz); return -EINVAL; @@ -587,7 +590,7 @@ ionic_dev_rss_reta_query(struct rte_eth_dev *eth_dev, if (reta_size != ident->lif.eth.rss_ind_tbl_sz) { IONIC_PRINT(ERR, "The size of hash lookup table configured " - "(%d) doesn't match the number hardware can supported " + "(%d) does not match the number hardware can support " "(%d)", reta_size, ident->lif.eth.rss_ind_tbl_sz); return -EINVAL; @@ -901,6 +904,9 @@ ionic_dev_start(struct rte_eth_dev *eth_dev) return -EINVAL; } + if (dev_conf->lpbk_mode) + IONIC_PRINT(WARNING, "Loopback mode not supported"); + err = ionic_lif_start(lif); if (err) { IONIC_PRINT(ERR, "Cannot start LIF: %d", err); @@ -922,41 +928,48 @@ ionic_dev_start(struct rte_eth_dev *eth_dev) /* * Stop device: disable rx and tx functions to allow for reconfiguring. */ -static void +static int ionic_dev_stop(struct rte_eth_dev *eth_dev) { struct ionic_lif *lif = IONIC_ETH_DEV_TO_LIF(eth_dev); - int err; IONIC_PRINT_CALL(); - err = ionic_lif_stop(lif); - if (err) - IONIC_PRINT(ERR, "Cannot stop LIF: %d", err); + ionic_lif_stop(lif); + + return 0; } +static void ionic_unconfigure_intr(struct ionic_adapter *adapter); + /* * Reset and stop device. */ -static void +static int ionic_dev_close(struct rte_eth_dev *eth_dev) { struct ionic_lif *lif = IONIC_ETH_DEV_TO_LIF(eth_dev); - int err; + struct ionic_adapter *adapter = lif->adapter; IONIC_PRINT_CALL(); + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return 0; - err = ionic_lif_stop(lif); - if (err) { - IONIC_PRINT(ERR, "Cannot stop LIF: %d", err); - return; - } + ionic_lif_stop(lif); - err = eth_ionic_dev_uninit(eth_dev); - if (err) { - IONIC_PRINT(ERR, "Cannot destroy LIF: %d", err); - return; - } + ionic_lif_free_queues(lif); + + IONIC_PRINT(NOTICE, "Removing device %s", eth_dev->device->name); + ionic_unconfigure_intr(adapter); + + rte_eth_dev_destroy(eth_dev, eth_ionic_dev_uninit); + + ionic_port_reset(adapter); + ionic_reset(adapter); + + rte_free(adapter); + + return 0; } static int @@ -979,11 +992,11 @@ eth_ionic_dev_init(struct rte_eth_dev *eth_dev, void *init_params) return 0; rte_eth_copy_pci_info(eth_dev, pci_dev); + eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS; - lif->index = adapter->nlifs; lif->eth_dev = eth_dev; lif->adapter = adapter; - adapter->lifs[adapter->nlifs] = lif; + adapter->lif = lif; IONIC_PRINT(DEBUG, "Up to %u MAC addresses supported", adapter->max_mac_addrs); @@ -1038,15 +1051,13 @@ eth_ionic_dev_uninit(struct rte_eth_dev *eth_dev) if (rte_eal_process_type() != RTE_PROC_PRIMARY) return 0; - adapter->lifs[lif->index] = NULL; + adapter->lif = NULL; ionic_lif_deinit(lif); ionic_lif_free(lif); - eth_dev->dev_ops = NULL; - eth_dev->rx_pkt_burst = NULL; - eth_dev->tx_pkt_burst = NULL; - eth_dev->tx_pkt_prepare = NULL; + if (!(lif->state & IONIC_LIF_F_FW_RESET)) + ionic_lif_reset(lif); return 0; } @@ -1158,8 +1169,6 @@ eth_ionic_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, goto err_free_adapter; } - adapter->is_mgmt_nic = (pci_dev->id.device_id == IONIC_DEV_ID_ETH_MGMT); - adapter->num_bars = 0; for (i = 0; i < PCI_MAX_RESOURCE && i < IONIC_BARS_MAX; i++) { resource = &pci_dev->mem_resource[i]; @@ -1222,22 +1231,19 @@ eth_ionic_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, adapter->max_mac_addrs = adapter->ident.lif.eth.max_ucast_filters; - adapter->nlifs = 0; - for (i = 0; i < adapter->ident.dev.nlifs; i++) { - snprintf(name, sizeof(name), "net_%s_lif_%lu", - pci_dev->device.name, i); - - err = rte_eth_dev_create(&pci_dev->device, name, - sizeof(struct ionic_lif), - NULL, NULL, - eth_ionic_dev_init, adapter); - if (err) { - IONIC_PRINT(ERR, "Cannot create eth device for " - "ionic lif %s", name); - break; - } + if (adapter->ident.dev.nlifs != 1) { + IONIC_PRINT(ERR, "Unexpected request for %d LIFs", + adapter->ident.dev.nlifs); + goto err_free_adapter; + } - adapter->nlifs++; + snprintf(name, sizeof(name), "%s_lif", pci_dev->device.name); + err = rte_eth_dev_create(&pci_dev->device, + name, sizeof(struct ionic_lif), + NULL, NULL, eth_ionic_dev_init, adapter); + if (err) { + IONIC_PRINT(ERR, "Cannot create eth device for %s", name); + goto err_free_adapter; } err = ionic_configure_intr(adapter); @@ -1256,34 +1262,20 @@ err: } static int -eth_ionic_pci_remove(struct rte_pci_device *pci_dev __rte_unused) +eth_ionic_pci_remove(struct rte_pci_device *pci_dev) { char name[RTE_ETH_NAME_MAX_LEN]; - struct ionic_adapter *adapter = NULL; struct rte_eth_dev *eth_dev; - struct ionic_lif *lif; - uint32_t i; - /* Adapter lookup is using (the first) eth_dev name */ - snprintf(name, sizeof(name), "net_%s_lif_0", - pci_dev->device.name); + /* Adapter lookup is using the eth_dev name */ + snprintf(name, sizeof(name), "%s_lif", pci_dev->device.name); eth_dev = rte_eth_dev_allocated(name); - if (eth_dev) { - lif = IONIC_ETH_DEV_TO_LIF(eth_dev); - adapter = lif->adapter; - } - - if (adapter) { - ionic_unconfigure_intr(adapter); - - for (i = 0; i < adapter->nlifs; i++) { - lif = adapter->lifs[i]; - rte_eth_dev_destroy(lif->eth_dev, eth_ionic_dev_uninit); - } - - rte_free(adapter); - } + if (eth_dev) + ionic_dev_close(eth_dev); + else + IONIC_PRINT(DEBUG, "Cannot find device %s", + pci_dev->device.name); return 0; } @@ -1298,10 +1290,4 @@ static struct rte_pci_driver rte_ionic_pmd = { RTE_PMD_REGISTER_PCI(net_ionic, rte_ionic_pmd); RTE_PMD_REGISTER_PCI_TABLE(net_ionic, pci_id_ionic_map); RTE_PMD_REGISTER_KMOD_DEP(net_ionic, "* igb_uio | uio_pci_generic | vfio-pci"); - -RTE_INIT(ionic_init_log) -{ - ionic_logtype = rte_log_register("pmd.net.ionic"); - if (ionic_logtype >= 0) - rte_log_set_level(ionic_logtype, RTE_LOG_NOTICE); -} +RTE_LOG_REGISTER(ionic_logtype, pmd.net.ionic, NOTICE);