Skip to contentSkip to conversation

add some features in stmmac

PATCH Superseded Biao Huang 2 participants 5 messages May 29, 2019 – May 30, 2019

Subsystems (5)

v5 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Biao Huang

author
#0 lore raw

PATCH v5 1/1 add some features in stmmac

Changes in v5:
1. run checkpatch.pl to fix coding style issue.
2. apply reverse xmas tree ordering.
3. add output log of "ethtool -t eth0" to commit message.

Changes in v4:
retain the reverse xmas tree ordering.

Changes in v3:
rewrite the patch base on serires in
https://patchwork.ozlabs.org/project/netdev/list/?series=109699

Changes in v2;
1. reverse Christmas tree order in dwmac4_set_filter.
2. remove clause 45 patch, waiting for cl45 patch from Boon Leong

v1:
This series add some features in stmmac driver.
1. add support for hash table size 128/256
2. add mdio clause 45 access from mac device for dwmac4.

Biao Huang (1):
net: stmmac: add support for hash table size 128/256 in dwmac4

 drivers/net/ethernet/stmicro/stmmac/common.h      |    7 +--                   
 drivers/net/ethernet/stmicro/stmmac/dwmac4.h      |    4 +-                    
 drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c |   49 ++++++++++++--------- 
 drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c  |    1 +                     
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c |    6 +++                   
 5 files changed, 42 insertions(+), 25 deletions(-)                             
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH v5 1/1 net: stmmac: add support for hash table size 128/256 in dwmac4

1. get hash table size in hw feature reigster, and add support for taller hash table(128/256) in dwmac4.
2. only clear GMAC_PACKET_FILTER bits used in this function, to avoid side effect to functions of other bits.

stmmac selftests output log:
ethtool -t eth0
The test result is FAIL
The test extra info:
1. MAC Loopback 0
2. PHY Loopback -95
3. MMC Counters 0
4. EEE -95
5. Hash Filter MC 0
6. Perfect Filter UC 0
7. MC Filter 0
8. UC Filter 0
9. Flow Control 1

---
 drivers/net/ethernet/stmicro/stmmac/common.h      |    7 +--
 drivers/net/ethernet/stmicro/stmmac/dwmac4.h      |    4 +-
 drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c |   49 ++++++++++++---------
 drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c  |    1 +
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c |    6 +++
 5 files changed, 42 insertions(+), 25 deletions(-)
drivers/net/ethernet/stmicro/stmmac/common.h +4 -3
index 1961fe9..26bbcd8 100644
@@ -335,6 +335,7 @@ struct dma_features {
 	/* 802.3az - Energy-Efficient Ethernet (EEE) */
 	unsigned int eee;
 	unsigned int av;
+	unsigned int hash_tb_sz;
 	unsigned int tsoen;
 	/* TX and RX csum */
 	unsigned int tx_coe;
@@ -428,9 +429,9 @@ struct mac_device_info {
 	struct mii_regs mii;	/* MII register Addresses */
 	struct mac_link link;
 	void __iomem *pcsr;     /* vpointer to device CSRs */
-	int multicast_filter_bins;
-	int unicast_filter_entries;
-	int mcast_bits_log2;
+	unsigned int multicast_filter_bins;
+	unsigned int unicast_filter_entries;
+	unsigned int mcast_bits_log2;
 	unsigned int rx_csum;
 	unsigned int pcs;
 	unsigned int pmt;
drivers/net/ethernet/stmicro/stmmac/dwmac4.h +2 -2
index 01c1089..b68785f7 100644
@@ -18,8 +18,7 @@
 /*  MAC registers */
 #define GMAC_CONFIG			0x00000000
 #define GMAC_PACKET_FILTER		0x00000008
-#define GMAC_HASH_TAB_0_31		0x00000010
-#define GMAC_HASH_TAB_32_63		0x00000014
+#define GMAC_HASH_TAB(x)		(0x10 + (x) * 4)
 #define GMAC_RX_FLOW_CTRL		0x00000090
 #define GMAC_QX_TX_FLOW_CTRL(x)		(0x70 + x * 4)
 #define GMAC_TXQ_PRTY_MAP0		0x98
@@ -184,6 +183,7 @@ enum power_event {
 #define GMAC_HW_FEAT_MIISEL		BIT(0)
 
 /* MAC HW features1 bitmap */
+#define GMAC_HW_HASH_TB_SZ		GENMASK(25, 24)
 #define GMAC_HW_FEAT_AVSEL		BIT(20)
 #define GMAC_HW_TSOEN			BIT(18)
 #define GMAC_HW_TXFIFOSIZE		GENMASK(10, 6)
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +29 -20

70 lines not on this page · raw message

drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c +1 -0
index edb6053..59afb53 100644
@@ -354,6 +354,7 @@ static void dwmac4_get_hw_feature(void __iomem *ioaddr,
 
 	/* MAC HW feature1 */
 	hw_cap = readl(ioaddr + GMAC_HW_FEATURE1);
+	dma_cap->hash_tb_sz = (hw_cap & GMAC_HW_HASH_TB_SZ) >> 24;
 	dma_cap->av = (hw_cap & GMAC_HW_FEAT_AVSEL) >> 20;
 	dma_cap->tsoen = (hw_cap & GMAC_HW_TSOEN) >> 18;
 	/* RX and TX FIFO sizes are encoded as log2(n / 128). Undo that by
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +6 -0
index 8fcbf22..f7aac15 100644
@@ -4166,6 +4166,12 @@ static int stmmac_hw_init(struct stmmac_priv *priv)
 		priv->plat->enh_desc = priv->dma_cap.enh_desc;
 		priv->plat->pmt = priv->dma_cap.pmt_remote_wake_up;
 		priv->hw->pmt = priv->plat->pmt;
+		if (priv->dma_cap.hash_tb_sz) {
+			priv->hw->multicast_filter_bins =
+					(BIT(priv->dma_cap.hash_tb_sz) << 5);
+			priv->hw->mcast_bits_log2 =
+					ilog2(priv->hw->multicast_filter_bins);
+		}
 
 		/* TXCOE doesn't work in thresh DMA mode */
 		if (priv->plat->force_thresh_dma_mode)
Signature · 1 line
1.7.9.5
#2 lore raw

RE: [v5, PATCH] net: stmmac: add support for hash table size 128/256 in dwmac4

From: Biao Huang <[email protected]>
Date: Wed, May 29, 2019 at 10:31:08

Quoted 5 lines

1. get hash table size in hw feature reigster, and add support for taller hash table(128/256) in dwmac4.
2. only clear GMAC_PACKET_FILTER bits used in this function, to avoid side effect to functions of other bits.

Quoted 13 lines

stmmac selftests output log:
ethtool -t eth0
The test result is FAIL
The test extra info:
1. MAC Loopback 0
2. PHY Loopback -95
3. MMC Counters 0
4. EEE -95
5. Hash Filter MC 0
6. Perfect Filter UC 0
7. MC Filter 0
8. UC Filter 0
9. Flow Control 1

Thanks for testing, this patch looks good to me.

Do you want to check why Flow Control selftest is failing ?

Thanks,
Jose Miguel Abreu

author
#3 lore raw

RE: [v5, PATCH] net: stmmac: add support for hash table size 128/256 in dwmac4

Hi Jose,
Flow control is disabled in v5 commit.

I tried "insmod stmmac flow_ctrl=1", and the output log shows self test
pass:
ethtool -t eth0
The test result is PASS
The test extra info:

 	 1. MAC Loopback                 0
 	 2. PHY Loopback                 -95
 	 3. MMC Counters                 0
 	 4. EEE                          -95
 	 5. Hash Filter MC               0
 	 6. Perfect Filter UC            0
 	 7. MC Filter                    0
 	 8. UC Filter                    0

9. Flow Control 0

Is v5 OK? Should I resend a v6?

Quoted 22 lines · Jose Abreu

From: Biao Huang <[email protected]>
Date: Wed, May 29, 2019 at 10:31:08

Quoted 5 lines

1. get hash table size in hw feature reigster, and add support for taller hash table(128/256) in dwmac4.
2. only clear GMAC_PACKET_FILTER bits used in this function, to avoid side effect to functions of other bits.

Quoted 13 lines

stmmac selftests output log:
ethtool -t eth0
The test result is FAIL
The test extra info:
1. MAC Loopback 0
2. PHY Loopback -95
3. MMC Counters 0
4. EEE -95
5. Hash Filter MC 0
6. Perfect Filter UC 0
7. MC Filter 0
8. UC Filter 0
9. Flow Control 1

Quoted 7 lines

Thanks for testing, this patch looks good to me.

Do you want to check why Flow Control selftest is failing ?

Thanks,
Jose Miguel Abreu

Thanks,
Biao

author
#4 lore raw

RE: [v5, PATCH] net: stmmac: add support for hash table size 128/256 in dwmac4

In reply to Jose Abreu

Hi Jose,
I also try "ethtool -A eth0 tx on rx on", and selftests pass.

But there are bugs in dwmac4_flow_ctrl:
flow control will keep on once enabled. ethtool -A eth0 tx off rx off can't change it.

if (fc & FLOW_RX) {
pr_debug ...
flow |= GMAC_RX_FLOW_CTRL_RFE;
writel(flow, ioaddr + GMAC_RX_FLOW_CTRL);
>> this should move outside to enasure rx flow control will be off
when execute "ethtool -A eth0 rx off"

	} 

	same for tx.
Quoted 29 lines · Jose Abreu

From: Biao Huang <[email protected]>
Date: Wed, May 29, 2019 at 10:31:08

Quoted 5 lines

1. get hash table size in hw feature reigster, and add support for taller hash table(128/256) in dwmac4.
2. only clear GMAC_PACKET_FILTER bits used in this function, to avoid side effect to functions of other bits.

Quoted 13 lines

stmmac selftests output log:
ethtool -t eth0
The test result is FAIL
The test extra info:
1. MAC Loopback 0
2. PHY Loopback -95
3. MMC Counters 0
4. EEE -95
5. Hash Filter MC 0
6. Perfect Filter UC 0
7. MC Filter 0
8. UC Filter 0
9. Flow Control 1

Thanks for testing, this patch looks good to me.

Do you want to check why Flow Control selftest is failing ?

Thanks,
Jose Miguel Abreu