235 lines
7.8 KiB
Diff
235 lines
7.8 KiB
Diff
From 4da9c7c34673ba1c1c8e3c8b6a85a632db909986 Mon Sep 17 00:00:00 2001
|
|
From: Kamal Heib <kheib@redhat.com>
|
|
Date: Mon, 20 Apr 2026 14:59:29 -0400
|
|
Subject: [PATCH] net/mlx5: Refactor EEPROM query error handling to return
|
|
status separately
|
|
|
|
JIRA: https://redhat.atlassian.net/browse/RHEL-169055
|
|
|
|
commit 2e4c44b12f4da60d3e8dcbc1ccf38bb28a878050
|
|
Author: Gal Pressman <gal@nvidia.com>
|
|
Date: Mon Nov 17 23:42:05 2025 +0200
|
|
|
|
net/mlx5: Refactor EEPROM query error handling to return status separately
|
|
|
|
Matthew and Jakub reported [1] issues where inventory automation tools
|
|
are calling EEPROM query repeatedly on a port that doesn't have an SFP
|
|
connected, resulting in millions of error prints.
|
|
|
|
Move MCIA register status extraction from the query functions to the
|
|
callers, allowing use of extack reporting instead of a dmesg print when
|
|
using the netlink API.
|
|
|
|
[1] https://lore.kernel.org/netdev/20251028194011.39877-1-mattc@purestorage.com/
|
|
|
|
Cc: Matthew W Carlis <mattc@purestorage.com>
|
|
Signed-off-by: Gal Pressman <gal@nvidia.com>
|
|
Reviewed-by: Jianbo Liu <jianbol@nvidia.com>
|
|
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
|
|
Link: https://patch.msgid.link/1763415729-1238421-2-git-send-email-tariqt@nvidia.com
|
|
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|
|
|
Signed-off-by: Kamal Heib <kheib@redhat.com>
|
|
|
|
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
|
|
index 61760af93969..6e12bd196ec9 100644
|
|
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
|
|
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
|
|
@@ -2026,7 +2026,7 @@ static int mlx5e_get_module_info(struct net_device *netdev,
|
|
int size_read = 0;
|
|
u8 data[4] = {0};
|
|
|
|
- size_read = mlx5_query_module_eeprom(dev, 0, 2, data);
|
|
+ size_read = mlx5_query_module_eeprom(dev, 0, 2, data, NULL);
|
|
if (size_read < 2)
|
|
return -EIO;
|
|
|
|
@@ -2068,6 +2068,7 @@ static int mlx5e_get_module_eeprom(struct net_device *netdev,
|
|
struct mlx5_core_dev *mdev = priv->mdev;
|
|
int offset = ee->offset;
|
|
int size_read;
|
|
+ u8 status = 0;
|
|
int i = 0;
|
|
|
|
if (!ee->len)
|
|
@@ -2077,15 +2078,15 @@ static int mlx5e_get_module_eeprom(struct net_device *netdev,
|
|
|
|
while (i < ee->len) {
|
|
size_read = mlx5_query_module_eeprom(mdev, offset, ee->len - i,
|
|
- data + i);
|
|
-
|
|
+ data + i, &status);
|
|
if (!size_read)
|
|
/* Done reading */
|
|
return 0;
|
|
|
|
if (size_read < 0) {
|
|
- netdev_err(priv->netdev, "%s: mlx5_query_eeprom failed:0x%x\n",
|
|
- __func__, size_read);
|
|
+ netdev_err(netdev,
|
|
+ "%s: mlx5_query_eeprom failed:0x%x, status %u\n",
|
|
+ __func__, size_read, status);
|
|
return size_read;
|
|
}
|
|
|
|
@@ -2105,6 +2106,7 @@ static int mlx5e_get_module_eeprom_by_page(struct net_device *netdev,
|
|
struct mlx5_core_dev *mdev = priv->mdev;
|
|
u8 *data = page_data->data;
|
|
int size_read;
|
|
+ u8 status = 0;
|
|
int i = 0;
|
|
|
|
if (!page_data->length)
|
|
@@ -2118,7 +2120,8 @@ static int mlx5e_get_module_eeprom_by_page(struct net_device *netdev,
|
|
query.page = page_data->page;
|
|
while (i < page_data->length) {
|
|
query.size = page_data->length - i;
|
|
- size_read = mlx5_query_module_eeprom_by_page(mdev, &query, data + i);
|
|
+ size_read = mlx5_query_module_eeprom_by_page(mdev, &query,
|
|
+ data + i, &status);
|
|
|
|
/* Done reading, return how many bytes was read */
|
|
if (!size_read)
|
|
@@ -2127,8 +2130,8 @@ static int mlx5e_get_module_eeprom_by_page(struct net_device *netdev,
|
|
if (size_read < 0) {
|
|
NL_SET_ERR_MSG_FMT_MOD(
|
|
extack,
|
|
- "Query module eeprom by page failed, read %u bytes, err %d",
|
|
- i, size_read);
|
|
+ "Query module eeprom by page failed, read %u bytes, err %d, status %u",
|
|
+ i, size_read, status);
|
|
return size_read;
|
|
}
|
|
|
|
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
|
|
index acef7d0ffa09..cfebc110c02f 100644
|
|
--- a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
|
|
+++ b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
|
|
@@ -357,11 +357,11 @@ int mlx5_set_port_fcs(struct mlx5_core_dev *mdev, u8 enable);
|
|
void mlx5_query_port_fcs(struct mlx5_core_dev *mdev, bool *supported,
|
|
bool *enabled);
|
|
int mlx5_query_module_eeprom(struct mlx5_core_dev *dev,
|
|
- u16 offset, u16 size, u8 *data);
|
|
+ u16 offset, u16 size, u8 *data, u8 *status);
|
|
int
|
|
mlx5_query_module_eeprom_by_page(struct mlx5_core_dev *dev,
|
|
struct mlx5_module_eeprom_query_params *params,
|
|
- u8 *data);
|
|
+ u8 *data, u8 *status);
|
|
|
|
int mlx5_query_port_dcbx_param(struct mlx5_core_dev *mdev, u32 *out);
|
|
int mlx5_set_port_dcbx_param(struct mlx5_core_dev *mdev, u32 *in);
|
|
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/port.c b/drivers/net/ethernet/mellanox/mlx5/core/port.c
|
|
index aa9f2b0a77d3..e4b1dfafb41f 100644
|
|
--- a/drivers/net/ethernet/mellanox/mlx5/core/port.c
|
|
+++ b/drivers/net/ethernet/mellanox/mlx5/core/port.c
|
|
@@ -289,11 +289,11 @@ int mlx5_query_module_num(struct mlx5_core_dev *dev, int *module_num)
|
|
}
|
|
|
|
static int mlx5_query_module_id(struct mlx5_core_dev *dev, int module_num,
|
|
- u8 *module_id)
|
|
+ u8 *module_id, u8 *status)
|
|
{
|
|
u32 in[MLX5_ST_SZ_DW(mcia_reg)] = {};
|
|
u32 out[MLX5_ST_SZ_DW(mcia_reg)];
|
|
- int err, status;
|
|
+ int err;
|
|
u8 *ptr;
|
|
|
|
MLX5_SET(mcia_reg, in, i2c_device_address, MLX5_I2C_ADDR_LOW);
|
|
@@ -308,12 +308,12 @@ static int mlx5_query_module_id(struct mlx5_core_dev *dev, int module_num,
|
|
if (err)
|
|
return err;
|
|
|
|
- status = MLX5_GET(mcia_reg, out, status);
|
|
- if (status) {
|
|
- mlx5_core_err(dev, "query_mcia_reg failed: status: 0x%x\n",
|
|
- status);
|
|
+ if (MLX5_GET(mcia_reg, out, status)) {
|
|
+ if (status)
|
|
+ *status = MLX5_GET(mcia_reg, out, status);
|
|
return -EIO;
|
|
}
|
|
+
|
|
ptr = MLX5_ADDR_OF(mcia_reg, out, dword_0);
|
|
|
|
*module_id = ptr[0];
|
|
@@ -370,13 +370,14 @@ static int mlx5_mcia_max_bytes(struct mlx5_core_dev *dev)
|
|
}
|
|
|
|
static int mlx5_query_mcia(struct mlx5_core_dev *dev,
|
|
- struct mlx5_module_eeprom_query_params *params, u8 *data)
|
|
+ struct mlx5_module_eeprom_query_params *params,
|
|
+ u8 *data, u8 *status)
|
|
{
|
|
u32 in[MLX5_ST_SZ_DW(mcia_reg)] = {};
|
|
u32 out[MLX5_ST_SZ_DW(mcia_reg)];
|
|
- int status, err;
|
|
void *ptr;
|
|
u16 size;
|
|
+ int err;
|
|
|
|
size = min_t(int, params->size, mlx5_mcia_max_bytes(dev));
|
|
|
|
@@ -392,12 +393,9 @@ static int mlx5_query_mcia(struct mlx5_core_dev *dev,
|
|
if (err)
|
|
return err;
|
|
|
|
- status = MLX5_GET(mcia_reg, out, status);
|
|
- if (status) {
|
|
- mlx5_core_err(dev, "query_mcia_reg failed: status: 0x%x\n",
|
|
- status);
|
|
+ *status = MLX5_GET(mcia_reg, out, status);
|
|
+ if (*status)
|
|
return -EIO;
|
|
- }
|
|
|
|
ptr = MLX5_ADDR_OF(mcia_reg, out, dword_0);
|
|
memcpy(data, ptr, size);
|
|
@@ -406,7 +404,7 @@ static int mlx5_query_mcia(struct mlx5_core_dev *dev,
|
|
}
|
|
|
|
int mlx5_query_module_eeprom(struct mlx5_core_dev *dev,
|
|
- u16 offset, u16 size, u8 *data)
|
|
+ u16 offset, u16 size, u8 *data, u8 *status)
|
|
{
|
|
struct mlx5_module_eeprom_query_params query = {0};
|
|
u8 module_id;
|
|
@@ -416,7 +414,8 @@ int mlx5_query_module_eeprom(struct mlx5_core_dev *dev,
|
|
if (err)
|
|
return err;
|
|
|
|
- err = mlx5_query_module_id(dev, query.module_number, &module_id);
|
|
+ err = mlx5_query_module_id(dev, query.module_number, &module_id,
|
|
+ status);
|
|
if (err)
|
|
return err;
|
|
|
|
@@ -441,12 +440,12 @@ int mlx5_query_module_eeprom(struct mlx5_core_dev *dev,
|
|
query.size = size;
|
|
query.offset = offset;
|
|
|
|
- return mlx5_query_mcia(dev, &query, data);
|
|
+ return mlx5_query_mcia(dev, &query, data, status);
|
|
}
|
|
|
|
int mlx5_query_module_eeprom_by_page(struct mlx5_core_dev *dev,
|
|
struct mlx5_module_eeprom_query_params *params,
|
|
- u8 *data)
|
|
+ u8 *data, u8 *status)
|
|
{
|
|
int err;
|
|
|
|
@@ -460,7 +459,7 @@ int mlx5_query_module_eeprom_by_page(struct mlx5_core_dev *dev,
|
|
return -EINVAL;
|
|
}
|
|
|
|
- return mlx5_query_mcia(dev, params, data);
|
|
+ return mlx5_query_mcia(dev, params, data, status);
|
|
}
|
|
|
|
static int mlx5_query_port_pvlc(struct mlx5_core_dev *dev, u32 *pvlc,
|
|
--
|
|
2.50.1 (Apple Git-155)
|
|
|