X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fiavf%2Fiavf_ethdev.c;h=0ef023c0aee4548cfc24b719750c354aa8f01381;hb=f30e69b41f949cd4a9afb6ff39de196e661708e2;hp=8e1d8a8d3e92c7f3330204af7648ff4e54dc7473;hpb=dd52fa0bade3d9e8bbb2229309c9f020cbe6872f;p=dpdk.git diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c index 8e1d8a8d3e..0ef023c0ae 100644 --- a/drivers/net/iavf/iavf_ethdev.c +++ b/drivers/net/iavf/iavf_ethdev.c @@ -31,8 +31,8 @@ static int iavf_dev_configure(struct rte_eth_dev *dev); static int iavf_dev_start(struct rte_eth_dev *dev); -static void iavf_dev_stop(struct rte_eth_dev *dev); -static void iavf_dev_close(struct rte_eth_dev *dev); +static int iavf_dev_stop(struct rte_eth_dev *dev); +static int iavf_dev_close(struct rte_eth_dev *dev); static int iavf_dev_reset(struct rte_eth_dev *dev); static int iavf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info); @@ -40,6 +40,11 @@ static const uint32_t *iavf_dev_supported_ptypes_get(struct rte_eth_dev *dev); static int iavf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); static int iavf_dev_stats_reset(struct rte_eth_dev *dev); +static int iavf_dev_xstats_get(struct rte_eth_dev *dev, + struct rte_eth_xstat *xstats, unsigned int n); +static int iavf_dev_xstats_get_names(struct rte_eth_dev *dev, + struct rte_eth_xstat_name *xstats_names, + unsigned int limit); static int iavf_dev_promiscuous_enable(struct rte_eth_dev *dev); static int iavf_dev_promiscuous_disable(struct rte_eth_dev *dev); static int iavf_dev_allmulticast_enable(struct rte_eth_dev *dev); @@ -82,6 +87,30 @@ static const struct rte_pci_id pci_id_iavf_map[] = { { .vendor_id = 0, /* sentinel */ }, }; +struct rte_iavf_xstats_name_off { + char name[RTE_ETH_XSTATS_NAME_SIZE]; + unsigned int offset; +}; + +static const struct rte_iavf_xstats_name_off rte_iavf_stats_strings[] = { + {"rx_bytes", offsetof(struct iavf_eth_stats, rx_bytes)}, + {"rx_unicast_packets", offsetof(struct iavf_eth_stats, rx_unicast)}, + {"rx_multicast_packets", offsetof(struct iavf_eth_stats, rx_multicast)}, + {"rx_broadcast_packets", offsetof(struct iavf_eth_stats, rx_broadcast)}, + {"rx_dropped_packets", offsetof(struct iavf_eth_stats, rx_discards)}, + {"rx_unknown_protocol_packets", offsetof(struct iavf_eth_stats, + rx_unknown_protocol)}, + {"tx_bytes", offsetof(struct iavf_eth_stats, tx_bytes)}, + {"tx_unicast_packets", offsetof(struct iavf_eth_stats, tx_unicast)}, + {"tx_multicast_packets", offsetof(struct iavf_eth_stats, tx_multicast)}, + {"tx_broadcast_packets", offsetof(struct iavf_eth_stats, tx_broadcast)}, + {"tx_dropped_packets", offsetof(struct iavf_eth_stats, tx_discards)}, + {"tx_error_packets", offsetof(struct iavf_eth_stats, tx_errors)}, +}; + +#define IAVF_NB_XSTATS (sizeof(rte_iavf_stats_strings) / \ + sizeof(rte_iavf_stats_strings[0])) + static const struct eth_dev_ops iavf_eth_dev_ops = { .dev_configure = iavf_dev_configure, .dev_start = iavf_dev_start, @@ -93,6 +122,9 @@ static const struct eth_dev_ops iavf_eth_dev_ops = { .link_update = iavf_dev_link_update, .stats_get = iavf_dev_stats_get, .stats_reset = iavf_dev_stats_reset, + .xstats_get = iavf_dev_xstats_get, + .xstats_get_names = iavf_dev_xstats_get_names, + .xstats_reset = iavf_dev_stats_reset, .promiscuous_enable = iavf_dev_promiscuous_enable, .promiscuous_disable = iavf_dev_promiscuous_disable, .allmulticast_enable = iavf_dev_allmulticast_enable, @@ -117,13 +149,11 @@ static const struct eth_dev_ops iavf_eth_dev_ops = { .rss_hash_conf_get = iavf_dev_rss_hash_conf_get, .rxq_info_get = iavf_dev_rxq_info_get, .txq_info_get = iavf_dev_txq_info_get, - .rx_queue_count = iavf_dev_rxq_count, - .rx_descriptor_status = iavf_dev_rx_desc_status, - .tx_descriptor_status = iavf_dev_tx_desc_status, .mtu_set = iavf_dev_mtu_set, .rx_queue_intr_enable = iavf_dev_rx_queue_intr_enable, .rx_queue_intr_disable = iavf_dev_rx_queue_intr_disable, .filter_ctrl = iavf_dev_filter_ctrl, + .tx_done_cleanup = iavf_dev_tx_done_cleanup, }; static int @@ -160,7 +190,7 @@ iavf_init_rss(struct iavf_adapter *adapter) { struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter); struct rte_eth_rss_conf *rss_conf; - uint8_t i, j, nb_q; + uint16_t i, j, nb_q; int ret; rss_conf = &adapter->eth_dev->data->dev_conf.rx_adv_conf.rss_conf; @@ -501,7 +531,7 @@ err_queue: return -1; } -static void +static int iavf_dev_stop(struct rte_eth_dev *dev) { struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private); @@ -512,7 +542,7 @@ iavf_dev_stop(struct rte_eth_dev *dev) PMD_INIT_FUNC_TRACE(); if (adapter->stopped == 1) - return; + return 0; iavf_stop_queues(dev); @@ -532,6 +562,9 @@ iavf_dev_stop(struct rte_eth_dev *dev) false); adapter->stopped = 1; + dev->data->dev_started = 0; + + return 0; } static int @@ -543,6 +576,8 @@ iavf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) dev_info->max_tx_queues = vf->vsi_res->num_queue_pairs; dev_info->min_rx_bufsize = IAVF_BUF_SIZE_MIN; dev_info->max_rx_pktlen = IAVF_FRAME_SIZE_MAX; + dev_info->max_mtu = dev_info->max_rx_pktlen - IAVF_ETH_OVERHEAD; + dev_info->min_mtu = RTE_ETHER_MIN_MTU; dev_info->hash_key_size = vf->vf_res->rss_key_size; dev_info->reta_size = vf->vf_res->rss_lut_size; dev_info->flow_type_rss_offloads = IAVF_RSS_OFFLOAD_ALL; @@ -668,12 +703,7 @@ iavf_dev_link_update(struct rte_eth_dev *dev, new_link.link_autoneg = !(dev->data->dev_conf.link_speeds & ETH_LINK_SPEED_FIXED); - if (rte_atomic64_cmpset((uint64_t *)&dev->data->dev_link, - *(uint64_t *)&dev->data->dev_link, - *(uint64_t *)&new_link) == 0) - return -1; - - return 0; + return rte_eth_linkstatus_set(dev, &new_link); } static int @@ -682,20 +712,9 @@ iavf_dev_promiscuous_enable(struct rte_eth_dev *dev) struct iavf_adapter *adapter = IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private); struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter); - int ret; - - if (vf->promisc_unicast_enabled) - return 0; - - ret = iavf_config_promisc(adapter, true, vf->promisc_multicast_enabled); - if (!ret) - vf->promisc_unicast_enabled = true; - else if (ret == IAVF_NOT_SUPPORTED) - ret = -ENOTSUP; - else - ret = -EAGAIN; - return ret; + return iavf_config_promisc(adapter, + true, vf->promisc_multicast_enabled); } static int @@ -704,21 +723,9 @@ iavf_dev_promiscuous_disable(struct rte_eth_dev *dev) struct iavf_adapter *adapter = IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private); struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter); - int ret; - if (!vf->promisc_unicast_enabled) - return 0; - - ret = iavf_config_promisc(adapter, false, - vf->promisc_multicast_enabled); - if (!ret) - vf->promisc_unicast_enabled = false; - else if (ret == IAVF_NOT_SUPPORTED) - ret = -ENOTSUP; - else - ret = -EAGAIN; - - return ret; + return iavf_config_promisc(adapter, + false, vf->promisc_multicast_enabled); } static int @@ -727,20 +734,9 @@ iavf_dev_allmulticast_enable(struct rte_eth_dev *dev) struct iavf_adapter *adapter = IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private); struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter); - int ret; - - if (vf->promisc_multicast_enabled) - return 0; - - ret = iavf_config_promisc(adapter, vf->promisc_unicast_enabled, true); - if (!ret) - vf->promisc_multicast_enabled = true; - else if (ret == IAVF_NOT_SUPPORTED) - ret = -ENOTSUP; - else - ret = -EAGAIN; - return ret; + return iavf_config_promisc(adapter, + vf->promisc_unicast_enabled, true); } static int @@ -749,20 +745,9 @@ iavf_dev_allmulticast_disable(struct rte_eth_dev *dev) struct iavf_adapter *adapter = IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private); struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter); - int ret; - - if (!vf->promisc_multicast_enabled) - return 0; - - ret = iavf_config_promisc(adapter, vf->promisc_unicast_enabled, false); - if (!ret) - vf->promisc_multicast_enabled = false; - else if (ret == IAVF_NOT_SUPPORTED) - ret = -ENOTSUP; - else - ret = -EAGAIN; - return ret; + return iavf_config_promisc(adapter, + vf->promisc_unicast_enabled, false); } static int @@ -1142,6 +1127,55 @@ iavf_dev_stats_reset(struct rte_eth_dev *dev) return 0; } +static int iavf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, + struct rte_eth_xstat_name *xstats_names, + __rte_unused unsigned int limit) +{ + unsigned int i; + + if (xstats_names != NULL) + for (i = 0; i < IAVF_NB_XSTATS; i++) { + snprintf(xstats_names[i].name, + sizeof(xstats_names[i].name), + "%s", rte_iavf_stats_strings[i].name); + } + return IAVF_NB_XSTATS; +} + +static int iavf_dev_xstats_get(struct rte_eth_dev *dev, + struct rte_eth_xstat *xstats, unsigned int n) +{ + int ret; + unsigned int i; + struct iavf_adapter *adapter = + IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private); + struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private); + struct iavf_vsi *vsi = &vf->vsi; + struct virtchnl_eth_stats *pstats = NULL; + + if (n < IAVF_NB_XSTATS) + return IAVF_NB_XSTATS; + + ret = iavf_query_stats(adapter, &pstats); + if (ret != 0) + return 0; + + if (!xstats) + return 0; + + iavf_update_stats(vsi, pstats); + + /* loop over xstats array and values from pstats */ + for (i = 0; i < IAVF_NB_XSTATS; i++) { + xstats[i].id = i; + xstats[i].value = *(uint64_t *)(((char *)pstats) + + rte_iavf_stats_strings[i].offset); + } + + return IAVF_NB_XSTATS; +} + + static int iavf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id) { @@ -1383,6 +1417,9 @@ iavf_dev_init(struct rte_eth_dev *eth_dev) /* assign ops func pointer */ eth_dev->dev_ops = &iavf_eth_dev_ops; + eth_dev->rx_queue_count = iavf_dev_rxq_count; + eth_dev->rx_descriptor_status = iavf_dev_rx_desc_status; + eth_dev->tx_descriptor_status = iavf_dev_tx_desc_status; eth_dev->rx_pkt_burst = &iavf_recv_pkts; eth_dev->tx_pkt_burst = &iavf_xmit_pkts; eth_dev->tx_pkt_prepare = &iavf_prep_pkts; @@ -1397,6 +1434,7 @@ iavf_dev_init(struct rte_eth_dev *eth_dev) return 0; } rte_eth_copy_pci_info(eth_dev, pci_dev); + eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS; hw->vendor_id = pci_dev->id.vendor_id; hw->device_id = pci_dev->id.device_id; @@ -1410,11 +1448,6 @@ iavf_dev_init(struct rte_eth_dev *eth_dev) adapter->eth_dev = eth_dev; adapter->stopped = 1; - /* Pass the information to the rte_eth_dev_close() that it should also - * release the private port resources. - */ - eth_dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE; - if (iavf_init_vf(eth_dev) != 0) { PMD_INIT_LOG(ERR, "Init vf failed"); return -1; @@ -1461,7 +1494,7 @@ iavf_dev_init(struct rte_eth_dev *eth_dev) return 0; } -static void +static int iavf_dev_close(struct rte_eth_dev *dev) { struct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(dev->data->dev_private); @@ -1470,10 +1503,24 @@ iavf_dev_close(struct rte_eth_dev *dev) struct iavf_adapter *adapter = IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private); struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private); + int ret; + + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return 0; + + ret = iavf_dev_stop(dev); - iavf_dev_stop(dev); iavf_flow_flush(dev, NULL); iavf_flow_uninit(adapter); + + /* + * disable promiscuous mode before reset vf + * it is a workaround solution when work with kernel driver + * and it is not the normal way + */ + if (vf->promisc_unicast_enabled || vf->promisc_multicast_enabled) + iavf_config_promisc(adapter, false, false); + iavf_shutdown_adminq(hw); /* disable uio intr before callback unregister */ rte_intr_disable(intr_handle); @@ -1483,10 +1530,6 @@ iavf_dev_close(struct rte_eth_dev *dev) iavf_dev_interrupt_handler, dev); iavf_disable_irq0(hw); - dev->dev_ops = NULL; - dev->rx_pkt_burst = NULL; - dev->tx_pkt_burst = NULL; - if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_RSS_PF) { if (vf->rss_lut) { rte_free(vf->rss_lut); @@ -1504,6 +1547,10 @@ iavf_dev_close(struct rte_eth_dev *dev) rte_free(vf->aq_resp); vf->aq_resp = NULL; + + vf->vf_reset = false; + + return ret; } static int