From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 22DB9466F0; Thu, 8 May 2025 07:34:51 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DCE014027C; Thu, 8 May 2025 07:34:50 +0200 (CEST) Received: from mail-vk1-f174.google.com (mail-vk1-f174.google.com [209.85.221.174]) by mails.dpdk.org (Postfix) with ESMTP id C4EFB4025A for ; Thu, 8 May 2025 07:34:49 +0200 (CEST) Received: by mail-vk1-f174.google.com with SMTP id 71dfb90a1353d-5240b014f47so189931e0c.1 for ; Wed, 07 May 2025 22:34:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1746682489; x=1747287289; darn=dpdk.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=pIpb9m/AWoE/OA1G6FgQ3hv/CYy7FpE1ls/h3rxhDno=; b=RdptnEcl30tozACm9grANJjlXjRYfro+ITaH2Qsi9JJY+asR0OxjOppE7asEg863BX H23siWUX5LLptPyonpsFhuNy48RggX4pbhsStLRBN7cwwnWxrVDRzUN/ebTBgQu+Uket TDCVcL9JFQB2OY+Aj3zUHLSETvObyVmAwpq4T0Y/3PAzBWE4ELF3ZigfmzRsM7t91cOx PwbblK82c/eR3w1pAgfYG0tbv9ydjGqy6bTLdbnS46Q5UJAuzJesvpNo2rjgvqGcSkSF sLOZTLSXvHC6frhXzFq+/GdOYywuGgoxC7nLdrICjpeuwUdd11g9FQrpLRSAbIebhcyS 1ZYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746682489; x=1747287289; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=pIpb9m/AWoE/OA1G6FgQ3hv/CYy7FpE1ls/h3rxhDno=; b=qBmTxAN5JU8k1hNnpW/6rhyZK9bZTeYiSv+xhg6xqaKWMbUQ8AOmzAVs+NYPPPvARH +AJ51uqJHg1wlnqnz/qyV3tWqT9y1jTxgpR/UQJgvlCkR3aFL9/9EE5mGgGrSjEUuPze 3+U4M6K/3dazYNxpn+vsRokcywHr9q/2lT5GGlAgCi3lgFuK1RsTJ8bH5xVVAmkOMmjO pMhibnmLeFdO+XKKIP2lnKL0bJKxuwyyhddIzn+zodlULROb2zMKNK2WTjNKGVAz5v03 aYO6kEMWXQEqRpWx2RdMfEnFT0PXkjP+Tl+OsTARPYLpDR5l0wy1sbDpSxoowE3ZlO/B /a5A== X-Gm-Message-State: AOJu0YyvWwCMTjroNuOP0YNpg5tjclYUaR2Xzw/DlHOuQWCZRLRhb75l Tn0FMs1LbvUvPS3VXs0yT1/NrXl9z7Lm5Dkli0by93zroO6r2q3zjhz0PqAOZ5t7VYNgZb5i54Q w/kKf/FF5iBDWMPCY/Pexo8NFKXTP4sUW53n38Q== X-Gm-Gg: ASbGncuiE6pIPK/X6W5F1ShYQS6MMYd/k+EQiq4oFaiYVos8Ar/CHAP+JC5vP7S3r13 ukzgvZDZLEJ7HZ20bQao5Q4D1kg0D3AEOXkOxulNCGzsmDVXK/yxfFYgzCLq2nKmKJmOctTIw4C p+4ptHQYueHprGjvnqytCHMbQ= X-Google-Smtp-Source: AGHT+IFHl2qT5B325rCz+NxVSYY5xVEGt08fYjh+eUcmtKxdKi5mgio+MAe2WYx6Y2POJvfl9z28DTLZBgubSSix8Fo= X-Received: by 2002:a05:6122:32d6:b0:525:aeb7:f22e with SMTP id 71dfb90a1353d-52c37a89dcamr4349189e0c.7.1746682489044; Wed, 07 May 2025 22:34:49 -0700 (PDT) MIME-Version: 1.0 References: <20250508023334.28416-1-sunyang.wu@jaguarmicro.com> In-Reply-To: <20250508023334.28416-1-sunyang.wu@jaguarmicro.com> From: Stephen Hemminger Date: Thu, 8 May 2025 14:34:39 +0900 X-Gm-Features: ATxdqUEz6PL9-3Y2oJmbwC-DN3os7olDhbRZ3gXtB8dRVm3IJURr7oSwEcCQd0I Message-ID: Subject: Re: [PATCH] ethdev: optimize how the values of the flag variables are assigned To: Sunyang Wu Cc: dev , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko Content-Type: multipart/alternative; boundary="0000000000004b9e4c063499353e" X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org --0000000000004b9e4c063499353e Content-Type: text/plain; charset="UTF-8" Why bother? This is not critical path. Original code looked fine On Thu, May 8, 2025, 11:34 Sunyang Wu wrote: > Set the values of the promiscuous and all_multicast variables > according to the return value. > > Signed-off-by: Sunyang Wu > --- > 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 > > --0000000000004b9e4c063499353e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Why bother? This is not critical path.
O= riginal code looked fine=C2=A0

On Thu, May 8, 20= 25, 11:34 Sunyang Wu <suny= ang.wu@jaguarmicro.com> wrote:
Set the values of the promiscuous and all_multicast v= ariables
according to the return value.

Signed-off-by: Sunyang Wu <sunyang.wu@jaguarmicro.com> ---
=C2=A0lib/ethdev/rte_ethdev.c | 9 +++------
=C2=A01 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)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (dev->dev_ops->promiscuous_disable =3D= =3D NULL)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return -ENOTSUP;
-=C2=A0 =C2=A0 =C2=A0 =C2=A0dev->data->promiscuous =3D 0;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 diag =3D dev->dev_ops->promiscuous_disabl= e(dev);
-=C2=A0 =C2=A0 =C2=A0 =C2=A0if (diag !=3D 0)
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0dev->data->pr= omiscuous =3D 1;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0dev->data->promiscuous =3D (diag =3D=3D 0= ) ? 0 : 1;

=C2=A0 =C2=A0 =C2=A0 =C2=A0 diag =3D eth_err(port_id, diag);

@@ -3112,10 +3110,9 @@ rte_eth_allmulticast_disable(uint16_t port_id)

=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (dev->dev_ops->allmulticast_disable = =3D=3D NULL)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return -ENOTSUP; -=C2=A0 =C2=A0 =C2=A0 =C2=A0dev->data->all_multicast =3D 0;
+
=C2=A0 =C2=A0 =C2=A0 =C2=A0 diag =3D dev->dev_ops->allmulticast_disab= le(dev);
-=C2=A0 =C2=A0 =C2=A0 =C2=A0if (diag !=3D 0)
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0dev->data->al= l_multicast =3D 1;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0dev->data->all_multicast =3D (diag =3D=3D= 0) ? 0 : 1;

=C2=A0 =C2=A0 =C2=A0 =C2=A0 diag =3D eth_err(port_id, diag);

--
2.19.0.rc0.windows.1

--0000000000004b9e4c063499353e--