net: atlantic: fix reading SFP module info on some AQC100 cards
Subsystems (3)
PATCH v2 1/1 net: atlantic: fix reading SFP module info on some AQC100 cards
Commit 853a2944aaf3 ("net: atlantic: support reading SFP module info") added support for reading SFP module info on AQC100-based cards. However, it only supports reading directly from the controller's hardware registers, and this does not seem to be supported on certain cards, including my TRENDnet TEG-10GECSFP V3. "ethtool -m" times out when reading certain registers, even when I increase the read poll timeout values.
The DPDK "atlantic" driver reads module info via firmware calls instead of directly reading the hardware registers, provided that the NIC's firmware version supports it.
This change adapts the DPDK firmware call code to the kernel driver. It preserves the old hardware-based module read code as a fallback when the firmware does not support it, to avoid breaking cards that are currently working.
Tested on 2 different TRENDnet TEG-10GECSFP V3 cards, both with firmware version 3.1.121 (current at the time of this patch). Both cards correctly reported module info for a passive DAC cable and 2 different 10G optical transceivers.
---
v2:
- Do not overwrite error code
- Remove blank line between fixes and signed-off-by
v1: https://lore.kernel.org/all/[email protected]/
--- .../ethernet/aquantia/atlantic/aq_ethtool.c | 42 ++++++++-- .../net/ethernet/aquantia/atlantic/aq_hw.h | 3 + .../aquantia/atlantic/hw_atl/hw_atl_utils.h | 7 ++ .../atlantic/hw_atl/hw_atl_utils_fw2x.c | 82 +++++++++++++++++++ 4 files changed, 128 insertions(+), 6 deletions(-)
drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c +36 -6
@@ -983,6 +983,36 @@ static int aq_ethtool_set_phy_tunable(struct net_device *ndev,return err; } +static bool aq_ethtool_can_read_module_eeprom (struct aq_nic_s *aq_nic) +{ +return aq_nic->aq_fw_ops->read_module_eeprom || + aq_nic->aq_hw_ops->hw_read_module_eeprom; +} + +static int aq_ethtool_read_module_eeprom (struct aq_nic_s *aq_nic,u8 dev_addr, +u8 reg_start_addr,int len,u8 *data) +{ +int err = -EOPNOTSUPP ; + +if (aq_nic->aq_fw_ops->read_module_eeprom) { + err = aq_nic->aq_fw_ops->read_module_eeprom (aq_nic->aq_hw, + dev_addr, reg_start_addr, len, data); + +/* If the only error is that the firmware version doesn't +* support reading EEPROM, we can still attempt to read it +* directly from the hardware if supported. +*/ +if (err != -EOPNOTSUPP ) +return err; + } + +if (aq_nic->aq_hw_ops->hw_read_module_eeprom) + err = aq_nic->aq_hw_ops->hw_read_module_eeprom (aq_nic->aq_hw, + dev_addr, reg_start_addr, len, data); + +return err; +} +static int aq_ethtool_get_module_info (struct net_device *ndev,struct ethtool_modinfo *modinfo) {
@@ -992,15 +1022,15 @@ static int aq_ethtool_get_module_info(struct net_device *ndev,/* Module EEPROM is only supported for controllers with external PHY */ if (aq_nic->aq_nic_cfg.aq_hw_caps->media_type !=AQ_HW_MEDIA_TYPE_FIBRE || - !aq_nic->aq_hw_ops->hw_read_module_eeprom) + !aq_ethtool_can_read_module_eeprom (aq_nic))return -EOPNOTSUPP ; - err = aq_nic->aq_hw_ops->hw_read_module_eeprom (aq_nic->aq_hw, + err =aq_ethtool_read_module_eeprom (aq_nic,SFF_8472_ID_ADDR ,SFF_8472_COMP_ADDR ,1 , &compliance_val);if (err)return err; - err = aq_nic->aq_hw_ops->hw_read_module_eeprom (aq_nic->aq_hw, + err =aq_ethtool_read_module_eeprom (aq_nic,SFF_8472_ID_ADDR ,SFF_8472_DOM_TYPE_ADDR ,1 , &dom_type);if (err)return err;
@@ -1022,7 +1052,7 @@ static int aq_ethtool_get_module_eeprom(struct net_device *ndev,unsigned int first, last, len;int err; -if (!aq_nic->aq_hw_ops->hw_read_module_eeprom) +if (!aq_ethtool_can_read_module_eeprom (aq_nic))return -EOPNOTSUPP ; first = ee->offset;
@@ -1032,7 +1062,7 @@ static int aq_ethtool_get_module_eeprom(struct net_device *ndev, len =min (last,ETH_MODULE_SFF_8079_LEN ); len -= first; - err = aq_nic->aq_hw_ops->hw_read_module_eeprom (aq_nic->aq_hw, + err =aq_ethtool_read_module_eeprom (aq_nic,SFF_8472_ID_ADDR , first, len, data);if (err)return err;
@@ -1045,7 +1075,7 @@ static int aq_ethtool_get_module_eeprom(struct net_device *ndev, len -= first; first -=ETH_MODULE_SFF_8079_LEN ; - err = aq_nic->aq_hw_ops->hw_read_module_eeprom (aq_nic->aq_hw, + err =aq_ethtool_read_module_eeprom (aq_nic,SFF_8472_DIAGNOSTICS_ADDR , first, len, data);if (err)return err;
drivers/net/ethernet/aquantia/atlantic/aq_hw.h +3 -0
@@ -404,6 +404,9 @@ struct aq_fw_ops {int (*send_macsec_req)(struct aq_hw_s *self,struct macsec_msg_fw_request *msg,struct macsec_msg_fw_response *resp); + +int (*read_module_eeprom)(struct aq_hw_s *self,u8 dev_addr, + u8 reg_start_addr, int len, u8 *data); };#endif /* AQ_HW_H */
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.h +7 -0
@@ -319,6 +319,13 @@ struct __packed hw_atl_utils_settings {u32 media_detect; }; +struct __packed smbus_request { +u32 msg_id; +u32 device_id; +u32 address; +u32 length; +}; +enum macsec_msg_type { macsec_cfg_msg =0 , macsec_add_rx_sc_msg,
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils_fw2x.c +82 -0
98 lines not on this page · raw message
Signature · 1 line
2.52.0
Jakub Kicinski
maintainerQuoted 16 lines · On Mon, 16 Feb 2026 16:49:12 -0600 Tiernan Hubble wrote:
Commit
853a2944aaf3("net: atlantic: support reading SFP module info") added support for reading SFP module info on AQC100-based cards. However, it only supports reading directly from the controller's hardware registers, and this does not seem to be supported on certain cards, including my TRENDnet TEG-10GECSFP V3. "ethtool -m" times out when reading certain registers, even when I increase the read poll timeout values.The DPDK "atlantic" driver reads module info via firmware calls instead of directly reading the hardware registers, provided that the NIC's firmware version supports it.
This change adapts the DPDK firmware call code to the kernel driver. It preserves the old hardware-based module read code as a fallback when the firmware does not support it, to avoid breaking cards that are currently working.
Quoted 7 lines
Tested on 2 different TRENDnet TEG-10GECSFP V3 cards, both with firmware version 3.1.121 (current at the time of this patch). Both cards correctly reported module info for a passive DAC cable and 2 different 10G optical transceivers.
Fixes 853a2944aaf3 ("net: atlantic: support reading SFP module info")Signed-off-by Tiernan Hubble <[email protected]>
Overall looks quite nice, but I don't think it qualifies as a fix. Fix means something regressed from previous release, crashes, etc For the adapters in question IIUC ethtool -m has never worked before. Please drop the Fixes tag and repost next week for net-next.
Some drive by comments below..
Quoted 8 lines
drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c +0
-0@@ -983,6 +983,36 @@ static int aq_ethtool_set_phy_tunable(struct net_device *ndev,return err; }
drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c static int aq_ethtool_set_phy_tunable(struct net_device *ndev, · line 995
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c +10
-0+static bool aq_ethtool_can_read_module_eeprom (struct aq_nic_s *aq_nic) +{ +return aq_nic->aq_fw_ops->read_module_eeprom || + aq_nic->aq_hw_ops->hw_read_module_eeprom; +} + +static int aq_ethtool_read_module_eeprom (struct aq_nic_s *aq_nic,u8 dev_addr, +u8 reg_start_addr,int len,u8 *data) +{ +int err = -EOPNOTSUPP ;
maybe add a temp variable:
const struct aq_fw_ops *ops = aq_nic->aq_fw_ops;
drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c static int aq_ethtool_set_phy_tunable(struct net_device *ndev, · line 998
Quoted 2 lines
drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c +2
-0+if (aq_nic->aq_fw_ops->read_module_eeprom) { + err = aq_nic->aq_fw_ops->read_module_eeprom(aq_nic->aq_hw,
to avoid the long lines and awkward wrapping ?
drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c static int aq_ethtool_set_phy_tunable(struct net_device *ndev, · line 1010
Quoted 12 lines
drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c +12
-0+ dev_addr, reg_start_addr, len, data); + +/* If the only error is that the firmware version doesn't +* support reading EEPROM, we can still attempt to read it +* directly from the hardware if supported. +*/ +if (err != -EOPNOTSUPP ) +return err; + } + +if (aq_nic->aq_hw_ops->hw_read_module_eeprom) + err = aq_nic->aq_hw_ops->hw_read_module_eeprom(aq_nic->aq_hw,
and here
Quoted 19 lines
drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c +18
-0+ dev_addr, reg_start_addr, len, data); + +return err; +} +static int aq_fw2x_read_module_eeprom (struct aq_hw_s *self,u8 dev_addr, +u8 reg_start_addr,int len,u8 *data) +{ +u32 low_status, orig_low_status, low_req =0 ; +u32 res_bytes_remain_cnt = len %sizeof (u32); +u32 res_dword_cnt = len /sizeof (u32); +struct smbus_request request = {0 }; +u32 req_dword_cnt; +u32 result =0 ; +u32 caps_lo; +u32 offset; +int err; + + caps_lo =aq_fw2x_get_link_capabilities (self);
drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c static int aq_ethtool_set_phy_tunable(struct net_device *ndev,
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c +10
-0+if (!(caps_lo &BIT (CAPS_LO_SMBUS_READ ))) +return -EOPNOTSUPP ; + + request.msg_id =0 ; + request.device_id = dev_addr; + request.address = reg_start_addr; + request.length = len; + +/* Write SMBUS request to cfg memory */ + req_dword_cnt = (sizeof (request) +sizeof (u32) -1 ) /sizeof (u32);
DIV_ROUND_UP()
drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c
Quoted 7 lines
drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c +7
-0+ err =hw_atl_write_fwcfg_dwords (self, (void *)&request, req_dword_cnt); +if (err <0 ) +return err; + +/* Toggle 0x368.CAPS_LO_SMBUS_READ bit */ + low_req =aq_hw_read_reg (self,HW_ATL_FW2X_MPI_CONTROL_ADDR ); + orig_low_status = low_req &BIT (CAPS_LO_SMBUS_READ );
the mixing of BIT(CAPS_LO_SMBUS_READ)..
drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c
Quoted 1 line
drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c +1
-0+ low_req ^=HW_ATL_FW2X_CAP_SMBUS_READ ;
.. and HW_ATL_FW2X_CAP_SMBUS_READ which is defined to
+#define HW_ATL_FW2X_CAP_SMBUS_READ BIT(CAPS_LO_SMBUS_READ)
seems unnecessary and confusing?
Signature · 1 line
pw-bot: cr