DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH v2] ethdev: optimize how the values of the flag variables are assigned
@ 2025-05-21 10:15 Sunyang Wu
  2025-05-21 13:57 ` Stephen Hemminger
  0 siblings, 1 reply; 2+ messages in thread
From: Sunyang Wu @ 2025-05-21 10:15 UTC (permalink / raw)
  To: dev; +Cc: stephen, thomas, ferruh.yigit, andrew.rybchenko, Morten Brørup

Set the values of the promiscuous and all_multicast variables
according to the return value.

Signed-off-by: Morten Brørup <mb@smartsharesystems.com>
Signed-off-by: Sunyang Wu <sunyang.wu@jaguarmicro.com>
---
 lib/ethdev/rte_ethdev.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index d4197322a0..c27d3e5041 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -3044,10 +3044,9 @@ rte_eth_promiscuous_disable(uint16_t port_id)
 	if (dev->dev_ops->promiscuous_disable == NULL)
 		return -ENOTSUP;
 
-	dev->data->promiscuous = 0;
 	diag = dev->dev_ops->promiscuous_disable(dev);
-	if (diag != 0)
-		dev->data->promiscuous = 1;
+	if (!diag)
+		dev->data->promiscuous = 0;
 
 	diag = eth_err(port_id, diag);
 
@@ -3112,10 +3111,10 @@ rte_eth_allmulticast_disable(uint16_t port_id)
 
 	if (dev->dev_ops->allmulticast_disable == NULL)
 		return -ENOTSUP;
-	dev->data->all_multicast = 0;
+
 	diag = dev->dev_ops->allmulticast_disable(dev);
-	if (diag != 0)
-		dev->data->all_multicast = 1;
+	if (!diag)
+		dev->data->all_multicast = 0;
 
 	diag = eth_err(port_id, diag);
 
-- 
2.19.0.rc0.windows.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] ethdev: optimize how the values of the flag variables are assigned
  2025-05-21 10:15 [PATCH v2] ethdev: optimize how the values of the flag variables are assigned Sunyang Wu
@ 2025-05-21 13:57 ` Stephen Hemminger
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Hemminger @ 2025-05-21 13:57 UTC (permalink / raw)
  To: Sunyang Wu
  Cc: dev, thomas, ferruh.yigit, andrew.rybchenko, Morten Brørup

On Wed, 21 May 2025 18:15:31 +0800
Sunyang Wu <sunyang.wu@jaguarmicro.com> wrote:

> Set the values of the promiscuous and all_multicast variables
> according to the return value.
> 
> Signed-off-by: Morten Brørup <mb@smartsharesystems.com>
> Signed-off-by: Sunyang Wu <sunyang.wu@jaguarmicro.com>
> ---
>  lib/ethdev/rte_ethdev.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
> index d4197322a0..c27d3e5041 100644
> --- a/lib/ethdev/rte_ethdev.c
> +++ b/lib/ethdev/rte_ethdev.c
> @@ -3044,10 +3044,9 @@ rte_eth_promiscuous_disable(uint16_t port_id)
>  	if (dev->dev_ops->promiscuous_disable == NULL)
>  		return -ENOTSUP;
>  
> -	dev->data->promiscuous = 0;
>  	diag = dev->dev_ops->promiscuous_disable(dev);
> -	if (diag != 0)
> -		dev->data->promiscuous = 1;
> +	if (!diag)
> +		dev->data->promiscuous = 0;
>  
>  	diag = eth_err(port_id, diag);
>  
> @@ -3112,10 +3111,10 @@ rte_eth_allmulticast_disable(uint16_t port_id)
>  
>  	if (dev->dev_ops->allmulticast_disable == NULL)
>  		return -ENOTSUP;
> -	dev->data->all_multicast = 0;
> +
>  	diag = dev->dev_ops->allmulticast_disable(dev);
> -	if (diag != 0)
> -		dev->data->all_multicast = 1;
> +	if (!diag)
> +		dev->data->all_multicast = 0;
>  
>  	diag = eth_err(port_id, diag);
>  

Code is fine, but the commit description is misleading.
It is not an optimization, it is a bug fix so that flags
are not set if device callback returns an error.

An optimization is something that is faster but has the
same effect.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-05-21 13:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-21 10:15 [PATCH v2] ethdev: optimize how the values of the flag variables are assigned Sunyang Wu
2025-05-21 13:57 ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).