Skip to contentSkip to conversation

net: phy/stmmac: Add Loongson platform support

RFC PATCH Superseded Feiyang Chen 4 participants 38 messages Jul 13, 2023 – Jul 25, 2023

Subsystems (7)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover net: phy/stmmac: Add Loongson platform support

Add driver for Loongson PHY. Extend stmmac functions and macros for Loongson DWMAC. Add LS7A support for dwmac_loongson.

Feiyang Chen (10):
net: phy: Add driver for Loongson PHY
net: stmmac: Pass stmmac_priv and chan in some callbacks
net: stmmac: dwmac1000: Allow platforms to choose some register
offsets
net: stmmac: dwmac1000: Add multi-channel support
net: stmmac: dwmac1000: Add 64-bit DMA support
net: stmmac: dwmac1000: Add Loongson register definitions
net: stmmac: Add Loongson HWIF entry
net: stmmac: dwmac-loongson: Add LS7A support
net: stmmac: dwmac-loongson: Add 64-bit DMA and multi-vector support
net: stmmac: dwmac-loongson: Add GNET support

 drivers/net/ethernet/stmicro/stmmac/Kconfig   |   1 +
 .../net/ethernet/stmicro/stmmac/chain_mode.c  |  28 ++-
 drivers/net/ethernet/stmicro/stmmac/common.h  |   3 +
 drivers/net/ethernet/stmicro/stmmac/descs.h   |   7 +
 .../net/ethernet/stmicro/stmmac/descs_com.h   |  49 ++--
 .../ethernet/stmicro/stmmac/dwmac-loongson.c  | 214 +++++++++++++-----
 .../net/ethernet/stmicro/stmmac/dwmac-sun8i.c |  20 +-
 .../net/ethernet/stmicro/stmmac/dwmac1000.h   |   4 +-
 .../ethernet/stmicro/stmmac/dwmac1000_core.c  |  63 ++++--
 .../ethernet/stmicro/stmmac/dwmac1000_dma.c   | 110 +++++++--
 .../ethernet/stmicro/stmmac/dwmac100_core.c   |  12 +-
 .../ethernet/stmicro/stmmac/dwmac100_dma.c    |   2 +-
 .../net/ethernet/stmicro/stmmac/dwmac4_core.c |  11 +-
 .../ethernet/stmicro/stmmac/dwmac4_descs.c    |  19 +-
 .../net/ethernet/stmicro/stmmac/dwmac4_dma.c  |   8 +-
 .../net/ethernet/stmicro/stmmac/dwmac_dma.h   | 210 +++++++++--------
 .../net/ethernet/stmicro/stmmac/dwmac_lib.c   | 156 +++++++++++--
 .../ethernet/stmicro/stmmac/dwxgmac2_core.c   |  11 +-
 .../ethernet/stmicro/stmmac/dwxgmac2_descs.c  |  17 +-
 .../ethernet/stmicro/stmmac/dwxgmac2_dma.c    |   8 +-
 .../net/ethernet/stmicro/stmmac/enh_desc.c    |  38 ++--
 drivers/net/ethernet/stmicro/stmmac/hwif.c    |  48 +++-
 drivers/net/ethernet/stmicro/stmmac/hwif.h    |  77 ++++---
 .../net/ethernet/stmicro/stmmac/norm_desc.c   |  17 +-
 .../net/ethernet/stmicro/stmmac/ring_mode.c   | 105 +++++++--
 .../net/ethernet/stmicro/stmmac/stmmac_main.c |  31 ++-
 drivers/net/phy/Kconfig                       |   5 +
 drivers/net/phy/Makefile                      |   1 +
 drivers/net/phy/loongson-phy.c                |  69 ++++++
 drivers/net/phy/phy_device.c                  |  16 ++
 include/linux/phy.h                           |   2 +
 include/linux/stmmac.h                        |  51 +++++
 32 files changed, 1054 insertions(+), 359 deletions(-)
 create mode 100644 drivers/net/phy/loongson-phy.c
Signature · 1 line
2.39.3
#1 lore raw

RFC PATCH 1/10 net: phy: Add driver for Loongson PHY

Add support for the Loongson PHY.

---
 drivers/net/phy/Kconfig        |  5 +++
 drivers/net/phy/Makefile       |  1 +
 drivers/net/phy/loongson-phy.c | 69 ++++++++++++++++++++++++++++++++++
 drivers/net/phy/phy_device.c   | 16 ++++++++
 include/linux/phy.h            |  2 +
 5 files changed, 93 insertions(+)
 create mode 100644 drivers/net/phy/loongson-phy.c
drivers/net/phy/Kconfig +5 -0
index 93b8efc79227..4f8ea32cbc68 100644
@@ -202,6 +202,11 @@ config INTEL_XWAY_PHY
 	  PEF 7061, PEF 7071 and PEF 7072 or integrated into the Intel
 	  SoCs xRX200, xRX300, xRX330, xRX350 and xRX550.
 
+config LOONGSON_PHY
+	tristate "Loongson PHY driver"
+	help
+	  Supports the Loongson PHY.
+
 config LSI_ET1011C_PHY
 	tristate "LSI ET1011C PHY"
 	help
drivers/net/phy/Makefile +1 -0
index f289ab16a1da..f775373e12b7 100644
@@ -62,6 +62,7 @@ obj-$(CONFIG_DP83TD510_PHY)	+= dp83td510.o
 obj-$(CONFIG_FIXED_PHY)		+= fixed_phy.o
 obj-$(CONFIG_ICPLUS_PHY)	+= icplus.o
 obj-$(CONFIG_INTEL_XWAY_PHY)	+= intel-xway.o
+obj-$(CONFIG_LOONGSON_PHY)	+= loongson-phy.o
 obj-$(CONFIG_LSI_ET1011C_PHY)	+= et1011c.o
 obj-$(CONFIG_LXT_PHY)		+= lxt.o
 obj-$(CONFIG_MARVELL_10G_PHY)	+= marvell10g.o
drivers/net/phy/loongson-phy.c new file +69 -0

69 lines not on this page · raw message

drivers/net/phy/phy_device.c +16 -0
index 53598210be6c..00568608118a 100644
@@ -146,6 +146,15 @@ static const int phy_eee_cap1_features_array[] = {
 __ETHTOOL_DECLARE_LINK_MODE_MASK(phy_eee_cap1_features) __ro_after_init;
 EXPORT_SYMBOL_GPL(phy_eee_cap1_features);
 
+static const int phy_10_100_1000_full_features_array[] = {
+	ETHTOOL_LINK_MODE_10baseT_Full_BIT,
+	ETHTOOL_LINK_MODE_100baseT_Full_BIT,
+	ETHTOOL_LINK_MODE_1000baseT_Full_BIT,
+};
+
+__ETHTOOL_DECLARE_LINK_MODE_MASK(phy_loongson_features) __ro_after_init;
+EXPORT_SYMBOL_GPL(phy_loongson_features);
+
 static void features_init(void)
 {
 	/* 10/100 half/full*/
@@ -230,6 +239,13 @@ static void features_init(void)
 	linkmode_set_bit_array(phy_eee_cap1_features_array,
 			       ARRAY_SIZE(phy_eee_cap1_features_array),
 			       phy_eee_cap1_features);
+	/* 10/100/1000 full */
+	linkmode_set_bit_array(phy_basic_ports_array,
+			       ARRAY_SIZE(phy_basic_ports_array),
+			       phy_loongson_features);
+	linkmode_set_bit_array(phy_10_100_1000_full_features_array,
+			       ARRAY_SIZE(phy_10_100_1000_full_features_array),
+			       phy_loongson_features);
 
 }
 
include/linux/phy.h +2 -0
index 6478838405a0..6bdb2a479755 100644
@@ -54,6 +54,7 @@ extern __ETHTOOL_DECLARE_LINK_MODE_MASK(phy_10gbit_features) __ro_after_init;
 extern __ETHTOOL_DECLARE_LINK_MODE_MASK(phy_10gbit_fec_features) __ro_after_init;
 extern __ETHTOOL_DECLARE_LINK_MODE_MASK(phy_10gbit_full_features) __ro_after_init;
 extern __ETHTOOL_DECLARE_LINK_MODE_MASK(phy_eee_cap1_features) __ro_after_init;
+extern __ETHTOOL_DECLARE_LINK_MODE_MASK(phy_loongson_features) __ro_after_init;
 
 #define PHY_BASIC_FEATURES ((unsigned long *)&phy_basic_features)
 #define PHY_BASIC_T1_FEATURES ((unsigned long *)&phy_basic_t1_features)
@@ -65,6 +66,7 @@ extern __ETHTOOL_DECLARE_LINK_MODE_MASK(phy_eee_cap1_features) __ro_after_init;
 #define PHY_10GBIT_FEC_FEATURES ((unsigned long *)&phy_10gbit_fec_features)
 #define PHY_10GBIT_FULL_FEATURES ((unsigned long *)&phy_10gbit_full_features)
 #define PHY_EEE_CAP1_FEATURES ((unsigned long *)&phy_eee_cap1_features)
+#define PHY_LOONGSON_FEATURES ((unsigned long *)&phy_loongson_features)
 
 extern const int phy_basic_ports_array[3];
 extern const int phy_fibre_port_array[1];
Signature · 1 line
2.39.3
maintainer
#2 lore raw

Re: [RFC PATCH 01/10] net: phy: Add driver for Loongson PHY

Quoted 7 lines · Feiyang Chen

Add support for the Loongson PHY.

---
 drivers/net/phy/Kconfig        |  5 +++
 drivers/net/phy/Makefile       |  1 +
 drivers/net/phy/loongson-phy.c | 69 ++++++++++++++++++++++++++++++++++

Please drop -phy from the filename. No other phy driver does this.

Quoted 45 lines
 drivers/net/phy/phy_device.c   | 16 ++++++++
 include/linux/phy.h            |  2 +
 5 files changed, 93 insertions(+)
 create mode 100644 drivers/net/phy/loongson-phy.c
drivers/net/phy/Kconfig +5 -0
index 93b8efc79227..4f8ea32cbc68 100644
@@ -202,6 +202,11 @@ config INTEL_XWAY_PHY
 	  PEF 7061, PEF 7071 and PEF 7072 or integrated into the Intel
 	  SoCs xRX200, xRX300, xRX330, xRX350 and xRX550.
 
+config LOONGSON_PHY
+	tristate "Loongson PHY driver"
+	help
+	  Supports the Loongson PHY.
+
 config LSI_ET1011C_PHY
 	tristate "LSI ET1011C PHY"
 	help
drivers/net/phy/Makefile +1 -0
index f289ab16a1da..f775373e12b7 100644
@@ -62,6 +62,7 @@ obj-$(CONFIG_DP83TD510_PHY)	+= dp83td510.o
 obj-$(CONFIG_FIXED_PHY)		+= fixed_phy.o
 obj-$(CONFIG_ICPLUS_PHY)	+= icplus.o
 obj-$(CONFIG_INTEL_XWAY_PHY)	+= intel-xway.o
+obj-$(CONFIG_LOONGSON_PHY)	+= loongson-phy.o
 obj-$(CONFIG_LSI_ET1011C_PHY)	+= et1011c.o
 obj-$(CONFIG_LXT_PHY)		+= lxt.o
 obj-$(CONFIG_MARVELL_10G_PHY)	+= marvell10g.o
drivers/net/phy/loongson-phy.c new file +6 -0
new file mode 100644
index 000000000000..d4aefa2110f8
@@ -0,0 +1,69 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * LS7A PHY driver
+ *
+ * Copyright (C) 2020-2023 Loongson Technology Corporation Limited
+ *

drivers/net/phy/loongson-phy.c line 16

Quoted 10 lines
drivers/net/phy/loongson-phy.c new file +10 -0
+ * Author: Zhang Baoqi <[email protected]>
+ */
+
+#include <linux/mii.h>
+#include <linux/module.h>
+#include <linux/netdevice.h>
+#include <linux/pci.h>
+#include <linux/phy.h>
+
+#define PHY_ID_LS7A2000		0x00061ce0

What is Loongson OUI?

drivers/net/phy/loongson-phy.c line 22

Quoted 6 lines
drivers/net/phy/loongson-phy.c new file +6 -0
+#define GNET_REV_LS7A2000	0x00
+
+static int ls7a2000_config_aneg(struct phy_device *phydev)
+{
+	if (phydev->speed == SPEED_1000)
+		phydev->autoneg = AUTONEG_ENABLE;

Please explain.

drivers/net/phy/loongson-phy.c line 32

Quoted 10 lines
drivers/net/phy/loongson-phy.c new file +10 -0
+
+	if (linkmode_test_bit(ETHTOOL_LINK_MODE_10baseT_Full_BIT,
+	    phydev->advertising) ||
+	    linkmode_test_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT,
+	    phydev->advertising) ||
+	    linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT,
+	    phydev->advertising))
+	    return genphy_config_aneg(phydev);
+
+	netdev_info(phydev->attached_dev, "Parameter Setting Error\n");

This also needs explaining. How can it be asked to do something it does not support?

drivers/net/phy/loongson-phy.c line 33

Quoted 1 line
drivers/net/phy/loongson-phy.c new file +1 -0
+	return -1;

Always use error codes. In this case EINVAL.

Quoted 4 lines
drivers/net/phy/loongson-phy.c new file +4 -0
+}
+
+int ls7a2000_match_phy_device(struct phy_device *phydev)
+{

drivers/net/phy/loongson-phy.c line 47

Quoted 10 lines
drivers/net/phy/loongson-phy.c new file +10 -0
+	struct net_device *ndev;
+	struct pci_dev *pdev;
+
+	if ((phydev->phy_id & 0xfffffff0) != PHY_ID_LS7A2000)
+		return 0;
+
+	ndev = phydev->mdio.bus->priv;
+	pdev = to_pci_dev(ndev->dev.parent);
+
+	return pdev->revision == GNET_REV_LS7A2000;

That is very unusual. Why is the PHY ID not sufficient?

drivers/net/phy/loongson-phy.c line 54

Quoted 7 lines
drivers/net/phy/loongson-phy.c new file +7 -0
+}
+
+static struct phy_driver loongson_phy_driver[] = {
+	{
+		PHY_ID_MATCH_MODEL(PHY_ID_LS7A2000),
+		.name			= "LS7A2000 PHY",
+		.features		= PHY_LOONGSON_FEATURES,

So what are the capabilities of this PHY? You seem to have some very odd hacks here, and no explanation of why they are needed. If you do something which no other device does, you need to explain it.

Does the PHY itself only support full duplex? No half duplex? Does the PHY support autoneg? Does it support fixed settings? What does genphy_read_abilities() return for this PHY?

Andrew

#3 lore raw

Re: [RFC PATCH 01/10] net: phy: Add driver for Loongson PHY

Quoted 4 lines · Andrew Lunn
Quoted 2 lines · Feiyang Chen

Add support for the Loongson PHY.

Quoted 8 lines
Quoted 5 lines
---
 drivers/net/phy/Kconfig        |  5 +++
 drivers/net/phy/Makefile       |  1 +
 drivers/net/phy/loongson-phy.c | 69 ++++++++++++++++++++++++++++++++++

Please drop -phy from the filename. No other phy driver does this.

Hi, Andrew,

OK.

Quoted 49 lines
Quoted 49 lines
 drivers/net/phy/phy_device.c   | 16 ++++++++
 include/linux/phy.h            |  2 +
 5 files changed, 93 insertions(+)
 create mode 100644 drivers/net/phy/loongson-phy.c
drivers/net/phy/Kconfig +5 -0
index 93b8efc79227..4f8ea32cbc68 100644
@@ -202,6 +202,11 @@ config INTEL_XWAY_PHY
        PEF 7061, PEF 7071 and PEF 7072 or integrated into the Intel
        SoCs xRX200, xRX300, xRX330, xRX350 and xRX550.
 
+config LOONGSON_PHY
+     tristate "Loongson PHY driver"
+     help
+       Supports the Loongson PHY.
+
 config LSI_ET1011C_PHY
      tristate "LSI ET1011C PHY"
      help
drivers/net/phy/Makefile +1 -0
index f289ab16a1da..f775373e12b7 100644
@@ -62,6 +62,7 @@ obj-$(CONFIG_DP83TD510_PHY) += dp83td510.o
 obj-$(CONFIG_FIXED_PHY)              += fixed_phy.o
 obj-$(CONFIG_ICPLUS_PHY)     += icplus.o
 obj-$(CONFIG_INTEL_XWAY_PHY) += intel-xway.o
+obj-$(CONFIG_LOONGSON_PHY)   += loongson-phy.o
 obj-$(CONFIG_LSI_ET1011C_PHY)        += et1011c.o
 obj-$(CONFIG_LXT_PHY)                += lxt.o
 obj-$(CONFIG_MARVELL_10G_PHY)        += marvell10g.o
drivers/net/phy/loongson-phy.c new file +10 -0
new file mode 100644
index 000000000000..d4aefa2110f8
@@ -0,0 +1,69 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * LS7A PHY driver
+ *
+ * Copyright (C) 2020-2023 Loongson Technology Corporation Limited
+ *
+ * Author: Zhang Baoqi <[email protected]>
+ */
+
+#include <linux/mii.h>
Quoted 9 lines

drivers/net/phy/loongson-phy.c line 16

Quoted 6 lines
drivers/net/phy/loongson-phy.c new file +6 -0
+#include <linux/module.h>
+#include <linux/netdevice.h>
+#include <linux/pci.h>
+#include <linux/phy.h>
+
+#define PHY_ID_LS7A2000              0x00061ce0

What is Loongson OUI?

Currently, we do not have an OUI for Loongson, but we are in the process of applying for one.

Quoted 9 lines

drivers/net/phy/loongson-phy.c line 22

Quoted 6 lines
drivers/net/phy/loongson-phy.c new file +6 -0
+#define GNET_REV_LS7A2000    0x00
+
+static int ls7a2000_config_aneg(struct phy_device *phydev)
+{
+     if (phydev->speed == SPEED_1000)
+             phydev->autoneg = AUTONEG_ENABLE;

Please explain.

The PHY itself supports half-duplex, but there are issues with the controller used in the 7A2000 chip. Moreover, the controller only supports auto-negotiation for gigabit speeds.

Quoted 5 lines
Quoted 5 lines
drivers/net/phy/loongson-phy.c new file +5 -0
+
+     if (linkmode_test_bit(ETHTOOL_LINK_MODE_10baseT_Full_BIT,
+         phydev->advertising) ||
+         linkmode_test_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT,
+         phydev->advertising) ||
Quoted 9 lines

drivers/net/phy/loongson-phy.c line 32

Quoted 5 lines
drivers/net/phy/loongson-phy.c new file +5 -0
+         linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT,
+         phydev->advertising))
+         return genphy_config_aneg(phydev);
+
+     netdev_info(phydev->attached_dev, "Parameter Setting Error\n");

This also needs explaining. How can it be asked to do something it does not support?

Perhaps I missed something, but I think that if someone uses ethtool, they can request it to perform actions or configurations that the tool does not support.

Quoted 4 lines

drivers/net/phy/loongson-phy.c line 33

Quoted 1 line
drivers/net/phy/loongson-phy.c new file +1 -0
+     return -1;

Always use error codes. In this case EINVAL.

OK.

Quoted 8 lines
Quoted 8 lines
drivers/net/phy/loongson-phy.c new file +8 -0
+}
+
+int ls7a2000_match_phy_device(struct phy_device *phydev)
+{
+     struct net_device *ndev;
+     struct pci_dev *pdev;
+
+     if ((phydev->phy_id & 0xfffffff0) != PHY_ID_LS7A2000)
Quoted 9 lines

drivers/net/phy/loongson-phy.c line 47

Quoted 6 lines
drivers/net/phy/loongson-phy.c new file +6 -0
+             return 0;
+
+     ndev = phydev->mdio.bus->priv;
+     pdev = to_pci_dev(ndev->dev.parent);
+
+     return pdev->revision == GNET_REV_LS7A2000;

That is very unusual. Why is the PHY ID not sufficient?

To work around the controller's issues, we enable the usage of this driver specifically for a certain version of the 7A2000 chip.

Quoted 12 lines

drivers/net/phy/loongson-phy.c line 54

Quoted 7 lines
drivers/net/phy/loongson-phy.c new file +7 -0
+}
+
+static struct phy_driver loongson_phy_driver[] = {
+     {
+             PHY_ID_MATCH_MODEL(PHY_ID_LS7A2000),
+             .name                   = "LS7A2000 PHY",
+             .features               = PHY_LOONGSON_FEATURES,

So what are the capabilities of this PHY? You seem to have some very odd hacks here, and no explanation of why they are needed. If you do something which no other device does, you need to explain it.

Quoted 4 lines

Does the PHY itself only support full duplex? No half duplex? Does the PHY support autoneg? Does it support fixed settings? What does genphy_read_abilities() return for this PHY?

As mentioned earlier, this driver is specifically designed for the PHY on the problematic 7A2000 chip. Therefore, we assume that this PHY only supports full- duplex mode and performs auto-negotiation exclusively for gigabit speeds.

Thanks,
Feiyang

Quoted 1 line

Andrew

maintainer
#4 lore raw

Re: [RFC PATCH 01/10] net: phy: Add driver for Loongson PHY

Quoted 11 lines
Quoted 10 lines

drivers/net/phy/loongson-phy.c line 16

Quoted 7 lines
drivers/net/phy/loongson-phy.c new file +7 -0
+#include <linux/mii.h>
+#include <linux/module.h>
+#include <linux/netdevice.h>
+#include <linux/pci.h>
+#include <linux/phy.h>
+
+#define PHY_ID_LS7A2000              0x00061ce0

What is Loongson OUI?

Quoted 2 lines

Currently, we do not have an OUI for Loongson, but we are in the process of applying for one.

Is the value 0x00061ce0 baked into the silicon? Or can it be changed once you have an OUI?

Quoted 10 lines
Quoted 9 lines

drivers/net/phy/loongson-phy.c line 22

Quoted 6 lines
drivers/net/phy/loongson-phy.c new file +6 -0
+#define GNET_REV_LS7A2000    0x00
+
+static int ls7a2000_config_aneg(struct phy_device *phydev)
+{
+     if (phydev->speed == SPEED_1000)
+             phydev->autoneg = AUTONEG_ENABLE;

Please explain.

Quoted 3 lines

The PHY itself supports half-duplex, but there are issues with the controller used in the 7A2000 chip. Moreover, the controller only supports auto-negotiation for gigabit speeds.

So you can force 10/100/1000, but auto neg only succeeds for 1G?

Are the LP autoneg values available for genphy_read_lpa() to read? If the LP values are available, maybe the PHY driver can resolve the autoneg for 10 an 100.

Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
drivers/net/phy/loongson-phy.c new file +9 -0
+     if (linkmode_test_bit(ETHTOOL_LINK_MODE_10baseT_Full_BIT,
+         phydev->advertising) ||
+         linkmode_test_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT,
+         phydev->advertising) ||
+         linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT,
+         phydev->advertising))
+         return genphy_config_aneg(phydev);
+
+     netdev_info(phydev->attached_dev, "Parameter Setting Error\n");
Quoted 7 lines
Quoted 3 lines

This also needs explaining. How can it be asked to do something it does not support?

Perhaps I missed something, but I think that if someone uses ethtool, they can request it to perform actions or configurations that the tool does not support.

No. The PHY should indicate what it can do, via the .get_abilities() etc. The MAC can also remove some of those link modes if it is more limited than the PHY. phylib will then not allow ksetting_set() to enable things which are not supported. So this should not happen. It would actually be a bad design, since it would force every driver to do such checks, rather than implement it once in the core.

Quoted 36 lines
Quoted 6 lines
Quoted 6 lines
drivers/net/phy/loongson-phy.c new file +6 -0
+int ls7a2000_match_phy_device(struct phy_device *phydev)
+{
+     struct net_device *ndev;
+     struct pci_dev *pdev;
+
+     if ((phydev->phy_id & 0xfffffff0) != PHY_ID_LS7A2000)
Quoted 9 lines

drivers/net/phy/loongson-phy.c line 47

Quoted 6 lines
drivers/net/phy/loongson-phy.c new file +6 -0
+             return 0;
+
+     ndev = phydev->mdio.bus->priv;
+     pdev = to_pci_dev(ndev->dev.parent);
+
+     return pdev->revision == GNET_REV_LS7A2000;

That is very unusual. Why is the PHY ID not sufficient?

To work around the controller's issues, we enable the usage of this driver specifically for a certain version of the 7A2000 chip.

Quoted 12 lines

drivers/net/phy/loongson-phy.c line 54

Quoted 7 lines
drivers/net/phy/loongson-phy.c new file +7 -0
+}
+
+static struct phy_driver loongson_phy_driver[] = {
+     {
+             PHY_ID_MATCH_MODEL(PHY_ID_LS7A2000),
+             .name                   = "LS7A2000 PHY",
+             .features               = PHY_LOONGSON_FEATURES,

So what are the capabilities of this PHY? You seem to have some very odd hacks here, and no explanation of why they are needed. If you do something which no other device does, you need to explain it.

Quoted 4 lines

Does the PHY itself only support full duplex? No half duplex? Does the PHY support autoneg? Does it support fixed settings? What does genphy_read_abilities() return for this PHY?

Quoted 4 lines

As mentioned earlier, this driver is specifically designed for the PHY on the problematic 7A2000 chip. Therefore, we assume that this PHY only supports full- duplex mode and performs auto-negotiation exclusively for gigabit speeds.

So what does genphy_read_abilities() return?

Nobody else going to use PHY_LOONGSON_FEATURES, so i would prefer not to add it to the core. If your PHY is designed correctly, genphy_read_abilities() should determine what the PHY can do from its registers. If the registers are wrong, it is better to add a .get_features function.

Andrew

#5 lore raw

Re: [RFC PATCH 01/10] net: phy: Add driver for Loongson PHY

Quoted 12 lines · Andrew Lunn
Quoted 12 lines
Quoted 11 lines

drivers/net/phy/loongson-phy.c line 16

Quoted 8 lines
drivers/net/phy/loongson-phy.c new file +7 -0
+#include <linux/mii.h>
+#include <linux/module.h>
+#include <linux/netdevice.h>
+#include <linux/pci.h>
+#include <linux/phy.h>
+
+#define PHY_ID_LS7A2000              0x00061ce0

What is Loongson OUI?

Quoted 6 lines
Quoted 2 lines

Currently, we do not have an OUI for Loongson, but we are in the process of applying for one.

Is the value 0x00061ce0 baked into the silicon? Or can it be changed once you have an OUI?

Hi, Andrew,

The value is baked into the silicon.

Quoted 14 lines
Quoted 10 lines
Quoted 9 lines

drivers/net/phy/loongson-phy.c line 22

Quoted 6 lines
drivers/net/phy/loongson-phy.c new file +6 -0
+#define GNET_REV_LS7A2000    0x00
+
+static int ls7a2000_config_aneg(struct phy_device *phydev)
+{
+     if (phydev->speed == SPEED_1000)
+             phydev->autoneg = AUTONEG_ENABLE;

Please explain.

Quoted 3 lines

The PHY itself supports half-duplex, but there are issues with the controller used in the 7A2000 chip. Moreover, the controller only supports auto-negotiation for gigabit speeds.

Quoted 6 lines

So you can force 10/100/1000, but auto neg only succeeds for 1G?

Are the LP autoneg values available for genphy_read_lpa() to read? If the LP values are available, maybe the PHY driver can resolve the autoneg for 10 an 100.

I apologize for the confusion caused by my previous description. To clarify, the PHY supports auto-negotiation and non-auto-negotiation for 10/100, but non-auto-negotiation for 1000 does not work correctly.

Quoted 18 lines
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
drivers/net/phy/loongson-phy.c new file +9 -0
+     if (linkmode_test_bit(ETHTOOL_LINK_MODE_10baseT_Full_BIT,
+         phydev->advertising) ||
+         linkmode_test_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT,
+         phydev->advertising) ||
+         linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT,
+         phydev->advertising))
+         return genphy_config_aneg(phydev);
+
+     netdev_info(phydev->attached_dev, "Parameter Setting Error\n");
Quoted 7 lines
Quoted 3 lines

This also needs explaining. How can it be asked to do something it does not support?

Perhaps I missed something, but I think that if someone uses ethtool, they can request it to perform actions or configurations that the tool does not support.

Quoted 7 lines

No. The PHY should indicate what it can do, via the .get_abilities() etc. The MAC can also remove some of those link modes if it is more limited than the PHY. phylib will then not allow ksetting_set() to enable things which are not supported. So this should not happen. It would actually be a bad design, since it would force every driver to do such checks, rather than implement it once in the core.

I see.

Quoted 41 lines
Quoted 36 lines
Quoted 6 lines
Quoted 6 lines
drivers/net/phy/loongson-phy.c new file +6 -0
+int ls7a2000_match_phy_device(struct phy_device *phydev)
+{
+     struct net_device *ndev;
+     struct pci_dev *pdev;
+
+     if ((phydev->phy_id & 0xfffffff0) != PHY_ID_LS7A2000)
Quoted 9 lines

drivers/net/phy/loongson-phy.c line 47

Quoted 6 lines
drivers/net/phy/loongson-phy.c new file +6 -0
+             return 0;
+
+     ndev = phydev->mdio.bus->priv;
+     pdev = to_pci_dev(ndev->dev.parent);
+
+     return pdev->revision == GNET_REV_LS7A2000;

That is very unusual. Why is the PHY ID not sufficient?

To work around the controller's issues, we enable the usage of this driver specifically for a certain version of the 7A2000 chip.

Quoted 12 lines

drivers/net/phy/loongson-phy.c line 54

Quoted 7 lines
drivers/net/phy/loongson-phy.c new file +7 -0
+}
+
+static struct phy_driver loongson_phy_driver[] = {
+     {
+             PHY_ID_MATCH_MODEL(PHY_ID_LS7A2000),
+             .name                   = "LS7A2000 PHY",
+             .features               = PHY_LOONGSON_FEATURES,

So what are the capabilities of this PHY? You seem to have some very odd hacks here, and no explanation of why they are needed. If you do something which no other device does, you need to explain it.

Quoted 4 lines

Does the PHY itself only support full duplex? No half duplex? Does the PHY support autoneg? Does it support fixed settings? What does genphy_read_abilities() return for this PHY?

Quoted 4 lines

As mentioned earlier, this driver is specifically designed for the PHY on the problematic 7A2000 chip. Therefore, we assume that this PHY only supports full- duplex mode and performs auto-negotiation exclusively for gigabit speeds.

Quoted 8 lines

So what does genphy_read_abilities() return?

Nobody else going to use PHY_LOONGSON_FEATURES, so i would prefer not to add it to the core. If your PHY is designed correctly, genphy_read_abilities() should determine what the PHY can do from its registers. If the registers are wrong, it is better to add a .get_features function.

genphy_read_abilities() returns 0, and it seems to be working fine. The registers are incorrect, so I will use the .get_features function to clear some of the half-duplex bits.

Thanks,
Feiyang

Quoted 1 line

Andrew

maintainer
#6 lore raw

Re: [RFC PATCH 01/10] net: phy: Add driver for Loongson PHY

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
Quoted 1 line

+#define PHY_ID_LS7A2000 0x00061ce0

What is Loongson OUI?

Currently, we do not have an OUI for Loongson, but we are in the process of applying for one.

Quoted 7 lines
Quoted 3 lines

Is the value 0x00061ce0 baked into the silicon? Or can it be changed once you have an OUI?

Hi, Andrew,

The value is baked into the silicon.

O.K. Thanks. Do you have an idea how long it will take to get an OUI?

Does the PCI ID uniquely identify the MAC+PHY combination?

Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

The PHY itself supports half-duplex, but there are issues with the controller used in the 7A2000 chip. Moreover, the controller only supports auto-negotiation for gigabit speeds.

So you can force 10/100/1000, but auto neg only succeeds for 1G?

Quoted 8 lines
Quoted 4 lines

Are the LP autoneg values available for genphy_read_lpa() to read? If the LP values are available, maybe the PHY driver can resolve the autoneg for 10 an 100.

I apologize for the confusion caused by my previous description. To clarify, the PHY supports auto-negotiation and non-auto-negotiation for 10/100, but non-auto-negotiation for 1000 does not work correctly.

So you can force 10/100, but auto-neg 10/100/1000.

So i would suggest .get_features() indicates normal 10/100/1000 operation. Have your .config_aneg function which is used for both auto-neg and forced configuration check for phydev->autoneg == AUTONEG_DISABLE and phydev->speed == SPEED_1000 and return -EOPNOTSUPP. Otherwise call genphy_config_aneg().

Quoted 9 lines
Quoted 8 lines

So what does genphy_read_abilities() return?

Nobody else going to use PHY_LOONGSON_FEATURES, so i would prefer not to add it to the core. If your PHY is designed correctly, genphy_read_abilities() should determine what the PHY can do from its registers. If the registers are wrong, it is better to add a .get_features function.

Quoted 3 lines

genphy_read_abilities() returns 0, and it seems to be working fine. The registers are incorrect, so I will use the .get_features function to clear some of the half-duplex bits.

You said above that the PHY supports half duplex, the MAC has problems with half duplex. So it should be the MAC which indicates it does not unsupported half duplex link modes.

So you need to modify phylink_config.mac_capabilities before phylink_create() is called. There is already

        /* Half-Duplex can only work with single queue */
	if (priv->plat->tx_queues_to_use > 1)
                priv->phylink_config.mac_capabilities &=
                        ~(MAC_10HD | MAC_100HD | MAC_1000HD);

so you just need to add a quirk for your broken hardware.

Andrew

#7 lore raw

Re: [RFC PATCH 01/10] net: phy: Add driver for Loongson PHY

Quoted 13 lines · Andrew Lunn
Quoted 13 lines
Quoted 12 lines
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

+#define PHY_ID_LS7A2000 0x00061ce0

What is Loongson OUI?

Currently, we do not have an OUI for Loongson, but we are in the process of applying for one.

Is the value 0x00061ce0 baked into the silicon? Or can it be changed once you have an OUI?

Quoted 8 lines
Quoted 3 lines

Hi, Andrew,

The value is baked into the silicon.

O.K. Thanks. Do you have an idea how long it will take to get an OUI?

Does the PCI ID uniquely identify the MAC+PHY combination?

Hi, Andrew,

Sorry, I currently don't have an exact timeline for when the OUI will be available. The next hardware version will address these bugs, so we won't be going with this driver.

Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

The PHY itself supports half-duplex, but there are issues with the controller used in the 7A2000 chip. Moreover, the controller only supports auto-negotiation for gigabit speeds.

So you can force 10/100/1000, but auto neg only succeeds for 1G?

Quoted 8 lines
Quoted 4 lines

Are the LP autoneg values available for genphy_read_lpa() to read? If the LP values are available, maybe the PHY driver can resolve the autoneg for 10 an 100.

I apologize for the confusion caused by my previous description. To clarify, the PHY supports auto-negotiation and non-auto-negotiation for 10/100, but non-auto-negotiation for 1000 does not work correctly.

Quoted 8 lines

So you can force 10/100, but auto-neg 10/100/1000.

So i would suggest .get_features() indicates normal 10/100/1000 operation. Have your .config_aneg function which is used for both auto-neg and forced configuration check for phydev->autoneg == AUTONEG_DISABLE and phydev->speed == SPEED_1000 and return -EOPNOTSUPP. Otherwise call genphy_config_aneg().

Well, can I return -EINVAL in the .set_link_ksettings callback? Considering that our next hardware version will have the OUI allocated and these bugs fixed, I won't submit this driver in the next patch version. I believe we can just use the generic PHY for now.

Quoted 20 lines
Quoted 9 lines
Quoted 8 lines

So what does genphy_read_abilities() return?

Nobody else going to use PHY_LOONGSON_FEATURES, so i would prefer not to add it to the core. If your PHY is designed correctly, genphy_read_abilities() should determine what the PHY can do from its registers. If the registers are wrong, it is better to add a .get_features function.

Quoted 3 lines

genphy_read_abilities() returns 0, and it seems to be working fine. The registers are incorrect, so I will use the .get_features function to clear some of the half-duplex bits.

You said above that the PHY supports half duplex, the MAC has problems with half duplex. So it should be the MAC which indicates it does not unsupported half duplex link modes.

So you need to modify phylink_config.mac_capabilities before phylink_create() is called. There is already

Quoted 7 lines
        /* Half-Duplex can only work with single queue */
        if (priv->plat->tx_queues_to_use > 1)
                priv->phylink_config.mac_capabilities &=
                        ~(MAC_10HD | MAC_100HD | MAC_1000HD);

so you just need to add a quirk for your broken hardware.

OK.

Thanks,
Feiyang

Quoted 2 lines

Andrew

maintainer
#8 lore raw

Re: [RFC PATCH 01/10] net: phy: Add driver for Loongson PHY

Quoted 5 lines

Hi, Andrew,

Sorry, I currently don't have an exact timeline for when the OUI will be available. The next hardware version will address these bugs, so we won't be going with this driver.

Not having an OUI breaks the standard. So i was actually thinking you should trap the reads to the ID registers in the MDIO bus driver and return valid values. Some Marvell Ethernet switch integrated PHYs have a valid OUI, and no device part. We trap those and insert valid values. So there is some president for doing this. Doing this would also allow you to avoid the PHY driver poking around the MAC drivers PCI bus.

Quoted 8 lines
Quoted 6 lines

So i would suggest .get_features() indicates normal 10/100/1000 operation. Have your .config_aneg function which is used for both auto-neg and forced configuration check for phydev->autoneg == AUTONEG_DISABLE and phydev->speed == SPEED_1000 and return -EOPNOTSUPP. Otherwise call genphy_config_aneg().

Well, can I return -EINVAL in the .set_link_ksettings callback?

If the PHY is broken, the PHY should do it. If the MAC is broken, the MAC should do it. We have clean separation here, even when the hardware is integrated.

Quoted 4 lines

Considering that our next hardware version will have the OUI allocated and these bugs fixed, I won't submit this driver in the next patch version. I believe we can just use the generic PHY for now.

The problem with the generic driver is you cannot have workarounds in it. You don't want to put PHY workarounds in the MAC driver.

Andrew

#9 lore raw

Re: [RFC PATCH 01/10] net: phy: Add driver for Loongson PHY

Quoted 22 lines · Andrew Lunn
Quoted 6 lines

Hi, Andrew,

Sorry, I currently don't have an exact timeline for when the OUI will be available. The next hardware version will address these bugs, so we won't be going with this driver.

Not having an OUI breaks the standard. So i was actually thinking you should trap the reads to the ID registers in the MDIO bus driver and return valid values. Some Marvell Ethernet switch integrated PHYs have a valid OUI, and no device part. We trap those and insert valid values. So there is some president for doing this. Doing this would also allow you to avoid the PHY driver poking around the MAC drivers PCI bus.

Quoted 7 lines
Quoted 6 lines

So i would suggest .get_features() indicates normal 10/100/1000 operation. Have your .config_aneg function which is used for both auto-neg and forced configuration check for phydev->autoneg == AUTONEG_DISABLE and phydev->speed == SPEED_1000 and return -EOPNOTSUPP. Otherwise call genphy_config_aneg().

Quoted 6 lines
Quoted 1 line

Well, can I return -EINVAL in the .set_link_ksettings callback?

If the PHY is broken, the PHY should do it. If the MAC is broken, the MAC should do it. We have clean separation here, even when the hardware is integrated.

Hi, Andrew,

I get it. To be honest, I'm not familiar with the hardware, so I asked the colleague who designed this chip. The real problem is the same as I described in Patch 10 - the Ethernet controller doesn't work well with the PHY. If the controller works properly, we can force 1000. Are there any methods to work around this problem in the MAC driver?

Quoted 8 lines
Quoted 4 lines

Considering that our next hardware version will have the OUI allocated and these bugs fixed, I won't submit this driver in the next patch version. I believe we can just use the generic PHY for now.

The problem with the generic driver is you cannot have workarounds in it. You don't want to put PHY workarounds in the MAC driver.

Sure, we should not put PHY workarounds in the MAC driver and vice versa.

This PHY driver was designed to solve two problems at first:
1. We cannot force 1000.
2. We cannot use half duplex.

Now, we are sure that the MAC is broken, not the PHY, so I think we can solve these problems in the MAC driver.

Thanks,
Feiyang

Quoted 2 lines

Andrew

maintainer
#10 lore raw

Re: [RFC PATCH 01/10] net: phy: Add driver for Loongson PHY

Quoted 6 lines

This PHY driver was designed to solve two problems at first:
1. We cannot force 1000.
2. We cannot use half duplex.

Now, we are sure that the MAC is broken, not the PHY, so I think we can solve these problems in the MAC driver.

You can solve both of these in the MAC. You can remove the half duplex link modes after the PHY is connected to the MAC. And you can add a test in ksetting_set to check for 1000 Force and return EOPNOTSUPP.

Andrew

#11 lore raw

Re: [RFC PATCH 01/10] net: phy: Add driver for Loongson PHY

In reply to Feiyang Chen
Quoted 5 lines · Feiyang Chen
drivers/net/phy/loongson-phy.c new file +5 -0
+#define PHY_ID_LS7A2000		0x00061ce0
+#define GNET_REV_LS7A2000	0x00
+
+static int ls7a2000_config_aneg(struct phy_device *phydev)
+{

drivers/net/phy/loongson-phy.c line 30

Quoted 10 lines
drivers/net/phy/loongson-phy.c new file +10 -0
+	if (phydev->speed == SPEED_1000)
+		phydev->autoneg = AUTONEG_ENABLE;
+
+	if (linkmode_test_bit(ETHTOOL_LINK_MODE_10baseT_Full_BIT,
+	    phydev->advertising) ||
+	    linkmode_test_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT,
+	    phydev->advertising) ||
+	    linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT,
+	    phydev->advertising))
+	    return genphy_config_aneg(phydev);

While it's fine to use four spaces within the if () expression, this "return" should be indented with a tab.

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+	netdev_info(phydev->attached_dev, "Parameter Setting Error\n");

Does this give the opportunity for userspace to spam the kernel log? E.g. by a daemon repeatedly trying to set link parameters? Should it be rate limited?

drivers/net/phy/loongson-phy.c line 33

Quoted 1 line
drivers/net/phy/loongson-phy.c new file +1 -0
+	return -1;

Sigh, not this laziness disease yet again. -1 is -EPERM. Return a real errno code.

drivers/net/phy/loongson-phy.c line 42

Quoted 7 lines
drivers/net/phy/loongson-phy.c new file +7 -0
+int ls7a2000_match_phy_device(struct phy_device *phydev)
+{
+	struct net_device *ndev;
+	struct pci_dev *pdev;
+
+	if ((phydev->phy_id & 0xfffffff0) != PHY_ID_LS7A2000)
+		return 0;
	if (!phy_id_compare(phydev->phy_id, PHY_ID_LS7A2000, 0xfffffff0))
		return 0;

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+	ndev = phydev->mdio.bus->priv;

This doesn't look safe to me - you're assuming that if the PHY ID above matches, that the MDIO bus' private data is something you know which is far from guaranteed.

The mdio bus has a parent device - that would be a safer route to check what the parent device is, provided the mdio bus is created so that it's a child of the parent PCI device.

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!
#12 lore raw

Re: [RFC PATCH 01/10] net: phy: Add driver for Loongson PHY

Quoted 12 lines · Russell King (Oracle)
Quoted 10 lines · Feiyang Chen
drivers/net/phy/loongson-phy.c new file +10 -0
+#define PHY_ID_LS7A2000              0x00061ce0
+#define GNET_REV_LS7A2000    0x00
+
+static int ls7a2000_config_aneg(struct phy_device *phydev)
+{
+     if (phydev->speed == SPEED_1000)
+             phydev->autoneg = AUTONEG_ENABLE;
+
+     if (linkmode_test_bit(ETHTOOL_LINK_MODE_10baseT_Full_BIT,
+         phydev->advertising) ||
Quoted 9 lines

drivers/net/phy/loongson-phy.c line 30

Quoted 5 lines
drivers/net/phy/loongson-phy.c new file +5 -0
+         linkmode_test_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT,
+         phydev->advertising) ||
+         linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT,
+         phydev->advertising))
+         return genphy_config_aneg(phydev);

While it's fine to use four spaces within the if () expression, this "return" should be indented with a tab.

Hi, Russell,

Sorry for the typo. I will correct it in the next version.

Quoted 12 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+     netdev_info(phydev->attached_dev, "Parameter Setting Error\n");

Does this give the opportunity for userspace to spam the kernel log? E.g. by a daemon repeatedly trying to set link parameters? Should it be rate limited?

Quoted 1 line

+ return -1;

Sigh, not this laziness disease yet again. -1 is -EPERM. Return a real errno code.

OK.

Quoted 11 lines

drivers/net/phy/loongson-phy.c line 42

Quoted 7 lines
drivers/net/phy/loongson-phy.c new file +7 -0
+int ls7a2000_match_phy_device(struct phy_device *phydev)
+{
+     struct net_device *ndev;
+     struct pci_dev *pdev;
+
+     if ((phydev->phy_id & 0xfffffff0) != PHY_ID_LS7A2000)
+             return 0;
        if (!phy_id_compare(phydev->phy_id, PHY_ID_LS7A2000, 0xfffffff0))
                return 0;

OK.

Quoted 11 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+     ndev = phydev->mdio.bus->priv;

This doesn't look safe to me - you're assuming that if the PHY ID above matches, that the MDIO bus' private data is something you know which is far from guaranteed.

The mdio bus has a parent device - that would be a safer route to check what the parent device is, provided the mdio bus is created so that it's a child of the parent PCI device.

OK. I’ll get right on that.

Thanks,
Feiyang

Quoted 3 lines

--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

#13 lore raw

RFC PATCH 2/10 net: stmmac: Pass stmmac_priv and chan in some callbacks

In reply to Feiyang Chen

Like commit 1d84b487bc2d90 ("net: stmmac: Pass stmmac_priv in some callbacks"), passing stmmac_priv and chan to more callbacks and adjust the callbacks accordingly.

---
 .../net/ethernet/stmicro/stmmac/chain_mode.c  |  5 +-
 .../net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 20 +++--
 .../ethernet/stmicro/stmmac/dwmac1000_core.c  |  9 ++-
 .../ethernet/stmicro/stmmac/dwmac1000_dma.c   |  8 +-
 .../ethernet/stmicro/stmmac/dwmac100_core.c   |  9 ++-
 .../ethernet/stmicro/stmmac/dwmac100_dma.c    |  2 +-
 .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 11 ++-
 .../ethernet/stmicro/stmmac/dwmac4_descs.c    | 19 ++---
 .../net/ethernet/stmicro/stmmac/dwmac4_dma.c  |  8 +-
 .../net/ethernet/stmicro/stmmac/dwmac_dma.h   |  3 +-
 .../net/ethernet/stmicro/stmmac/dwmac_lib.c   |  3 +-
 .../ethernet/stmicro/stmmac/dwxgmac2_core.c   | 11 ++-
 .../ethernet/stmicro/stmmac/dwxgmac2_descs.c  | 17 ++--
 .../ethernet/stmicro/stmmac/dwxgmac2_dma.c    |  8 +-
 .../net/ethernet/stmicro/stmmac/enh_desc.c    | 17 ++--
 drivers/net/ethernet/stmicro/stmmac/hwif.h    | 77 ++++++++++---------
 .../net/ethernet/stmicro/stmmac/norm_desc.c   | 17 ++--
 .../net/ethernet/stmicro/stmmac/ring_mode.c   |  4 +-
 .../net/ethernet/stmicro/stmmac/stmmac_main.c |  6 +-
 19 files changed, 145 insertions(+), 109 deletions(-)
drivers/net/ethernet/stmicro/stmmac/chain_mode.c +3 -2
index fb55efd52240..a95866871f3e 100644
@@ -95,8 +95,9 @@ static unsigned int is_jumbo_frm(int len, int enh_desc)
 	return ret;
 }
 
-static void init_dma_chain(void *des, dma_addr_t phy_addr,
-				  unsigned int size, unsigned int extend_desc)
+static void init_dma_chain(struct stmmac_priv *priv, void *des,
+			   dma_addr_t phy_addr, unsigned int size,
+			   unsigned int extend_desc)
 {
 	/*
 	 * In chained mode the des3 points to the next element in the ring.
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c +12 -8
index c2c592ba0eb8..bcb95dcb4371 100644
@@ -297,7 +297,7 @@ static int sun8i_dwmac_dma_reset(void __iomem *ioaddr)
 /* sun8i_dwmac_dma_init() - initialize the EMAC
  * Called from stmmac via stmmac_dma_ops->init
  */
-static void sun8i_dwmac_dma_init(void __iomem *ioaddr,
+static void sun8i_dwmac_dma_init(struct stmmac_priv *priv, void __iomem *ioaddr,
 				 struct stmmac_dma_cfg *dma_cfg, int atds)
 {
 	writel(EMAC_RX_INT | EMAC_TX_INT, ioaddr + EMAC_INT_EN);
@@ -394,7 +394,8 @@ static void sun8i_dwmac_dma_start_tx(struct stmmac_priv *priv,
 	writel(v, ioaddr + EMAC_TX_CTL1);
 }
 
-static void sun8i_dwmac_enable_dma_transmission(void __iomem *ioaddr)
+static void sun8i_dwmac_enable_dma_transmission(struct stmmac_priv *priv,
+						void __iomem *ioaddr, u32 chan)
 {
 	u32 v;
 
@@ -636,7 +637,8 @@ static void sun8i_dwmac_set_mac(void __iomem *ioaddr, bool enable)
  * All slot > 0 need to be enabled with MAC_ADDR_TYPE_DST
  * If addr is NULL, clear the slot
  */
-static void sun8i_dwmac_set_umac_addr(struct mac_device_info *hw,
+static void sun8i_dwmac_set_umac_addr(struct stmmac_priv *priv,
+				      struct mac_device_info *hw,
 				      const unsigned char *addr,
 				      unsigned int reg_n)
 {
@@ -657,7 +659,8 @@ static void sun8i_dwmac_set_umac_addr(struct mac_device_info *hw,
 	}
 }
 
-static void sun8i_dwmac_get_umac_addr(struct mac_device_info *hw,
+static void sun8i_dwmac_get_umac_addr(struct stmmac_priv *priv,
+				      struct mac_device_info *hw,
 				      unsigned char *addr,
 				      unsigned int reg_n)
 {
@@ -680,7 +683,8 @@ static int sun8i_dwmac_rx_ipc_enable(struct mac_device_info *hw)
 	return 1;
 }
 
-static void sun8i_dwmac_set_filter(struct mac_device_info *hw,
+static void sun8i_dwmac_set_filter(struct stmmac_priv *priv,
+				   struct mac_device_info *hw,
 				   struct net_device *dev)
 {
 	void __iomem *ioaddr = hw->pcsr;
@@ -698,13 +702,13 @@ static void sun8i_dwmac_set_filter(struct mac_device_info *hw,
 	} else if (macaddrs <= hw->unicast_filter_entries) {
 		if (!netdev_mc_empty(dev)) {
 			netdev_for_each_mc_addr(ha, dev) {
-				sun8i_dwmac_set_umac_addr(hw, ha->addr, i);
+				sun8i_dwmac_set_umac_addr(priv, hw, ha->addr, i);
 				i++;
 			}
 		}
 		if (!netdev_uc_empty(dev)) {
 			netdev_for_each_uc_addr(ha, dev) {
-				sun8i_dwmac_set_umac_addr(hw, ha->addr, i);
+				sun8i_dwmac_set_umac_addr(priv, hw, ha->addr, i);
 				i++;
 			}
 		}
@@ -716,7 +720,7 @@ static void sun8i_dwmac_set_filter(struct mac_device_info *hw,
 
 	/* Disable unused address filter slots */
 	while (i < hw->unicast_filter_entries)
-		sun8i_dwmac_set_umac_addr(hw, NULL, i++);
+		sun8i_dwmac_set_umac_addr(priv, hw, NULL, i++);
 
 	writel(v, ioaddr + EMAC_RX_FRM_FLT);
 }
drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +6 -3
index 3927609abc44..b52793edf62f 100644
@@ -94,7 +94,8 @@ static void dwmac1000_dump_regs(struct mac_device_info *hw, u32 *reg_space)
 		reg_space[i] = readl(ioaddr + i * 4);
 }
 
-static void dwmac1000_set_umac_addr(struct mac_device_info *hw,
+static void dwmac1000_set_umac_addr(struct stmmac_priv *priv,
+				    struct mac_device_info *hw,
 				    const unsigned char *addr,
 				    unsigned int reg_n)
 {
@@ -103,7 +104,8 @@ static void dwmac1000_set_umac_addr(struct mac_device_info *hw,
 			    GMAC_ADDR_LOW(reg_n));
 }
 
-static void dwmac1000_get_umac_addr(struct mac_device_info *hw,
+static void dwmac1000_get_umac_addr(struct stmmac_priv *priv,
+				    struct mac_device_info *hw,
 				    unsigned char *addr,
 				    unsigned int reg_n)
 {
@@ -137,7 +139,8 @@ static void dwmac1000_set_mchash(void __iomem *ioaddr, u32 *mcfilterbits,
 		       ioaddr + GMAC_EXTHASH_BASE + regs * 4);
 }
 
-static void dwmac1000_set_filter(struct mac_device_info *hw,
+static void dwmac1000_set_filter(struct stmmac_priv *priv,
+				 struct mac_device_info *hw,
 				 struct net_device *dev)
 {
 	void __iomem *ioaddr = (void __iomem *)dev->base_addr;
drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c +5 -3
index daf79cdbd3ec..ce0e6ca6f3a2 100644
@@ -16,7 +16,8 @@
 #include "dwmac1000.h"
 #include "dwmac_dma.h"
 
-static void dwmac1000_dma_axi(void __iomem *ioaddr, struct stmmac_axi *axi)
+static void dwmac1000_dma_axi(struct stmmac_priv *priv, void __iomem *ioaddr,
+			      struct stmmac_axi *axi)
 {
 	u32 value = readl(ioaddr + DMA_AXI_BUS_MODE);
 	int i;
@@ -70,7 +71,7 @@ static void dwmac1000_dma_axi(void __iomem *ioaddr, struct stmmac_axi *axi)
 	writel(value, ioaddr + DMA_AXI_BUS_MODE);
 }
 
-static void dwmac1000_dma_init(void __iomem *ioaddr,
+static void dwmac1000_dma_init(struct stmmac_priv *priv, void __iomem *ioaddr,
 			       struct stmmac_dma_cfg *dma_cfg, int atds)
 {
 	u32 value = readl(ioaddr + DMA_BUS_MODE);
@@ -223,7 +224,8 @@ static void dwmac1000_dump_dma_regs(struct stmmac_priv *priv,
 				readl(ioaddr + DMA_BUS_MODE + i * 4);
 }
 
-static int dwmac1000_get_hw_feature(void __iomem *ioaddr,
+static int dwmac1000_get_hw_feature(struct stmmac_priv *priv,
+				    void __iomem *ioaddr,
 				    struct dma_features *dma_cap)
 {
 	u32 hw_cap = readl(ioaddr + DMA_HW_FEATURE);
drivers/net/ethernet/stmicro/stmmac/dwmac100_core.c +6 -3
index a6e8d7bd9588..c03623edeb75 100644
@@ -59,7 +59,8 @@ static int dwmac100_irq_status(struct mac_device_info *hw,
 	return 0;
 }
 
-static void dwmac100_set_umac_addr(struct mac_device_info *hw,
+static void dwmac100_set_umac_addr(struct stmmac_priv *priv,
+				   struct mac_device_info *hw,
 				   const unsigned char *addr,
 				   unsigned int reg_n)
 {
@@ -67,7 +68,8 @@ static void dwmac100_set_umac_addr(struct mac_device_info *hw,
 	stmmac_set_mac_addr(ioaddr, addr, MAC_ADDR_HIGH, MAC_ADDR_LOW);
 }
 
-static void dwmac100_get_umac_addr(struct mac_device_info *hw,
+static void dwmac100_get_umac_addr(struct stmmac_priv *priv,
+				   struct mac_device_info *hw,
 				   unsigned char *addr,
 				   unsigned int reg_n)
 {
@@ -75,7 +77,8 @@ static void dwmac100_get_umac_addr(struct mac_device_info *hw,
 	stmmac_get_mac_addr(ioaddr, addr, MAC_ADDR_HIGH, MAC_ADDR_LOW);
 }
 
-static void dwmac100_set_filter(struct mac_device_info *hw,
+static void dwmac100_set_filter(struct stmmac_priv *priv,
+				struct mac_device_info *hw,
 				struct net_device *dev)
 {
 	void __iomem *ioaddr = (void __iomem *)dev->base_addr;
drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c +1 -1
index 1c32b1788f02..e6ae230fa453 100644
@@ -18,7 +18,7 @@
 #include "dwmac100.h"
 #include "dwmac_dma.h"
 
-static void dwmac100_dma_init(void __iomem *ioaddr,
+static void dwmac100_dma_init(struct stmmac_priv *priv, void __iomem *ioaddr,
 			      struct stmmac_dma_cfg *dma_cfg, int atds)
 {
 	/* Enable Application Access by writing to DMA CSR0 */
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +7 -4
index 11a51a8a80ff..c0db43138bb7 100644
@@ -330,7 +330,8 @@ static void dwmac4_pmt(struct mac_device_info *hw, unsigned long mode)
 	writel(pmt, ioaddr + GMAC_PMT);
 }
 
-static void dwmac4_set_umac_addr(struct mac_device_info *hw,
+static void dwmac4_set_umac_addr(struct stmmac_priv *priv,
+				 struct mac_device_info *hw,
 				 const unsigned char *addr, unsigned int reg_n)
 {
 	void __iomem *ioaddr = hw->pcsr;
@@ -339,7 +340,8 @@ static void dwmac4_set_umac_addr(struct mac_device_info *hw,
 				   GMAC_ADDR_LOW(reg_n));
 }
 
-static void dwmac4_get_umac_addr(struct mac_device_info *hw,
+static void dwmac4_get_umac_addr(struct stmmac_priv *priv,
+				 struct mac_device_info *hw,
 				 unsigned char *addr, unsigned int reg_n)
 {
 	void __iomem *ioaddr = hw->pcsr;
@@ -588,7 +590,8 @@ static void dwmac4_restore_hw_vlan_rx_fltr(struct net_device *dev,
 	}
 }
 
-static void dwmac4_set_filter(struct mac_device_info *hw,
+static void dwmac4_set_filter(struct stmmac_priv *priv,
+			      struct mac_device_info *hw,
 			      struct net_device *dev)
 {
 	void __iomem *ioaddr = (void __iomem *)dev->base_addr;
@@ -664,7 +667,7 @@ static void dwmac4_set_filter(struct mac_device_info *hw,
 		int reg = 1;
 
 		netdev_for_each_uc_addr(ha, dev) {
-			dwmac4_set_umac_addr(hw, ha->addr, reg);
+			dwmac4_set_umac_addr(priv, hw, ha->addr, reg);
 			reg++;
 		}
 
drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c +10 -9
index 6a011d8633e8..98061986c5f4 100644
@@ -175,7 +175,7 @@ static int dwmac4_wrback_get_rx_status(struct net_device_stats *stats,
 	return ret;
 }
 
-static int dwmac4_rd_get_tx_len(struct dma_desc *p)
+static int dwmac4_rd_get_tx_len(struct stmmac_priv *priv, struct dma_desc *p)
 {
 	return (le32_to_cpu(p->des2) & TDES2_BUFFER1_SIZE_MASK);
 }
@@ -296,8 +296,8 @@ static int dwmac4_wrback_get_rx_timestamp_status(void *desc, void *next_desc,
 	return 0;
 }
 
-static void dwmac4_rd_init_rx_desc(struct dma_desc *p, int disable_rx_ic,
-				   int mode, int end, int bfsize)
+static void dwmac4_rd_init_rx_desc(struct stmmac_priv *priv, struct dma_desc *p,
+				   int disable_rx_ic, int mode, int end, int bfsize)
 {
 	dwmac4_set_rx_owner(p, disable_rx_ic);
 }
@@ -310,9 +310,9 @@ static void dwmac4_rd_init_tx_desc(struct dma_desc *p, int mode, int end)
 	p->des3 = 0;
 }
 
-static void dwmac4_rd_prepare_tx_desc(struct dma_desc *p, int is_fs, int len,
-				      bool csum_flag, int mode, bool tx_own,
-				      bool ls, unsigned int tot_pkt_len)
+static void dwmac4_rd_prepare_tx_desc(struct stmmac_priv *priv, struct dma_desc *p,
+				      int is_fs, int len, bool csum_flag, int mode,
+				      bool tx_own, bool ls, unsigned int tot_pkt_len)
 {
 	unsigned int tdes3 = le32_to_cpu(p->des3);
 
@@ -462,13 +462,14 @@ static void dwmac4_set_mss_ctxt(struct dma_desc *p, unsigned int mss)
 	p->des3 = cpu_to_le32(TDES3_CONTEXT_TYPE | TDES3_CTXT_TCMSSV);
 }
 
-static void dwmac4_set_addr(struct dma_desc *p, dma_addr_t addr)
+static void dwmac4_set_addr(struct stmmac_priv *priv, struct dma_desc *p,
+			    dma_addr_t addr)
 {
 	p->des0 = cpu_to_le32(lower_32_bits(addr));
 	p->des1 = cpu_to_le32(upper_32_bits(addr));
 }
 
-static void dwmac4_clear(struct dma_desc *p)
+static void dwmac4_clear(struct stmmac_priv *priv, struct dma_desc *p)
 {
 	p->des0 = 0;
 	p->des1 = 0;
@@ -483,7 +484,7 @@ static void dwmac4_set_sarc(struct dma_desc *p, u32 sarc_type)
 	p->des3 |= cpu_to_le32(sarc_type & TDES3_SA_INSERT_CTRL_MASK);
 }
 
-static int set_16kib_bfsize(int mtu)
+static int set_16kib_bfsize(struct stmmac_priv *priv, int mtu)
 {
 	int ret = 0;
 
drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c +5 -3
index 84d3a8551b03..97dad00dc850 100644
@@ -15,7 +15,8 @@
 #include "dwmac4_dma.h"
 #include "stmmac.h"
 
-static void dwmac4_dma_axi(void __iomem *ioaddr, struct stmmac_axi *axi)
+static void dwmac4_dma_axi(struct stmmac_priv *priv, void __iomem *ioaddr,
+			   struct stmmac_axi *axi)
 {
 	u32 value = readl(ioaddr + DMA_SYS_BUS_MODE);
 	int i;
@@ -152,7 +153,7 @@ static void dwmac410_dma_init_channel(struct stmmac_priv *priv,
 	       ioaddr + DMA_CHAN_INTR_ENA(dwmac4_addrs, chan));
 }
 
-static void dwmac4_dma_init(void __iomem *ioaddr,
+static void dwmac4_dma_init(struct stmmac_priv *priv, void __iomem *ioaddr,
 			    struct stmmac_dma_cfg *dma_cfg, int atds)
 {
 	u32 value = readl(ioaddr + DMA_SYS_BUS_MODE);
@@ -374,7 +375,8 @@ static void dwmac4_dma_tx_chan_op_mode(struct stmmac_priv *priv,
 	writel(mtl_tx_op, ioaddr +  MTL_CHAN_TX_OP_MODE(dwmac4_addrs, channel));
 }
 
-static int dwmac4_get_hw_feature(void __iomem *ioaddr,
+static int dwmac4_get_hw_feature(struct stmmac_priv *priv,
+				 void __iomem *ioaddr,
 				 struct dma_features *dma_cap)
 {
 	u32 hw_cap = readl(ioaddr + GMAC_HW_FEATURE0);
drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h +2 -1
index 72672391675f..e7aef136824b 100644
@@ -152,7 +152,8 @@
 #define NUM_DWMAC1000_DMA_REGS	23
 #define NUM_DWMAC4_DMA_REGS	27
 
-void dwmac_enable_dma_transmission(void __iomem *ioaddr);
+void dwmac_enable_dma_transmission(struct stmmac_priv *priv,
+				   void __iomem *ioaddr, u32 chan);
 void dwmac_enable_dma_irq(struct stmmac_priv *priv, void __iomem *ioaddr,
 			  u32 chan, bool rx, bool tx);
 void dwmac_disable_dma_irq(struct stmmac_priv *priv, void __iomem *ioaddr,
drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c +2 -1
index 0b6f999a8305..2dd457032187 100644
@@ -27,7 +27,8 @@ int dwmac_dma_reset(void __iomem *ioaddr)
 }
 
 /* CSR1 enables the transmit DMA to check for new descriptor */
-void dwmac_enable_dma_transmission(void __iomem *ioaddr)
+void dwmac_enable_dma_transmission(struct stmmac_priv *priv,
+				   void __iomem *ioaddr, u32 chan)
 {
 	writel(1, ioaddr + DMA_XMT_POLL_DEMAND);
 }
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +7 -4
index a0c2ef8bb0ac..640c1b4a0c14 100644
@@ -337,7 +337,8 @@ static void dwxgmac2_pmt(struct mac_device_info *hw, unsigned long mode)
 	writel(val, ioaddr + XGMAC_PMT);
 }
 
-static void dwxgmac2_set_umac_addr(struct mac_device_info *hw,
+static void dwxgmac2_set_umac_addr(struct stmmac_priv *priv,
+				   struct mac_device_info *hw,
 				   const unsigned char *addr,
 				   unsigned int reg_n)
 {
@@ -351,7 +352,8 @@ static void dwxgmac2_set_umac_addr(struct mac_device_info *hw,
 	writel(value, ioaddr + XGMAC_ADDRx_LOW(reg_n));
 }
 
-static void dwxgmac2_get_umac_addr(struct mac_device_info *hw,
+static void dwxgmac2_get_umac_addr(struct stmmac_priv *priv,
+				   struct mac_device_info *hw,
 				   unsigned char *addr, unsigned int reg_n)
 {
 	void __iomem *ioaddr = hw->pcsr;
@@ -440,7 +442,8 @@ static void dwxgmac2_set_mchash(void __iomem *ioaddr, u32 *mcfilterbits,
 		writel(mcfilterbits[regs], ioaddr + XGMAC_HASH_TABLE(regs));
 }
 
-static void dwxgmac2_set_filter(struct mac_device_info *hw,
+static void dwxgmac2_set_filter(struct stmmac_priv *priv,
+				struct mac_device_info *hw,
 				struct net_device *dev)
 {
 	void __iomem *ioaddr = (void __iomem *)dev->base_addr;
@@ -485,7 +488,7 @@ static void dwxgmac2_set_filter(struct mac_device_info *hw,
 		int reg = 1;
 
 		netdev_for_each_uc_addr(ha, dev) {
-			dwxgmac2_set_umac_addr(hw, ha->addr, reg);
+			dwxgmac2_set_umac_addr(priv, hw, ha->addr, reg);
 			reg++;
 		}
 
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c +9 -8
index 13c347ee8be9..e6fb47563fc0 100644
@@ -41,7 +41,7 @@ static int dwxgmac2_get_rx_status(struct net_device_stats *stats,
 	return good_frame;
 }
 
-static int dwxgmac2_get_tx_len(struct dma_desc *p)
+static int dwxgmac2_get_tx_len(struct stmmac_priv *priv, struct dma_desc *p)
 {
 	return (le32_to_cpu(p->des2) & XGMAC_TDES2_B1L);
 }
@@ -128,8 +128,8 @@ static int dwxgmac2_get_rx_timestamp_status(void *desc, void *next_desc,
 	return !ret;
 }
 
-static void dwxgmac2_init_rx_desc(struct dma_desc *p, int disable_rx_ic,
-				  int mode, int end, int bfsize)
+static void dwxgmac2_init_rx_desc(struct stmmac_priv *priv, struct dma_desc *p,
+				  int disable_rx_ic, int mode, int end, int bfsize)
 {
 	dwxgmac2_set_rx_owner(p, disable_rx_ic);
 }
@@ -142,9 +142,9 @@ static void dwxgmac2_init_tx_desc(struct dma_desc *p, int mode, int end)
 	p->des3 = 0;
 }
 
-static void dwxgmac2_prepare_tx_desc(struct dma_desc *p, int is_fs, int len,
-				     bool csum_flag, int mode, bool tx_own,
-				     bool ls, unsigned int tot_pkt_len)
+static void dwxgmac2_prepare_tx_desc(struct stmmac_priv *priv, struct dma_desc *p,
+				     int is_fs, int len, bool csum_flag, int mode,
+				     bool tx_own, bool ls, unsigned int tot_pkt_len)
 {
 	unsigned int tdes3 = le32_to_cpu(p->des3);
 
@@ -241,13 +241,14 @@ static void dwxgmac2_set_mss(struct dma_desc *p, unsigned int mss)
 	p->des3 = cpu_to_le32(XGMAC_TDES3_CTXT | XGMAC_TDES3_TCMSSV);
 }
 
-static void dwxgmac2_set_addr(struct dma_desc *p, dma_addr_t addr)
+static void dwxgmac2_set_addr(struct stmmac_priv *priv, struct dma_desc *p,
+			      dma_addr_t addr)
 {
 	p->des0 = cpu_to_le32(lower_32_bits(addr));
 	p->des1 = cpu_to_le32(upper_32_bits(addr));
 }
 
-static void dwxgmac2_clear(struct dma_desc *p)
+static void dwxgmac2_clear(struct stmmac_priv *priv, struct dma_desc *p)
 {
 	p->des0 = 0;
 	p->des1 = 0;
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c +5 -3
index dfd53264e036..c6b032cd6d9a 100644
@@ -19,7 +19,7 @@ static int dwxgmac2_dma_reset(void __iomem *ioaddr)
 				  !(value & XGMAC_SWR), 0, 100000);
 }
 
-static void dwxgmac2_dma_init(void __iomem *ioaddr,
+static void dwxgmac2_dma_init(struct stmmac_priv *priv, void __iomem *ioaddr,
 			      struct stmmac_dma_cfg *dma_cfg, int atds)
 {
 	u32 value = readl(ioaddr + XGMAC_DMA_SYSBUS_MODE);
@@ -81,7 +81,8 @@ static void dwxgmac2_dma_init_tx_chan(struct stmmac_priv *priv,
 	writel(lower_32_bits(phy), ioaddr + XGMAC_DMA_CH_TxDESC_LADDR(chan));
 }
 
-static void dwxgmac2_dma_axi(void __iomem *ioaddr, struct stmmac_axi *axi)
+static void dwxgmac2_dma_axi(struct stmmac_priv *priv, void __iomem *ioaddr,
+			     struct stmmac_axi *axi)
 {
 	u32 value = readl(ioaddr + XGMAC_DMA_SYSBUS_MODE);
 	int i;
@@ -382,7 +383,8 @@ static int dwxgmac2_dma_interrupt(struct stmmac_priv *priv,
 	return ret;
 }
 
-static int dwxgmac2_get_hw_feature(void __iomem *ioaddr,
+static int dwxgmac2_get_hw_feature(struct stmmac_priv *priv,
+				   void __iomem *ioaddr,
 				   struct dma_features *dma_cap)
 {
 	u32 hw_cap;
drivers/net/ethernet/stmicro/stmmac/enh_desc.c +9 -8
index a91d8f13a931..1932a3a8e03c 100644
@@ -79,7 +79,7 @@ static int enh_desc_get_tx_status(struct net_device_stats *stats,
 	return ret;
 }
 
-static int enh_desc_get_tx_len(struct dma_desc *p)
+static int enh_desc_get_tx_len(struct stmmac_priv *priv, struct dma_desc *p)
 {
 	return (le32_to_cpu(p->des1) & ETDES1_BUFFER1_SIZE_MASK);
 }
@@ -255,8 +255,8 @@ static int enh_desc_get_rx_status(struct net_device_stats *stats,
 	return ret;
 }
 
-static void enh_desc_init_rx_desc(struct dma_desc *p, int disable_rx_ic,
-				  int mode, int end, int bfsize)
+static void enh_desc_init_rx_desc(struct stmmac_priv *priv, struct dma_desc *p,
+				  int disable_rx_ic, int mode, int end, int bfsize)
 {
 	int bfsize1;
 
@@ -314,9 +314,9 @@ static void enh_desc_release_tx_desc(struct dma_desc *p, int mode)
 		enh_desc_end_tx_desc_on_ring(p, ter);
 }
 
-static void enh_desc_prepare_tx_desc(struct dma_desc *p, int is_fs, int len,
-				     bool csum_flag, int mode, bool tx_own,
-				     bool ls, unsigned int tot_pkt_len)
+static void enh_desc_prepare_tx_desc(struct stmmac_priv *priv, struct dma_desc *p,
+				     int is_fs, int len, bool csum_flag, int mode,
+				     bool tx_own, bool ls, unsigned int tot_pkt_len)
 {
 	unsigned int tdes0 = le32_to_cpu(p->des0);
 
@@ -441,12 +441,13 @@ static void enh_desc_display_ring(void *head, unsigned int size, bool rx,
 	pr_info("\n");
 }
 
-static void enh_desc_set_addr(struct dma_desc *p, dma_addr_t addr)
+static void enh_desc_set_addr(struct stmmac_priv *priv, struct dma_desc *p,
+			      dma_addr_t addr)
 {
 	p->des2 = cpu_to_le32(addr);
 }
 
-static void enh_desc_clear(struct dma_desc *p)
+static void enh_desc_clear(struct stmmac_priv *priv, struct dma_desc *p)
 {
 	p->des2 = 0;
 }
drivers/net/ethernet/stmicro/stmmac/hwif.h +42 -35

215 lines not on this page · raw message

drivers/net/ethernet/stmicro/stmmac/norm_desc.c +9 -8
index 350e6670a576..22b8f27edfab 100644
@@ -61,7 +61,7 @@ static int ndesc_get_tx_status(struct net_device_stats *stats,
 	return ret;
 }
 
-static int ndesc_get_tx_len(struct dma_desc *p)
+static int ndesc_get_tx_len(struct stmmac_priv *priv, struct dma_desc *p)
 {
 	return (le32_to_cpu(p->des1) & RDES1_BUFFER1_SIZE_MASK);
 }
@@ -122,8 +122,8 @@ static int ndesc_get_rx_status(struct net_device_stats *stats,
 	return ret;
 }
 
-static void ndesc_init_rx_desc(struct dma_desc *p, int disable_rx_ic, int mode,
-			       int end, int bfsize)
+static void ndesc_init_rx_desc(struct stmmac_priv *priv, struct dma_desc *p,
+			       int disable_rx_ic, int mode, int end, int bfsize)
 {
 	int bfsize1;
 
@@ -181,9 +181,9 @@ static void ndesc_release_tx_desc(struct dma_desc *p, int mode)
 		ndesc_end_tx_desc_on_ring(p, ter);
 }
 
-static void ndesc_prepare_tx_desc(struct dma_desc *p, int is_fs, int len,
-				  bool csum_flag, int mode, bool tx_own,
-				  bool ls, unsigned int tot_pkt_len)
+static void ndesc_prepare_tx_desc(struct stmmac_priv *priv, struct dma_desc *p,
+				  int is_fs, int len, bool csum_flag, int mode,
+				  bool tx_own, bool ls, unsigned int tot_pkt_len)
 {
 	unsigned int tdes1 = le32_to_cpu(p->des1);
 
@@ -292,12 +292,13 @@ static void ndesc_display_ring(void *head, unsigned int size, bool rx,
 	pr_info("\n");
 }
 
-static void ndesc_set_addr(struct dma_desc *p, dma_addr_t addr)
+static void ndesc_set_addr(struct stmmac_priv *priv, struct dma_desc *p,
+			   dma_addr_t addr)
 {
 	p->des2 = cpu_to_le32(addr);
 }
 
-static void ndesc_clear(struct dma_desc *p)
+static void ndesc_clear(struct stmmac_priv *priv, struct dma_desc *p)
 {
 	p->des2 = 0;
 }
drivers/net/ethernet/stmicro/stmmac/ring_mode.c +2 -2
index d218412ca832..49dd6ea07416 100644
@@ -111,7 +111,7 @@ static void refill_desc3(struct stmmac_rx_queue *rx_q, struct dma_desc *p)
 }
 
 /* In ring mode we need to fill the desc3 because it is used as buffer */
-static void init_desc3(struct dma_desc *p)
+static void init_desc3(struct stmmac_priv *priv, struct dma_desc *p)
 {
 	p->des3 = cpu_to_le32(le32_to_cpu(p->des2) + BUF_SIZE_8KiB);
 }
@@ -128,7 +128,7 @@ static void clean_desc3(struct stmmac_tx_queue *tx_q, struct dma_desc *p)
 		p->des3 = 0;
 }
 
-static int set_16kib_bfsize(int mtu)
+static int set_16kib_bfsize(struct stmmac_priv *priv, int mtu)
 {
 	int ret = 0;
 	if (unlikely(mtu > BUF_SIZE_8KiB))
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +3 -3
index 1bd8f69d7be4..2e95568b1e4a 100644
@@ -2488,7 +2488,7 @@ static bool stmmac_xdp_xmit_zc(struct stmmac_priv *priv, u32 queue, u32 budget)
 				       true, priv->mode, true, true,
 				       xdp_desc.len);
 
-		stmmac_enable_dma_transmission(priv, priv->ioaddr);
+		stmmac_enable_dma_transmission(priv, priv->ioaddr, queue);
 
 		tx_q->cur_tx = STMMAC_GET_ENTRY(tx_q->cur_tx, priv->dma_conf.dma_tx_size);
 		entry = tx_q->cur_tx;
@@ -4547,7 +4547,7 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
 
 	netdev_tx_sent_queue(netdev_get_tx_queue(dev, queue), skb->len);
 
-	stmmac_enable_dma_transmission(priv, priv->ioaddr);
+	stmmac_enable_dma_transmission(priv, priv->ioaddr, queue);
 
 	stmmac_flush_tx_descriptors(priv, queue);
 	stmmac_tx_timer_arm(priv, queue);
@@ -4763,7 +4763,7 @@ static int stmmac_xdp_xmit_xdpf(struct stmmac_priv *priv, int queue,
 		priv->xstats.tx_set_ic_bit++;
 	}
 
-	stmmac_enable_dma_transmission(priv, priv->ioaddr);
+	stmmac_enable_dma_transmission(priv, priv->ioaddr, queue);
 
 	entry = STMMAC_GET_ENTRY(entry, priv->dma_conf.dma_tx_size);
 	tx_q->cur_tx = entry;
Signature · 1 line
2.39.3
maintainer
#14 lore raw

Re: [RFC PATCH 02/10] net: stmmac: Pass stmmac_priv and chan in some callbacks

Quoted 3 lines · Feiyang Chen

Like commit 1d84b487bc2d90 ("net: stmmac: Pass stmmac_priv in some callbacks"), passing stmmac_priv and chan to more callbacks and adjust the callbacks accordingly.

Commit messages don't say what a patch does, you can see that from reading the patch. The commit message should explain why it is doing something.

Andrew

#15 lore raw

Re: [RFC PATCH 02/10] net: stmmac: Pass stmmac_priv and chan in some callbacks

Quoted 10 lines · Andrew Lunn
Quoted 3 lines · Feiyang Chen

Like commit 1d84b487bc2d90 ("net: stmmac: Pass stmmac_priv in some callbacks"), passing stmmac_priv and chan to more callbacks and adjust the callbacks accordingly.

Commit messages don't say what a patch does, you can see that from reading the patch. The commit message should explain why it is doing something.

Hi, Andrew,

Alright, I will make improvements in the next version.

Thanks,
Feiyang

Quoted 1 line

Andrew

#16 lore raw

RFC PATCH 3/10 net: stmmac: dwmac1000: Allow platforms to choose some register offsets

In reply to Feiyang Chen

Some platforms have dwmac1000 implementations that have a different address space layout than the default. Extend the macro to allow a platform driver to choose the appropriate register offsets.

---
 .../ethernet/stmicro/stmmac/dwmac1000_core.c  |  14 +-
 .../ethernet/stmicro/stmmac/dwmac100_core.c   |   3 +
 .../net/ethernet/stmicro/stmmac/dwmac_dma.h   | 205 +++++++++---------
 .../net/ethernet/stmicro/stmmac/dwmac_lib.c   |  41 ++++
 include/linux/stmmac.h                        |  48 ++++
 5 files changed, 210 insertions(+), 101 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +11 -3
index b52793edf62f..9015a61f804c 100644
@@ -19,6 +19,7 @@
 #include "stmmac.h"
 #include "stmmac_pcs.h"
 #include "dwmac1000.h"
+#include "dwmac_dma.h"
 
 static void dwmac1000_core_init(struct mac_device_info *hw,
 				struct net_device *dev)
@@ -527,12 +528,10 @@ const struct stmmac_ops dwmac1000_ops = {
 	.set_mac_loopback = dwmac1000_set_mac_loopback,
 };
 
-int dwmac1000_setup(struct stmmac_priv *priv)
+static int _dwmac1000_setup(struct stmmac_priv *priv)
 {
 	struct mac_device_info *mac = priv->hw;
 
-	dev_info(priv->device, "\tDWMAC1000\n");
-
 	priv->dev->priv_flags |= IFF_UNICAST_FLT;
 	mac->pcsr = priv->ioaddr;
 	mac->multicast_filter_bins = priv->plat->multicast_filter_bins;
@@ -558,3 +557,12 @@ int dwmac1000_setup(struct stmmac_priv *priv)
 
 	return 0;
 }
+
+int dwmac1000_setup(struct stmmac_priv *priv)
+{
+	dev_info(priv->device, "\tDWMAC1000\n");
+
+	priv->plat->dwmac_regs = &dwmac_default_dma_regs;
+
+	return _dwmac1000_setup(priv);
+}
drivers/net/ethernet/stmicro/stmmac/dwmac100_core.c +3 -0
index c03623edeb75..73ee16549775 100644
@@ -18,6 +18,7 @@
 #include <asm/io.h>
 #include "stmmac.h"
 #include "dwmac100.h"
+#include "dwmac_dma.h"
 
 static void dwmac100_core_init(struct mac_device_info *hw,
 			       struct net_device *dev)
@@ -177,6 +178,8 @@ int dwmac100_setup(struct stmmac_priv *priv)
 
 	dev_info(priv->device, "\tDWMAC100\n");
 
+	priv->plat->dwmac_regs = &dwmac_default_dma_regs;
+
 	mac->pcsr = priv->ioaddr;
 	mac->link.duplex = MAC_CONTROL_F;
 	mac->link.speed10 = 0;
drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h +107 -98

241 lines not on this page · raw message

drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c +41 -0

47 lines not on this page · raw message

include/linux/stmmac.h +48 -0

59 lines not on this page · raw message

Signature · 1 line
2.39.3
#17 lore raw

RFC PATCH 4/10 net: stmmac: dwmac1000: Add multi-channel support

In reply to Feiyang Chen

Some platforms have dwmac1000 implementations that support multi- channel. Extend the functions to add multi-channel support.

---
 .../ethernet/stmicro/stmmac/dwmac1000_core.c  |  1 +
 .../ethernet/stmicro/stmmac/dwmac1000_dma.c   | 64 +++++++++++++++++--
 .../net/ethernet/stmicro/stmmac/dwmac_lib.c   | 28 ++++----
 include/linux/stmmac.h                        |  1 +
 4 files changed, 73 insertions(+), 21 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +1 -0
index 9015a61f804c..a9b42a122ed6 100644
@@ -562,6 +562,7 @@ int dwmac1000_setup(struct stmmac_priv *priv)
 {
 	dev_info(priv->device, "\tDWMAC1000\n");
 
+	priv->plat->dwmac_is_loongson = false;
 	priv->plat->dwmac_regs = &dwmac_default_dma_regs;
 
 	return _dwmac1000_setup(priv);
drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c +57 -7

117 lines not on this page · raw message

drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c +14 -14
index 266f64148c1a..99838497b183 100644
@@ -71,63 +71,63 @@ int dwmac_dma_reset(void __iomem *ioaddr)
 void dwmac_enable_dma_transmission(struct stmmac_priv *priv,
 				   void __iomem *ioaddr, u32 chan)
 {
-	writel(1, ioaddr + DMA_XMT_POLL_DEMAND);
+	writel(1, ioaddr + DMA_XMT_POLL_DEMAND + chan * DMA_CHAN_OFFSET);
 }
 
 void dwmac_enable_dma_irq(struct stmmac_priv *priv, void __iomem *ioaddr,
 			  u32 chan, bool rx, bool tx)
 {
-	u32 value = readl(ioaddr + DMA_INTR_ENA);
+	u32 value = readl(ioaddr + DMA_INTR_ENA + chan * DMA_CHAN_OFFSET);
 
 	if (rx)
 		value |= DMA_INTR_DEFAULT_RX;
 	if (tx)
 		value |= DMA_INTR_DEFAULT_TX;
 
-	writel(value, ioaddr + DMA_INTR_ENA);
+	writel(value, ioaddr + DMA_INTR_ENA + chan * DMA_CHAN_OFFSET);
 }
 
 void dwmac_disable_dma_irq(struct stmmac_priv *priv, void __iomem *ioaddr,
 			   u32 chan, bool rx, bool tx)
 {
-	u32 value = readl(ioaddr + DMA_INTR_ENA);
+	u32 value = readl(ioaddr + DMA_INTR_ENA + chan * DMA_CHAN_OFFSET);
 
 	if (rx)
 		value &= ~DMA_INTR_DEFAULT_RX;
 	if (tx)
 		value &= ~DMA_INTR_DEFAULT_TX;
 
-	writel(value, ioaddr + DMA_INTR_ENA);
+	writel(value, ioaddr + DMA_INTR_ENA + chan * DMA_CHAN_OFFSET);
 }
 
 void dwmac_dma_start_tx(struct stmmac_priv *priv, void __iomem *ioaddr,
 			u32 chan)
 {
-	u32 value = readl(ioaddr + DMA_CONTROL);
+	u32 value = readl(ioaddr + DMA_CONTROL + chan * DMA_CHAN_OFFSET);
 	value |= DMA_CONTROL_ST;
-	writel(value, ioaddr + DMA_CONTROL);
+	writel(value, ioaddr + DMA_CONTROL + chan * DMA_CHAN_OFFSET);
 }
 
 void dwmac_dma_stop_tx(struct stmmac_priv *priv, void __iomem *ioaddr, u32 chan)
 {
-	u32 value = readl(ioaddr + DMA_CONTROL);
+	u32 value = readl(ioaddr + DMA_CONTROL + chan * DMA_CHAN_OFFSET);
 	value &= ~DMA_CONTROL_ST;
-	writel(value, ioaddr + DMA_CONTROL);
+	writel(value, ioaddr + DMA_CONTROL + chan * DMA_CHAN_OFFSET);
 }
 
 void dwmac_dma_start_rx(struct stmmac_priv *priv, void __iomem *ioaddr,
 			u32 chan)
 {
-	u32 value = readl(ioaddr + DMA_CONTROL);
+	u32 value = readl(ioaddr + DMA_CONTROL + chan * DMA_CHAN_OFFSET);
 	value |= DMA_CONTROL_SR;
-	writel(value, ioaddr + DMA_CONTROL);
+	writel(value, ioaddr + DMA_CONTROL + chan * DMA_CHAN_OFFSET);
 }
 
 void dwmac_dma_stop_rx(struct stmmac_priv *priv, void __iomem *ioaddr, u32 chan)
 {
-	u32 value = readl(ioaddr + DMA_CONTROL);
+	u32 value = readl(ioaddr + DMA_CONTROL + chan * DMA_CHAN_OFFSET);
 	value &= ~DMA_CONTROL_SR;
-	writel(value, ioaddr + DMA_CONTROL);
+	writel(value, ioaddr + DMA_CONTROL + chan * DMA_CHAN_OFFSET);
 }
 
 #ifdef DWMAC_DMA_DEBUG
@@ -205,7 +205,7 @@ int dwmac_dma_interrupt(struct stmmac_priv *priv, void __iomem *ioaddr,
 {
 	int ret = 0;
 	/* read the status register (CSR5) */
-	u32 intr_status = readl(ioaddr + DMA_STATUS);
+	u32 intr_status = readl(ioaddr + DMA_STATUS + chan * DMA_CHAN_OFFSET);
 
 #ifdef DWMAC_DMA_DEBUG
 	/* Enable it to monitor DMA rx/tx status in case of critical problems */
include/linux/stmmac.h +1 -0
index eafe85e45977..ff539681a3a4 100644
@@ -340,6 +340,7 @@ struct plat_stmmacenet_data {
 	bool sph_disable;
 	bool serdes_up_after_phy_linkup;
 	const struct dwmac4_addrs *dwmac4_addrs;
+	bool dwmac_is_loongson;
 	const struct dwmac_regs *dwmac_regs;
 };
 #endif
Signature · 1 line
2.39.3
#18 lore raw

RFC PATCH 5/10 net: stmmac: dwmac1000: Add 64-bit DMA support

In reply to Feiyang Chen

Some platforms have dwmac1000 implementations that support 64-bit DMA. Extend the functions to add 64-bit DMA support.

---
 .../net/ethernet/stmicro/stmmac/chain_mode.c  |  23 +++-
 drivers/net/ethernet/stmicro/stmmac/descs.h   |   7 ++
 .../net/ethernet/stmicro/stmmac/descs_com.h   |  49 ++++++---
 .../ethernet/stmicro/stmmac/dwmac1000_dma.c   |  30 ++++--
 .../net/ethernet/stmicro/stmmac/enh_desc.c    |  21 +++-
 .../net/ethernet/stmicro/stmmac/ring_mode.c   | 101 ++++++++++++++----
 include/linux/stmmac.h                        |   1 +
 7 files changed, 183 insertions(+), 49 deletions(-)
drivers/net/ethernet/stmicro/stmmac/chain_mode.c +21 -2
index a95866871f3e..c8d77cbd51bc 100644
@@ -36,6 +36,9 @@ static int jumbo_frm(struct stmmac_tx_queue *tx_q, struct sk_buff *skb,
 	des2 = dma_map_single(priv->device, skb->data,
 			      bmax, DMA_TO_DEVICE);
 	desc->des2 = cpu_to_le32(des2);
+	if (priv->plat->dma_cfg->dma64)
+		desc->des3 = cpu_to_le32(upper_32_bits(des2));
+
 	if (dma_mapping_error(priv->device, des2))
 		return -1;
 	tx_q->tx_skbuff_dma[entry].buf = des2;
@@ -54,12 +57,16 @@ static int jumbo_frm(struct stmmac_tx_queue *tx_q, struct sk_buff *skb,
 					      (skb->data + bmax * i),
 					      bmax, DMA_TO_DEVICE);
 			desc->des2 = cpu_to_le32(des2);
+			if (priv->plat->dma_cfg->dma64)
+				desc->des3 = cpu_to_le32(upper_32_bits(des2));
 			if (dma_mapping_error(priv->device, des2))
 				return -1;
 			tx_q->tx_skbuff_dma[entry].buf = des2;
 			tx_q->tx_skbuff_dma[entry].len = bmax;
 			stmmac_prepare_tx_desc(priv, desc, 0, bmax, csum,
-					STMMAC_CHAIN_MODE, 1, false, skb->len);
+					       STMMAC_CHAIN_MODE,
+					       !priv->plat->dma_cfg->dma64,
+					       false, skb->len);
 			len -= bmax;
 			i++;
 		} else {
@@ -67,6 +74,8 @@ static int jumbo_frm(struct stmmac_tx_queue *tx_q, struct sk_buff *skb,
 					      (skb->data + bmax * i), len,
 					      DMA_TO_DEVICE);
 			desc->des2 = cpu_to_le32(des2);
+			if (priv->plat->dma_cfg->dma64)
+				desc->des3 = cpu_to_le32(upper_32_bits(des2));
 			if (dma_mapping_error(priv->device, des2))
 				return -1;
 			tx_q->tx_skbuff_dma[entry].buf = des2;
@@ -110,7 +119,11 @@ static void init_dma_chain(struct stmmac_priv *priv, void *des,
 		struct dma_extended_desc *p = (struct dma_extended_desc *)des;
 		for (i = 0; i < (size - 1); i++) {
 			dma_phy += sizeof(struct dma_extended_desc);
-			p->basic.des3 = cpu_to_le32((unsigned int)dma_phy);
+			if (priv->plat->dma_cfg->dma64) {
+				p->des6 = cpu_to_le32((unsigned int)dma_phy);
+				p->des7 = cpu_to_le32(upper_32_bits(dma_phy));
+			} else
+				p->basic.des3 = cpu_to_le32((unsigned int)dma_phy);
 			p++;
 		}
 		p->basic.des3 = cpu_to_le32((unsigned int)phy_addr);
@@ -130,6 +143,9 @@ static void refill_desc3(struct stmmac_rx_queue *rx_q, struct dma_desc *p)
 {
 	struct stmmac_priv *priv = rx_q->priv_data;
 
+	if (priv->plat->dma_cfg->dma64)
+		return;
+
 	if (priv->hwts_rx_en && !priv->extend_desc)
 		/* NOTE: Device will overwrite des3 with timestamp value if
 		 * 1588-2002 time stamping is enabled, hence reinitialize it
@@ -146,6 +162,9 @@ static void clean_desc3(struct stmmac_tx_queue *tx_q, struct dma_desc *p)
 	struct stmmac_priv *priv = tx_q->priv_data;
 	unsigned int entry = tx_q->dirty_tx;
 
+	if (priv->plat->dma_cfg->dma64)
+		return;
+
 	if (tx_q->tx_skbuff_dma[entry].last_segment && !priv->extend_desc &&
 	    priv->hwts_tx_en)
 		/* NOTE: Device will overwrite des3 with timestamp value if
drivers/net/ethernet/stmicro/stmmac/descs.h +7 -0
index 49d6a866244f..223b77f0271c 100644
@@ -56,6 +56,9 @@
 #define ERDES1_BUFFER2_SIZE_SHIFT	16
 #define	ERDES1_DISABLE_IC		BIT(31)
 
+#define	E64RDES1_BUFFER1_SIZE_MASK	GENMASK(13, 0)
+#define	E64RDES1_BUFFER2_SIZE_MASK	GENMASK(29, 16)
+
 /* Normal transmit descriptor defines */
 /* TDES0 */
 #define	TDES0_DEFERRED			BIT(0)
@@ -122,6 +125,10 @@
 #define	ETDES1_BUFFER2_SIZE_MASK	GENMASK(28, 16)
 #define	ETDES1_BUFFER2_SIZE_SHIFT	16
 
+#define	E64TDES1_BUFFER1_SIZE_MASK	GENMASK(13, 0)
+#define	E64TDES1_BUFFER2_SIZE_MASK	GENMASK(28, 15)
+#define	E64TDES1_BUFFER2_SIZE_SHIFT	15
+
 /* Extended Receive descriptor definitions */
 #define	ERDES4_IP_PAYLOAD_TYPE_MASK	GENMASK(6, 2)
 #define	ERDES4_IP_HDR_ERR		BIT(3)
drivers/net/ethernet/stmicro/stmmac/descs_com.h +35 -14

71 lines not on this page · raw message

drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c +24 -6
index efb219999a20..632c4f110d01 100644
@@ -15,6 +15,7 @@
 #include <asm/io.h>
 #include "dwmac1000.h"
 #include "dwmac_dma.h"
+#include "stmmac.h"
 
 static void dwmac1000_dma_axi(struct stmmac_priv *priv, void __iomem *ioaddr,
 			      struct stmmac_axi *axi)
@@ -109,6 +110,9 @@ static void dwmac1000_dma_init(struct stmmac_priv *priv, void __iomem *ioaddr,
 
 	/* Mask interrupts by writing to CSR7 */
 	writel(DMA_INTR_DEFAULT_MASK, ioaddr + DMA_INTR_ENA);
+
+	if (dma_cfg->dma64)
+		writel(0x100, ioaddr + DMA_FUNC_CONFIG);
 }
 
 void dwmac1000_dma_init_channel(struct stmmac_priv *priv, void __iomem *ioaddr,
@@ -163,9 +167,16 @@ static void dwmac1000_dma_init_rx(struct stmmac_priv *priv,
 				  struct stmmac_dma_cfg *dma_cfg,
 				  dma_addr_t dma_rx_phy, u32 chan)
 {
-	/* RX descriptor base address list must be written into DMA CSR3 */
-	writel(lower_32_bits(dma_rx_phy), ioaddr + DMA_RCV_BASE_ADDR +
-		chan * DMA_CHAN_OFFSET);
+	if (dma_cfg->dma64) {
+		writel(lower_32_bits(dma_rx_phy), ioaddr + DMA_RCV_BASE_ADDR +
+		       chan * DMA_CHAN_OFFSET);
+		writel(upper_32_bits(dma_rx_phy), ioaddr + DMA_RCV_BASE_ADDR_HI +
+		       chan * DMA_CHAN_OFFSET);
+	} else {
+		/* RX descriptor base address list must be written into DMA CSR3 */
+		writel(lower_32_bits(dma_rx_phy), ioaddr + DMA_RCV_BASE_ADDR +
+		       chan * DMA_CHAN_OFFSET);
+	}
 }
 
 static void dwmac1000_dma_init_tx(struct stmmac_priv *priv,
@@ -173,9 +184,16 @@ static void dwmac1000_dma_init_tx(struct stmmac_priv *priv,
 				  struct stmmac_dma_cfg *dma_cfg,
 				  dma_addr_t dma_tx_phy, u32 chan)
 {
-	/* TX descriptor base address list must be written into DMA CSR4 */
-	writel(lower_32_bits(dma_tx_phy), ioaddr + DMA_TX_BASE_ADDR +
-		chan * DMA_CHAN_OFFSET);
+	if (dma_cfg->dma64) {
+		writel(lower_32_bits(dma_tx_phy), ioaddr + DMA_TX_BASE_ADDR +
+		       chan * DMA_CHAN_OFFSET);
+		writel(upper_32_bits(dma_tx_phy), ioaddr + DMA_TX_BASE_ADDR_HI +
+		       chan * DMA_CHAN_OFFSET);
+	} else {
+		/* TX descriptor base address list must be written into DMA CSR4 */
+		writel(lower_32_bits(dma_tx_phy), ioaddr + DMA_TX_BASE_ADDR +
+		       chan * DMA_CHAN_OFFSET);
+	}
 }
 
 static u32 dwmac1000_configure_fc(u32 csr6, int rxfifosz)
drivers/net/ethernet/stmicro/stmmac/enh_desc.c +16 -5
index 1932a3a8e03c..ee07006c97c1 100644
@@ -11,6 +11,7 @@
 #include <linux/stmmac.h>
 #include "common.h"
 #include "descs_com.h"
+#include "stmmac.h"
 
 static int enh_desc_get_tx_status(struct net_device_stats *stats,
 				  struct stmmac_extra_stats *x,
@@ -81,7 +82,10 @@ static int enh_desc_get_tx_status(struct net_device_stats *stats,
 
 static int enh_desc_get_tx_len(struct stmmac_priv *priv, struct dma_desc *p)
 {
-	return (le32_to_cpu(p->des1) & ETDES1_BUFFER1_SIZE_MASK);
+	if (priv->plat->dma_cfg->dma64)
+		return (le32_to_cpu(p->des1) & E64TDES1_BUFFER1_SIZE_MASK);
+	else
+		return (le32_to_cpu(p->des1) & ETDES1_BUFFER1_SIZE_MASK);
 }
 
 static int enh_desc_coe_rdes0(int ipc_err, int type, int payload_err)
@@ -263,12 +267,15 @@ static void enh_desc_init_rx_desc(struct stmmac_priv *priv, struct dma_desc *p,
 	p->des0 |= cpu_to_le32(RDES0_OWN);
 
 	bfsize1 = min(bfsize, BUF_SIZE_8KiB);
-	p->des1 |= cpu_to_le32(bfsize1 & ERDES1_BUFFER1_SIZE_MASK);
+	if (priv->plat->dma_cfg->dma64)
+		p->des1 |= cpu_to_le32(bfsize1 & E64RDES1_BUFFER1_SIZE_MASK);
+	else
+		p->des1 |= cpu_to_le32(bfsize1 & ERDES1_BUFFER1_SIZE_MASK);
 
 	if (mode == STMMAC_CHAIN_MODE)
 		ehn_desc_rx_set_on_chain(p);
 	else
-		ehn_desc_rx_set_on_ring(p, end, bfsize);
+		ehn_desc_rx_set_on_ring(p, end, bfsize, priv->plat->dma_cfg->dma64);
 
 	if (disable_rx_ic)
 		p->des1 |= cpu_to_le32(ERDES1_DISABLE_IC);
@@ -321,9 +328,9 @@ static void enh_desc_prepare_tx_desc(struct stmmac_priv *priv, struct dma_desc *
 	unsigned int tdes0 = le32_to_cpu(p->des0);
 
 	if (mode == STMMAC_CHAIN_MODE)
-		enh_set_tx_desc_len_on_chain(p, len);
+		enh_set_tx_desc_len_on_chain(p, len, priv->plat->dma_cfg->dma64);
 	else
-		enh_set_tx_desc_len_on_ring(p, len);
+		enh_set_tx_desc_len_on_ring(p, len, priv->plat->dma_cfg->dma64);
 
 	if (is_fs)
 		tdes0 |= ETDES0_FIRST_SEGMENT;
@@ -445,11 +452,15 @@ static void enh_desc_set_addr(struct stmmac_priv *priv, struct dma_desc *p,
 			      dma_addr_t addr)
 {
 	p->des2 = cpu_to_le32(addr);
+	if (priv->plat->dma_cfg->dma64)
+		p->des3 = cpu_to_le32(upper_32_bits(addr));
 }
 
 static void enh_desc_clear(struct stmmac_priv *priv, struct dma_desc *p)
 {
 	p->des2 = 0;
+	if (priv->plat->dma_cfg->dma64)
+		p->des3 = 0;
 }
 
 const struct stmmac_desc_ops enh_desc_ops = {
drivers/net/ethernet/stmicro/stmmac/ring_mode.c +79 -22

169 lines not on this page · raw message

include/linux/stmmac.h +1 -0
index ff539681a3a4..f9af24f760d4 100644
@@ -98,6 +98,7 @@ struct stmmac_dma_cfg {
 	bool eame;
 	bool multi_msi_en;
 	bool dche;
+	bool dma64;
 };
 
 #define AXI_BLEN	7
Signature · 1 line
2.39.3
#19 lore raw

RFC PATCH 6/10 net: stmmac: dwmac1000: Add Loongson register definitions

In reply to Feiyang Chen

Add definitions for Loongson platform.

---
 .../net/ethernet/stmicro/stmmac/dwmac1000.h   |  4 +-
 .../ethernet/stmicro/stmmac/dwmac1000_core.c  | 43 +++++++---
 .../ethernet/stmicro/stmmac/dwmac1000_dma.c   | 10 ++-
 .../net/ethernet/stmicro/stmmac/dwmac_dma.h   |  2 +
 .../net/ethernet/stmicro/stmmac/dwmac_lib.c   | 84 +++++++++++++++++--
 5 files changed, 119 insertions(+), 24 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac1000.h +2 -2
index 4296ddda8aaa..f827bf8f30a9 100644
@@ -76,9 +76,9 @@ enum power_event {
 #define LPI_CTRL_STATUS_TLPIEN	0x00000001	/* Transmit LPI Entry */
 
 /* GMAC HW ADDR regs */
-#define GMAC_ADDR_HIGH(reg)	((reg > 15) ? 0x00000800 + (reg - 16) * 8 : \
+#define GMAC_ADDR_HIGH(reg, x)	((reg > 15) ? 0x00000800 + (reg - 16) * 8 * (x) : \
 				 0x00000040 + (reg * 8))
-#define GMAC_ADDR_LOW(reg)	((reg > 15) ? 0x00000804 + (reg - 16) * 8 : \
+#define GMAC_ADDR_LOW(reg, x)	((reg > 15) ? 0x00000804 + (reg - 16) * 8 * (x) : \
 				 0x00000044 + (reg * 8))
 #define GMAC_MAX_PERFECT_ADDRESSES	1
 
drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +32 -11

97 lines not on this page · raw message

drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c +8 -2
index 632c4f110d01..7aa450d6a81a 100644
@@ -329,8 +329,14 @@ static int dwmac1000_get_hw_feature(struct stmmac_priv *priv,
 	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;
+	if (priv->plat->dwmac_is_loongson &&
+	    ((hw_cap & (DMA_HW_FEAT_RXCHCNT | DMA_HW_FEAT_TXCHCNT)) >> 20) == 0) {
+		dma_cap->number_rx_channel = 8;
+		dma_cap->number_tx_channel = 8;
+	} else {
+		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;
 
drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h +2 -0
index 915a4d70fd3b..3828902baa80 100644
@@ -160,6 +160,8 @@
 #define NUM_DWMAC4_DMA_REGS	27
 
 extern const struct dwmac_regs dwmac_default_dma_regs;
+extern const struct dwmac_regs dwmac_loongson_dma_regs;
+extern const struct dwmac_regs dwmac_loongson64_dma_regs;
 
 void dwmac_enable_dma_transmission(struct stmmac_priv *priv,
 				   void __iomem *ioaddr, u32 chan);
drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c +75 -9

127 lines not on this page · raw message

Signature · 1 line
2.39.3
#20 lore raw

RFC PATCH 7/10 net: stmmac: Add Loongson HWIF entry

In reply to Feiyang Chen

Add a new entry to HWIF table for Loongson.

---
 drivers/net/ethernet/stmicro/stmmac/common.h  |  3 ++
 .../ethernet/stmicro/stmmac/dwmac1000_dma.c   |  6 +++
 drivers/net/ethernet/stmicro/stmmac/hwif.c    | 48 ++++++++++++++++++-
 .../net/ethernet/stmicro/stmmac/stmmac_main.c | 25 ++++++----
 include/linux/stmmac.h                        |  1 +
 5 files changed, 73 insertions(+), 10 deletions(-)
drivers/net/ethernet/stmicro/stmmac/common.h +3 -0
index 4ad692c4116c..45c49c7a9ccb 100644
@@ -29,11 +29,13 @@
 /* Synopsys Core versions */
 #define	DWMAC_CORE_3_40		0x34
 #define	DWMAC_CORE_3_50		0x35
+#define	DWMAC_CORE_3_70		0x37
 #define	DWMAC_CORE_4_00		0x40
 #define DWMAC_CORE_4_10		0x41
 #define DWMAC_CORE_5_00		0x50
 #define DWMAC_CORE_5_10		0x51
 #define DWMAC_CORE_5_20		0x52
+#define DWLGMAC_CORE_1_00	0x10
 #define DWXGMAC_CORE_2_10	0x21
 #define DWXLGMAC_CORE_2_00	0x20
 
@@ -546,6 +548,7 @@ int dwmac1000_setup(struct stmmac_priv *priv);
 int dwmac4_setup(struct stmmac_priv *priv);
 int dwxgmac2_setup(struct stmmac_priv *priv);
 int dwxlgmac2_setup(struct stmmac_priv *priv);
+int dwmac_loongson_setup(struct stmmac_priv *priv);
 
 void stmmac_set_mac_addr(void __iomem *ioaddr, const u8 addr[6],
 			 unsigned int high, unsigned int low);
drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c +6 -0
index 7aa450d6a81a..5da5f111d7e0 100644
@@ -172,6 +172,12 @@ static void dwmac1000_dma_init_rx(struct stmmac_priv *priv,
 		       chan * DMA_CHAN_OFFSET);
 		writel(upper_32_bits(dma_rx_phy), ioaddr + DMA_RCV_BASE_ADDR_HI +
 		       chan * DMA_CHAN_OFFSET);
+		if (priv->plat->has_lgmac) {
+			writel(upper_32_bits(dma_rx_phy),
+			       ioaddr + DMA_RCV_BASE_ADDR_SHADOW1);
+			writel(upper_32_bits(dma_rx_phy),
+			       ioaddr + DMA_RCV_BASE_ADDR_SHADOW2);
+		}
 	} else {
 		/* RX descriptor base address list must be written into DMA CSR3 */
 		writel(lower_32_bits(dma_rx_phy), ioaddr + DMA_RCV_BASE_ADDR +
drivers/net/ethernet/stmicro/stmmac/hwif.c +47 -1

114 lines not on this page · raw message

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +16 -9
index 2e95568b1e4a..59e9b61315bb 100644
@@ -3494,17 +3494,21 @@ static int stmmac_request_irq_multi_msi(struct net_device *dev)
 {
 	struct stmmac_priv *priv = netdev_priv(dev);
 	enum request_irq_err irq_err;
+	unsigned long flags = 0;
 	cpumask_t cpu_mask;
 	int irq_idx = 0;
 	char *int_name;
 	int ret;
 	int i;
 
+	if (priv->plat->has_lgmac)
+		flags |= IRQF_TRIGGER_RISING;
+
 	/* For common interrupt */
 	int_name = priv->int_name_mac;
 	sprintf(int_name, "%s:%s", dev->name, "mac");
 	ret = request_irq(dev->irq, stmmac_mac_interrupt,
-			  0, int_name, dev);
+			  flags, int_name, dev);
 	if (unlikely(ret < 0)) {
 		netdev_err(priv->dev,
 			   "%s: alloc mac MSI %d (error: %d)\n",
@@ -3521,7 +3525,7 @@ static int stmmac_request_irq_multi_msi(struct net_device *dev)
 		sprintf(int_name, "%s:%s", dev->name, "wol");
 		ret = request_irq(priv->wol_irq,
 				  stmmac_mac_interrupt,
-				  0, int_name, dev);
+				  flags, int_name, dev);
 		if (unlikely(ret < 0)) {
 			netdev_err(priv->dev,
 				   "%s: alloc wol MSI %d (error: %d)\n",
@@ -3539,7 +3543,7 @@ static int stmmac_request_irq_multi_msi(struct net_device *dev)
 		sprintf(int_name, "%s:%s", dev->name, "lpi");
 		ret = request_irq(priv->lpi_irq,
 				  stmmac_mac_interrupt,
-				  0, int_name, dev);
+				  flags, int_name, dev);
 		if (unlikely(ret < 0)) {
 			netdev_err(priv->dev,
 				   "%s: alloc lpi MSI %d (error: %d)\n",
@@ -3557,7 +3561,7 @@ static int stmmac_request_irq_multi_msi(struct net_device *dev)
 		sprintf(int_name, "%s:%s", dev->name, "safety-ce");
 		ret = request_irq(priv->sfty_ce_irq,
 				  stmmac_safety_interrupt,
-				  0, int_name, dev);
+				  flags, int_name, dev);
 		if (unlikely(ret < 0)) {
 			netdev_err(priv->dev,
 				   "%s: alloc sfty ce MSI %d (error: %d)\n",
@@ -3575,7 +3579,7 @@ static int stmmac_request_irq_multi_msi(struct net_device *dev)
 		sprintf(int_name, "%s:%s", dev->name, "safety-ue");
 		ret = request_irq(priv->sfty_ue_irq,
 				  stmmac_safety_interrupt,
-				  0, int_name, dev);
+				  flags, int_name, dev);
 		if (unlikely(ret < 0)) {
 			netdev_err(priv->dev,
 				   "%s: alloc sfty ue MSI %d (error: %d)\n",
@@ -3596,7 +3600,7 @@ static int stmmac_request_irq_multi_msi(struct net_device *dev)
 		sprintf(int_name, "%s:%s-%d", dev->name, "rx", i);
 		ret = request_irq(priv->rx_irq[i],
 				  stmmac_msi_intr_rx,
-				  0, int_name, &priv->dma_conf.rx_queue[i]);
+				  flags, int_name, &priv->dma_conf.rx_queue[i]);
 		if (unlikely(ret < 0)) {
 			netdev_err(priv->dev,
 				   "%s: alloc rx-%d  MSI %d (error: %d)\n",
@@ -3621,7 +3625,7 @@ static int stmmac_request_irq_multi_msi(struct net_device *dev)
 		sprintf(int_name, "%s:%s-%d", dev->name, "tx", i);
 		ret = request_irq(priv->tx_irq[i],
 				  stmmac_msi_intr_tx,
-				  0, int_name, &priv->dma_conf.tx_queue[i]);
+				  flags, int_name, &priv->dma_conf.tx_queue[i]);
 		if (unlikely(ret < 0)) {
 			netdev_err(priv->dev,
 				   "%s: alloc tx-%d  MSI %d (error: %d)\n",
@@ -6045,8 +6049,10 @@ static u16 stmmac_select_queue(struct net_device *dev, struct sk_buff *skb,
 			       struct net_device *sb_dev)
 {
 	int gso = skb_shinfo(skb)->gso_type;
+	struct stmmac_priv *priv = netdev_priv(dev);
 
-	if (gso & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6 | SKB_GSO_UDP_L4)) {
+	if ((gso & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6 | SKB_GSO_UDP_L4)) ||
+	    priv->plat->has_lgmac) {
 		/*
 		 * There is no way to determine the number of TSO/USO
 		 * capable Queues. Let's use always the Queue 0
@@ -6924,7 +6930,8 @@ static int stmmac_hw_init(struct stmmac_priv *priv)
 	 * riwt_off field from the platform.
 	 */
 	if (((priv->synopsys_id >= DWMAC_CORE_3_50) ||
-	    (priv->plat->has_xgmac)) && (!priv->plat->riwt_off)) {
+	    (priv->plat->has_xgmac) || (priv->plat->has_lgmac)) &&
+	    (!priv->plat->riwt_off)) {
 		priv->use_riwt = 1;
 		dev_info(priv->device,
 			 "Enable RX Mitigation via HW Watchdog Timer\n");
include/linux/stmmac.h +1 -0
index f9af24f760d4..8ee1d8c7827f 100644
@@ -341,6 +341,7 @@ struct plat_stmmacenet_data {
 	bool sph_disable;
 	bool serdes_up_after_phy_linkup;
 	const struct dwmac4_addrs *dwmac4_addrs;
+	int has_lgmac;
 	bool dwmac_is_loongson;
 	const struct dwmac_regs *dwmac_regs;
 };
Signature · 1 line
2.39.3
#21 lore raw

RFC PATCH 8/10 net: stmmac: dwmac-loongson: Add LS7A support

In reply to Feiyang Chen

Current dwmac-loongson only support LS2K in the "probed with PCI and configured with DT" manner. We add LS7A support on which the devices are fully PCI (non-DT).

---
 .../ethernet/stmicro/stmmac/dwmac-loongson.c  | 135 +++++++++++-------
 1 file changed, 82 insertions(+), 53 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +82 -53
index a25c187d3185..dc0916f2e9b8 100644
@@ -9,14 +9,22 @@
 #include <linux/of_irq.h>
 #include "stmmac.h"
 
-static int loongson_default_data(struct plat_stmmacenet_data *plat)
+struct stmmac_pci_info {
+	int (*setup)(struct pci_dev *pdev, struct plat_stmmacenet_data *plat);
+};
+
+static void common_default_data(struct pci_dev *pdev,
+				struct plat_stmmacenet_data *plat)
 {
+	plat->bus_id = (pci_domain_nr(pdev->bus) << 16) | PCI_DEVID(pdev->bus->number, pdev->devfn);
+	plat->interface = PHY_INTERFACE_MODE_GMII;
+
 	plat->clk_csr = 2;	/* clk_csr_i = 20-35MHz & MDC = clk_csr_i/16 */
 	plat->has_gmac = 1;
 	plat->force_sf_dma_mode = 1;
 
 	/* Set default value for multicast hash bins */
-	plat->multicast_filter_bins = HASH_TABLE_SIZE;
+	plat->multicast_filter_bins = 256;
 
 	/* Set default value for unicast filter entries */
 	plat->unicast_filter_entries = 1;
@@ -35,31 +43,43 @@ static int loongson_default_data(struct plat_stmmacenet_data *plat)
 	/* Disable RX queues routing by default */
 	plat->rx_queues_cfg[0].pkt_route = 0x0;
 
-	/* Default to phy auto-detection */
-	plat->phy_addr = -1;
-
 	plat->dma_cfg->pbl = 32;
 	plat->dma_cfg->pblx8 = true;
 
-	plat->multicast_filter_bins = 256;
+	plat->clk_ref_rate = 125000000;
+	plat->clk_ptp_rate = 125000000;
+
+	plat->has_lgmac = 1;
+}
+
+static int loongson_gmac_data(struct pci_dev *pdev,
+			      struct plat_stmmacenet_data *plat)
+{
+	common_default_data(pdev, plat);
+
+	plat->mdio_bus_data->phy_mask = 0;
+
+	plat->phy_addr = -1;
+	plat->phy_interface = PHY_INTERFACE_MODE_RGMII_ID;
+
 	return 0;
 }
 
-static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id *id)
+static struct stmmac_pci_info loongson_gmac_pci_info = {
+	.setup = loongson_gmac_data,
+};
+
+static int loongson_dwmac_probe(struct pci_dev *pdev,
+				const struct pci_device_id *id)
 {
+	int ret, i, bus_id, phy_mode;
 	struct plat_stmmacenet_data *plat;
+	struct stmmac_pci_info *info;
 	struct stmmac_resources res;
 	struct device_node *np;
-	int ret, i, phy_mode;
 
 	np = dev_of_node(&pdev->dev);
-
-	if (!np) {
-		pr_info("dwmac_loongson_pci: No OF node\n");
-		return -ENODEV;
-	}
-
-	if (!of_device_is_compatible(np, "loongson, pci-gmac")) {
+	if (np && !of_device_is_compatible(np, "loongson, pci-gmac")) {
 		pr_info("dwmac_loongson_pci: Incompatible OF node\n");
 		return -ENODEV;
 	}
@@ -68,17 +88,14 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id
 	if (!plat)
 		return -ENOMEM;
 
+	plat->mdio_bus_data = devm_kzalloc(&pdev->dev,
+				   sizeof(*plat->mdio_bus_data), GFP_KERNEL);
+	if (!plat->mdio_bus_data)
+		return -ENOMEM;
+
 	plat->mdio_node = of_get_child_by_name(np, "mdio");
 	if (plat->mdio_node) {
 		dev_info(&pdev->dev, "Found MDIO subnode\n");
-
-		plat->mdio_bus_data = devm_kzalloc(&pdev->dev,
-						   sizeof(*plat->mdio_bus_data),
-						   GFP_KERNEL);
-		if (!plat->mdio_bus_data) {
-			ret = -ENOMEM;
-			goto err_put_node;
-		}
 		plat->mdio_bus_data->needs_reset = true;
 	}
 
@@ -105,45 +122,55 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id
 		break;
 	}
 
-	plat->bus_id = of_alias_get_id(np, "ethernet");
-	if (plat->bus_id < 0)
-		plat->bus_id = pci_dev_id(pdev);
+	pci_set_master(pdev);
 
-	phy_mode = device_get_phy_mode(&pdev->dev);
-	if (phy_mode < 0) {
-		dev_err(&pdev->dev, "phy_mode not found\n");
-		ret = phy_mode;
+	info = (struct stmmac_pci_info *)id->driver_data;
+	ret = info->setup(pdev, plat);
+	if (ret)
 		goto err_disable_device;
-	}
 
-	plat->phy_interface = phy_mode;
-	plat->interface = PHY_INTERFACE_MODE_GMII;
+	if (np) {
+		bus_id = of_alias_get_id(np, "ethernet");
+		if (bus_id >= 0)
+			plat->bus_id = bus_id;
 
-	pci_set_master(pdev);
+		phy_mode = device_get_phy_mode(&pdev->dev);
+		if (phy_mode < 0) {
+			dev_err(&pdev->dev, "phy_mode not found\n");
+			ret = phy_mode;
+			goto err_disable_device;
+		}
+		plat->phy_interface = phy_mode;
+	}
 
-	loongson_default_data(plat);
 	pci_enable_msi(pdev);
+
 	memset(&res, 0, sizeof(res));
 	res.addr = pcim_iomap_table(pdev)[0];
+	if (np) {
+		res.irq = of_irq_get_byname(np, "macirq");
+		if (res.irq < 0) {
+			dev_err(&pdev->dev, "IRQ macirq not found\n");
+			ret = -ENODEV;
+			goto err_disable_msi;
+		}
 
-	res.irq = of_irq_get_byname(np, "macirq");
-	if (res.irq < 0) {
-		dev_err(&pdev->dev, "IRQ macirq not found\n");
-		ret = -ENODEV;
-		goto err_disable_msi;
-	}
-
-	res.wol_irq = of_irq_get_byname(np, "eth_wake_irq");
-	if (res.wol_irq < 0) {
-		dev_info(&pdev->dev, "IRQ eth_wake_irq not found, using macirq\n");
-		res.wol_irq = res.irq;
-	}
+		res.wol_irq = of_irq_get_byname(np, "eth_wake_irq");
+		if (res.wol_irq < 0) {
+			dev_info(&pdev->dev,
+				 "IRQ eth_wake_irq not found, using macirq\n");
+			res.wol_irq = res.irq;
+		}
 
-	res.lpi_irq = of_irq_get_byname(np, "eth_lpi");
-	if (res.lpi_irq < 0) {
-		dev_err(&pdev->dev, "IRQ eth_lpi not found\n");
-		ret = -ENODEV;
-		goto err_disable_msi;
+		res.lpi_irq = of_irq_get_byname(np, "eth_lpi");
+		if (res.lpi_irq < 0) {
+			dev_err(&pdev->dev, "IRQ eth_lpi not found\n");
+			ret = -ENODEV;
+			goto err_disable_msi;
+		}
+	} else {
+		res.irq = pdev->irq;
+		res.wol_irq = pdev->irq;
 	}
 
 	ret = stmmac_dvr_probe(&pdev->dev, plat, &res);
@@ -219,8 +246,10 @@ static int __maybe_unused loongson_dwmac_resume(struct device *dev)
 static SIMPLE_DEV_PM_OPS(loongson_dwmac_pm_ops, loongson_dwmac_suspend,
 			 loongson_dwmac_resume);
 
+#define PCI_DEVICE_ID_LOONGSON_GMAC	0x7a03
+
 static const struct pci_device_id loongson_dwmac_id_table[] = {
-	{ PCI_VDEVICE(LOONGSON, 0x7a03) },
+	{ PCI_DEVICE_DATA(LOONGSON, GMAC, &loongson_gmac_pci_info) },
 	{}
 };
 MODULE_DEVICE_TABLE(pci, loongson_dwmac_id_table);
Signature · 1 line
2.39.3
#22 lore raw

RFC PATCH 9/10 net: stmmac: dwmac-loongson: Add 64-bit DMA and multi-vector support

In reply to Feiyang Chen

Set 64-Bit DMA for specific versions. Request allocation for multi- vector interrupts for DWLGMAC_CORE_1_00. If it fails, fallback to request allocation for single interrupts.

---
 .../ethernet/stmicro/stmmac/dwmac-loongson.c  | 53 ++++++++++++++++++-
 1 file changed, 51 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +51 -2
index dc0916f2e9b8..3732f90a79c7 100644
@@ -72,11 +72,12 @@ static struct stmmac_pci_info loongson_gmac_pci_info = {
 static int loongson_dwmac_probe(struct pci_dev *pdev,
 				const struct pci_device_id *id)
 {
-	int ret, i, bus_id, phy_mode;
+	int ret, i, bus_id, phy_mode, ch_cnt, vecs;
 	struct plat_stmmacenet_data *plat;
 	struct stmmac_pci_info *info;
 	struct stmmac_resources res;
 	struct device_node *np;
+	u32 version;
 
 	np = dev_of_node(&pdev->dev);
 	if (np && !of_device_is_compatible(np, "loongson, pci-gmac")) {
@@ -173,12 +174,59 @@ static int loongson_dwmac_probe(struct pci_dev *pdev,
 		res.wol_irq = pdev->irq;
 	}
 
+	version = readl(res.addr + GMAC_VERSION);
+	switch (version & 0xff) {
+	case DWLGMAC_CORE_1_00:
+		ch_cnt = 8;
+		plat->multi_msi_en = 1;
+		break;
+
+	case DWMAC_CORE_3_50:
+	case DWMAC_CORE_3_70:
+	default:
+		plat->multi_msi_en = 0;
+		if (version & 0x00008000) {
+			plat->host_dma_width = 64;
+			plat->dma_cfg->dma64 = true;
+		}
+		break;
+	}
+
+	if (plat->multi_msi_en) {
+		plat->rx_queues_to_use = ch_cnt;
+		plat->tx_queues_to_use = ch_cnt;
+
+		pci_disable_msi(pdev);
+
+		res.irq = pci_irq_vector(pdev, 0);
+		res.wol_irq = res.irq;
+		vecs = roundup_pow_of_two(ch_cnt * 2 + 1);
+		if (pci_alloc_irq_vectors(pdev, vecs, vecs, PCI_IRQ_MSI) < 0) {
+			dev_info(&pdev->dev,
+				 "MSI enable failed, Fallback to line interrupt\n");
+			plat->multi_msi_en = 0;
+		} else {
+			/*
+			 * INT NAME | MAC | CH7 rx | CH7 tx | ... | CH0 rx | CH0 tx |
+			 * --------- ----- -------- --------  ...  -------- --------
+			 * IRQ NUM  |  0  |   1    |   2    | ... |   15   |   16   |
+			 */
+			for (i = 0; i < ch_cnt; i++) {
+				res.rx_irq[ch_cnt - 1 - i] = pci_irq_vector(pdev, 1 + i * 2);
+				res.tx_irq[ch_cnt - 1 - i] = pci_irq_vector(pdev, 2 + i * 2);
+			}
+		}
+	}
+
 	ret = stmmac_dvr_probe(&pdev->dev, plat, &res);
 	if (ret)
-		goto err_disable_msi;
+		goto err_free_irq_vectors;
 
 	return ret;
 
+err_free_irq_vectors:
+	if (plat->multi_msi_en)
+		pci_free_irq_vectors(pdev);
 err_disable_msi:
 	pci_disable_msi(pdev);
 err_disable_device:
@@ -204,6 +252,7 @@ static void loongson_dwmac_remove(struct pci_dev *pdev)
 		break;
 	}
 
+	pci_free_irq_vectors(pdev);
 	pci_disable_msi(pdev);
 	pci_disable_device(pdev);
 }
Signature · 1 line
2.39.3
#23 lore raw

RFC PATCH 10/10 net: stmmac: dwmac-loongson: Add GNET support

In reply to Feiyang Chen

Add GNET support. Use the fix_mac_speed() callback to workaround issues with the Loongson PHY.

---
 drivers/net/ethernet/stmicro/stmmac/Kconfig   |  1 +
 .../ethernet/stmicro/stmmac/dwmac-loongson.c  | 34 +++++++++++++++++++
 2 files changed, 35 insertions(+)
drivers/net/ethernet/stmicro/stmmac/Kconfig +1 -0
index 5f5a997f21f3..8c25d5616941 100644
@@ -279,6 +279,7 @@ config DWMAC_LOONGSON
 	default MACH_LOONGSON64
 	depends on STMMAC_ETH && PCI
 	depends on COMMON_CLK
+	select LOONGSON_PHY
 	help
 	  This selects the LOONGSON PCI bus support for the stmmac driver,
 	  Support for ethernet controller on Loongson-2K1000 SoC and LS7A1000 bridge.
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +34 -0
index 3732f90a79c7..c840d9d1d72a 100644
@@ -69,6 +69,38 @@ static struct stmmac_pci_info loongson_gmac_pci_info = {
 	.setup = loongson_gmac_data,
 };
 
+static void loongson_gnet_fix_speed(void *priv, unsigned int speed)
+{
+	struct net_device *ndev = (struct net_device *)(*(unsigned long *)priv);
+	struct stmmac_priv *ptr = netdev_priv(ndev);
+
+	if (speed == SPEED_1000)
+		if (readl(ptr->ioaddr + MAC_CTRL_REG) & (1 << 15) /* PS */)
+			phy_restart_aneg(ndev->phydev);
+}
+
+static int loongson_gnet_data(struct pci_dev *pdev,
+			      struct plat_stmmacenet_data *plat)
+{
+	common_default_data(pdev, plat);
+
+	plat->mdio_bus_data->phy_mask = 0xfffffffb;
+
+	plat->phy_addr = 2;
+	plat->phy_interface = PHY_INTERFACE_MODE_GMII;
+
+	plat->fix_mac_speed = loongson_gnet_fix_speed;
+
+	/* Get netdev pointer address */
+	plat->bsp_priv = &(pdev->dev.driver_data);
+
+	return 0;
+}
+
+static struct stmmac_pci_info loongson_gnet_pci_info = {
+	.setup = loongson_gnet_data,
+};
+
 static int loongson_dwmac_probe(struct pci_dev *pdev,
 				const struct pci_device_id *id)
 {
@@ -296,9 +328,11 @@ static SIMPLE_DEV_PM_OPS(loongson_dwmac_pm_ops, loongson_dwmac_suspend,
 			 loongson_dwmac_resume);
 
 #define PCI_DEVICE_ID_LOONGSON_GMAC	0x7a03
+#define PCI_DEVICE_ID_LOONGSON_GNET	0x7a13
 
 static const struct pci_device_id loongson_dwmac_id_table[] = {
 	{ PCI_DEVICE_DATA(LOONGSON, GMAC, &loongson_gmac_pci_info) },
+	{ PCI_DEVICE_DATA(LOONGSON, GNET, &loongson_gnet_pci_info) },
 	{}
 };
 MODULE_DEVICE_TABLE(pci, loongson_dwmac_id_table);
Signature · 1 line
2.39.3
maintainer
#24 lore raw

Re: [RFC PATCH 10/10] net: stmmac: dwmac-loongson: Add GNET support

Quoted 2 lines · Feiyang Chen

Add GNET support. Use the fix_mac_speed() callback to workaround issues with the Loongson PHY.

What are the issues?

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

Quoted 8 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +8 -0
+static void loongson_gnet_fix_speed(void *priv, unsigned int speed)
+{
+	struct net_device *ndev = (struct net_device *)(*(unsigned long *)priv);
+	struct stmmac_priv *ptr = netdev_priv(ndev);
+
+	if (speed == SPEED_1000)
+		if (readl(ptr->ioaddr + MAC_CTRL_REG) & (1 << 15) /* PS */)
+			phy_restart_aneg(ndev->phydev);

This needs a comment at least, but if you explain what is actually FUBAR in this PHY, we might be able to tell you a better way to work around its problems.

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

Quoted 9 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +9 -0
+static int loongson_gnet_data(struct pci_dev *pdev,
+			      struct plat_stmmacenet_data *plat)
+{
+	common_default_data(pdev, plat);
+
+	plat->mdio_bus_data->phy_mask = 0xfffffffb;
+
+	plat->phy_addr = 2;
+	plat->phy_interface = PHY_INTERFACE_MODE_GMII;

You would normally get this from DT. Is the PHY integrated? Is it really using GMII, or would PHY_INTERFACE_MODE_INTERNAL be better?

Andrew

#25 lore raw

Re: [RFC PATCH 10/10] net: stmmac: dwmac-loongson: Add GNET support

Quoted 7 lines · Andrew Lunn
Quoted 2 lines · Feiyang Chen

Add GNET support. Use the fix_mac_speed() callback to workaround issues with the Loongson PHY.

What are the issues?

Hi, Andrew,

There is an issue with the synchronization between the network card and the PHY. In the case of gigabit operation, if the PHY's speed changes, the network card's speed remains unaffected. Hence, it is necessary to initiate a re-negotiation process with the PHY to align the link speeds properly.

Quoted 13 lines

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

Quoted 8 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +8 -0
+static void loongson_gnet_fix_speed(void *priv, unsigned int speed)
+{
+     struct net_device *ndev = (struct net_device *)(*(unsigned long *)priv);
+     struct stmmac_priv *ptr = netdev_priv(ndev);
+
+     if (speed == SPEED_1000)
+             if (readl(ptr->ioaddr + MAC_CTRL_REG) & (1 << 15) /* PS */)
+                     phy_restart_aneg(ndev->phydev);

This needs a comment at least, but if you explain what is actually FUBAR in this PHY, we might be able to tell you a better way to work around its problems.

Quoted 13 lines

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

Quoted 9 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +9 -0
+static int loongson_gnet_data(struct pci_dev *pdev,
+                           struct plat_stmmacenet_data *plat)
+{
+     common_default_data(pdev, plat);
+
+     plat->mdio_bus_data->phy_mask = 0xfffffffb;
+
+     plat->phy_addr = 2;
+     plat->phy_interface = PHY_INTERFACE_MODE_GMII;

You would normally get this from DT. Is the PHY integrated? Is it really using GMII, or would PHY_INTERFACE_MODE_INTERNAL be better?

Yes, the PHY is integrated. I'll try to use PHY_INTERFACE_MODE_INTERNAL later.

Thanks,
Feiyang

Quoted 1 line

Andrew

maintainer
#26 lore raw

Re: [RFC PATCH 10/10] net: stmmac: dwmac-loongson: Add GNET support

Quoted 9 lines · Feiyang Chen
Quoted 7 lines · Andrew Lunn
Quoted 2 lines · Feiyang Chen

Add GNET support. Use the fix_mac_speed() callback to workaround issues with the Loongson PHY.

What are the issues?

Quoted 7 lines

Hi, Andrew,

There is an issue with the synchronization between the network card and the PHY. In the case of gigabit operation, if the PHY's speed changes, the network card's speed remains unaffected. Hence, it is necessary to initiate a re-negotiation process with the PHY to align the link speeds properly.

When the line side speed changes, the PHY will first report link down via the adjust_link callback in the MAC driver. Once the PHY has determined the new speed, the adjust_link callback will be called again with the new speed and pause parameters.

So what is actually going wrong?

Andrew

#27 lore raw

Re: [RFC PATCH 10/10] net: stmmac: dwmac-loongson: Add GNET support

Quoted 18 lines · Andrew Lunn
Quoted 9 lines · Feiyang Chen
Quoted 7 lines · Andrew Lunn
Quoted 2 lines · Feiyang Chen

Add GNET support. Use the fix_mac_speed() callback to workaround issues with the Loongson PHY.

What are the issues?

Quoted 7 lines

Hi, Andrew,

There is an issue with the synchronization between the network card and the PHY. In the case of gigabit operation, if the PHY's speed changes, the network card's speed remains unaffected. Hence, it is necessary to initiate a re-negotiation process with the PHY to align the link speeds properly.

Quoted 4 lines

When the line side speed changes, the PHY will first report link down via the adjust_link callback in the MAC driver. Once the PHY has determined the new speed, the adjust_link callback will be called again with the new speed and pause parameters.

Or in the case of stmmac, phylink is involved, so .mac_link_down will get called and then .mac_link_up with the new parameters.

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!
#28 lore raw

Re: [RFC PATCH 10/10] net: stmmac: dwmac-loongson: Add GNET support

In reply to Feiyang Chen
Quoted 9 lines · Feiyang Chen
Quoted 7 lines · Andrew Lunn
Quoted 2 lines · Feiyang Chen

Add GNET support. Use the fix_mac_speed() callback to workaround issues with the Loongson PHY.

What are the issues?

Quoted 7 lines

Hi, Andrew,

There is an issue with the synchronization between the network card and the PHY. In the case of gigabit operation, if the PHY's speed changes, the network card's speed remains unaffected. Hence, it is necessary to initiate a re-negotiation process with the PHY to align the link speeds properly.

Please could you explain a bit more what happens when "the PHY's speed changes". Are you suggesting that:

You have a connection where the media side has negotiated 1G speed. The gigabit partner is disconnected, so the link goes down, and is then replaced by a partner only capable of 100M. The link comes back up at 100M, but the network card continues trying to operate at 1G?

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!
#29 lore raw

Re: [RFC PATCH 10/10] net: stmmac: dwmac-loongson: Add GNET support

Quoted 19 lines · Russell King (Oracle)
Quoted 9 lines · Feiyang Chen
Quoted 7 lines · Andrew Lunn
Quoted 2 lines · Feiyang Chen

Add GNET support. Use the fix_mac_speed() callback to workaround issues with the Loongson PHY.

What are the issues?

Quoted 7 lines

Hi, Andrew,

There is an issue with the synchronization between the network card and the PHY. In the case of gigabit operation, if the PHY's speed changes, the network card's speed remains unaffected. Hence, it is necessary to initiate a re-negotiation process with the PHY to align the link speeds properly.

Quoted 8 lines

Please could you explain a bit more what happens when "the PHY's speed changes". Are you suggesting that:

You have a connection where the media side has negotiated 1G speed. The gigabit partner is disconnected, so the link goes down, and is then replaced by a partner only capable of 100M. The link comes back up at 100M, but the network card continues trying to operate at 1G?

Hi, Russell, Andrew,

This bug shows up in the following way: when the speed is set to 1000M, PHY is set up correctly and its status is normal. However, the controller and PHY don't work well together, causing the controller to fail in establishing a gigabit connection, which leads to a network disruption. So, we need to use this bit to check if the controller's status is correct and reset PHY if necessary.

if (readl(ptr->ioaddr + MAC_CTRL_REG) & (1 << 15) /* PS */)

The troublesome issue is that we have to check this bit in stmmac. As a result, we are forced to place phy_restart_aneg() there.

Thanks,
Feiyang

Quoted 5 lines

Thanks.

--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

#30 lore raw

Re: [RFC PATCH 10/10] net: stmmac: dwmac-loongson: Add GNET support

In reply to Feiyang Chen
Quoted 2 lines · Feiyang Chen

Add GNET support. Use the fix_mac_speed() callback to workaround issues with the Loongson PHY.

It would be good to document what those issue(s) are, and if they are a PHY issue, why they need to be resolved in a MAC driver rather than using the PHY driver's link_change_notify().

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!
#31 lore raw

Re: [RFC PATCH 10/10] net: stmmac: dwmac-loongson: Add GNET support

Quoted 9 lines · Russell King (Oracle)
Quoted 2 lines · Feiyang Chen

Add GNET support. Use the fix_mac_speed() callback to workaround issues with the Loongson PHY.

It would be good to document what those issue(s) are, and if they are a PHY issue, why they need to be resolved in a MAC driver rather than using the PHY driver's link_change_notify().

Hi, Russell,

There is an issue with the synchronization between the network card and the PHY. I believe that I am unable to access certain bits of the network card's registers within the PHY driver.

Thanks,
Feiyang

Quoted 5 lines

Thanks.

--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

maintainer
#32 lore raw

Re: [RFC PATCH 10/10] net: stmmac: dwmac-loongson: Add GNET support

Quoted 4 lines

Hi, Russell,

There is an issue with the synchronization between the network card and the PHY.

Details. We need the details in order to tell you the best workaround for your broken hardware.

I believe that I am unable to access certain bits of the

Quoted 1 line

network card's registers within the PHY driver.

The PHY driver and the MAC driver should never access each others registers.

Andrew

maintainer
#33 lore raw
In reply to Feiyang Chen
Quoted 2 lines · Feiyang Chen

Add driver for Loongson PHY. Extend stmmac functions and macros for Loongson DWMAC. Add LS7A support for dwmac_loongson.

Why is this RFC? What do you actually want comment on?

Andrew

#34 lore raw
Quoted 7 lines · Andrew Lunn
Quoted 2 lines · Feiyang Chen

Add driver for Loongson PHY. Extend stmmac functions and macros for Loongson DWMAC. Add LS7A support for dwmac_loongson.

Why is this RFC? What do you actually want comment on?

Hi, Andrew,

I marked this patch series as an RFC because I believe it involves significant changes to the dwmac1000 driver. I want comments on the design and any alternative suggestions.

Thanks,
Feiyang

Quoted 1 line

Andrew

#35 lore raw
Quoted 6 lines · Feiyang Chen
Quoted 5 lines · Andrew Lunn
Quoted 2 lines · Feiyang Chen

Add driver for Loongson PHY. Extend stmmac functions and macros for Loongson DWMAC. Add LS7A support for dwmac_loongson.

Quoted 8 lines
Quoted 2 lines

Why is this RFC? What do you actually want comment on?

Hi, Andrew,

I marked this patch series as an RFC because I believe it involves significant changes to the dwmac1000 driver. I want comments on the design and any alternative suggestions.

That is admirable, but in practice, I've found that posting RFCs is a waste of effort and time - basically, it seems people ignore patches posted as RFC.

This turns the whole thing when posting patches into basically what I'd summarise as "reviewer blackmail" - post the patches non-RFC even when you want only comments, and reviewers _have_ to comment on the patches if there's something they don't like to prevent them being merged.

It's sad that it comes to that, but that is the reality of how things appear to work.

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!
maintainer
#36 lore raw
Quoted 20 lines · Russell King (Oracle)
Quoted 6 lines · Feiyang Chen
Quoted 5 lines · Andrew Lunn
Quoted 2 lines · Feiyang Chen

Add driver for Loongson PHY. Extend stmmac functions and macros for Loongson DWMAC. Add LS7A support for dwmac_loongson.

Quoted 8 lines
Quoted 2 lines

Why is this RFC? What do you actually want comment on?

Hi, Andrew,

I marked this patch series as an RFC because I believe it involves significant changes to the dwmac1000 driver. I want comments on the design and any alternative suggestions.

That is admirable, but in practice, I've found that posting RFCs is a waste of effort and time - basically, it seems people ignore patches posted as RFC.

Quoted 8 lines

This turns the whole thing when posting patches into basically what I'd summarise as "reviewer blackmail" - post the patches non-RFC even when you want only comments, and reviewers _have_ to comment on the patches if there's something they don't like to prevent them being merged.

It's sad that it comes to that, but that is the reality of how things appear to work.

I have to agree with Russell. You wanted comments on the dwmac1000 patches, but all you received where comments on the PHY parts. Maybe if you had requested comments on the MAC driver changes, somebody might of commented, but i doubt it.

RFC seems best used during the merge window, and when you know the target audience well enough to know they will look at the patches even when it does have RFC.

Andrew

#37 lore raw

Hi, Russell, Andrew,

Thank you for your insights on RFC patches. I'll remove the RFC in the next version of the patch series.

Thanks,
Feiyang