net/iavf: cleanup Tx buffers
[dpdk.git] / drivers / net / iavf / iavf_ethdev.c
index 8f46c45..a65140d 100644 (file)
@@ -121,6 +121,7 @@ static const struct eth_dev_ops iavf_eth_dev_ops = {
        .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
@@ -540,6 +541,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;
@@ -665,12 +668,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
@@ -679,20 +677,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
@@ -701,21 +688,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
@@ -724,20 +699,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
@@ -746,20 +710,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
@@ -1285,8 +1238,6 @@ iavf_init_vf(struct rte_eth_dev *dev)
                }
        }
 
-       vf->vf_reset = false;
-
        return 0;
 err_rss:
        rte_free(vf->rss_key);
@@ -1412,11 +1363,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;
@@ -1473,9 +1419,21 @@ iavf_dev_close(struct rte_eth_dev *dev)
                IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
        struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
 
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
+
        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);
@@ -1507,6 +1465,8 @@ iavf_dev_close(struct rte_eth_dev *dev)
        rte_free(vf->aq_resp);
        vf->aq_resp = NULL;
 
+       vf->vf_reset = false;
+
        return 0;
 }