X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fiavf%2Fiavf_ethdev.c;h=a39ba1466cbf7b543a83e1e9db6a42d2bf7366f2;hb=b6197a7beb511f273aeca829c59355d993353261;hp=4072a7b7904e4c2046f1511c4680c660777a2f73;hpb=c387effde8fe244f70a937a66f63dd82d9a79f29;p=dpdk.git diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c index 4072a7b790..a39ba1466c 100644 --- a/drivers/net/iavf/iavf_ethdev.c +++ b/drivers/net/iavf/iavf_ethdev.c @@ -37,18 +37,18 @@ 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 void iavf_dev_info_get(struct rte_eth_dev *dev, +static int iavf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info); 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 void iavf_dev_stats_reset(struct rte_eth_dev *dev); -static void iavf_dev_promiscuous_enable(struct rte_eth_dev *dev); -static void iavf_dev_promiscuous_disable(struct rte_eth_dev *dev); -static void iavf_dev_allmulticast_enable(struct rte_eth_dev *dev); -static void iavf_dev_allmulticast_disable(struct rte_eth_dev *dev); +static int iavf_dev_stats_reset(struct rte_eth_dev *dev); +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); +static int iavf_dev_allmulticast_disable(struct rte_eth_dev *dev); static int iavf_dev_add_mac_addr(struct rte_eth_dev *dev, - struct ether_addr *addr, + struct rte_ether_addr *addr, uint32_t index, uint32_t pool); static void iavf_dev_del_mac_addr(struct rte_eth_dev *dev, uint32_t index); @@ -67,7 +67,7 @@ static int iavf_dev_rss_hash_conf_get(struct rte_eth_dev *dev, struct rte_eth_rss_conf *rss_conf); static int iavf_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu); static int iavf_dev_set_default_mac_addr(struct rte_eth_dev *dev, - struct ether_addr *mac_addr); + struct rte_ether_addr *mac_addr); static int iavf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id); static int iavf_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, @@ -76,6 +76,16 @@ static int iavf_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, int iavf_logtype_init; int iavf_logtype_driver; +#ifdef RTE_LIBRTE_IAVF_DEBUG_RX +int iavf_logtype_rx; +#endif +#ifdef RTE_LIBRTE_IAVF_DEBUG_TX +int iavf_logtype_tx; +#endif +#ifdef RTE_LIBRTE_IAVF_DEBUG_TX_FREE +int iavf_logtype_tx_free; +#endif + static const struct rte_pci_id pci_id_iavf_map[] = { { RTE_PCI_DEVICE(IAVF_INTEL_VENDOR_ID, IAVF_DEV_ID_ADAPTIVE_VF) }, { .vendor_id = 0, /* sentinel */ }, @@ -131,16 +141,14 @@ iavf_dev_configure(struct rte_eth_dev *dev) struct rte_eth_conf *dev_conf = &dev->data->dev_conf; ad->rx_bulk_alloc_allowed = true; -#ifdef RTE_LIBRTE_IAVF_INC_VECTOR /* Initialize to TRUE. If any of Rx queues doesn't meet the * vector Rx/Tx preconditions, it will be reset. */ ad->rx_vec_allowed = true; ad->tx_vec_allowed = true; -#else - ad->rx_vec_allowed = false; - ad->tx_vec_allowed = false; -#endif + + if (dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_RSS_FLAG) + dev->data->dev_conf.rxmode.offloads |= DEV_RX_OFFLOAD_RSS_HASH; /* Vlan stripping setting */ if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_VLAN) { @@ -225,23 +233,23 @@ iavf_init_rxq(struct rte_eth_dev *dev, struct iavf_rx_queue *rxq) * correctly. */ if (dev->data->dev_conf.rxmode.offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) { - if (max_pkt_len <= ETHER_MAX_LEN || + if (max_pkt_len <= RTE_ETHER_MAX_LEN || max_pkt_len > IAVF_FRAME_SIZE_MAX) { PMD_DRV_LOG(ERR, "maximum packet length must be " "larger than %u and smaller than %u, " "as jumbo frame is enabled", - (uint32_t)ETHER_MAX_LEN, + (uint32_t)RTE_ETHER_MAX_LEN, (uint32_t)IAVF_FRAME_SIZE_MAX); return -EINVAL; } } else { - if (max_pkt_len < ETHER_MIN_LEN || - max_pkt_len > ETHER_MAX_LEN) { + if (max_pkt_len < RTE_ETHER_MIN_LEN || + max_pkt_len > RTE_ETHER_MAX_LEN) { PMD_DRV_LOG(ERR, "maximum packet length must be " "larger than %u and smaller than %u, " "as jumbo frame is disabled", - (uint32_t)ETHER_MIN_LEN, - (uint32_t)ETHER_MAX_LEN); + (uint32_t)RTE_ETHER_MIN_LEN, + (uint32_t)RTE_ETHER_MAX_LEN); return -EINVAL; } } @@ -495,7 +503,7 @@ iavf_dev_stop(struct rte_eth_dev *dev) hw->adapter_stopped = 1; } -static void +static int iavf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) { struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private); @@ -517,7 +525,8 @@ iavf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM | DEV_RX_OFFLOAD_SCATTER | DEV_RX_OFFLOAD_JUMBO_FRAME | - DEV_RX_OFFLOAD_VLAN_FILTER; + DEV_RX_OFFLOAD_VLAN_FILTER | + DEV_RX_OFFLOAD_RSS_HASH; dev_info->tx_offload_capa = DEV_TX_OFFLOAD_VLAN_INSERT | DEV_TX_OFFLOAD_QINQ_INSERT | @@ -556,6 +565,8 @@ iavf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) .nb_min = IAVF_MIN_RING_DESC, .nb_align = IAVF_ALIGN_RING_DESC, }; + + return 0; } static const uint32_t * @@ -632,7 +643,7 @@ iavf_dev_link_update(struct rte_eth_dev *dev, return 0; } -static void +static int iavf_dev_promiscuous_enable(struct rte_eth_dev *dev) { struct iavf_adapter *adapter = @@ -641,14 +652,18 @@ iavf_dev_promiscuous_enable(struct rte_eth_dev *dev) int ret; if (vf->promisc_unicast_enabled) - return; + return 0; ret = iavf_config_promisc(adapter, TRUE, vf->promisc_multicast_enabled); if (!ret) vf->promisc_unicast_enabled = TRUE; + else + ret = -EAGAIN; + + return ret; } -static void +static int iavf_dev_promiscuous_disable(struct rte_eth_dev *dev) { struct iavf_adapter *adapter = @@ -657,14 +672,18 @@ iavf_dev_promiscuous_disable(struct rte_eth_dev *dev) int ret; if (!vf->promisc_unicast_enabled) - return; + return 0; ret = iavf_config_promisc(adapter, FALSE, vf->promisc_multicast_enabled); if (!ret) vf->promisc_unicast_enabled = FALSE; + else + ret = -EAGAIN; + + return ret; } -static void +static int iavf_dev_allmulticast_enable(struct rte_eth_dev *dev) { struct iavf_adapter *adapter = @@ -673,14 +692,18 @@ iavf_dev_allmulticast_enable(struct rte_eth_dev *dev) int ret; if (vf->promisc_multicast_enabled) - return; + return 0; ret = iavf_config_promisc(adapter, vf->promisc_unicast_enabled, TRUE); if (!ret) vf->promisc_multicast_enabled = TRUE; + else + ret = -EAGAIN; + + return ret; } -static void +static int iavf_dev_allmulticast_disable(struct rte_eth_dev *dev) { struct iavf_adapter *adapter = @@ -689,15 +712,19 @@ iavf_dev_allmulticast_disable(struct rte_eth_dev *dev) int ret; if (!vf->promisc_multicast_enabled) - return; + return 0; ret = iavf_config_promisc(adapter, vf->promisc_unicast_enabled, FALSE); if (!ret) vf->promisc_multicast_enabled = FALSE; + else + ret = -EAGAIN; + + return ret; } static int -iavf_dev_add_mac_addr(struct rte_eth_dev *dev, struct ether_addr *addr, +iavf_dev_add_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *addr, __rte_unused uint32_t index, __rte_unused uint32_t pool) { @@ -706,7 +733,7 @@ iavf_dev_add_mac_addr(struct rte_eth_dev *dev, struct ether_addr *addr, struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter); int err; - if (is_zero_ether_addr(addr)) { + if (rte_is_zero_ether_addr(addr)) { PMD_DRV_LOG(ERR, "Invalid Ethernet Address"); return -EINVAL; } @@ -728,7 +755,7 @@ iavf_dev_del_mac_addr(struct rte_eth_dev *dev, uint32_t index) struct iavf_adapter *adapter = IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private); struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter); - struct ether_addr *addr; + struct rte_ether_addr *addr; int err; addr = &dev->data->mac_addrs[index]; @@ -917,7 +944,7 @@ iavf_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) uint32_t frame_size = mtu + IAVF_ETH_OVERHEAD; int ret = 0; - if (mtu < ETHER_MIN_MTU || frame_size > IAVF_FRAME_SIZE_MAX) + if (mtu < RTE_ETHER_MIN_MTU || frame_size > IAVF_FRAME_SIZE_MAX) return -EINVAL; /* mtu setting is forbidden if port is start */ @@ -926,7 +953,7 @@ iavf_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) return -EBUSY; } - if (frame_size > ETHER_MAX_LEN) + if (frame_size > RTE_ETHER_MAX_LEN) dev->data->dev_conf.rxmode.offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME; else @@ -940,22 +967,22 @@ iavf_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) static int iavf_dev_set_default_mac_addr(struct rte_eth_dev *dev, - struct ether_addr *mac_addr) + struct rte_ether_addr *mac_addr) { struct iavf_adapter *adapter = IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private); struct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(adapter); - struct ether_addr *perm_addr, *old_addr; + struct rte_ether_addr *perm_addr, *old_addr; int ret; - old_addr = (struct ether_addr *)hw->mac.addr; - perm_addr = (struct ether_addr *)hw->mac.perm_addr; + old_addr = (struct rte_ether_addr *)hw->mac.addr; + perm_addr = (struct rte_ether_addr *)hw->mac.perm_addr; - if (is_same_ether_addr(mac_addr, old_addr)) + if (rte_is_same_ether_addr(mac_addr, old_addr)) return 0; /* If the MAC address is configured by host, skip the setting */ - if (is_valid_assigned_ether_addr(perm_addr)) + if (rte_is_valid_assigned_ether_addr(perm_addr)) return -EPERM; ret = iavf_add_del_eth_addr(adapter, old_addr, FALSE); @@ -983,7 +1010,7 @@ iavf_dev_set_default_mac_addr(struct rte_eth_dev *dev, if (ret) return -EIO; - ether_addr_copy(mac_addr, (struct ether_addr *)hw->mac.addr); + rte_ether_addr_copy(mac_addr, (struct rte_ether_addr *)hw->mac.addr); return 0; } @@ -1047,6 +1074,7 @@ iavf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) stats->imissed = pstats->rx_discards; stats->oerrors = pstats->tx_errors + pstats->tx_discards; stats->ibytes = pstats->rx_bytes; + stats->ibytes -= stats->ipackets * RTE_ETHER_CRC_LEN; stats->obytes = pstats->tx_bytes; } else { PMD_DRV_LOG(ERR, "Get statistics failed"); @@ -1054,7 +1082,7 @@ iavf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) return -EIO; } -static void +static int iavf_dev_stats_reset(struct rte_eth_dev *dev) { int ret; @@ -1066,10 +1094,13 @@ iavf_dev_stats_reset(struct rte_eth_dev *dev) /* read stat values to clear hardware registers */ ret = iavf_query_stats(adapter, &pstats); + if (ret != 0) + return ret; /* set stats offset base on current values */ - if (ret == 0) - vsi->eth_stats_offset = *pstats; + vsi->eth_stats_offset = *pstats; + + return 0; } static int @@ -1098,7 +1129,7 @@ iavf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id) IAVF_WRITE_FLUSH(hw); - rte_intr_enable(&pci_dev->intr_handle); + rte_intr_ack(&pci_dev->intr_handle); return 0; } @@ -1305,21 +1336,20 @@ iavf_dev_init(struct rte_eth_dev *eth_dev) /* copy mac addr */ eth_dev->data->mac_addrs = rte_zmalloc( - "iavf_mac", - ETHER_ADDR_LEN * IAVF_NUM_MACADDR_MAX, - 0); + "iavf_mac", RTE_ETHER_ADDR_LEN * IAVF_NUM_MACADDR_MAX, 0); if (!eth_dev->data->mac_addrs) { PMD_INIT_LOG(ERR, "Failed to allocate %d bytes needed to" " store MAC addresses", - ETHER_ADDR_LEN * IAVF_NUM_MACADDR_MAX); + RTE_ETHER_ADDR_LEN * IAVF_NUM_MACADDR_MAX); return -ENOMEM; } /* If the MAC address is not configured by host, * generate a random one. */ - if (!is_valid_assigned_ether_addr((struct ether_addr *)hw->mac.addr)) - eth_random_addr(hw->mac.addr); - ether_addr_copy((struct ether_addr *)hw->mac.addr, + if (!rte_is_valid_assigned_ether_addr( + (struct rte_ether_addr *)hw->mac.addr)) + rte_eth_random_addr(hw->mac.addr); + rte_ether_addr_copy((struct rte_ether_addr *)hw->mac.addr, ð_dev->data->mac_addrs[0]); /* register callback func to eal lib */ @@ -1403,8 +1433,7 @@ static int eth_iavf_pci_remove(struct rte_pci_device *pci_dev) /* Adaptive virtual function driver struct */ static struct rte_pci_driver rte_iavf_pmd = { .id_table = pci_id_iavf_map, - .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC | - RTE_PCI_DRV_IOVA_AS_VA, + .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC, .probe = eth_iavf_pci_probe, .remove = eth_iavf_pci_remove, }; @@ -1420,6 +1449,24 @@ RTE_INIT(iavf_init_log) iavf_logtype_driver = rte_log_register("pmd.net.iavf.driver"); if (iavf_logtype_driver >= 0) rte_log_set_level(iavf_logtype_driver, RTE_LOG_NOTICE); + +#ifdef RTE_LIBRTE_IAVF_DEBUG_RX + iavf_logtype_rx = rte_log_register("pmd.net.iavf.rx"); + if (iavf_logtype_rx >= 0) + rte_log_set_level(iavf_logtype_rx, RTE_LOG_DEBUG); +#endif + +#ifdef RTE_LIBRTE_IAVF_DEBUG_TX + iavf_logtype_tx = rte_log_register("pmd.net.iavf.tx"); + if (iavf_logtype_tx >= 0) + rte_log_set_level(iavf_logtype_tx, RTE_LOG_DEBUG); +#endif + +#ifdef RTE_LIBRTE_IAVF_DEBUG_TX_FREE + iavf_logtype_tx_free = rte_log_register("pmd.net.iavf.tx_free"); + if (iavf_logtype_tx_free >= 0) + rte_log_set_level(iavf_logtype_tx_free, RTE_LOG_DEBUG); +#endif } /* memory func for base code */