[v2,1/2] ethdev: add check for device promiscuous state
diff mbox series

Message ID 20191021122238.58852-2-ciara.power@intel.com
State Accepted, archived
Delegated to: Ferruh Yigit
Headers show
Series
  • enable virtual PMD promiscuous and multicast
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-intel-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-compilation success Compile Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS

Commit Message

Power, Ciara Oct. 21, 2019, 12:22 p.m. UTC
The promiscuous enable and disable functions now check the
promiscuous state of the device before checking if the dev_ops
function exists for the device.

This change is necessary to allow sample applications run on
virtual PMDs, as previously -ENOTSUP returned when the promiscuous
enable function was called. This caused the sample application to
fail unnecessarily.

Signed-off-by: Ciara Power <ciara.power@intel.com>
---
 lib/librte_ethdev/rte_ethdev.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

Comments

Ferruh Yigit Oct. 21, 2019, 6:39 p.m. UTC | #1
On 10/21/2019 1:22 PM, Ciara Power wrote:
> The promiscuous enable and disable functions now check the
> promiscuous state of the device before checking if the dev_ops
> function exists for the device.
> 
> This change is necessary to allow sample applications run on
> virtual PMDs, as previously -ENOTSUP returned when the promiscuous
> enable function was called. This caused the sample application to
> fail unnecessarily.
> 
> Signed-off-by: Ciara Power <ciara.power@intel.com>

Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

@Andrew, any concern/objection on the patch?
Andrew Rybchenko Oct. 22, 2019, 7:03 a.m. UTC | #2
On 10/21/19 3:22 PM, Ciara Power wrote:
> The promiscuous enable and disable functions now check the
> promiscuous state of the device before checking if the dev_ops
> function exists for the device.
>
> This change is necessary to allow sample applications run on
> virtual PMDs, as previously -ENOTSUP returned when the promiscuous
> enable function was called. This caused the sample application to
> fail unnecessarily.
>
> Signed-off-by: Ciara Power <ciara.power@intel.com>

Many thanks,
Reviewed-by: Andrew Rybchenko <arybchenko@solarflare.com>
Ferruh Yigit Oct. 22, 2019, 8:18 a.m. UTC | #3
On 10/22/2019 8:03 AM, Andrew Rybchenko wrote:
> On 10/21/19 3:22 PM, Ciara Power wrote:
>> The promiscuous enable and disable functions now check the
>> promiscuous state of the device before checking if the dev_ops
>> function exists for the device.
>>
>> This change is necessary to allow sample applications run on
>> virtual PMDs, as previously -ENOTSUP returned when the promiscuous
>> enable function was called. This caused the sample application to
>> fail unnecessarily.
>>
>> Signed-off-by: Ciara Power <ciara.power@intel.com>
> 
> Many thanks,
> Reviewed-by: Andrew Rybchenko <arybchenko@solarflare.com>
> 

Series applied to dpdk-next-net/master, thanks.

Patch
diff mbox series

diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index af823607c..67db0d1dd 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -1930,12 +1930,13 @@  rte_eth_promiscuous_enable(uint16_t port_id)
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 
+	if (dev->data->promiscuous == 1)
+		return 0;
+
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->promiscuous_enable, -ENOTSUP);
 
-	if (dev->data->promiscuous == 0) {
-		diag = (*dev->dev_ops->promiscuous_enable)(dev);
-		dev->data->promiscuous = (diag == 0) ? 1 : 0;
-	}
+	diag = (*dev->dev_ops->promiscuous_enable)(dev);
+	dev->data->promiscuous = (diag == 0) ? 1 : 0;
 
 	return eth_err(port_id, diag);
 }
@@ -1949,14 +1950,15 @@  rte_eth_promiscuous_disable(uint16_t port_id)
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 
+	if (dev->data->promiscuous == 0)
+		return 0;
+
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->promiscuous_disable, -ENOTSUP);
 
-	if (dev->data->promiscuous == 1) {
-		dev->data->promiscuous = 0;
-		diag = (*dev->dev_ops->promiscuous_disable)(dev);
-		if (diag != 0)
-			dev->data->promiscuous = 1;
-	}
+	dev->data->promiscuous = 0;
+	diag = (*dev->dev_ops->promiscuous_disable)(dev);
+	if (diag != 0)
+		dev->data->promiscuous = 1;
 
 	return eth_err(port_id, diag);
 }