* [PATCH] net: rocker: Change netdev names to include slot number
@ 2015-02-02 6:03 David Ahern
2015-02-02 21:33 ` Scott Feldman
0 siblings, 1 reply; 10+ messages in thread
From: David Ahern @ 2015-02-02 6:03 UTC (permalink / raw)
To: netdev; +Cc: sfeldma, 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.
Signed-off-by: David Ahern <dsahern@gmail.com>
---
drivers/net/ethernet/rocker/rocker.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/rocker/rocker.c b/drivers/net/ethernet/rocker/rocker.c
index 11f4ffcc113d..1d1cf84e6f47 100644
--- a/drivers/net/ethernet/rocker/rocker.c
+++ b/drivers/net/ethernet/rocker/rocker.c
@@ -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);
--
1.9.3 (Apple Git-50)
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] net: rocker: Change netdev names to include slot number
2015-02-02 6:03 [PATCH] net: rocker: Change netdev names to include slot number David Ahern
@ 2015-02-02 21:33 ` Scott Feldman
2015-02-02 21:41 ` David Ahern
2015-02-02 22:15 ` David Miller
0 siblings, 2 replies; 10+ messages in thread
From: Scott Feldman @ 2015-02-02 21:33 UTC (permalink / raw)
To: David Ahern; +Cc: Netdev
On Sun, Feb 1, 2015 at 10:03 PM, David Ahern <dsahern@gmail.com> wrote:
> 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.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] net: rocker: Change netdev names to include slot number
2015-02-02 21:33 ` Scott Feldman
@ 2015-02-02 21:41 ` David Ahern
2015-02-02 22:03 ` Florian Fainelli
2015-02-02 22:16 ` David Miller
2015-02-02 22:15 ` David Miller
1 sibling, 2 replies; 10+ messages in thread
From: David Ahern @ 2015-02-02 21:41 UTC (permalink / raw)
To: Scott Feldman; +Cc: Netdev
On 2/2/15 2:33 PM, Scott Feldman wrote:
> On Sun, Feb 1, 2015 at 10:03 PM, David Ahern <dsahern@gmail.com> wrote:
>> 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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] net: rocker: Change netdev names to include slot number
2015-02-02 21:41 ` David Ahern
@ 2015-02-02 22:03 ` Florian Fainelli
2015-02-02 22:09 ` David Ahern
2015-02-02 22:16 ` David Miller
1 sibling, 1 reply; 10+ messages in thread
From: Florian Fainelli @ 2015-02-02 22:03 UTC (permalink / raw)
To: David Ahern, Scott Feldman; +Cc: Netdev
On 02/02/15 13:41, David Ahern wrote:
> On 2/2/15 2:33 PM, Scott Feldman wrote:
>> On Sun, Feb 1, 2015 at 10:03 PM, David Ahern <dsahern@gmail.com> wrote:
>>> 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.
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.
>
> David
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Florian
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] net: rocker: Change netdev names to include slot number
2015-02-02 22:03 ` Florian Fainelli
@ 2015-02-02 22:09 ` David Ahern
2015-02-03 5:46 ` Scott Feldman
2015-02-03 7:33 ` Rosen, Rami
0 siblings, 2 replies; 10+ messages in thread
From: David Ahern @ 2015-02-02 22:09 UTC (permalink / raw)
To: Florian Fainelli, Scott Feldman; +Cc: Netdev
On 2/2/15 3:03 PM, Florian Fainelli wrote:
> 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.
[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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] net: rocker: Change netdev names to include slot number
2015-02-02 21:33 ` Scott Feldman
2015-02-02 21:41 ` David Ahern
@ 2015-02-02 22:15 ` David Miller
1 sibling, 0 replies; 10+ messages in thread
From: David Miller @ 2015-02-02 22:15 UTC (permalink / raw)
To: sfeldma; +Cc: dsahern, netdev
From: Scott Feldman <sfeldma@gmail.com>
Date: Mon, 2 Feb 2015 13:33:08 -0800
> On Sun, Feb 1, 2015 at 10:03 PM, David Ahern <dsahern@gmail.com> wrote:
>> 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.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] net: rocker: Change netdev names to include slot number
2015-02-02 21:41 ` David Ahern
2015-02-02 22:03 ` Florian Fainelli
@ 2015-02-02 22:16 ` David Miller
1 sibling, 0 replies; 10+ messages in thread
From: David Miller @ 2015-02-02 22:16 UTC (permalink / raw)
To: dsahern; +Cc: sfeldma, netdev
From: David Ahern <dsahern@gmail.com>
Date: Mon, 02 Feb 2015 14:41:52 -0700
> On 2/2/15 2:33 PM, Scott Feldman wrote:
>> On Sun, Feb 1, 2015 at 10:03 PM, David Ahern <dsahern@gmail.com>
>> wrote:
>>> 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.
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.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] net: rocker: Change netdev names to include slot number
2015-02-02 22:09 ` David Ahern
@ 2015-02-03 5:46 ` Scott Feldman
2015-02-03 16:06 ` David Ahern
2015-02-03 7:33 ` Rosen, Rami
1 sibling, 1 reply; 10+ messages in thread
From: Scott Feldman @ 2015-02-03 5:46 UTC (permalink / raw)
To: David Ahern; +Cc: Florian Fainelli, Netdev
On Mon, Feb 2, 2015 at 2:09 PM, David Ahern <dsahern@gmail.com> wrote:
> On 2/2/15 3:03 PM, Florian Fainelli wrote:
>>
>> 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.
>
>
> [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.
>
> But in general I guess need to find time to figure out systemd-udev files.
>
> David
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [PATCH] net: rocker: Change netdev names to include slot number
2015-02-02 22:09 ` David Ahern
2015-02-03 5:46 ` Scott Feldman
@ 2015-02-03 7:33 ` Rosen, Rami
1 sibling, 0 replies; 10+ messages in thread
From: Rosen, Rami @ 2015-02-03 7:33 UTC (permalink / raw)
To: David Ahern, Florian Fainelli, Scott Feldman; +Cc: Netdev
Hi,
>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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] net: rocker: Change netdev names to include slot number
2015-02-03 5:46 ` Scott Feldman
@ 2015-02-03 16:06 ` David Ahern
0 siblings, 0 replies; 10+ messages in thread
From: David Ahern @ 2015-02-03 16:06 UTC (permalink / raw)
To: Scott Feldman; +Cc: Florian Fainelli, Netdev
On 2/2/15 10:46 PM, Scott Feldman wrote:
>> [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
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.
> 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.
>
> 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
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2015-02-03 16:06 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-02 6:03 [PATCH] net: rocker: Change netdev names to include slot number David Ahern
2015-02-02 21:33 ` Scott Feldman
2015-02-02 21:41 ` David Ahern
2015-02-02 22:03 ` Florian Fainelli
2015-02-02 22:09 ` David Ahern
2015-02-03 5:46 ` Scott Feldman
2015-02-03 16:06 ` David Ahern
2015-02-03 7:33 ` Rosen, Rami
2015-02-02 22:16 ` David Miller
2015-02-02 22:15 ` David Miller
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).