From: Robin Zhang Date: Sun, 27 Sep 2020 07:26:22 +0000 (+0000) Subject: net/iavf: optimize promiscuous device operations X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=1e4d55a7fe71b7cbb648a2443413057dbbfd9add;p=dpdk.git net/iavf: optimize promiscuous device operations This patch is to improve efficiency and eliminate code redundancy of promiscuous ops. Signed-off-by: Robin Zhang Acked-by: Qi Zhang --- diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c index c2e89b848a..0012c77b9b 100644 --- a/drivers/net/iavf/iavf_ethdev.c +++ b/drivers/net/iavf/iavf_ethdev.c @@ -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 diff --git a/drivers/net/iavf/iavf_vchnl.c b/drivers/net/iavf/iavf_vchnl.c index e369430833..db0b768765 100644 --- a/drivers/net/iavf/iavf_vchnl.c +++ b/drivers/net/iavf/iavf_vchnl.c @@ -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