Netdev List
 help / color / mirror / Atom feed
From: Potnuri Bharat Teja <bharat@chelsio.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, kuba@kernel.org, edumazet@google.com,
	pabeni@redhat.com, andrew+netdev@lunn.ch, bharat@chelsio.com,
	harshitha.vr@chelsio.com
Subject: [PATCH net-next v6 07/12] cxgb4: extend ethtool support for T7 adapters
Date: Tue,  1 Dec 2026 17:15:51 -0500	[thread overview]
Message-ID: <20261201221556.251018-8-bharat@chelsio.com> (raw)
In-Reply-To: <20261201221556.251018-1-bharat@chelsio.com>

Extend the ethtool implementation for the T7 port types, link modes
and module types, and add RSS hash key and paged module EEPROM
support.

Port and module types:

  - Handle the T7 port types (SFP56, QSFP56, QSFP56 4x50G/2x50G/2x100G,
    QSFP-DD, QSFP-DD 2x200G/4x100G, OSFP, OSFP 2x200G, and the
    50G/100G/200G/400G backplane types) when reporting the port type
    and reading module information.
  - Report the DR and LR_SIMPLEX module types as fibre.

Link modes:

  - fw_caps_to_lmm() now derives the reported link modes from the
    port type and the module type (backplane, BASE-T, DA copper, SR,
    LR/ER, DR, LRM) instead of from the port type alone, and covers
    speeds up to 400G.  This also changes the modes reported on
    earlier adapters: for example an SFP port with an SR module now
    reports 10000baseSR rather than 10000baseT, and no medium
    specific modes are reported while no module is present.
    ethtool has no 25G LR/ER mode, so 25G on LR/ER modules is reported
    as 25000baseSR.
  - lmm_to_fw_caps() accepts all of these modes when setting the
    advertised link modes.
  - eth_to_cc_fec() turns FEC off only when ETHTOOL_FEC_OFF is the
    only requested mode.

Firmware port commands, port statistics and module I2C accesses use
the logical port number (pi->lport) rather than pi->tx_chan, which
differs from it on T7.

RSS: add get_rxfh_key_size() and support reading and writing the RSS
hash key through get_rxfh()/set_rxfh().  A request to change the
indirection table before the interface has been brought up is
rejected before the key is written.

Module EEPROM:

  - get_module_info() returns -EOPNOTSUPP for CMIS modules (QSFP-DD,
    OSFP, QSFP+ CMIS), identified by their SFF-8024 identifier, since
    they have no legacy ethtool module type.
  - Add get_module_eeprom_by_page().  SFF-8636 and CMIS modules select
    the requested upper page through the page select byte and restore
    page 0 afterwards; SFF-8472 modules are not paged.  Banks are not
    supported.

Signed-off-by: Potnuri Bharat Teja <bharat@chelsio.com>
---
 .../ethernet/chelsio/cxgb4/cxgb4_ethtool.c    | 520 ++++++++++++++----
 1 file changed, 401 insertions(+), 119 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
index c72c0bcd45c8..f77f6482bd00 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
@@ -5,6 +5,7 @@
 
 #include <linux/firmware.h>
 #include <linux/mdio.h>
+#include <linux/unaligned.h>
 
 #include "cxgb4.h"
 #include "t4_regs.h"
@@ -14,6 +15,8 @@
 #include "cxgb4_tc_flower.h"
 
 #define EEPROM_MAGIC 0x38E2F10C
+#define RSS_HASH_KEY_SIZE 40
+#define CMIS_PAGE_SELECT_REG 127
 
 static u32 get_msglevel(struct net_device *dev)
 {
@@ -358,7 +361,7 @@ static void get_stats(struct net_device *dev, struct ethtool_stats *stats,
 	int i;
 	u64 *p0;
 
-	t4_get_port_stats_offset(adapter, pi->tx_chan,
+	t4_get_port_stats_offset(adapter, pi->lport,
 				 (struct port_stats *)data,
 				 &pi->stats_base);
 
@@ -396,7 +399,7 @@ static int restart_autoneg(struct net_device *dev)
 		return -EAGAIN;
 	if (p->link_cfg.autoneg != AUTONEG_ENABLE)
 		return -EINVAL;
-	t4_restart_aneg(p->adapter, p->adapter->pf, p->tx_chan);
+	t4_restart_aneg(p->adapter, p->adapter->pf, p->lport);
 	return 0;
 }
 
@@ -440,11 +443,23 @@ static int from_fw_port_mod_type(enum fw_port_type port_type,
 		   port_type == FW_PORT_TYPE_CR4_QSFP ||
 		   port_type == FW_PORT_TYPE_CR_QSFP ||
 		   port_type == FW_PORT_TYPE_CR2_QSFP ||
-		   port_type == FW_PORT_TYPE_SFP28) {
+		   port_type == FW_PORT_TYPE_SFP28 ||
+		   port_type == FW_PORT_TYPE_SFP56 ||
+		   port_type == FW_PORT_TYPE_QSFP56 ||
+		   port_type == FW_PORT_TYPE_QSFP56_4_50G ||
+		   port_type == FW_PORT_TYPE_QSFP56_2_50G ||
+		   port_type == FW_PORT_TYPE_QSFP56_2_100G ||
+		   port_type == FW_PORT_TYPE_QSFPDD ||
+		   port_type == FW_PORT_TYPE_QSFPDD_2_200G ||
+		   port_type == FW_PORT_TYPE_QSFPDD_4_100G ||
+		   port_type == FW_PORT_TYPE_OSFP ||
+		   port_type == FW_PORT_TYPE_OSFP_2_200G) {
 		if (mod_type == FW_PORT_MOD_TYPE_LR ||
 		    mod_type == FW_PORT_MOD_TYPE_SR ||
 		    mod_type == FW_PORT_MOD_TYPE_ER ||
-		    mod_type == FW_PORT_MOD_TYPE_LRM)
+		    mod_type == FW_PORT_MOD_TYPE_DR ||
+		    mod_type == FW_PORT_MOD_TYPE_LRM ||
+		    mod_type == FW_PORT_MOD_TYPE_LR_SIMPLEX)
 			return PORT_FIBRE;
 		else if (mod_type == FW_PORT_MOD_TYPE_TWINAX_PASSIVE ||
 			 mod_type == FW_PORT_MOD_TYPE_TWINAX_ACTIVE)
@@ -453,7 +468,12 @@ static int from_fw_port_mod_type(enum fw_port_type port_type,
 			return PORT_OTHER;
 	} else if (port_type == FW_PORT_TYPE_KR4_100G ||
 		   port_type == FW_PORT_TYPE_KR_SFP28 ||
-		   port_type == FW_PORT_TYPE_KR_XLAUI) {
+		   port_type == FW_PORT_TYPE_KR_XLAUI ||
+		   port_type == FW_PORT_TYPE_KR_50G ||
+		   port_type == FW_PORT_TYPE_KR2_100G ||
+		   port_type == FW_PORT_TYPE_KR4_200G ||
+		   port_type == FW_PORT_TYPE_KR8_400G ||
+		   port_type == FW_PORT_TYPE_KR2_50G) {
 		return PORT_NONE;
 	}
 
@@ -490,9 +510,103 @@ static unsigned int speed_to_fw_caps(int speed)
 	return 0;
 }
 
+enum link_medium {
+	LINK_MEDIUM_NONE,
+	LINK_MEDIUM_TP,		/* plain copper baseT               */
+	LINK_MEDIUM_KR,		/* electrical backplane             */
+	LINK_MEDIUM_CR,		/* copper direct-attach (TwinAx)    */
+	LINK_MEDIUM_SR,
+	LINK_MEDIUM_LR,		/* also covers ER FR                */
+	LINK_MEDIUM_DR,
+	LINK_MEDIUM_LRM,
+};
+
+static bool fw_port_is_backplane(enum fw_port_type port_type)
+{
+	switch (port_type) {
+	case FW_PORT_TYPE_KX:
+	case FW_PORT_TYPE_KX4:
+	case FW_PORT_TYPE_BP_AP:
+	case FW_PORT_TYPE_BP4_AP:
+	case FW_PORT_TYPE_BP40_BA:
+	case FW_PORT_TYPE_KR:
+	case FW_PORT_TYPE_KR_50G:
+	case FW_PORT_TYPE_KR_SFP28:
+	case FW_PORT_TYPE_KR_XLAUI:
+	case FW_PORT_TYPE_KR2_100G:
+	case FW_PORT_TYPE_KR4_100G:
+	case FW_PORT_TYPE_KR4_200G:
+	case FW_PORT_TYPE_KR8_400G:
+	case FW_PORT_TYPE_KR2_50G:
+		return true;
+	default:
+		return false;
+	}
+}
+
+static bool fw_port_is_electrical_tp(enum fw_port_type port_type)
+{
+	switch (port_type) {
+	case FW_PORT_TYPE_BT_SGMII:
+	case FW_PORT_TYPE_BT_XFI:
+	case FW_PORT_TYPE_BT_XAUI:
+		return true;
+	default:
+		return false;
+	}
+}
+
+static bool fw_port_is_fixed_baset(enum fw_port_type port_type)
+{
+	switch (port_type) {
+	case FW_PORT_TYPE_FIBER_XFI:
+	case FW_PORT_TYPE_FIBER_XAUI:
+		return true;
+	default:
+		return fw_port_is_electrical_tp(port_type);
+	}
+}
+
+static int fw_port_class_bit(enum fw_port_type port_type)
+{
+	if (fw_port_is_backplane(port_type))
+		return ETHTOOL_LINK_MODE_Backplane_BIT;
+	if (fw_port_is_electrical_tp(port_type))
+		return ETHTOOL_LINK_MODE_TP_BIT;
+	return ETHTOOL_LINK_MODE_FIBRE_BIT;
+}
+
+static enum link_medium fw_port_medium(enum fw_port_type port_type,
+				       enum fw_port_module_type mod_type)
+{
+	if (fw_port_is_backplane(port_type))
+		return LINK_MEDIUM_KR;
+	if (fw_port_is_fixed_baset(port_type))
+		return LINK_MEDIUM_TP;
+
+	switch (mod_type) {
+	case FW_PORT_MOD_TYPE_TWINAX_PASSIVE:
+	case FW_PORT_MOD_TYPE_TWINAX_ACTIVE:
+		return LINK_MEDIUM_CR;
+	case FW_PORT_MOD_TYPE_SR:
+		return LINK_MEDIUM_SR;
+	case FW_PORT_MOD_TYPE_LR:
+	case FW_PORT_MOD_TYPE_ER:
+	case FW_PORT_MOD_TYPE_LR_SIMPLEX:
+		return LINK_MEDIUM_LR;
+	case FW_PORT_MOD_TYPE_DR:
+		return LINK_MEDIUM_DR;
+	case FW_PORT_MOD_TYPE_LRM:
+		return LINK_MEDIUM_LRM;
+	default:
+		return LINK_MEDIUM_NONE;	/* no module / unreadable */
+	}
+}
+
 /**
  *	fw_caps_to_lmm - translate Firmware to ethtool Link Mode Mask
  *	@port_type: Firmware Port Type
+ *	@mod_type: Firmware Module Type
  *	@fw_caps: Firmware Port Capabilities
  *	@link_mode_mask: ethtool Link Mode Mask
  *
@@ -500,114 +614,98 @@ static unsigned int speed_to_fw_caps(int speed)
  *	Link Mode Mask.
  */
 static void fw_caps_to_lmm(enum fw_port_type port_type,
+			   enum fw_port_module_type mod_type,
 			   fw_port_cap32_t fw_caps,
 			   unsigned long *link_mode_mask)
 {
-	#define SET_LMM(__lmm_name) \
-		do { \
-			__set_bit(ETHTOOL_LINK_MODE_ ## __lmm_name ## _BIT, \
-				  link_mode_mask); \
-		} while (0)
+	enum link_medium medium = fw_port_medium(port_type, mod_type);
 
 	#define FW_CAPS_TO_LMM(__fw_name, __lmm_name) \
 		do { \
 			if (fw_caps & FW_PORT_CAP32_ ## __fw_name) \
-				SET_LMM(__lmm_name); \
+				__set_bit(ETHTOOL_LINK_MODE_ ## __lmm_name ## _BIT, \
+					  link_mode_mask); \
 		} while (0)
 
-	switch (port_type) {
-	case FW_PORT_TYPE_BT_SGMII:
-	case FW_PORT_TYPE_BT_XFI:
-	case FW_PORT_TYPE_BT_XAUI:
-		SET_LMM(TP);
-		FW_CAPS_TO_LMM(SPEED_100M, 100baseT_Full);
-		FW_CAPS_TO_LMM(SPEED_1G, 1000baseT_Full);
-		FW_CAPS_TO_LMM(SPEED_10G, 10000baseT_Full);
-		break;
-
-	case FW_PORT_TYPE_KX4:
-	case FW_PORT_TYPE_KX:
-		SET_LMM(Backplane);
-		FW_CAPS_TO_LMM(SPEED_1G, 1000baseKX_Full);
-		FW_CAPS_TO_LMM(SPEED_10G, 10000baseKX4_Full);
-		break;
+	if (medium != LINK_MEDIUM_NONE)
+		__set_bit(fw_port_class_bit(port_type), link_mode_mask);
 
-	case FW_PORT_TYPE_KR:
-		SET_LMM(Backplane);
-		FW_CAPS_TO_LMM(SPEED_10G, 10000baseKR_Full);
-		break;
-
-	case FW_PORT_TYPE_BP_AP:
-		SET_LMM(Backplane);
-		FW_CAPS_TO_LMM(SPEED_1G, 1000baseKX_Full);
-		FW_CAPS_TO_LMM(SPEED_10G, 10000baseR_FEC);
-		FW_CAPS_TO_LMM(SPEED_10G, 10000baseKR_Full);
-		break;
-
-	case FW_PORT_TYPE_BP4_AP:
-		SET_LMM(Backplane);
-		FW_CAPS_TO_LMM(SPEED_1G, 1000baseKX_Full);
-		FW_CAPS_TO_LMM(SPEED_10G, 10000baseR_FEC);
-		FW_CAPS_TO_LMM(SPEED_10G, 10000baseKR_Full);
-		FW_CAPS_TO_LMM(SPEED_10G, 10000baseKX4_Full);
-		break;
-
-	case FW_PORT_TYPE_FIBER_XFI:
-	case FW_PORT_TYPE_FIBER_XAUI:
-	case FW_PORT_TYPE_SFP:
-	case FW_PORT_TYPE_QSFP_10G:
-	case FW_PORT_TYPE_QSA:
-		SET_LMM(FIBRE);
-		FW_CAPS_TO_LMM(SPEED_1G, 1000baseT_Full);
-		FW_CAPS_TO_LMM(SPEED_10G, 10000baseT_Full);
+	switch (medium) {
+	case LINK_MEDIUM_TP:
+		FW_CAPS_TO_LMM(SPEED_100M, 100baseT_Full);
+		FW_CAPS_TO_LMM(SPEED_1G,   1000baseT_Full);
+		FW_CAPS_TO_LMM(SPEED_10G,  10000baseT_Full);
 		break;
 
-	case FW_PORT_TYPE_BP40_BA:
-	case FW_PORT_TYPE_QSFP:
-		SET_LMM(FIBRE);
-		FW_CAPS_TO_LMM(SPEED_1G, 1000baseT_Full);
-		FW_CAPS_TO_LMM(SPEED_10G, 10000baseT_Full);
-		FW_CAPS_TO_LMM(SPEED_40G, 40000baseSR4_Full);
+	case LINK_MEDIUM_KR:
+		FW_CAPS_TO_LMM(SPEED_1G,   1000baseKX_Full);
+		FW_CAPS_TO_LMM(SPEED_10G,  10000baseKX4_Full);
+		FW_CAPS_TO_LMM(SPEED_10G,  10000baseR_FEC);
+		FW_CAPS_TO_LMM(SPEED_10G,  10000baseKR_Full);
+		FW_CAPS_TO_LMM(SPEED_25G,  25000baseKR_Full);
+		FW_CAPS_TO_LMM(SPEED_40G,  40000baseKR4_Full);
+		FW_CAPS_TO_LMM(SPEED_50G,  50000baseKR_Full);
+		FW_CAPS_TO_LMM(SPEED_50G,  50000baseKR2_Full);
+		FW_CAPS_TO_LMM(SPEED_100G, 100000baseKR2_Full);
+		FW_CAPS_TO_LMM(SPEED_100G, 100000baseKR4_Full);
+		FW_CAPS_TO_LMM(SPEED_200G, 200000baseKR4_Full);
+		FW_CAPS_TO_LMM(SPEED_400G, 400000baseKR8_Full);
 		break;
 
-	case FW_PORT_TYPE_CR_QSFP:
-	case FW_PORT_TYPE_SFP28:
-		SET_LMM(FIBRE);
-		FW_CAPS_TO_LMM(SPEED_1G, 1000baseT_Full);
-		FW_CAPS_TO_LMM(SPEED_10G, 10000baseT_Full);
-		FW_CAPS_TO_LMM(SPEED_25G, 25000baseCR_Full);
+	case LINK_MEDIUM_CR:
+		FW_CAPS_TO_LMM(SPEED_1G,   1000baseT_Full);
+		FW_CAPS_TO_LMM(SPEED_10G,  10000baseCR_Full);
+		FW_CAPS_TO_LMM(SPEED_25G,  25000baseCR_Full);
+		FW_CAPS_TO_LMM(SPEED_40G,  40000baseCR4_Full);
+		FW_CAPS_TO_LMM(SPEED_50G,  50000baseCR_Full);
+		FW_CAPS_TO_LMM(SPEED_50G,  50000baseCR2_Full);
+		FW_CAPS_TO_LMM(SPEED_100G, 100000baseCR2_Full);
+		FW_CAPS_TO_LMM(SPEED_100G, 100000baseCR4_Full);
+		FW_CAPS_TO_LMM(SPEED_200G, 200000baseCR4_Full);
+		FW_CAPS_TO_LMM(SPEED_400G, 400000baseCR8_Full);
 		break;
 
-	case FW_PORT_TYPE_KR_SFP28:
-		SET_LMM(Backplane);
-		FW_CAPS_TO_LMM(SPEED_1G, 1000baseT_Full);
-		FW_CAPS_TO_LMM(SPEED_10G, 10000baseKR_Full);
-		FW_CAPS_TO_LMM(SPEED_25G, 25000baseKR_Full);
+	case LINK_MEDIUM_SR:
+		FW_CAPS_TO_LMM(SPEED_1G,   1000baseT_Full);
+		FW_CAPS_TO_LMM(SPEED_10G,  10000baseSR_Full);
+		FW_CAPS_TO_LMM(SPEED_25G,  25000baseSR_Full);
+		FW_CAPS_TO_LMM(SPEED_40G,  40000baseSR4_Full);
+		FW_CAPS_TO_LMM(SPEED_50G,  50000baseSR_Full);
+		FW_CAPS_TO_LMM(SPEED_50G,  50000baseSR2_Full);
+		FW_CAPS_TO_LMM(SPEED_100G, 100000baseSR2_Full);
+		FW_CAPS_TO_LMM(SPEED_100G, 100000baseSR4_Full);
+		FW_CAPS_TO_LMM(SPEED_200G, 200000baseSR4_Full);
+		FW_CAPS_TO_LMM(SPEED_400G, 400000baseSR8_Full);
 		break;
 
-	case FW_PORT_TYPE_KR_XLAUI:
-		SET_LMM(Backplane);
-		FW_CAPS_TO_LMM(SPEED_1G, 1000baseKX_Full);
-		FW_CAPS_TO_LMM(SPEED_10G, 10000baseKR_Full);
-		FW_CAPS_TO_LMM(SPEED_40G, 40000baseKR4_Full);
+	case LINK_MEDIUM_LR:
+		FW_CAPS_TO_LMM(SPEED_1G,   1000baseT_Full);
+		FW_CAPS_TO_LMM(SPEED_10G,  10000baseLR_Full);
+		/* ethtool has no 25G LR/ER link mode; report 25000baseSR so
+		 * the speed stays visible and can be advertised.
+		 */
+		FW_CAPS_TO_LMM(SPEED_25G,  25000baseSR_Full);
+		FW_CAPS_TO_LMM(SPEED_40G,  40000baseLR4_Full);
+		FW_CAPS_TO_LMM(SPEED_50G,  50000baseLR_ER_FR_Full);
+		FW_CAPS_TO_LMM(SPEED_100G, 100000baseLR2_ER2_FR2_Full);
+		FW_CAPS_TO_LMM(SPEED_100G, 100000baseLR4_ER4_Full);
+		FW_CAPS_TO_LMM(SPEED_200G, 200000baseLR4_ER4_FR4_Full);
+		FW_CAPS_TO_LMM(SPEED_400G, 400000baseLR8_ER8_FR8_Full);
 		break;
 
-	case FW_PORT_TYPE_CR2_QSFP:
-		SET_LMM(FIBRE);
-		FW_CAPS_TO_LMM(SPEED_50G, 50000baseSR2_Full);
+	case LINK_MEDIUM_DR:
+		FW_CAPS_TO_LMM(SPEED_50G,  50000baseDR_Full);
+		FW_CAPS_TO_LMM(SPEED_100G, 100000baseDR2_Full);
+		FW_CAPS_TO_LMM(SPEED_200G, 200000baseDR4_Full);
+		FW_CAPS_TO_LMM(SPEED_400G, 400000baseDR8_Full);
 		break;
 
-	case FW_PORT_TYPE_KR4_100G:
-	case FW_PORT_TYPE_CR4_QSFP:
-		SET_LMM(FIBRE);
-		FW_CAPS_TO_LMM(SPEED_1G,  1000baseT_Full);
-		FW_CAPS_TO_LMM(SPEED_10G, 10000baseKR_Full);
-		FW_CAPS_TO_LMM(SPEED_40G, 40000baseSR4_Full);
-		FW_CAPS_TO_LMM(SPEED_25G, 25000baseCR_Full);
-		FW_CAPS_TO_LMM(SPEED_50G, 50000baseCR2_Full);
-		FW_CAPS_TO_LMM(SPEED_100G, 100000baseCR4_Full);
+	case LINK_MEDIUM_LRM:
+		FW_CAPS_TO_LMM(SPEED_1G,   1000baseT_Full);
+		FW_CAPS_TO_LMM(SPEED_10G,  10000baseLRM_Full);
 		break;
 
+	case LINK_MEDIUM_NONE:
 	default:
 		break;
 	}
@@ -616,7 +714,7 @@ static void fw_caps_to_lmm(enum fw_port_type port_type,
 		FW_CAPS_TO_LMM(FEC_RS, FEC_RS);
 		FW_CAPS_TO_LMM(FEC_BASER_RS, FEC_BASER);
 	} else {
-		SET_LMM(FEC_NONE);
+		__set_bit(ETHTOOL_LINK_MODE_FEC_NONE_BIT, link_mode_mask);
 	}
 
 	FW_CAPS_TO_LMM(ANEG, Autoneg);
@@ -624,7 +722,6 @@ static void fw_caps_to_lmm(enum fw_port_type port_type,
 	FW_CAPS_TO_LMM(802_3_ASM_DIR, Asym_Pause);
 
 	#undef FW_CAPS_TO_LMM
-	#undef SET_LMM
 }
 
 /**
@@ -648,11 +745,49 @@ static unsigned int lmm_to_fw_caps(const unsigned long *link_mode_mask)
 
 	LMM_TO_FW_CAPS(100baseT_Full, SPEED_100M);
 	LMM_TO_FW_CAPS(1000baseT_Full, SPEED_1G);
+	LMM_TO_FW_CAPS(1000baseKX_Full, SPEED_1G);
 	LMM_TO_FW_CAPS(10000baseT_Full, SPEED_10G);
-	LMM_TO_FW_CAPS(40000baseSR4_Full, SPEED_40G);
+	LMM_TO_FW_CAPS(10000baseKX4_Full, SPEED_10G);
+	LMM_TO_FW_CAPS(10000baseR_FEC, SPEED_10G);
+	LMM_TO_FW_CAPS(10000baseKR_Full, SPEED_10G);
+	LMM_TO_FW_CAPS(10000baseCR_Full, SPEED_10G);
+	LMM_TO_FW_CAPS(10000baseSR_Full, SPEED_10G);
+	LMM_TO_FW_CAPS(10000baseLR_Full, SPEED_10G);
+	LMM_TO_FW_CAPS(10000baseLRM_Full, SPEED_10G);
+	LMM_TO_FW_CAPS(25000baseKR_Full, SPEED_25G);
 	LMM_TO_FW_CAPS(25000baseCR_Full, SPEED_25G);
+	LMM_TO_FW_CAPS(25000baseSR_Full, SPEED_25G);
+	LMM_TO_FW_CAPS(40000baseKR4_Full, SPEED_40G);
+	LMM_TO_FW_CAPS(40000baseCR4_Full, SPEED_40G);
+	LMM_TO_FW_CAPS(40000baseSR4_Full, SPEED_40G);
+	LMM_TO_FW_CAPS(40000baseLR4_Full, SPEED_40G);
+	LMM_TO_FW_CAPS(50000baseKR_Full, SPEED_50G);
+	LMM_TO_FW_CAPS(50000baseKR2_Full, SPEED_50G);
+	LMM_TO_FW_CAPS(50000baseCR_Full, SPEED_50G);
 	LMM_TO_FW_CAPS(50000baseCR2_Full, SPEED_50G);
+	LMM_TO_FW_CAPS(50000baseSR_Full, SPEED_50G);
+	LMM_TO_FW_CAPS(50000baseSR2_Full, SPEED_50G);
+	LMM_TO_FW_CAPS(50000baseLR_ER_FR_Full, SPEED_50G);
+	LMM_TO_FW_CAPS(50000baseDR_Full, SPEED_50G);
+	LMM_TO_FW_CAPS(100000baseKR2_Full, SPEED_100G);
+	LMM_TO_FW_CAPS(100000baseKR4_Full, SPEED_100G);
+	LMM_TO_FW_CAPS(100000baseCR2_Full, SPEED_100G);
 	LMM_TO_FW_CAPS(100000baseCR4_Full, SPEED_100G);
+	LMM_TO_FW_CAPS(100000baseSR2_Full, SPEED_100G);
+	LMM_TO_FW_CAPS(100000baseSR4_Full, SPEED_100G);
+	LMM_TO_FW_CAPS(100000baseLR2_ER2_FR2_Full, SPEED_100G);
+	LMM_TO_FW_CAPS(100000baseLR4_ER4_Full, SPEED_100G);
+	LMM_TO_FW_CAPS(100000baseDR2_Full, SPEED_100G);
+	LMM_TO_FW_CAPS(200000baseKR4_Full, SPEED_200G);
+	LMM_TO_FW_CAPS(200000baseCR4_Full, SPEED_200G);
+	LMM_TO_FW_CAPS(200000baseSR4_Full, SPEED_200G);
+	LMM_TO_FW_CAPS(200000baseLR4_ER4_FR4_Full, SPEED_200G);
+	LMM_TO_FW_CAPS(200000baseDR4_Full, SPEED_200G);
+	LMM_TO_FW_CAPS(400000baseKR8_Full, SPEED_400G);
+	LMM_TO_FW_CAPS(400000baseCR8_Full, SPEED_400G);
+	LMM_TO_FW_CAPS(400000baseSR8_Full, SPEED_400G);
+	LMM_TO_FW_CAPS(400000baseLR8_ER8_FR8_Full, SPEED_400G);
+	LMM_TO_FW_CAPS(400000baseDR8_Full, SPEED_400G);
 
 	#undef LMM_TO_FW_CAPS
 
@@ -688,14 +823,14 @@ static int get_link_ksettings(struct net_device *dev,
 		base->mdio_support = 0;
 	}
 
-	fw_caps_to_lmm(pi->port_type, pi->link_cfg.pcaps,
+	fw_caps_to_lmm(pi->port_type, pi->mod_type, pi->link_cfg.pcaps,
 		       link_ksettings->link_modes.supported);
-	fw_caps_to_lmm(pi->port_type,
+	fw_caps_to_lmm(pi->port_type, pi->mod_type,
 		       t4_link_acaps(pi->adapter,
 				     pi->lport,
 				     &pi->link_cfg),
 		       link_ksettings->link_modes.advertising);
-	fw_caps_to_lmm(pi->port_type, pi->link_cfg.lpacaps,
+	fw_caps_to_lmm(pi->port_type, pi->mod_type, pi->link_cfg.lpacaps,
 		       link_ksettings->link_modes.lp_advertising);
 
 	base->speed = (netif_carrier_ok(dev)
@@ -752,7 +887,7 @@ static int set_link_ksettings(struct net_device *dev,
 	/* If the firmware rejects the Link Configuration request, back out
 	 * the changes and report the error.
 	 */
-	ret = t4_link_l1cfg(pi->adapter, pi->adapter->mbox, pi->tx_chan, lc);
+	ret = t4_link_l1cfg(pi->adapter, pi->adapter->mbox, pi->lport, lc);
 	if (ret)
 		*lc = old_lc;
 
@@ -800,7 +935,7 @@ static inline unsigned int eth_to_cc_fec(unsigned int eth_fec)
 {
 	unsigned int cc_fec = 0;
 
-	if (eth_fec & ETHTOOL_FEC_OFF)
+	if (eth_fec == ETHTOOL_FEC_OFF)
 		return cc_fec;
 
 	if (eth_fec & ETHTOOL_FEC_AUTO)
@@ -850,8 +985,7 @@ static int set_fecparam(struct net_device *dev, struct ethtool_fecparam *fec)
 	 * effort.  If it fails, revert the attempted change.
 	 */
 	lc->requested_fec = eth_to_cc_fec(fec->fec);
-	ret = t4_link_l1cfg(pi->adapter, pi->adapter->mbox,
-			    pi->tx_chan, lc);
+	ret = t4_link_l1cfg(pi->adapter, pi->adapter->mbox, pi->lport, lc);
 	if (ret)
 		*lc = old_lc;
 	return ret;
@@ -885,8 +1019,7 @@ static int set_pauseparam(struct net_device *dev,
 	if (epause->tx_pause)
 		lc->requested_fc |= PAUSE_TX;
 	if (netif_running(dev))
-		return t4_link_l1cfg(p->adapter, p->adapter->mbox, p->tx_chan,
-				     lc);
+		return t4_link_l1cfg(p->adapter, p->adapter->mbox, p->lport, lc);
 	return 0;
 }
 
@@ -1576,6 +1709,11 @@ static int get_ts_info(struct net_device *dev, struct kernel_ethtool_ts_info *ts
 	return 0;
 }
 
+static u32 get_rss_key_size(struct net_device *dev)
+{
+	return RSS_HASH_KEY_SIZE;
+}
+
 static u32 get_rss_table_size(struct net_device *dev)
 {
 	const struct port_info *pi = netdev_priv(dev);
@@ -1590,8 +1728,21 @@ static int get_rss_table(struct net_device *dev,
 	unsigned int n = pi->rss_size;
 
 	rxfh->hfunc = ETH_RSS_HASH_TOP;
+
+	if (rxfh->key) {
+		u32 key[10];
+
+		t4_read_rss_key(pi->adapter, key, true);
+		/* key[] holds TP_RSS_SECRET_KEY0..9.  The ethtool key is a
+		 * byte stream that starts with the MSB of TP_RSS_SECRET_KEY9.
+		 */
+		for (int i = 0; i < 10; i++)
+			put_unaligned_be32(key[9 - i], rxfh->key + i * 4);
+	}
+
 	if (!rxfh->indir)
 		return 0;
+
 	while (n--)
 		rxfh->indir[n] = pi->rss[n];
 	return 0;
@@ -1607,22 +1758,33 @@ static int set_rss_table(struct net_device *dev,
 	/* We require at least one supported parameter to be changed and no
 	 * change in any of the unsupported parameters
 	 */
-	if (rxfh->key ||
-	    (rxfh->hfunc != ETH_RSS_HASH_NO_CHANGE &&
-	     rxfh->hfunc != ETH_RSS_HASH_TOP))
+	if (rxfh->hfunc != ETH_RSS_HASH_NO_CHANGE &&
+	    rxfh->hfunc != ETH_RSS_HASH_TOP)
 		return -EOPNOTSUPP;
-	if (!rxfh->indir)
-		return 0;
 
-	/* Interface must be brought up atleast once */
-	if (pi->adapter->flags & CXGB4_FULL_INIT_DONE) {
-		for (i = 0; i < pi->rss_size; i++)
-			pi->rss[i] = rxfh->indir[i];
+	/* The indirection table can only be programmed once the interface
+	 * has been brought up at least once.  Check this before touching
+	 * the key so that a rejected request leaves the hardware unchanged.
+	 */
+	if (rxfh->indir && !(pi->adapter->flags & CXGB4_FULL_INIT_DONE))
+		return -EPERM;
+
+	if (rxfh->key) {
+		u32 key[10];
 
-		return cxgb4_write_rss(pi, pi->rss);
+		/* Same byte order as get_rss_table() */
+		for (i = 0; i < 10; i++)
+			key[i] = get_unaligned_be32(rxfh->key + (9 - i) * 4);
+		t4_write_rss_key(pi->adapter, key, -1, true);
 	}
 
-	return -EPERM;
+	if (!rxfh->indir)
+		return 0;
+
+	for (i = 0; i < pi->rss_size; i++)
+		pi->rss[i] = rxfh->indir[i];
+
+	return cxgb4_write_rss(pi, pi->rss);
 }
 
 static struct filter_entry *cxgb4_get_filter_entry(struct adapter *adap,
@@ -2007,11 +2169,18 @@ static bool cxgb4_fw_mod_type_info_available(unsigned int fw_mod_type)
 		fw_mod_type != FW_PORT_MOD_TYPE_ERROR);
 }
 
+/* SFF-8024 Identifier, byte 0 of the module EEPROM */
+#define SFF_ID_ADDR			0x0
+#define SFF_ID_LEN			1
+#define SFF_ID_QSFP_DD			0x18
+#define SFF_ID_OSFP			0x19
+#define SFF_ID_QSFP_PLUS_CMIS		0x1e
+
 static int cxgb4_get_module_info(struct net_device *dev,
 				 struct ethtool_modinfo *modinfo)
 {
 	struct port_info *pi = netdev_priv(dev);
-	u8 sff8472_comp, sff_diag_type, sff_rev;
+	u8 sff8472_comp, sff_diag_type, sff_rev, sff_id;
 	struct adapter *adapter = pi->adapter;
 	int ret;
 
@@ -2022,12 +2191,13 @@ static int cxgb4_get_module_info(struct net_device *dev,
 	case FW_PORT_TYPE_SFP:
 	case FW_PORT_TYPE_QSA:
 	case FW_PORT_TYPE_SFP28:
-		ret = t4_i2c_rd(adapter, adapter->mbox, pi->tx_chan,
+	case FW_PORT_TYPE_SFP56:
+		ret = t4_i2c_rd(adapter, adapter->mbox, pi->lport,
 				I2C_DEV_ADDR_A0, SFF_8472_COMP_ADDR,
 				SFF_8472_COMP_LEN, &sff8472_comp);
 		if (ret)
 			return ret;
-		ret = t4_i2c_rd(adapter, adapter->mbox, pi->tx_chan,
+		ret = t4_i2c_rd(adapter, adapter->mbox, pi->lport,
 				I2C_DEV_ADDR_A0, SFP_DIAG_TYPE_ADDR,
 				SFP_DIAG_TYPE_LEN, &sff_diag_type);
 		if (ret)
@@ -2046,11 +2216,34 @@ static int cxgb4_get_module_info(struct net_device *dev,
 		break;
 
 	case FW_PORT_TYPE_QSFP:
+	case FW_PORT_TYPE_QSFP56:
+	case FW_PORT_TYPE_QSFP56_4_50G:
+	case FW_PORT_TYPE_QSFP56_2_50G:
+	case FW_PORT_TYPE_QSFP56_2_100G:
+	case FW_PORT_TYPE_QSFPDD:
+	case FW_PORT_TYPE_QSFPDD_2_200G:
+	case FW_PORT_TYPE_QSFPDD_4_100G:
+	case FW_PORT_TYPE_OSFP:
+	case FW_PORT_TYPE_OSFP_2_200G:
 	case FW_PORT_TYPE_QSFP_10G:
 	case FW_PORT_TYPE_CR_QSFP:
 	case FW_PORT_TYPE_CR2_QSFP:
 	case FW_PORT_TYPE_CR4_QSFP:
-		ret = t4_i2c_rd(adapter, adapter->mbox, pi->tx_chan,
+		ret = t4_i2c_rd(adapter, adapter->mbox, pi->lport,
+				I2C_DEV_ADDR_A0, SFF_ID_ADDR,
+				SFF_ID_LEN, &sff_id);
+		if (ret)
+			return ret;
+		/* CMIS modules have no legacy ethtool module type, their
+		 * EEPROM is read with get_module_eeprom_by_page(). The
+		 * Identifier is checked rather than the port type, as a
+		 * QSFP-DD cage also accepts SFF-8636 QSFP modules.
+		 */
+		if (sff_id == SFF_ID_QSFP_DD || sff_id == SFF_ID_OSFP ||
+		    sff_id == SFF_ID_QSFP_PLUS_CMIS)
+			return -EOPNOTSUPP;
+
+		ret = t4_i2c_rd(adapter, adapter->mbox, pi->lport,
 				I2C_DEV_ADDR_A0, SFF_REV_ADDR,
 				SFF_REV_LEN, &sff_rev);
 		/* For QSFP type ports, revision value >= 3
@@ -2083,14 +2276,14 @@ static int cxgb4_get_module_eeprom(struct net_device *dev,
 
 	memset(data, 0, eprom->len);
 	if (offset + len <= I2C_PAGE_SIZE)
-		return t4_i2c_rd(adapter, adapter->mbox, pi->tx_chan,
+		return t4_i2c_rd(adapter, adapter->mbox, pi->lport,
 				 I2C_DEV_ADDR_A0, offset, len, data);
 
 	/* offset + len spans 0xa0 and 0xa1 pages */
 	if (offset <= I2C_PAGE_SIZE) {
 		/* read 0xa0 page */
 		len = I2C_PAGE_SIZE - offset;
-		ret =  t4_i2c_rd(adapter, adapter->mbox, pi->tx_chan,
+		ret =  t4_i2c_rd(adapter, adapter->mbox, pi->lport,
 				 I2C_DEV_ADDR_A0, offset, len, data);
 		if (ret)
 			return ret;
@@ -2101,10 +2294,97 @@ static int cxgb4_get_module_eeprom(struct net_device *dev,
 		len = eprom->len - len;
 	}
 	/* Read additional optical diagnostics from page 0xa2 if supported */
-	return t4_i2c_rd(adapter, adapter->mbox, pi->tx_chan, I2C_DEV_ADDR_A2,
+	return t4_i2c_rd(adapter, adapter->mbox, pi->lport, I2C_DEV_ADDR_A2,
 			 offset, len, &data[eprom->len - len]);
 }
 
+static int
+cxgb4_get_module_eeprom_by_page(struct net_device *dev,
+				const struct ethtool_module_eeprom *page_data,
+				struct netlink_ext_ack *extack)
+{
+	unsigned int devid = page_data->i2c_address << 1;
+	struct port_info *pi = netdev_priv(dev);
+	struct adapter *adapter = pi->adapter;
+	bool select_page;
+	int ret, ret2;
+	bool paged;
+	u8 page;
+
+	if (!cxgb4_fw_mod_type_info_available(pi->mod_type)) {
+		NL_SET_ERR_MSG_MOD(extack, "No module present");
+		return -ENODEV;
+	}
+
+	switch (pi->port_type) {
+	case FW_PORT_TYPE_SFP:
+	case FW_PORT_TYPE_QSA:
+	case FW_PORT_TYPE_SFP28:
+	case FW_PORT_TYPE_SFP56:
+		/* SFF-8472: flat memory at A0h and A2h, byte 127 of A0h
+		 * is vendor data, not a page select register.
+		 */
+		paged = false;
+		break;
+	case FW_PORT_TYPE_QSFP:
+	case FW_PORT_TYPE_QSFP56:
+	case FW_PORT_TYPE_QSFP56_4_50G:
+	case FW_PORT_TYPE_QSFP56_2_50G:
+	case FW_PORT_TYPE_QSFP56_2_100G:
+	case FW_PORT_TYPE_QSFPDD:
+	case FW_PORT_TYPE_QSFPDD_2_200G:
+	case FW_PORT_TYPE_QSFPDD_4_100G:
+	case FW_PORT_TYPE_OSFP:
+	case FW_PORT_TYPE_OSFP_2_200G:
+	case FW_PORT_TYPE_QSFP_10G:
+	case FW_PORT_TYPE_CR_QSFP:
+	case FW_PORT_TYPE_CR2_QSFP:
+	case FW_PORT_TYPE_CR4_QSFP:
+		/* SFF-8636 and CMIS: upper page selected by byte 127 */
+		paged = true;
+		break;
+	default:
+		return -EOPNOTSUPP;
+	}
+
+	if (page_data->bank) {
+		NL_SET_ERR_MSG_MOD(extack, "Module EEPROM banks are not supported");
+		return -EOPNOTSUPP;
+	}
+
+	if (page_data->page && !paged) {
+		NL_SET_ERR_MSG_MOD(extack, "Module EEPROM is not paged");
+		return -EOPNOTSUPP;
+	}
+
+	/* Bytes 0-127 always map to page 0. For the upper half, select the
+	 * page even when it is 0, as firmware may have left another page
+	 * selected.
+	 */
+	select_page = paged && page_data->offset >= 128;
+	if (select_page) {
+		page = page_data->page;
+		ret = t4_i2c_wr(adapter, adapter->mbox, pi->lport, devid,
+				CMIS_PAGE_SELECT_REG, 1, &page);
+		if (ret)
+			return ret;
+	}
+
+	ret = t4_i2c_rd(adapter, adapter->mbox, pi->lport, devid,
+			page_data->offset, page_data->length, page_data->data);
+
+	/* Restore page 0 for cxgb4_get_module_eeprom() */
+	if (select_page && page_data->page) {
+		page = 0;
+		ret2 = t4_i2c_wr(adapter, adapter->mbox, pi->lport, devid,
+				 CMIS_PAGE_SELECT_REG, 1, &page);
+		if (!ret)
+			ret = ret2;
+	}
+
+	return ret ? ret : page_data->length;
+}
+
 static u32 cxgb4_get_priv_flags(struct net_device *netdev)
 {
 	struct port_info *pi = netdev_priv(netdev);
@@ -2205,6 +2485,7 @@ static const struct ethtool_ops cxgb_ethtool_ops = {
 	.get_rxnfc         = get_rxnfc,
 	.set_rxnfc         = set_rxnfc,
 	.get_rx_ring_count = get_rx_ring_count,
+	.get_rxfh_key_size = get_rss_key_size,
 	.get_rxfh_indir_size = get_rss_table_size,
 	.get_rxfh	   = get_rss_table,
 	.set_rxfh	   = set_rss_table,
@@ -2217,6 +2498,7 @@ static const struct ethtool_ops cxgb_ethtool_ops = {
 	.get_dump_data     = get_dump_data,
 	.get_module_info   = cxgb4_get_module_info,
 	.get_module_eeprom = cxgb4_get_module_eeprom,
+	.get_module_eeprom_by_page  = cxgb4_get_module_eeprom_by_page,
 	.get_priv_flags    = cxgb4_get_priv_flags,
 	.set_priv_flags    = cxgb4_set_priv_flags,
 };
-- 
2.39.1


  parent reply	other threads:[~2026-12-01 12:45 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 22:15 [PATCH net-next v6 00/12] cxgb4: Add T7 adapter support Potnuri Bharat Teja
2026-12-01 22:15 ` [PATCH net-next v6 01/12] cxgb4: add T7 hardware definitions and firmware interfaces Potnuri Bharat Teja
2026-12-01 22:15 ` [PATCH net-next v6 02/12] cxgb4: rework the interrupt handling framework Potnuri Bharat Teja
2026-12-01 22:15 ` [PATCH net-next v6 03/12] cxgb4: add T7 hardware management support Potnuri Bharat Teja
2026-12-01 22:15 ` [PATCH net-next v6 04/12] cxgb4: move PCI device management into cxgb4_pci.c and rework driver helpers Potnuri Bharat Teja
2026-12-01 22:15 ` [PATCH net-next v6 05/12] cxgb4: add T7 support to the main driver Potnuri Bharat Teja
2026-12-01 22:15 ` [PATCH net-next v6 06/12] cxgb4: update PTP register access for T7 Potnuri Bharat Teja
2026-12-01 22:15 ` Potnuri Bharat Teja [this message]
2026-12-01 22:15 ` [PATCH net-next v6 08/12] cxgb4: Add T7 support to the filter infrastructure Potnuri Bharat Teja
2026-12-01 22:15 ` [PATCH net-next v6 09/12] cxgb4: Add indirect register definitions for T7 Potnuri Bharat Teja
2026-12-01 22:15 ` [PATCH net-next v6 10/12] cxgb4: extend CUDBG support for T7 adapters Potnuri Bharat Teja
2026-12-01 22:15 ` [PATCH net-next v6 11/12] cxgb4: extend debugfs " Potnuri Bharat Teja
2026-12-01 22:15 ` [PATCH net-next v6 12/12] cxgb4: select ULD Tx and control queues by TID on T7 Potnuri Bharat Teja

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=20261201221556.251018-8-bharat@chelsio.com \
    --to=bharat@chelsio.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=harshitha.vr@chelsio.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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