[net-next v1.5] mlx5_core: fall back to dev->board_id for shd id
From: Adam Young
Date: Wed Mar 25 2026 - 18:15:47 EST
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);
+ 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