net/iavf: optimize promiscuous device operations
authorRobin Zhang <robinx.zhang@intel.com>
Sun, 27 Sep 2020 07:26:22 +0000 (07:26 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 9 Oct 2020 11:17:43 +0000 (13:17 +0200)
This patch is to improve efficiency and eliminate code
redundancy of promiscuous ops.

Signed-off-by: Robin Zhang <robinx.zhang@intel.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
drivers/net/iavf/iavf_ethdev.c
drivers/net/iavf/iavf_vchnl.c

index c2e89b8..0012c77 100644 (file)
@@ -676,17 +676,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;
-
-       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
@@ -695,18 +687,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;
-
-       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
@@ -715,17 +698,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;
-
-       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
@@ -734,17 +709,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;
-
-       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
index e369430..db0b768 100644 (file)
@@ -842,10 +842,19 @@ iavf_config_promisc(struct iavf_adapter *adapter,
 
        err = iavf_execute_vf_cmd(adapter, &args);
 
-       if (err)
+       if (err) {
                PMD_DRV_LOG(ERR,
                            "fail to execute command CONFIG_PROMISCUOUS_MODE");
-       return err;
+
+               if (err == IAVF_NOT_SUPPORTED)
+                       return -ENOTSUP;
+
+               return -EAGAIN;
+       }
+
+       vf->promisc_unicast_enabled = enable_unicast;
+       vf->promisc_multicast_enabled = enable_multicast;
+       return 0;
 }
 
 int