Skip to content

Commit 21db923

Browse files
committed
Merge branch 'mlxsw-Add-support-for-QSFP-DD-transceiver-type'
Ido Schimmel says: ==================== mlxsw: Add support for QSFP-DD transceiver type This patch set from Vadim adds support for Quad Small Form Factor Pluggable Double Density (QSFP-DD) modules in mlxsw. Patch kernel-patches#1 enables dumping of QSFP-DD module information through ethtool. Patch kernel-patches#2 enables reading of temperature thresholds from QSFP-DD modules for hwmon and thermal zone purposes. Changes since v1 [1]: Only rebase on top of net-next. After discussing with Andrew and Adrian we agreed that current approach is OK and that in the future we can follow Andrew's suggestion to "make a new API where user space can request any pages it want, and specify the size of the page". This should allow us "to work around known issues when manufactures get their EEPROM wrong". [1] https://lore.kernel.org/netdev/[email protected]/#t ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 0082dd8 + f152b41 commit 21db923

File tree

2 files changed

+44
-12
lines changed

2 files changed

+44
-12
lines changed

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

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include "reg.h"
1212

1313
static int mlxsw_env_validate_cable_ident(struct mlxsw_core *core, int id,
14-
bool *qsfp)
14+
bool *qsfp, bool *cmis)
1515
{
1616
char eeprom_tmp[MLXSW_REG_MCIA_EEPROM_SIZE];
1717
char mcia_pl[MLXSW_REG_MCIA_LEN];
@@ -25,15 +25,19 @@ static int mlxsw_env_validate_cable_ident(struct mlxsw_core *core, int id,
2525
return err;
2626
mlxsw_reg_mcia_eeprom_memcpy_from(mcia_pl, eeprom_tmp);
2727
ident = eeprom_tmp[0];
28+
*cmis = false;
2829
switch (ident) {
2930
case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_SFP:
3031
*qsfp = false;
3132
break;
3233
case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP: /* fall-through */
3334
case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP_PLUS: /* fall-through */
34-
case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP28: /* fall-through */
35+
case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP28:
36+
*qsfp = true;
37+
break;
3538
case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP_DD:
3639
*qsfp = true;
40+
*cmis = true;
3741
break;
3842
default:
3943
return -EINVAL;
@@ -70,8 +74,9 @@ mlxsw_env_query_module_eeprom(struct mlxsw_core *mlxsw_core, int module,
7074
if (qsfp) {
7175
/* When reading upper pages 1, 2 and 3 the offset
7276
* starts at 128. Please refer to "QSFP+ Memory Map"
73-
* figure in SFF-8436 specification for graphical
74-
* depiction.
77+
* figure in SFF-8436 specification and to "CMIS Module
78+
* Memory Map" figure in CMIS specification for
79+
* graphical depiction.
7580
*/
7681
page = MLXSW_REG_MCIA_PAGE_GET(offset);
7782
offset -= MLXSW_REG_MCIA_EEPROM_UP_PAGE_LENGTH * page;
@@ -116,7 +121,8 @@ int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module,
116121
char mcia_pl[MLXSW_REG_MCIA_LEN] = {0};
117122
char mtmp_pl[MLXSW_REG_MTMP_LEN];
118123
unsigned int module_temp;
119-
bool qsfp;
124+
bool qsfp, cmis;
125+
int page;
120126
int err;
121127

122128
mlxsw_reg_mtmp_pack(mtmp_pl, MLXSW_REG_MTMP_MODULE_INDEX_MIN + module,
@@ -140,21 +146,28 @@ int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module,
140146
*/
141147

142148
/* Validate module identifier value. */
143-
err = mlxsw_env_validate_cable_ident(core, module, &qsfp);
149+
err = mlxsw_env_validate_cable_ident(core, module, &qsfp, &cmis);
144150
if (err)
145151
return err;
146152

147-
if (qsfp)
148-
mlxsw_reg_mcia_pack(mcia_pl, module, 0,
149-
MLXSW_REG_MCIA_TH_PAGE_NUM,
153+
if (qsfp) {
154+
/* For QSFP/CMIS module-defined thresholds are located in page
155+
* 02h, otherwise in page 03h.
156+
*/
157+
if (cmis)
158+
page = MLXSW_REG_MCIA_TH_PAGE_CMIS_NUM;
159+
else
160+
page = MLXSW_REG_MCIA_TH_PAGE_NUM;
161+
mlxsw_reg_mcia_pack(mcia_pl, module, 0, page,
150162
MLXSW_REG_MCIA_TH_PAGE_OFF + off,
151163
MLXSW_REG_MCIA_TH_ITEM_SIZE,
152164
MLXSW_REG_MCIA_I2C_ADDR_LOW);
153-
else
165+
} else {
154166
mlxsw_reg_mcia_pack(mcia_pl, module, 0,
155167
MLXSW_REG_MCIA_PAGE0_LO,
156168
off, MLXSW_REG_MCIA_TH_ITEM_SIZE,
157169
MLXSW_REG_MCIA_I2C_ADDR_HIGH);
170+
}
158171

159172
err = mlxsw_reg_query(core, MLXSW_REG(mcia), mcia_pl);
160173
if (err)
@@ -221,6 +234,22 @@ int mlxsw_env_get_module_info(struct mlxsw_core *mlxsw_core, int module,
221234
else
222235
modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN / 2;
223236
break;
237+
case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP_DD:
238+
/* Use SFF_8636 as base type. ethtool should recognize specific
239+
* type through the identifier value.
240+
*/
241+
modinfo->type = ETH_MODULE_SFF_8636;
242+
/* Verify if module EEPROM is a flat memory. In case of flat
243+
* memory only page 00h (0-255 bytes) can be read. Otherwise
244+
* upper pages 01h and 02h can also be read. Upper pages 10h
245+
* and 11h are currently not supported by the driver.
246+
*/
247+
if (module_info[MLXSW_REG_MCIA_EEPROM_MODULE_INFO_TYPE_ID] &
248+
MLXSW_REG_MCIA_EEPROM_CMIS_FLAT_MEMORY)
249+
modinfo->eeprom_len = ETH_MODULE_SFF_8636_LEN;
250+
else
251+
modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN;
252+
break;
224253
default:
225254
return -EINVAL;
226255
}
@@ -235,16 +264,16 @@ int mlxsw_env_get_module_eeprom(struct net_device *netdev,
235264
{
236265
int offset = ee->offset;
237266
unsigned int read_size;
267+
bool qsfp, cmis;
238268
int i = 0;
239-
bool qsfp;
240269
int err;
241270

242271
if (!ee->len)
243272
return -EINVAL;
244273

245274
memset(data, 0, ee->len);
246275
/* Validate module identifier value. */
247-
err = mlxsw_env_validate_cable_ident(mlxsw_core, module, &qsfp);
276+
err = mlxsw_env_validate_cable_ident(mlxsw_core, module, &qsfp, &cmis);
248277
if (err)
249278
return err;
250279

drivers/net/ethernet/mellanox/mlxsw/reg.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8605,8 +8605,10 @@ MLXSW_ITEM32(reg, mcia, size, 0x08, 0, 16);
86058605
#define MLXSW_REG_MCIA_PAGE0_LO_OFF 0xa0
86068606
#define MLXSW_REG_MCIA_TH_ITEM_SIZE 2
86078607
#define MLXSW_REG_MCIA_TH_PAGE_NUM 3
8608+
#define MLXSW_REG_MCIA_TH_PAGE_CMIS_NUM 2
86088609
#define MLXSW_REG_MCIA_PAGE0_LO 0
86098610
#define MLXSW_REG_MCIA_TH_PAGE_OFF 0x80
8611+
#define MLXSW_REG_MCIA_EEPROM_CMIS_FLAT_MEMORY BIT(7)
86108612

86118613
enum mlxsw_reg_mcia_eeprom_module_info_rev_id {
86128614
MLXSW_REG_MCIA_EEPROM_MODULE_INFO_REV_ID_UNSPC = 0x00,
@@ -8625,6 +8627,7 @@ enum mlxsw_reg_mcia_eeprom_module_info_id {
86258627
enum mlxsw_reg_mcia_eeprom_module_info {
86268628
MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID,
86278629
MLXSW_REG_MCIA_EEPROM_MODULE_INFO_REV_ID,
8630+
MLXSW_REG_MCIA_EEPROM_MODULE_INFO_TYPE_ID,
86288631
MLXSW_REG_MCIA_EEPROM_MODULE_INFO_SIZE,
86298632
};
86308633

0 commit comments

Comments
 (0)