ethdev: optimize how the values of the flag variables are assigned

Message ID 20250508023334.28416-1-sunyang.wu@jaguarmicro.com (mailing list archive)
State Changes Requested
Delegated to: Stephen Hemminger
Headers
Series ethdev: optimize how the values of the flag variables are assigned |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/github-robot: build success github build: passed
ci/iol-marvell-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-abi-testing warning Testing issues
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/aws-unit-testing success Unit Testing PASS

Commit Message

Sunyang Wu May 8, 2025, 2:33 a.m. UTC
Set the values of the promiscuous and all_multicast variables
according to the return value.

Signed-off-by: Sunyang Wu <sunyang.wu@jaguarmicro.com>
---
 lib/ethdev/rte_ethdev.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
  

Comments

Stephen Hemminger May 8, 2025, 5:34 a.m. UTC | #1
Why bother? This is not critical path.
Original code looked fine

On Thu, May 8, 2025, 11:34 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: Sunyang Wu <sunyang.wu@jaguarmicro.com>
> ---
>  lib/ethdev/rte_ethdev.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
> index d4197322a0..b1f593edc4 100644
> --- a/lib/ethdev/rte_ethdev.c
> +++ b/lib/ethdev/rte_ethdev.c
> @@ -3044,10 +3044,8 @@ 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;
> +       dev->data->promiscuous = (diag == 0) ? 0 : 1;
>
>         diag = eth_err(port_id, diag);
>
> @@ -3112,10 +3110,9 @@ 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;
> +       dev->data->all_multicast = (diag == 0) ? 0 : 1;
>
>         diag = eth_err(port_id, diag);
>
> --
> 2.19.0.rc0.windows.1
>
>
  

Patch

diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index d4197322a0..b1f593edc4 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -3044,10 +3044,8 @@  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;
+	dev->data->promiscuous = (diag == 0) ? 0 : 1;
 
 	diag = eth_err(port_id, diag);
 
@@ -3112,10 +3110,9 @@  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;
+	dev->data->all_multicast = (diag == 0) ? 0 : 1;
 
 	diag = eth_err(port_id, diag);