Re: [PATCH net-next 5/5] igc: Export LEDs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Am 2021-07-27 17:28, schrieb Marek Behún:
On Tue, 27 Jul 2021 17:03:53 +0200
Michael Walle <michael@xxxxxxxx> wrote:

I wasn't talking about ethN being same as the network interface name.
For clarity I'll use ethernetN now. My question was why would you
use ethmacN or ethphyN instead if just ethernetN for both. What is
the reason for having two different names? I'm not sure who is using
that name anyway. If it is for an user, I don't think he is interested
in knowing wether that LED is controlled by the PHY or by the MAC.

Suppose that the system has 2 ethernet MACs, each with an attached PHY.
Each MAC-PHY pair has one LED, but one MAC-PHY pair has the LED
attached to the MAC, and the second pair has the LED attached to the
PHY:
     +------+        +------+
     | macA |        | macB |
     +-+--+-+        +-+----+
       |  |            |
      /   +------+   +-+----+
   ledA   | phyA |   | phyB |
          +------+   +----+-+
                          |
                           \
                            ledB

Now suppose that during system initialization the system enumerates
MACs and PHYs in different order:
   macA -> 0      phyA -> 1
   macB -> 1      phyB -> 0

If we used the devicename as you are suggesting, then for the two LEDs
the devicename part would be the same:
  ledA -> macA -> ethernet0
  ledB -> phyB -> ethernet0
although they are clearly on different MACs.

Why is that the case? Why can't both the MAC and the PHY request a unique
name from the same namespace? As Andrew pointed out, the names in
/sys/class/leds don't really matter. Ok, it will still depend on the
probe order which might not be the case if you split it between ethmac
and ethphy.

Sorry, if I may ask stupid questions here. I don't want to cause much
trouble, here. I was just wondering why we have to make up two different
(totally unrelated names to the network interface names) instead of just
one (again totally unrelated to the interface name and index).

We could create a simple atomically increasing index only for MACs, and
for a LED connected to a PHY, instead of using the PHY's index, we
would look at the attached MAC and use the MAC index.

Oh, I see. I was assuming we are talking about "just a number" not
related to anything.

The problem is that PHYs and MACs are not always attached, and are not
necessarily mapped 1-to-1. It is possible to have a board where one PHY
can connect to 2 different MACs and you can switch between them, and
also vice versa.

> So it can for example happen that within a network namespace you
> have only one interface, eth0, but in /sys/class/leds you would see
>   eth0:green:activity
>   eth1:green:activity
> So you would know that there are at least 2 network interfaces on the
> system, and also with renaming it can happen that the first LED is not
> in fact connected to the eth0 interface in your network namespace.

But the first problem persists wether its named ethernetN or ethphyN,
no?

No. The N in the "ethphyN" for etherent PHYs is supposed to be unrelated
to the N in "ethN" for interface names. So if you have eth0 network
interface with attached phy ethphy0, this is a coincidence. (That is
why Andrew is proposing to start the index for PHYs at a different
number, like 42.)

Yes, in my case ethernet0 has nothing to do with eth0, either.

But I was actually referring to your "you see the leds in /sys/ of all
the network adapters". That problem still persists, right?

-michael



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux