Skip to contentSkip to conversation

net: stmmac: add new features to xgmac

PATCH Superseded Jisheng Zhang 4 participants 18 messages Jul 23, 2023 – Jul 26, 2023

Subsystems (5)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

cover net: stmmac: add new features to xgmac

This series add below new features to xgmac:

correct RX COE parsing
add more feature parsing from hw cap enlarge C22 ADDR and rx/tx channels support parse safety ce/ue irq from DT support per channel irq

Jisheng Zhang (10):
net: stmmac: correct RX COE parsing for xgmac
net: stmmac: xgmac: add more feature parsing from hw cap
net: stmmac: mdio: enlarge the max XGMAC C22 ADDR to 31
net: stmmac: enlarge max rx/tx queues and channels to 16
net: stmmac: rename multi_msi_en to perch_irq_en
net: stmmac: xgmac: support per-channel irq
dt-bindings: net: snps,dwmac: add safety irq support
net: stmmac: platform: support parsing safety irqs from DT
dt-bindings: net: snps,dwmac: add per channel irq support
net: stmmac: platform: support parsing per channel irq from DT

 .../devicetree/bindings/net/snps,dwmac.yaml   | 27 +++++++++++++
 .../net/ethernet/stmicro/stmmac/dwmac-intel.c |  4 +-
 .../net/ethernet/stmicro/stmmac/dwmac4_dma.c  |  2 +-
 .../net/ethernet/stmicro/stmmac/dwxgmac2.h    |  5 +++
 .../ethernet/stmicro/stmmac/dwxgmac2_core.c   |  5 +--
 .../ethernet/stmicro/stmmac/dwxgmac2_dma.c    | 37 +++++++++++-------
 .../net/ethernet/stmicro/stmmac/stmmac_main.c | 12 +++---
 .../net/ethernet/stmicro/stmmac/stmmac_mdio.c |  2 +-
 .../ethernet/stmicro/stmmac/stmmac_platform.c | 39 +++++++++++++++++++
 include/linux/stmmac.h                        | 10 ++---
 10 files changed, 112 insertions(+), 31 deletions(-)
Signature · 1 line
2.40.1
#1 lore raw

PATCH 1/10 net: stmmac: correct RX COE parsing for xgmac

xgmac can support RX COE, but there's no two kinds of COE, I.E type 1 and type 2 COE.

---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2 -2
index e1f1c034d325..15ed3947361b 100644
@@ -6271,7 +6271,7 @@ static int stmmac_dma_cap_show(struct seq_file *seq, void *v)
 	seq_printf(seq, "\tAV features: %s\n", (priv->dma_cap.av) ? "Y" : "N");
 	seq_printf(seq, "\tChecksum Offload in TX: %s\n",
 		   (priv->dma_cap.tx_coe) ? "Y" : "N");
-	if (priv->synopsys_id >= DWMAC_CORE_4_00) {
+	if (priv->synopsys_id >= DWMAC_CORE_4_00 || priv->plat->has_xgmac) {
 		seq_printf(seq, "\tIP Checksum Offload in RX: %s\n",
 			   (priv->dma_cap.rx_coe) ? "Y" : "N");
 	} else {
@@ -7013,7 +7013,7 @@ static int stmmac_hw_init(struct stmmac_priv *priv)
 	if (priv->plat->rx_coe) {
 		priv->hw->rx_csum = priv->plat->rx_coe;
 		dev_info(priv->device, "RX Checksum Offload Engine supported\n");
-		if (priv->synopsys_id < DWMAC_CORE_4_00)
+		if (priv->synopsys_id < DWMAC_CORE_4_00 && !priv->plat->has_xgmac)
 			dev_info(priv->device, "COE Type %d\n", priv->hw->rx_csum);
 	}
 	if (priv->plat->tx_coe)
Signature · 1 line
2.40.1
#2 lore raw

PATCH 2/10 net: stmmac: xgmac: add more feature parsing from hw cap

In reply to Jisheng Zhang

The XGMAC_HWFEAT_GMIISEL bit also indicates whether support 10/100Mbps or not.
The XGMAC_HWFEAT_HDSEL bit indicates whether support half duplex or not.
The XGMAC_HWFEAT_ADDMACADRSEL bit indicates whether support Multiple MAC address registers or not.
The XGMAC_HWFEAT_SMASEL bit indicates whether support SMA (MDIO) Interface or not.

---
 drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h     | 3 +++
 drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c | 4 ++++
 2 files changed, 7 insertions(+)
drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h +3 -0
index 153321fe42c3..81cbb13a101d 100644
@@ -111,6 +111,7 @@
 #define XGMAC_LPI_TIMER_CTRL		0x000000d4
 #define XGMAC_HW_FEATURE0		0x0000011c
 #define XGMAC_HWFEAT_SAVLANINS		BIT(27)
+#define XGMAC_HWFEAT_ADDMACADRSEL	GENMASK(22, 18)
 #define XGMAC_HWFEAT_RXCOESEL		BIT(16)
 #define XGMAC_HWFEAT_TXCOESEL		BIT(14)
 #define XGMAC_HWFEAT_EEESEL		BIT(13)
@@ -121,7 +122,9 @@
 #define XGMAC_HWFEAT_MMCSEL		BIT(8)
 #define XGMAC_HWFEAT_MGKSEL		BIT(7)
 #define XGMAC_HWFEAT_RWKSEL		BIT(6)
+#define XGMAC_HWFEAT_SMASEL		BIT(5)
 #define XGMAC_HWFEAT_VLHASH		BIT(4)
+#define XGMAC_HWFEAT_HDSEL		BIT(3)
 #define XGMAC_HWFEAT_GMIISEL		BIT(1)
 #define XGMAC_HW_FEATURE1		0x00000120
 #define XGMAC_HWFEAT_L3L4FNUM		GENMASK(30, 27)
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c +4 -0
index b09395f5edcb..b5ba4e0cca55 100644
@@ -406,6 +406,10 @@ static int dwxgmac2_get_hw_feature(void __iomem *ioaddr,
 	dma_cap->pmt_remote_wake_up = (hw_cap & XGMAC_HWFEAT_RWKSEL) >> 6;
 	dma_cap->vlhash = (hw_cap & XGMAC_HWFEAT_VLHASH) >> 4;
 	dma_cap->mbps_1000 = (hw_cap & XGMAC_HWFEAT_GMIISEL) >> 1;
+	dma_cap->mbps_10_100 = (hw_cap & XGMAC_HWFEAT_GMIISEL) >> 1;
+	dma_cap->half_duplex = (hw_cap & XGMAC_HWFEAT_HDSEL) >> 3;
+	dma_cap->multi_addr = (hw_cap & XGMAC_HWFEAT_ADDMACADRSEL) >> 18;
+	dma_cap->sma_mdio = (hw_cap & XGMAC_HWFEAT_SMASEL) >> 5;
 
 	/* MAC HW feature 1 */
 	hw_cap = readl(ioaddr + XGMAC_HW_FEATURE1);
Signature · 1 line
2.40.1
#3 lore raw

PATCH 3/10 net: stmmac: mdio: enlarge the max XGMAC C22 ADDR to 31

In reply to Jisheng Zhang

The IP can support up to 31 xgmac c22 addresses now.

---
 drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +1 -1
index 3db1cb0fd160..e6d8e34fafef 100644
@@ -40,7 +40,7 @@
 #define MII_XGMAC_WRITE			(1 << MII_XGMAC_CMD_SHIFT)
 #define MII_XGMAC_READ			(3 << MII_XGMAC_CMD_SHIFT)
 #define MII_XGMAC_BUSY			BIT(22)
-#define MII_XGMAC_MAX_C22ADDR		3
+#define MII_XGMAC_MAX_C22ADDR		31
 #define MII_XGMAC_C22P_MASK		GENMASK(MII_XGMAC_MAX_C22ADDR, 0)
 #define MII_XGMAC_PA_SHIFT		16
 #define MII_XGMAC_DA_SHIFT		21
Signature · 1 line
2.40.1
#4 lore raw

PATCH 4/10 net: stmmac: enlarge max rx/tx queues and channels to 16

In reply to Jisheng Zhang

xgmac supports up to 16 rx/tx queues and up to 16 channels.

---
 drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c | 5 ++---
 include/linux/stmmac.h                              | 6 +++---
 2 files changed, 5 insertions(+), 6 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +2 -3
index a0c2ef8bb0ac..aaae82d3d9dc 100644
@@ -202,9 +202,8 @@ static void dwxgmac2_map_mtl_to_dma(struct mac_device_info *hw, u32 queue,
 	void __iomem *ioaddr = hw->pcsr;
 	u32 value, reg;
 
-	reg = (queue < 4) ? XGMAC_MTL_RXQ_DMA_MAP0 : XGMAC_MTL_RXQ_DMA_MAP1;
-	if (queue >= 4)
-		queue -= 4;
+	reg = XGMAC_MTL_RXQ_DMA_MAP0 + (queue & ~0x3);
+	queue &= 0x3;
 
 	value = readl(ioaddr + reg);
 	value &= ~XGMAC_QxMDMACH(queue);
include/linux/stmmac.h +3 -3
index ef67dba775d0..11671fd6adee 100644
@@ -15,9 +15,9 @@
 #include <linux/platform_device.h>
 #include <linux/phy.h>
 
-#define MTL_MAX_RX_QUEUES	8
-#define MTL_MAX_TX_QUEUES	8
-#define STMMAC_CH_MAX		8
+#define MTL_MAX_RX_QUEUES	16
+#define MTL_MAX_TX_QUEUES	16
+#define STMMAC_CH_MAX		16
 
 #define STMMAC_RX_COE_NONE	0
 #define STMMAC_RX_COE_TYPE1	1
Signature · 1 line
2.40.1
#5 lore raw

PATCH 5/10 net: stmmac: rename multi_msi_en to perch_irq_en

In reply to Jisheng Zhang

The IP supports per channel interrupt, when intel adds the per channel interrupt support, the per channel irq is from MSI vector, but this feature can also be supported on non-MSI platforms. Renaming multi_msi_en to perch_irq_en to reflects this fact.

---
 drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c | 4 ++--
 drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c  | 2 +-
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 8 ++++----
 include/linux/stmmac.h                            | 4 ++--
 4 files changed, 9 insertions(+), 9 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +2 -2
index 0ffae785d8bd..99a072907008 100644
@@ -953,7 +953,7 @@ static int stmmac_config_single_msi(struct pci_dev *pdev,
 
 	res->irq = pci_irq_vector(pdev, 0);
 	res->wol_irq = res->irq;
-	plat->flags &= ~STMMAC_FLAG_MULTI_MSI_EN;
+	plat->flags &= ~STMMAC_FLAG_PERCH_IRQ_EN;
 	dev_info(&pdev->dev, "%s: Single IRQ enablement successful\n",
 		 __func__);
 
@@ -1005,7 +1005,7 @@ static int stmmac_config_multi_msi(struct pci_dev *pdev,
 	if (plat->msi_sfty_ue_vec < STMMAC_MSI_VEC_MAX)
 		res->sfty_ue_irq = pci_irq_vector(pdev, plat->msi_sfty_ue_vec);
 
-	plat->flags |= STMMAC_FLAG_MULTI_MSI_EN;
+	plat->flags |= STMMAC_FLAG_PERCH_IRQ_EN;
 	dev_info(&pdev->dev, "%s: multi MSI enablement successful\n", __func__);
 
 	return 0;
drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c +1 -1
index 84d3a8551b03..9bf8adf466a2 100644
@@ -175,7 +175,7 @@ static void dwmac4_dma_init(void __iomem *ioaddr,
 
 	value = readl(ioaddr + DMA_BUS_MODE);
 
-	if (dma_cfg->multi_msi_en) {
+	if (dma_cfg->perch_irq_en) {
 		value &= ~DMA_BUS_MODE_INTM_MASK;
 		value |= (DMA_BUS_MODE_INTM_MODE1 << DMA_BUS_MODE_INTM_SHIFT);
 	}
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +4 -4
index 15ed3947361b..c97bebfd04f8 100644
@@ -3722,7 +3722,7 @@ static int stmmac_request_irq(struct net_device *dev)
 	int ret;
 
 	/* Request the IRQ lines */
-	if (priv->plat->flags & STMMAC_FLAG_MULTI_MSI_EN)
+	if (priv->plat->flags & STMMAC_FLAG_PERCH_IRQ_EN)
 		ret = stmmac_request_irq_multi_msi(dev);
 	else
 		ret = stmmac_request_irq_single(dev);
@@ -6007,7 +6007,7 @@ static void stmmac_poll_controller(struct net_device *dev)
 	if (test_bit(STMMAC_DOWN, &priv->state))
 		return;
 
-	if (priv->plat->flags & STMMAC_FLAG_MULTI_MSI_EN) {
+	if (priv->plat->flags & STMMAC_FLAG_PERCH_IRQ_EN) {
 		for (i = 0; i < priv->plat->rx_queues_to_use; i++)
 			stmmac_msi_intr_rx(0, &priv->dma_conf.rx_queue[i]);
 
@@ -7278,8 +7278,8 @@ int stmmac_dvr_probe(struct device *device,
 	priv->plat = plat_dat;
 	priv->ioaddr = res->addr;
 	priv->dev->base_addr = (unsigned long)res->addr;
-	priv->plat->dma_cfg->multi_msi_en =
-		(priv->plat->flags & STMMAC_FLAG_MULTI_MSI_EN);
+	priv->plat->dma_cfg->perch_irq_en =
+		(priv->plat->flags & STMMAC_FLAG_PERCH_IRQ_EN);
 
 	priv->dev->irq = res->irq;
 	priv->wol_irq = res->wol_irq;
include/linux/stmmac.h +2 -2
index 11671fd6adee..76249117c0ff 100644
@@ -96,7 +96,7 @@ struct stmmac_dma_cfg {
 	int mixed_burst;
 	bool aal;
 	bool eame;
-	bool multi_msi_en;
+	bool perch_irq_en;
 	bool dche;
 };
 
@@ -211,7 +211,7 @@ struct dwmac4_addrs {
 #define STMMAC_FLAG_TSO_EN			BIT(4)
 #define STMMAC_FLAG_SERDES_UP_AFTER_PHY_LINKUP	BIT(5)
 #define STMMAC_FLAG_VLAN_FAIL_Q_EN		BIT(6)
-#define STMMAC_FLAG_MULTI_MSI_EN		BIT(7)
+#define STMMAC_FLAG_PERCH_IRQ_EN		BIT(7)
 #define STMMAC_FLAG_EXT_SNAPSHOT_EN		BIT(8)
 #define STMMAC_FLAG_INT_SNAPSHOT_EN		BIT(9)
 #define STMMAC_FLAG_RX_CLK_RUNS_IN_LPI		BIT(10)
Signature · 1 line
2.40.1
#6 lore raw

PATCH 6/10 net: stmmac: xgmac: support per-channel irq

In reply to Jisheng Zhang

The IP supports per channel interrupt, add support for this usage case.

---
 .../net/ethernet/stmicro/stmmac/dwxgmac2.h    |  2 ++
 .../ethernet/stmicro/stmmac/dwxgmac2_dma.c    | 33 +++++++++++--------
 2 files changed, 22 insertions(+), 13 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h +2 -0
index 81cbb13a101d..12e1228ccf2a 100644
@@ -327,6 +327,8 @@
 
 /* DMA Registers */
 #define XGMAC_DMA_MODE			0x00003000
+#define XGMAC_INTM			GENMASK(13, 12)
+#define XGMAC_INTM_MODE1		0x1
 #define XGMAC_SWR			BIT(0)
 #define XGMAC_DMA_SYSBUS_MODE		0x00003004
 #define XGMAC_WR_OSR_LMT		GENMASK(29, 24)
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c +20 -13
index b5ba4e0cca55..ef25af92d6cc 100644
@@ -31,6 +31,13 @@ static void dwxgmac2_dma_init(void __iomem *ioaddr,
 		value |= XGMAC_EAME;
 
 	writel(value, ioaddr + XGMAC_DMA_SYSBUS_MODE);
+
+	if (dma_cfg->perch_irq_en) {
+		value = readl(ioaddr + XGMAC_DMA_MODE);
+		value &= ~XGMAC_INTM;
+		value |= FIELD_PREP(XGMAC_INTM, XGMAC_INTM_MODE1);
+		writel(value, ioaddr + XGMAC_DMA_MODE);
+	}
 }
 
 static void dwxgmac2_dma_init_chan(struct stmmac_priv *priv,
@@ -365,20 +372,20 @@ static int dwxgmac2_dma_interrupt(struct stmmac_priv *priv,
 	}
 
 	/* TX/RX NORMAL interrupts */
-	if (likely(intr_status & XGMAC_NIS)) {
-		if (likely(intr_status & XGMAC_RI)) {
-			u64_stats_update_begin(&rx_q->rxq_stats.syncp);
-			rx_q->rxq_stats.rx_normal_irq_n++;
-			u64_stats_update_end(&rx_q->rxq_stats.syncp);
-			ret |= handle_rx;
-		}
-		if (likely(intr_status & (XGMAC_TI | XGMAC_TBU))) {
-			u64_stats_update_begin(&tx_q->txq_stats.syncp);
-			tx_q->txq_stats.tx_normal_irq_n++;
-			u64_stats_update_end(&tx_q->txq_stats.syncp);
-			ret |= handle_tx;
-		}
+	if (likely(intr_status & XGMAC_RI)) {
+		u64_stats_update_begin(&rx_q->rxq_stats.syncp);
+		rx_q->rxq_stats.rx_normal_irq_n++;
+		u64_stats_update_end(&rx_q->rxq_stats.syncp);
+		ret |= handle_rx;
+	}
+	if (likely(intr_status & XGMAC_TI)) {
+		u64_stats_update_begin(&tx_q->txq_stats.syncp);
+		tx_q->txq_stats.tx_normal_irq_n++;
+		u64_stats_update_end(&tx_q->txq_stats.syncp);
+		ret |= handle_tx;
 	}
+	if (unlikely(intr_status & XGMAC_TBU))
+		ret |= handle_tx;
 
 	/* Clear interrupts */
 	writel(intr_en & intr_status, ioaddr + XGMAC_DMA_CH_STATUS(chan));
Signature · 1 line
2.40.1
#7 lore raw

PATCH 7/10 dt-bindings: net: snps,dwmac: add safety irq support

In reply to Jisheng Zhang

The snps dwmac IP support safety features, and those Safety Feature Correctible Error and Uncorrectible Error irqs may be separate irqs.

---
 Documentation/devicetree/bindings/net/snps,dwmac.yaml | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/net/snps,dwmac.yaml +4 -0
index ddf9522a5dc2..bb80ca205d26 100644
@@ -107,6 +107,8 @@ properties:
       - description: Combined signal for various interrupt events
       - description: The interrupt to manage the remote wake-up packet detection
       - description: The interrupt that occurs when Rx exits the LPI state
+      - description: The interrupt that occurs when Safety Feature Correctible Errors happen
+      - description: The interrupt that occurs when Safety Feature Uncorrectible Errors happen
 
   interrupt-names:
     minItems: 1
@@ -114,6 +116,8 @@ properties:
       - const: macirq
       - enum: [eth_wake_irq, eth_lpi]
       - const: eth_lpi
+      - const: sfty_ce_irq
+      - const: sfty_ue_irq
 
   clocks:
     minItems: 1
Signature · 1 line
2.40.1
#11 lore raw

PATCH 8/10 net: stmmac: platform: support parsing safety irqs from DT

In reply to Jisheng Zhang

The snps dwmac IP may support safety features, and those Safety Feature Correctible Error and Uncorrectible Error irqs may be separate irqs. Add support to parse the safety irqs from DT.

---
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c    | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +12 -0
index 23d53ea04b24..e1b7a3fefd1a 100644
@@ -738,6 +738,18 @@ int stmmac_get_platform_resources(struct platform_device *pdev,
 		dev_info(&pdev->dev, "IRQ eth_lpi not found\n");
 	}
 
+	stmmac_res->sfty_ce_irq = platform_get_irq_byname_optional(pdev, "sfty_ce_irq");
+	if (stmmac_res->sfty_ce_irq < 0) {
+		if (stmmac_res->sfty_ce_irq == -EPROBE_DEFER)
+			return -EPROBE_DEFER;
+	}
+
+	stmmac_res->sfty_ue_irq = platform_get_irq_byname_optional(pdev, "sfty_ue_irq");
+	if (stmmac_res->sfty_ue_irq < 0) {
+		if (stmmac_res->sfty_ue_irq == -EPROBE_DEFER)
+			return -EPROBE_DEFER;
+	}
+
 	stmmac_res->addr = devm_platform_ioremap_resource(pdev, 0);
 
 	return PTR_ERR_OR_ZERO(stmmac_res->addr);
Signature · 1 line
2.40.1
#12 lore raw

PATCH 9/10 dt-bindings: net: snps,dwmac: add per channel irq support

In reply to Jisheng Zhang

The IP supports per channel interrupt, add support for this usage case.

---
 .../devicetree/bindings/net/snps,dwmac.yaml   | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)
Documentation/devicetree/bindings/net/snps,dwmac.yaml +23 -0
index bb80ca205d26..525210c2c06c 100644
@@ -101,6 +101,11 @@ properties:
     minItems: 1
     maxItems: 2
 
+  snps,per-channel-interrupt:
+    $ref: /schemas/types.yaml#/definitions/flag
+    description:
+      Indicates that Rx and Tx complete will generate a unique interrupt for each channel
+
   interrupts:
     minItems: 1
     items:
@@ -109,6 +114,8 @@ properties:
       - description: The interrupt that occurs when Rx exits the LPI state
       - description: The interrupt that occurs when Safety Feature Correctible Errors happen
       - description: The interrupt that occurs when Safety Feature Uncorrectible Errors happen
+      - description: All of the rx per-channel interrupts
+      - description: All of the tx per-channel interrupts
 
   interrupt-names:
     minItems: 1
@@ -118,6 +125,22 @@ properties:
       - const: eth_lpi
       - const: sfty_ce_irq
       - const: sfty_ue_irq
+      - const: rx0
+      - const: rx1
+      - const: rx2
+      - const: rx3
+      - const: rx4
+      - const: rx5
+      - const: rx6
+      - const: rx7
+      - const: tx0
+      - const: tx1
+      - const: tx2
+      - const: tx3
+      - const: tx4
+      - const: tx5
+      - const: tx6
+      - const: tx7
 
   clocks:
     minItems: 1
Signature · 1 line
2.40.1
#16 lore raw

PATCH 10/10 net: stmmac: platform: support parsing per channel irq from DT

In reply to Jisheng Zhang

The snps dwmac IP may support per channel interrupt. Add support to parse the per channel irq from DT.

---
 .../ethernet/stmicro/stmmac/stmmac_platform.c | 27 +++++++++++++++++++
 1 file changed, 27 insertions(+)
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +27 -0
index e1b7a3fefd1a..16fff66c578b 100644
@@ -539,10 +539,14 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac)
 	if (of_device_is_compatible(np, "snps,dwxgmac")) {
 		plat->has_xgmac = 1;
 		plat->pmt = 1;
+
 		if (of_property_read_bool(np, "snps,tso"))
 			plat->flags |= STMMAC_FLAG_TSO_EN;
 	}
 
+	if (of_property_read_bool(np, "snps,per-channel-interrupt"))
+		plat->flags |= STMMAC_FLAG_PERCH_IRQ_EN;
+
 	dma_cfg = devm_kzalloc(&pdev->dev, sizeof(*dma_cfg),
 			       GFP_KERNEL);
 	if (!dma_cfg) {
@@ -705,6 +709,9 @@ EXPORT_SYMBOL_GPL(stmmac_remove_config_dt);
 int stmmac_get_platform_resources(struct platform_device *pdev,
 				  struct stmmac_resources *stmmac_res)
 {
+	char irq_name[8];
+	int i;
+
 	memset(stmmac_res, 0, sizeof(*stmmac_res));
 
 	/* Get IRQ information early to have an ability to ask for deferred
@@ -738,6 +745,26 @@ int stmmac_get_platform_resources(struct platform_device *pdev,
 		dev_info(&pdev->dev, "IRQ eth_lpi not found\n");
 	}
 
+	for (i = 0; i < MTL_MAX_RX_QUEUES; i++) {
+		snprintf(irq_name, sizeof(irq_name), "rx%i", i);
+		stmmac_res->rx_irq[i] = platform_get_irq_byname_optional(pdev, irq_name);
+		if (stmmac_res->rx_irq[i] < 0) {
+			if (stmmac_res->rx_irq[i] == -EPROBE_DEFER)
+				return -EPROBE_DEFER;
+			break;
+		}
+	}
+
+	for (i = 0; i < MTL_MAX_TX_QUEUES; i++) {
+		snprintf(irq_name, sizeof(irq_name), "tx%i", i);
+		stmmac_res->tx_irq[i] = platform_get_irq_byname_optional(pdev, irq_name);
+		if (stmmac_res->tx_irq[i] < 0) {
+			if (stmmac_res->tx_irq[i] == -EPROBE_DEFER)
+				return -EPROBE_DEFER;
+			break;
+		}
+	}
+
 	stmmac_res->sfty_ce_irq = platform_get_irq_byname_optional(pdev, "sfty_ce_irq");
 	if (stmmac_res->sfty_ce_irq < 0) {
 		if (stmmac_res->sfty_ce_irq == -EPROBE_DEFER)
Signature · 1 line
2.40.1
Acked-by on v1 7/10
#8 lore raw

Re: [PATCH net-next 07/10] dt-bindings: net: snps,dwmac: add safety irq support

In reply to Jisheng Zhang
Quoted 22 lines · Jisheng Zhang

The snps dwmac IP support safety features, and those Safety Feature Correctible Error and Uncorrectible Error irqs may be separate irqs.

---
 Documentation/devicetree/bindings/net/snps,dwmac.yaml | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/net/snps,dwmac.yaml +2 -0
index ddf9522a5dc2..bb80ca205d26 100644
@@ -107,6 +107,8 @@ properties:
       - description: Combined signal for various interrupt events
       - description: The interrupt to manage the remote wake-up packet detection
       - description: The interrupt that occurs when Rx exits the LPI state
+      - description: The interrupt that occurs when Safety Feature Correctible Errors happen
+      - description: The interrupt that occurs when Safety Feature Uncorrectible Errors happen
 
   interrupt-names:
     minItems: 1

Documentation/devicetree/bindings/net/snps,dwmac.yaml properties: · line 120

Quoted 5 lines
Documentation/devicetree/bindings/net/snps,dwmac.yaml +2 -0
@@ -114,6 +116,8 @@ properties:
       - const: macirq
       - enum: [eth_wake_irq, eth_lpi]
       - const: eth_lpi
+      - const: sfty_ce_irq
+      - const: sfty_ue_irq

Putting _irq in an interrupt name seems rather redundant to me although, clearly not the first time for it here.

Thanks,
Conor.

#13 lore raw

Re: [PATCH net-next 09/10] dt-bindings: net: snps,dwmac: add per channel irq support

In reply to Jisheng Zhang

Hey Jisheng,

Quoted 3 lines · Jisheng Zhang

The IP supports per channel interrupt, add support for this usage case.

Silly question perhaps, but the commit message and description for this property imply that this is an optional feature that software may choose to make use of, but will function without. Is that the case?

Quoted 55 lines
---
 .../devicetree/bindings/net/snps,dwmac.yaml   | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)
Documentation/devicetree/bindings/net/snps,dwmac.yaml +23 -0
index bb80ca205d26..525210c2c06c 100644
@@ -101,6 +101,11 @@ properties:
     minItems: 1
     maxItems: 2
 
+  snps,per-channel-interrupt:
+    $ref: /schemas/types.yaml#/definitions/flag
+    description:
+      Indicates that Rx and Tx complete will generate a unique interrupt for each channel
+
   interrupts:
     minItems: 1
     items:
@@ -109,6 +114,8 @@ properties:
       - description: The interrupt that occurs when Rx exits the LPI state
       - description: The interrupt that occurs when Safety Feature Correctible Errors happen
       - description: The interrupt that occurs when Safety Feature Uncorrectible Errors happen
+      - description: All of the rx per-channel interrupts
+      - description: All of the tx per-channel interrupts
 
   interrupt-names:
     minItems: 1
@@ -118,6 +125,22 @@ properties:
       - const: eth_lpi
       - const: sfty_ce_irq
       - const: sfty_ue_irq
+      - const: rx0
+      - const: rx1
+      - const: rx2
+      - const: rx3
+      - const: rx4
+      - const: rx5
+      - const: rx6
+      - const: rx7
+      - const: tx0
+      - const: tx1
+      - const: tx2
+      - const: tx3
+      - const: tx4
+      - const: tx5
+      - const: tx6
+      - const: tx7
 
   clocks:
     minItems: 1
Signature · 1 line
2.40.1
maintainer
#17 lore raw
In reply to Jisheng Zhang
Quoted 7 lines · On Mon, 24 Jul 2023 00:10:19 +0800 Jisheng Zhang wrote:

This series add below new features to xgmac:

correct RX COE parsing
add more feature parsing from hw cap enlarge C22 ADDR and rx/tx channels support parse safety ce/ue irq from DT support per channel irq

Giuseppe, please take a look (try 3/3).

maintainer
#9 lore raw

Re: [PATCH net-next 07/10] dt-bindings: net: snps,dwmac: add safety irq support

In reply to Conor Dooley
Quoted 20 lines · Conor Dooley
Quoted 19 lines · Jisheng Zhang

The snps dwmac IP support safety features, and those Safety Feature Correctible Error and Uncorrectible Error irqs may be separate irqs.

---
 Documentation/devicetree/bindings/net/snps,dwmac.yaml | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/net/snps,dwmac.yaml +2 -0
index ddf9522a5dc2..bb80ca205d26 100644
@@ -107,6 +107,8 @@ properties:
       - description: Combined signal for various interrupt events
       - description: The interrupt to manage the remote wake-up packet detection
       - description: The interrupt that occurs when Rx exits the LPI state
+      - description: The interrupt that occurs when Safety Feature Correctible Errors happen
+      - description: The interrupt that occurs when Safety Feature Uncorrectible Errors happen
 
Quoted 11 lines

Documentation/devicetree/bindings/net/snps,dwmac.yaml properties: · line 120

Quoted 8 lines
Documentation/devicetree/bindings/net/snps,dwmac.yaml +2 -0
   interrupt-names:
     minItems: 1
@@ -114,6 +116,8 @@ properties:
       - const: macirq
       - enum: [eth_wake_irq, eth_lpi]
       - const: eth_lpi
+      - const: sfty_ce_irq
+      - const: sfty_ue_irq

Putting _irq in an interrupt name seems rather redundant to me although, clearly not the first time for it here.

It's already inconsistent, so don't follow that pattern. Drop '_irq'.

Quoted 5 lines

Thanks,
Conor.

#10 lore raw

Re: [PATCH net-next 07/10] dt-bindings: net: snps,dwmac: add safety irq support

Quoted 33 lines · Rob Herring
Quoted 20 lines · Conor Dooley
Quoted 19 lines · Jisheng Zhang

The snps dwmac IP support safety features, and those Safety Feature Correctible Error and Uncorrectible Error irqs may be separate irqs.

---
 Documentation/devicetree/bindings/net/snps,dwmac.yaml | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/net/snps,dwmac.yaml +2 -0
index ddf9522a5dc2..bb80ca205d26 100644
@@ -107,6 +107,8 @@ properties:
       - description: Combined signal for various interrupt events
       - description: The interrupt to manage the remote wake-up packet detection
       - description: The interrupt that occurs when Rx exits the LPI state
+      - description: The interrupt that occurs when Safety Feature Correctible Errors happen
+      - description: The interrupt that occurs when Safety Feature Uncorrectible Errors happen
 
Quoted 11 lines

Documentation/devicetree/bindings/net/snps,dwmac.yaml properties: · line 120

Quoted 8 lines
Documentation/devicetree/bindings/net/snps,dwmac.yaml +2 -0
   interrupt-names:
     minItems: 1
@@ -114,6 +116,8 @@ properties:
       - const: macirq
       - enum: [eth_wake_irq, eth_lpi]
       - const: eth_lpi
+      - const: sfty_ce_irq
+      - const: sfty_ue_irq

Putting _irq in an interrupt name seems rather redundant to me although, clearly not the first time for it here.

Quoted 1 line

It's already inconsistent, so don't follow that pattern. Drop '_irq'.

Thanks for the suggestion, will wait a bit to get more feedbacks before sending out v2.

Quoted 8 lines
Quoted 6 lines

Thanks,
Conor.

maintainer
#14 lore raw

Re: [PATCH net-next 09/10] dt-bindings: net: snps,dwmac: add per channel irq support

In reply to Jisheng Zhang
Quoted 12 lines · Jisheng Zhang

The IP supports per channel interrupt, add support for this usage case.

---
 .../devicetree/bindings/net/snps,dwmac.yaml   | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)
Documentation/devicetree/bindings/net/snps,dwmac.yaml +0 -0
index bb80ca205d26..525210c2c06c 100644

Documentation/devicetree/bindings/net/snps,dwmac.yaml properties: · line 107

Quoted 7 lines
Documentation/devicetree/bindings/net/snps,dwmac.yaml +4 -0
@@ -101,6 +101,11 @@ properties:
     minItems: 1
     maxItems: 2
 
+  snps,per-channel-interrupt:
+    $ref: /schemas/types.yaml#/definitions/flag
+    description:
+      Indicates that Rx and Tx complete will generate a unique interrupt for each channel

Can't you determine this based on the number of interrupts or interrupt names?

Documentation/devicetree/bindings/net/snps,dwmac.yaml properties: · line 118

Quoted 10 lines
Documentation/devicetree/bindings/net/snps,dwmac.yaml +3 -0
+
   interrupts:
     minItems: 1
     items:
@@ -109,6 +114,8 @@ properties:
       - description: The interrupt that occurs when Rx exits the LPI state
       - description: The interrupt that occurs when Safety Feature Correctible Errors happen
       - description: The interrupt that occurs when Safety Feature Uncorrectible Errors happen
+      - description: All of the rx per-channel interrupts
+      - description: All of the tx per-channel interrupts

You added 2 interrupts here and...

Quoted 13 lines
Documentation/devicetree/bindings/net/snps,dwmac.yaml +6 -0
   interrupt-names:
     minItems: 1
@@ -118,6 +125,22 @@ properties:
       - const: eth_lpi
       - const: sfty_ce_irq
       - const: sfty_ue_irq
+      - const: rx0
+      - const: rx1
+      - const: rx2
+      - const: rx3
+      - const: rx4
+      - const: rx5

Documentation/devicetree/bindings/net/snps,dwmac.yaml properties: · line 143

Quoted 10 lines
Documentation/devicetree/bindings/net/snps,dwmac.yaml +10 -0
+      - const: rx6
+      - const: rx7
+      - const: tx0
+      - const: tx1
+      - const: tx2
+      - const: tx3
+      - const: tx4
+      - const: tx5
+      - const: tx6
+      - const: tx7

And 16 here?

Quoted 6 lines
Documentation/devicetree/bindings/net/snps,dwmac.yaml +0 -0
   clocks:
     minItems: 1
Signature · 1 line
2.40.1
#15 lore raw

Re: [PATCH net-next 09/10] dt-bindings: net: snps,dwmac: add per channel irq support

Quoted 16 lines · Rob Herring
Quoted 15 lines · Jisheng Zhang

The IP supports per channel interrupt, add support for this usage case.

---
 .../devicetree/bindings/net/snps,dwmac.yaml   | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)
Documentation/devicetree/bindings/net/snps,dwmac.yaml +0 -0
index bb80ca205d26..525210c2c06c 100644
@@ -101,6 +101,11 @@ properties:
     minItems: 1
     maxItems: 2
 
Quoted 7 lines

Documentation/devicetree/bindings/net/snps,dwmac.yaml properties: · line 107

Quoted 4 lines
Documentation/devicetree/bindings/net/snps,dwmac.yaml +4 -0
+  snps,per-channel-interrupt:
+    $ref: /schemas/types.yaml#/definitions/flag
+    description:
+      Indicates that Rx and Tx complete will generate a unique interrupt for each channel

Can't you determine this based on the number of interrupts or interrupt names?

Good idea! this flag can be dynamically detected based on the interrupt names. The driver code will be patched a bit ugly, I will try and send out for review.

Quoted 13 lines

Documentation/devicetree/bindings/net/snps,dwmac.yaml properties: · line 118

Quoted 11 lines
Documentation/devicetree/bindings/net/snps,dwmac.yaml +3 -0
+
   interrupts:
     minItems: 1
     items:
@@ -109,6 +114,8 @@ properties:
       - description: The interrupt that occurs when Rx exits the LPI state
       - description: The interrupt that occurs when Safety Feature Correctible Errors happen
       - description: The interrupt that occurs when Safety Feature Uncorrectible Errors happen
+      - description: All of the rx per-channel interrupts
+      - description: All of the tx per-channel interrupts

You added 2 interrupts here and...

I'm not sure how to write the description here, could it be one line
"- description: All of the tx/rx per-channel interrupts"?

Quoted 18 lines
Quoted 18 lines
Documentation/devicetree/bindings/net/snps,dwmac.yaml +10 -0
   interrupt-names:
     minItems: 1
@@ -118,6 +125,22 @@ properties:
       - const: eth_lpi
       - const: sfty_ce_irq
       - const: sfty_ue_irq
+      - const: rx0
+      - const: rx1
+      - const: rx2
+      - const: rx3
+      - const: rx4
+      - const: rx5
+      - const: rx6
+      - const: rx7
+      - const: tx0
+      - const: tx1
Quoted 9 lines

Documentation/devicetree/bindings/net/snps,dwmac.yaml properties: · line 143

Quoted 6 lines
Documentation/devicetree/bindings/net/snps,dwmac.yaml +6 -0
+      - const: tx2
+      - const: tx3
+      - const: tx4
+      - const: tx5
+      - const: tx6
+      - const: tx7

And 16 here?

oops, indeed HW supports up to 16 channels for tx and rx, thus up to 16 interrupts.

Quoted 6 lines
Quoted 6 lines
Documentation/devicetree/bindings/net/snps,dwmac.yaml +0 -0
   clocks:
     minItems: 1
Signature · 1 line
2.40.1