Skip to content

Commit fcb610a

Browse files
gal-pressmanSaeed Mahameed
authored andcommitted
net/mlx5: Parse module mapping using mlx5_ifc
The assumption that the first byte in the module mapping dword is the module number shouldn't be hard-coded in the driver, but come from mlx5_ifc structs. While at it, fix the incorrect width for the 'rx_lane' and 'tx_lane' fields. Signed-off-by: Gal Pressman <[email protected]> Reviewed-by: Maxim Mikityanskiy <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 271907e commit fcb610a

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

drivers/net/ethernet/mellanox/mlx5/core/port.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,6 @@ static int mlx5_query_module_num(struct mlx5_core_dev *dev, int *module_num)
275275
{
276276
u32 in[MLX5_ST_SZ_DW(pmlp_reg)] = {0};
277277
u32 out[MLX5_ST_SZ_DW(pmlp_reg)];
278-
int module_mapping;
279278
int err;
280279

281280
MLX5_SET(pmlp_reg, in, local_port, 1);
@@ -284,8 +283,9 @@ static int mlx5_query_module_num(struct mlx5_core_dev *dev, int *module_num)
284283
if (err)
285284
return err;
286285

287-
module_mapping = MLX5_GET(pmlp_reg, out, lane0_module_mapping);
288-
*module_num = module_mapping & MLX5_EEPROM_IDENTIFIER_BYTE_MASK;
286+
*module_num = MLX5_GET(lane_2_module_mapping,
287+
MLX5_ADDR_OF(pmlp_reg, out, lane0_module_mapping),
288+
module);
289289

290290
return 0;
291291
}

include/linux/mlx5/mlx5_ifc.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9888,10 +9888,10 @@ struct mlx5_ifc_pcmr_reg_bits {
98889888
};
98899889

98909890
struct mlx5_ifc_lane_2_module_mapping_bits {
9891-
u8 reserved_at_0[0x6];
9892-
u8 rx_lane[0x2];
9893-
u8 reserved_at_8[0x6];
9894-
u8 tx_lane[0x2];
9891+
u8 reserved_at_0[0x4];
9892+
u8 rx_lane[0x4];
9893+
u8 reserved_at_8[0x4];
9894+
u8 tx_lane[0x4];
98959895
u8 reserved_at_10[0x8];
98969896
u8 module[0x8];
98979897
};

include/linux/mlx5/port.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ enum mlx5_an_status {
5656
MLX5_AN_LINK_DOWN = 4,
5757
};
5858

59-
#define MLX5_EEPROM_IDENTIFIER_BYTE_MASK 0x000000ff
6059
#define MLX5_I2C_ADDR_LOW 0x50
6160
#define MLX5_I2C_ADDR_HIGH 0x51
6261
#define MLX5_EEPROM_PAGE_LENGTH 256

0 commit comments

Comments
 (0)