Skip to content

Commit a45bfb5

Browse files
mellanoxbmcJakub Kicinski
authored andcommitted
mlxsw: core: Extend QSFP EEPROM size for ethtool
Extend the size of QSFP EEPROM for the cable types SSF8436 and SFF8636 from 256 to 640 bytes in order to expose all the EEPROM pages by ethtool. For SFF-8636 and SFF-8436 specifications, the driver exposes 256 bytes of data for ethtool's get_module_eeprom() callback. This is because the driver uses the below defines to specify SFF module length in ethtool's get_module_info() callback: 'ETH_MODULE_SFF_8636_LEN' and 'ETH_MODULE_SFF_8436_LEN' (both are 256). As a result of exposing 256 bytes only, ethtool shows wrong "zero" info for pages 1, 2, 3. The patch changes the length returned by callback for get_module_info() to the values from the next defines: 'ETH_MODULE_SFF_8636_MAX_LEN' and 'ETH_MODULE_SFF_8436_MAX_LEN' (both are 640) to allow exposing of upper page 1, 2 and 3. Signed-off-by: Vadim Pasternak <[email protected]> Acked-by: Jiri Pirko <[email protected]> Signed-off-by: Ido Schimmel <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent f366cd2 commit a45bfb5

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

drivers/net/ethernet/mellanox/mlxsw/core_env.c

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ mlxsw_env_query_module_eeprom(struct mlxsw_core *mlxsw_core, int module,
5050
char eeprom_tmp[MLXSW_REG_MCIA_EEPROM_SIZE];
5151
char mcia_pl[MLXSW_REG_MCIA_LEN];
5252
u16 i2c_addr;
53+
u8 page = 0;
5354
int status;
5455
int err;
5556

@@ -62,11 +63,21 @@ mlxsw_env_query_module_eeprom(struct mlxsw_core *mlxsw_core, int module,
6263

6364
i2c_addr = MLXSW_REG_MCIA_I2C_ADDR_LOW;
6465
if (offset >= MLXSW_REG_MCIA_EEPROM_PAGE_LENGTH) {
65-
i2c_addr = MLXSW_REG_MCIA_I2C_ADDR_HIGH;
66-
offset -= MLXSW_REG_MCIA_EEPROM_PAGE_LENGTH;
66+
page = MLXSW_REG_MCIA_PAGE_GET(offset);
67+
offset -= MLXSW_REG_MCIA_EEPROM_UP_PAGE_LENGTH * page;
68+
/* When reading upper pages 1, 2 and 3 the offset starts at
69+
* 128. Please refer to "QSFP+ Memory Map" figure in SFF-8436
70+
* specification for graphical depiction.
71+
* MCIA register accepts buffer size <= 48. Page of size 128
72+
* should be read by chunks of size 48, 48, 32. Align the size
73+
* of the last chunk to avoid reading after the end of the
74+
* page.
75+
*/
76+
if (offset + size > MLXSW_REG_MCIA_EEPROM_PAGE_LENGTH)
77+
size = MLXSW_REG_MCIA_EEPROM_PAGE_LENGTH - offset;
6778
}
6879

69-
mlxsw_reg_mcia_pack(mcia_pl, module, 0, 0, offset, size, i2c_addr);
80+
mlxsw_reg_mcia_pack(mcia_pl, module, 0, page, offset, size, i2c_addr);
7081

7182
err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mcia), mcia_pl);
7283
if (err)
@@ -168,18 +179,18 @@ int mlxsw_env_get_module_info(struct mlxsw_core *mlxsw_core, int module,
168179
switch (module_id) {
169180
case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP:
170181
modinfo->type = ETH_MODULE_SFF_8436;
171-
modinfo->eeprom_len = ETH_MODULE_SFF_8436_LEN;
182+
modinfo->eeprom_len = ETH_MODULE_SFF_8436_MAX_LEN;
172183
break;
173184
case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP_PLUS: /* fall-through */
174185
case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP28:
175186
if (module_id == MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP28 ||
176187
module_rev_id >=
177188
MLXSW_REG_MCIA_EEPROM_MODULE_INFO_REV_ID_8636) {
178189
modinfo->type = ETH_MODULE_SFF_8636;
179-
modinfo->eeprom_len = ETH_MODULE_SFF_8636_LEN;
190+
modinfo->eeprom_len = ETH_MODULE_SFF_8636_MAX_LEN;
180191
} else {
181192
modinfo->type = ETH_MODULE_SFF_8436;
182-
modinfo->eeprom_len = ETH_MODULE_SFF_8436_LEN;
193+
modinfo->eeprom_len = ETH_MODULE_SFF_8436_MAX_LEN;
183194
}
184195
break;
185196
case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_SFP:

0 commit comments

Comments
 (0)