From 6bd8ae031f915183a50692e28fae2bd93d046d58 Mon Sep 17 00:00:00 2001 From: Ulrich Langenbach Date: Thu, 11 Aug 2022 09:54:56 +0200 Subject: [PATCH] modules/mqnic: fix SFP EEPROM readout to support optical module diagnosis * fix offset check for allowing an offset of exactly 256 Bytes * fix allowing the I2C address of 0x51 to access the optical SFP modules diagnosis information, see SFF8472 rev 12.4 p. 8 --- modules/mqnic/mqnic_ethtool.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/mqnic/mqnic_ethtool.c b/modules/mqnic/mqnic_ethtool.c index 4263bc1ce..60e76c76b 100644 --- a/modules/mqnic/mqnic_ethtool.c +++ b/modules/mqnic/mqnic_ethtool.c @@ -339,21 +339,22 @@ static int mqnic_query_module_eeprom_by_page(struct net_device *ndev, case SFF_MODULE_ID_SFP: if (page > 0 || bank > 0) return -EINVAL; + if (i2c_addr != 0x50 && i2c_addr != 0x51) + return -EINVAL; break; case SFF_MODULE_ID_QSFP: case SFF_MODULE_ID_QSFP_PLUS: case SFF_MODULE_ID_QSFP28: if (page > 3 || bank > 0) return -EINVAL; + if (i2c_addr != 0x50) + return -EINVAL; break; default: netdev_err(ndev, "%s: Unknown module ID (0x%x)", __func__, module_id); return -EINVAL; } - if (i2c_addr != 0x50) - return -EINVAL; - // set page switch (module_id) { case SFF_MODULE_ID_SFP: @@ -396,7 +397,7 @@ static int mqnic_query_module_eeprom(struct net_device *ndev, case SFF_MODULE_ID_SFP: i2c_addr = 0x50; page = 0; - if (offset > 256) { + if (offset >= 256) { offset -= 256; i2c_addr = 0x51; }