Skip to contentSkip to conversation

cxgb4: Add T7 adapter support

PATCH Superseded Potnuri Bharat Teja 2 participants 13 messages Oct 22

Subsystems (3)
lore
Share & tools
lore

Potnuri Bharat Teja

author maintainer
#0 lore raw

v5 cover cxgb4: Add T7 adapter support

This series adds support for Chelsio T7 adapters to the cxgb4 driver.

The series extends the driver core to recognize and initialize T7 devices, adds support for T7-specific hardware resources and firmware interfaces, updates PCI initialization and resource management, and enables adapter operation through the existing networking stack.

In addition, the series updates several auxiliary components to support the T7 architecture, including PTP, ethtool, filter management, CUDBG, and debugfs. Support is also added for T7 multicore debugging and diagnostic infrastructure.

Testing:
1. Each patch compiled individually
2. Driver probe and initialization on T7 adapters
3. Link bring-up
4. ping
5. NIC tx and rx traffic (using neperf and iperf)
6. Reload the driver multiple times

checkpatch.pl:
- Patch 4: "missing sentinel in ID array" and "Macros with complex values should be enclosed in parentheses" warnings are reported for the macro-generated PCI device ID table. The generated table includes the required terminating entry. This error is a false-positive.
- Patch 7: Several "Avoid CamelCase" warnings are reported for standard ethtool link mode identifiers (e.g. 1000baseKX_Full, 100000baseCR4_Full), which are kernel-defined names and cannot be renamed.

Potnuri Bharat Teja (12):
cxgb4: add T7 hardware definitions and firmware interfaces
cxgb4: rework the interrupt handling framework
cxgb4: add T7 hardware management support
cxgb4: move PCI device management into cxgb4_pci.c and rework driver
helpers
cxgb4: add T7 support to the main driver
cxgb4: update PTP register access for T7
cxgb4: extend ethtool support for T7 adapters
cxgb4: Add T7 support to the filter infrastructure.
cxgb4: Add indirect register definitions for T7
cxgb4: extend CUDBG support for T7 adapters
cxgb4: extend debugfs support for T7 adapters
cxgb4: select ULD Tx and control queues by TID on T7

---
v4 -> v5
- fixed the build error reported by the Kernel Test Robot.
---
v3 -> v4
- fixed buildbot errors
---
v2 -> v3:
- rebase the patches to tot
- add ULD multicore support changes
v1 -> v2:
- split the v1 hardware management patch in two; the interrupt handling rework is not T7 specific and now lands first
- merged the PCI management patch into the one that wires it up, so each commit builds what it adds, then split off the T7 changes
- fixed per patch build failures reported by the kernel test robot
- fixed: shared static intr_info structures mutated per adapter; t4_handle_intr() clearing only enabled cause bits; IPv4 address byte order in mk_act_open_req(); cxgb4_read_tpte() sleeping under xa_lock_irq(); missing CAP_NET_ADMIN on the cudbg ioctl read commands; CXGB4_DEV_ENABLED set too late in probe
- dropped the SYN-only filter field and the unused cxgb4_pci helpers
---

 drivers/net/ethernet/chelsio/cxgb4/Makefile   |    2 +-
 drivers/net/ethernet/chelsio/cxgb4/clip_tbl.c |   10 +-
 .../net/ethernet/chelsio/cxgb4/cudbg_entity.h |  114 +-
 drivers/net/ethernet/chelsio/cxgb4/cudbg_if.h |   56 +-
 .../ethernet/chelsio/cxgb4/cudbg_indir_reg.h  |   43 +
 .../chelsio/cxgb4/cudbg_indir_reg_t7.h        | 1113 +++
 .../net/ethernet/chelsio/cxgb4/cudbg_lib.c    | 1088 ++-
 .../net/ethernet/chelsio/cxgb4/cudbg_lib.h    |   60 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h    |  148 +-
 .../net/ethernet/chelsio/cxgb4/cxgb4_cudbg.c  |   20 +-
 .../net/ethernet/chelsio/cxgb4/cxgb4_dcb.c    |   19 +-
 .../ethernet/chelsio/cxgb4/cxgb4_debugfs.c    | 1031 ++-
 .../ethernet/chelsio/cxgb4/cxgb4_debugfs.h    |   17 +-
 .../ethernet/chelsio/cxgb4/cxgb4_ethtool.c    |  381 +-
 .../net/ethernet/chelsio/cxgb4/cxgb4_filter.c |  214 +-
 .../net/ethernet/chelsio/cxgb4/cxgb4_main.c   | 1183 +--
 .../net/ethernet/chelsio/cxgb4/cxgb4_pci.c    |  332 +
 .../net/ethernet/chelsio/cxgb4/cxgb4_pci.h    |   23 +
 .../net/ethernet/chelsio/cxgb4/cxgb4_ptp.c    |   82 +-
 .../net/ethernet/chelsio/cxgb4/cxgb4_uld.c    |  140 +-
 .../net/ethernet/chelsio/cxgb4/cxgb4_uld.h    |    5 +
 drivers/net/ethernet/chelsio/cxgb4/sge.c      |  182 +-
 .../net/ethernet/chelsio/cxgb4/t4_chip_type.h |   10 +
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c    | 6579 ++++++++++++---
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.h    |  140 +-
 drivers/net/ethernet/chelsio/cxgb4/t4_msg.h   |  109 +-
 .../ethernet/chelsio/cxgb4/t4_pci_id_tbl.h    |   21 +
 drivers/net/ethernet/chelsio/cxgb4/t4_regs.h  | 7285 ++++++++++++++---
 drivers/net/ethernet/chelsio/cxgb4/t4_tcb.h   |   16 +
 .../net/ethernet/chelsio/cxgb4/t4_values.h    |   11 +
 drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h |   88 +-
 .../net/ethernet/chelsio/cxgb4/t4fw_version.h |    9 +
 32 files changed, 17042 insertions(+), 3489 deletions(-)
 create mode 100644 drivers/net/ethernet/chelsio/cxgb4/cudbg_indir_reg.h
 create mode 100644 drivers/net/ethernet/chelsio/cxgb4/cudbg_indir_reg_t7.h
 create mode 100644 drivers/net/ethernet/chelsio/cxgb4/cxgb4_pci.c
 create mode 100644 drivers/net/ethernet/chelsio/cxgb4/cxgb4_pci.h
Signature · 1 line
2.39.1
author maintainer
#1 lore raw

PATCH v5 1/12 cxgb4: add T7 hardware definitions and firmware interfaces

Add the initial T7-specific hardware definitions required by the cxgb4 driver. This patch updates chip identification, PCI device IDs, register definitions, TCB layout definitions, firmware API interfaces, firmware version information, message formats, and related constants to provide the foundational infrastructure for upcoming T7 support.

No functional changes are introduced by this patch. It only extends the existing hardware and firmware definition headers for T7-specific driver functionality.

---
 .../net/ethernet/chelsio/cxgb4/t4_chip_type.h |   10 +
 drivers/net/ethernet/chelsio/cxgb4/t4_msg.h   |  109 +-
 .../ethernet/chelsio/cxgb4/t4_pci_id_tbl.h    |   21 +
 drivers/net/ethernet/chelsio/cxgb4/t4_regs.h  | 7284 ++++++++++++++---
 drivers/net/ethernet/chelsio/cxgb4/t4_tcb.h   |   16 +
 .../net/ethernet/chelsio/cxgb4/t4_values.h    |   11 +
 drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h |   83 +-
 .../net/ethernet/chelsio/cxgb4/t4fw_version.h |    9 +
 8 files changed, 6401 insertions(+), 1142 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/t4_chip_type.h +10 -0
index 721c77577ec5..444675436b01 100644
@@ -39,6 +39,7 @@
 #define CHELSIO_T4		0x4
 #define CHELSIO_T5		0x5
 #define CHELSIO_T6		0x6
+#define CHELSIO_T7		0x7
 
 /* We code the Chelsio T4 Family "Chip Code" as a tuple:
  *
@@ -67,6 +68,11 @@ enum chip_type {
 	T6_A0 = CHELSIO_CHIP_CODE(CHELSIO_T6, 0),
 	T6_FIRST_REV	= T6_A0,
 	T6_LAST_REV	= T6_A0,
+
+	T7_A0 = CHELSIO_CHIP_CODE(CHELSIO_T7, 0),
+	T7_B0 = CHELSIO_CHIP_CODE(CHELSIO_T7, 1),
+	T7_FIRST_REV    = T7_A0,
+	T7_LAST_REV     = T7_B0,
 };
 
 static inline int is_t4(enum chip_type chip)
@@ -84,4 +90,8 @@ static inline int is_t6(enum chip_type chip)
 	return (CHELSIO_CHIP_VERSION(chip) == CHELSIO_T6);
 }
 
+static inline int is_t7(enum chip_type chip)
+{
+	return (CHELSIO_CHIP_VERSION(chip) == CHELSIO_T7);
+}
 #endif /* __T4_CHIP_TYPE_H__ */
drivers/net/ethernet/chelsio/cxgb4/t4_msg.h +99 -10

155 lines not on this page · raw message

drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h +21 -0
index 0b1b5f9c67d4..d0921b76049d 100644
@@ -220,6 +220,27 @@ CH_PCI_DEVICE_ID_TABLE_DEFINE_BEGIN
 	CH_PCI_ID_TABLE_FENTRY(0x608a), /* Custom T62100-CR */
 	CH_PCI_ID_TABLE_FENTRY(0x608b), /* Custom T6225-CR */
 	CH_PCI_ID_TABLE_FENTRY(0x6092), /* Custom T62100-CR-LOM */
+
+	/* T7 adapter */
+	CH_PCI_ID_TABLE_FENTRY(0x7000), /* T7-DBG */
+	CH_PCI_ID_TABLE_FENTRY(0x7001), /* T7250 */
+	CH_PCI_ID_TABLE_FENTRY(0x7002), /* S7250 */
+	CH_PCI_ID_TABLE_FENTRY(0x7003), /* T7450 */
+	CH_PCI_ID_TABLE_FENTRY(0x7004), /* S7450 */
+	CH_PCI_ID_TABLE_FENTRY(0x7005), /* T72200 */
+	CH_PCI_ID_TABLE_FENTRY(0x7006), /* S72200 */
+	CH_PCI_ID_TABLE_FENTRY(0x7007), /* T72200-FH */
+	CH_PCI_ID_TABLE_FENTRY(0x7008), /* T71400 */
+	CH_PCI_ID_TABLE_FENTRY(0x7009), /* S7210-BT */
+	CH_PCI_ID_TABLE_FENTRY(0x700a), /* T7450-RC */
+	CH_PCI_ID_TABLE_FENTRY(0x700b), /* T72200-RC */
+	CH_PCI_ID_TABLE_FENTRY(0x700c), /* T72200-FH-RC */
+	CH_PCI_ID_TABLE_FENTRY(0x700d), /* S72200-OCP3 */
+	CH_PCI_ID_TABLE_FENTRY(0x700e), /* S7450-OCP3 */
+	CH_PCI_ID_TABLE_FENTRY(0x700f), /* S7410-BT-OCP3 */
+	CH_PCI_ID_TABLE_FENTRY(0x7010), /* S7210-BT-A */
+	CH_PCI_ID_TABLE_FENTRY(0x7011), /* T7_MAYRA_7 */
+	CH_PCI_ID_TABLE_FENTRY(0x7012), /* T7-iNIC */
 CH_PCI_DEVICE_ID_TABLE_DEFINE_END;
 
 #endif /* __T4_PCI_ID_TBL_H__ */
drivers/net/ethernet/chelsio/cxgb4/t4_regs.h +6160 -1124

2,792 lines not on this page · raw message

drivers/net/ethernet/chelsio/cxgb4/t4_tcb.h +16 -0
index 22a0220123ad..1b7fc71dd835 100644

Lines of this file are not shown. View the raw message.

drivers/net/ethernet/chelsio/cxgb4/t4_values.h +11 -0
index eb1aa82149db..1598d8cdd696 100644

Lines of this file are not shown. View the raw message.

drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h +75 -8

83 lines not on this page · raw message

drivers/net/ethernet/chelsio/cxgb4/t4fw_version.h +9 -0
index a02b1dff403e..d19979c8bfc0 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.39.1

Part of the diff is not shown here. View the raw message.

author maintainer
#2 lore raw

PATCH v5 2/12 cxgb4: rework the interrupt handling framework

In reply to Potnuri Bharat Teja

The slow interrupt path used a per module handler that walked a table of (mask, message) pairs with t4_handle_intr_status() and printed a message for every bit it found set. Each module handler open coded the read, report and clear sequence, and there was no way to express that a cause bit should be handled by inspecting a sub-register, or that a bit is only fatal when it is also enabled.

Replace it with a data driven framework:

struct intr_info describes one cause register: its name, the cause and enable register offsets, the mask of fatal bits, a table of struct intr_details for decoding individual bits, and an optional table of struct intr_action entries naming a function to call for a given cause bit.

t4_handle_intr() implements the common read, report, dispatch and clear sequence once, so a module handler reduces to describing its registers and any nested cause registers it owns.

The module interrupt handlers now return bool rather than void so a fatal condition propagates back to t4_slow_intr_handler() instead of being signalled out of band, and t4_slow_intr_handler() takes a verbose flag controlling whether individual cause bits are decoded and logged.

This changes the interrupt path for all supported adapters. No functional change is intended for T4, T5 or T6 beyond the wording of the messages emitted.

---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h    |    2 +-
 .../net/ethernet/chelsio/cxgb4/cxgb4_main.c   |    2 +-
 drivers/net/ethernet/chelsio/cxgb4/sge.c      |    4 +-
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c    | 4435 ++++++++++++++---
 4 files changed, 3790 insertions(+), 653 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h +1 -1
index f20f4bc58492..acdeab77352f 100644
@@ -1788,7 +1788,7 @@ struct fw_filter_wr;
 
 void t4_intr_enable(struct adapter *adapter);
 void t4_intr_disable(struct adapter *adapter);
-int t4_slow_intr_handler(struct adapter *adapter);
+int t4_slow_intr_handler(struct adapter *adap, bool verbose);
 
 int t4_wait_dev_ready(void __iomem *regs);
 
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +1 -1
index 1ced6df6eac8..5189016c3ef6 100644
@@ -682,7 +682,7 @@ static irqreturn_t t4_nondata_intr(int irq, void *cookie)
 		t4_write_reg(adap, MYPF_REG(PL_PF_INT_CAUSE_A), v);
 	}
 	if (adap->flags & CXGB4_MASTER_PF)
-		t4_slow_intr_handler(adap);
+		t4_slow_intr_handler(adap, true);
 	return IRQ_HANDLED;
 }
 
drivers/net/ethernet/chelsio/cxgb4/sge.c +2 -2
index 9fccb8ea9bcd..4fe6c10d50e0 100644
@@ -4193,7 +4193,7 @@ static irqreturn_t t4_intr_msi(int irq, void *cookie)
 	struct adapter *adap = cookie;
 
 	if (adap->flags & CXGB4_MASTER_PF)
-		t4_slow_intr_handler(adap);
+		t4_slow_intr_handler(adap, true);
 	process_intrq(adap);
 	return IRQ_HANDLED;
 }
@@ -4208,7 +4208,7 @@ static irqreturn_t t4_intr_intx(int irq, void *cookie)
 	struct adapter *adap = cookie;
 
 	t4_write_reg(adap, MYPF_REG(PCIE_PF_CLI_A), 0);
-	if (((adap->flags & CXGB4_MASTER_PF) && t4_slow_intr_handler(adap)) |
+	if (((adap->flags & CXGB4_MASTER_PF) && t4_slow_intr_handler(adap, true)) |
 	    process_intrq(adap))
 		return IRQ_HANDLED;
 	return IRQ_NONE;             /* probably shared interrupt */
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +3786 -649

2,968 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.39.1

Part of the diff is not shown here. View the raw message.

author maintainer
#3 lore raw

PATCH v5 3/12 cxgb4: add T7 hardware management support

In reply to Potnuri Bharat Teja

Extend the cxgb4 hardware management layer to support T7 adapters.

Add T7 handling to hardware resource and topology discovery. The TP load balancer mode and the firmware supplied TP channel map are read into adapter_params, and t4_get_mps_bg_map() and t4_get_tp_ch_map() account for the T7 channel layout. The load balancer mode distributes the four TP channels across the active ports as four ports of one channel, two ports of two channels, or one port of four channels.

t4_get_chip_type() moves from cxgb4_main.c into t4_hw.c so that chip identification lives with the rest of the hardware layer, and learns the T7 chip version.

Add T7 flash support. The flash layout is described by a table indexed by flash location rather than by fixed FLASH_*_START_SEC and FLASH_*_NSECS constants, with t4_flash_location_start_sec(), t4_flash_location_nsecs(), t4_flash_location_start() and t4_flash_location_size() returning the bounds of a region. t4_flash_cfg_addr() now returns int so that it can report a region that does not exist on the running adapter. t4_get_flash_params() learns the flash parts used on T7 and a four byte address serial flash interface, which is required for parts larger than 16MB.

Add the T7 register ranges to t4_get_regs(), the T7 PCIE memory window registers, and T7 support to the CIM ingress and egress queue, CIM LA, SGE context, MPS trace filter, PM statistics, scheduler and I2C accessors.

T7 implements multiple uP cores. The number of enabled cores is read during device log initialisation and the per core device log parameters are kept in an array, so that the device log and the CIM queue accessors can address a specific core.

---
 .../net/ethernet/chelsio/cxgb4/cudbg_lib.c    |    4 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h    |   89 +-
 .../ethernet/chelsio/cxgb4/cxgb4_debugfs.c    |    2 +-
 .../net/ethernet/chelsio/cxgb4/cxgb4_main.c   |   17 -
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c    | 2200 ++++++++++++++---
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.h    |  139 +-
 6 files changed, 2022 insertions(+), 429 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c +2 -2
index 557c591a6ce3..4bae323351f7 100644
@@ -198,7 +198,7 @@ u32 cudbg_get_entity_length(struct adapter *adap, u32 entity)
 		}
 		break;
 	case CUDBG_DEV_LOG:
-		len = adap->params.devlog.size;
+		len = adap->params.devlogs.size;
 		break;
 	case CUDBG_CIM_LA:
 		if (is_t6(adap->params.chip)) {
@@ -847,7 +847,7 @@ int cudbg_collect_fw_devlog(struct cudbg_init *pdbg_init,
 		return rc;
 	}
 
-	dparams = &padap->params.devlog;
+	dparams = &padap->params.devlogs;
 	rc = cudbg_get_buff(pdbg_init, dbg_buff, dparams->size, &temp_buff);
 	if (rc)
 		return rc;
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h +77 -12

267 lines not on this page · raw message

drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c +1 -1
index f521737d1275..e0b4b04d4aac 100644
@@ -1081,7 +1081,7 @@ static const struct seq_operations devlog_seq_ops = {
 static int devlog_open(struct inode *inode, struct file *file)
 {
 	struct adapter *adap = inode->i_private;
-	struct devlog_params *dparams = &adap->params.devlog;
+	struct devlog_params *dparams = &adap->params.devlogs;
 	struct devlog_info *dinfo;
 	unsigned int index;
 	u32 fseqno;
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +0 -17
index 5189016c3ef6..b7f0df9704a2 100644
@@ -6199,23 +6199,6 @@ static void free_some_resources(struct adapter *adapter)
 		   NETIF_F_GRO | NETIF_F_IPV6_CSUM | NETIF_F_HIGHDMA)
 #define SEGMENT_SIZE 128
 
-static int t4_get_chip_type(struct adapter *adap, int ver)
-{
-	u32 pl_rev = REV_G(t4_read_reg(adap, PL_REV_A));
-
-	switch (ver) {
-	case CHELSIO_T4:
-		return CHELSIO_CHIP_CODE(CHELSIO_T4, pl_rev);
-	case CHELSIO_T5:
-		return CHELSIO_CHIP_CODE(CHELSIO_T5, pl_rev);
-	case CHELSIO_T6:
-		return CHELSIO_CHIP_CODE(CHELSIO_T6, pl_rev);
-	default:
-		break;
-	}
-	return -EINVAL;
-}
-
 #ifdef CONFIG_PCI_IOV
 static void cxgb4_mgmt_setup(struct net_device *dev)
 {
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +1849 -351

2,686 lines not on this page · raw message

drivers/net/ethernet/chelsio/cxgb4/t4_hw.h +93 -46

139 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.39.1

Part of the diff is not shown here. View the raw message.

author maintainer
#4 lore raw

PATCH v5 4/12 cxgb4: move PCI device management into cxgb4_pci.c and rework driver helpers

In reply to Potnuri Bharat Teja

cxgb4_main.c has accumulated all of the PCI bus glue - the device ID table, probe, remove, shutdown and the EEH error handlers - alongside the actual network driver. Split the bus-facing half out into a new cxgb4_pci.c so that adding a new chip generation does not require touching PCI enumeration code, and so that the probe path can be read as a sequence of named steps rather than one 400 line function.

init_one() becomes cxgb4_pci_init_one() (bus side) plus cxgb4_adap_probe() (driver side); remove_one() and shutdown_one() are split the same way. Resource acquisition, chip identification, memory window setup and the firmware handshake move into cxgb4_pci_resource_init(), cxgb4_pci_chip_init(), cxgb4_pci_setup_memwin{,_rdma}() and cxgb4_pci_fw_init(). The EEH handlers are renamed cxgb4_pci_eeh_* and exported so the pci_error_handlers table can live next to the pci_driver.

Because the pci_driver structure is no longer in cxgb4_main.c, the two places that identified a cxgb4 netdevice by comparing its parent device driver now compare netdev_ops against cxgb4_netdev_ops instead.

Several helpers are reworked while the code is being moved:

- cxgb4_work_queue()/cxgb4_work_cancel() and cxgb4_workqueues_{create,destroy}() replace the open coded workqueue calls.
- cxgb4_pci_msi{x,}_enabled() replace direct tests of CXGB4_USING_MSI/CXGB4_USING_MSIX, and enable_msix() now records which interrupt mode was actually selected.
- cxgb4_port_chan_to_netdev() looks a netdevice up by channel and returns NULL if none matches, so the DCB firmware event paths no longer index chan_map[] blindly.
- The HMA page size calculation picks the largest power of two page size the scatterlist actually provides instead of assuming a fixed page order.
- SGE doorbell addresses are computed once at probe and used via writel() rather than recomputed per doorbell ring.

Fixed while moving the code:

- CXGB4_DEV_ENABLED is now set in cxgb4_pci_resource_init() immediately after pci_enable_device() and cleared where the VF management PF disables the device again. Previously the flag was set late in probe, so an early probe failure left the device enabled.
- enable_msix() leaked the msix_entry array on its success path.
- free_some_resources() passed adapter->pf to t4_fw_bye() where the mailbox number is wanted.
- cxgb_udp_tunnel_set_port() now unwinds the MAC filters it allocated if a later port fails, and only programs the MPS register once every filter is in place.

No functional change is intended for T4/T5/T6 beyond the fixes listed above.

---
 drivers/net/ethernet/chelsio/cxgb4/Makefile   |   2 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h    |  18 +
 .../net/ethernet/chelsio/cxgb4/cxgb4_dcb.c    |  19 +-
 .../net/ethernet/chelsio/cxgb4/cxgb4_main.c   | 647 ++++++++----------
 .../net/ethernet/chelsio/cxgb4/cxgb4_pci.c    | 332 +++++++++
 .../net/ethernet/chelsio/cxgb4/cxgb4_pci.h    |  23 +
 drivers/net/ethernet/chelsio/cxgb4/sge.c      |  96 +--
 7 files changed, 715 insertions(+), 422 deletions(-)
 create mode 100644 drivers/net/ethernet/chelsio/cxgb4/cxgb4_pci.c
 create mode 100644 drivers/net/ethernet/chelsio/cxgb4/cxgb4_pci.h
drivers/net/ethernet/chelsio/cxgb4/Makefile +1 -1
index a4b4d475abf8..08aef803a14a 100644
@@ -9,7 +9,7 @@ cxgb4-objs := cxgb4_main.o l2t.o smt.o t4_hw.o sge.o clip_tbl.o cxgb4_ethtool.o
 	      cxgb4_uld.o srq.o sched.o cxgb4_filter.o cxgb4_tc_u32.o \
 	      cxgb4_ptp.o cxgb4_tc_flower.o cxgb4_cudbg.o cxgb4_mps.o \
 	      cudbg_common.o cudbg_lib.o cudbg_zlib.o cxgb4_tc_mqprio.o \
-	      cxgb4_tc_matchall.o
+	      cxgb4_tc_matchall.o cxgb4_pci.o
 cxgb4-$(CONFIG_CHELSIO_T4_DCB) +=  cxgb4_dcb.o
 cxgb4-$(CONFIG_CHELSIO_T4_FCOE) +=  cxgb4_fcoe.o
 cxgb4-$(CONFIG_DEBUG_FS) += cxgb4_debugfs.o
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h +18 -0
index f07fdb99d83b..f08bb0993c37 100644
@@ -70,6 +70,8 @@ enum dev_state {
 
 #include "cxgb4_uld.h"
 #include "t4fw_api.h"
+#include "t4_values.h"
+#include "cxgb4_pci.h"
 
 #define CH_WARN(adap, fmt, ...) dev_warn(adap->pdev_dev, fmt, ## __VA_ARGS__)
 extern struct list_head adapter_list;
@@ -1636,6 +1638,9 @@ extern char cxgb4_driver_name[];
 void t4_os_portmod_changed(struct adapter *adap, int port_id);
 void t4_os_link_changed(struct adapter *adap, int port_id, int link_stat);
 
+void cxgb4_work_queue(struct workqueue_struct *workq, struct work_struct *work);
+void cxgb4_work_cancel(struct workqueue_struct *workq, struct work_struct *work);
+struct net_device *cxgb4_port_chan_to_netdev(struct adapter *adap, u8 chan);
 void t4_free_sge_resources(struct adapter *adap);
 irq_handler_t t4_intr_handler(struct adapter *adap);
 netdev_tx_t t4_start_xmit(struct sk_buff *skb, struct net_device *dev);
@@ -2067,6 +2072,19 @@ int t4_free_mac_filt(struct adapter *adap, unsigned int mbox,
 		     const u8 **addr, bool sleep_ok);
 int t4_change_mac(struct adapter *adap, unsigned int mbox, unsigned int viid,
 		  int idx, const u8 *addr, bool persist, u8 *smt_idx);
+int cxgb4_is_primary_pf(struct adapter *adapter);
+int cxgb4_mbox_log_init(struct adapter *adap);
+
+pci_ers_result_t cxgb4_pci_eeh_err_detected(struct pci_dev *pdev,
+					    pci_channel_state_t state);
+pci_ers_result_t cxgb4_pci_eeh_slot_reset(struct pci_dev *pdev);
+void cxgb4_pci_eeh_resume(struct pci_dev *pdev);
+void cxgb4_pci_eeh_reset_prepare(struct pci_dev *pdev);
+void cxgb4_pci_eeh_reset_done(struct pci_dev *pdev);
+int cxgb4_iov_configure(struct pci_dev *pdev, int num_vfs);
+int cxgb4_adap_probe(struct adapter *adapter);
+void cxgb4_adap_remove(struct adapter *adapter);
+void cxgb4_adap_shutdown(struct adapter *adapter);
 int t4_set_addr_hash(struct adapter *adap, unsigned int mbox, unsigned int viid,
 		     bool ucast, u64 vec, bool sleep_ok);
 int t4_enable_vi_params(struct adapter *adap, unsigned int mbox,
drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c +15 -4
index 7d5204834ee2..7c5437423696 100644
@@ -273,13 +273,24 @@ void cxgb4_dcb_state_fsm(struct net_device *dev,
 void cxgb4_dcb_handle_fw_update(struct adapter *adap,
 				const struct fw_port_cmd *pcmd)
 {
-	const union fw_port_dcb *fwdcb = &pcmd->u.dcb;
 	int port = FW_PORT_CMD_PORTID_G(be32_to_cpu(pcmd->op_to_portid));
-	struct net_device *dev = adap->port[adap->chan_map[port]];
-	struct port_info *pi = netdev_priv(dev);
-	struct port_dcb_info *dcb = &pi->dcb;
+	const union fw_port_dcb *fwdcb = &pcmd->u.dcb;
 	int dcb_type = pcmd->u.dcb.pgid.type;
+	struct port_dcb_info *dcb;
 	int dcb_running_version;
+	struct net_device *dev;
+	struct port_info *pi;
+
+	dev = cxgb4_port_chan_to_netdev(adap, port);
+	if (!dev) {
+		dev_warn(adap->pdev_dev,
+			 "Could not get netdevice for handling DCB FW update for port: %d\n",
+			 port);
+		return;
+	}
+
+	pi = netdev_priv(dev);
+	dcb = &pi->dcb;
 
 	/* Handle Firmware DCB Control messages separately since they drive
 	 * our state machine.
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +271 -376

1,206 lines not on this page · raw message

drivers/net/ethernet/chelsio/cxgb4/cxgb4_pci.c new file +332 -0

332 lines not on this page · raw message

drivers/net/ethernet/chelsio/cxgb4/cxgb4_pci.h new file +23 -0
new file mode 100644
index 000000000000..78a814207f61
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ *  Copyright (C) 2026 Chelsio Communications.  All rights reserved.
+ */
+
+#ifndef __CXGB4_PCI_H__
+#define __CXGB4_PCI_H__
+
+#define CXGB4_UNIFIED_PF 0x4
+
+int cxgb4_pci_resource_init(struct adapter *adap);
+void cxgb4_pci_resource_free(struct adapter *adap);
+int cxgb4_pci_chip_init(struct adapter *adap);
+void cxgb4_pci_chip_free(struct adapter *adap);
+void cxgb4_pci_setup_memwin(struct adapter *adap);
+void cxgb4_pci_setup_memwin_rdma(struct adapter *adap);
+int cxgb4_pci_fw_init(struct adapter *adap, enum dev_state *state);
+bool cxgb4_pci_msix_enabled(struct adapter *adap);
+bool cxgb4_pci_msi_enabled(struct adapter *adap);
+
+int cxgb4_pci_driver_register(void);
+void cxgb4_pci_driver_unregister(void);
+#endif /* __CXGB4_PCI_H__ */
drivers/net/ethernet/chelsio/cxgb4/sge.c +55 -41

241 lines not on this page · raw message

Signature · 1 line
2.39.1
author maintainer
#5 lore raw

PATCH v5 5/12 cxgb4: add T7 support to the main driver

In reply to Potnuri Bharat Teja

Enable the T7 generation in the NIC driver proper, on top of the PCI and helper rework done in the previous patch.

Firmware and configuration:

- Add FW7_FNAME/FW7_CFNAME, the T7 entry in fw_info_array[] and the matching case in adap_init0_config().
- Bound the configuration file against the size reported by t4_flash_location_size(FLASH_LOC_CFG) rather than the fixed FLASH_CFG_MAX_SIZE, which no longer describes every generation.
- The high priority filter and PPOD EDRAM setup is enabled for T6 and later rather than T6 only.

Reporting:

- link_report() learns 200G and 400G.
- t4_os_portmod_changed() learns the LR_SIMPLEX and DR module types.

Channel programming:

- Port related firmware commands and register accesses now use the logical port number (pi->lport) rather than pi->tx_chan. These are identical on T4/T5/T6; on T7 the TP channel for a port is supplied by firmware via FW_PARAMS_PARAM_DEV_TPCHMAP and is read through cxgb4_port_chan(), which the SGE queue allocation paths now use.
- t4_set_trace_rss_control() replaces the open coded, chip conditional MPS trace RSS control register write.

UDP tunnels:

- VXLAN and GENEVE RX type registers moved on T7; select between the legacy and T7 register offsets.

Multiple uP cores:

- t4_sge_alloc_eth_txq() and t4_sge_alloc_ctrl_txq() take a queue index and program FW_EQ_{ETH,CTRL}_CMD_COREGROUP so that queues are distributed across the available cores.
- setup_sge_queues() allocates num_up_cores control queues per port, and cfg_queues()/enable_msix() size the offload queue sets and vector requirements accordingly.

SGE:

- On T7 and later the firmware derives the congestion channel map from the configured load balancer mode, so the driver passes the channel vector directly instead of building the map itself.
- t4_sge_init() handles the T7 chip version.

---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h    |   4 +-
 .../net/ethernet/chelsio/cxgb4/cxgb4_main.c   | 248 +++++++++---------
 drivers/net/ethernet/chelsio/cxgb4/sge.c      |  55 ++--
 3 files changed, 168 insertions(+), 139 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h +2 -2
index f08bb0993c37..8409e759f5ae 100644
@@ -1655,10 +1655,10 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq,
 		     rspq_flush_handler_t flush_handler, int cong);
 int t4_sge_alloc_eth_txq(struct adapter *adap, struct sge_eth_txq *txq,
 			 struct net_device *dev, struct netdev_queue *netdevq,
-			 unsigned int iqid, u8 dbqt);
+			 unsigned int iqid, u8 dbqt, int index);
 int t4_sge_alloc_ctrl_txq(struct adapter *adap, struct sge_ctrl_txq *txq,
 			  struct net_device *dev, unsigned int iqid,
-			  unsigned int cmplqid);
+			  unsigned int cmplqid, int index);
 int t4_sge_mod_ctrl_txq(struct adapter *adap, unsigned int eqid,
 			unsigned int cmplqid);
 int t4_sge_alloc_uld_txq(struct adapter *adap, struct sge_uld_txq *txq,
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +128 -120

488 lines not on this page · raw message

drivers/net/ethernet/chelsio/cxgb4/sge.c +38 -17

133 lines not on this page · raw message

Signature · 1 line
2.39.1
author maintainer
#6 lore raw

PATCH v5 6/12 cxgb4: update PTP register access for T7

In reply to Potnuri Bharat Teja

The MAC_PORT_TX_TS_VAL_LO/HI registers moved within the port register block on T7, and the PTP clock sum is now read from the chip global MAC_PTP_SUM_LO/HI instead of a per port register. Select the right registers by chip version and read both values with t4_read_reg64(). PTP port accesses now use the logical port number (pi->lport).

On T7 a transmitted PTP event packet is looped back with equal source and destination MAC addresses rather than an MPS timestamp header. Detect that and hand the packet to the transmit timestamp path. The loopback packet is not necessarily UDP, so the RXF_UDP_F test is dropped and cxgb4_ptp_is_ptp_rx() parses the frame itself, handling VLAN tagged and IEEE 802.3 encapsulated PTP. On transmit, ptp_classify_raw() replaces the open coded IPv4/UDP test.

---
 .../net/ethernet/chelsio/cxgb4/cxgb4_ptp.c    | 82 ++++++++++++++-----
 drivers/net/ethernet/chelsio/cxgb4/sge.c      | 13 ++-
 drivers/net/ethernet/chelsio/cxgb4/t4_regs.h  |  1 +
 3 files changed, 71 insertions(+), 25 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/cxgb4_ptp.c +60 -22
index cbd06d9b95d4..fb0d4ae11196 100644
@@ -57,14 +57,13 @@
  */
 bool cxgb4_ptp_is_ptp_tx(struct sk_buff *skb)
 {
-	struct udphdr *uh;
-
-	uh = udp_hdr(skb);
-	return skb->len >= PTP_MIN_LENGTH &&
-		skb->len <= PTP_IN_TRANSMIT_PACKET_MAXNUM &&
-		likely(skb->protocol == htons(ETH_P_IP)) &&
-		ip_hdr(skb)->protocol == IPPROTO_UDP &&
-		uh->dest == htons(PTP_EVENT_PORT);
+	unsigned int ptp_class;
+
+	ptp_class = ptp_classify_raw(skb);
+	if (ptp_class == PTP_CLASS_NONE)
+		return false;
+
+	return true;
 }
 
 bool is_ptp_enabled(struct sk_buff *skb, struct net_device *dev)
@@ -83,11 +82,50 @@ bool is_ptp_enabled(struct sk_buff *skb, struct net_device *dev)
  */
 bool cxgb4_ptp_is_ptp_rx(struct sk_buff *skb)
 {
-	struct udphdr *uh = (struct udphdr *)(skb->data + ETH_HLEN +
-					      IPV4_HLEN(skb->data));
+	int offset = ETH_HLEN;
+	struct ethhdr *eth;
+	__be16 proto;
+
+	if (skb->len < ETH_HLEN)
+		return false;
+
+	eth = (struct ethhdr *)skb->data;
+	proto = eth->h_proto;
+
+	if (proto == htons(ETH_P_8021Q)) {
+		struct vlan_hdr *vhdr;
+
+		if (skb->len < offset + VLAN_HLEN)
+			return false;
+
+		vhdr = (struct vlan_hdr *)(skb->data + offset);
+		proto = vhdr->h_vlan_encapsulated_proto;
+		offset += VLAN_HLEN;
+	}
+
+	if (proto == htons(ETH_P_1588))
+		return true;
+
+	if (proto == htons(ETH_P_IP)) {
+		struct iphdr *iph;
+		struct udphdr *uh;
+
+		if (skb->len < offset + sizeof(*iph))
+			return false;
+		iph = (struct iphdr *)(skb->data + offset);
+
+		if (iph->protocol != IPPROTO_UDP)
+			return false;
+		offset += (iph->ihl * 4);
+
+		if (skb->len < offset + sizeof(*uh))
+			return false;
+		uh = (struct udphdr *)(skb->data + offset);
+
+		return uh->dest == htons(PTP_EVENT_PORT);
+	}
 
-	return  uh->dest == htons(PTP_EVENT_PORT) &&
-		uh->source == htons(PTP_EVENT_PORT);
+	return false;
 }
 
 /**
@@ -103,12 +141,11 @@ void cxgb4_ptp_read_hwstamp(struct adapter *adapter, struct port_info *pi)
 
 	skb_ts = skb_hwtstamps(adapter->ptp_tx_skb);
 
-	tx_ts = t4_read_reg(adapter,
-			    T5_PORT_REG(pi->port_id, MAC_PORT_TX_TS_VAL_LO));
+	if (CHELSIO_CHIP_VERSION(adapter->params.chip) >= CHELSIO_T7)
+		tx_ts = t4_read_reg64(adapter, T7_PORT_REG(pi->lport, T7_MAC_PORT_TX_TS_VAL_LO));
+	else
+		tx_ts = t4_read_reg64(adapter, T5_PORT_REG(pi->lport, MAC_PORT_TX_TS_VAL_LO));
 
-	tx_ts |= (u64)t4_read_reg(adapter,
-				  T5_PORT_REG(pi->port_id,
-					      MAC_PORT_TX_TS_VAL_HI)) << 32;
 	skb_ts->hwtstamp = ns_to_ktime(tx_ts);
 	skb_tstamp_tx(adapter->ptp_tx_skb, skb_ts);
 	dev_kfree_skb_any(adapter->ptp_tx_skb);
@@ -183,7 +220,7 @@ int cxgb4_ptp_redirect_rx_packet(struct adapter *adapter, struct port_info *pi)
 
 	c.retval_len16 = cpu_to_be32(FW_CMD_LEN16_V(sizeof(c) / 16));
 	c.u.init.sc = FW_PTP_SC_RDRX_TYPE;
-	c.u.init.txchan = pi->tx_chan;
+	c.u.init.txchan = pi->lport;
 	c.u.init.absid = cpu_to_be16(receive_q->rspq.abs_id);
 
 	err = t4_wr_mbox(adapter, adapter->mbox, &c, sizeof(c), NULL);
@@ -319,9 +356,10 @@ static int cxgb4_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
 					       ptp_clock_info);
 	u64 ns;
 
-	ns = t4_read_reg(adapter, T5_PORT_REG(0, MAC_PORT_PTP_SUM_LO_A));
-	ns |= (u64)t4_read_reg(adapter,
-			       T5_PORT_REG(0, MAC_PORT_PTP_SUM_HI_A)) << 32;
+	if (CHELSIO_CHIP_VERSION(adapter->params.chip) >= CHELSIO_T7)
+		ns = t4_read_reg64(adapter, MAC_PTP_SUM_LO_A);
+	else
+		ns = t4_read_reg64(adapter, T5_PORT_REG(0, MAC_PORT_PTP_SUM_LO_A));
 
 	/* convert to timespec*/
 	*ts = ns_to_timespec64(ns);
@@ -432,7 +470,7 @@ void cxgb4_ptp_init(struct adapter *adapter)
 	spin_lock_init(&adapter->ptp_lock);
 
 	adapter->ptp_clock = ptp_clock_register(&adapter->ptp_clock_info,
-						&adapter->pdev->dev);
+						adapter->pdev_dev);
 	if (IS_ERR_OR_NULL(adapter->ptp_clock)) {
 		adapter->ptp_clock = NULL;
 		dev_err(adapter->pdev_dev,
drivers/net/ethernet/chelsio/cxgb4/sge.c +10 -3
index 4a694d94f6eb..2171db2f201a 100644
@@ -3483,7 +3483,8 @@ static void do_gro(struct sge_eth_rxq *rxq, const struct pkt_gl *gl,
 enum {
 	RX_NON_PTP_PKT = 0,
 	RX_PTP_PKT_SUC = 1,
-	RX_PTP_PKT_ERR = 2
+	RX_PTP_PKT_ERR = 2,
+	RX_PTP_PKT_T7 = 3
 };
 
 /**
@@ -3509,6 +3510,13 @@ static noinline int t4_systim_to_hwstamp(struct adapter *adapter,
 
 	data = skb->data + sizeof(*cpl);
 	skb_pull(skb, 2 * sizeof(u64) + sizeof(struct cpl_rx_mps_pkt));
+
+	if (CHELSIO_CHIP_VERSION(adapter->params.chip) == CHELSIO_T7) {
+		struct ethhdr *eth = (struct ethhdr *)skb->data;
+
+		if (ether_addr_equal(eth->h_source, eth->h_dest))
+			return RX_PTP_PKT_T7;
+	}
 	offset = ETH_HLEN + IPV4_HLEN(skb->data) + UDP_HLEN;
 	if (skb->len < offset + OFF_PTP_SEQUENCE_ID + sizeof(short))
 		return RX_PTP_PKT_ERR;
@@ -3740,8 +3748,7 @@ int t4_ethrx_handler(struct sge_rspq *q, const __be64 *rsp,
 		__skb_pull(skb, s->pktshift); /* remove ethernet header pad */
 
 	/* Handle the PTP Event Tx Loopback packet */
-	if (unlikely(pi->ptp_enable && !ret &&
-		     (pkt->l2info & htonl(RXF_UDP_F)) &&
+	if (unlikely(pi->ptp_enable && (ret == RX_PTP_PKT_T7 || !ret) &&
 		     cxgb4_ptp_is_ptp_rx(skb))) {
 		if (!t4_tx_hststamp(adapter, skb, q->netdev))
 			return 0;
drivers/net/ethernet/chelsio/cxgb4/t4_regs.h +1 -0
index 5ac262ec389f..e8bcce1993e1 100644
@@ -4533,6 +4533,7 @@
 #define MAC_PORT_EPIO_OP_A 0x8d0
 
 #define MAC_PORT_CFG2_A 0x818
+#define MAC_PTP_SUM_LO_A 0x38108
 
 #define MAC_PORT_PTP_SUM_LO_A 0x990
 #define MAC_PORT_PTP_SUM_HI_A 0x994
Signature · 1 line
2.39.1
author maintainer
#7 lore raw

PATCH v5 7/12 cxgb4: extend ethtool support for T7 adapters

In reply to Potnuri Bharat Teja

Update the ethtool implementation to support T7-specific port types, link modes, and adapter capabilities.

Add support for new T7 port configurations including SFP56, QSFP56, 50G/100G/200G/400G backplane modes, and the associated ethtool link mode mappings. Update port statistics handling and module type reporting to account for the new hardware capabilities.

Extend RSS configuration support by implementing RSS hash key retrieval and programming through ethtool. Also update module EEPROM handling for new optical module types and CMIS-based devices.

---
 .../ethernet/chelsio/cxgb4/cxgb4_ethtool.c    | 381 +++++++++++++-----
 1 file changed, 278 insertions(+), 103 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c +278 -103
index 0092bc16f887..605c0783d3d5 100644
@@ -14,6 +14,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 +360,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);
 
@@ -440,10 +442,13 @@ 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) {
 		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_DR ||
 		    mod_type == FW_PORT_MOD_TYPE_LRM)
 			return PORT_FIBRE;
 		else if (mod_type == FW_PORT_MOD_TYPE_TWINAX_PASSIVE ||
@@ -453,7 +458,11 @@ 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) {
 		return PORT_NONE;
 	}
 
@@ -490,8 +499,100 @@ 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:
+		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:
+		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
+ *	@mod_type: Firmware Module Type
  *	@port_type: Firmware Port Type
  *	@fw_caps: Firmware Port Capabilities
  *	@link_mode_mask: ethtool Link Mode Mask
@@ -500,114 +601,93 @@ 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;
-
-	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;
+	if (medium != LINK_MEDIUM_NONE)
+		__set_bit(fw_port_class_bit(port_type), link_mode_mask);
 
-	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);
+	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_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);
+	case LINK_MEDIUM_KR:
+		FW_CAPS_TO_LMM(SPEED_1G,   1000baseT_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_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);
-		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);
+		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_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 +696,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 +704,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
 }
 
 /**
@@ -649,10 +728,46 @@ 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(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(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 +803,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)
@@ -800,7 +915,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)
@@ -1576,6 +1691,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 +1710,19 @@ static int get_rss_table(struct net_device *dev,
 	unsigned int n = pi->rss_size;
 
 	rxfh->hfunc = ETH_RSS_HASH_TOP;
+
+	if (rxfh->key) {
+		__be32 key[10];
+
+		t4_read_rss_key(pi->adapter, (u32 *)key, true);
+		/* RSS hash keys are read in order TP_RSS_SECRET_KEY9..0 */
+		for (int i = 0; i < 10; i++)
+			((u32 *)rxfh->key)[i] = be32_to_cpu(key[9 - i]);
+	}
+
 	if (!rxfh->indir)
 		return 0;
+
 	while (n--)
 		rxfh->indir[n] = pi->rss[n];
 	return 0;
@@ -1607,10 +1738,19 @@ 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->key) {
+		__be32 key[10];
+
+		/* RSS hash keys are written in order TP_RSS_SECRET_KEY9..0 */
+		for (int i = 0; i < 10; i++)
+			key[i] = cpu_to_be32(((u32 *)rxfh->key)[9 - i]);
+		t4_write_rss_key(pi->adapter, (u32 *)key, -1, true);
+	}
+
 	if (!rxfh->indir)
 		return 0;
 
@@ -2022,12 +2162,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 +2187,12 @@ 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_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_REV_ADDR,
 				SFF_REV_LEN, &sff_rev);
 		/* For QSFP type ports, revision value >= 3
@@ -2083,14 +2225,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 +2243,41 @@ 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)
+{
+	struct port_info *pi = netdev_priv(dev);
+	struct adapter *adapter = pi->adapter;
+	int ret;
+
+	if (page_data->offset >= 128) {
+		u8 page = page_data->page;
+		/* Before reading EEPROM data first select the page in PageSelect register */
+		ret = t4_i2c_wr(adapter, adapter->mbox, pi->lport,
+				page_data->i2c_address << 1,
+				CMIS_PAGE_SELECT_REG,        /* CMIS Page Select register */
+				1,                           /* Page Select register length */
+				&page);
+		if (ret)
+			return ret;
+	}
+
+	ret = t4_i2c_rd(adapter, adapter->mbox, pi->lport,
+			page_data->i2c_address << 1, page_data->offset,
+			page_data->length, page_data->data);
+
+	if (ret)
+		return ret;
+
+	return page_data->length;
+}
+
 static u32 cxgb4_get_priv_flags(struct net_device *netdev)
 {
 	struct port_info *pi = netdev_priv(netdev);
@@ -2205,6 +2378,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 +2391,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,
 };
Signature · 1 line
2.39.1
author maintainer
#8 lore raw

PATCH v5 8/12 cxgb4: Add T7 support to the filter infrastructure.

In reply to Potnuri Bharat Teja

T7 introduces a number of changes in filter-related register fields, firmware work request formats and CPL definitions. Update the filter code to use the appropriate T7-specific encodings while preserving existing behavior on earlier adapters.

The changes include:
- Use T7 reply channel and queue number encodings in filter-related CPL requests.
- Add T7-specific filter capability validation using the new TP filter field definitions.
- Enable validation and programming of the SYN-only filter field, which is supported on T7.
- Adjust FW_FILTER_WR construction to match T7 semantics where the RX channel is no longer programmed through the legacy field.
- Add support for T7 active-open filter requests using the T7 CPL layout and T7 filter tuple encoding.
- Update filter resource handling to work correctly across T6 and T7 devices.

---
 .../net/ethernet/chelsio/cxgb4/cxgb4_filter.c | 214 ++++++++++++------
 1 file changed, 141 insertions(+), 73 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c +141 -73
index 657d96b9e2f6..c9182c69cc7e 100644
@@ -66,9 +66,14 @@ static int set_tcb_field(struct adapter *adap, struct filter_entry *f,
 
 	req = (struct cpl_set_tcb_field *)__skb_put_zero(skb, sizeof(*req));
 	INIT_TP_WR_CPL(req, CPL_SET_TCB_FIELD, ftid);
-	req->reply_ctrl = htons(REPLY_CHAN_V(0) |
-				QUEUENO_V(adap->sge.fw_evtq.abs_id) |
-				NO_REPLY_V(no_reply));
+	if (CHELSIO_CHIP_VERSION(adap->params.chip) >= CHELSIO_T7)
+		req->reply_ctrl = htons(T7_REPLY_CHAN_V(0) |
+					T7_QUEUENO_V(adap->sge.fw_evtq.abs_id) |
+					NO_REPLY_V(no_reply));
+	else
+		req->reply_ctrl = htons(REPLY_CHAN_V(0) |
+					QUEUENO_V(adap->sge.fw_evtq.abs_id) |
+					NO_REPLY_V(no_reply));
 	req->word_cookie = htons(TCB_WORD_V(word) | TCB_COOKIE_V(ftid));
 	req->mask = cpu_to_be64(mask);
 	req->val = cpu_to_be64(val);
@@ -249,32 +254,53 @@ static int validate_filter(struct net_device *dev,
 			   struct ch_filter_specification *fs)
 {
 	struct adapter *adapter = netdev2adap(dev);
-	u32 fconf, iconf;
+	u32 fconf, iconf, chip_ver;
 
+	chip_ver = CHELSIO_CHIP_VERSION(adapter->params.chip);
 	/* Check for unconfigured fields being used. */
 	iconf = adapter->params.tp.ingress_config;
 	fconf = fs->hash ? adapter->params.tp.filter_mask :
 			   adapter->params.tp.vlan_pri_map;
 
-	if (unsupported(fconf, FCOE_F, fs->val.fcoe, fs->mask.fcoe) ||
-	    unsupported(fconf, PORT_F, fs->val.iport, fs->mask.iport) ||
-	    unsupported(fconf, TOS_F, fs->val.tos, fs->mask.tos) ||
-	    unsupported(fconf, ETHERTYPE_F, fs->val.ethtype,
-			fs->mask.ethtype) ||
-	    unsupported(fconf, MACMATCH_F, fs->val.macidx, fs->mask.macidx) ||
-	    unsupported(fconf, MPSHITTYPE_F, fs->val.matchtype,
-			fs->mask.matchtype) ||
-	    unsupported(fconf, FRAGMENTATION_F, fs->val.frag, fs->mask.frag) ||
-	    unsupported(fconf, PROTOCOL_F, fs->val.proto, fs->mask.proto) ||
-	    unsupported(fconf, VNIC_ID_F, fs->val.pfvf_vld,
-			fs->mask.pfvf_vld) ||
-	    unsupported(fconf, VNIC_ID_F, fs->val.ovlan_vld,
-			fs->mask.ovlan_vld) ||
-	    unsupported(fconf, VNIC_ID_F, fs->val.encap_vld,
-			fs->mask.encap_vld) ||
-	    unsupported(fconf, VLAN_F, fs->val.ivlan_vld, fs->mask.ivlan_vld))
-		return -EOPNOTSUPP;
-
+	if (chip_ver >= CHELSIO_T7) {
+		if (unsupported(fconf, T7_FCOE_F, fs->val.fcoe, fs->mask.fcoe) ||
+		    unsupported(fconf, T7_PORT_F, fs->val.iport, fs->mask.iport) ||
+		    unsupported(fconf, T7_TOS_F, fs->val.tos, fs->mask.tos) ||
+		    unsupported(fconf, T7_ETHERTYPE_F, fs->val.ethtype,
+				fs->mask.ethtype) ||
+		    unsupported(fconf, T7_MACMATCH_F, fs->val.macidx, fs->mask.macidx) ||
+		    unsupported(fconf, T7_MPSHITTYPE_F, fs->val.matchtype,
+				fs->mask.matchtype) ||
+		    unsupported(fconf, T7_FRAGMENTATION_F, fs->val.frag, fs->mask.frag) ||
+		    unsupported(fconf, T7_PROTOCOL_F, fs->val.proto, fs->mask.proto) ||
+		    unsupported(fconf, T7_VNIC_ID_F, fs->val.pfvf_vld,
+				fs->mask.pfvf_vld) ||
+		    unsupported(fconf, T7_VNIC_ID_F, fs->val.ovlan_vld,
+				fs->mask.ovlan_vld) ||
+		    unsupported(fconf, T7_VNIC_ID_F, fs->val.encap_vld,
+				fs->mask.encap_vld) ||
+		    unsupported(fconf, T7_VLAN_F, fs->val.ivlan_vld, fs->mask.ivlan_vld))
+			return -EOPNOTSUPP;
+	} else {
+		if (unsupported(fconf, FCOE_F, fs->val.fcoe, fs->mask.fcoe) ||
+		    unsupported(fconf, PORT_F, fs->val.iport, fs->mask.iport) ||
+		    unsupported(fconf, TOS_F, fs->val.tos, fs->mask.tos) ||
+		    unsupported(fconf, ETHERTYPE_F, fs->val.ethtype,
+				fs->mask.ethtype) ||
+		    unsupported(fconf, MACMATCH_F, fs->val.macidx, fs->mask.macidx) ||
+		    unsupported(fconf, MPSHITTYPE_F, fs->val.matchtype,
+				fs->mask.matchtype) ||
+		    unsupported(fconf, FRAGMENTATION_F, fs->val.frag, fs->mask.frag) ||
+		    unsupported(fconf, PROTOCOL_F, fs->val.proto, fs->mask.proto) ||
+		    unsupported(fconf, VNIC_ID_F, fs->val.pfvf_vld,
+				fs->mask.pfvf_vld) ||
+		    unsupported(fconf, VNIC_ID_F, fs->val.ovlan_vld,
+				fs->mask.ovlan_vld) ||
+		    unsupported(fconf, VNIC_ID_F, fs->val.encap_vld,
+				fs->mask.encap_vld) ||
+		    unsupported(fconf, VLAN_F, fs->val.ivlan_vld, fs->mask.ivlan_vld))
+			return -EOPNOTSUPP;
+	}
 	/* T4 inconveniently uses the same FT_VNIC_ID_W bits for both the Outer
 	 * VLAN Tag and PF/VF/VFvld fields based on VNIC_F being set
 	 * in TP_INGRESS_CONFIG.  Hense the somewhat crazy checks
@@ -793,9 +819,12 @@ static int del_filter_wr(struct adapter *adapter, int fidx)
 int set_filter_wr(struct adapter *adapter, int fidx)
 {
 	struct fw_filter2_wr *fwr;
+	unsigned int chip_ver;
 	struct filter_entry *f;
 	struct sk_buff *skb;
 
+	chip_ver = CHELSIO_CHIP_VERSION(adapter->params.chip);
+
 	if (fidx < adapter->tids.nhpftids)
 		f = &adapter->tids.hpftid_tab[fidx];
 	else
@@ -883,8 +912,10 @@ int set_filter_wr(struct adapter *adapter, int fidx)
 	if (f->fs.newsmac)
 		fwr->smac_sel = f->smt->idx;
 	fwr->rx_chan_rx_rpl_iq =
-		htons(FW_FILTER_WR_RX_CHAN_V(0) |
-		      FW_FILTER_WR_RX_RPL_IQ_V(adapter->sge.fw_evtq.abs_id));
+		htons(FW_FILTER_WR_RX_RPL_IQ_V(adapter->sge.fw_evtq.abs_id));
+	if (chip_ver <= CHELSIO_T6)
+		fwr->rx_chan_rx_rpl_iq |=
+			htons(FW_FILTER_WR_RX_CHAN_V(cxgb4_port_e2cchan(f->dev)));
 	fwr->maci_to_matchtypem =
 		htonl(FW_FILTER_WR_MACI_V(f->fs.val.macidx) |
 		      FW_FILTER_WR_MACIM_V(f->fs.mask.macidx) |
@@ -993,7 +1024,9 @@ void clear_filter(struct adapter *adap, struct filter_entry *f)
 		t4_free_encap_mac_filt(adap, pi->viid,
 				       f->fs.val.ovlan & 0x1ff, 0);
 
-	if ((f->fs.hash || is_t6(adap->params.chip)) && f->fs.type)
+	if ((f->fs.hash ||
+	     (CHELSIO_CHIP_VERSION(adap->params.chip) >= CHELSIO_T6)) &&
+	     f->fs.type)
 		cxgb4_clip_release(f->dev, (const u32 *)&f->fs.val.lip, 1);
 
 	/* The zeroing of the filter rule below clears the filter valid,
@@ -1296,20 +1329,16 @@ static void mk_act_open_req6(struct filter_entry *f, struct sk_buff *skb,
 			     unsigned int qid_filterid, struct adapter *adap)
 {
 	struct cpl_t6_act_open_req6 *t6req = NULL;
+	struct cpl_t7_act_open_req6 *t7req = NULL;
 	struct cpl_act_open_req6 *req = NULL;
+	u32 chip_ver;
+	__be32 opt2;
+	__be64 opt0;
 
-	t6req = (struct cpl_t6_act_open_req6 *)__skb_put(skb, sizeof(*t6req));
-	INIT_TP_WR(t6req, 0);
-	req = (struct cpl_act_open_req6 *)t6req;
-	OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_ACT_OPEN_REQ6, qid_filterid));
-	req->local_port = cpu_to_be16(f->fs.val.lport);
-	req->peer_port = cpu_to_be16(f->fs.val.fport);
-	req->local_ip_hi = *(__be64 *)(&f->fs.val.lip);
-	req->local_ip_lo = *(((__be64 *)&f->fs.val.lip) + 1);
-	req->peer_ip_hi = *(__be64 *)(&f->fs.val.fip);
-	req->peer_ip_lo = *(((__be64 *)&f->fs.val.fip) + 1);
-	req->opt0 = cpu_to_be64(NAGLE_V(f->fs.newvlan == VLAN_REMOVE ||
-					f->fs.newvlan == VLAN_REWRITE) |
+	chip_ver = CHELSIO_CHIP_VERSION(adap->params.chip);
+
+	opt0 = cpu_to_be64(NAGLE_V(f->fs.newvlan == VLAN_REMOVE ||
+				   f->fs.newvlan == VLAN_REWRITE) |
 				DELACK_V(f->fs.hitcnts) |
 				L2T_IDX_V(f->l2t ? f->l2t->idx : 0) |
 				SMAC_SEL_V((cxgb4_port_viid(f->dev) &
@@ -1319,52 +1348,90 @@ static void mk_act_open_req6(struct filter_entry *f, struct sk_buff *skb,
 				ULP_MODE_V(f->fs.nat_mode ?
 					   ULP_MODE_TCPDDP : ULP_MODE_NONE) |
 				TCAM_BYPASS_F | NON_OFFLOAD_F);
-	t6req->params = cpu_to_be64(FILTER_TUPLE_V(hash_filter_ntuple(&f->fs,
-								      f->dev)));
-	t6req->opt2 = htonl(RSS_QUEUE_VALID_F |
-			    RSS_QUEUE_V(f->fs.iq) |
-			    TX_QUEUE_V(f->fs.nat_mode) |
-			    T5_OPT_2_VALID_F |
-			    RX_CHANNEL_V(cxgb4_port_e2cchan(f->dev)) |
-			    PACE_V((f->fs.maskhash) |
+	opt2 = cpu_to_be32(RSS_QUEUE_VALID_F |
+			   RSS_QUEUE_V(f->fs.iq) |
+			   TX_QUEUE_V(f->fs.nat_mode) |
+			   T5_OPT_2_VALID_F |
+			   RX_CHANNEL_V(cxgb4_port_e2cchan(f->dev)) |
+			   PACE_V((f->fs.maskhash) |
 				   ((f->fs.dirsteerhash) << 1)));
+
+	if (chip_ver >= CHELSIO_T7) {
+		t7req = (struct cpl_t7_act_open_req6 *)__skb_put(skb, sizeof(*t7req));
+		INIT_TP_WR(t7req, 0);
+		req = (struct cpl_act_open_req6 *)t7req;
+		t7req->opt0 = opt0;
+		t7req->opt2 = opt2;
+		t7req->params = cpu_to_be64(T7_FILTER_TUPLE_V(hash_filter_ntuple(&f->fs, f->dev)));
+	} else {
+		t6req = (struct cpl_t6_act_open_req6 *)__skb_put(skb, sizeof(*t6req));
+		INIT_TP_WR(t6req, 0);
+		req = (struct cpl_act_open_req6 *)t6req;
+		t6req->opt0 = opt0;
+		t6req->opt2 = opt2;
+		t6req->params = cpu_to_be64(FILTER_TUPLE_V(hash_filter_ntuple(&f->fs, f->dev)));
+	}
+
+	OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_ACT_OPEN_REQ6, qid_filterid));
+	req->local_port = cpu_to_be16(f->fs.val.lport);
+	req->peer_port = cpu_to_be16(f->fs.val.fport);
+	req->local_ip_hi = *(__be64 *)(&f->fs.val.lip);
+	req->local_ip_lo = *(((__be64 *)&f->fs.val.lip) + 1);
+	req->peer_ip_hi = *(__be64 *)(&f->fs.val.fip);
+	req->peer_ip_lo = *(((__be64 *)&f->fs.val.fip) + 1);
 }
 
 static void mk_act_open_req(struct filter_entry *f, struct sk_buff *skb,
 			    unsigned int qid_filterid, struct adapter *adap)
 {
 	struct cpl_t6_act_open_req *t6req = NULL;
+	struct cpl_t7_act_open_req *t7req = NULL;
 	struct cpl_act_open_req *req = NULL;
+	u32 chip_ver;
+	__be32 opt2;
+	__be64 opt0;
+
+	chip_ver = CHELSIO_CHIP_VERSION(adap->params.chip);
+
+	opt0 = cpu_to_be64(NAGLE_V(f->fs.newvlan == VLAN_REMOVE ||
+				   f->fs.newvlan == VLAN_REWRITE) |
+			   DELACK_V(f->fs.hitcnts) |
+			   L2T_IDX_V(f->l2t ? f->l2t->idx : 0) |
+			   SMAC_SEL_V((cxgb4_port_viid(f->dev) &
+				       0x7F) << 1) |
+			   TX_CHAN_V(f->fs.eport) |
+			   NO_CONG_V(f->fs.rpttid) |
+			   ULP_MODE_V(f->fs.nat_mode ?
+				      ULP_MODE_TCPDDP : ULP_MODE_NONE) |
+			   TCAM_BYPASS_F | NON_OFFLOAD_F);
+	opt2 = cpu_to_be32(RSS_QUEUE_VALID_F |
+			   RSS_QUEUE_V(f->fs.iq) |
+			   TX_QUEUE_V(f->fs.nat_mode) |
+			   T5_OPT_2_VALID_F |
+			   RX_CHANNEL_V(cxgb4_port_e2cchan(f->dev)) |
+			   PACE_V((f->fs.maskhash) |
+				  ((f->fs.dirsteerhash) << 1)));
+	if (chip_ver >= CHELSIO_T7) {
+		t7req = (struct cpl_t7_act_open_req *)__skb_put(skb, sizeof(*t7req));
+		INIT_TP_WR(t7req, 0);
+		req = (struct cpl_act_open_req *)t7req;
+		t7req->opt0 = opt0;
+		t7req->opt2 = opt2;
+		t7req->params = cpu_to_be64(T7_FILTER_TUPLE_V(hash_filter_ntuple(&f->fs, f->dev)));
+	} else {
+		t6req = (struct cpl_t6_act_open_req *)__skb_put(skb, sizeof(*t6req));
+		INIT_TP_WR(t6req, 0);
+		req = (struct cpl_act_open_req *)t6req;
+		t6req->opt0 = opt0;
+		t6req->opt2 = opt2;
+		t6req->params = cpu_to_be64(FILTER_TUPLE_V(hash_filter_ntuple(&f->fs, f->dev)));
+	}
 
-	t6req = (struct cpl_t6_act_open_req *)__skb_put(skb, sizeof(*t6req));
-	INIT_TP_WR(t6req, 0);
-	req = (struct cpl_act_open_req *)t6req;
 	OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_ACT_OPEN_REQ, qid_filterid));
 	req->local_port = cpu_to_be16(f->fs.val.lport);
 	req->peer_port = cpu_to_be16(f->fs.val.fport);
 	memcpy(&req->local_ip, f->fs.val.lip, 4);
 	memcpy(&req->peer_ip, f->fs.val.fip, 4);
-	req->opt0 = cpu_to_be64(NAGLE_V(f->fs.newvlan == VLAN_REMOVE ||
-					f->fs.newvlan == VLAN_REWRITE) |
-				DELACK_V(f->fs.hitcnts) |
-				L2T_IDX_V(f->l2t ? f->l2t->idx : 0) |
-				SMAC_SEL_V((cxgb4_port_viid(f->dev) &
-					    0x7F) << 1) |
-				TX_CHAN_V(f->fs.eport) |
-				NO_CONG_V(f->fs.rpttid) |
-				ULP_MODE_V(f->fs.nat_mode ?
-					   ULP_MODE_TCPDDP : ULP_MODE_NONE) |
-				TCAM_BYPASS_F | NON_OFFLOAD_F);
-
-	t6req->params = cpu_to_be64(FILTER_TUPLE_V(hash_filter_ntuple(&f->fs,
-								      f->dev)));
-	t6req->opt2 = htonl(RSS_QUEUE_VALID_F |
-			    RSS_QUEUE_V(f->fs.iq) |
-			    TX_QUEUE_V(f->fs.nat_mode) |
-			    T5_OPT_2_VALID_F |
-			    RX_CHANNEL_V(cxgb4_port_e2cchan(f->dev)) |
-			    PACE_V((f->fs.maskhash) |
-				   ((f->fs.dirsteerhash) << 1)));
 }
 
 static int cxgb4_set_hash_filter(struct net_device *dev,
@@ -1663,7 +1730,7 @@ int __cxgb4_set_filter(struct net_device *dev, int ftid,
 	if (ret)
 		goto free_tid;
 
-	if (is_t6(adapter->params.chip) && fs->type &&
+	if (chip_ver >= CHELSIO_T6 && fs->type &&
 	    ipv6_addr_type((const struct in6_addr *)fs->val.lip) !=
 	    IPV6_ADDR_ANY) {
 		ret = cxgb4_clip_get(dev, (const u32 *)&fs->val.lip, 1);
@@ -2140,12 +2207,13 @@ void filter_rpl(struct adapter *adap, const struct cpl_set_tcb_rpl *rpl)
 
 void init_hash_filter(struct adapter *adap)
 {
-	u32 reg;
+	u32 reg, chip_ver;
 
+	chip_ver = CHELSIO_CHIP_VERSION(adap->params.chip);
 	/* On T6, verify the necessary register configs and warn the user in
 	 * case of improper config
 	 */
-	if (is_t6(adap->params.chip)) {
+	if (chip_ver >= CHELSIO_T6) {
 		if (is_offload(adap)) {
 			if (!(t4_read_reg(adap, TP_GLOBAL_CONFIG_A)
 			   & ACTIVEFILTERCOUNTS_F)) {
Signature · 1 line
2.39.1
author maintainer
#9 lore raw

PATCH v5 9/12 cxgb4: Add indirect register definitions for T7

In reply to Potnuri Bharat Teja

Add indirect register definition headers used by the CUDBG infrastructure.

Introduce cudbg_indir_reg.h and cudbg_indir_reg_t7.h containing the indirect registers required for cudbg register collection.

These headers will be used by subsequent patch that add indirect register handling support to cudbg.

---
 .../ethernet/chelsio/cxgb4/cudbg_indir_reg.h  |   43 +
 .../chelsio/cxgb4/cudbg_indir_reg_t7.h        | 1113 +++++++++++++++++
 2 files changed, 1156 insertions(+)
 create mode 100644 drivers/net/ethernet/chelsio/cxgb4/cudbg_indir_reg.h
 create mode 100644 drivers/net/ethernet/chelsio/cxgb4/cudbg_indir_reg_t7.h
drivers/net/ethernet/chelsio/cxgb4/cudbg_indir_reg.h new file +43 -0
new file mode 100644
index 000000000000..a33e003c78d5
@@ -0,0 +1,43 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ *  Copyright (C) 2026 Chelsio Communications.  All rights reserved.
+ */
+
+#ifndef __CUDBG_INDIR_REG_H__
+#define __CUDBG_INDIR_REG_H__
+
+enum cudbg_indir_type {
+	CUDBG_INDIR_TYPE_CIM_CTL,
+	CUDBG_INDIR_TYPE_PM_RX_DBG_CTRL,
+	CUDBG_INDIR_TYPE_PM_TX_DBG_CTRL,
+	CUDBG_INDIR_TYPE_TP_MIB_INDEX,
+	CUDBG_INDIR_TYPE_TP_PIO_ADDR,
+	CUDBG_INDIR_TYPE_TP_TM_PIO_ADDR,
+	CUDBG_INDIR_TYPE_UP,
+	CUDBG_INDIR_TYPE_HMAT6_LOCAL_DEBUG_CFG,
+	CUDBG_INDIR_TYPE_MA_LOCAL_DEBUG_CFG,
+	CUDBG_INDIR_TYPE_MA_LOCAL_DEBUG_PERF_CFG,
+	CUDBG_INDIR_TYPE_MAX, /* New members need to be added at end */
+};
+
+struct cudbg_indir_reg {
+	u32 addr;
+};
+
+struct cudbg_indir_type_entry {
+	struct cudbg_indir_reg *reg_arr;
+	u32 nentries;
+};
+
+#include "cudbg_indir_reg_t7.h"
+
+static inline struct cudbg_indir_type_entry *
+cudbg_get_indir_reg_info(u32 chip_ver, enum cudbg_indir_type type)
+{
+	if (chip_ver >= CHELSIO_T7)
+		return &t7_indir_type_arr[type];
+
+	return NULL;
+}
+
+#endif /* __CUDBG_INDIR_REG_H__ */
drivers/net/ethernet/chelsio/cxgb4/cudbg_indir_reg_t7.h new file +1113 -0

1,113 lines not on this page · raw message

Signature · 1 line
2.39.1
author maintainer
#10 lore raw

PATCH v5 10/12 cxgb4: extend CUDBG support for T7 adapters

In reply to Potnuri Bharat Teja

Update the CUDBG infrastructure to support T7-specific debug data collection.

Add support for collecting CIM IBQ and OBQ debug entities from T7 adapters, including the additional queues introduced by T7 and support for multicore.

Also add T7 indirect register collection support using the new indirect register definitions, while preserving the existing register access mechanism for T5/T6.

Debug tooling needs to read and write individual adapter registers and to read SGE contexts and queue descriptors without collecting a full cudbg dump. Add a private ioctl providing four commands

---
 .../net/ethernet/chelsio/cxgb4/cudbg_entity.h |  114 +-
 drivers/net/ethernet/chelsio/cxgb4/cudbg_if.h |   56 +-
 .../net/ethernet/chelsio/cxgb4/cudbg_lib.c    | 1088 ++++++++++++++---
 .../net/ethernet/chelsio/cxgb4/cudbg_lib.h    |   60 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h    |    1 -
 .../net/ethernet/chelsio/cxgb4/cxgb4_cudbg.c  |   20 +-
 .../net/ethernet/chelsio/cxgb4/cxgb4_main.c   |  242 ++++
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c    |   20 -
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.h    |    1 +
 9 files changed, 1400 insertions(+), 202 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/cudbg_entity.h +100 -14
index d5218e74284c..8295b330a7b9 100644
@@ -21,13 +21,58 @@ struct cudbg_mbox_log {
 	u32 lo[MBOX_LEN / 8];
 };
 
-struct cudbg_cim_qcfg {
-	u8 chip;
-	u16 base[CIM_NUM_IBQ + CIM_NUM_OBQ_T5];
-	u16 size[CIM_NUM_IBQ + CIM_NUM_OBQ_T5];
-	u16 thres[CIM_NUM_IBQ];
-	u32 obq_wr[2 * CIM_NUM_OBQ_T5];
-	u32 stat[4 * (CIM_NUM_IBQ + CIM_NUM_OBQ_T5)];
+#define CUDBG_CIM_IBQ_REV 1
+
+struct cim_ibq_rev1 {
+	struct cudbg_ver_hdr ver_hdr;
+	u8 qid;
+	u8 coreid;
+	u32 data[]; /* Must be last */
+};
+
+#define CUDBG_CIM_OBQ_REV 1
+
+struct cim_obq_rev1 {
+	struct cudbg_ver_hdr ver_hdr;
+	u8 qid;
+	u8 coreid;
+	u32 data[]; /* Must be last */
+};
+
+#define CUDBG_CIM_QCFG_REV 1
+
+enum cudbg_entity_cim_qcfg_qtype {
+	CUDBG_ENTITY_CIM_QCFG_QTYPE_IBQ = 0,
+	CUDBG_ENTITY_CIM_QCFG_QTYPE_OBQ,
+};
+
+struct cim_qcfg_rev1_data {
+	u8 qtype;
+	u8 qid;
+	u16 base;
+	u16 size;
+	u16 thres;
+	u32 obq_wr[2];
+	u32 stat[4];
+};
+
+struct cim_qcfg_rev1 {
+	struct cudbg_ver_hdr ver_hdr;
+	u8 num_cim_ibq;
+	u8 num_cim_obq;
+	u8 coreid;
+	struct cim_qcfg_rev1_data data[]; /* Must be last */
+};
+
+#define CUDBG_CIM_LA_REV 1
+
+struct cim_la_rev1 {
+	struct cudbg_ver_hdr ver_hdr;
+	u8 coreid;
+	u8 ncol;
+	u16 nrow;
+	u32 config;
+	u32 data[]; /* Must be last */
 };
 
 struct cudbg_rss_vf_conf {
@@ -50,6 +95,25 @@ struct cudbg_hw_sched {
 	u32 map;
 };
 
+#define CUDBG_TP_INDIR_REG_REV 1
+#define CUDBG_PM_INDIR_REG_REV 1
+#define CUDBG_MA_INDIR_REG_REV 1
+#define CUDBG_UP_CIM_INDIR_REG_REV 1
+#define CUDBG_HMA_INDIR_REG_REV 1
+
+struct cudbg_indir_reg_data {
+	u32 offset;
+	u32 data;
+};
+
+struct cudbg_indir_reg_entity {
+	struct cudbg_ver_hdr ver_hdr;
+	u32 indir_reg;
+	u32 indir_data;
+	u32 nentries;
+	struct cudbg_indir_reg_data data[];
+};
+
 #define SGE_QBASE_DATA_REG_NUM 4
 
 struct sge_qbase_reg_field {
@@ -91,8 +155,8 @@ static const char * const cudbg_region[] = {
 	"Tx payload:", "Rx payload:", "LE hash:", "iSCSI region:",
 	"TDDP region:", "TPT region:", "STAG region:", "RQ region:",
 	"RQUDP region:", "PBL region:", "TXPBL region:",
-	"DBVFIFO region:", "ULPRX state:", "ULPTX state:",
-	"On-chip queues:"
+	"RRQ region:", "DBVFIFO region:", "ULPRX state:",
+	"ULPTX state:", "On-chip queues:"
 };
 
 /* Memory region info relative to current memory (i.e. wrt 0). */
@@ -187,20 +251,42 @@ struct cudbg_tid_info_region_rev1 {
 	struct cudbg_ver_hdr ver_hdr;
 	struct cudbg_tid_info_region tid;
 	u32 tid_start;
-	u32 reserved[16];
+	u32 nhash;
+	u32 clip_base;
+	u32 nclip;
+	u32 route_base;
+	u32 nroute;
+	u32 reserved[11];
 };
 
 #define CUDBG_LOWMEM_MAX_CTXT_QIDS 256
 #define CUDBG_MAX_FL_QIDS 1024
 
-struct cudbg_ch_cntxt {
-	u32 cntxt_type;
-	u32 cntxt_id;
-	u32 data[SGE_CTXT_SIZE / 4];
+#define CUDBG_SGE_CTXT_REV 1
+
+struct sge_ctxt_rev1_data {
+	u8 ctxt_type;
+	u8 size;
+	u32 ctxt_id;
+	u32 data[];
+};
+
+struct sge_ctxt_rev1 {
+	struct cudbg_ver_hdr ver_hdr;
+	u32 nentries;
+	u8 data[]; /* Must be last */
 };
 
 #define CUDBG_MAX_RPLC_SIZE 128
 
+struct cudbg_cntxt_field {
+	char *name;
+	u32 start_bit;
+	u32 end_bit;
+	u32 shift;
+	u32 islog2;
+};
+
 struct cudbg_mps_tcam {
 	u64 mask;
 	u32 rplc[8];
drivers/net/ethernet/chelsio/cxgb4/cudbg_if.h +53 -3

78 lines not on this page · raw message

drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c +932 -156

1,558 lines not on this page · raw message

drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.h +54 -6

77 lines not on this page · raw message

drivers/net/ethernet/chelsio/cxgb4/cxgb4.h +0 -1
index 8409e759f5ae..bf47aecc4bb3 100644
@@ -1857,7 +1857,6 @@ void t4_setup_memwin(struct adapter *adap, u32 memwin_base, u32 window);
 
 int t4_memory_rw_init(struct adapter *adap, int win, int mtype, u32 *mem_off,
 		      u32 *mem_base, u32 *mem_aperture);
-void t4_memory_update_win(struct adapter *adap, int win, u32 addr);
 void t4_memory_rw_residual(struct adapter *adap, u32 off, u32 addr, u8 *buf,
 			   int dir);
 #define T4_MEMORY_WRITE	0
drivers/net/ethernet/chelsio/cxgb4/cxgb4_cudbg.c +18 -2
index dd66b244466d..f2b98f1b4d61 100644
@@ -27,8 +27,8 @@ static const struct cxgb4_collect_entity cxgb4_collect_hw_dump[] = {
 	{ CUDBG_CIM_IBQ_TP0, cudbg_collect_cim_ibq_tp0 },
 	{ CUDBG_CIM_IBQ_TP1, cudbg_collect_cim_ibq_tp1 },
 	{ CUDBG_CIM_IBQ_ULP, cudbg_collect_cim_ibq_ulp },
-	{ CUDBG_CIM_IBQ_SGE0, cudbg_collect_cim_ibq_sge0 },
-	{ CUDBG_CIM_IBQ_SGE1, cudbg_collect_cim_ibq_sge1 },
+	{ CUDBG_CIM_IBQ_SGE, cudbg_collect_cim_ibq_sge },
+	{ CUDBG_CIM_IBQ_PCIE, cudbg_collect_cim_ibq_pcie },
 	{ CUDBG_CIM_IBQ_NCSI, cudbg_collect_cim_ibq_ncsi },
 	{ CUDBG_CIM_OBQ_ULP0, cudbg_collect_cim_obq_ulp0 },
 	{ CUDBG_CIM_OBQ_ULP1, cudbg_collect_cim_obq_ulp1 },
@@ -64,6 +64,22 @@ static const struct cxgb4_collect_entity cxgb4_collect_hw_dump[] = {
 	{ CUDBG_UP_CIM_INDIRECT, cudbg_collect_up_cim_indirect },
 	{ CUDBG_PBT_TABLE, cudbg_collect_pbt_tables },
 	{ CUDBG_HMA_INDIRECT, cudbg_collect_hma_indirect },
+	{ CUDBG_CIM_IBQ_TP2, cudbg_collect_cim_ibq_tp2 },
+	{ CUDBG_CIM_IBQ_TP3, cudbg_collect_cim_ibq_tp3 },
+	{ CUDBG_CIM_IBQ_IPC1, cudbg_collect_cim_ibq_ipc1 },
+	{ CUDBG_CIM_IBQ_IPC2, cudbg_collect_cim_ibq_ipc2 },
+	{ CUDBG_CIM_IBQ_IPC3, cudbg_collect_cim_ibq_ipc3 },
+	{ CUDBG_CIM_IBQ_IPC4, cudbg_collect_cim_ibq_ipc4 },
+	{ CUDBG_CIM_IBQ_IPC5, cudbg_collect_cim_ibq_ipc5 },
+	{ CUDBG_CIM_IBQ_IPC6, cudbg_collect_cim_ibq_ipc6 },
+	{ CUDBG_CIM_IBQ_IPC7, cudbg_collect_cim_ibq_ipc7 },
+	{ CUDBG_CIM_OBQ_IPC1, cudbg_collect_cim_obq_ipc1 },
+	{ CUDBG_CIM_OBQ_IPC2, cudbg_collect_cim_obq_ipc2 },
+	{ CUDBG_CIM_OBQ_IPC3, cudbg_collect_cim_obq_ipc3 },
+	{ CUDBG_CIM_OBQ_IPC4, cudbg_collect_cim_obq_ipc4 },
+	{ CUDBG_CIM_OBQ_IPC5, cudbg_collect_cim_obq_ipc5 },
+	{ CUDBG_CIM_OBQ_IPC6, cudbg_collect_cim_obq_ipc6 },
+	{ CUDBG_CIM_OBQ_IPC7, cudbg_collect_cim_obq_ipc7 },
 };
 
 static const struct cxgb4_collect_entity cxgb4_collect_flash_dump[] = {
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +242 -0

254 lines not on this page · raw message

drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +0 -20
index 04550a362504..742d417d2e4f 100644
@@ -580,26 +580,6 @@ int t4_memory_rw_init(struct adapter *adap, int win, int mtype, u32 *mem_off,
 	return 0;
 }
 
-/**
- * t4_memory_update_win - Move memory window to specified address.
- * @adap: the adapter
- * @win: PCI-E Memory Window to use
- * @addr: location to move.
- *
- * Move memory window to specified address.
- */
-void t4_memory_update_win(struct adapter *adap, int win, u32 addr)
-{
-	t4_write_reg(adap,
-		     PCIE_MEM_ACCESS_REG(PCIE_MEM_ACCESS_OFFSET_A, win),
-		     addr);
-	/* Read it back to ensure that changes propagate before we
-	 * attempt to use the new value.
-	 */
-	t4_read_reg(adap,
-		    PCIE_MEM_ACCESS_REG(PCIE_MEM_ACCESS_OFFSET_A, win));
-}
-
 /**
  * t4_memory_rw_residual - Read/Write residual data.
  * @adap: the adapter
drivers/net/ethernet/chelsio/cxgb4/t4_hw.h +1 -0
index 13c56fedfc5c..6f45f68e4299 100644
@@ -80,6 +80,7 @@ enum ctxt_type {
 	CTXT_INGRESS,
 	CTXT_FLM,
 	CTXT_CNM,
+	CTXT_MAX,
 };
 
 enum {
Signature · 1 line
2.39.1
author maintainer
#11 lore raw

PATCH v5 11/12 cxgb4: extend debugfs support for T7 adapters

In reply to Potnuri Bharat Teja

Update the debugfs infrastructure to support T7-specific debug data and multicore adapter architectures.

Add support for collecting and displaying debug information from individual CIM cores, including CIM logic analyzer data, queue configuration, and queue state information. Update debugfs handlers to use the multicore-aware access mechanisms required by T7 devices.

Also extend debugfs support for T7-specific CIM IBQ and OBQ layouts, per-core device logs, and related debug entities.

---
 drivers/net/ethernet/chelsio/cxgb4/clip_tbl.c |   10 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h    |    8 -
 .../ethernet/chelsio/cxgb4/cxgb4_debugfs.c    | 1031 ++++++++++++-----
 .../ethernet/chelsio/cxgb4/cxgb4_debugfs.h    |   17 +-
 .../net/ethernet/chelsio/cxgb4/cxgb4_main.c   |    2 +-
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c    |   64 +-
 6 files changed, 789 insertions(+), 343 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/clip_tbl.c +8 -2
index 6954c15d2b82..7c13bc984883 100644
@@ -17,6 +17,7 @@
 #include <net/addrconf.h>
 #include "cxgb4.h"
 #include "clip_tbl.h"
+#include "cxgb4_debugfs.h"
 
 static inline unsigned int ipv4_clip_hash(struct clip_tbl *c, const u32 *key)
 {
@@ -249,12 +250,17 @@ EXPORT_SYMBOL(cxgb4_update_root_dev_clip);
 
 int clip_tbl_show(struct seq_file *seq, void *v)
 {
-	struct adapter *adapter = seq->private;
-	struct clip_tbl *ctbl = adapter->clipt;
+	struct t4_linux_debugfs_data *d = seq->private;
+	struct adapter *adapter = d->adap;
+	struct clip_tbl *ctbl;
 	struct clip_entry *ce;
 	char ip[60];
 	int i;
 
+	ctbl = adapter->clipt;
+	if (!ctbl)
+		return 0;
+
 	read_lock_bh(&ctbl->lock);
 
 	seq_puts(seq, "IP Address                  Users\n");
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h +0 -8
index bf47aecc4bb3..e6250e031609 100644
@@ -455,7 +455,6 @@ struct adapter_params {
 	struct vpd_params vpd;
 	struct pf_resources pfres;
 	struct pci_params pci;
-	struct devlog_params devlogs;
 	struct devlog_params devlog[MAX_UP_CORES];
 	enum pcie_memwin drv_memwin;
 
@@ -1957,12 +1956,8 @@ u8 t4_cim_num_ibq(struct adapter *adap);
 u8 t4_cim_num_obq(struct adapter *adap);
 void t4_read_cimq_cfg_core(struct adapter *adap, u8 coreid, u16 *base,
 			   u16 *size, u16 *thres);
-int t4_read_cim_ibq(struct adapter *adap, unsigned int qid, u32 *data,
-		    size_t n);
 int t4_read_cim_obq_core(struct adapter *adap, u8 coreid, u32 qid, u32 *data,
 			 size_t n);
-int t4_read_cim_obq(struct adapter *adap, unsigned int qid, u32 *data,
-		    size_t n);
 int t4_cim_read_core(struct adapter *adap, u8 group, u8 coreid,
 		     unsigned int addr, unsigned int n, unsigned int *valp);
 int t4_cim_read(struct adapter *adap, unsigned int addr, unsigned int n,
@@ -1970,11 +1965,8 @@ int t4_cim_read(struct adapter *adap, unsigned int addr, unsigned int n,
 int t4_cim_write_core(struct adapter *adap, u8 group, u8 coreid,
 		      unsigned int addr, unsigned int n,
 		      const unsigned int *valp);
-int t4_cim_write(struct adapter *adap, unsigned int addr, unsigned int n,
-		 const unsigned int *valp);
 int t4_cim_read_la_core(struct adapter *adap, u8 coreid, u32 *la_buf,
 			u32 *wrptr);
-int t4_cim_read_la(struct adapter *adap, u32 *la_buf, unsigned int *wrptr);
 void t4_cim_read_pif_la(struct adapter *adap, u32 *pif_req, u32 *pif_rsp,
 			unsigned int *pif_req_wrptr,
 			unsigned int *pif_rsp_wrptr);
drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c +768 -263

1,660 lines not on this page · raw message

drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.h +11 -6
index 1471cf0deb58..77a0ed068baa 100644
@@ -37,7 +37,13 @@
 
 #include <linux/export.h>
 
-struct t4_debugfs_entry {
+struct t4_linux_debugfs_data {
+	struct adapter *adap;
+	unsigned int data;
+	unsigned char coreid;
+};
+
+struct t4_linux_debugfs_entry {
 	const char *name;
 	const struct file_operations *ops;
 	umode_t mode;
@@ -61,10 +67,9 @@ struct seq_tab *seq_open_tab(struct file *f, unsigned int rows,
 			     unsigned int width, unsigned int have_header,
 			     int (*show)(struct seq_file *seq, void *v, int i));
 
-int t4_setup_debugfs(struct adapter *adap);
-void add_debugfs_files(struct adapter *adap,
-		       struct t4_debugfs_entry *files,
-		       unsigned int nfiles);
+void add_debugfs_files(struct adapter *adap, struct dentry *dentry,
+		       unsigned char coreid, struct t4_linux_debugfs_entry *f,
+		       unsigned int n);
 int mem_open(struct inode *inode, struct file *file);
-
+int cxgb4_setup_debugfs(struct adapter *adap);
 #endif
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +1 -1
index a3b1f9db5cbe..563a0ee1ce2c 100644
@@ -7190,7 +7190,7 @@ int cxgb4_adap_probe(struct adapter *adapter)
 		const char *dir_name = pci_name(adapter->pdev);
 
 		adapter->debugfs_root = debugfs_create_dir(dir_name, cxgb4_debugfs_root);
-		t4_setup_debugfs(adapter);
+		cxgb4_setup_debugfs(adapter);
 	}
 
 	if (is_uld(adapter))
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +1 -63

94 lines not on this page · raw message

Signature · 1 line
2.39.1
maintainer
#12 lore raw
In reply to Potnuri Bharat Teja
Quoted 1 line · On Thu, 22 Oct 2026 22:38:17 -0400 Potnuri Bharat Teja wrote:

This series adds support for Chelsio T7 adapters to the cxgb4 driver.

## Form letter - net-next-closed

The merge window for Linux v7.4 has begun, and the net-next tree is now closed for new drivers, features, code refactoring and optimizations. We are currently accepting bug fixes only.

Please repost when net-next reopens. There is some uncertainty about how long this merge window will last, so please check
https://netdev.bots.linux.dev/net-next.html
before reposting. net-next _may_ reopen on Nov 2nd.

See: https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#development-cycle

Signature · 2 lines
pw-bot: defer
pv-bot: closed