net: rocker: Change netdev names to include slot number
Subsystems (3)
PATCH 1/1 net: rocker: Change netdev names to include slot number
Currently, rocker devices are given eth%d names. If you have multiple rocker devices it is difficult to easily correlate eth%d names to a rocker device and port. Change the device name to sw + PCI slot number + p + id (sw%dp%d). This makes the device names easier to correlate. ie., Rather than eth0, ..., eth N (N = number of ports in device) the ports get netdev names like sw5p0, ..., sw5pN.
--- drivers/net/ethernet/rocker/rocker.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/rocker/rocker.c +4 -1
@@ -4010,8 +4010,11 @@ static int rocker_probe_port(struct rocker *rocker, unsigned int port_number)struct rocker_port *rocker_port;struct net_device *dev;int err; +char str[IFNAMSIZ ]; - dev =alloc_etherdev (sizeof (struct rocker_port )); +snprintf (str,sizeof (str),"sw%dp%%d" , pdev->slot->number); + dev =alloc_netdev_mqs (sizeof (struct rocker_port ), + str,NET_NAME_UNKNOWN , ether_setup,1 ,1 );if (!dev)return -ENOMEM ; rocker_port =netdev_priv (dev);
Signature · 1 line
1.9.3 (Apple Git-50)
Quoted 6 lines · David Ahern
Currently, rocker devices are given eth%d names. If you have multiple rocker devices it is difficult to easily correlate eth%d names to a rocker device and port. Change the device name to sw + PCI slot number + p + id (sw%dp%d). This makes the device names easier to correlate. ie., Rather than eth0, ..., eth N (N = number of ports in device) the ports get netdev names like sw5p0, ..., sw5pN.
I think udev is the preferred tool for interface naming, rather than hard-coding interface names in the driver.
Quoted 11 lines · Scott Feldman
Quoted 6 lines · David Ahern
Currently, rocker devices are given eth%d names. If you have multiple rocker devices it is difficult to easily correlate eth%d names to a rocker device and port. Change the device name to sw + PCI slot number + p + id (sw%dp%d). This makes the device names easier to correlate. ie., Rather than eth0, ..., eth N (N = number of ports in device) the ports get netdev names like sw5p0, ..., sw5pN.
I think udev is the preferred tool for interface naming, rather than hard-coding interface names in the driver.
hmmm... What I am seeing right now is a race as to which devices are detected first -- rocker or virtio. On half of the boots the virtio are detected first and named eth0 and eth1. The other half of the boots virtio devices are detected last and become ethN+1 and ethN+2 (N=number of rocker ports) -- which makes it a PITA to script commands. AFAIK udev won't solve that problem.
David
Quoted 14 lines · David Ahern
Quoted 11 lines · Scott Feldman
Quoted 6 lines · David Ahern
Currently, rocker devices are given eth%d names. If you have multiple rocker devices it is difficult to easily correlate eth%d names to a rocker device and port. Change the device name to sw + PCI slot number + p + id (sw%dp%d). This makes the device names easier to correlate. ie., Rather than eth0, ..., eth N (N = number of ports in device) the ports get netdev names like sw5p0, ..., sw5pN.
I think udev is the preferred tool for interface naming, rather than hard-coding interface names in the driver.
Quoted 6 lines
hmmm... What I am seeing right now is a race as to which devices are detected first -- rocker or virtio. On half of the boots the virtio are detected first and named eth0 and eth1. The other half of the boots virtio devices are detected last and become ethN+1 and ethN+2 (N=number of rocker ports) -- which makes it a PITA to script commands. AFAIK udev won't solve that problem.
Why not? virtio and rocker interfaces are backed by different devices drivers which should allow you to use that to name interfaces differently. In the case of rocker, you would probably want to read the phys_port_id sysfs attribute to name them after their parent switch id too.
Quoted 6 lines
David
Signature · 3 lines
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 1 line
Florian
Quoted 4 lines · Florian Fainelli
Why not? virtio and rocker interfaces are backed by different devices drivers which should allow you to use that to name interfaces differently. In the case of rocker, you would probably want to read the
phys_port_idsysfs attribute to name them after their parent switch id too.
[root@f21 ~]# cat /sys/devices/virtual/net/sw5p0/phys_port_id
cat: /sys/devices/virtual/net/sw5p0/phys_port_id: Operation not supported
But in general I guess need to find time to figure out systemd-udev files.
David
David Miller
maintainerFrom: Scott Feldman <[email protected]>
Date: Mon, 2 Feb 2015 13:33:08 -0800
Quoted 10 lines · David Ahern
Quoted 6 lines
Currently, rocker devices are given eth%d names. If you have multiple rocker devices it is difficult to easily correlate eth%d names to a rocker device and port. Change the device name to sw + PCI slot number + p + id (sw%dp%d). This makes the device names easier to correlate. ie., Rather than eth0, ..., eth N (N = number of ports in device) the ports get netdev names like sw5p0, ..., sw5pN.
I think udev is the preferred tool for interface naming, rather than hard-coding interface names in the driver.
That's correct.
David Miller
maintainerFrom: David Ahern <[email protected]>
Date: Mon, 02 Feb 2015 14:41:52 -0700
Quoted 14 lines · Scott Feldman
Quoted 9 lines
Quoted 6 lines · David Ahern
Currently, rocker devices are given eth%d names. If you have multiple rocker devices it is difficult to easily correlate eth%d names to a rocker device and port. Change the device name to sw + PCI slot number + p + id (sw%dp%d). This makes the device names easier to correlate. ie., Rather than eth0, ..., eth N (N = number of ports in device) the ports get netdev names like sw5p0, ..., sw5pN.
Quoted 3 lines
I think udev is the preferred tool for interface naming, rather than hard-coding interface names in the driver.
Quoted 6 lines
hmmm... What I am seeing right now is a race as to which devices are detected first -- rocker or virtio. On half of the boots the virtio are detected first and named eth0 and eth1. The other half of the boots virtio devices are detected last and become ethN+1 and ethN+2 (N=number of rocker ports) -- which makes it a PITA to script commands. AFAIK udev won't solve that problem.
udev has already tackled this problem, it uses platform specific code to determine the physical geographic location of devices on the bus, and uses that to map device names.
Quoted 11 lines · David Ahern
Quoted 6 lines · Florian Fainelli
Why not? virtio and rocker interfaces are backed by different devices drivers which should allow you to use that to name interfaces differently. In the case of rocker, you would probably want to read the
phys_port_idsysfs attribute to name them after their parent switch id too.[root@f21 ~]# cat
/sys/devices/virtual/net/sw5p0/phys_port_id
cat:/sys/devices/virtual/net/sw5p0/phys_port_id: Operation not supported
We should implement .ndo_get_phys_port_id in rocker to return a unique name for the port, which can then be used in udev script to name interface. When rocker device is instantiated, a unique switch name is given on qemu cmd line, for example "sw1". Rocker device could return that string to the driver, or even combine that string with the port index to have "sw1p1". The second instantiated rocker device would give up "sw2px" port names.
A real switch with a physical port than can be split, or when multiple ports are ganged to form one mega port, letting the device pick a unique name is probably best. For example, splitting a single physical 40Gb port into 4 10Gb ports would present 4 kernel interfaces, but we probably want to use the base port in the naming, so we'd have something like "sw1p1s1" to mean switch 1, front panel port 1, split port 1. Letting the device name the ports on current port configuration of the port will keep driver/kernel simple, and let udev be the final name chooser.
Quoted 4 lines
But in general I guess need to find time to figure out systemd-udev files.
David
Hi,
Quoted 2 lines
root@f21 ~]# cat
/sys/devices/virtual/net/sw5p0/phys_port_id
cat:/sys/devices/virtual/net/sw5p0/phys_port_id: Operation not supported
Just a side note: commit aecbe01e7410 "net-sysfs: expose physical switch id for particular device" added support for this entry, relying on the fact that the ndo_switch_parent_id_get() is implemented (which seems to be a valid assumption for switch devices) and that the dev_isalive() condition is met.
Could it be that the reason for getting -EOPNOTSUPP was that the ndo_switch_parent_id_get() is not implemented in your switch device or that the condition was not met in your test?
Rami Rosen
Intel Corporation
Quoted 8 lines · Scott Feldman
Quoted 2 lines
[root@f21 ~]# cat
/sys/devices/virtual/net/sw5p0/phys_port_id
cat:/sys/devices/virtual/net/sw5p0/phys_port_id: Operation not supportedWe should implement .ndo_get_phys_port_id in rocker to return a unique name for the port, which can then be used in udev script to name interface. When rocker device is instantiated, a unique switch name is given on qemu cmd line, for example "sw1". Rocker device could return that string to the driver, or even combine that string with the
Right. That's what I went looking for at first and noticed that info is not pushed to the driver. And then I know at least one vendor puts the slot id in interface names which is the reason I went for the PCI slot id.
Quoted 2 lines
port index to have "sw1p1". The second instantiated rocker device would give up "sw2px" port names.
And yes, adding the port index to the above name -- though ideally starting at 1 and not 0.
Quoted 10 lines
A real switch with a physical port than can be split, or when multiple ports are ganged to form one mega port, letting the device pick a unique name is probably best. For example, splitting a single physical 40Gb port into 4 10Gb ports would present 4 kernel interfaces, but we probably want to use the base port in the naming, so we'd have something like "sw1p1s1" to mean switch 1, front panel port 1, split port 1. Letting the device name the ports on current port configuration of the port will keep driver/kernel simple, and let udev be the final name chooser.
Exactly. When you add in break out ports to the mix having sane, logical default names (without udev) makes life easier. That was my ultimate intent here - logical default names that udev or a user could then modify if so desired.
But anyways, since the request is to have udev do the naming I need to come back to it. A quick search on the systemd web site did not stumble onto examples I could use, so I need to put this on the back burner until I have time to dig through systemd docs.
David