Message ID | KL1PR0601MB55678B1F0A4D7AC99B21B5F6908BA@KL1PR0601MB5567.apcprd06.prod.outlook.com (mailing list archive) |
---|---|
State | Not Applicable |
Delegated to: | Stephen Hemminger |
Headers |
Return-Path: <dev-bounces@dpdk.org> X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3660D466F2; Thu, 8 May 2025 08:26:48 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B3C014027C; Thu, 8 May 2025 08:26:47 +0200 (CEST) Received: from TYPPR03CU001.outbound.protection.outlook.com (mail-japaneastazon11022081.outbound.protection.outlook.com [52.101.126.81]) by mails.dpdk.org (Postfix) with ESMTP id 491CC4025A for <dev@dpdk.org>; Thu, 8 May 2025 08:26:44 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=pwt8PQ1z4d558aOO38wY3vf8zPkOKnoQ50jaU6bVwPKaKmMCN0tb4XCTahPdxsQ5hm8SVPpoa3zwruDDiuwHF13oQN8WCLux0jvKcoXAenJA8f08LWfIDgfb07xGmhm8KR3VGPRM7ClUCegL9Qxr/33Y+Ucvep6sBQPs7+QDr7p0RzbRAVK2QQdWjOrFbJR+/d1fgMCPoen84x6h8pV/FImAdziU+7L9mHemXqG7VV7go3sReHCxzGbB8pjbe7e88GtsnDiT4zYP+1i1HiUUf4oV9n3mfs5WnpbGjLmavV7qjGfBrNm3emnK3IFb41uq+EbXuIrKpdogNxTKb6SqqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Gc4KQo06qxzsJJ1svaZDfhLGq5GMD2Fr+wWNdi7t+6Q=; b=Vw+0selmP6q2vMYiWw0LTmiLQr074+XAWbuwSIHdro0kifbByCUGhGpgGI0aAIpv8VIwQAkuPngKLWUi/QaSvZCNZbYd9V6xn1HyRjc3ce7blCjfTD1NbeGdvx6bi1/AEMlzMEqKCAqVyFn55VRKRCA8L7NZGhZtpI5rNVCYhYkbjRGmnyniRSNRGLQn+z/KNsTmFe3zzBxcPT/WJ6Jg/ZqrGf6SdGzoYDoZPDTWhPvnKFElJAg1UhZ/2DN0eLjRHoeLIP/8/lgRiySZ5EYCIUcS/IL02DMLP2PGZBjZDjjizslLnOq/f0EVdASnqRqRXus5P5CDYAVChlp2DJF6LQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=jaguarmicro.com; dmarc=pass action=none header.from=jaguarmicro.com; dkim=pass header.d=jaguarmicro.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jaguarmicro.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Gc4KQo06qxzsJJ1svaZDfhLGq5GMD2Fr+wWNdi7t+6Q=; b=QQeVmV0sWIwcLvVogAtqkuwKsmIHR+miBCTeQ1H4ahcRVeYdmkwPTn+pSBVc6/oteymQYeegqCaHR0ae3QgxUA05/KXC7X79QitTGJGC1vu25mONnmbF0XhHBkm8ZZJQDfLi3s3cH8DRCaUl8BCRdNFfktksRJHmS2mDctutyc64InOeEwEZtWaS5qUYGoiqXFbtqI7Z0z5z/rwdbN3CluheloO7BRzqX0fJiKr90OSATH/kCJkaKtjrUEra/OcXL7Hgdky27FnpI2YVLOzId4ssqDKxNJwzhoasNqzxy2yfadGlTK+paMVGP6XSBfyz+RJT2v6eTTYr5O54+iuSkQ== Received: from KL1PR0601MB5567.apcprd06.prod.outlook.com (2603:1096:820:c5::14) by SG2PR06MB5430.apcprd06.prod.outlook.com (2603:1096:4:1ba::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8699.30; Thu, 8 May 2025 06:26:39 +0000 Received: from KL1PR0601MB5567.apcprd06.prod.outlook.com ([fe80::3ad3:b4d9:7e69:85cb]) by KL1PR0601MB5567.apcprd06.prod.outlook.com ([fe80::3ad3:b4d9:7e69:85cb%5]) with mapi id 15.20.8722.021; Thu, 8 May 2025 06:26:39 +0000 From: Sunyang Wu <sunyang.wu@jaguarmicro.com> To: Stephen Hemminger <stephen@networkplumber.org> CC: dev <dev@dpdk.org>, Thomas Monjalon <thomas@monjalon.net>, Ferruh Yigit <ferruh.yigit@amd.com>, Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru> Subject: =?utf-8?q?=E5=9B=9E=E5=A4=8D=3A_=5BPATCH=5D_ethdev=3A_optimize_how_?= =?utf-8?q?the_values_of_the_flag_variables_are_assigned?= Thread-Topic: [PATCH] ethdev: optimize how the values of the flag variables are assigned Thread-Index: AQHbv8GrSBuoTF9nK02aIDHiEdAvBLPINkWAgAAOJHA= Date: Thu, 8 May 2025 06:26:39 +0000 Message-ID: <KL1PR0601MB55678B1F0A4D7AC99B21B5F6908BA@KL1PR0601MB5567.apcprd06.prod.outlook.com> References: <20250508023334.28416-1-sunyang.wu@jaguarmicro.com> <CAOaVG15=NiMUfxtkjPSdQWXKhqJ7x+9n-F1K-LdKpHuSUYnoAQ@mail.gmail.com> In-Reply-To: <CAOaVG15=NiMUfxtkjPSdQWXKhqJ7x+9n-F1K-LdKpHuSUYnoAQ@mail.gmail.com> Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=jaguarmicro.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: KL1PR0601MB5567:EE_|SG2PR06MB5430:EE_ x-ms-office365-filtering-correlation-id: 7a5ae3f6-e7bb-4bae-8097-08dd8df94a67 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|376014|1800799024|366016|7053199007|8096899003|38070700018; x-microsoft-antispam-message-info: =?utf-8?q?KaAnUKQBOsHsKyRxqROF3OUYVd+qRuk?= =?utf-8?q?oxDFpbemXiml5Xge1tyak0MmG1CpZHHnTImkXwjjrdnu2L25XS4z35i/PrggVLtUy?= =?utf-8?q?j2XC2wKomE++oo5pe8iiVgdlcFV8TTBAPwsNRmfEFp/hKYuQKpLGDzNt5yEw6qzlB?= =?utf-8?q?Ta6B1as7ZPt/4qZDhzufT4AGwL9uGjrncIZIv+HHjHVUtm8VNvFSlIGXO3MklDi96?= =?utf-8?q?L+mI61FMICceM9G4uess2esr8lcqqbcfCn95JgtwQwlUNohX8r6ifeEROLOFlDbCC?= =?utf-8?q?bpmcDCWtkaLHP1ufMR3Q9eIT/NqlzhGBFnbmR6qrfTjT97RO5Kg/7bbPrZEUVJurG?= =?utf-8?q?uEMRB1x+GXpMUPL98vzGfNhwhCKmQBVdtAqQKxUcsq11KsloJOrBBLbVJJVXasLgD?= =?utf-8?q?YIDkamy0gEJ+xyQ5lkqyhzgXrvizPrGD+x81GC1ogIt/XBUKCWwbD4Kzucms1p0d5?= =?utf-8?q?dc3ohLWqwwR1cnJscDVR6/2b4ERJ8/XSKw6LiJHbLVe3mlRMUSMdAtoj87qestg+W?= =?utf-8?q?ezf8pkhcgs9BjyUYlNWFG79KGkkeGhGcz82nk+pjk6Y5LGokrmzmwoK3ewqyEZRUt?= =?utf-8?q?beXC6NXkPm6YCGb7+jx/OUO/tDE67xLYQMNQU55SfMuQa2Mnmpv6nKuKNBfjUOtTP?= =?utf-8?q?1dsNoL8ctlGWyKKW6xQEF3GMObGJz/K9ho9RlD2tKiM/gFVXJRPa4U7cQtbYi511t?= =?utf-8?q?w3qxxKBdsmPY4B4paYima8utUaPpcl0EQwJNYVDb39W1+WWRL38WrtAiCECnuZS8S?= =?utf-8?q?fSULv/U1v7F55cl7DCXThfYzlYA+UPvoumVo5HRcLbKaEthQWeUguNR5I1eqJMhhg?= =?utf-8?q?DITCg8hiO08k0BvXwcy01bUGzW09lgaJz1W4PHMQCtl3gw53pxRVb2yQatEp1u+g1?= =?utf-8?q?d8+X1BMxqlPZkCIfWE0EybU733755yDNuPNs54u6y781EdURu5KNY+xfqO/phDXyN?= =?utf-8?q?YSuViU1G63zt364+loodIly3YDAQbOQka8rsHN8Bjw0q/umhoKeZMWvyBSIvRUwHu?= =?utf-8?q?tuRwAJdcqXxiQRCevMkwWfIBSqO4WJzfisHwPvI7Cr9G4/P75R+B6ie73jziq2ckj?= =?utf-8?q?F5sdQ6tHSXIOETRmOBPziT0UyxtUVeF8B6MmVxlA25BwLRyisF7S7YVgM9Ug9iq1B?= =?utf-8?q?G7W0P7LRiTtRdTcrm4Tg0lrrgtq80c4RdO3bbGH1Y9c/ETc9BjKq6kBc8hT1gFuI4?= =?utf-8?q?sM0SQNQ8vrSJLhIPl1C8lf1qkzSQxraDT0qmnWIMg/480yx4o/7t9wnrBRZotCfDO?= =?utf-8?q?5o4Wi/nHqZaH1AX4yA+Xdb+a0oOH98NMgY4B/CpJrZcDSMGm5zVm96pqAbXHzQ9j0?= =?utf-8?q?aof3Ku32AjbaxRE1dcX07r+8bgtDBza7JSwV+JdPTuipUqZ4DN3Y2l8wt7tvjaR7p?= =?utf-8?q?lK2CIUO51PwmFtwUtOSonFuyntcS/utfN6BKHkaQhs6pX7RyxVfMNg=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:zh-cn; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:KL1PR0601MB5567.apcprd06.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(1800799024)(366016)(7053199007)(8096899003)(38070700018); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?PUizhXbOqKdsikcdMCZ6fY/QBc0q?= =?utf-8?q?C60pMQVab4ERkJVzkOAehwlalQ/ATmgHXf7catE2e30phNI+igxHwiZrkNbJL6BhR?= =?utf-8?q?32dxuIRXTRnwA68Qclsag5g6zH0PsXpRT10n4Q/Sq7t+x2gUzskbVDBAIuP4GCo5U?= =?utf-8?q?Fz0NF6M2P3tsd//s2URYX15YvnEBOa1DAI9eCVvrt1mTrUmkHo85JJBa3B1gPUZht?= =?utf-8?q?0vB307GFVMPxROvJSsWBedU8PDc+5DNuKy3d9YmHuYnu0fqQjatTKdOe2UmDZ8jwb?= =?utf-8?q?YRYB0u/bW8tkeZEm3haa4rEU1Y9Mdjc/G6ay+nKqRrgxtePSlChqdywV4bvvrYlzy?= =?utf-8?q?x4OPwK9n1DYa7pIRAbGz9Eis16ZhfvmoPoEshTYzdcFLzLxvVq/qJMsjxopc69LdU?= =?utf-8?q?OdaeiXltpq54d24bj/OjVFnrEgVHIvhl+0Y4mAxaXkYepxXof9FWylHP363LkEAbc?= =?utf-8?q?LweSPdQxnviYAZ6sxqw5Gfl/gOKQn0La1NXGxmNVSDumW3/UB5Bp1uAvyBfgC/iLK?= =?utf-8?q?u3WuznkDt5QkHPAZITnJVrZvdJ3NFSxbxpGLV95NfnpLfsYSHmtuA5T80v3vsz91d?= =?utf-8?q?Am1rcxS+szRu0EgFSW2VJRwLh2HBnAZ//Aja78BiIMog48zgspcOuTiFaPsx83k0V?= =?utf-8?q?xcaMVeQXJgM7Df5MAHXSVynm5NK36n25IzfyhoxYbO9+imYrUjBO4Vh/uip4y6Ku1?= =?utf-8?q?4+8ZtjIm+xIKeGbJVgMfx2kcvi+YNI1YlS/U6QBQnv1Dmh6p29LUxWXCymI9IyHJL?= =?utf-8?q?xU3g4Jc04PQMTzhe9p1QsnZq4xfTTm6kHH23sAaTvKzb80YT4oMbEf8cC0gGrxVkf?= =?utf-8?q?hZeCJvEe/yGI8vcpOoQ2zH+ihcNBVujHv4Kpb9zZ+lAWkOLq0MaqA/fUiGjOQUrrv?= =?utf-8?q?sL2ie+9Knt57PeT2o58fXF56CYe4/PyXkl470r5/s8ItszjbbxSfu2Qcc1VZ32puP?= =?utf-8?q?BJSqPEHFbrSr5uAVETkJbh4xu9t7qVWSOO9TKQgL/6Us/qQHTBbpgVNqfo4wVfRFD?= =?utf-8?q?/oGagFQJtAARcFAbHZk2PiTlXiEyI0EPpKkFElbIUGlCCnorMpik/tmrhiT6qubqQ?= =?utf-8?q?ox3sE2Kfl9Ska+Fldra6KMMz/bK/jFglmnpkkiAu+TcjRmWBZ59QI2aAadu6o3a5p?= =?utf-8?q?VxPXwbSWs1TglFWkZctbbbGAC2HIATKLbTTYTVhA4dWQ+AhyRXJ0ucxIqR5T1qZxZ?= =?utf-8?q?xD6t2y+d+3ONcuyHfiySYgLxxMzCvHWs8fMaQo/C49YkI9pJkXG28Pa8s/+9YSMdx?= =?utf-8?q?KWYx+qVxJvcDQg6Z9YIrdEhw6UPAbItpEZq4v3N9utkQIDpWq+4JfTZc2YjOzIVXs?= =?utf-8?q?eJG6Y2hGdb9tOHlCSsQlQVJWn1A7uba/K8WgPTiKKYXRAaCQFF9lvNumYOOPFGHwN?= =?utf-8?q?Zx0lbqYeQ+xq0v4bmLhNFVtOs8DChDGMSxXDFRmAihetVQJwF5SUx9g5fCPtz58g/?= =?utf-8?q?FsHfRYktZik0XqAp6G4/AFwlzZQXQVGOHafy/DkxRnfxaIs7iH4FwrqmljukzVY32?= =?utf-8?q?nR64NszRePKa?= Content-Type: multipart/alternative; boundary="_000_KL1PR0601MB55678B1F0A4D7AC99B21B5F6908BAKL1PR0601MB5567_" MIME-Version: 1.0 X-OriginatorOrg: jaguarmicro.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: KL1PR0601MB5567.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7a5ae3f6-e7bb-4bae-8097-08dd8df94a67 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 May 2025 06:26:39.1085 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 1e45a5c2-d3e1-46b3-a0e6-c5ebf6d8ba7b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: yrTstBVw6yLokr1ekIqG3xjIkeMH8fxTEO2ZyM/B2TJTyedCmQepzDcZBTtiIE93ct/n3mR0kNaKI/CoU0qtWbtEu9XmeariXz/cYhAAoLA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR06MB5430 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions <dev.dpdk.org> List-Unsubscribe: <https://mails.dpdk.org/options/dev>, <mailto:dev-request@dpdk.org?subject=unsubscribe> List-Archive: <http://mails.dpdk.org/archives/dev/> List-Post: <mailto:dev@dpdk.org> List-Help: <mailto:dev-request@dpdk.org?subject=help> List-Subscribe: <https://mails.dpdk.org/listinfo/dev>, <mailto:dev-request@dpdk.org?subject=subscribe> Errors-To: dev-bounces@dpdk.org |
Series |
回复: [PATCH] ethdev: optimize how the values of the flag variables are assigned
|
|
Checks
Context | Check | Description |
---|---|---|
ci/loongarch-compilation | warning | apply patch failure |
ci/Intel-compilation | warning | apply issues |
ci/iol-testing | warning | apply patch failure |
Commit Message
Sunyang Wu
May 8, 2025, 6:26 a.m. UTC
Thank you for your reply. Personally, I think that when disabling promiscuous/all-multicast mode, the corresponding flag should be set based on the return value. This is because, at the driver implementation level, the driver may check the flag to determine whether the corresponding disable operation needs to be executed. If the flag is set before the operation is completed, the driver will not execute the operation when it checks the flag, as it will find that the flag has already been set.
发件人: Stephen Hemminger <stephen@networkplumber.org>
发送时间: 2025年5月8日 13:35
收件人: Sunyang Wu <sunyang.wu@jaguarmicro.com>
抄送: dev <dev@dpdk.org>; Thomas Monjalon <thomas@monjalon.net>; Ferruh Yigit <ferruh.yigit@amd.com>; Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
主题: Re: [PATCH] ethdev: optimize how the values of the flag variables are assigned
External Mail: This email originated from OUTSIDE of the organization!
Do not click links, open attachments or provide ANY information unless you recognize the sender and know the content is safe.
Why bother? This is not critical path.
Original code looked fine
On Thu, May 8, 2025, 11:34 Sunyang Wu <sunyang.wu@jaguarmicro.com<mailto: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<mailto:sunyang.wu@jaguarmicro.com>>
---
lib/ethdev/rte_ethdev.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
--
2.19.0.rc0.windows.1
Comments
Wouldn't the correct fix assume the change has no effect if the operation failed, like the _enable_ functions do, i.e.: int rte_eth_promiscuous_disable(uint16_t port_id) { struct rte_eth_dev *dev; int diag = 0; RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); dev = &rte_eth_devices[port_id]; if (dev->data->promiscuous == 0) return 0; 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 == 0) + dev->data->promiscuous = 0; diag = eth_err(port_id, diag); rte_eth_trace_promiscuous_disable(port_id, dev->data->promiscuous, diag); return diag; } From: Sunyang Wu [mailto:sunyang.wu@jaguarmicro.com] Sent: Thursday, 8 May 2025 08.27 Thank you for your reply. Personally, I think that when disabling promiscuous/all-multicast mode, the corresponding flag should be set based on the return value. This is because, at the driver implementation level, the driver may check the flag to determine whether the corresponding disable operation needs to be executed. If the flag is set before the operation is completed, the driver will not execute the operation when it checks the flag, as it will find that the flag has already been set. 发件人: Stephen Hemminger <stephen@networkplumber.org> 发送时间: 2025年5月8日 13:35 收件人: Sunyang Wu <sunyang.wu@jaguarmicro.com> 抄送: dev <dev@dpdk.org>; Thomas Monjalon <thomas@monjalon.net>; Ferruh Yigit <ferruh.yigit@amd.com>; Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru> 主题: Re: [PATCH] ethdev: optimize how the values of the flag variables are assigned External Mail: This email originated from OUTSIDE of the organization! Do not click links, open attachments or provide ANY information unless you recognize the sender and know the content is safe. 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
On Thu, 8 May 2025 10:17:44 +0200 Morten Brørup <mb@smartsharesystems.com> wrote: > Wouldn't the correct fix assume the change has no effect if the operation failed, like the _enable_ functions do, i.e.: > > int > rte_eth_promiscuous_disable(uint16_t port_id) > { > struct rte_eth_dev *dev; > int diag = 0; > > RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); > dev = &rte_eth_devices[port_id]; > > if (dev->data->promiscuous == 0) > return 0; > > 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 == 0) > + dev->data->promiscuous = 0; > diag = eth_err(port_id, diag); > > rte_eth_trace_promiscuous_disable(port_id, dev->data->promiscuous, > diag); > > return diag; > } > > > From: Sunyang Wu [mailto:sunyang.wu@jaguarmicro.com] > Sent: Thursday, 8 May 2025 08.27 > > Thank you for your reply. Personally, I think that when disabling promiscuous/all-multicast mode, the corresponding flag should be set based on the return value. This is because, at the driver implementation level, the driver may check the flag to determine whether the corresponding disable operation needs to be executed. If the flag is set before the operation is completed, the driver will not execute the operation when it checks the flag, as it will find that the flag has already been set. > > 发件人: Stephen Hemminger <stephen@networkplumber.org> > 发送时间: 2025年5月8日 13:35 > 收件人: Sunyang Wu <sunyang.wu@jaguarmicro.com> > 抄送: dev <dev@dpdk.org>; Thomas Monjalon <thomas@monjalon.net>; Ferruh Yigit <ferruh.yigit@amd.com>; Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru> > 主题: Re: [PATCH] ethdev: optimize how the values of the flag variables are assigned > > > External Mail: This email originated from OUTSIDE of the organization! > Do not click links, open attachments or provide ANY information unless you recognize the sender and know the content is safe. > > 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); > Agree. The concept is good, but it is not an optimization. There is a bug here. The flag should not be set if driver returns an error. The error should be directly returned to application and state should not change.
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);