All of lore.kernel.org
 help / color / mirror / Atom feed
From: Josua Mayer <josua@solid-run.com>
To: "Russell King (Oracle)" <linux@armlinux.org.uk>
Cc: netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Rob Herring <robh+dt@kernel.org>, Andrew Lunn <andrew@lunn.ch>,
	Heiner Kallweit <hkallweit1@gmail.com>
Subject: Re: [PATCH RFC] net: sfp: support assigning status LEDs to SFP connectors
Date: Tue, 10 May 2022 12:44:41 +0300	[thread overview]
Message-ID: <bc461bd4-e123-212d-42a5-2da2efb7235a@solid-run.com> (raw)
In-Reply-To: <Ynk5UPWkuoXeqfJj@shell.armlinux.org.uk>

Hi Russell,

Am 09.05.22 um 18:54 schrieb Russell King (Oracle):
> On Mon, May 09, 2022 at 03:29:38PM +0300, Josua Mayer wrote:
>> Dear Maintainers,
>>
>> I am working on a new device based on the LX2160A platform, that exposes
>> 16 sfp connectors, each with its own led controlled by gpios intended
>> to show link status.
>> This patch intends to illustrate in code what we want to achieve,
>> so that I can better ask you all:
>> How can this work with the generic led framework, and how was it meant to work?
>>
>> The paragraphs below are a discussion of paths I have explored without success.
>> Please let me know if you have any opinions and ideas.
>>
>> Describing in device-tree that an led node belongs to a particular network
>> device (dpmac) however seems impossible. Instead the standard appears to work
>> through triggers, where in device-tree one only annotates that the led should
>> show a trigger "netdev" or "phy". Both of these make no sense when multiple
>> network interfaces exist - raising the first question:
>> How can device-tree indicate that an individual led should show the events of
>> a particular network interface?
>>
>> We have found that there is a way in sysfs to echo the name of the network
>> device to the api of the led driver, and it will start showing link status.
>> However this has to be done at runtime by the user.
>> But network interface names are unstable. They depend on probe order and
>> can be changed at will. Further they can be moved to different namespaces,
>> which will allow e.g. two instances of "eth0" to coexist.
>> On the Layerscape platform in particular these devices are created dynamically
>> by the networkign coprocessor, which supports complex functions such as
>> creating one network interface that spans multiple ports.
>> It seems to me that the netdev trigger therefore can not properly reflect
>> the relation between an LED (which is hard-wired to an sfp cage), and the
>> link state reported by e.g. a phy inside an sfp module.
>>
>> There exists also a phy trigger for leds.
>> When invoking the phy_attach or phy_connect functions from the generic phy
>> framework to connect an instance of net_device with an instance of phy_device,
>> a trigger providing the link and speed events is registered.
>> You may notice that again leds are tied to existence of a particular logical
>> network interface, which may or may not exist, and may span multiple
>> physical interfaces in case of layerscape.
>> This is a dead end though, simply because the dpaa2 driver does not even use
>> objects of phy_device, so this registering of triggers never happens.
>>
>> In addition the dpmac nodes in device-tree don't really have a phy modeled.
>> One end are the serdes which are managed by the networking coprocessor.
>> The other end has removable sfp modules, which may or may not contain a phy.
>>
>> The serdes are modeled as phy in device-tree though, perhaps the dpaa2 driver
>> could be extended to instantiate phy_device objects for the serdes?
>> However I feel like this would especially not solve when mutliple physical
>> ports are used as one logical interface.
>>
>> It seems to me that there should be a way to explicitly link gpio-driven LEDs to
>> either specific phy nodes, or specific sfp connectors - and have them receive
>> link events from the respective phy, fully independent even from whether there
>> is a logical network interface.
>>
>> If you got here, thank you very much for reading!
>> Ay comments?
> You really don't need any of this.
>
> We already have the "netdev" trigger - you just need to assign the LED
> to the appropriate netdev link.
Yes, that is what we are doing at runtime now:
echo eth12 > /sys/class/leds/led_c1_at/device_name

I feared though (without testing) that this might break when interfaces 
are moved between namespaces, or renamed.
And it seemed wrong requiring the user to do explicitly make this 
assignment, when the purpose is very much fixed once you put a case 
around it and add some labels.

> I do this on the SolidSense platform with the two LEDs when using it as
> my internet gateway on the boat - one LED gives wlan status, the other
> LED gives wwan status, both of them green for link and red for tx/rx
> activity.
Ah. And do you put the assignment of the LEDs into an init script?
> Exactly the same can be done with SFPs if the net device is exclusive
> to the SFP socket.
One issue is that the interfaces don't have stable names. It purely 
depends on probe order,
which is controlled by sending commands to the networking coprocessor.

We actually get asked this question sometimes how to have stable device 
names, and so far the answer has been systemd services with explicit 
sleep to force the order.
But this is a different topic.

> Doing it this way also tells you that the netdev
> link is up, not just that a SFP has decided to deassert the RXLOS
> signals, which on some SFPs is tied inactive.
Good point, I have already noticed inconsistencies in this regard.
The information provided by the netdev trigger does seem superior.

We will try to adopt a solution based on what Andrew pointed me to, as 
that one appears to be a good way to describe this relationship between 
LEDs and MACs (by extension eth[0-9]+ interfaces).

> Thanks.

Thank you for your comments!

sincerely
Josua Mayer


  reply	other threads:[~2022-05-10  9:44 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-09 12:29 [PATCH RFC] net: sfp: support assigning status LEDs to SFP connectors Josua Mayer
2022-05-09 12:49 ` Andrew Lunn
2022-05-10  8:56   ` Josua Mayer
2022-05-10 12:13     ` Andrew Lunn
2022-05-11 10:26       ` Russell King (Oracle)
2022-05-11 14:48         ` Ioana Ciornei
2022-05-11 10:12     ` Russell King (Oracle)
2022-05-11 15:48     ` Ioana Ciornei
2022-05-18  7:42       ` Josua Mayer
2022-05-09 15:54 ` Russell King (Oracle)
2022-05-10  9:44   ` Josua Mayer [this message]
2022-05-11 10:21     ` Russell King (Oracle)
2022-05-11 13:22     ` Ioana Ciornei
2022-05-11 13:39       ` Russell King (Oracle)
2022-06-01 10:18         ` Josua Mayer
2022-06-01 10:52           ` Russell King (Oracle)

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=bc461bd4-e123-212d-42a5-2da2efb7235a@solid-run.com \
    --to=josua@solid-run.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.