From: Christian Marangi <ansuelsmth@gmail.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: 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>,
Piergiorgio Beruto <piergiorgio.beruto@gmail.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [net-next PATCH 0/2] net: add define to describe link speed modes
Date: Thu, 14 Dec 2023 00:10:43 +0100 [thread overview]
Message-ID: <657a39f6.050a0220.50ffc.9232@mx.google.com> (raw)
In-Reply-To: <a4661402-414a-4b0d-82e8-97031fa46230@lunn.ch>
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)
--
Ansuel
prev parent reply other threads:[~2023-12-13 23:10 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-13 18:15 [net-next PATCH 0/2] net: add define to describe link speed modes Christian Marangi
2023-12-13 18:15 ` [net-next PATCH 1/2] net: ethtool: add define for link speed mode number Christian Marangi
2023-12-13 20:10 ` Russell King (Oracle)
2023-12-13 20:15 ` Christian Marangi
2023-12-13 20:23 ` Russell King (Oracle)
2023-12-14 7:35 ` kernel test robot
2023-12-13 18:15 ` [net-next PATCH 2/2] net: phy: leds: use new define for link speed modes number Christian Marangi
2023-12-13 20:18 ` Russell King (Oracle)
2023-12-13 20:34 ` Christian Marangi
2023-12-13 23:05 ` [net-next PATCH 0/2] net: add define to describe link speed modes Andrew Lunn
2023-12-13 23:10 ` Christian Marangi [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=657a39f6.050a0220.50ffc.9232@mx.google.com \
--to=ansuelsmth@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=keescook@chromium.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=mailhol.vincent@wanadoo.fr \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=piergiorgio.beruto@gmail.com \
--cc=vladimir.oltean@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).