IB/ipoib: Use dev_port to disambiguate port numbers
Subsystems (3)
cover IB/ipoib: Use dev_port to disambiguate port numbers
Pre-3.15 userspace had trouble distinguishing different ports of a NIC on a single PCI bus/device/function. To solve this, a sysfs field `dev_port' was introduced quite a while ago (commit v3.14-rc3-739-g3f85944fe207), and some relevant device drivers were fixed to use it, but not in case of IPoIB.
The convention for some reason never got documented in the kernel, but was immediately adopted by userspace (notably udev[1][2], biosdevname[3])
3/3 documents the sysfs field — that's why I'm CC-ing netdev.
This series was tested on and applies to 4.19-rc1.
[1] https://lists.freedesktop.org/archives/systemd-devel/2014-June/020788.html
[2] https://lists.freedesktop.org/archives/systemd-devel/2014-July/020804.html
[3] https://github.com/CloudAutomationNTools/biosdevname/blob/c795d51dd93a5309652f0d635f12a3ecfabfaa72/src/eths.c#L38
Arseny Maslennikov (3):
IB/ipoib: Use dev_port to expose network interface port numbers IB/ipoib: Stop using dev_id to expose port numbers Documentation/ABI: document /sys/class/net/*/dev_port
Documentation/ABI/testing/sysfs-class-net | 10 ++++++++++ drivers/infiniband/ulp/ipoib/ipoib_main.c | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-)
Signature · 1 line
2.18.0
PATCH 1/3 IB/ipoib: Use dev_port to expose network interface port numbers
Some InfiniBand network devices have multiple ports on the same PCI function. This initializes the `dev_port' sysfs field of those network interfaces with their port number.
The use of dev_id' was considered correct until Linux 3.15, when another field, dev_port', was defined for this particular purpose and `dev_id' was reserved for distinguishing stacked ifaces (e.g: VLANs) with the same hardware address as their parent device.
Similar fixes to net/mlx4_en and many other drivers, which started exporting this information through `dev_id' before 3.15, were accepted into the kernel 4 years ago.
See 76a066f2a2a0268b565459c417b59724b5a3197b, commit message:
`net/mlx4_en: Expose port number through sysfs'.
--- drivers/infiniband/ulp/ipoib/ipoib_main.c | 1 + 1 file changed, 1 insertion(+)
drivers/infiniband/ulp/ipoib/ipoib_main.c +1 -0
@@ -1881,6 +1881,7 @@ static int ipoib_parent_init(struct net_device *ndev)SET_NETDEV_DEV (priv->dev, priv->ca->dev.parent); priv->dev->dev_id = priv->port -1 ; + priv->dev->dev_port = priv->port -1 ;return 0 ; }
Signature · 1 line
2.18.0
PATCH 2/3 IB/ipoib: Stop using dev_id to expose port numbers
In reply to Arseny MaslennikovSome InfiniBand network devices have multiple ports on the same PCI function. Prior to this the kernel erroneously used the `dev_id' sysfs field of those network interfaces to convey the port number to userspace.
`dev_id' is currently reserved for distinguishing stacked ifaces (e.g: VLANs) with the same hardware address as their parent device.
Similar fixes to net/mlx4_en and many other drivers, which started exporting this information through `dev_id' before 3.15, were accepted into the kernel 4 years ago.
See 76a066f2a2a0268b565459c417b59724b5a3197b, commit message:
`net/mlx4_en: Expose port number through sysfs'.
This commit is separated from the previous one since we may wish to preserve backwards compatibility with userspace being already dependent on `dev_id' being different.
--- drivers/infiniband/ulp/ipoib/ipoib_main.c | 1 - 1 file changed, 1 deletion(-)
drivers/infiniband/ulp/ipoib/ipoib_main.c +0 -1
@@ -1880,7 +1880,6 @@ static int ipoib_parent_init(struct net_device *ndev) sizeof(union ib_gid));SET_NETDEV_DEV (priv->dev, priv->ca->dev.parent); - priv->dev->dev_id = priv->port -1 ; priv->dev->dev_port = priv->port -1 ;return 0 ;
Signature · 1 line
2.18.0
Re: [PATCH 2/3] IB/ipoib: Stop using dev_id to expose port numbers
Hello!
Quoted 4 lines · Arseny Maslennikov
Some InfiniBand network devices have multiple ports on the same PCI function. Prior to this the kernel erroneously used the `dev_id' sysfs field of those network interfaces to convey the port number to userspace.
Quoted 8 lines
`dev_id' is currently reserved for distinguishing stacked ifaces (e.g: VLANs) with the same hardware address as their parent device.
Similar fixes to
net/mlx4_enand many other drivers, which started exporting this information through `dev_id' before 3.15, were accepted into the kernel 4 years ago.
See76a066f2a2a0268b565459c417b59724b5a3197b, commit message:
`net/mlx4_en: Expose port number through sysfs'.
See commit 76a066f2a2a0 ("net/mlx4_en: Expose port number through sysfs").
Quoted 5 lines
This commit is separated from the previous one since we may wish to preserve backwards compatibility with userspace being already dependent on `dev_id' being different.
Signed-off-by Arseny Maslennikov <[email protected]>
[...]
MBR, Sergei
PATCH 3/3 Documentation/ABI: document /sys/class/net/*/dev_port
In reply to Arseny MaslennikovThe sysfs field was introduced 4 years ago along with fixes to various drivers that erroneously used `dev_id' for that purpose, but it was not properly documented anywhere.
See commit v3.14-rc3-739-g3f85944fe207.
--- Documentation/ABI/testing/sysfs-class-net | 10 ++++++++++ 1 file changed, 10 insertions(+)
Documentation/ABI/testing/sysfs-class-net +10 -0
@@ -91,6 +91,16 @@ Description: stacked (e.g: VLAN interfaces) but still have the same MAC address as their parent device. +What: /sys/class/net/<iface>/dev_port +Date: February 2014 +KernelVersion: 3.15 +Contact: [email protected] +Description: + Indicates the port number of this network device, formatted + as a decimal value. Some NICs have multiple independent ports + on the same PCI bus, device and function. This field allows + userspace to distinguish the respective interfaces. + What: /sys/class/net/<iface>/dormant Date: March 2006 KernelVersion: 2.6.17
Signature · 1 line
2.18.0
Quoted 13 lines · Arseny Maslennikov
Pre-3.15 userspace had trouble distinguishing different ports of a NIC on a single PCI bus/device/function. To solve this, a sysfs field `dev_port' was introduced quite a while ago (commit v3.14-rc3-739-g3f85944fe207), and some relevant device drivers were fixed to use it, but not in case of IPoIB.
The convention for some reason never got documented in the kernel, but was immediately adopted by userspace (notably udev[1][2], biosdevname[3])
3/3 documents the sysfs field — that's why I'm CC-ing netdev.
This series was tested on and applies to 4.19-rc1.
Quoted 7 lines
[1] https://lists.freedesktop.org/archives/systemd-devel/2014-June/020788.html
[2] https://lists.freedesktop.org/archives/systemd-devel/2014-July/020804.html
[3] https://github.com/CloudAutomationNTools/biosdevname/blob/c795d51dd93a5309652f0d635f12a3ecfabfaa72/src/eths.c#L38Arseny Maslennikov (3):
IB/ipoib: Usedev_portto expose network interface port numbers IB/ipoib: Stop usingdev_idto expose port numbers
I completely agree with previous Yuval's comment, it makes no sense to start separate commits for every line.
Please decide what is best and right behavior and do it, instead of pushing it up to be the maintainer's problem.
Thanks
Quoted 9 lines
Documentation/ABI: document/sys/class/net/*/dev_portDocumentation/ABI/testing/sysfs-class-net | 10 ++++++++++ drivers/infiniband/ulp/ipoib/ipoib_main.c | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-)--
2.18.0
Quoted 22 lines · Leon Romanovsky
Quoted 13 lines · Arseny Maslennikov
Pre-3.15 userspace had trouble distinguishing different ports of a NIC on a single PCI bus/device/function. To solve this, a sysfs field `dev_port' was introduced quite a while ago (commit v3.14-rc3-739-g3f85944fe207), and some relevant device drivers were fixed to use it, but not in case of IPoIB.
The convention for some reason never got documented in the kernel, but was immediately adopted by userspace (notably udev[1][2], biosdevname[3])
3/3 documents the sysfs field — that's why I'm CC-ing netdev.
This series was tested on and applies to 4.19-rc1.
Quoted 7 lines
[1] https://lists.freedesktop.org/archives/systemd-devel/2014-June/020788.html
[2] https://lists.freedesktop.org/archives/systemd-devel/2014-July/020804.html
[3] https://github.com/CloudAutomationNTools/biosdevname/blob/c795d51dd93a5309652f0d635f12a3ecfabfaa72/src/eths.c#L38Arseny Maslennikov (3):
IB/ipoib: Usedev_portto expose network interface port numbers IB/ipoib: Stop usingdev_idto expose port numbers
Quoted 6 lines
I completely agree with previous Yuval's comment, it makes no sense to start separate commits for every line.
Please decide what is best and right behavior and do it, instead of pushing it up to be the maintainer's problem.
No problem; will squash those two in v2, then.
Quoted 11 lines
Thanks
Quoted 9 lines
Documentation/ABI: document/sys/class/net/*/dev_portDocumentation/ABI/testing/sysfs-class-net | 10 ++++++++++ drivers/infiniband/ulp/ipoib/ipoib_main.c | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-)--
2.18.0