Message ID | 20231213181554.4741-1-ansuelsmth@gmail.com |
---|---|
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 c4csp7973370dys; Wed, 13 Dec 2023 10:16:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IH5s2JkdCqqtxNyeUSMUuUp53glErtBbBhebpz2yp1ADizEfsJtXbVSUq8ZS2h2C1jXOoWF X-Received: by 2002:a17:902:d510:b0:1d3:5701:3761 with SMTP id b16-20020a170902d51000b001d357013761mr692418plg.111.1702491373643; Wed, 13 Dec 2023 10:16:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702491373; cv=none; d=google.com; s=arc-20160816; b=nahHOKMFyQaEDnFFRVSVQpZ2kdZHRbxc4U7kHBwNcS2BmfRAq3jRxdN3MQw/hx7hZN +6aThHrG8V+s19qgcTvtcPMuOmw/x7QYIvZeysrBx+nVUhJGQyZoAFwPh5ZLEyVkYk1i xyo0t0wbx0cPH4Jqk7/5gGUmTaiYJmzZkKkLEh2FML3XoCcqc6XsKwTfM2K7vh1hwAjz Lws65z4/ltWrqUXD+bG0+qbXpTyVmv1pDSZFgn/2cNhm9qVaV7m94iznD5Pl3FaYI/Sx NZgqrOD+Wvlkep3DfNDCnERmPw/dIZtDzD1h2S5BxkJC7Ixn9yXOR3kb73o8hk1HHcXU aQAQ== 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 :message-id:date:subject:to:from:dkim-signature; bh=nGFsEcnLWfQskkH/HBBeriUIEXqAgKL8+Y/z39zis/U=; fh=p6UE9/XeFdVcez2P5EpH3VpeppOo7ov8vHzRKEaMwWo=; b=CRzQlUSyk+eMPDlyJmilCxcnv1RGhdip8d5ldyeszxbRMbm93qIkBEzx6gQByG99uQ BA7BgIcH7+4M7pfiGe/TTlftWRVQhGsQI8rRWbai/hfdGDenJRhaQAc9N2pJouR4MPlk rrrKwmwGTQDKX7LpTAlzF3JBtCWZseW8G0HhGlJ8xg3Hmh48OyFJw+02rLfPtp29aisX bOJgmmC/5uf0fmz79Xz8SD2vsaiNSriDRqhYuyzuPd1ScJDGG9UQawNJHhJWe9s6riPR nGBBRR8T4pdSQ7SkyzAEpfi6fZoN7vdUF9tHBHP4xn62T2FGJuVwwQ3xZ6bUOnUusHfz N+7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=DQm3jOX0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id p18-20020a170902e75200b001bf0b29d935si9252455plf.34.2023.12.13.10.16.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 10:16:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=DQm3jOX0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 45649802E5FF; Wed, 13 Dec 2023 10:16:12 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232163AbjLMSP7 (ORCPT <rfc822;dexuan.linux@gmail.com> + 99 others); Wed, 13 Dec 2023 13:15:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233759AbjLMSPz (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 13 Dec 2023 13:15:55 -0500 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79FB0A7; Wed, 13 Dec 2023 10:16:01 -0800 (PST) Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-3360ae1b937so3694103f8f.0; Wed, 13 Dec 2023 10:16:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702491360; x=1703096160; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=nGFsEcnLWfQskkH/HBBeriUIEXqAgKL8+Y/z39zis/U=; b=DQm3jOX0GiWYveROu/pugi10THtutEEKijcAPXCm/kHQbFecwsOAigGNC/A2apCgrH c1YCdR67c1XK6L9FR8Nvi63hSf0OzNV9rU2Tvf1mAoN59FaRzZc+1ksInJ83geLH1S6T XxHFGGuLGQDzysh5PwTtpxOEIAUHbroBPa3H+vSw+GKyzRa1Huwiw+OWeaOS3qGsC863 bHIZTjHmB6ILAIgmwEUjzWsNgz+0yFtsdRO9iU6XzN/xwU51GbkRbVoNuqoJuhTerAIP EjIWqiPFQ8Ic7XAeHyC97fSXcGKFWHoMNF7TpDG0pRYIyfKMcdvRP3ZHyjLNcxfBR8UW SLWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702491360; x=1703096160; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=nGFsEcnLWfQskkH/HBBeriUIEXqAgKL8+Y/z39zis/U=; b=iEKoYW2j/EdYgOQ2HDfNUcd2XyOuhwuvgcFs2Rv0xmey2oqLvkjiOU9OR7sjiX3w2W 695v1xynill2XsLhhqA919m49EOkw53vh/oT51BSP829cq+XrS6c+vlSvVXz13sAWq// 3EoMTyIB4BEz/8FPZl/Wz6p1gvO1IJJjbmBMO203v+p3wdb+mLL6ASHKF7xpySywtSrI 8abk0JTSQUFHnjpvnxn0xrPz/YV+nNh72qJPcFyTuEoYKtZhg9bOBqL4wi5itG/M+MQU USHMFpsxznJfIzYgWPAOck8hJARc+LWI8S7S1UL/lzh/Gn96a3ZKj2GhlwN2VvJJj3Wg FowQ== X-Gm-Message-State: AOJu0YzsHIJqAT90rjeI28dOGItfsgmNhk7pfozFbjy/x6SpJTgTQNBO XE2GuhvpqXX6OmoiWXCsp7c= X-Received: by 2002:a5d:6611:0:b0:333:179:d8df with SMTP id n17-20020a5d6611000000b003330179d8dfmr4457400wru.26.1702491359661; Wed, 13 Dec 2023 10:15:59 -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.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 10:15:59 -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 0/2] net: add define to describe link speed modes Date: Wed, 13 Dec 2023 19:15:52 +0100 Message-Id: <20231213181554.4741-1-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Wed, 13 Dec 2023 10:16:12 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785191594757177439 X-GMAIL-MSGID: 1785191594757177439 |
Series |
net: add define to describe link speed modes
|
|
Message
Christian Marangi
Dec. 13, 2023, 6:15 p.m. UTC
This is a simple series to add define to describe link speed modes. Hope the proposed way is acceptable with the enum and define. This is also needed in the upcoming changes in the netdev trigger for LEDs where phy_speeds functions is used to declare a more compact array instead of using a "big enough" approach. Christian Marangi (2): net: ethtool: add define for link speed mode number net: phy: leds: use new define for link speed modes number drivers/net/phy/phy_led_triggers.c | 2 +- include/uapi/linux/ethtool.h | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-)
Comments
On Wed, Dec 13, 2023 at 07:15:52PM +0100, Christian Marangi wrote: > This is a simple series to add define to describe link speed modes. > > Hope the proposed way is acceptable with the enum and define. > > This is also needed in the upcoming changes in the netdev trigger for LEDs > where phy_speeds functions is used to declare a more compact array instead > of using a "big enough" approach. I'm trying to figure out the 'big picture' here. The LED trigger will call ksetting_get to get a list of supported link modes. You can then use the table struct phy_setting settings[] in phy-core.c to translate the link mode to a speed. You are likely to get a lot of duplicate speeds, but you can remove them. For each speed you need to create a sysfs file. Why not just create a linked list, rather than an array? Or just walk the table and find out how many different speeds there are and allocate an array of that size. Its currently 15, which is not that big. And then just use the is_visible method to hide the ones which are not relevant. I don't see any need for new enums or tables here, just a function to look up a link mode in that table and return the speed. Andrew
On Thu, Dec 14, 2023 at 12:05:52AM +0100, Andrew Lunn wrote: > On Wed, Dec 13, 2023 at 07:15:52PM +0100, Christian Marangi wrote: > > This is a simple series to add define to describe link speed modes. > > > > Hope the proposed way is acceptable with the enum and define. > > > > This is also needed in the upcoming changes in the netdev trigger for LEDs > > where phy_speeds functions is used to declare a more compact array instead > > of using a "big enough" approach. > > I'm trying to figure out the 'big picture' here. > > The LED trigger will call ksetting_get to get a list of supported link > modes. You can then use the table struct phy_setting settings[] in > phy-core.c to translate the link mode to a speed. You are likely to > get a lot of duplicate speeds, but you can remove them. For each speed > you need to create a sysfs file. Why not just create a linked list, > rather than an array? Or just walk the table and find out how many > different speeds there are and allocate an array of that size. Its > currently 15, which is not that big. And then just use the is_visible > method to hide the ones which are not relevant. > > I don't see any need for new enums or tables here, just a function to > look up a link mode in that table and return the speed. > The big picture was to have an handy define and statically allocate the array with the max amount of link modes possible without having to allocate kernel memory at runtime. With the current way of allocating only the needed space, I have to parse the settings table 2 times (one to get the number and the second time to compose the actual array) Not a problem since these are called only on LED register or when the device name is called... Just extra code and the fact that kmalloc can fail with ENOMEM. (but that is almost imposible and would be in an OOM condition)