Re: [net-next v1.5] mlx5_core: fall back to dev->board_id for shd id
From: Jiri Pirko
Date: Thu Mar 26 2026 - 01:27:51 EST
Wed, Mar 25, 2026 at 11:11:31PM +0100, admiyo@xxxxxxxxxxxxxxxxxxxxxx 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@xxxxxxxxxxxxxxxxxxxxxx>
>---
> 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
>
>