From: Tony Nguyen <anthony.l.nguyen@intel.com>
To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
edumazet@kernel.org, andrew+netdev@lunn.ch, willemb@google.com,
netdev@vger.kernel.org
Cc: Pawel Dembicki <paweldembicki@gmail.com>,
anthony.l.nguyen@intel.com, dima.ruinskiy@intel.com,
pavankumaryalagada@gmail.com, Rinitha S <sx.rinitha@intel.com>
Subject: [PATCH net-next 3/4] igb: read SFP module EEPROM through igb_read_sfp_data_byte
Date: Wed, 2 Dec 2026 16:50:38 -0800 [thread overview]
Message-ID: <20261203005042.348952-4-anthony.l.nguyen@intel.com> (raw)
In-Reply-To: <20261203005042.348952-1-anthony.l.nguyen@intel.com>
From: Pawel Dembicki <paweldembicki@gmail.com>
igb_get_module_info() and igb_get_module_eeprom() use
igb_read_phy_reg_i2c(), which accesses the external PHY register space.
On designs with an external SGMII PHY this returns PHY register contents
instead of the SFP module EEPROM requested by ethtool -m.
Use igb_read_sfp_data_byte() for module EEPROM reads. The legacy
ethtool module EEPROM offset space maps directly to the I210 I2CCMD
module address space: offsets 0x000-0x0ff address the SFP base EEPROM
and offsets 0x100-0x1ff address the diagnostics EEPROM.
Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
Tested-by: Rinitha S <sx.rinitha@intel.com> (A Contingent worker at Intel)
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
drivers/net/ethernet/intel/igb/igb_ethtool.c | 39 ++++++--------------
1 file changed, 12 insertions(+), 27 deletions(-)
diff --git a/drivers/net/ethernet/intel/igb/igb_ethtool.c b/drivers/net/ethernet/intel/igb/igb_ethtool.c
index ccc7302dc7bd..12d449bb062e 100644
--- a/drivers/net/ethernet/intel/igb/igb_ethtool.c
+++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c
@@ -3208,7 +3208,7 @@ static int igb_get_module_info(struct net_device *netdev,
struct igb_adapter *adapter = netdev_priv(netdev);
struct e1000_hw *hw = &adapter->hw;
u32 status = 0;
- u16 sff8472_rev, addr_mode;
+ u8 sff8472_rev, addr_mode;
bool page_swap = false;
if ((hw->phy.media_type == e1000_media_type_copper) ||
@@ -3216,22 +3216,26 @@ static int igb_get_module_info(struct net_device *netdev,
return -EOPNOTSUPP;
/* Check whether we support SFF-8472 or not */
- status = igb_read_phy_reg_i2c(hw, IGB_SFF_8472_COMP, &sff8472_rev);
+ status = igb_read_sfp_data_byte(hw,
+ E1000_I2CCMD_SFP_DATA_ADDR(IGB_SFF_8472_COMP),
+ &sff8472_rev);
if (status)
return -EIO;
/* addressing mode is not supported */
- status = igb_read_phy_reg_i2c(hw, IGB_SFF_8472_SWAP, &addr_mode);
+ status = igb_read_sfp_data_byte(hw,
+ E1000_I2CCMD_SFP_DATA_ADDR(IGB_SFF_8472_SWAP),
+ &addr_mode);
if (status)
return -EIO;
/* addressing mode is not supported */
- if ((addr_mode & 0xFF) & IGB_SFF_ADDRESSING_MODE) {
+ if (addr_mode & IGB_SFF_ADDRESSING_MODE) {
hw_dbg("Address change required to access page 0xA2, but not supported. Please report the module type to the driver maintainers.\n");
page_swap = true;
}
- if ((sff8472_rev & 0xFF) == IGB_SFF_8472_UNSUP || page_swap) {
+ if (sff8472_rev == IGB_SFF_8472_UNSUP || page_swap) {
/* We have an SFP, but it does not support SFF-8472 */
modinfo->type = ETH_MODULE_SFF_8079;
modinfo->eeprom_len = ETH_MODULE_SFF_8079_LEN;
@@ -3250,36 +3254,17 @@ static int igb_get_module_eeprom(struct net_device *netdev,
struct igb_adapter *adapter = netdev_priv(netdev);
struct e1000_hw *hw = &adapter->hw;
u32 status = 0;
- u16 *dataword;
- u16 first_word, last_word;
int i = 0;
if (ee->len == 0)
return -EINVAL;
- first_word = ee->offset >> 1;
- last_word = (ee->offset + ee->len - 1) >> 1;
-
- dataword = kmalloc_objs(u16, last_word - first_word + 1);
- if (!dataword)
- return -ENOMEM;
-
- /* Read EEPROM block, SFF-8079/SFF-8472, word at a time */
- for (i = 0; i < last_word - first_word + 1; i++) {
- status = igb_read_phy_reg_i2c(hw, (first_word + i) * 2,
- &dataword[i]);
- if (status) {
- /* Error occurred while reading module */
- kfree(dataword);
+ for (i = 0; i < ee->len; i++) {
+ status = igb_read_sfp_data_byte(hw, ee->offset + i, &data[i]);
+ if (status)
return -EIO;
- }
-
- be16_to_cpus(&dataword[i]);
}
- memcpy(data, (u8 *)dataword + (ee->offset & 1), ee->len);
- kfree(dataword);
-
return 0;
}
--
2.47.1
next prev parent reply other threads:[~2026-12-03 0:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 0:50 [PATCH net-next 0/4][pull request] Intel Wired LAN Driver Updates 2026-12-02 (igc, igb, e100) Tony Nguyen
2026-12-03 0:50 ` [PATCH net-next 1/4] igc: Support ACPI-based MAC passthrough Tony Nguyen
2026-12-03 0:50 ` [PATCH net-next 2/4] igb: detect M88E1112 100BASE-FX SGMII mode Tony Nguyen
2026-12-03 0:50 ` Tony Nguyen [this message]
2026-12-03 0:50 ` [PATCH net-next 4/4] e100: prevent shift-out-of-bounds in EEPROM access Tony Nguyen
2026-12-03 0:53 ` [PATCH net-next 0/4][pull request] Intel Wired LAN Driver Updates 2026-12-02 (igc, igb, e100) netdev-bot+sinfo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261203005042.348952-4-anthony.l.nguyen@intel.com \
--to=anthony.l.nguyen@intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=dima.ruinskiy@intel.com \
--cc=edumazet@kernel.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pavankumaryalagada@gmail.com \
--cc=paweldembicki@gmail.com \
--cc=sx.rinitha@intel.com \
--cc=willemb@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox