Skip to contentSkip to conversation

stmmac: Add Loongson platform support

PATCH Superseded Yanteng Si 6 participants 97 messages Jan 30, 2024 – Apr 5, 2024 4 messages not in the archive Page 2 of 2

Subsystems (5)

v8 of 17 Superseded Latest is v17 →

lore
Share & tools
lore
author
#65 lore raw

Re: [PATCH net-next v8 08/11] net: stmmac: dwmac-loongson: Fix MAC speed for GNET

In reply to Serge Semin
Quoted 40 lines · Serge Semin
Quoted 39 lines · Yanteng Si
Quoted 10 lines · Yanteng Si
Quoted 7 lines · Serge Semin
Quoted 2 lines · Yanteng Si

Current GNET on LS7A only supports ANE when speed is set to 1000M.

If so you need to merge it into the patch
[PATCH net-next v8 06/11] net: stmmac: dwmac-loongson: Add GNET support Current GNET on LS7A only supports ANE when speed is
set to 1000M.

If so you need to merge it into the patch
[PATCH net-next v8 06/11] net: stmmac: dwmac-loongson: Add GNET support

OK.

Quoted 26 lines
Quoted 9 lines
Quoted 9 lines
---
   .../ethernet/stmicro/stmmac/dwmac-loongson.c  | 19 +++++++++++++++++++
   .../ethernet/stmicro/stmmac/stmmac_ethtool.c  |  6 ++++++
   include/linux/stmmac.h                        |  1 +
   3 files changed, 26 insertions(+)
Quoted 8 lines

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c static struct stmmac_pci_info loongson_gmac_pci_info = { · line 346

Quoted 8 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +0 -0
index 60d0a122d7c9..264c4c198d5a 100644
@@ -344,6 +344,21 @@ static struct stmmac_pci_info loongson_gmac_pci_info = {
   	.config = loongson_gmac_config,
   };
   >> +static void loongson_gnet_fix_speed(void *priv, unsigned int

speed, unsigned int mode)

Quoted 8 lines

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c static struct stmmac_pci_info loongson_gmac_pci_info = { · line 353

Quoted 6 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +6 -0
+{
+	struct loongson_data *ld = (struct loongson_data *)priv;
+	struct net_device *ndev = dev_get_drvdata(ld->dev);
+	struct stmmac_priv *ptr = netdev_priv(ndev);
+
+	/* The controller and PHY don't work well together.

So there _is_ a PHY. What is the interface between MAC and PHY then?

Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line

GMAC only has a MAC chip inside the chip and needs an external PHY

chip; GNET > has the PHY chip inside the chip.

We are talking about GNETs in this method since it has the loongson_gnet_ prefix. You are referring to GMAC. I am getting confused about all of these. Based on the patch 06/11 of this series you call "Loongson GNET" of all the devices placed on the PCI devices with PCI ID 0x7a13. PCIe device with ID 0x7a03 is called "Loongson GMAC". Right?

ls2k is SOC, ls7a ls bridge:

device    type    pci_id    gmac_version ls7a1000  gmac    7a03      0x37 ls2k1000  gmac    7a03      0x37 ls7a2000  gnet    7a13      0x37 ls2k2000  gnet    7a13      0x10

Quoted 43 lines

Anyway no matter whether the PHY is placed externally or inside the chip. AFAIU as long as you know the interface type between MAC and PHY it would be better to have it specified.

Quoted 17 lines
Quoted 17 lines
Quoted 7 lines

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c static struct stmmac_pci_info loongson_gmac_pci_info = { · line 359

Quoted 6 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +6 -0
+	 * We need to use the PS bit to check if the controller's status
+	 * is correct and reset PHY if necessary.
+	 */
+	if (speed == SPEED_1000)
+		if (readl(ptr->ioaddr + MAC_CTRL_REG) & (1 << 15) /* PS */)
+			phy_restart_aneg(ndev->phydev);

1. Please add curly braces for the outer if-statement.

OK,

Quoted 1 line

2. MAC_CTRL_REG.15 is defined by the GMAC_CONTROL_PS macro.

OK.

if(speed==SPEED_1000){
/*MAC_CTRL_REG.15 is defined by the GMAC_CONTROL_PS macro.*/ if(readl(ptr->ioaddr+MAC_CTRL_REG) &(1<<15)) phy_restart_aneg(ndev->phydev);
}

Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

3. How is the AN-restart helps? PHY-reset is done in stmmac_init_phy()->phylink_connect_phy()->... a bit earlier than this is called in the framework of the stmmac_mac_link_up() callback. Wouldn't that restart AN too?

Due to a bug in the chip's internal PHY, the network is still not working after the first self-negotiation, and it needs to be self-negotiated again.

Then please describe the bug in more details then.

Getting back to the code you implemented here. In the in-situ comment you say: "We need to use the PS bit to check if the controller's status is correct and reset PHY if necessary." By calling phy_restart_aneg() you don't reset the PHY.

Moreover if "PS" flag is set, then the MAC has been pre-configured to work in the 10/100Mbps mode. Since 1000Mbps speed is requested, the MAC_CTRL_REG.PS flag will be cleared later in the stmmac_mac_link_up() method and then phylink_start() shall cause the link speed re-auto-negotiation. Why do you need the auto-negotiation started for the default MAC config which will be changed just in a moment later? All of that seems weird.

Quoted 3 lines

Most importantly I have doubts the networking subsystem maintainers will permit you calling the phy_restart_aneg() method from the MAC driver code.

I will reply to you tomorrow.

Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
Quoted 13 lines
Quoted 13 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +3 -0
+}
+
   static struct mac_device_info *loongson_setup(void *apriv)
   {
   	struct stmmac_priv *priv = apriv;
@@ -401,6 +416,7 @@ static int loongson_gnet_data(struct pci_dev *pdev,
   	plat->phy_interface = PHY_INTERFACE_MODE_INTERNAL;
   >>   	plat->bsp_priv = &pdev->dev;
+	plat->fix_mac_speed = loongson_gnet_fix_speed;
   >>   	plat->dma_cfg->pbl = 32;
   	plat->dma_cfg->pblx8 = true;
@@ -416,6 +432,9 @@ static int loongson_gnet_config(struct pci_dev *pdev,
Quoted 8 lines

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c static int loongson_gnet_config(struct pci_dev *pdev, · line 437

Quoted 6 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +3 -0
   				struct stmmac_resources *res,
   				struct device_node *np)
   {
+	if (pdev->revision == 0x00 || pdev->revision == 0x01)
+		plat->flags |= STMMAC_FLAG_DISABLE_FORCE_1000;
+

This should be in the patch
[PATCH net-next v8 06/11] net: stmmac: dwmac-loongson: Add GNET support

OK.

Quoted 3 lines

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c static int loongson_gnet_config(struct pci_dev *pdev,

Quoted 3 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +0 -0
   	return 0;
   }
   >> diff --git

a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c

Quoted 7 lines

drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c stmmac_ethtool_set_link_ksettings(struct net_device *dev, · line 424

Quoted 7 lines

index 42d27b97dd1d..31068fbc23c9 100644

drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +0 -0
@@ -422,6 +422,12 @@ stmmac_ethtool_set_link_ksettings(struct net_device *dev,
   		return 0;
   	}
   >> +	if (FIELD_GET(STMMAC_FLAG_DISABLE_FORCE_1000,

priv->plat->flags)) {

Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line

FIELD_GET()?

OK,

if (STMMAC_FLAG_DISABLE_FORCE_1000 & priv->plat->flags) {

it's better to change the order of the operands:

	if (priv->plat->flags & STMMAC_FLAG_DISABLE_FORCE_1000) {

OK,

Thanks,

Yanteng

Quoted 38 lines

-Serge(y)

Quoted 35 lines
Quoted 35 lines
Quoted 14 lines
Quoted 14 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +5 -0
+		if (cmd->base.speed == SPEED_1000 &&
+		    cmd->base.autoneg != AUTONEG_ENABLE)
+			return -EOPNOTSUPP;
+	}
+
   	return phylink_ethtool_ksettings_set(priv->phylink, cmd);
   }
   >> diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h

index dee5ad6e48c5..2810361e4048 100644

include/linux/stmmac.h +0 -0
@@ -221,6 +221,7 @@ struct dwmac4_addrs {
   #define STMMAC_FLAG_RX_CLK_RUNS_IN_LPI		BIT(10)
   #define STMMAC_FLAG_EN_TX_LPI_CLOCKGATING	BIT(11)
Quoted 8 lines

include/linux/stmmac.h struct dwmac4_addrs { · line 224

Quoted 2 lines
include/linux/stmmac.h +1 -0
   #define STMMAC_FLAG_HWTSTAMP_CORRECT_LATENCY	BIT(12)
+#define STMMAC_FLAG_DISABLE_FORCE_1000	BIT(13)

Detach the change introducing the STMMAC_FLAG_DISABLE_FORCE_1000 flag into a separate patch a place it before
[PATCH net-next v8 06/11] net: stmmac: dwmac-loongson: Add GNET support as a pre-requisite/preparation patch.
Don't forget a _detailed_ description of why it's necessary, what is wrong with GNET so 1G speed doesn't work without AN.

OK.

Thanks,

Yanteng

Quoted 6 lines

-Serge(y)

Quoted 4 lines
include/linux/stmmac.h +0 -1
   >>   struct plat_stmmacenet_data {
   	int bus_id;
-- >> 2.31.4
author
#66 lore raw

Re: [PATCH net-next v8 08/11] net: stmmac: dwmac-loongson: Fix MAC speed for GNET

In reply to Serge Semin
Quoted 9 lines · Serge Semin
Quoted 2 lines
Quoted 2 lines

Due to a bug in the chip's internal PHY, the network is still not working after the first self-negotiation, and it needs to be self-negotiated again.

Then please describe the bug in more details then.

Getting back to the code you implemented here. In the in-situ comment you say: "We need to use the PS bit to check if the controller's status is correct and reset PHY if necessary." By calling phy_restart_aneg() you don't reset the PHY.

Quoted 7 lines

Moreover if "PS" flag is set, then the MAC has been pre-configured to work in the 10/100Mbps mode. Since 1000Mbps speed is requested, the MAC_CTRL_REG.PS flag will be cleared later in the stmmac_mac_link_up() method and then phylink_start() shall cause the link speed re-auto-negotiation. Why do you need the auto-negotiation started for the default MAC config which will be changed just in a moment later? All of that seems weird.

When switching speeds (from 100M to 1000M), the phy cannot output clocks,

resulting in the unavailability of the network card.  At this time, a reset of the

phy is required.

BTW, This bug has been fixed in gnet of 2k2000 (0x10, 7a13).

Quoted 4 lines

Most importantly I have doubts the networking subsystem maintainers will permit you calling the phy_restart_aneg() method from the MAC driver code.

We are happy to accept the opinions of the community.

Thanks,

Yanteng

Quoted 1 line
#67 lore raw

Re: [PATCH net-next v8 08/11] net: stmmac: dwmac-loongson: Fix MAC speed for GNET

Quoted 19 lines · Yanteng Si
Quoted 9 lines · Serge Semin
Quoted 2 lines
Quoted 2 lines

Due to a bug in the chip's internal PHY, the network is still not working after the first self-negotiation, and it needs to be self-negotiated again.

Then please describe the bug in more details then.

Getting back to the code you implemented here. In the in-situ comment you say: "We need to use the PS bit to check if the controller's status is correct and reset PHY if necessary." By calling phy_restart_aneg() you don't reset the PHY.

Quoted 7 lines

Moreover if "PS" flag is set, then the MAC has been pre-configured to work in the 10/100Mbps mode. Since 1000Mbps speed is requested, the MAC_CTRL_REG.PS flag will be cleared later in the stmmac_mac_link_up() method and then phylink_start() shall cause the link speed re-auto-negotiation. Why do you need the auto-negotiation started for the default MAC config which will be changed just in a moment later? All of that seems weird.

Quoted 6 lines

When switching speeds (from 100M to 1000M), the phy cannot output clocks,

resulting in the unavailability of the network card.  At this time, a reset of the

phy is required.

reset, or restart of autoneg?

Quoted 6 lines

BTW, This bug has been fixed in gnet of 2k2000 (0x10, 7a13).

Quoted 4 lines

Most importantly I have doubts the networking subsystem maintainers will permit you calling the phy_restart_aneg() method from the MAC driver code.

That is O.K. It should have a comment explaining that it is working around a hardware bug. And you need to take care of locking. But a MAC driver can call this, e.g. if it implements ethtool nway_reset, it needs to do exactly this. See phy_ethtool_nway_reset().

Andrew

#68 lore raw

Re: [PATCH net-next v8 08/11] net: stmmac: dwmac-loongson: Fix MAC speed for GNET

Quoted 32 lines · Andrew Lunn
Quoted 19 lines · Yanteng Si
Quoted 9 lines · Serge Semin
Quoted 2 lines
Quoted 2 lines

Due to a bug in the chip's internal PHY, the network is still not working after the first self-negotiation, and it needs to be self-negotiated again.

Then please describe the bug in more details then.

Getting back to the code you implemented here. In the in-situ comment you say: "We need to use the PS bit to check if the controller's status is correct and reset PHY if necessary." By calling phy_restart_aneg() you don't reset the PHY.

Quoted 7 lines

Moreover if "PS" flag is set, then the MAC has been pre-configured to work in the 10/100Mbps mode. Since 1000Mbps speed is requested, the MAC_CTRL_REG.PS flag will be cleared later in the stmmac_mac_link_up() method and then phylink_start() shall cause the link speed re-auto-negotiation. Why do you need the auto-negotiation started for the default MAC config which will be changed just in a moment later? All of that seems weird.

Quoted 6 lines

When switching speeds (from 100M to 1000M), the phy cannot output clocks,

resulting in the unavailability of the network card.  At this time, a reset of the

phy is required.

reset, or restart of autoneg?

Quoted 3 lines

BTW, This bug has been fixed in gnet of 2k2000 (0x10, 7a13).

Quoted 1 line
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines

Most importantly I have doubts the networking subsystem maintainers will permit you calling the phy_restart_aneg() method from the MAC driver code.

That is O.K. It should have a comment explaining that it is working around a hardware bug. And you need to take care of locking. But a MAC driver can call this, e.g. if it implements ethtool nway_reset, it needs to do exactly this. See phy_ethtool_nway_reset().

However, because stmmac uses phylink, we should be adding phylink interfaces that forward to phylib to avoid the layering violation.

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
#69 lore raw

Re: [PATCH net-next v8 08/11] net: stmmac: dwmac-loongson: Fix MAC speed for GNET

Quoted 2 lines

However, because stmmac uses phylink, we should be adding phylink interfaces that forward to phylib to avoid the layering violation.

Yes.

Maybe just call phylink_ethtool_nway_reset()? Just depends if the additional phylink_pcs_an_restart(pl) will mess things up for this device.

Andrew

author
#70 lore raw

Re: [PATCH net-next v8 08/11] net: stmmac: dwmac-loongson: Fix MAC speed for GNET

Hi Andrew, Serge and Russell,

Quoted 5 lines · Andrew Lunn
Quoted 2 lines

However, because stmmac uses phylink, we should be adding phylink interfaces that forward to phylib to avoid the layering violation.

Yes.

Maybe just call phylink_ethtool_nway_reset()? Just depends if the

Nice! It works.

In fact, after repeated testing, my previous code did not fix all issues, such

as network unavailability when switching from 1000M to 100M(physical).

But your method is perfect!

Thanks,

Yanteng

Quoted 4 lines

additional phylink_pcs_an_restart(pl) will mess things up for this device.

Andrew

author
#71 lore raw

Re: [PATCH net-next v8 08/11] net: stmmac: dwmac-loongson: Fix MAC speed for GNET

In reply to Andrew Lunn
Quoted 7 lines · Andrew Lunn
Quoted 6 lines

When switching speeds (from 100M to 1000M), the phy cannot output clocks,

resulting in the unavailability of the network card.  At this time, a reset of the

phy is required.

reset, or restart of autoneg?

reset.

Thanks,

Yanteng

#72 lore raw

Re: [PATCH net-next v8 08/11] net: stmmac: dwmac-loongson: Fix MAC speed for GNET

Quoted 11 lines · Yanteng Si
Quoted 7 lines · Andrew Lunn
Quoted 6 lines

When switching speeds (from 100M to 1000M), the phy cannot output clocks,

resulting in the unavailability of the network card.  At this time, a reset of the

phy is required.

reset, or restart of autoneg?

reset.

If you need a reset, why are you asking it to restart auto-neg?

Andrew

author
#73 lore raw

Re: [PATCH net-next v8 08/11] net: stmmac: dwmac-loongson: Fix MAC speed for GNET

Quoted 11 lines · Andrew Lunn
Quoted 9 lines · Yanteng Si
Quoted 7 lines · Andrew Lunn
Quoted 6 lines

When switching speeds (from 100M to 1000M), the phy cannot output clocks,

resulting in the unavailability of the network card.  At this time, a reset of the

phy is required.

reset, or restart of autoneg?

reset.

If you need a reset, why are you asking it to restart auto-neg?

Autoneg was discussed in patch v1, but we may have misunderstood the description from our hardware engineers at the time. The root cause is that there is an error in the connection between the MAC and PHY. After repeated tests, we have found that

auto-negcannot solve all problems and can only be reset. Thanks, Yanteng

#74 lore raw

Re: [PATCH net-next v8 08/11] net: stmmac: dwmac-loongson: Fix MAC speed for GNET

Quoted 11 lines · Yanteng Si
Quoted 9 lines · Andrew Lunn
Quoted 8 lines · Yanteng Si
Quoted 7 lines · Andrew Lunn
Quoted 6 lines

When switching speeds (from 100M to 1000M), the phy cannot output clocks,

resulting in the unavailability of the network card.  At this time, a reset of the

phy is required.

reset, or restart of autoneg?

Quoted 8 lines
Quoted 2 lines
Quoted 1 line

reset.

If you need a reset, why are you asking it to restart auto-neg?

Autoneg was discussed in patch v1, but we may have misunderstood the description from our hardware engineers at the time. The root cause is that there is an error in the connection between the MAC and PHY. After repeated tests, we have found that

auto-negcannot solve all problems and can only be reset. Thanks, Yanteng

So calling phylink_ethtool_nway_reset() does not fix your problem, and you need some other fix.

Andrew

---
pw-bot: cr

author
#75 lore raw

Re: [PATCH net-next v8 08/11] net: stmmac: dwmac-loongson: Fix MAC speed for GNET

Quoted 18 lines · Andrew Lunn
Quoted 17 lines · Yanteng Si
Quoted 11 lines · Andrew Lunn
Quoted 9 lines · Yanteng Si
Quoted 7 lines · Andrew Lunn
Quoted 6 lines

When switching speeds (from 100M to 1000M), the phy cannot output clocks,

resulting in the unavailability of the network card.  At this time, a reset of the

phy is required.

reset, or restart of autoneg?

reset.

If you need a reset, why are you asking it to restart auto-neg?

Autoneg was discussed in patch v1, but we may have misunderstood the description from our hardware engineers at the time. The root cause is that there is an error in the connection between the MAC and PHY. After repeated tests, we have found that

Quoted 5 lines
Quoted 1 line

auto-negcannot solve all problems and can only be reset. Thanks, Yanteng

So calling phylink_ethtool_nway_reset() does not fix your problem, and you need some other fix.

Sorry, it's my fault.  I was stupid. Let me explain the whole story:

First, here is the original code we got:

 if (speed == SPEED_1000) {
  if (readl(ptr->ioaddr + MAC_CTRL_REG) & (1 << 15) /* PS */) { /* reset phy */
   phy_set_bits(ndev->phydev, 0 /*MII_BMCR*/, 0x200 /*BMCR_ANRESTART*/);

Although the comment in the code is **reset phy**, the actual operation is to modify the autoneg bit. This method fixes all problems.

V1:
if (phydev->speed == SPEED_1000)
 phydev->autoneg = AUTONEG_ENABLE

After discussing with you, see:
<https://lore.kernel.org/loongarch/be1874e517f4f4cc50906f18689a0add3594c2e0.1689215889.git.chenfeiyang@loongson.cn/>

v2 -> v8:
if (speed == SPEED_1000)
 if (readl(ptr->ioaddr + MAC_CTRL_REG) & (1 << 15) /* PS */) phy_restart_aneg(ndev->phydev);

Subsequent versions have been using this method. In recent days, I accidentally conducted an erroneous test, possibly due to the network cable not being firmly connected, leading me to mistakenly believe that this did not fix all problems. After conducting sufficient testing today, I found that I was mistaken and that calling phy_restart_aneg() directly fixed all problems.

At your suggestion, calling phylink_et Athletic_nway_reset() also works well, but it will report an assertion failed at drivers/net/phy/phylink.c in the dmesg. So let's continue to call phy_restart_aneg()?

Finally, why did I reply you with reset?  It's because I first checked the original code, and the comment in the original code was /* reset phy */.  I thought it was reset, but today I found out that it was actually autoneg. I apologize for my

carelessness.

Thanks,

Yanteng

author
#76 lore raw

PATCH v8 9/11 net: stmmac: dwmac-loongson: Fix half duplex

In reply to Yanteng Si

Current GNET does not support half duplex mode.

---
 drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c | 11 ++++++++++-
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c    |  3 ++-
 include/linux/stmmac.h                               |  1 +
 3 files changed, 13 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +10 -1
index 264c4c198d5a..1753a3c46b77 100644
@@ -432,8 +432,17 @@ static int loongson_gnet_config(struct pci_dev *pdev,
 				struct stmmac_resources *res,
 				struct device_node *np)
 {
-	if (pdev->revision == 0x00 || pdev->revision == 0x01)
+	switch (pdev->revision) {
+	case 0x00:
+		plat->flags |= STMMAC_FLAG_DISABLE_FORCE_1000 |
+			       STMMAC_FLAG_DISABLE_HALF_DUPLEX;
+		break;
+	case 0x01:
 		plat->flags |= STMMAC_FLAG_DISABLE_FORCE_1000;
+		break;
+	default:
+		break;
+	}
 
 	return 0;
 }
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2 -1
index 5617b40abbe4..3aa862269eb0 100644
@@ -1201,7 +1201,8 @@ static int stmmac_init_phy(struct net_device *dev)
 static void stmmac_set_half_duplex(struct stmmac_priv *priv)
 {
 	/* Half-Duplex can only work with single tx queue */
-	if (priv->plat->tx_queues_to_use > 1)
+	if (priv->plat->tx_queues_to_use > 1 ||
+	    (STMMAC_FLAG_DISABLE_HALF_DUPLEX & priv->plat->flags))
 		priv->phylink_config.mac_capabilities &=
 			~(MAC_10HD | MAC_100HD | MAC_1000HD);
 	else
include/linux/stmmac.h +1 -0
index 2810361e4048..197f6f914104 100644
@@ -222,6 +222,7 @@ struct dwmac4_addrs {
 #define STMMAC_FLAG_EN_TX_LPI_CLOCKGATING	BIT(11)
 #define STMMAC_FLAG_HWTSTAMP_CORRECT_LATENCY	BIT(12)
 #define STMMAC_FLAG_DISABLE_FORCE_1000	BIT(13)
+#define STMMAC_FLAG_DISABLE_HALF_DUPLEX	BIT(14)
 
 struct plat_stmmacenet_data {
 	int bus_id;
Signature · 1 line
2.31.4
#77 lore raw

Re: [PATCH net-next v8 09/11] net: stmmac: dwmac-loongson: Fix half duplex

Quoted 22 lines · Yanteng Si

Current GNET does not support half duplex mode.

---
 drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c | 11 ++++++++++-
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c    |  3 ++-
 include/linux/stmmac.h                               |  1 +
 3 files changed, 13 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +1 -1
index 264c4c198d5a..1753a3c46b77 100644
@@ -432,8 +432,17 @@ static int loongson_gnet_config(struct pci_dev *pdev,
 				struct stmmac_resources *res,
 				struct device_node *np)
 {
 
-	if (pdev->revision == 0x00 || pdev->revision == 0x01)
+	switch (pdev->revision) {

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c static int loongson_gnet_config(struct pci_dev *pdev, · line 446

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +9 -0
+	case 0x00:
+		plat->flags |= STMMAC_FLAG_DISABLE_FORCE_1000 |
+			       STMMAC_FLAG_DISABLE_HALF_DUPLEX;
+		break;
+	case 0x01:
 		plat->flags |= STMMAC_FLAG_DISABLE_FORCE_1000;
+		break;
+	default:
+		break;
+	}

Move this change into the patch
[PATCH net-next v8 06/11] net: stmmac: dwmac-loongson: Add GNET support

Quoted 23 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +0 -0
 	return 0;
 }
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2 -1
index 5617b40abbe4..3aa862269eb0 100644
@@ -1201,7 +1201,8 @@ static int stmmac_init_phy(struct net_device *dev)
 static void stmmac_set_half_duplex(struct stmmac_priv *priv)
 {
 
 	/* Half-Duplex can only work with single tx queue */
-	if (priv->plat->tx_queues_to_use > 1)
+	if (priv->plat->tx_queues_to_use > 1 ||
+	    (STMMAC_FLAG_DISABLE_HALF_DUPLEX & priv->plat->flags))
 		priv->phylink_config.mac_capabilities &=
 			~(MAC_10HD | MAC_100HD | MAC_1000HD);
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0 -0
 	else
include/linux/stmmac.h +0 -0
index 2810361e4048..197f6f914104 100644

include/linux/stmmac.h struct dwmac4_addrs { · line 226

Quoted 5 lines
include/linux/stmmac.h +1 -0
@@ -222,6 +222,7 @@ struct dwmac4_addrs {
 #define STMMAC_FLAG_EN_TX_LPI_CLOCKGATING	BIT(11)
 #define STMMAC_FLAG_HWTSTAMP_CORRECT_LATENCY	BIT(12)
 #define STMMAC_FLAG_DISABLE_FORCE_1000	BIT(13)
+#define STMMAC_FLAG_DISABLE_HALF_DUPLEX	BIT(14)
 

Place the patch with this change before
[PATCH net-next v8 06/11] net: stmmac: dwmac-loongson: Add GNET support as a pre-requisite/preparation patch. Don't forget a thorough description of what is wrong with the GNET Half-Duplex mode.

-Serge(y)

Quoted 5 lines
include/linux/stmmac.h +0 -0
 struct plat_stmmacenet_data {
 	int bus_id;
Signature · 1 line
2.31.4
#78 lore raw

Re: [PATCH net-next v8 09/11] net: stmmac: dwmac-loongson: Fix half duplex

Quoted 63 lines · Serge Semin
Quoted 22 lines · Yanteng Si

Current GNET does not support half duplex mode.

---
 drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c | 11 ++++++++++-
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c    |  3 ++-
 include/linux/stmmac.h                               |  1 +
 3 files changed, 13 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +1 -1
index 264c4c198d5a..1753a3c46b77 100644
@@ -432,8 +432,17 @@ static int loongson_gnet_config(struct pci_dev *pdev,
 				struct stmmac_resources *res,
 				struct device_node *np)
 {
 
-	if (pdev->revision == 0x00 || pdev->revision == 0x01)
+	switch (pdev->revision) {

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c static int loongson_gnet_config(struct pci_dev *pdev, · line 446

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +9 -0
+	case 0x00:
+		plat->flags |= STMMAC_FLAG_DISABLE_FORCE_1000 |
+			       STMMAC_FLAG_DISABLE_HALF_DUPLEX;
+		break;
+	case 0x01:
 		plat->flags |= STMMAC_FLAG_DISABLE_FORCE_1000;
+		break;
+	default:
+		break;
+	}

Move this change into the patch
[PATCH net-next v8 06/11] net: stmmac: dwmac-loongson: Add GNET support

Quoted 26 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +0 -0
 	return 0;
 }
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2 -1
index 5617b40abbe4..3aa862269eb0 100644
@@ -1201,7 +1201,8 @@ static int stmmac_init_phy(struct net_device *dev)
 static void stmmac_set_half_duplex(struct stmmac_priv *priv)
 {
 
 
 	/* Half-Duplex can only work with single tx queue */
-	if (priv->plat->tx_queues_to_use > 1)
+	if (priv->plat->tx_queues_to_use > 1 ||
+	    (STMMAC_FLAG_DISABLE_HALF_DUPLEX & priv->plat->flags))
 		priv->phylink_config.mac_capabilities &=
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0 -0
 			~(MAC_10HD | MAC_100HD | MAC_1000HD);
 	else
include/linux/stmmac.h +0 -0
index 2810361e4048..197f6f914104 100644
@@ -222,6 +222,7 @@ struct dwmac4_addrs {
 #define STMMAC_FLAG_EN_TX_LPI_CLOCKGATING	BIT(11)
 #define STMMAC_FLAG_HWTSTAMP_CORRECT_LATENCY	BIT(12)
Quoted 8 lines

include/linux/stmmac.h struct dwmac4_addrs { · line 226

Quoted 3 lines
include/linux/stmmac.h +1 -0
 #define STMMAC_FLAG_DISABLE_FORCE_1000	BIT(13)
+#define STMMAC_FLAG_DISABLE_HALF_DUPLEX	BIT(14)
 

Place the patch with this change before
[PATCH net-next v8 06/11] net: stmmac: dwmac-loongson: Add GNET support as a pre-requisite/preparation patch. Don't forget a thorough description of what is wrong with the GNET Half-Duplex mode.

BTW what about re-defining the stmmac_ops.phylink_get_caps() callback instead of adding fixup flags in this patch and in the next one?

-Serge()

Quoted 8 lines

-Serge(y)

Quoted 5 lines
include/linux/stmmac.h +0 -0
 struct plat_stmmacenet_data {
 	int bus_id;
Signature · 1 line
2.31.4
author
#79 lore raw

Re: [PATCH net-next v8 09/11] net: stmmac: dwmac-loongson: Fix half duplex

Quoted 67 lines · Serge Semin
Quoted 58 lines · Serge Semin
Quoted 21 lines · Yanteng Si

Current GNET does not support half duplex mode.

---
  drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c | 11 ++++++++++-
  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c    |  3 ++-
  include/linux/stmmac.h                               |  1 +
  3 files changed, 13 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +1 -1
index 264c4c198d5a..1753a3c46b77 100644
@@ -432,8 +432,17 @@ static int loongson_gnet_config(struct pci_dev *pdev,
  				struct stmmac_resources *res,
  				struct device_node *np)
  {
-	if (pdev->revision == 0x00 || pdev->revision == 0x01)
+	switch (pdev->revision) {

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c static int loongson_gnet_config(struct pci_dev *pdev, · line 445

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +9 -0
+	case 0x00:
+		plat->flags |= STMMAC_FLAG_DISABLE_FORCE_1000 |
+			       STMMAC_FLAG_DISABLE_HALF_DUPLEX;
+		break;
+	case 0x01:
  		plat->flags |= STMMAC_FLAG_DISABLE_FORCE_1000;
+		break;
+	default:
+		break;
+	}

Move this change into the patch
[PATCH net-next v8 06/11] net: stmmac: dwmac-loongson: Add GNET support

Quoted 23 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +0 -0
  	return 0;
  }
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2 -1
index 5617b40abbe4..3aa862269eb0 100644
@@ -1201,7 +1201,8 @@ static int stmmac_init_phy(struct net_device *dev)
  static void stmmac_set_half_duplex(struct stmmac_priv *priv)
  {
  	/* Half-Duplex can only work with single tx queue */
-	if (priv->plat->tx_queues_to_use > 1)
+	if (priv->plat->tx_queues_to_use > 1 ||
+	    (STMMAC_FLAG_DISABLE_HALF_DUPLEX & priv->plat->flags))
  		priv->phylink_config.mac_capabilities &=
  			~(MAC_10HD | MAC_100HD | MAC_1000HD);
  	else
include/linux/stmmac.h +0 -0
index 2810361e4048..197f6f914104 100644
@@ -222,6 +222,7 @@ struct dwmac4_addrs {
  #define STMMAC_FLAG_EN_TX_LPI_CLOCKGATING	BIT(11)
Quoted 8 lines

include/linux/stmmac.h struct dwmac4_addrs { · line 226

Quoted 4 lines
include/linux/stmmac.h +1 -0
  #define STMMAC_FLAG_HWTSTAMP_CORRECT_LATENCY	BIT(12)
  #define STMMAC_FLAG_DISABLE_FORCE_1000	BIT(13)
+#define STMMAC_FLAG_DISABLE_HALF_DUPLEX	BIT(14)
 

Place the patch with this change before
[PATCH net-next v8 06/11] net: stmmac: dwmac-loongson: Add GNET support as a pre-requisite/preparation patch. Don't forget a thorough description of what is wrong with the GNET Half-Duplex mode.

Quoted 2 lines

BTW what about re-defining the stmmac_ops.phylink_get_caps() callback instead of adding fixup flags in this patch and in the next one?

ok.

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +0 -0
index ac1b48ff7199..b57e1325ce62 100644
@@ -238,6 +234,13 @@ static int loongson_gnet_get_hw_feature(void __iomem *ioaddr,

     return 0;
 }

+static void loongson_phylink_get_caps(struct stmmac_priv *priv)
+{
+    priv->phylink_config.mac_capabilities = (MAC_10FD |
+        MAC_100FD | MAC_1000FD) & ~(MAC_10HD | MAC_100HD | MAC_1000HD);
+
+}
+
 struct stmmac_pci_info {
     int (*setup)(struct pci_dev *pdev, struct plat_stmmacenet_data *plat);
     int (*config)(struct pci_dev *pdev, struct plat_stmmacenet_data *plat,
@@ -403,10 +405,15 @@ static void loongson_gnet_fix_speed(void *priv, unsigned int speed, unsigned int

 static struct mac_device_info *loongson_setup(void *apriv) {
+    struct stmmac_ops *loongson_dwmac_ops;
     struct stmmac_priv *priv = apriv;
     struct mac_device_info *mac;
     struct stmmac_dma_ops *dma;

+    loongson_dwmac_ops = devm_kzalloc(priv->device, sizeof(*loongson_dwmac_ops), GFP_KERNEL); +    if (!loongson_dwmac_ops)
+        return NULL;
+
     mac = devm_kzalloc(priv->device, sizeof(*mac), GFP_KERNEL);
     if (!mac)
         return NULL;
@@ -417,6 +424,10 @@ static struct mac_device_info *loongson_setup(void *apriv)

     priv->synopsys_id = 0x37;    /*Overwrite custom IP*/

+    *loongson_dwmac_ops = dwmac1000_ops;
+    loongson_dwmac_ops->phylink_get_caps = loongson_phylink_get_caps; +    mac->mac = loongson_dwmac_ops;
+
     *dma = dwmac1000_dma_ops;
     dma->init_chan = loongson_gnet_dma_init_channel; dma->dma_interrupt = loongson_gnet_dma_interrupt;
@@ -375,8 +375,6 @@ static int loongson_gmac_config(struct pci_dev *pdev, struct stmmac_resources *res, struct device_node *np)
 {
-       plat->flags |= STMMAC_FLAG_DISABLE_FLOW_CONTROL;
-
        return 0;
 }

@@ -489,17 +487,7 @@ static int loongson_gnet_config(struct pci_dev *pdev, struct stmmac_resources *res, struct device_node *np)
 {
-       switch (pdev->revision) {
-       case 0x00:
-               plat->flags |= STMMAC_FLAG_DISABLE_FORCE_1000 | -                              STMMAC_FLAG_DISABLE_HALF_DUPLEX; -               break;
-       case 0x01:
-               plat->flags |= STMMAC_FLAG_DISABLE_FORCE_1000; -               break;
-       default:
-               break;
-       }
+       plat->flags |= STMMAC_FLAG_DISABLE_FORCE_1000;

        return 0;
 }

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0 -0
index 8705e04913d1..7c656f970575 100644
@@ -1201,8 +1201,7 @@ static int stmmac_init_phy(struct net_device *dev)

 static void stmmac_set_half_duplex(struct stmmac_priv *priv)
 {
     /* Half-Duplex can only work with single tx queue */
-    if (priv->plat->tx_queues_to_use > 1 ||
-        (STMMAC_FLAG_DISABLE_HALF_DUPLEX & priv->plat->flags)) +    if (priv->plat->tx_queues_to_use > 1) priv->phylink_config.mac_capabilities &=
             ~(MAC_10HD | MAC_100HD | MAC_1000HD);
     else
@@ -1237,9 +1236,9 @@ static int stmmac_phy_setup(struct stmmac_priv *priv) xpcs_get_interfaces(priv->hw->xpcs, priv->phylink_config.supported_interfaces);

-    priv->phylink_config.mac_capabilities = MAC_10FD | MAC_100FD | MAC_1000FD; -    if (!(priv->plat->flags & STMMAC_FLAG_DISABLE_FLOW_CONTROL))
-        priv->phylink_config.mac_capabilities |= MAC_ASYM_PAUSE | MAC_SYM_PAUSE; +    priv->phylink_config.mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE | +                        MAC_10FD | MAC_100FD |
+                        MAC_1000FD;

     stmmac_set_half_duplex(priv);
 -----

loongson_gmac/gnet_config()

I will try to remove these two functions according to your comment in another patch。

Thanks,

Yanteng

Quoted 10 lines

-Serge()

Quoted 7 lines

-Serge(y)

Quoted 5 lines
include/linux/stmmac.h +0 -0
  struct plat_stmmacenet_data {
  	int bus_id;
Signature · 1 line
2.31.4
#80 lore raw

Re: [PATCH net-next v8 09/11] net: stmmac: dwmac-loongson: Fix half duplex

Quoted 77 lines · Yanteng Si
Quoted 65 lines · Serge Semin
Quoted 56 lines · Serge Semin
Quoted 21 lines · Yanteng Si

Current GNET does not support half duplex mode.

---
  drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c | 11 ++++++++++-
  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c    |  3 ++-
  include/linux/stmmac.h                               |  1 +
  3 files changed, 13 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +1 -1
index 264c4c198d5a..1753a3c46b77 100644
@@ -432,8 +432,17 @@ static int loongson_gnet_config(struct pci_dev *pdev,
  				struct stmmac_resources *res,
  				struct device_node *np)
  {
-	if (pdev->revision == 0x00 || pdev->revision == 0x01)
+	switch (pdev->revision) {

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c static int loongson_gnet_config(struct pci_dev *pdev, · line 445

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +9 -0
+	case 0x00:
+		plat->flags |= STMMAC_FLAG_DISABLE_FORCE_1000 |
+			       STMMAC_FLAG_DISABLE_HALF_DUPLEX;
+		break;
+	case 0x01:
  		plat->flags |= STMMAC_FLAG_DISABLE_FORCE_1000;
+		break;
+	default:
+		break;
+	}

Move this change into the patch
[PATCH net-next v8 06/11] net: stmmac: dwmac-loongson: Add GNET support

Quoted 21 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +0 -0
  	return 0;
  }
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2 -1
index 5617b40abbe4..3aa862269eb0 100644
@@ -1201,7 +1201,8 @@ static int stmmac_init_phy(struct net_device *dev)
  static void stmmac_set_half_duplex(struct stmmac_priv *priv)
  {
  	/* Half-Duplex can only work with single tx queue */
-	if (priv->plat->tx_queues_to_use > 1)
+	if (priv->plat->tx_queues_to_use > 1 ||
+	    (STMMAC_FLAG_DISABLE_HALF_DUPLEX & priv->plat->flags))
  		priv->phylink_config.mac_capabilities &=
  			~(MAC_10HD | MAC_100HD | MAC_1000HD);
  	else
include/linux/stmmac.h +0 -0
index 2810361e4048..197f6f914104 100644
@@ -222,6 +222,7 @@ struct dwmac4_addrs {
Quoted 8 lines

include/linux/stmmac.h struct dwmac4_addrs { · line 225

Quoted 4 lines
include/linux/stmmac.h +1 -0
  #define STMMAC_FLAG_EN_TX_LPI_CLOCKGATING	BIT(11)
  #define STMMAC_FLAG_HWTSTAMP_CORRECT_LATENCY	BIT(12)
  #define STMMAC_FLAG_DISABLE_FORCE_1000	BIT(13)
+#define STMMAC_FLAG_DISABLE_HALF_DUPLEX	BIT(14)

Place the patch with this change before
[PATCH net-next v8 06/11] net: stmmac: dwmac-loongson: Add GNET support as a pre-requisite/preparation patch. Don't forget a thorough description of what is wrong with the GNET Half-Duplex mode.

Quoted 2 lines

BTW what about re-defining the stmmac_ops.phylink_get_caps() callback instead of adding fixup flags in this patch and in the next one?

ok.

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +0 -0
index ac1b48ff7199..b57e1325ce62 100644

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c static int loongson_gnet_get_hw_feature(void __iomem · line 241

Quoted 8 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +4 -0
@@ -238,6 +234,13 @@ static int loongson_gnet_get_hw_feature(void __iomem
 *ioaddr,
      return 0;
  }
 
+static void loongson_phylink_get_caps(struct stmmac_priv *priv)
+{
+    priv->phylink_config.mac_capabilities = (MAC_10FD |
+        MAC_100FD | MAC_1000FD) & ~(MAC_10HD | MAC_100HD | MAC_1000HD);

Why is this so complicated? It would be silly if the _full duplex_ definitions also defined the _half duplex_ bits. This should be just:

	priv->phylink_config.mac_capabilities = MAC_10FD | MAC_100FD |
						MAC_1000FD;

if that is all you support. Do you not support any pause modes (they would need to be included as well here.)

As to this approach, I don't think it's a good model to override the stmmac MAC operations. Instead, I would suggest that a better approach would be for the platform to provide its capabilities to the stmmac core code (maybe a new member in stmmac_priv) which, when set, is used to reduce the capabilities provided to phylink via priv->phylink_config.mac_capabilities.

Why? The driver has several components that are involved in the overall capabilities, and the capabilities of the system is the logical subset of all these capabilities. One component should not be setting capabilities that a different component doesn't support.

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
author
#81 lore raw

Re: [PATCH net-next v8 09/11] net: stmmac: dwmac-loongson: Fix half duplex

Quoted 71 lines · Russell King (Oracle)
Quoted 70 lines · Yanteng Si
Quoted 65 lines · Serge Semin
Quoted 56 lines · Serge Semin
Quoted 21 lines · Yanteng Si

Current GNET does not support half duplex mode.

---
   drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c | 11 ++++++++++-
   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c    |  3 ++-
   include/linux/stmmac.h                               |  1 +
   3 files changed, 13 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +1 -1
index 264c4c198d5a..1753a3c46b77 100644
@@ -432,8 +432,17 @@ static int loongson_gnet_config(struct pci_dev *pdev,
   				struct stmmac_resources *res,
   				struct device_node *np)
   {
-	if (pdev->revision == 0x00 || pdev->revision == 0x01)
+	switch (pdev->revision) {

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c static int loongson_gnet_config(struct pci_dev *pdev, · line 445

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +9 -0
+	case 0x00:
+		plat->flags |= STMMAC_FLAG_DISABLE_FORCE_1000 |
+			       STMMAC_FLAG_DISABLE_HALF_DUPLEX;
+		break;
+	case 0x01:
   		plat->flags |= STMMAC_FLAG_DISABLE_FORCE_1000;
+		break;
+	default:
+		break;
+	}

Move this change into the patch
[PATCH net-next v8 06/11] net: stmmac: dwmac-loongson: Add GNET support

Quoted 21 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +0 -0
   	return 0;
   }
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2 -1
index 5617b40abbe4..3aa862269eb0 100644
@@ -1201,7 +1201,8 @@ static int stmmac_init_phy(struct net_device *dev)
   static void stmmac_set_half_duplex(struct stmmac_priv *priv)
   {
   	/* Half-Duplex can only work with single tx queue */
-	if (priv->plat->tx_queues_to_use > 1)
+	if (priv->plat->tx_queues_to_use > 1 ||
+	    (STMMAC_FLAG_DISABLE_HALF_DUPLEX & priv->plat->flags))
   		priv->phylink_config.mac_capabilities &=
   			~(MAC_10HD | MAC_100HD | MAC_1000HD);
   	else
include/linux/stmmac.h +0 -0
index 2810361e4048..197f6f914104 100644
@@ -222,6 +222,7 @@ struct dwmac4_addrs {
Quoted 8 lines

include/linux/stmmac.h struct dwmac4_addrs { · line 225

Quoted 4 lines
include/linux/stmmac.h +1 -0
   #define STMMAC_FLAG_EN_TX_LPI_CLOCKGATING	BIT(11)
   #define STMMAC_FLAG_HWTSTAMP_CORRECT_LATENCY	BIT(12)
   #define STMMAC_FLAG_DISABLE_FORCE_1000	BIT(13)
+#define STMMAC_FLAG_DISABLE_HALF_DUPLEX	BIT(14)

Place the patch with this change before
[PATCH net-next v8 06/11] net: stmmac: dwmac-loongson: Add GNET support as a pre-requisite/preparation patch. Don't forget a thorough description of what is wrong with the GNET Half-Duplex mode.

Quoted 2 lines

BTW what about re-defining the stmmac_ops.phylink_get_caps() callback instead of adding fixup flags in this patch and in the next one?

ok.

Quoted 9 lines

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c static int loongson_gnet_get_hw_feature(void __iomem · line 236

Quoted 9 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +0 -0
index ac1b48ff7199..b57e1325ce62 100644
@@ -238,6 +234,13 @@ static int loongson_gnet_get_hw_feature(void __iomem
 *ioaddr,
      return 0;
  }

Hi Russell,

Quoted 9 lines

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c static int loongson_gnet_get_hw_feature(void __iomem · line 240

Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +4 -0
+static void loongson_phylink_get_caps(struct stmmac_priv *priv)
+{
+    priv->phylink_config.mac_capabilities = (MAC_10FD |
+        MAC_100FD | MAC_1000FD) & ~(MAC_10HD | MAC_100HD | MAC_1000HD);

Why is this so complicated? It would be silly if the _full duplex_ definitions also defined the _half duplex_ bits. This should be just:

	priv->phylink_config.mac_capabilities = MAC_10FD | MAC_100FD |
						MAC_1000FD;

Yes, you are right. Our gnet device (7a2000) does not support half-duplex, while the gnet device (2k2000) does.

I plan to use PCI IDand IP CORE as the condition to separate full-duplex and half-duplex.

Quoted 3 lines

if that is all you support. Do you not support any pause modes (they would need to be included as well here.)

I have tested it and our gnet device supports MAC_ASYM_PAUSE and MAC_SYM_PAUSE, but gmac does not. I will fix this in the patch v9.

This is also easy to do because all GMAC devices have the same PCI ID.

Quoted 8 lines

As to this approach, I don't think it's a good model to override the stmmac MAC operations. Instead, I would suggest that a better approach would be for the platform to provide its capabilities to the stmmac core code (maybe a new member in stmmac_priv) which, when set, is used to reduce the capabilities provided to phylink via priv->phylink_config.mac_capabilities.

Quoted 4 lines

Why? The driver has several components that are involved in the overall capabilities, and the capabilities of the system is the logical subset of all these capabilities. One component should not be setting capabilities that a different component doesn't support.

Hi Serge,

It seems to be going back again, what do you think?

Thanks,

Yanteng

Quoted 1 line
#82 lore raw

Re: [PATCH net-next v8 09/11] net: stmmac: dwmac-loongson: Fix half duplex

Quoted 102 lines · Yanteng Si
Quoted 71 lines · Russell King (Oracle)
Quoted 70 lines · Yanteng Si
Quoted 65 lines · Serge Semin
Quoted 56 lines · Serge Semin
Quoted 21 lines · Yanteng Si

Current GNET does not support half duplex mode.

---
   drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c | 11 ++++++++++-
   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c    |  3 ++-
   include/linux/stmmac.h                               |  1 +
   3 files changed, 13 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +1 -1
index 264c4c198d5a..1753a3c46b77 100644
@@ -432,8 +432,17 @@ static int loongson_gnet_config(struct pci_dev *pdev,
   				struct stmmac_resources *res,
   				struct device_node *np)
   {
-	if (pdev->revision == 0x00 || pdev->revision == 0x01)
+	switch (pdev->revision) {

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c static int loongson_gnet_config(struct pci_dev *pdev, · line 445

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +9 -0
+	case 0x00:
+		plat->flags |= STMMAC_FLAG_DISABLE_FORCE_1000 |
+			       STMMAC_FLAG_DISABLE_HALF_DUPLEX;
+		break;
+	case 0x01:
   		plat->flags |= STMMAC_FLAG_DISABLE_FORCE_1000;
+		break;
+	default:
+		break;
+	}

Move this change into the patch
[PATCH net-next v8 06/11] net: stmmac: dwmac-loongson: Add GNET support

Quoted 21 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +0 -0
   	return 0;
   }
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2 -1
index 5617b40abbe4..3aa862269eb0 100644
@@ -1201,7 +1201,8 @@ static int stmmac_init_phy(struct net_device *dev)
   static void stmmac_set_half_duplex(struct stmmac_priv *priv)
   {
   	/* Half-Duplex can only work with single tx queue */
-	if (priv->plat->tx_queues_to_use > 1)
+	if (priv->plat->tx_queues_to_use > 1 ||
+	    (STMMAC_FLAG_DISABLE_HALF_DUPLEX & priv->plat->flags))
   		priv->phylink_config.mac_capabilities &=
   			~(MAC_10HD | MAC_100HD | MAC_1000HD);
   	else
include/linux/stmmac.h +0 -0
index 2810361e4048..197f6f914104 100644
@@ -222,6 +222,7 @@ struct dwmac4_addrs {
Quoted 8 lines

include/linux/stmmac.h struct dwmac4_addrs { · line 225

Quoted 4 lines
include/linux/stmmac.h +1 -0
   #define STMMAC_FLAG_EN_TX_LPI_CLOCKGATING	BIT(11)
   #define STMMAC_FLAG_HWTSTAMP_CORRECT_LATENCY	BIT(12)
   #define STMMAC_FLAG_DISABLE_FORCE_1000	BIT(13)
+#define STMMAC_FLAG_DISABLE_HALF_DUPLEX	BIT(14)

Place the patch with this change before
[PATCH net-next v8 06/11] net: stmmac: dwmac-loongson: Add GNET support as a pre-requisite/preparation patch. Don't forget a thorough description of what is wrong with the GNET Half-Duplex mode.

Quoted 2 lines

BTW what about re-defining the stmmac_ops.phylink_get_caps() callback instead of adding fixup flags in this patch and in the next one?

ok.

Quoted 9 lines

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c static int loongson_gnet_get_hw_feature(void __iomem · line 236

Quoted 9 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +0 -0
index ac1b48ff7199..b57e1325ce62 100644
@@ -238,6 +234,13 @@ static int loongson_gnet_get_hw_feature(void __iomem
 *ioaddr,
      return 0;
  }

Hi Russell,

Quoted 9 lines

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c static int loongson_gnet_get_hw_feature(void __iomem · line 240

Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +4 -0
+static void loongson_phylink_get_caps(struct stmmac_priv *priv)
+{
+    priv->phylink_config.mac_capabilities = (MAC_10FD |
+        MAC_100FD | MAC_1000FD) & ~(MAC_10HD | MAC_100HD | MAC_1000HD);

Why is this so complicated? It would be silly if the _full duplex_ definitions also defined the _half duplex_ bits. This should be just:

	priv->phylink_config.mac_capabilities = MAC_10FD | MAC_100FD |
						MAC_1000FD;

Yes, you are right. Our gnet device (7a2000) does not support half-duplex, while the gnet device (2k2000) does.

I plan to use PCI IDand IP CORE as the condition to separate full-duplex and half-duplex.

Quoted 1 line
Quoted 21 lines
Quoted 2 lines

if that is all you support. Do you not support any pause modes (they would need to be included as well here.)

I have tested it and our gnet device supports MAC_ASYM_PAUSE and MAC_SYM_PAUSE, but gmac does not. I will fix this in the patch v9.

This is also easy to do because all GMAC devices have the same PCI ID.

Quoted 13 lines

As to this approach, I don't think it's a good model to override the stmmac MAC operations. Instead, I would suggest that a better approach would be for the platform to provide its capabilities to the stmmac core code (maybe a new member in stmmac_priv) which, when set, is used to reduce the capabilities provided to phylink via priv->phylink_config.mac_capabilities.

Why? The driver has several components that are involved in the overall capabilities, and the capabilities of the system is the logical subset of all these capabilities. One component should not be setting capabilities that a different component doesn't support.

In general you are right for sure - it's better to avoid one part setting capabilities and another part unsetting them at least from the readability and maintainability point of view. But in this case we've already got implemented a ready-to-use internal interface stmmac_ops::phylink_get_caps() which can be used to extend/reduce the capabilities field based on the particular MAC abilities. Moreover it's called right from the component setting the capabilities. Are you saying that the callback is supposed to be utilized for extending the capabilities only?

If you insist on not overriding the stmmac_ops::phylink_get_caps() anyway then please explain what is the principal difference between the next two code snippets:

	/* Get the MAC specific capabilities */
        stmmac_mac_phylink_get_caps(priv);
and
	priv->phylink_config.mac_capabilities &= ~priv->plat->mac_caps_mask;

in the MAC-capabilities update implementation? Do you think the later approach would be more descriptive? If so then would the callback-based approach almost equally descriptive if the callback name was, suppose, stmmac_mac_phylink_set_caps() or similar?

In anyway I am sure the approach suggested in the initial patch of this thread isn't good since it motivates the developers to implement more-and-more DW MAC-specific platform capabilities flags fixing another flags, which makes the generic code even more complicated than it already is with endless if-else-plat-flags statements.

-Serge(y)

Quoted 12 lines

Hi Serge,

It seems to be going back again, what do you think?

Thanks,

Yanteng

Quoted 1 line
#83 lore raw

Re: [PATCH net-next v8 09/11] net: stmmac: dwmac-loongson: Fix half duplex

Serge,

Again, please learn to trim your replies.

Quoted 12 lines · Serge Semin
Quoted 11 lines
Quoted 11 lines

As to this approach, I don't think it's a good model to override the stmmac MAC operations. Instead, I would suggest that a better approach would be for the platform to provide its capabilities to the stmmac core code (maybe a new member in stmmac_priv) which, when set, is used to reduce the capabilities provided to phylink via priv->phylink_config.mac_capabilities.

Why? The driver has several components that are involved in the overall capabilities, and the capabilities of the system is the logical subset of all these capabilities. One component should not be setting capabilities that a different component doesn't support.

Quoted 9 lines

In general you are right for sure - it's better to avoid one part setting capabilities and another part unsetting them at least from the readability and maintainability point of view. But in this case we've already got implemented a ready-to-use internal interface stmmac_ops::phylink_get_caps() which can be used to extend/reduce the capabilities field based on the particular MAC abilities. Moreover it's called right from the component setting the capabilities. Are you saying that the callback is supposed to be utilized for extending the capabilities only?

What concerns me is that the proposed code _overwrites_ the capabilities from the MAC layer, so from a maintanability point of view it's a nightmare, because you will now have the situation where MACs provide their capabilities, and then platform code may overwrite it - which means it's like a spiders web trying to work out what capabilities are provided.

The reality is surely that the MAC dictates what it can do, but there may be further restrictions by other components in the platform, so the capabilities provided to phylink should be:

mac_capabilities & platform_capabilities

And what I'm proposing is that _that_ should be done in a way that makes it _easy_ for the platform code to get right. Overriding stmmac_ops::phylink_get_caps() doesn't do that - as can be seen in the proposed patch.

Help your users write correct code by adopting a structure that makes it easy for them to do the right thing.

Quoted 7 lines

If you insist on not overriding the stmmac_ops::phylink_get_caps() anyway then please explain what is the principal difference between the next two code snippets:

	/* Get the MAC specific capabilities */
        stmmac_mac_phylink_get_caps(priv);
and
	priv->phylink_config.mac_capabilities &= ~priv->plat->mac_caps_mask;

I was thinking:

	stmmac_mac_phylink_get_caps(priv);

	if (priv->plat->mac_capabilities)
		priv->phylink_config.mac_capabilities &=
			priv->plat->mac_capabilities;

In other words, if a platform sets plat->mac_capabilities, then it is providing the capabilities that it supports, and those need to reduce the capabilities provided by the MAC.

This will _also_ allow stmmac_set_half_duplex() to do the right thing. Consider something in the platform side that doesn't allow half-duplex, but allows tx_queues_to_use == 1. That'll set the half-duplex modes when stmmac_set_half_duplex() is called, overriding what the platform supports.

Now that I look at the stmmac implementation, there's even more that is wrong. Consider plat->max_speed = 100, like arch/arc/boot/dts/axs10x_mb.dtsi sets. If stmmac_set_half_duplex() is called as it can be from stmmac_reinit_queues(), it'll enable 1000 half-duplex, despite the plat->max_speed = 100.

Quoted 4 lines

in the MAC-capabilities update implementation? Do you think the later approach would be more descriptive? If so then would the callback-based approach almost equally descriptive if the callback name was, suppose, stmmac_mac_phylink_set_caps() or similar?

From what I can see of the existing stmmac MAC phylink_get_caps implementations, there seem to be two - xgmac_phylink_get_caps() and dwmac4_phylink_get_caps(). Both of these merely set additional modes in priv->phylink_config.mac_capabilities. Is there a reason to have this as an instruction stream, rather than providing data to the core stmmac code from the MAC about its capabilities? Is there a reason why it would be necessary for the code in a MAC backend to make a decision about what capabilities to enable based on some condition?

Quoted 5 lines

In anyway I am sure the approach suggested in the initial patch of this thread isn't good since it motivates the developers to implement more-and-more DW MAC-specific platform capabilities flags fixing another flags, which makes the generic code even more complicated than it already is with endless if-else-plat-flags statements.

Yes, I do agree with that.

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
#84 lore raw

Re: [PATCH net-next v8 09/11] net: stmmac: dwmac-loongson: Fix half duplex

Quoted 11 lines · Russell King (Oracle)

I was thinking:

	stmmac_mac_phylink_get_caps(priv);

	if (priv->plat->mac_capabilities)
		priv->phylink_config.mac_capabilities &=
			priv->plat->mac_capabilities;

In other words, if a platform sets plat->mac_capabilities, then it is providing the capabilities that it supports, and those need to reduce the capabilities provided by the MAC.

To further expand on this given the additional discussion, here's a patch that amagamates the ideas so far - however, it doesn't implement everything.

I think an additional step would be to provide a function that does all the mac capability calculations, something like:

static void stmmac_calculate_mac_capabilities(struct stmmac_priv *priv)

{
	struct phylink_config cfg;

	/* do everything with cfg.mac_capabilities that is currently in
	 * stmmac_phy_setup()
	 */

	/* this must be done with rtnl held if the device is open */
	priv->phylink_config.mac_capabilities = cfg.mac_capabilities;
}

and that needs to be called from both stmmac_reinit_queues() and stmmac_phy_setup().

drivers/net/ethernet/stmicro/stmmac/common.h +1 -0
index a6fefe675ef1..a1e144b99213 100644
@@ -605,6 +605,7 @@ struct mac_device_info {
 	unsigned int pmt;
 	unsigned int ps;
 	unsigned int xlgmac;
+	u32 phylink_mac_capabilities;
 	unsigned int num_vlan;
 	u32 vlan_filter[32];
 	bool vlan_fail_q_en;
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +2 -8
index 6b6d0de09619..2e4da6ac5173 100644
@@ -68,11 +68,6 @@ static void dwmac4_core_init(struct mac_device_info *hw,
 		init_waitqueue_head(&priv->tstamp_busy_wait);
 }
 
-static void dwmac4_phylink_get_caps(struct stmmac_priv *priv)
-{
-	priv->phylink_config.mac_capabilities |= MAC_2500FD;
-}
-
 static void dwmac4_rx_queue_enable(struct mac_device_info *hw,
 				   u8 mode, u32 queue)
 {
@@ -1165,7 +1160,6 @@ static void dwmac4_set_hw_vlan_mode(struct mac_device_info *hw)
 
 const struct stmmac_ops dwmac4_ops = {
 	.core_init = dwmac4_core_init,
-	.phylink_get_caps = dwmac4_phylink_get_caps,
 	.set_mac = stmmac_set_mac,
 	.rx_ipc = dwmac4_rx_ipc_enable,
 	.rx_queue_enable = dwmac4_rx_queue_enable,
@@ -1210,7 +1204,6 @@ const struct stmmac_ops dwmac4_ops = {
 
 const struct stmmac_ops dwmac410_ops = {
 	.core_init = dwmac4_core_init,
-	.phylink_get_caps = dwmac4_phylink_get_caps,
 	.set_mac = stmmac_dwmac4_set_mac,
 	.rx_ipc = dwmac4_rx_ipc_enable,
 	.rx_queue_enable = dwmac4_rx_queue_enable,
@@ -1259,7 +1252,6 @@ const struct stmmac_ops dwmac410_ops = {
 
 const struct stmmac_ops dwmac510_ops = {
 	.core_init = dwmac4_core_init,
-	.phylink_get_caps = dwmac4_phylink_get_caps,
 	.set_mac = stmmac_dwmac4_set_mac,
 	.rx_ipc = dwmac4_rx_ipc_enable,
 	.rx_queue_enable = dwmac4_rx_queue_enable,
@@ -1372,5 +1364,7 @@ int dwmac4_setup(struct stmmac_priv *priv)
 	mac->mii.clk_csr_mask = GENMASK(11, 8);
 	mac->num_vlan = dwmac4_get_num_vlan(priv->ioaddr);
 
+	mac->phylink_mac_capabilities |= MAC_2500FD;
+
 	return 0;
 }
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +10 -10
index 1af2f89a0504..f3daa284012b 100644
@@ -47,14 +47,6 @@ static void dwxgmac2_core_init(struct mac_device_info *hw,
 	writel(XGMAC_INT_DEFAULT_EN, ioaddr + XGMAC_INT_EN);
 }
 
-static void xgmac_phylink_get_caps(struct stmmac_priv *priv)
-{
-	priv->phylink_config.mac_capabilities |= MAC_2500FD | MAC_5000FD |
-						 MAC_10000FD | MAC_25000FD |
-						 MAC_40000FD | MAC_50000FD |
-						 MAC_100000FD;
-}
-
 static void dwxgmac2_set_mac(void __iomem *ioaddr, bool enable)
 {
 	u32 tx = readl(ioaddr + XGMAC_TX_CONFIG);
@@ -1516,7 +1508,6 @@ static void dwxgmac3_fpe_configure(void __iomem *ioaddr, struct stmmac_fpe_cfg *
 
 const struct stmmac_ops dwxgmac210_ops = {
 	.core_init = dwxgmac2_core_init,
-	.phylink_get_caps = xgmac_phylink_get_caps,
 	.set_mac = dwxgmac2_set_mac,
 	.rx_ipc = dwxgmac2_rx_ipc,
 	.rx_queue_enable = dwxgmac2_rx_queue_enable,
@@ -1577,7 +1568,6 @@ static void dwxlgmac2_rx_queue_enable(struct mac_device_info *hw, u8 mode,
 
 const struct stmmac_ops dwxlgmac2_ops = {
 	.core_init = dwxgmac2_core_init,
-	.phylink_get_caps = xgmac_phylink_get_caps,
 	.set_mac = dwxgmac2_set_mac,
 	.rx_ipc = dwxgmac2_rx_ipc,
 	.rx_queue_enable = dwxlgmac2_rx_queue_enable,
@@ -1656,6 +1646,11 @@ int dwxgmac2_setup(struct stmmac_priv *priv)
 	mac->mii.clk_csr_shift = 19;
 	mac->mii.clk_csr_mask = GENMASK(21, 19);
 
+	mac->phylink_mac_capabilities = MAC_2500FD | MAC_5000FD |
+					MAC_10000FD | MAC_25000FD |
+					MAC_40000FD | MAC_50000FD |
+					MAC_100000FD;
+
 	return 0;
 }
 
@@ -1693,5 +1688,10 @@ int dwxlgmac2_setup(struct stmmac_priv *priv)
 	mac->mii.clk_csr_shift = 19;
 	mac->mii.clk_csr_mask = GENMASK(21, 19);
 
+	mac->phylink_mac_capabilities = MAC_2500FD | MAC_5000FD |
+					MAC_10000FD | MAC_25000FD |
+					MAC_40000FD | MAC_50000FD |
+					MAC_100000FD;
+
 	return 0;
 }
drivers/net/ethernet/stmicro/stmmac/hwif.h +0 -4
index 7be04b54738b..7370cd963569 100644
@@ -308,8 +308,6 @@ struct stmmac_est;
 struct stmmac_ops {
 	/* MAC core initialization */
 	void (*core_init)(struct mac_device_info *hw, struct net_device *dev);
-	/* Get phylink capabilities */
-	void (*phylink_get_caps)(struct stmmac_priv *priv);
 	/* Enable the MAC RX/TX */
 	void (*set_mac)(void __iomem *ioaddr, bool enable);
 	/* Enable and verify that the IPC module is supported */
@@ -430,8 +428,6 @@ struct stmmac_ops {
 
 #define stmmac_core_init(__priv, __args...) \
 	stmmac_do_void_callback(__priv, mac, core_init, __args)
-#define stmmac_mac_phylink_get_caps(__priv) \
-	stmmac_do_void_callback(__priv, mac, phylink_get_caps, __priv)
 #define stmmac_mac_set(__priv, __args...) \
 	stmmac_do_void_callback(__priv, mac, set_mac, __args)
 #define stmmac_rx_ipc(__priv, __args...) \
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +13 -3
index 24cd80490d19..5e8cffc49f1f 100644
@@ -1240,15 +1240,25 @@ static int stmmac_phy_setup(struct stmmac_priv *priv)
 						MAC_10FD | MAC_100FD |
 						MAC_1000FD;
 
-	stmmac_set_half_duplex(priv);
+	/* Merge in the MAC capabilities */
+	priv->phylink_config.mac_capabilities |=
+					priv->hw->phylink_mac_capabilities;
 
-	/* Get the MAC specific capabilities */
-	stmmac_mac_phylink_get_caps(priv);
+	stmmac_set_half_duplex(priv);
 
 	max_speed = priv->plat->max_speed;
 	if (max_speed)
 		phylink_limit_mac_speed(&priv->phylink_config, max_speed);
 
+	/* If the platform supplies MAC capabilities, calculate the union
+	 * of the MAC and platform capabilities to give the whole-system
+	 * capabilities. This intetionally can not add additional capabilities
+	 * so if this is populated, it must list everything that is supported.
+	 */
+	if (priv->plat->phylink_mac_capabilities)
+		priv->phylink_config.mac_capabilities &=
+					priv->plat->phylink_mac_capabilities;
+
 	fwnode = priv->plat->port_node;
 	if (!fwnode)
 		fwnode = dev_fwnode(priv->device);
include/linux/stmmac.h +1 -0
index dfa1828cd756..fe3f64df17ac 100644
@@ -272,6 +272,7 @@ struct plat_stmmacenet_data {
 	u8 tx_sched_algorithm;
 	struct stmmac_rxq_cfg rx_queues_cfg[MTL_MAX_RX_QUEUES];
 	struct stmmac_txq_cfg tx_queues_cfg[MTL_MAX_TX_QUEUES];
+	u32 phylink_mac_capabilities;
 	void (*fix_mac_speed)(void *priv, unsigned int speed, unsigned int mode);
 	int (*fix_soc_reset)(void *priv, void __iomem *ioaddr);
 	int (*serdes_powerup)(struct net_device *ndev, void *priv);
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
#85 lore raw

Re: [PATCH net-next v8 09/11] net: stmmac: dwmac-loongson: Fix half duplex

Quoted 13 lines · Russell King (Oracle)
Quoted 11 lines · Russell King (Oracle)

I was thinking:

	stmmac_mac_phylink_get_caps(priv);

	if (priv->plat->mac_capabilities)
		priv->phylink_config.mac_capabilities &=
			priv->plat->mac_capabilities;

In other words, if a platform sets plat->mac_capabilities, then it is providing the capabilities that it supports, and those need to reduce the capabilities provided by the MAC.

Quoted 6 lines

To further expand on this given the additional discussion, here's a patch that amagamates the ideas so far - however, it doesn't implement everything.

I think an additional step would be to provide a function that does all the mac capability calculations, something like:

Here's the complete patch:

drivers/net/ethernet/stmicro/stmmac/common.h +1 -0
index a6fefe675ef1..a1e144b99213 100644
@@ -605,6 +605,7 @@ struct mac_device_info {
 	unsigned int pmt;
 	unsigned int ps;
 	unsigned int xlgmac;
+	u32 phylink_mac_capabilities;
 	unsigned int num_vlan;
 	u32 vlan_filter[32];
 	bool vlan_fail_q_en;
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +2 -8
index 6b6d0de09619..2e4da6ac5173 100644
@@ -68,11 +68,6 @@ static void dwmac4_core_init(struct mac_device_info *hw,
 		init_waitqueue_head(&priv->tstamp_busy_wait);
 }
 
-static void dwmac4_phylink_get_caps(struct stmmac_priv *priv)
-{
-	priv->phylink_config.mac_capabilities |= MAC_2500FD;
-}
-
 static void dwmac4_rx_queue_enable(struct mac_device_info *hw,
 				   u8 mode, u32 queue)
 {
@@ -1165,7 +1160,6 @@ static void dwmac4_set_hw_vlan_mode(struct mac_device_info *hw)
 
 const struct stmmac_ops dwmac4_ops = {
 	.core_init = dwmac4_core_init,
-	.phylink_get_caps = dwmac4_phylink_get_caps,
 	.set_mac = stmmac_set_mac,
 	.rx_ipc = dwmac4_rx_ipc_enable,
 	.rx_queue_enable = dwmac4_rx_queue_enable,
@@ -1210,7 +1204,6 @@ const struct stmmac_ops dwmac4_ops = {
 
 const struct stmmac_ops dwmac410_ops = {
 	.core_init = dwmac4_core_init,
-	.phylink_get_caps = dwmac4_phylink_get_caps,
 	.set_mac = stmmac_dwmac4_set_mac,
 	.rx_ipc = dwmac4_rx_ipc_enable,
 	.rx_queue_enable = dwmac4_rx_queue_enable,
@@ -1259,7 +1252,6 @@ const struct stmmac_ops dwmac410_ops = {
 
 const struct stmmac_ops dwmac510_ops = {
 	.core_init = dwmac4_core_init,
-	.phylink_get_caps = dwmac4_phylink_get_caps,
 	.set_mac = stmmac_dwmac4_set_mac,
 	.rx_ipc = dwmac4_rx_ipc_enable,
 	.rx_queue_enable = dwmac4_rx_queue_enable,
@@ -1372,5 +1364,7 @@ int dwmac4_setup(struct stmmac_priv *priv)
 	mac->mii.clk_csr_mask = GENMASK(11, 8);
 	mac->num_vlan = dwmac4_get_num_vlan(priv->ioaddr);
 
+	mac->phylink_mac_capabilities |= MAC_2500FD;
+
 	return 0;
 }
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +10 -10
index 1af2f89a0504..f3daa284012b 100644
@@ -47,14 +47,6 @@ static void dwxgmac2_core_init(struct mac_device_info *hw,
 	writel(XGMAC_INT_DEFAULT_EN, ioaddr + XGMAC_INT_EN);
 }
 
-static void xgmac_phylink_get_caps(struct stmmac_priv *priv)
-{
-	priv->phylink_config.mac_capabilities |= MAC_2500FD | MAC_5000FD |
-						 MAC_10000FD | MAC_25000FD |
-						 MAC_40000FD | MAC_50000FD |
-						 MAC_100000FD;
-}
-
 static void dwxgmac2_set_mac(void __iomem *ioaddr, bool enable)
 {
 	u32 tx = readl(ioaddr + XGMAC_TX_CONFIG);
@@ -1516,7 +1508,6 @@ static void dwxgmac3_fpe_configure(void __iomem *ioaddr, struct stmmac_fpe_cfg *
 
 const struct stmmac_ops dwxgmac210_ops = {
 	.core_init = dwxgmac2_core_init,
-	.phylink_get_caps = xgmac_phylink_get_caps,
 	.set_mac = dwxgmac2_set_mac,
 	.rx_ipc = dwxgmac2_rx_ipc,
 	.rx_queue_enable = dwxgmac2_rx_queue_enable,
@@ -1577,7 +1568,6 @@ static void dwxlgmac2_rx_queue_enable(struct mac_device_info *hw, u8 mode,
 
 const struct stmmac_ops dwxlgmac2_ops = {
 	.core_init = dwxgmac2_core_init,
-	.phylink_get_caps = xgmac_phylink_get_caps,
 	.set_mac = dwxgmac2_set_mac,
 	.rx_ipc = dwxgmac2_rx_ipc,
 	.rx_queue_enable = dwxlgmac2_rx_queue_enable,
@@ -1656,6 +1646,11 @@ int dwxgmac2_setup(struct stmmac_priv *priv)
 	mac->mii.clk_csr_shift = 19;
 	mac->mii.clk_csr_mask = GENMASK(21, 19);
 
+	mac->phylink_mac_capabilities = MAC_2500FD | MAC_5000FD |
+					MAC_10000FD | MAC_25000FD |
+					MAC_40000FD | MAC_50000FD |
+					MAC_100000FD;
+
 	return 0;
 }
 
@@ -1693,5 +1688,10 @@ int dwxlgmac2_setup(struct stmmac_priv *priv)
 	mac->mii.clk_csr_shift = 19;
 	mac->mii.clk_csr_mask = GENMASK(21, 19);
 
+	mac->phylink_mac_capabilities = MAC_2500FD | MAC_5000FD |
+					MAC_10000FD | MAC_25000FD |
+					MAC_40000FD | MAC_50000FD |
+					MAC_100000FD;
+
 	return 0;
 }
drivers/net/ethernet/stmicro/stmmac/hwif.h +0 -4
index 7be04b54738b..7370cd963569 100644
@@ -308,8 +308,6 @@ struct stmmac_est;
 struct stmmac_ops {
 	/* MAC core initialization */
 	void (*core_init)(struct mac_device_info *hw, struct net_device *dev);
-	/* Get phylink capabilities */
-	void (*phylink_get_caps)(struct stmmac_priv *priv);
 	/* Enable the MAC RX/TX */
 	void (*set_mac)(void __iomem *ioaddr, bool enable);
 	/* Enable and verify that the IPC module is supported */
@@ -430,8 +428,6 @@ struct stmmac_ops {
 
 #define stmmac_core_init(__priv, __args...) \
 	stmmac_do_void_callback(__priv, mac, core_init, __args)
-#define stmmac_mac_phylink_get_caps(__priv) \
-	stmmac_do_void_callback(__priv, mac, phylink_get_caps, __priv)
 #define stmmac_mac_set(__priv, __args...) \
 	stmmac_do_void_callback(__priv, mac, set_mac, __args)
 #define stmmac_rx_ipc(__priv, __args...) \
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +25 -18

65 lines not on this page · raw message

include/linux/stmmac.h +1 -0
index dfa1828cd756..fe3f64df17ac 100644
@@ -272,6 +272,7 @@ struct plat_stmmacenet_data {
 	u8 tx_sched_algorithm;
 	struct stmmac_rxq_cfg rx_queues_cfg[MTL_MAX_RX_QUEUES];
 	struct stmmac_txq_cfg tx_queues_cfg[MTL_MAX_TX_QUEUES];
+	u32 phylink_mac_capabilities;
 	void (*fix_mac_speed)(void *priv, unsigned int speed, unsigned int mode);
 	int (*fix_soc_reset)(void *priv, void __iomem *ioaddr);
 	int (*serdes_powerup)(struct net_device *ndev, void *priv);
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
#86 lore raw

Re: [PATCH net-next v8 09/11] net: stmmac: dwmac-loongson: Fix half duplex

In reply to Russell King (Oracle)
Quoted 3 lines · Russell King (Oracle)

Serge,

Again, please learn to trim your replies.

Ok, got it.

Quoted 27 lines · Serge Semin

...

Quoted 10 lines

In general you are right for sure - it's better to avoid one part setting capabilities and another part unsetting them at least from the readability and maintainability point of view. But in this case we've already got implemented a ready-to-use internal interface stmmac_ops::phylink_get_caps() which can be used to extend/reduce the capabilities field based on the particular MAC abilities. Moreover it's called right from the component setting the capabilities. Are you saying that the callback is supposed to be utilized for extending the capabilities only?

What concerns me is that the proposed code _overwrites_ the capabilities from the MAC layer, so from a maintanability point of view it's a nightmare, because you will now have the situation where MACs provide their capabilities, and then platform code may overwrite it - which means it's like a spiders web trying to work out what capabilities are provided.

The reality is surely that the MAC dictates what it can do, but there may be further restrictions by other components in the platform, so the capabilities provided to phylink should be:

mac_capabilities & platform_capabilities

Quoted 7 lines

And what I'm proposing is that _that_ should be done in a way that makes it _easy_ for the platform code to get right. Overriding stmmac_ops::phylink_get_caps() doesn't do that - as can be seen in the proposed patch.

Help your users write correct code by adopting a structure that makes it easy for them to do the right thing.

Got it. Thanks for the detailed explanation. So you prefer not to provide too much freedom in the interface to refrain the users from unwillingly doing something wrong. Sounds very reasonable.

Quoted 28 lines
Quoted 8 lines

If you insist on not overriding the stmmac_ops::phylink_get_caps() anyway then please explain what is the principal difference between the next two code snippets:

	/* Get the MAC specific capabilities */
        stmmac_mac_phylink_get_caps(priv);
and
	priv->phylink_config.mac_capabilities &= ~priv->plat->mac_caps_mask;

I was thinking:

	stmmac_mac_phylink_get_caps(priv);

	if (priv->plat->mac_capabilities)
		priv->phylink_config.mac_capabilities &=
			priv->plat->mac_capabilities;

In other words, if a platform sets plat->mac_capabilities, then it is providing the capabilities that it supports, and those need to reduce the capabilities provided by the MAC.

This will _also_ allow stmmac_set_half_duplex() to do the right thing. Consider something in the platform side that doesn't allow half-duplex, but allows tx_queues_to_use == 1. That'll set the half-duplex modes when stmmac_set_half_duplex() is called, overriding what the platform supports.

Quoted 5 lines

Now that I look at the stmmac implementation, there's even more that is wrong. Consider plat->max_speed = 100, like arch/arc/boot/dts/axs10x_mb.dtsi sets. If stmmac_set_half_duplex() is called as it can be from stmmac_reinit_queues(), it'll enable 1000 half-duplex, despite the plat->max_speed = 100.

Right. Plus to that I found three more issues in the MAC-capabilities detection code:
1. There is DW MAC100 (see dwmac100_core.c, dwmac100_dma.c), which doesn't seem like supporting 1G speed, but stmmac_phy_setup() and stmmac_set_half_duplex() enable the MAC_1000* capabilities anyway.
2. DW XGMAC doesn't support 10/100Mbps speed and half-duplex, but the stmmac_phy_setup() and stmmac_set_half_duplex() methods set them up anyway.
3. It seems that the Tx-queues-based constraint of the half-duplex-ness is only specific for DW QoS Eth (DW GMAC v4/v5). The databook explicitly says about that:
"In multi queue/channel configurations, enable only Q0/CH0 on Tx and Rx for half-duplex operation. If you want to enable single queue/channel in full-duplex operation, any queue/channel can be enabled."
There is no such note in the DW GMAC v3.x databook.

At least first two problems look as bugs. The last note will be interesting for Yanteng who has the multi-channel DW GMAC _v3_ device with the half-duplex mode working for all channels. Therefore the statement

        if (priv->plat->tx_queues_to_use > 1)
                priv->phylink_config.mac_capabilities &=
                        ~(MAC_10HD | MAC_100HD | MAC_1000HD);
        else
                priv->phylink_config.mac_capabilities |=
                        (MAC_10HD | MAC_100HD | MAC_1000HD);

won't be acceptable for his device.

Quoted 7 lines
Quoted 5 lines

in the MAC-capabilities update implementation? Do you think the later approach would be more descriptive? If so then would the callback-based approach almost equally descriptive if the callback name was, suppose, stmmac_mac_phylink_set_caps() or similar?

Quoted 9 lines

From what I can see of the existing stmmac MAC phylink_get_caps implementations, there seem to be two - xgmac_phylink_get_caps() and dwmac4_phylink_get_caps(). Both of these merely set additional modes in priv->phylink_config.mac_capabilities. Is there a reason to have this as an instruction stream, rather than providing data to the core stmmac code from the MAC about its capabilities? Is there a reason why it would be necessary for the code in a MAC backend to make a decision about what capabilities to enable based on some condition?

Seeing the Tx-queues-based constraint is DW QoS Eth-specific there is such reason. It might be better to move the selective Half-duplex mode disabling to the MAC-specific callback.

But based on what you already demonstrated in the following up email messages there is a better option to implement the MAC capabilities detection procedure. Let's see what MAC-capabilities can be currently specified based on the DW MAC IP-core versions:

DW MAC100: MAC_ASYM_PAUSE | MAC_SYM_PAUSE |

	   MAC_10 | MAC_100

DW GMAC: MAC_ASYM_PAUSE | MAC_SYM_PAUSE |

         MAC_10 | MAC_100 | MAC_1000

DW QoS Eth: MAC_ASYM_PAUSE | MAC_SYM_PAUSE |

            MAC_10 | MAC_100 | MAC_1000 | MAC_2500FD
but if the amount of the active Tx queues is > 1, then:
	   MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
           MAC_10FD | MAC_100FD | MAC_1000FD | MAC_2500FD 

DW XGMAC: MAC_ASYM_PAUSE | MAC_SYM_PAUSE |

          MAC_1000FD | MAC_2500FD | MAC_5000FD |
          MAC_10000FD | MAC_25000FD |
          MAC_40000FD | MAC_50000FD |
          MAC_100000FD

As you can see there are only two common capabilities:
MAC_ASYM_PAUSE | MAC_SYM_PAUSE. Seeing the flow-control is implemented as a callback for each MAC IP-core (see dwmac100_flow_ctrl(), dwmac1000_flow_ctrl(), sun8i_dwmac_flow_ctrl(), etc) we can freely move all the PHYLINK MAC capabilities initializations to the MAC-specific setup methods (similarly to what you already did in your patch but specifying the full MAC capabilities list).

After that the only IP-core which requires the capabilities update will be DW QoS Eth. So the Tx-queue-based capabilities update can be moved there and the rest of the xgmac_phylink_get_caps() callback can be dropped.

We can go further. Instead of calling the stmmac_set_half_duplex()/stmmac_set_mac_capabilties() methods on the device init and queues reinit stages, we can move their bodies into the phylink:mac_get_caps() callback.

Here is what the described changes will look like:

drivers/net/ethernet/stmicro/stmmac/common.h +1 -0
index 721c1f8e892f..2339af32ac77 100644
@@ -525,6 +525,7 @@ extern const struct stmmac_hwtimestamp stmmac_ptp;
 extern const struct stmmac_mode_ops dwmac4_ring_mode_ops;
 
 struct mac_link {
+	u32 caps;
 	u32 speed_mask;
 	u32 speed10;
 	u32 speed100;
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c +2 -0
index 137741b94122..6bc18d4c4da9 100644
@@ -1097,6 +1097,8 @@ static struct mac_device_info *sun8i_dwmac_setup(void *ppriv)
 
 	priv->dev->priv_flags |= IFF_UNICAST_FLT;
 
+	mac->link.caps = MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
+			 MAC_10 | MAC_100 | MAC_1000;
 	/* The loopback bit seems to be re-set when link change
 	 * Simply mask it each time
 	 * Speed 10/100/1000 are set in BIT(2)/BIT(3)
drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +2 -0
index 3927609abc44..8555299443f4 100644
@@ -539,6 +539,8 @@ int dwmac1000_setup(struct stmmac_priv *priv)
 	if (mac->multicast_filter_bins)
 		mac->mcast_bits_log2 = ilog2(mac->multicast_filter_bins);
 
+	mac->link.caps = MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
+			 MAC_10 | MAC_100 | MAC_1000;
 	mac->link.duplex = GMAC_CONTROL_DM;
 	mac->link.speed10 = GMAC_CONTROL_PS;
 	mac->link.speed100 = GMAC_CONTROL_PS | GMAC_CONTROL_FES;
drivers/net/ethernet/stmicro/stmmac/dwmac100_core.c +2 -0
index a6e8d7bd9588..7667d103cd0e 100644
@@ -175,6 +175,8 @@ int dwmac100_setup(struct stmmac_priv *priv)
 	dev_info(priv->device, "\tDWMAC100\n");
 
 	mac->pcsr = priv->ioaddr;
+	mac->link.caps = MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
+			 MAC_10 | MAC_100;
 	mac->link.duplex = MAC_CONTROL_F;
 	mac->link.speed10 = 0;
 	mac->link.speed100 = 0;
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +7 -1
index 6b6d0de09619..c51dc946e8ef 100644
@@ -70,7 +70,11 @@ static void dwmac4_core_init(struct mac_device_info *hw,
 
 static void dwmac4_phylink_get_caps(struct stmmac_priv *priv)
 {
-	priv->phylink_config.mac_capabilities |= MAC_2500FD;
+	/* Half-Duplex can only work with single tx queue */
+	if (priv->plat->tx_queues_to_use > 1)
+		priv->hw->link.caps &= ~(MAC_10HD | MAC_100HD | MAC_1000HD);
+	else
+		priv->hw->link.caps |= (MAC_10HD | MAC_100HD | MAC_1000HD);
 }
 
 static void dwmac4_rx_queue_enable(struct mac_device_info *hw,
@@ -1356,6 +1360,8 @@ int dwmac4_setup(struct stmmac_priv *priv)
 	if (mac->multicast_filter_bins)
 		mac->mcast_bits_log2 = ilog2(mac->multicast_filter_bins);
 
+	mac->link.caps = MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
+			 MAC_10 | MAC_100 | MAC_1000 | MAC_2500FD;
 	mac->link.duplex = GMAC_CONFIG_DM;
 	mac->link.speed10 = GMAC_CONFIG_PS;
 	mac->link.speed100 = GMAC_CONFIG_FES | GMAC_CONFIG_PS;
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +5 -8
index eb48211d9b0e..79ea8329ead5 100644
@@ -47,14 +47,6 @@ static void dwxgmac2_core_init(struct mac_device_info *hw,
 	writel(XGMAC_INT_DEFAULT_EN, ioaddr + XGMAC_INT_EN);
 }
 
-static void xgmac_phylink_get_caps(struct stmmac_priv *priv)
-{
-	priv->phylink_config.mac_capabilities |= MAC_2500FD | MAC_5000FD |
-						 MAC_10000FD | MAC_25000FD |
-						 MAC_40000FD | MAC_50000FD |
-						 MAC_100000FD;
-}
-
 static void dwxgmac2_set_mac(void __iomem *ioaddr, bool enable)
 {
 	u32 tx = readl(ioaddr + XGMAC_TX_CONFIG);
@@ -1618,6 +1610,11 @@ int dwxlgmac2_setup(struct stmmac_priv *priv)
 	if (mac->multicast_filter_bins)
 		mac->mcast_bits_log2 = ilog2(mac->multicast_filter_bins);
 
+	mac->link.caps = MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
+			 MAC_1000FD | MAC_2500FD | MAC_5000FD |
+			 MAC_10000FD | MAC_25000FD |
+			 MAC_40000FD | MAC_50000FD |
+			 MAC_100000FD;
 	mac->link.duplex = 0;
 	mac->link.speed1000 = XLGMAC_CONFIG_SS_1000;
 	mac->link.speed2500 = XLGMAC_CONFIG_SS_2500;
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +17 -25

72 lines not on this page · raw message

---

Note I intentionally omitted the part with the platform-specific MAC capabilities filtering because AFAICS it won't be necessary for Yanteng. He'll have the plat_stmmacenet_data::setup() callback defined anyway, in which he'll be able to initialize the MAC capabilities as required by his platform.

-Serge(y)

Quoted 12 lines
Quoted 6 lines

In anyway I am sure the approach suggested in the initial patch of this thread isn't good since it motivates the developers to implement more-and-more DW MAC-specific platform capabilities flags fixing another flags, which makes the generic code even more complicated than it already is with endless if-else-plat-flags statements.

Yes, I do agree with that.

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
#87 lore raw

Re: [PATCH net-next v8 09/11] net: stmmac: dwmac-loongson: Fix half duplex

Quoted 12 lines · Serge Semin
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +4 -0
index 25519952f754..24ff5d1eb963 100644
@@ -936,6 +936,22 @@ static void stmmac_mac_flow_ctrl(struct stmmac_priv *priv, u32 duplex)
 			priv->pause, tx_cnt);
 }
 
+static unsigned long stmmac_mac_get_caps(struct phylink_config *config,
+					 phy_interface_t interface)
+{
+	struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev));

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static void stmmac_mac_flow_ctrl(struct stmmac_priv *priv, u32 duplex) · line 952

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +10 -0
+
+	/* Get the MAC-specific capabilities */
+	stmmac_mac_phylink_get_caps(priv);
+
+	config->mac_capabilities = priv->hw->link.caps;
+
+	if (priv->plat->max_speed)
+		phylink_limit_mac_speed(config, priv->plat->max_speed);
+
+	return config->mac_capabilities;

Yes, I think your approach is better - and it still allows for the platform's capabilities to be masked in towards the end of this function.

Thanks.

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
#88 lore raw

Re: [PATCH net-next v8 09/11] net: stmmac: dwmac-loongson: Fix half duplex

Quoted 19 lines · Russell King (Oracle)
Quoted 18 lines · Serge Semin
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +10 -0
index 25519952f754..24ff5d1eb963 100644
@@ -936,6 +936,22 @@ static void stmmac_mac_flow_ctrl(struct stmmac_priv *priv, u32 duplex)
 			priv->pause, tx_cnt);
 }
 
+static unsigned long stmmac_mac_get_caps(struct phylink_config *config,
+					 phy_interface_t interface)
+{
+	struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev));
+
+	/* Get the MAC-specific capabilities */
+	stmmac_mac_phylink_get_caps(priv);
+
+	config->mac_capabilities = priv->hw->link.caps;
+
Quoted 8 lines

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static void stmmac_mac_flow_ctrl(struct stmmac_priv *priv, u32 duplex) · line 952

Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +4 -0
+	if (priv->plat->max_speed)
+		phylink_limit_mac_speed(config, priv->plat->max_speed);
+
+	return config->mac_capabilities;

Yes, I think your approach is better - and it still allows for the platform's capabilities to be masked in towards the end of this function.

Sorry for the long-term response. Thanks for your comment. Seeing Yanteng is struggling much with this series review I'll convert the suggested change into a patchset (taking into account that the change implies some fixes) and submit it for review later on this week. After finishing the review stage, the series could be either merged in right away or Yanteng will be able to pick it up and add it into his patchset.

-Serge(y)

Quoted 6 lines

Thanks.

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
author
#89 lore raw

Re: [PATCH net-next v8 09/11] net: stmmac: dwmac-loongson: Fix half duplex

Quoted 27 lines · Serge Semin
Quoted 18 lines · Russell King (Oracle)
Quoted 17 lines · Serge Semin
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +9 -0
index 25519952f754..24ff5d1eb963 100644
@@ -936,6 +936,22 @@ static void stmmac_mac_flow_ctrl(struct stmmac_priv *priv, u32 duplex)
  			priv->pause, tx_cnt);
  }
 
+static unsigned long stmmac_mac_get_caps(struct phylink_config *config,
+					 phy_interface_t interface)
+{
+	struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev));
+
+	/* Get the MAC-specific capabilities */
+	stmmac_mac_phylink_get_caps(priv);
+
+	config->mac_capabilities = priv->hw->link.caps;
Quoted 8 lines

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static void stmmac_mac_flow_ctrl(struct stmmac_priv *priv, u32 duplex) · line 952

Quoted 5 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +5 -0
+
+	if (priv->plat->max_speed)
+		phylink_limit_mac_speed(config, priv->plat->max_speed);
+
+	return config->mac_capabilities;

Yes, I think your approach is better - and it still allows for the platform's capabilities to be masked in towards the end of this function.

Quoted 7 lines

Sorry for the long-term response. Thanks for your comment. Seeing Yanteng is struggling much with this series review I'll convert the suggested change into a patchset (taking into account that the change implies some fixes) and submit it for review later on this week. After finishing the review stage, the series could be either merged in right away or Yanteng will be able to pick it up and add it into his patchset.

Couldn't be better! I have already started to re-split the patches, and then a series

of tests are needed. There are some network card parameters that I need to confirm

with the hardware engineer. Of course, I will pay attention to the email list before

sending it out. If I don't see your patch set, I will pick it up.

Thanks,

Yanteng

author
#90 lore raw

PATCH v8 10/11 net: stmmac: dwmac-loongson: Disable flow control for GMAC

In reply to Yanteng Si

Loongson GMAC does not support Flow Control feature. Set flags to disable it.

---
 drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c | 1 +
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c    | 6 +++---
 include/linux/stmmac.h                               | 1 +
 3 files changed, 5 insertions(+), 3 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +1 -0
index 1753a3c46b77..b78a73ea748b 100644
@@ -335,6 +335,7 @@ static int loongson_gmac_config(struct pci_dev *pdev,
 				struct stmmac_resources *res,
 				struct device_node *np)
 {
+	plat->flags |= STMMAC_FLAG_DISABLE_FLOW_CONTROL;
 
 	return 0;
 }
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +3 -3
index 3aa862269eb0..8d676cbfba1e 100644
@@ -1237,9 +1237,9 @@ static int stmmac_phy_setup(struct stmmac_priv *priv)
 		xpcs_get_interfaces(priv->hw->xpcs,
 				    priv->phylink_config.supported_interfaces);
 
-	priv->phylink_config.mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
-						MAC_10FD | MAC_100FD |
-						MAC_1000FD;
+	priv->phylink_config.mac_capabilities = MAC_10FD | MAC_100FD | MAC_1000FD;
+	if (!(priv->plat->flags & STMMAC_FLAG_DISABLE_FLOW_CONTROL))
+		priv->phylink_config.mac_capabilities |= MAC_ASYM_PAUSE | MAC_SYM_PAUSE;
 
 	stmmac_set_half_duplex(priv);
 
include/linux/stmmac.h +1 -0
index 197f6f914104..832cd8cd688f 100644
@@ -223,6 +223,7 @@ struct dwmac4_addrs {
 #define STMMAC_FLAG_HWTSTAMP_CORRECT_LATENCY	BIT(12)
 #define STMMAC_FLAG_DISABLE_FORCE_1000	BIT(13)
 #define STMMAC_FLAG_DISABLE_HALF_DUPLEX	BIT(14)
+#define STMMAC_FLAG_DISABLE_FLOW_CONTROL	BIT(15)
 
 struct plat_stmmacenet_data {
 	int bus_id;
Signature · 1 line
2.31.4
#91 lore raw

Re: [PATCH net-next v8 10/11] net: stmmac: dwmac-loongson: Disable flow control for GMAC

Quoted 46 lines · Yanteng Si

Loongson GMAC does not support Flow Control feature. Set flags to disable it.

---
 drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c | 1 +
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c    | 6 +++---
 include/linux/stmmac.h                               | 1 +
 3 files changed, 5 insertions(+), 3 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +1 -0
index 1753a3c46b77..b78a73ea748b 100644
@@ -335,6 +335,7 @@ static int loongson_gmac_config(struct pci_dev *pdev,
 				struct stmmac_resources *res,
 				struct device_node *np)
 {
+	plat->flags |= STMMAC_FLAG_DISABLE_FLOW_CONTROL;
 
 	return 0;
 }
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +3 -3
index 3aa862269eb0..8d676cbfba1e 100644
@@ -1237,9 +1237,9 @@ static int stmmac_phy_setup(struct stmmac_priv *priv)
 		xpcs_get_interfaces(priv->hw->xpcs,
 				    priv->phylink_config.supported_interfaces);
 
-	priv->phylink_config.mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
-						MAC_10FD | MAC_100FD |
-						MAC_1000FD;
+	priv->phylink_config.mac_capabilities = MAC_10FD | MAC_100FD | MAC_1000FD;
+	if (!(priv->plat->flags & STMMAC_FLAG_DISABLE_FLOW_CONTROL))
+		priv->phylink_config.mac_capabilities |= MAC_ASYM_PAUSE | MAC_SYM_PAUSE;
 
 	stmmac_set_half_duplex(priv);
 
include/linux/stmmac.h +0 -0
index 197f6f914104..832cd8cd688f 100644

include/linux/stmmac.h struct dwmac4_addrs { · line 226

Quoted 4 lines
include/linux/stmmac.h +1 -0
@@ -223,6 +223,7 @@ struct dwmac4_addrs {
 #define STMMAC_FLAG_HWTSTAMP_CORRECT_LATENCY	BIT(12)
 #define STMMAC_FLAG_DISABLE_FORCE_1000	BIT(13)
 #define STMMAC_FLAG_DISABLE_HALF_DUPLEX	BIT(14)
+#define STMMAC_FLAG_DISABLE_FLOW_CONTROL	BIT(15)

See my last comment in patch 9/11. This can be reached by re-defining the stmmac_ops::phylink_get_caps() callback.

-Serge(y)

Quoted 6 lines
include/linux/stmmac.h +0 -0
 struct plat_stmmacenet_data {
 	int bus_id;
Signature · 1 line
2.31.4
author
#92 lore raw

Re: [PATCH net-next v8 10/11] net: stmmac: dwmac-loongson: Disable flow control for GMAC

Quoted 42 lines · Serge Semin
Quoted 41 lines · Yanteng Si

Loongson GMAC does not support Flow Control feature. Set flags to disable it.

---
  drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c | 1 +
  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c    | 6 +++---
  include/linux/stmmac.h                               | 1 +
  3 files changed, 5 insertions(+), 3 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +1 -0
index 1753a3c46b77..b78a73ea748b 100644
@@ -335,6 +335,7 @@ static int loongson_gmac_config(struct pci_dev *pdev,
  				struct stmmac_resources *res,
  				struct device_node *np)
  {
+	plat->flags |= STMMAC_FLAG_DISABLE_FLOW_CONTROL;
 
  	return 0;
  }
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +3 -3
index 3aa862269eb0..8d676cbfba1e 100644
@@ -1237,9 +1237,9 @@ static int stmmac_phy_setup(struct stmmac_priv *priv)
  		xpcs_get_interfaces(priv->hw->xpcs,
  				    priv->phylink_config.supported_interfaces);
 
-	priv->phylink_config.mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
-						MAC_10FD | MAC_100FD |
-						MAC_1000FD;
+	priv->phylink_config.mac_capabilities = MAC_10FD | MAC_100FD | MAC_1000FD;
+	if (!(priv->plat->flags & STMMAC_FLAG_DISABLE_FLOW_CONTROL))
+		priv->phylink_config.mac_capabilities |= MAC_ASYM_PAUSE | MAC_SYM_PAUSE;
 
  	stmmac_set_half_duplex(priv);
 
Quoted 11 lines

include/linux/stmmac.h struct dwmac4_addrs { · line 226

Quoted 9 lines
include/linux/stmmac.h +1 -0
index 197f6f914104..832cd8cd688f 100644
@@ -223,6 +223,7 @@ struct dwmac4_addrs {
  #define STMMAC_FLAG_HWTSTAMP_CORRECT_LATENCY	BIT(12)
  #define STMMAC_FLAG_DISABLE_FORCE_1000	BIT(13)
  #define STMMAC_FLAG_DISABLE_HALF_DUPLEX	BIT(14)
+#define STMMAC_FLAG_DISABLE_FLOW_CONTROL	BIT(15)

See my last comment in patch 9/11. This can be reached by re-defining the stmmac_ops::phylink_get_caps() callback.

OK.

Thanks,

Yanteng

Quoted 9 lines

-Serge(y)

Quoted 6 lines
include/linux/stmmac.h +0 -0
  struct plat_stmmacenet_data {
  	int bus_id;
Signature · 1 line
2.31.4
author
#93 lore raw

PATCH v8 11/11 net: stmmac: dwmac-loongson: Disable coe for some Loongson GNET

In reply to Yanteng Si

Some chips of Loongson GNET does not support coe, so disable them.

Set dma_cap->tx_coe to 0 and overwrite get_hw_feature.

---
 .../ethernet/stmicro/stmmac/dwmac-loongson.c  | 46 +++++++++++++++++++
 1 file changed, 46 insertions(+)
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +46 -0
index b78a73ea748b..8018d7d5f31b 100644
@@ -196,6 +196,51 @@ static int dwlgmac_dma_interrupt(struct stmmac_priv *priv, void __iomem *ioaddr,
 	return ret;
 }
 
+static int dwlgmac_get_hw_feature(void __iomem *ioaddr,
+				  struct dma_features *dma_cap)
+{
+	u32 hw_cap = readl(ioaddr + DMA_HW_FEATURE);
+
+	if (!hw_cap) {
+		/* 0x00000000 is the value read on old hardware that does not
+		 * implement this register
+		 */
+		return -EOPNOTSUPP;
+	}
+
+	dma_cap->mbps_10_100 = (hw_cap & DMA_HW_FEAT_MIISEL);
+	dma_cap->mbps_1000 = (hw_cap & DMA_HW_FEAT_GMIISEL) >> 1;
+	dma_cap->half_duplex = (hw_cap & DMA_HW_FEAT_HDSEL) >> 2;
+	dma_cap->hash_filter = (hw_cap & DMA_HW_FEAT_HASHSEL) >> 4;
+	dma_cap->multi_addr = (hw_cap & DMA_HW_FEAT_ADDMAC) >> 5;
+	dma_cap->pcs = (hw_cap & DMA_HW_FEAT_PCSSEL) >> 6;
+	dma_cap->sma_mdio = (hw_cap & DMA_HW_FEAT_SMASEL) >> 8;
+	dma_cap->pmt_remote_wake_up = (hw_cap & DMA_HW_FEAT_RWKSEL) >> 9;
+	dma_cap->pmt_magic_frame = (hw_cap & DMA_HW_FEAT_MGKSEL) >> 10;
+	/* MMC */
+	dma_cap->rmon = (hw_cap & DMA_HW_FEAT_MMCSEL) >> 11;
+	/* IEEE 1588-2002 */
+	dma_cap->time_stamp =
+	    (hw_cap & DMA_HW_FEAT_TSVER1SEL) >> 12;
+	/* IEEE 1588-2008 */
+	dma_cap->atime_stamp = (hw_cap & DMA_HW_FEAT_TSVER2SEL) >> 13;
+	/* 802.3az - Energy-Efficient Ethernet (EEE) */
+	dma_cap->eee = (hw_cap & DMA_HW_FEAT_EEESEL) >> 14;
+	dma_cap->av = (hw_cap & DMA_HW_FEAT_AVSEL) >> 15;
+	/* TX and RX csum */
+	dma_cap->tx_coe = 0;
+	dma_cap->rx_coe_type1 = (hw_cap & DMA_HW_FEAT_RXTYP1COE) >> 17;
+	dma_cap->rx_coe_type2 = (hw_cap & DMA_HW_FEAT_RXTYP2COE) >> 18;
+	dma_cap->rxfifo_over_2048 = (hw_cap & DMA_HW_FEAT_RXFIFOSIZE) >> 19;
+	/* TX and RX number of channels */
+	dma_cap->number_rx_channel = (hw_cap & DMA_HW_FEAT_RXCHCNT) >> 20;
+	dma_cap->number_tx_channel = (hw_cap & DMA_HW_FEAT_TXCHCNT) >> 22;
+	/* Alternate (enhanced) DESC mode */
+	dma_cap->enh_desc = (hw_cap & DMA_HW_FEAT_ENHDESSEL) >> 24;
+
+	return 0;
+}
+
 struct stmmac_pci_info {
 	int (*setup)(struct pci_dev *pdev, struct plat_stmmacenet_data *plat);
 	int (*config)(struct pci_dev *pdev, struct plat_stmmacenet_data *plat,
@@ -542,6 +587,7 @@ static int loongson_dwmac_probe(struct pci_dev *pdev,
 		ld->dwlgmac_dma_ops = dwmac1000_dma_ops;
 		ld->dwlgmac_dma_ops.init_chan = dwlgmac_dma_init_channel;
 		ld->dwlgmac_dma_ops.dma_interrupt = dwlgmac_dma_interrupt;
+		ld->dwlgmac_dma_ops.get_hw_feature = dwlgmac_get_hw_feature;
 
 		plat->setup = loongson_setup;
 		ret = loongson_dwmac_config_multi_msi(pdev, plat, &res, np, 8);
Signature · 1 line
2.31.4
#94 lore raw

Re: [PATCH net-next v8 11/11] net: stmmac: dwmac-loongson: Disable coe for some Loongson GNET

Quoted 1 line · Yanteng Si

Some chips of Loongson GNET does not support coe, so disable them.

s/coe/Tx COE

Quoted 15 lines

Set dma_cap->tx_coe to 0 and overwrite get_hw_feature.

---
 .../ethernet/stmicro/stmmac/dwmac-loongson.c  | 46 +++++++++++++++++++
 1 file changed, 46 insertions(+)
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +0 -0
index b78a73ea748b..8018d7d5f31b 100644

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c static int dwlgmac_dma_interrupt(struct stmmac_priv *priv, void __iomem *ioaddr, · line 200

Quoted 5 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +1 -0
@@ -196,6 +196,51 @@ static int dwlgmac_dma_interrupt(struct stmmac_priv *priv, void __iomem *ioaddr,
 	return ret;
 }
 
 
+static int dwlgmac_get_hw_feature(void __iomem *ioaddr,

Please use GNET-specific prefix.

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c static int dwlgmac_dma_interrupt(struct stmmac_priv *priv, void __iomem *ioaddr, · line 209

Quoted 11 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +10 -0
+				  struct dma_features *dma_cap)
+{
+	u32 hw_cap = readl(ioaddr + DMA_HW_FEATURE);
+
 
+	if (!hw_cap) {
+		/* 0x00000000 is the value read on old hardware that does not
+		 * implement this register
+		 */
+		return -EOPNOTSUPP;
+	}

This doesn't seems like possible. All your devices have the HW-features register. If so please drop.

Quoted 20 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +20 -0
+
+	dma_cap->mbps_10_100 = (hw_cap & DMA_HW_FEAT_MIISEL);
+	dma_cap->mbps_1000 = (hw_cap & DMA_HW_FEAT_GMIISEL) >> 1;
+	dma_cap->half_duplex = (hw_cap & DMA_HW_FEAT_HDSEL) >> 2;
+	dma_cap->hash_filter = (hw_cap & DMA_HW_FEAT_HASHSEL) >> 4;
+	dma_cap->multi_addr = (hw_cap & DMA_HW_FEAT_ADDMAC) >> 5;
+	dma_cap->pcs = (hw_cap & DMA_HW_FEAT_PCSSEL) >> 6;
+	dma_cap->sma_mdio = (hw_cap & DMA_HW_FEAT_SMASEL) >> 8;
+	dma_cap->pmt_remote_wake_up = (hw_cap & DMA_HW_FEAT_RWKSEL) >> 9;
+	dma_cap->pmt_magic_frame = (hw_cap & DMA_HW_FEAT_MGKSEL) >> 10;
+	/* MMC */
+	dma_cap->rmon = (hw_cap & DMA_HW_FEAT_MMCSEL) >> 11;
+	/* IEEE 1588-2002 */
+	dma_cap->time_stamp =
+	    (hw_cap & DMA_HW_FEAT_TSVER1SEL) >> 12;
+	/* IEEE 1588-2008 */
+	dma_cap->atime_stamp = (hw_cap & DMA_HW_FEAT_TSVER2SEL) >> 13;
+	/* 802.3az - Energy-Efficient Ethernet (EEE) */
+	dma_cap->eee = (hw_cap & DMA_HW_FEAT_EEESEL) >> 14;
+	dma_cap->av = (hw_cap & DMA_HW_FEAT_AVSEL) >> 15;

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c static int dwlgmac_dma_interrupt(struct stmmac_priv *priv, void __iomem *ioaddr, · line 239

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +10 -0
+	/* TX and RX csum */
+	dma_cap->tx_coe = 0;
+	dma_cap->rx_coe_type1 = (hw_cap & DMA_HW_FEAT_RXTYP1COE) >> 17;
+	dma_cap->rx_coe_type2 = (hw_cap & DMA_HW_FEAT_RXTYP2COE) >> 18;
+	dma_cap->rxfifo_over_2048 = (hw_cap & DMA_HW_FEAT_RXFIFOSIZE) >> 19;
+	/* TX and RX number of channels */
+	dma_cap->number_rx_channel = (hw_cap & DMA_HW_FEAT_RXCHCNT) >> 20;
+	dma_cap->number_tx_channel = (hw_cap & DMA_HW_FEAT_TXCHCNT) >> 22;
+	/* Alternate (enhanced) DESC mode */
+	dma_cap->enh_desc = (hw_cap & DMA_HW_FEAT_ENHDESSEL) >> 24;

I am not sure whether you need to parse the capability register at all seeing this is a GNET-specific method. For that device all the capabilities are already known and can be just initialized in this method.

-Serge(y)

Quoted 18 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +4 -0
+
+	return 0;
+}
+
 struct stmmac_pci_info {
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +1 -0
 	int (*setup)(struct pci_dev *pdev, struct plat_stmmacenet_data *plat);
 	int (*config)(struct pci_dev *pdev, struct plat_stmmacenet_data *plat,
@@ -542,6 +587,7 @@ static int loongson_dwmac_probe(struct pci_dev *pdev,
 		ld->dwlgmac_dma_ops = dwmac1000_dma_ops;
 		ld->dwlgmac_dma_ops.init_chan = dwlgmac_dma_init_channel;
 		ld->dwlgmac_dma_ops.dma_interrupt = dwlgmac_dma_interrupt;
+		ld->dwlgmac_dma_ops.get_hw_feature = dwlgmac_get_hw_feature;
 
 		plat->setup = loongson_setup;
 		ret = loongson_dwmac_config_multi_msi(pdev, plat, &res, np, 8);
Signature · 1 line
2.31.4
author
#95 lore raw

Re: [PATCH net-next v8 11/11] net: stmmac: dwmac-loongson: Disable coe for some Loongson GNET

Quoted 3 lines · Serge Semin
Quoted 1 line · Yanteng Si

Some chips of Loongson GNET does not support coe, so disable them.

s/coe/Tx COE

OK.

Quoted 18 lines
Quoted 18 lines

Set dma_cap->tx_coe to 0 and overwrite get_hw_feature.

---
  .../ethernet/stmicro/stmmac/dwmac-loongson.c  | 46 +++++++++++++++++++
  1 file changed, 46 insertions(+)
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +0 -0
index b78a73ea748b..8018d7d5f31b 100644
@@ -196,6 +196,51 @@ static int dwlgmac_dma_interrupt(struct stmmac_priv *priv, void __iomem *ioaddr,
  	return ret;
  }
 
Quoted 2 lines

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c static int dwlgmac_dma_interrupt(struct stmmac_priv *priv, void __iomem *ioaddr, · line 199

Quoted 1 line
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +1 -0
+static int dwlgmac_get_hw_feature(void __iomem *ioaddr,

Please use GNET-specific prefix.

OK. loongson_gnet_get_hw_feature()

Quoted 13 lines

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c static int dwlgmac_dma_interrupt(struct stmmac_priv *priv, void __iomem *ioaddr, · line 209

Quoted 11 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +10 -0
+				  struct dma_features *dma_cap)
+{
+	u32 hw_cap = readl(ioaddr + DMA_HW_FEATURE);
+
+	if (!hw_cap) {
+		/* 0x00000000 is the value read on old hardware that does not
+		 * implement this register
+		 */
+		return -EOPNOTSUPP;
+	}

This doesn't seems like possible. All your devices have the HW-features register. If so please drop.

OK, drop it.

Quoted 27 lines
Quoted 27 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +26 -0
+
+	dma_cap->mbps_10_100 = (hw_cap & DMA_HW_FEAT_MIISEL);
+	dma_cap->mbps_1000 = (hw_cap & DMA_HW_FEAT_GMIISEL) >> 1;
+	dma_cap->half_duplex = (hw_cap & DMA_HW_FEAT_HDSEL) >> 2;
+	dma_cap->hash_filter = (hw_cap & DMA_HW_FEAT_HASHSEL) >> 4;
+	dma_cap->multi_addr = (hw_cap & DMA_HW_FEAT_ADDMAC) >> 5;
+	dma_cap->pcs = (hw_cap & DMA_HW_FEAT_PCSSEL) >> 6;
+	dma_cap->sma_mdio = (hw_cap & DMA_HW_FEAT_SMASEL) >> 8;
+	dma_cap->pmt_remote_wake_up = (hw_cap & DMA_HW_FEAT_RWKSEL) >> 9;
+	dma_cap->pmt_magic_frame = (hw_cap & DMA_HW_FEAT_MGKSEL) >> 10;
+	/* MMC */
+	dma_cap->rmon = (hw_cap & DMA_HW_FEAT_MMCSEL) >> 11;
+	/* IEEE 1588-2002 */
+	dma_cap->time_stamp =
+	    (hw_cap & DMA_HW_FEAT_TSVER1SEL) >> 12;
+	/* IEEE 1588-2008 */
+	dma_cap->atime_stamp = (hw_cap & DMA_HW_FEAT_TSVER2SEL) >> 13;
+	/* 802.3az - Energy-Efficient Ethernet (EEE) */
+	dma_cap->eee = (hw_cap & DMA_HW_FEAT_EEESEL) >> 14;
+	dma_cap->av = (hw_cap & DMA_HW_FEAT_AVSEL) >> 15;
+	/* TX and RX csum */
+	dma_cap->tx_coe = 0;
+	dma_cap->rx_coe_type1 = (hw_cap & DMA_HW_FEAT_RXTYP1COE) >> 17;
+	dma_cap->rx_coe_type2 = (hw_cap & DMA_HW_FEAT_RXTYP2COE) >> 18;
+	dma_cap->rxfifo_over_2048 = (hw_cap & DMA_HW_FEAT_RXFIFOSIZE) >> 19;
+	/* TX and RX number of channels */
Quoted 8 lines

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c static int dwlgmac_dma_interrupt(struct stmmac_priv *priv, void __iomem *ioaddr, · line 239

Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +4 -0
+	dma_cap->number_rx_channel = (hw_cap & DMA_HW_FEAT_RXCHCNT) >> 20;
+	dma_cap->number_tx_channel = (hw_cap & DMA_HW_FEAT_TXCHCNT) >> 22;
+	/* Alternate (enhanced) DESC mode */
+	dma_cap->enh_desc = (hw_cap & DMA_HW_FEAT_ENHDESSEL) >> 24;

I am not sure whether you need to parse the capability register at all seeing this is a GNET-specific method. For that device all the capabilities are already known and can be just initialized in this method.

-dma_cap->tx_coe = (hw_cap & DMA_HW_FEAT_TXCOESEL) >> 16;

+dma_cap->tx_coe = 0;

I'm a little confused. Actually, I only modified this line, which is used to fix the checksum.

2k2000 of Loongson GNET does not support coe.

Thanks,
Yanteng

Quoted 21 lines

-Serge(y)

Quoted 18 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +5 -0
+
+	return 0;
+}
+
  struct stmmac_pci_info {
  	int (*setup)(struct pci_dev *pdev, struct plat_stmmacenet_data *plat);
  	int (*config)(struct pci_dev *pdev, struct plat_stmmacenet_data *plat,
@@ -542,6 +587,7 @@ static int loongson_dwmac_probe(struct pci_dev *pdev,
  		ld->dwlgmac_dma_ops = dwmac1000_dma_ops;
  		ld->dwlgmac_dma_ops.init_chan = dwlgmac_dma_init_channel;
  		ld->dwlgmac_dma_ops.dma_interrupt = dwlgmac_dma_interrupt;
+		ld->dwlgmac_dma_ops.get_hw_feature = dwlgmac_get_hw_feature;
 
  		plat->setup = loongson_setup;
  		ret = loongson_dwmac_config_multi_msi(pdev, plat, &res, np, 8);
Signature · 1 line
2.31.4
author
#96 lore raw

Re: [PATCH net-next v8 11/11] net: stmmac: dwmac-loongson: Disable coe for some Loongson GNET

Quoted 82 lines · Yanteng Si
Quoted 3 lines · Serge Semin
Quoted 1 line · Yanteng Si

Some chips of Loongson GNET does not support coe, so disable them.

s/coe/Tx COE

OK.

Quoted 11 lines
Quoted 11 lines

Set dma_cap->tx_coe to 0 and overwrite get_hw_feature.

---
  .../ethernet/stmicro/stmmac/dwmac-loongson.c  | 46
+++++++++++++++++++

  1 file changed, 46 insertions(+)
Quoted 10 lines

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c static int dwlgmac_dma_interrupt(struct · line 199

Quoted 9 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +0 -0
index b78a73ea748b..8018d7d5f31b 100644
@@ -196,6 +196,51 @@ static int dwlgmac_dma_interrupt(struct 
 stmmac_priv *priv, void __iomem *ioaddr,
       return ret;
   }
   +static int dwlgmac_get_hw_feature(void __iomem *ioaddr,

Please use GNET-specific prefix.

OK. loongson_gnet_get_hw_feature()

Quoted 13 lines

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c static int dwlgmac_dma_interrupt(struct stmmac_priv *priv, void __iomem *ioaddr, · line 209

Quoted 11 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +10 -0
+                  struct dma_features *dma_cap)
+{
+    u32 hw_cap = readl(ioaddr + DMA_HW_FEATURE);
+
+    if (!hw_cap) {
+        /* 0x00000000 is the value read on old hardware that does not
+         * implement this register
+         */
+        return -EOPNOTSUPP;
+    }

This doesn't seems like possible. All your devices have the HW-features register. If so please drop.

OK, drop it.

Quoted 36 lines
Quoted 22 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +21 -0
+
+    dma_cap->mbps_10_100 = (hw_cap & DMA_HW_FEAT_MIISEL);
+    dma_cap->mbps_1000 = (hw_cap & DMA_HW_FEAT_GMIISEL) >> 1;
+    dma_cap->half_duplex = (hw_cap & DMA_HW_FEAT_HDSEL) >> 2;
+    dma_cap->hash_filter = (hw_cap & DMA_HW_FEAT_HASHSEL) >> 4;
+    dma_cap->multi_addr = (hw_cap & DMA_HW_FEAT_ADDMAC) >> 5;
+    dma_cap->pcs = (hw_cap & DMA_HW_FEAT_PCSSEL) >> 6;
+    dma_cap->sma_mdio = (hw_cap & DMA_HW_FEAT_SMASEL) >> 8;
+    dma_cap->pmt_remote_wake_up = (hw_cap & DMA_HW_FEAT_RWKSEL) >> 9;
+    dma_cap->pmt_magic_frame = (hw_cap & DMA_HW_FEAT_MGKSEL) >> 10;
+    /* MMC */
+    dma_cap->rmon = (hw_cap & DMA_HW_FEAT_MMCSEL) >> 11;
+    /* IEEE 1588-2002 */
+    dma_cap->time_stamp =
+        (hw_cap & DMA_HW_FEAT_TSVER1SEL) >> 12;
+    /* IEEE 1588-2008 */
+    dma_cap->atime_stamp = (hw_cap & DMA_HW_FEAT_TSVER2SEL) >> 13;
+    /* 802.3az - Energy-Efficient Ethernet (EEE) */
+    dma_cap->eee = (hw_cap & DMA_HW_FEAT_EEESEL) >> 14;
+    dma_cap->av = (hw_cap & DMA_HW_FEAT_AVSEL) >> 15;
+    /* TX and RX csum */

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c static int dwlgmac_dma_interrupt(struct stmmac_priv *priv, void __iomem *ioaddr, · line 239

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +9 -0
+    dma_cap->tx_coe = 0;
+    dma_cap->rx_coe_type1 = (hw_cap & DMA_HW_FEAT_RXTYP1COE) >> 17;
+    dma_cap->rx_coe_type2 = (hw_cap & DMA_HW_FEAT_RXTYP2COE) >> 18;
+    dma_cap->rxfifo_over_2048 = (hw_cap & DMA_HW_FEAT_RXFIFOSIZE) 
 >> 19;
+    /* TX and RX number of channels */
+    dma_cap->number_rx_channel = (hw_cap & DMA_HW_FEAT_RXCHCNT) >> 20;
+    dma_cap->number_tx_channel = (hw_cap & DMA_HW_FEAT_TXCHCNT) >> 22;
+    /* Alternate (enhanced) DESC mode */
+    dma_cap->enh_desc = (hw_cap & DMA_HW_FEAT_ENHDESSEL) >> 24;

I am not sure whether you need to parse the capability register at all seeing this is a GNET-specific method. For that device all the capabilities are already known and can be just initialized in this method.

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +1 -1
-dma_cap->tx_coe = (hw_cap & DMA_HW_FEAT_TXCOESEL) >> 16;
 
+dma_cap->tx_coe = 0;
Quoted 3 lines

I'm a little confused. Actually, I only modified this line, which is used to fix the checksum.

2k2000  of Loongson GNET does not support coe.

Specifically, it is to ensure the normal operation of multiple channels, as other channels except for channel 0 cannot perform checksum.

Thanks,

Yanteng

Quoted 26 lines

Thanks,
Yanteng

Quoted 21 lines

-Serge(y)

Quoted 18 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +4 -0
+
+    return 0;
+}
+
   struct stmmac_pci_info {

      int (*setup)(struct pci_dev *pdev, struct plat_stmmacenet_data *plat); int (*config)(struct pci_dev *pdev, struct plat_stmmacenet_data *plat,

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +1 -0
@@ -542,6 +587,7 @@ static int loongson_dwmac_probe(struct pci_dev 
 *pdev,
           ld->dwlgmac_dma_ops = dwmac1000_dma_ops;
           ld->dwlgmac_dma_ops.init_chan = dwlgmac_dma_init_channel;
           ld->dwlgmac_dma_ops.dma_interrupt = dwlgmac_dma_interrupt;
+        ld->dwlgmac_dma_ops.get_hw_feature = dwlgmac_get_hw_feature;
             plat->setup = loongson_setup;
           ret = loongson_dwmac_config_multi_msi(pdev, plat, &res, np, 8);
Signature · 1 line
2.31.4
#97 lore raw

Re: [PATCH net-next v8 11/11] net: stmmac: dwmac-loongson: Disable coe for some Loongson GNET

Hi Yanteng

Quoted 86 lines · Yanteng Si
Quoted 84 lines · Yanteng Si
Quoted 3 lines · Serge Semin
Quoted 1 line · Yanteng Si

Some chips of Loongson GNET does not support coe, so disable them.

s/coe/Tx COE

OK.

Quoted 11 lines
Quoted 11 lines

Set dma_cap->tx_coe to 0 and overwrite get_hw_feature.

---
  .../ethernet/stmicro/stmmac/dwmac-loongson.c  | 46
+++++++++++++++++++

  1 file changed, 46 insertions(+)
Quoted 12 lines

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c static int dwlgmac_dma_interrupt(struct · line 199

Quoted 11 lines

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c index b78a73ea748b..8018d7d5f31b 100644

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +0 -0
@@ -196,6 +196,51 @@ static int dwlgmac_dma_interrupt(struct
 stmmac_priv *priv, void __iomem *ioaddr,
       return ret;
   }
   +static int dwlgmac_get_hw_feature(void __iomem *ioaddr,

Please use GNET-specific prefix.

OK. loongson_gnet_get_hw_feature()

Quoted 13 lines

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c static int dwlgmac_dma_interrupt(struct stmmac_priv *priv, void __iomem *ioaddr, · line 209

Quoted 11 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +10 -0
+                  struct dma_features *dma_cap)
+{
+    u32 hw_cap = readl(ioaddr + DMA_HW_FEATURE);
+
+    if (!hw_cap) {
+        /* 0x00000000 is the value read on old hardware that does not
+         * implement this register
+         */
+        return -EOPNOTSUPP;
+    }

This doesn't seems like possible. All your devices have the HW-features register. If so please drop.

OK, drop it.

Quoted 36 lines
Quoted 22 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +21 -0
+
+    dma_cap->mbps_10_100 = (hw_cap & DMA_HW_FEAT_MIISEL);
+    dma_cap->mbps_1000 = (hw_cap & DMA_HW_FEAT_GMIISEL) >> 1;
+    dma_cap->half_duplex = (hw_cap & DMA_HW_FEAT_HDSEL) >> 2;
+    dma_cap->hash_filter = (hw_cap & DMA_HW_FEAT_HASHSEL) >> 4;
+    dma_cap->multi_addr = (hw_cap & DMA_HW_FEAT_ADDMAC) >> 5;
+    dma_cap->pcs = (hw_cap & DMA_HW_FEAT_PCSSEL) >> 6;
+    dma_cap->sma_mdio = (hw_cap & DMA_HW_FEAT_SMASEL) >> 8;
+    dma_cap->pmt_remote_wake_up = (hw_cap & DMA_HW_FEAT_RWKSEL) >> 9;
+    dma_cap->pmt_magic_frame = (hw_cap & DMA_HW_FEAT_MGKSEL) >> 10;
+    /* MMC */
+    dma_cap->rmon = (hw_cap & DMA_HW_FEAT_MMCSEL) >> 11;
+    /* IEEE 1588-2002 */
+    dma_cap->time_stamp =
+        (hw_cap & DMA_HW_FEAT_TSVER1SEL) >> 12;
+    /* IEEE 1588-2008 */
+    dma_cap->atime_stamp = (hw_cap & DMA_HW_FEAT_TSVER2SEL) >> 13;
+    /* 802.3az - Energy-Efficient Ethernet (EEE) */
+    dma_cap->eee = (hw_cap & DMA_HW_FEAT_EEESEL) >> 14;
+    dma_cap->av = (hw_cap & DMA_HW_FEAT_AVSEL) >> 15;
+    /* TX and RX csum */

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c static int dwlgmac_dma_interrupt(struct stmmac_priv *priv, void __iomem *ioaddr, · line 239

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +9 -0
+    dma_cap->tx_coe = 0;
+    dma_cap->rx_coe_type1 = (hw_cap & DMA_HW_FEAT_RXTYP1COE) >> 17;
+    dma_cap->rx_coe_type2 = (hw_cap & DMA_HW_FEAT_RXTYP2COE) >> 18;
+    dma_cap->rxfifo_over_2048 = (hw_cap &
 DMA_HW_FEAT_RXFIFOSIZE) >> 19;
+    /* TX and RX number of channels */
+    dma_cap->number_rx_channel = (hw_cap & DMA_HW_FEAT_RXCHCNT) >> 20;
+    dma_cap->number_tx_channel = (hw_cap & DMA_HW_FEAT_TXCHCNT) >> 22;
+    /* Alternate (enhanced) DESC mode */
+    dma_cap->enh_desc = (hw_cap & DMA_HW_FEAT_ENHDESSEL) >> 24;

I am not sure whether you need to parse the capability register at all seeing this is a GNET-specific method. For that device all the capabilities are already known and can be just initialized in this method.

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +1 -1
-dma_cap->tx_coe = (hw_cap & DMA_HW_FEAT_TXCOESEL) >> 16;
 
+dma_cap->tx_coe = 0;
Quoted 7 lines
Quoted 4 lines

I'm a little confused. Actually, I only modified this line, which is used to fix the checksum.

2k2000  of Loongson GNET does not support coe.

Specifically, it is to ensure the normal operation of multiple channels, as other channels except for channel 0 cannot perform checksum.

Originally I thought that Tx-COE was fully broken, but seeing it works for channel 0 changes the situation. While we kept discussing your series a useful patch was merged into the driver:
https://lore.kernel.org/netdev/[email protected]/
The stmmac_txq_cfg::coe_unsupported flag can be used to disable Tx COE for the particular channels. You can just set the coe_unsupported flag for the channels greater than zero and the skb_checksum_help() helper will be utilized for them to calculate the packets control sum. This will be the most optimal solution since channel zero will still be serviced by the Tx Checksum Offload Engine and you won't need the stmmac_dma_ops::get_hw_feature() callback redefinition.

-Serge(y)

Quoted 36 lines

Thanks,

Yanteng

Quoted 29 lines

Thanks,
Yanteng

Quoted 24 lines

-Serge(y)

Quoted 21 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +4 -0
+
+    return 0;
+}
+
   struct stmmac_pci_info {

      int (*setup)(struct pci_dev *pdev, struct
plat_stmmacenet_data *plat);
      int (*config)(struct pci_dev *pdev, struct
plat_stmmacenet_data *plat,

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +1 -0
@@ -542,6 +587,7 @@ static int loongson_dwmac_probe(struct
 pci_dev *pdev,
           ld->dwlgmac_dma_ops = dwmac1000_dma_ops;
           ld->dwlgmac_dma_ops.init_chan = dwlgmac_dma_init_channel;
           ld->dwlgmac_dma_ops.dma_interrupt = dwlgmac_dma_interrupt;
+        ld->dwlgmac_dma_ops.get_hw_feature = dwlgmac_get_hw_feature;
             plat->setup = loongson_setup;
           ret = loongson_dwmac_config_multi_msi(pdev, plat,

&res, np, 8);

Signature · 1 line
2.31.4
#98 lore raw
In reply to Yanteng Si

Hi Yanteng

Quoted 37 lines · Yanteng Si

v8:
* The biggest change is according to Serge's comment in the previous edition:
Seeing the patch in the current state would overcomplicate the generic code and the only functions you need to update are dwmac_dma_interrupt()
dwmac1000_dma_init_channel()
you can have these methods re-defined with all the Loongson GNET specifics in the low-level platform driver (dwmac-loongson.c). After that you can just override the mac_device_info.dma pointer with a fixed stmmac_dma_ops descriptor. Here is what should be done for that:

1. Keep the Patch 4/9 with my comments fixed. First it will be partly useful for your GNET device. Second in general it's a correct implementation of the normal DW GMAC v3.x multi-channels feature and will be useful for the DW GMACs with that feature enabled.

2. Create the Loongson GNET-specific stmmac_dma_ops.dma_interrupt()
stmmac_dma_ops.init_chan()
methods in the dwmac-loongson.c driver. Don't forget to move all the Loongson-specific macros from dwmac_dma.h to dwmac-loongson.c.

3. Create a Loongson GNET-specific platform setup method with the next semantics:
+ allocate stmmac_dma_ops instance and initialize it with dwmac1000_dma_ops.
+ override the stmmac_dma_ops.{dma_interrupt, init_chan} with the pointers to the methods defined in 2.
+ allocate mac_device_info instance and initialize the mac_device_info.dma field with a pointer to the new stmmac_dma_ops instance.
+ call dwmac1000_setup() or initialize mac_device_info in a way it's done in dwmac1000_setup() (the later might be better so you wouldn't need to export the dwmac1000_setup() function).
+ override stmmac_priv.synopsys_id with a correct value.

Quoted 6 lines

4. Initialize plat_stmmacenet_data.setup() with the pointer to the method created in 3.

* Others:
Re-split the patch.
Passed checkpatch.pl test.

Thanks for the updated series. I'll have a look at it later on this week or early on the next one.

-Serge(y)

Quoted 85 lines

v7:
* Refer to andrew's suggestion:
- Add DMA_INTR_ENA_NIE_RX and DMA_INTR_ENA_NIE_TX #define's, etc.

* Others:
- Using --subject-prefix="PATCH net-next vN" to indicate that the patches are for the networking tree.
- Rebase to the latest networking tree:
<git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git>

v6:

* Refer to Serge's suggestion:
- Add new platform feature flag:

    include/linux/stmmac.h:
    +#define STMMAC_FLAG_HAS_LGMAC			BIT(13)

- Add the IRQs macros specific to the Loongson Multi-channels GMAC:

     drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h:
     +#define DMA_INTR_ENA_NIE_LOONGSON 0x00060000      /* ...*/
     #define DMA_INTR_ENA_NIE 0x00010000	/* Normal Summary */
     ...

- Drop all of redundant changes that don't require the prototypes being converted to accepting the stmmac_priv pointer.

* Refer to andrew's suggestion:
- Drop white space changes.
- break patch up into lots of smaller parts.
Some small patches have been put into another series as a preparation see <https://lore.kernel.org/loongarch/[email protected]/T/#t>

*note* : This series of patches relies on the three small patches above.
* others
- Drop irq_flags changes.
- Changed patch order.

v4 -> v5:

* Remove an ugly and useless patch (fix channel number).
* Remove the non-standard dma64 driver code, and also remove the HWIF entries, since the associated custom callbacks no longer exist.
* Refer to Serge's suggestion: Update the dwmac1000_dma.c to support the multi-DMA-channels controller setup.

See:
v4: <https://lore.kernel.org/loongarch/[email protected]/>
v3: <https://lore.kernel.org/loongarch/[email protected]/>
v2: <https://lore.kernel.org/loongarch/[email protected]/>
v1: <https://lore.kernel.org/loongarch/[email protected]/>

Yanteng Si (11):
net: stmmac: Add multi-channel support
net: stmmac: dwmac-loongson: Refactor code for loongson_dwmac_probe()
net: stmmac: dwmac-loongson: Add full PCI support
net: stmmac: dwmac-loongson: Move irq config to loongson_gmac_config
net: stmmac: dwmac-loongson: Add Loongson-specific register
definitions
net: stmmac: dwmac-loongson: Add GNET support
net: stmmac: dwmac-loongson: Add multi-channel supports for loongson
net: stmmac: dwmac-loongson: Fix MAC speed for GNET
net: stmmac: dwmac-loongson: Fix half duplex
net: stmmac: dwmac-loongson: Disable flow control for GMAC
net: stmmac: dwmac-loongson: Disable coe for some Loongson GNET

 .../ethernet/stmicro/stmmac/dwmac-loongson.c  | 561 ++++++++++++++++--
 .../net/ethernet/stmicro/stmmac/dwmac-sun8i.c |   2 +-
 .../ethernet/stmicro/stmmac/dwmac1000_dma.c   |  36 +-
 .../net/ethernet/stmicro/stmmac/dwmac_dma.h   |  19 +-
 .../net/ethernet/stmicro/stmmac/dwmac_lib.c   |  32 +-
 drivers/net/ethernet/stmicro/stmmac/hwif.h    |   2 +-
 .../ethernet/stmicro/stmmac/stmmac_ethtool.c  |   6 +
 .../net/ethernet/stmicro/stmmac/stmmac_main.c |  15 +-
 include/linux/stmmac.h                        |   3 +
 9 files changed, 582 insertions(+), 94 deletions(-)
Signature · 1 line
2.31.4
maintainer
#99 lore raw
In reply to Yanteng Si
Quoted 2 lines · On Tue, 30 Jan 2024 16:43:20 +0800 Yanteng Si wrote:

* The biggest change is according to Serge's comment in the previous edition:

Looks like there's a trivial build issue here:

ERROR: modpost: "dwmac1000_dma_ops" [drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.ko] undefined!

Please wait for Serge's review before posting v9.

Signature · 1 line
pw-bot: cr
author
#100 lore raw
Quoted 9 lines · Jakub Kicinski
Quoted 2 lines · On Tue, 30 Jan 2024 16:43:20 +0800 Yanteng Si wrote:

* The biggest change is according to Serge's comment in the previous edition:

Looks like there's a trivial build issue here:

ERROR: modpost: "dwmac1000_dma_ops" [drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.ko] undefined!

Please wait for Serge's review before posting v9.

OK!  Will fix with:

drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c +0 -0
index 5f7b82ad3ec2..0323f0a5049c 100644
@@ -296,3 +296,4 @@ const struct stmmac_dma_ops dwmac1000_dma_ops = {

        .get_hw_feature = dwmac1000_get_hw_feature, .rx_watchdog = dwmac1000_rx_watchdog, };
+EXPORT_SYMBOL_GPL(dwmac1000_dma_ops);

Thanks,

Yanteng