* [net-next v1.5] mlx5_core: fall back to dev->board_id for shd id
@ 2026-03-25 22:11 Adam Young
2026-03-26 5:27 ` Jiri Pirko
0 siblings, 1 reply; 2+ messages in thread
From: Adam Young @ 2026-03-25 22:11 UTC (permalink / raw)
To: Saeed Mahameed, Leon Romanovsky, Tariq Toukan, Mark Bloch,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: netdev, linux-kernel
Making the devlink device shared requires an identifier
to uniquely related the netlink device and the physical
board. The original code used the serial number, requested
from the boards attributes. However, not all members of
the family of cards expose that attribute. The module init
will fail on these devices. As a fall back, the driver can
use the board_id, which is guaranteed to be present, and
which is unique for every board in a deployment.
Signed-off-by: Adam Young <admiyo@os.amperecomputing.com>
---
drivers/net/ethernet/mellanox/mlx5/core/sh_devlink.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/sh_devlink.c b/drivers/net/ethernet/mellanox/mlx5/core/sh_devlink.c
index bc33f95302df..6fa691aca81f 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/sh_devlink.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/sh_devlink.c
@@ -32,12 +32,14 @@ int mlx5_shd_init(struct mlx5_core_dev *dev)
/* Fall-back to SN for older devices. */
start = pci_vpd_find_ro_info_keyword(vpd_data, vpd_size,
PCI_VPD_RO_KEYWORD_SERIALNO, &kw_len);
- if (start < 0)
- return -ENOENT;
}
- sn = kstrndup(vpd_data + start, kw_len, GFP_KERNEL);
+ if (start < 0)
+ sn = kstrndup(dev->board_id, MLX5_BOARD_ID_LEN, GFP_KERNEL);
+ else
+ sn = kstrndup(vpd_data + start, kw_len, GFP_KERNEL);
if (!sn)
return -ENOMEM;
+
/* Firmware may return spaces at the end of the string, strip it. */
end = strchrnul(sn, ' ');
*end = '\0';
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [net-next v1.5] mlx5_core: fall back to dev->board_id for shd id
2026-03-25 22:11 [net-next v1.5] mlx5_core: fall back to dev->board_id for shd id Adam Young
@ 2026-03-26 5:27 ` Jiri Pirko
0 siblings, 0 replies; 2+ messages in thread
From: Jiri Pirko @ 2026-03-26 5:27 UTC (permalink / raw)
To: Adam Young
Cc: Saeed Mahameed, Leon Romanovsky, Tariq Toukan, Mark Bloch,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, netdev, linux-kernel
Wed, Mar 25, 2026 at 11:11:31PM +0100, admiyo@os.amperecomputing.com wrote:
>Making the devlink device shared requires an identifier
>to uniquely related the netlink device and the physical
>board. The original code used the serial number, requested
>from the boards attributes. However, not all members of
>the family of cards expose that attribute. The module init
>will fail on these devices. As a fall back, the driver can
>use the board_id, which is guaranteed to be present, and
>which is unique for every board in a deployment.
>
>Signed-off-by: Adam Young <admiyo@os.amperecomputing.com>
>---
> drivers/net/ethernet/mellanox/mlx5/core/sh_devlink.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
>diff --git a/drivers/net/ethernet/mellanox/mlx5/core/sh_devlink.c b/drivers/net/ethernet/mellanox/mlx5/core/sh_devlink.c
>index bc33f95302df..6fa691aca81f 100644
>--- a/drivers/net/ethernet/mellanox/mlx5/core/sh_devlink.c
>+++ b/drivers/net/ethernet/mellanox/mlx5/core/sh_devlink.c
>@@ -32,12 +32,14 @@ int mlx5_shd_init(struct mlx5_core_dev *dev)
> /* Fall-back to SN for older devices. */
> start = pci_vpd_find_ro_info_keyword(vpd_data, vpd_size,
> PCI_VPD_RO_KEYWORD_SERIALNO, &kw_len);
>- if (start < 0)
>- return -ENOENT;
> }
>- sn = kstrndup(vpd_data + start, kw_len, GFP_KERNEL);
>+ if (start < 0)
>+ sn = kstrndup(dev->board_id, MLX5_BOARD_ID_LEN, GFP_KERNEL);
Board id is PSID. That is not a serial, but rather type. That would
result in 2 nics of the same type to share 1 devlink instance, which is
wrong. Better to just don't create shared instance in case we can get
any identification in form of serial.
>+ else
>+ sn = kstrndup(vpd_data + start, kw_len, GFP_KERNEL);
> if (!sn)
> return -ENOMEM;
>+
> /* Firmware may return spaces at the end of the string, strip it. */
> end = strchrnul(sn, ' ');
> *end = '\0';
>--
>2.43.0
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-03-26 5:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-25 22:11 [net-next v1.5] mlx5_core: fall back to dev->board_id for shd id Adam Young
2026-03-26 5:27 ` Jiri Pirko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox