Message ID | 20231213181554.4741-2-ansuelsmth@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp7973765dys; Wed, 13 Dec 2023 10:16:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IGGslBU41Dady8GB6uTzIt5R3neJjL5OZWU+Lf76jbhUCdc7mWsuNygVnY6ZPTFH6tuMdDX X-Received: by 2002:a17:902:d4cf:b0:1d0:8abf:3f3 with SMTP id o15-20020a170902d4cf00b001d08abf03f3mr5290078plg.35.1702491400677; Wed, 13 Dec 2023 10:16:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702491400; cv=none; d=google.com; s=arc-20160816; b=nNmEbmAUBpODnS8AhHSdJLjn2VxpKLMdhnoBL+gaqu0hART4HQErevs1fjgdEZPSHm 0+x+k24abTlE8OFK5QwJhqOCU4qXgV0z4T/HgZUPUDIUoaRy0LcL8QxrZSoV/6miKYxE NgRY51q7qkTtfDELyOCBmFMpc3TQbVi89/a321GCj8FgQFLwFCjQM0C+K1fZ8ZfulXUW IwZgMDeradbbvRFSvIvN33Fx18ScI7ZTtaSasNP2traTBbfpvgv4oyOQVnrlppiLGAwm Uu91KD9p032Udek24b9WgKLkyQaBsix0vnHj+xsdC4QVInVKDYzMUkBIwMe5iMiZmRXf xN/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=XWFAx4kAF7hKrrXw5IZi1qHuzEkNqyvfaO25OJOU7sA=; fh=p6UE9/XeFdVcez2P5EpH3VpeppOo7ov8vHzRKEaMwWo=; b=TYDXIRcrXD6a/nlMlFSo+d9e+FULD3vItseMJUfvyIz19amwTWWxTHlzzYonXBhV/w RQPnaKNwDX/tnXvXoCOqrmHZGLxoBFSa9ZL/D0S3B0OwauqNXd1hLasT5oDL660eE/WA Pz2Vfn/bFOxvzcW1RgAB692n7gtJ3WnA3AggR/Qrzw1Av18OJRFuROZ++DvPkCii1jyS UJcXjkINdW4dVLOidVJ6hJFriIWmL2w/QSkBqDbGrf6P5djHyvyL/ffKO0Tsbv4PtE8L ebz5FLqGvOfWO3Z880VRJUANLmPG6j0opHn+0JUmhE63qEJ4Rz/x1cgVLHLfp1kI6F25 R0Dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=dZyeq8Qf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id bj3-20020a170902850300b001d092e9cbbfsi9856280plb.445.2023.12.13.10.16.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 10:16:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=dZyeq8Qf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 4634E8297212; Wed, 13 Dec 2023 10:16:26 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442148AbjLMSQD (ORCPT <rfc822;dexuan.linux@gmail.com> + 99 others); Wed, 13 Dec 2023 13:16:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233807AbjLMSP4 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 13 Dec 2023 13:15:56 -0500 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72ADAF3; Wed, 13 Dec 2023 10:16:02 -0800 (PST) Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-3360ae1b937so3694112f8f.0; Wed, 13 Dec 2023 10:16:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702491361; x=1703096161; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=XWFAx4kAF7hKrrXw5IZi1qHuzEkNqyvfaO25OJOU7sA=; b=dZyeq8QfVckkss0cDgsppzOC5CyNkvPCZgbub7jwwbBaGTHKlXOYChgbLNf2+QBLN0 1+uPcWl9aKr2DvDU8jbmD8ZnMv2zW5IzGSY9Bvx3VrWIfu8k/3DsRZ1bMUdAMGCZ1gly EkDPWUPio+t1o755n7YKZZb8OX+oq/sO4DJY/aN2ItvHoAd8reKhgdQEYQGJa2LVeQ1t OSDKuuQn0z002xv1rulQjYOUEsIJaSiR39UPp4OUQQy/04GX1qHd0iv/8KIgpBUXEnTW nqDaHZ7VNh4dVIi/1qLGKil+NMaSZ43fGM8sAB5+5IZ4VOETdJWVD8Bp2DVbuBcaCcta d57A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702491361; x=1703096161; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XWFAx4kAF7hKrrXw5IZi1qHuzEkNqyvfaO25OJOU7sA=; b=np6YiJy4Whs5sDbILvdaWeWKTiAyPol9nlnggGGhwqHjilMY9VGHAiai4grEoS30Xt eDg/WTasSpqvlSbsVgH6rULWqrHzLIvSm/kzZqT2Jvh3Px0+kN6sDHpsZELJUGxb+hag cYFPU/gvD5wrkjLjZ+2ths9msdz2uoF86i34YT8U1k0P+PmR8MLI/zaf+BVuN7hReAld xXpjqWP9BounwEQzGnyDhvw9iFR+tDnrVpNMZ4wTNPXvL2PLCxt2vLr3mj8PAEK2jRd6 EQRMMp7OhPWev4TGNtpmkx8W25Hr53cKh3wt0q9iR5JCorJUVOzlnqN7KW4GW7V4+gRs qrrw== X-Gm-Message-State: AOJu0YwM6cBqRie2f6sPZeQJZa43z5c1uXYy3KQcyINsE/iCHTgNoHOf xWKqI65p3kYGuJ5Atg8ACN8= X-Received: by 2002:adf:fb43:0:b0:334:b1f4:5d59 with SMTP id c3-20020adffb43000000b00334b1f45d59mr4781640wrs.40.1702491360826; Wed, 13 Dec 2023 10:16:00 -0800 (PST) Received: from localhost.localdomain (93-34-89-13.ip49.fastwebnet.it. [93.34.89.13]) by smtp.googlemail.com with ESMTPSA id e33-20020a5d5961000000b0033346fe9b9bsm13947762wri.83.2023.12.13.10.15.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 10:16:00 -0800 (PST) From: Christian Marangi <ansuelsmth@gmail.com> To: Andrew Lunn <andrew@lunn.ch>, Heiner Kallweit <hkallweit1@gmail.com>, Russell King <linux@armlinux.org.uk>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Vladimir Oltean <vladimir.oltean@nxp.com>, Vincent Mailhol <mailhol.vincent@wanadoo.fr>, Kees Cook <keescook@chromium.org>, Christian Marangi <ansuelsmth@gmail.com>, Piergiorgio Beruto <piergiorgio.beruto@gmail.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [net-next PATCH 1/2] net: ethtool: add define for link speed mode number Date: Wed, 13 Dec 2023 19:15:53 +0100 Message-Id: <20231213181554.4741-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231213181554.4741-1-ansuelsmth@gmail.com> References: <20231213181554.4741-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 13 Dec 2023 10:16:26 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785191622637880083 X-GMAIL-MSGID: 1785191622637880083 |
Series |
net: add define to describe link speed modes
|
|
Commit Message
Christian Marangi
Dec. 13, 2023, 6:15 p.m. UTC
Add define to reference the number of link speed mode defined in the
system.
This can be handy for generic parsing of the different link speed mode.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
include/uapi/linux/ethtool.h | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
Comments
NAK. You *clearly* didn't look before you leaped. On Wed, Dec 13, 2023 at 07:15:53PM +0100, Christian Marangi wrote: > +enum ethtool_link_speeds { > + SPEED_10 = 0, > + SPEED_100, > + SPEED_1000, ... and from the context immediately below, included in your patch: > #define SPEED_10 10 ^^^^^^^^ > #define SPEED_100 100 ^^^^^^^^^ > #define SPEED_1000 1000 ^^^^^^^^^^ Your enumerated values will be overridden by the preprocessor definitions. Moreover, SPEED_xxx is an already taken namespace and part of the UAPI, and thus can _not_ be changed. Convention is that SPEED_x will be defined as the numeric speed.
On Wed, Dec 13, 2023 at 08:10:42PM +0000, Russell King (Oracle) wrote: > NAK. > > You *clearly* didn't look before you leaped. > > On Wed, Dec 13, 2023 at 07:15:53PM +0100, Christian Marangi wrote: > > +enum ethtool_link_speeds { > > + SPEED_10 = 0, > > + SPEED_100, > > + SPEED_1000, > ... > > and from the context immediately below, included in your patch: > > #define SPEED_10 10 > ^^^^^^^^ > > #define SPEED_100 100 > ^^^^^^^^^ > > #define SPEED_1000 1000 > ^^^^^^^^^^ > > Your enumerated values will be overridden by the preprocessor > definitions. > > Moreover, SPEED_xxx is an already taken namespace and part of the UAPI, > and thus can _not_ be changed. Convention is that SPEED_x will be > defined as the numeric speed. > Well yes that is the idea of having the enum to count them and then redefining them to the correct value. (wasn't trying to introduce new define for the speed and trying to assign incremental values) Any idea how to handle this without the enum - redefine thing? Was trying to find a more automated way than defining the raw number of the current modes. (but maybe this is not that bad? since on adding more modes, other values has to be changed so it would be just another value to document in the comment)
On Wed, Dec 13, 2023 at 09:15:27PM +0100, Christian Marangi wrote: > On Wed, Dec 13, 2023 at 08:10:42PM +0000, Russell King (Oracle) wrote: > > NAK. > > > > You *clearly* didn't look before you leaped. > > > > On Wed, Dec 13, 2023 at 07:15:53PM +0100, Christian Marangi wrote: > > > +enum ethtool_link_speeds { > > > + SPEED_10 = 0, > > > + SPEED_100, > > > + SPEED_1000, > > ... > > > > and from the context immediately below, included in your patch: > > > #define SPEED_10 10 > > ^^^^^^^^ > > > #define SPEED_100 100 > > ^^^^^^^^^ > > > #define SPEED_1000 1000 > > ^^^^^^^^^^ > > > > Your enumerated values will be overridden by the preprocessor > > definitions. > > > > Moreover, SPEED_xxx is an already taken namespace and part of the UAPI, > > and thus can _not_ be changed. Convention is that SPEED_x will be > > defined as the numeric speed. > > > > Well yes that is the idea of having the enum to count them and then redefining > them to the correct value. (wasn't trying to introduce new define for > the speed and trying to assign incremental values) > > Any idea how to handle this without the enum - redefine thing? > > Was trying to find a more automated way than defining the raw number of > the current modes. (but maybe this is not that bad? since on adding more > modes, other values has to be changed so it would be just another value > to document in the comment) I think my comment on patch 2 gives some ideas! :D
Hi Christian, kernel test robot noticed the following build errors: [auto build test ERROR on net-next/main] url: https://github.com/intel-lab-lkp/linux/commits/Christian-Marangi/net-ethtool-add-define-for-link-speed-mode-number/20231214-021806 base: net-next/main patch link: https://lore.kernel.org/r/20231213181554.4741-2-ansuelsmth%40gmail.com patch subject: [net-next PATCH 1/2] net: ethtool: add define for link speed mode number config: x86_64-kexec (https://download.01.org/0day-ci/archive/20231214/202312141531.bEtUmIwG-lkp@intel.com/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231214/202312141531.bEtUmIwG-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202312141531.bEtUmIwG-lkp@intel.com/ All errors (new ones prefixed by >>): In file included from drivers/net/ethernet/intel/igb/e1000_hw.h:13, from drivers/net/ethernet/intel/igb/e1000_mac.h:7, from drivers/net/ethernet/intel/igb/e1000_82575.c:14: >> drivers/net/ethernet/intel/igb/e1000_defines.h:256:21: error: expected identifier before numeric constant 256 | #define SPEED_10 10 | ^~ include/uapi/linux/ethtool.h:1888:9: note: in expansion of macro 'SPEED_10' 1888 | SPEED_10 = 0, | ^~~~~~~~ -- In file included from drivers/net/ethernet/intel/igc/igc_hw.h:12, from drivers/net/ethernet/intel/igc/igc_base.c:6: >> drivers/net/ethernet/intel/igc/igc_defines.h:231:33: error: expected identifier before numeric constant 231 | #define SPEED_10 10 | ^~ include/uapi/linux/ethtool.h:1888:9: note: in expansion of macro 'SPEED_10' 1888 | SPEED_10 = 0, | ^~~~~~~~ vim +256 drivers/net/ethernet/intel/igb/e1000_defines.h 9d5c824399dea8 drivers/net/igb/e1000_defines.h Auke Kok 2008-01-24 255 9d5c824399dea8 drivers/net/igb/e1000_defines.h Auke Kok 2008-01-24 @256 #define SPEED_10 10 9d5c824399dea8 drivers/net/igb/e1000_defines.h Auke Kok 2008-01-24 257 #define SPEED_100 100 9d5c824399dea8 drivers/net/igb/e1000_defines.h Auke Kok 2008-01-24 258 #define SPEED_1000 1000 ceb5f13b70cd6e drivers/net/ethernet/intel/igb/e1000_defines.h Carolyn Wyborny 2013-04-18 259 #define SPEED_2500 2500 9d5c824399dea8 drivers/net/igb/e1000_defines.h Auke Kok 2008-01-24 260 #define HALF_DUPLEX 1 9d5c824399dea8 drivers/net/igb/e1000_defines.h Auke Kok 2008-01-24 261 #define FULL_DUPLEX 2 9d5c824399dea8 drivers/net/igb/e1000_defines.h Auke Kok 2008-01-24 262 9d5c824399dea8 drivers/net/igb/e1000_defines.h Auke Kok 2008-01-24 263
diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h index f7fba0dc87e5..59f394a663ab 100644 --- a/include/uapi/linux/ethtool.h +++ b/include/uapi/linux/ethtool.h @@ -1884,6 +1884,28 @@ enum ethtool_link_mode_bit_indices { * Update drivers/net/phy/phy.c:phy_speed_to_str() and * drivers/net/bonding/bond_3ad.c:__get_link_speed() when adding new values. */ +enum ethtool_link_speeds { + SPEED_10 = 0, + SPEED_100, + SPEED_1000, + SPEED_2500, + SPEED_5000, + SPEED_10000, + SPEED_14000, + SPEED_20000, + SPEED_25000, + SPEED_40000, + SPEED_50000, + SPEED_56000, + SPEED_100000, + SPEED_200000, + SPEED_400000, + SPEED_800000, + + /* must be last entry */ + __LINK_SPEEDS_NUM, +}; + #define SPEED_10 10 #define SPEED_100 100 #define SPEED_1000 1000