Skip to content

Commit 7328a23

Browse files
Vasundhara Volamdavem330
authored andcommitted
bnxt_en: Read phy eeprom A2h address only when optical diagnostics is supported.
For SFP+ modules, 0xA2 page is available only when Diagnostic Monitoring Type [Address A0h, Byte 92] is implemented. Extend bnxt_get_module_info(), to read optical diagnostics support at offset 92(0x5c) and set eeprom_len length to ETH_MODULE_SFF_8436_LEN (to exclude A2 page), if dianostics is not supported. Also in bnxt_get_module_info(), module id is read from offset 0x5e which is not correct. It was working by accident, as offset was not effective without setting enables flag in the firmware request. SFP module id is present at location 0. Fix this by removing the offset and read it from location 0. Signed-off-by: Vasundhara Volam <[email protected]> Signed-off-by: Michael Chan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent dac0490 commit 7328a23

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,8 +1414,7 @@ struct bnxt {
14141414

14151415
#define I2C_DEV_ADDR_A0 0xa0
14161416
#define I2C_DEV_ADDR_A2 0xa2
1417-
#define SFP_EEPROM_SFF_8472_COMP_ADDR 0x5e
1418-
#define SFP_EEPROM_SFF_8472_COMP_SIZE 1
1417+
#define SFF_DIAG_SUPPORT_OFFSET 0x5c
14191418
#define SFF_MODULE_ID_SFP 0x3
14201419
#define SFF_MODULE_ID_QSFP 0xc
14211420
#define SFF_MODULE_ID_QSFP_PLUS 0xd

drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2184,9 +2184,8 @@ static int bnxt_read_sfp_module_eeprom_info(struct bnxt *bp, u16 i2c_addr,
21842184
static int bnxt_get_module_info(struct net_device *dev,
21852185
struct ethtool_modinfo *modinfo)
21862186
{
2187+
u8 data[SFF_DIAG_SUPPORT_OFFSET + 1];
21872188
struct bnxt *bp = netdev_priv(dev);
2188-
struct hwrm_port_phy_i2c_read_input req = {0};
2189-
struct hwrm_port_phy_i2c_read_output *output = bp->hwrm_cmd_resp_addr;
21902189
int rc;
21912190

21922191
/* No point in going further if phy status indicates
@@ -2201,21 +2200,19 @@ static int bnxt_get_module_info(struct net_device *dev,
22012200
if (bp->hwrm_spec_code < 0x10202)
22022201
return -EOPNOTSUPP;
22032202

2204-
bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_PORT_PHY_I2C_READ, -1, -1);
2205-
req.i2c_slave_addr = I2C_DEV_ADDR_A0;
2206-
req.page_number = 0;
2207-
req.page_offset = cpu_to_le16(SFP_EEPROM_SFF_8472_COMP_ADDR);
2208-
req.data_length = SFP_EEPROM_SFF_8472_COMP_SIZE;
2209-
req.port_id = cpu_to_le16(bp->pf.port_id);
2210-
mutex_lock(&bp->hwrm_cmd_lock);
2211-
rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
2203+
rc = bnxt_read_sfp_module_eeprom_info(bp, I2C_DEV_ADDR_A0, 0, 0,
2204+
SFF_DIAG_SUPPORT_OFFSET + 1,
2205+
data);
22122206
if (!rc) {
2213-
u32 module_id = le32_to_cpu(output->data[0]);
2207+
u8 module_id = data[0];
2208+
u8 diag_supported = data[SFF_DIAG_SUPPORT_OFFSET];
22142209

22152210
switch (module_id) {
22162211
case SFF_MODULE_ID_SFP:
22172212
modinfo->type = ETH_MODULE_SFF_8472;
22182213
modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN;
2214+
if (!diag_supported)
2215+
modinfo->eeprom_len = ETH_MODULE_SFF_8436_LEN;
22192216
break;
22202217
case SFF_MODULE_ID_QSFP:
22212218
case SFF_MODULE_ID_QSFP_PLUS:
@@ -2231,7 +2228,6 @@ static int bnxt_get_module_info(struct net_device *dev,
22312228
break;
22322229
}
22332230
}
2234-
mutex_unlock(&bp->hwrm_cmd_lock);
22352231
return rc;
22362232
}
22372233

0 commit comments

Comments
 (0)