Skip to contentSkip to conversation

net: stmmac: enable EHL SGMI

PATCH Superseded Voon Weifeng 3 participants 14 messages May 29, 2019

Subsystems (5)

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v4 cover net: stmmac: enable EHL SGMI

This patch-set is to enable Ethernet controller
(DW Ethernet QoS and DW Ethernet PCS) with SGMII interface in Elkhart Lake. The DW Ethernet PCS is the Physical Coding Sublayer that is between Ethernet MAC and PHY and uses MDIO Clause-45 as Communication.

Kweh Hock Leong (1):
net: stmmac: enable clause 45 mdio support

Ong Boon Leong (3):
net: stmmac: introducing support for DWC xPCS logics
net: stmmac: add xpcs function hooks into main driver and ethtool
net: stmmac: add xPCS functions for device with DWMACv5.1

Voon Weifeng (1):
net: stmmac: add EHL SGMII 1Gbps PCI info and PCI ID

 drivers/net/ethernet/stmicro/stmmac/Makefile       |   2 +-
 drivers/net/ethernet/stmicro/stmmac/common.h       |   1 +
 drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c  |  33 ++++
 drivers/net/ethernet/stmicro/stmmac/dwxpcs.c       | 198 +++++++++++++++++++++
 drivers/net/ethernet/stmicro/stmmac/dwxpcs.h       |  51 ++++++
 drivers/net/ethernet/stmicro/stmmac/hwif.c         |  42 ++++-
 drivers/net/ethernet/stmicro/stmmac/hwif.h         |  21 +++
 drivers/net/ethernet/stmicro/stmmac/stmmac.h       |   2 +
 .../net/ethernet/stmicro/stmmac/stmmac_ethtool.c   |  50 ++++--
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c  | 152 ++++++++++++----
 drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c  |  40 ++++-
 drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c   | 111 ++++++++++++
 include/linux/phy.h                                |   2 +
 include/linux/stmmac.h                             |   3 +
 14 files changed, 650 insertions(+), 58 deletions(-)
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwxpcs.c
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwxpcs.h
Signature · 12 lines
Changelog v2:
*Added support for the C37 AN for 1000BASE-X and SGMII (MAC side SGMII only)
*removed and submitted the fix patch to net
 "net: stmmac: dma channel control register need to be init first"
*Squash the following 2 patches and move it to the end of the patch set:
 "net: stmmac: add EHL SGMII 1Gbps platform data and PCI ID"
 "net: stmmac: add xPCS platform data for EHL"
Changelog v3:
*Applied reversed christmas tree
Changelog v4:
*Rebased to latest net-next
1.9.1
#1 lore raw

PATCH v4 1/5 net: stmmac: enable clause 45 mdio support

From: Kweh Hock Leong <[email protected]>

DWMAC4 is capable to support clause 45 mdio communication. This patch enable the feature on stmmac_mdio_write() and stmmac_mdio_read() by following phy_write_mmd() and phy_read_mmd() mdiobus read write implementation format.

---
 drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 40 ++++++++++++++++++-----
 include/linux/phy.h                               |  2 ++
 2 files changed, 34 insertions(+), 8 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +32 -8
index bdd351597b55..c3d8f1d145ec 100644
@@ -34,11 +34,27 @@
 
 #define MII_BUSY 0x00000001
 #define MII_WRITE 0x00000002
+#define MII_DATA_MASK GENMASK(15, 0)
 
 /* GMAC4 defines */
 #define MII_GMAC4_GOC_SHIFT		2
+#define MII_GMAC4_REG_ADDR_SHIFT	16
 #define MII_GMAC4_WRITE			(1 << MII_GMAC4_GOC_SHIFT)
 #define MII_GMAC4_READ			(3 << MII_GMAC4_GOC_SHIFT)
+#define MII_GMAC4_C45E			BIT(1)
+
+static void stmmac_mdio_c45_setup(struct stmmac_priv *priv, int phyreg,
+				  u32 *val, u32 *data)
+{
+	unsigned int reg_shift = priv->hw->mii.reg_shift;
+	unsigned int reg_mask = priv->hw->mii.reg_mask;
+
+	*val |= MII_GMAC4_C45E;
+	*val &= ~reg_mask;
+	*val |= ((phyreg >> MII_DEVADDR_C45_SHIFT) << reg_shift) & reg_mask;
+
+	*data |= (phyreg & MII_REGADDR_C45_MASK) << MII_GMAC4_REG_ADDR_SHIFT;
+}
 
 /* XGMAC defines */
 #define MII_XGMAC_SADDR			BIT(18)
@@ -165,22 +181,26 @@ static int stmmac_mdio_read(struct mii_bus *bus, int phyaddr, int phyreg)
 	struct stmmac_priv *priv = netdev_priv(ndev);
 	unsigned int mii_address = priv->hw->mii.addr;
 	unsigned int mii_data = priv->hw->mii.data;
-	u32 v;
-	int data;
 	u32 value = MII_BUSY;
+	int data = 0;
+	u32 v;
 
 	value |= (phyaddr << priv->hw->mii.addr_shift)
 		& priv->hw->mii.addr_mask;
 	value |= (phyreg << priv->hw->mii.reg_shift) & priv->hw->mii.reg_mask;
 	value |= (priv->clk_csr << priv->hw->mii.clk_csr_shift)
 		& priv->hw->mii.clk_csr_mask;
-	if (priv->plat->has_gmac4)
+	if (priv->plat->has_gmac4) {
 		value |= MII_GMAC4_READ;
+		if (phyreg & MII_ADDR_C45)
+			stmmac_mdio_c45_setup(priv, phyreg, &value, &data);
+	}
 
 	if (readl_poll_timeout(priv->ioaddr + mii_address, v, !(v & MII_BUSY),
 			       100, 10000))
 		return -EBUSY;
 
+	writel(data, priv->ioaddr + mii_data);
 	writel(value, priv->ioaddr + mii_address);
 
 	if (readl_poll_timeout(priv->ioaddr + mii_address, v, !(v & MII_BUSY),
@@ -188,7 +208,7 @@ static int stmmac_mdio_read(struct mii_bus *bus, int phyaddr, int phyreg)
 		return -EBUSY;
 
 	/* Read the data from the MII data register */
-	data = (int)readl(priv->ioaddr + mii_data);
+	data = (int)readl(priv->ioaddr + mii_data) & MII_DATA_MASK;
 
 	return data;
 }
@@ -208,8 +228,9 @@ static int stmmac_mdio_write(struct mii_bus *bus, int phyaddr, int phyreg,
 	struct stmmac_priv *priv = netdev_priv(ndev);
 	unsigned int mii_address = priv->hw->mii.addr;
 	unsigned int mii_data = priv->hw->mii.data;
-	u32 v;
 	u32 value = MII_BUSY;
+	int data = phydata;
+	u32 v;
 
 	value |= (phyaddr << priv->hw->mii.addr_shift)
 		& priv->hw->mii.addr_mask;
@@ -217,10 +238,13 @@ static int stmmac_mdio_write(struct mii_bus *bus, int phyaddr, int phyreg,
 
 	value |= (priv->clk_csr << priv->hw->mii.clk_csr_shift)
 		& priv->hw->mii.clk_csr_mask;
-	if (priv->plat->has_gmac4)
+	if (priv->plat->has_gmac4) {
 		value |= MII_GMAC4_WRITE;
-	else
+		if (phyreg & MII_ADDR_C45)
+			stmmac_mdio_c45_setup(priv, phyreg, &value, &data);
+	} else {
 		value |= MII_WRITE;
+	}
 
 	/* Wait until any existing MII operation is complete */
 	if (readl_poll_timeout(priv->ioaddr + mii_address, v, !(v & MII_BUSY),
@@ -228,7 +252,7 @@ static int stmmac_mdio_write(struct mii_bus *bus, int phyaddr, int phyreg,
 		return -EBUSY;
 
 	/* Set the MII address register to write */
-	writel(phydata, priv->ioaddr + mii_data);
+	writel(data, priv->ioaddr + mii_data);
 	writel(value, priv->ioaddr + mii_address);
 
 	/* Wait until any existing MII operation is complete */
include/linux/phy.h +2 -0
index 7180b1d1e5e3..27d267bde363 100644
@@ -201,6 +201,8 @@ static inline const char *phy_modes(phy_interface_t interface)
 /* Or MII_ADDR_C45 into regnum for read/write on mii_bus to enable the 21 bit
    IEEE 802.3ae clause 45 addressing mode used by 10GIGE phy chips. */
 #define MII_ADDR_C45 (1<<30)
+#define MII_DEVADDR_C45_SHIFT	16
+#define MII_REGADDR_C45_MASK	GENMASK(15, 0)
 
 struct device;
 struct phylink;
Signature · 1 line
1.9.1
#2 lore raw

RE: [PATCH net-next v4 1/5] net: stmmac: enable clause 45 mdio support

From: Voon Weifeng <[email protected]>
Date: Wed, May 29, 2019 at 17:58:23

drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c line 50

Quoted 5 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +5 -0
+static void stmmac_mdio_c45_setup(struct stmmac_priv *priv, int phyreg,
+				  u32 *val, u32 *data)
+{
+	unsigned int reg_shift = priv->hw->mii.reg_shift;
+	unsigned int reg_mask = priv->hw->mii.reg_mask;

Reverse christmas tree here. You also should align the function variables with the opening parenthesis of the function here and in the remaining series.

Otherwise this patch looks good to me.

Thanks,
Jose Miguel Abreu

#3 lore raw

RE: [PATCH net-next v4 1/5] net: stmmac: enable clause 45 mdio support

Quoted 10 lines

drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c line 50

Quoted 5 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +5 -0
+static void stmmac_mdio_c45_setup(struct stmmac_priv *priv, int phyreg,
+				  u32 *val, u32 *data)
+{
+	unsigned int reg_shift = priv->hw->mii.reg_shift;
+	unsigned int reg_mask = priv->hw->mii.reg_mask;

Reverse christmas tree here. You also should align the function variables with the opening parenthesis of the function here and in the remaining series.

Otherwise this patch looks good to me.

It is already reversed Christmas tree. Somehow each of the character's width in the email is not equal. As you can see that the first line of assignment is having more character than the second line of assignment.
The alignment is also correct when I check it after doing a git am.

Regards,
Weifeng

Quoted 3 lines

Thanks,
Jose Miguel Abreu

maintainer
#4 lore raw

Re: [PATCH net-next v4 1/5] net: stmmac: enable clause 45 mdio support

Quoted 9 lines · Weifeng
Quoted 9 lines

drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c line 50

Quoted 5 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +5 -0
+static void stmmac_mdio_c45_setup(struct stmmac_priv *priv, int phyreg,
+				  u32 *val, u32 *data)
+{
+	unsigned int reg_shift = priv->hw->mii.reg_shift;
+	unsigned int reg_mask = priv->hw->mii.reg_mask;

Reverse christmas tree here. You also should align the function variables with the opening parenthesis of the function here and in the remaining series.

Quoted 3 lines
Quoted 1 line

Otherwise this patch looks good to me.

It is already reversed Christmas tree.

Yes.

Quoted 2 lines

Somehow each of the character's width in the
email is not equal.

Sounds like somebody is using a proportional font in there email client. Bad idea.

Andrew

#5 lore raw

PATCH v4 2/5 net: stmmac: introducing support for DWC xPCS logics

In reply to Voon Weifeng

From: Ong Boon Leong <[email protected]>

xPCS is DWC Ethernet Physical Coding Sublayer that may be integrated into a GbE controller that uses DWC EQoS MAC controller. An example of HW configuration is shown below:-

<-----------------GBE Controller---------->|<--External PHY chip-->

  +----------+         +----+    +---+               +--------------+
  |   EQoS   | <-GMII->| DW |<-->|PHY| <-- SGMII --> | External GbE |
  |   MAC    |         |xPCS|    |IF |               | PHY Chip     |
  +----------+         +----+    +---+               +--------------+
         ^               ^                                  ^
         |               |                                  |
         +---------------------MDIO-------------------------+

xPCS is a Clause-45 MDIO Manageable Device (MMD) and we need a way to differentiate it from external PHY chip that is discovered over MDIO. Therefore, xpcs_phy_addr is introduced in stmmac platform data (plat_stmmacenet_data) for differentiating xPCS from 'phy_addr' that belongs to external PHY.

Basic functionalities for initializing xPCS and configuring auto negotiation (AN), loopback, link status, AN advertisement and Link Partner ability are implemented. The implementation supports the C37 AN for 1000BASE-X and SGMII (MAC side SGMII only).

---
 drivers/net/ethernet/stmicro/stmmac/Makefile |   2 +-
 drivers/net/ethernet/stmicro/stmmac/common.h |   1 +
 drivers/net/ethernet/stmicro/stmmac/dwxpcs.c | 198 +++++++++++++++++++++++++++
 drivers/net/ethernet/stmicro/stmmac/dwxpcs.h |  51 +++++++
 drivers/net/ethernet/stmicro/stmmac/hwif.h   |  19 +++
 include/linux/stmmac.h                       |   1 +
 6 files changed, 271 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwxpcs.c
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwxpcs.h
drivers/net/ethernet/stmicro/stmmac/Makefile +1 -1
index c59926d96bcc..f007fb873455 100644
@@ -6,7 +6,7 @@ stmmac-objs:= stmmac_main.o stmmac_ethtool.o stmmac_mdio.o ring_mode.o	\
 	      mmc_core.o stmmac_hwtstamp.o stmmac_ptp.o dwmac4_descs.o	\
 	      dwmac4_dma.o dwmac4_lib.o dwmac4_core.o dwmac5.o hwif.o \
 	      stmmac_tc.o dwxgmac2_core.o dwxgmac2_dma.o dwxgmac2_descs.o \
-	      $(stmmac-y)
+	      dwxpcs.o $(stmmac-y)
 
 stmmac-$(CONFIG_STMMAC_SELFTESTS) += stmmac_selftests.o
 
drivers/net/ethernet/stmicro/stmmac/common.h +1 -0
index 1961fe9144ca..822786872796 100644
@@ -419,6 +419,7 @@ struct mii_regs {
 
 struct mac_device_info {
 	const struct stmmac_ops *mac;
+	const struct stmmac_xpcs *xpcs;
 	const struct stmmac_desc_ops *desc;
 	const struct stmmac_dma_ops *dma;
 	const struct stmmac_mode_ops *mode;
drivers/net/ethernet/stmicro/stmmac/dwxpcs.c new file +198 -0

198 lines not on this page · raw message

drivers/net/ethernet/stmicro/stmmac/dwxpcs.h new file +51 -0

51 lines not on this page · raw message

drivers/net/ethernet/stmicro/stmmac/hwif.h +19 -0
index 2acfbc70e3c8..8531d33f8eb9 100644
@@ -398,6 +398,25 @@ struct stmmac_ops {
 #define stmmac_set_mac_loopback(__priv, __args...) \
 	stmmac_do_void_callback(__priv, mac, set_mac_loopback, __args)
 
+/* Helpers for DW xPCS */
+struct stmmac_xpcs {
+	void (*xpcs_init)(struct net_device *ndev, int pcs_mode);
+	void (*xpcs_ctrl_ane)(struct net_device *ndev, bool ane, bool loopback);
+	void (*xpcs_get_adv_lp)(struct net_device *ndev, struct rgmii_adv *adv,
+				int pcs_mode);
+	int (*xpcs_irq_status)(struct net_device *ndev,
+			       struct stmmac_extra_stats *x, int pcs_mode);
+};
+
+#define stmmac_xpcs_init(__priv, __args...) \
+	stmmac_do_void_callback(__priv, xpcs, xpcs_init, __args)
+#define stmmac_xpcs_ctrl_ane(__priv, __args...) \
+	stmmac_do_void_callback(__priv, xpcs, xpcs_ctrl_ane, __args)
+#define stmmac_xpcs_get_adv_lp(__priv, __args...) \
+	stmmac_do_void_callback(__priv, xpcs, xpcs_get_adv_lp, __args)
+#define stmmac_xpcs_irq_status(__priv, __args...) \
+	stmmac_do_callback(__priv, xpcs, xpcs_irq_status, __args)
+
 /* PTP and HW Timer helpers */
 struct stmmac_hwtimestamp {
 	void (*config_hw_tstamping) (void __iomem *ioaddr, u32 data);
include/linux/stmmac.h +1 -0
index 4335bd771ce5..b00e7951a66d 100644
@@ -148,6 +148,7 @@ struct stmmac_txq_cfg {
 struct plat_stmmacenet_data {
 	int bus_id;
 	int phy_addr;
+	int xpcs_phy_addr;
 	int interface;
 	struct stmmac_mdio_bus_data *mdio_bus_data;
 	struct device_node *phy_node;
Signature · 1 line
1.9.1
#6 lore raw

RE: [PATCH net-next v4 2/5] net: stmmac: introducing support for DWC xPCS logics

From: Voon Weifeng <[email protected]>
Date: Wed, May 29, 2019 at 17:58:24

drivers/net/ethernet/stmicro/stmmac/hwif.h struct stmmac_ops { · line 409

Quoted 9 lines
drivers/net/ethernet/stmicro/stmmac/hwif.h +9 -0
+/* Helpers for DW xPCS */
+struct stmmac_xpcs {
+	void (*xpcs_init)(struct net_device *ndev, int pcs_mode);
+	void (*xpcs_ctrl_ane)(struct net_device *ndev, bool ane, bool loopback);
+	void (*xpcs_get_adv_lp)(struct net_device *ndev, struct rgmii_adv *adv,
+				int pcs_mode);
+	int (*xpcs_irq_status)(struct net_device *ndev,
+			       struct stmmac_extra_stats *x, int pcs_mode);
+};

Please rename the structure to stmmac_xpcs_ops, to keep consistency with other helpers.

Thanks,
Jose Miguel Abreu

#7 lore raw

PATCH v4 3/5 net: stmmac: add xpcs function hooks into main driver and ethtool

In reply to Voon Weifeng

From: Ong Boon Leong <[email protected]>

With xPCS functions now ready, we add them into the main driver and ethtool logics. To differentiate from EQoS MAC PCS and DWC Ethernet xPCS, we introduce 'has_xpcs' in platform data as a mean to indicate whether GBE controller includes xPCS or not.

To support platform-specific C37 AN PCS mode selection for MII MMD, we introduce 'pcs_mode' in platform data.

The basic framework for xPCS interrupt handling is implemented too.

---
 drivers/net/ethernet/stmicro/stmmac/stmmac.h       |   2 +
 .../net/ethernet/stmicro/stmmac/stmmac_ethtool.c   |  50 +++++--
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c  | 152 ++++++++++++++++-----
 include/linux/stmmac.h                             |   2 +
 4 files changed, 158 insertions(+), 48 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac.h +2 -0
index a16ada8b8507..999311236521 100644
@@ -36,6 +36,7 @@ struct stmmac_resources {
 	const char *mac;
 	int wol_irq;
 	int lpi_irq;
+	int xpcs_irq;
 	int irq;
 };
 
@@ -168,6 +169,7 @@ struct stmmac_priv {
 	int clk_csr;
 	struct timer_list eee_ctrl_timer;
 	int lpi_irq;
+	int xpcs_irq;
 	int eee_enabled;
 	int eee_active;
 	int tx_lpi_timer;
drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +39 -11

92 lines not on this page · raw message

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +115 -37

209 lines not on this page · raw message

include/linux/stmmac.h +2 -0
index b00e7951a66d..c6778abd41c5 100644
@@ -189,6 +189,8 @@ struct plat_stmmacenet_data {
 	struct reset_control *stmmac_rst;
 	struct stmmac_axi *axi;
 	int has_gmac4;
+	bool has_xpcs;
+	int pcs_mode;
 	bool has_sun8i;
 	bool tso_en;
 	int mac_port_sel_speed;
Signature · 1 line
1.9.1
#8 lore raw

RE: [PATCH net-next v4 3/5] net: stmmac: add xpcs function hooks into main driver and ethtool

From: Voon Weifeng <[email protected]>
Date: Wed, May 29, 2019 at 17:58:25

Quoted 6 lines

+/**

+ *  xPCS_interrupt - xPCS ISR
+ *  @irq: interrupt number.
+ *  @dev_id: to pass the net device pointer.
+ *  Description: this is the xPCS interrupt service routine.

+ */

Please remove all JAVA docs from the series unless they are really useful. This looks like it's stating the obvious and just pollutes the eyes.

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static irqreturn_t stmmac_interrupt(int irq, void *dev_id) · line 3826

Quoted 7 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +7 -0
+static irqreturn_t xpcs_interrupt(int irq, void *dev_id)
+{
+	struct net_device *ndev = (struct net_device *)dev_id;
+	struct stmmac_priv *priv = netdev_priv(ndev);
+	irqreturn_t ret = IRQ_NONE;
+
+	if (unlikely(!ndev)) {

This is a useless check because you already dereference the pointer when you assign "priv" variable.

Thanks,
Jose Miguel Abreu

#9 lore raw

PATCH v4 4/5 net: stmmac: add xPCS functions for device with DWMACv5.1

In reply to Voon Weifeng

From: Ong Boon Leong <[email protected]>

We introduce support for driver that has v5.10 IP and is also using xPCS as MMD. This can be easily enabled for other product that integrates xPCS that is not using v5.00 IP.

---
 drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 33 ++++++++++++++++++
 drivers/net/ethernet/stmicro/stmmac/hwif.c        | 42 ++++++++++++++++++++++-
 drivers/net/ethernet/stmicro/stmmac/hwif.h        |  2 ++
 3 files changed, 76 insertions(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +33 -0
index 5e98da4e14f9..3afb60f2775c 100644
@@ -824,6 +824,39 @@ static void dwmac4_set_mac_loopback(void __iomem *ioaddr, bool enable)
 	.set_mac_loopback = dwmac4_set_mac_loopback,
 };
 
+const struct stmmac_ops dwmac510_xpcs_ops = {
+	.core_init = dwmac4_core_init,
+	.set_mac = stmmac_dwmac4_set_mac,
+	.rx_ipc = dwmac4_rx_ipc_enable,
+	.rx_queue_enable = dwmac4_rx_queue_enable,
+	.rx_queue_prio = dwmac4_rx_queue_priority,
+	.tx_queue_prio = dwmac4_tx_queue_priority,
+	.rx_queue_routing = dwmac4_rx_queue_routing,
+	.prog_mtl_rx_algorithms = dwmac4_prog_mtl_rx_algorithms,
+	.prog_mtl_tx_algorithms = dwmac4_prog_mtl_tx_algorithms,
+	.set_mtl_tx_queue_weight = dwmac4_set_mtl_tx_queue_weight,
+	.map_mtl_to_dma = dwmac4_map_mtl_dma,
+	.config_cbs = dwmac4_config_cbs,
+	.dump_regs = dwmac4_dump_regs,
+	.host_irq_status = dwmac4_irq_status,
+	.host_mtl_irq_status = dwmac4_irq_mtl_status,
+	.flow_ctrl = dwmac4_flow_ctrl,
+	.pmt = dwmac4_pmt,
+	.set_umac_addr = dwmac4_set_umac_addr,
+	.get_umac_addr = dwmac4_get_umac_addr,
+	.set_eee_mode = dwmac4_set_eee_mode,
+	.reset_eee_mode = dwmac4_reset_eee_mode,
+	.set_eee_timer = dwmac4_set_eee_timer,
+	.set_eee_pls = dwmac4_set_eee_pls,
+	.debug = dwmac4_debug,
+	.set_filter = dwmac4_set_filter,
+	.safety_feat_config = dwmac5_safety_feat_config,
+	.safety_feat_irq_status = dwmac5_safety_feat_irq_status,
+	.safety_feat_dump = dwmac5_safety_feat_dump,
+	.rxp_config = dwmac5_rxp_config,
+	.flex_pps_config = dwmac5_flex_pps_config,
+};
+
 int dwmac4_setup(struct stmmac_priv *priv)
 {
 	struct mac_device_info *mac = priv->hw;
drivers/net/ethernet/stmicro/stmmac/hwif.c +41 -1

161 lines not on this page · raw message

drivers/net/ethernet/stmicro/stmmac/hwif.h +2 -0
index 8531d33f8eb9..9726245d10b4 100644
@@ -509,6 +509,7 @@ struct stmmac_regs_off {
 };
 
 extern const struct stmmac_ops dwmac100_ops;
+extern const struct stmmac_xpcs stmmac_xpcs_ops;
 extern const struct stmmac_dma_ops dwmac100_dma_ops;
 extern const struct stmmac_ops dwmac1000_ops;
 extern const struct stmmac_dma_ops dwmac1000_dma_ops;
@@ -517,6 +518,7 @@ struct stmmac_regs_off {
 extern const struct stmmac_ops dwmac410_ops;
 extern const struct stmmac_dma_ops dwmac410_dma_ops;
 extern const struct stmmac_ops dwmac510_ops;
+extern const struct stmmac_ops dwmac510_xpcs_ops;
 extern const struct stmmac_tc_ops dwmac510_tc_ops;
 extern const struct stmmac_ops dwxgmac210_ops;
 extern const struct stmmac_dma_ops dwxgmac210_dma_ops;
Signature · 1 line
1.9.1
Acked-by on v4 4/5
#10 lore raw

RE: [PATCH net-next v4 4/5] net: stmmac: add xPCS functions for device with DWMACv5.1

From: Voon Weifeng <[email protected]>
Date: Wed, May 29, 2019 at 17:58:26

Quoted 6 lines

From: Ong Boon Leong <[email protected]>

We introduce support for driver that has v5.10 IP and is also using xPCS as MMD. This can be easily enabled for other product that integrates xPCS that is not using v5.00 IP.

Quoted 6 lines

Thanks,
Jose Miguel
Abreu

#11 lore raw

PATCH v4 5/5 net: stmmac: add EHL SGMII 1Gbps PCI info and PCI ID

In reply to Voon Weifeng

Added EHL SGMII 1Gbps PCI ID. Different MII and speed will have different PCI ID.

---
 drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 111 +++++++++++++++++++++++
 1 file changed, 111 insertions(+)
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +111 -0
index 7cbc01f316fa..f2225c1eafc2 100644
@@ -23,6 +23,7 @@
 #include <linux/dmi.h>
 
 #include "stmmac.h"
+#include "dwxpcs.h"
 
 /*
  * This struct is used to associate PCI Function of MAC controller on a board,
@@ -118,6 +119,113 @@ static int stmmac_default_data(struct pci_dev *pdev,
 	.setup = stmmac_default_data,
 };
 
+static int ehl_common_data(struct pci_dev *pdev,
+			   struct plat_stmmacenet_data *plat)
+{
+	int i;
+
+	plat->bus_id = 1;
+	plat->phy_addr = 0;
+	plat->clk_csr = 5;
+	plat->has_gmac = 0;
+	plat->has_gmac4 = 1;
+	plat->xpcs_phy_addr = 0x16;
+	plat->pcs_mode = AN_CTRL_PCS_MD_C37_SGMII;
+	plat->force_sf_dma_mode = 0;
+	plat->tso_en = 1;
+
+	plat->rx_queues_to_use = 8;
+	plat->tx_queues_to_use = 8;
+	plat->rx_sched_algorithm = MTL_RX_ALGORITHM_SP;
+
+	for (i = 0; i < plat->rx_queues_to_use; i++) {
+		plat->rx_queues_cfg[i].mode_to_use = MTL_QUEUE_DCB;
+		plat->rx_queues_cfg[i].chan = i;
+
+		/* Disable Priority config by default */
+		plat->rx_queues_cfg[i].use_prio = false;
+
+		/* Disable RX queues routing by default */
+		plat->rx_queues_cfg[i].pkt_route = 0x0;
+	}
+
+	for (i = 0; i < plat->tx_queues_to_use; i++) {
+		plat->tx_queues_cfg[i].mode_to_use = MTL_QUEUE_DCB;
+
+		/* Disable Priority config by default */
+		plat->tx_queues_cfg[i].use_prio = false;
+	}
+
+	plat->tx_sched_algorithm = MTL_TX_ALGORITHM_WRR;
+	plat->tx_queues_cfg[0].weight = 0x09;
+	plat->tx_queues_cfg[1].weight = 0x0A;
+	plat->tx_queues_cfg[2].weight = 0x0B;
+	plat->tx_queues_cfg[3].weight = 0x0C;
+	plat->tx_queues_cfg[4].weight = 0x0D;
+	plat->tx_queues_cfg[5].weight = 0x0E;
+	plat->tx_queues_cfg[6].weight = 0x0F;
+	plat->tx_queues_cfg[7].weight = 0x10;
+
+	plat->mdio_bus_data->phy_reset = NULL;
+	plat->mdio_bus_data->phy_mask = 0;
+
+	plat->dma_cfg->pbl = 32;
+	plat->dma_cfg->pblx8 = true;
+	plat->dma_cfg->fixed_burst = 0;
+	plat->dma_cfg->mixed_burst = 0;
+	plat->dma_cfg->aal = 0;
+
+	plat->axi = devm_kzalloc(&pdev->dev, sizeof(*plat->axi),
+				 GFP_KERNEL);
+	if (!plat->axi)
+		return -ENOMEM;
+	plat->axi->axi_lpi_en = 0;
+	plat->axi->axi_xit_frm = 0;
+	plat->axi->axi_wr_osr_lmt = 0;
+	plat->axi->axi_rd_osr_lmt = 2;
+	plat->axi->axi_blen[0] = 4;
+	plat->axi->axi_blen[1] = 8;
+	plat->axi->axi_blen[2] = 16;
+
+	/* Set default value for multicast hash bins */
+	plat->multicast_filter_bins = HASH_TABLE_SIZE;
+
+	/* Set default value for unicast filter entries */
+	plat->unicast_filter_entries = 1;
+
+	/* Set the maxmtu to a default of JUMBO_LEN */
+	plat->maxmtu = JUMBO_LEN;
+
+	/* Set 32KB fifo size as the advertised fifo size in
+	 * the HW features is not the same as the HW implementation
+	 */
+	plat->tx_fifo_size = 32768;
+	plat->rx_fifo_size = 32768;
+
+	return 0;
+}
+
+static int ehl_sgmii1g_data(struct pci_dev *pdev,
+			    struct plat_stmmacenet_data *plat)
+{
+	int ret;
+
+	/* Set common default data first */
+	ret = ehl_common_data(pdev, plat);
+
+	if (ret)
+		return ret;
+
+	plat->interface = PHY_INTERFACE_MODE_SGMII;
+	plat->has_xpcs = 1;
+
+	return 0;
+}
+
+static struct stmmac_pci_info ehl_sgmii1g_pci_info = {
+	.setup = ehl_sgmii1g_data,
+};
+
 static const struct stmmac_pci_func_data galileo_stmmac_func_data[] = {
 	{
 		.func = 6,
@@ -290,6 +398,7 @@ static int stmmac_pci_probe(struct pci_dev *pdev,
 	res.addr = pcim_iomap_table(pdev)[i];
 	res.wol_irq = pdev->irq;
 	res.irq = pdev->irq;
+	res.xpcs_irq = 0;
 
 	return stmmac_dvr_probe(&pdev->dev, plat, &res);
 }
@@ -359,6 +468,7 @@ static int __maybe_unused stmmac_pci_resume(struct device *dev)
 
 #define STMMAC_QUARK_ID  0x0937
 #define STMMAC_DEVICE_ID 0x1108
+#define STMMAC_EHL_SGMII1G_ID   0x4b31
 
 #define STMMAC_DEVICE(vendor_id, dev_id, info)	{	\
 	PCI_VDEVICE(vendor_id, dev_id),			\
@@ -369,6 +479,7 @@ static int __maybe_unused stmmac_pci_resume(struct device *dev)
 	STMMAC_DEVICE(STMMAC, STMMAC_DEVICE_ID, stmmac_pci_info),
 	STMMAC_DEVICE(STMICRO, PCI_DEVICE_ID_STMICRO_MAC, stmmac_pci_info),
 	STMMAC_DEVICE(INTEL, STMMAC_QUARK_ID, quark_pci_info),
+	STMMAC_DEVICE(INTEL, STMMAC_EHL_SGMII1G_ID, ehl_sgmii1g_pci_info),
 	{}
 };
 
Signature · 1 line
1.9.1
#12 lore raw

RE: [PATCH net-next v4 5/5] net: stmmac: add EHL SGMII 1Gbps PCI info and PCI ID

From: Voon Weifeng <[email protected]>
Date: Wed, May 29, 2019 at 17:58:27

drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c static int stmmac_default_data(struct pci_dev *pdev, · line 181

Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +4 -0
+	plat->axi = devm_kzalloc(&pdev->dev, sizeof(*plat->axi),
+				 GFP_KERNEL);
+	if (!plat->axi)
+		return -ENOMEM;

Missing line break here.

drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c static int stmmac_default_data(struct pci_dev *pdev, · line 184

Quoted 3 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +3 -0
+	plat->axi->axi_lpi_en = 0;
+	plat->axi->axi_xit_frm = 0;
+	plat->axi->axi_wr_osr_lmt = 0;

This is not a valid value.

Quoted 7 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +7 -0
+	plat->axi->axi_rd_osr_lmt = 2;
+	plat->axi->axi_blen[0] = 4;
+	plat->axi->axi_blen[1] = 8;
+	plat->axi->axi_blen[2] = 16;
+
+	/* Set default value for multicast hash bins */
+	plat->multicast_filter_bins = HASH_TABLE_SIZE;

drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c static int stmmac_default_data(struct pci_dev *pdev, · line 201

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +10 -0
+
+	/* Set default value for unicast filter entries */
+	plat->unicast_filter_entries = 1;
+
+	/* Set the maxmtu to a default of JUMBO_LEN */
+	plat->maxmtu = JUMBO_LEN;
+
+	/* Set 32KB fifo size as the advertised fifo size in
+	 * the HW features is not the same as the HW implementation
+	 */

Hmm ? I'm curious, can you explain ?

Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +4 -0
+	plat->tx_fifo_size = 32768;
+	plat->rx_fifo_size = 32768;
+
+	return 0;

drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c static int stmmac_default_data(struct pci_dev *pdev, · line 215

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +10 -0
+}
+
+static int ehl_sgmii1g_data(struct pci_dev *pdev,
+			    struct plat_stmmacenet_data *plat)
+{
+	int ret;
+
+	/* Set common default data first */
+	ret = ehl_common_data(pdev, plat);
+

Remove the extra line break please.

Quoted 3 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +3 -0
+	if (ret)
+		return ret;
+
#13 lore raw

RE: [PATCH net-next v4 5/5] net: stmmac: add EHL SGMII 1Gbps PCI info and PCI ID

Quoted 6 lines

drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c static int stmmac_default_data(struct pci_dev *pdev, · line 184

Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +3 -0
+	plat->axi->axi_lpi_en = 0;
+	plat->axi->axi_xit_frm = 0;
+	plat->axi->axi_wr_osr_lmt = 0;

This is not a valid value.

Can you please explained why is not a valid value? And what should be the recommended value?
Databook mentioned that "Maximum outstanding requests = WR_OSR_LMT + 1"

Quoted 12 lines
Quoted 12 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +11 -0
+	plat->axi->axi_rd_osr_lmt = 2;
+	plat->axi->axi_blen[0] = 4;
+	plat->axi->axi_blen[1] = 8;
+	plat->axi->axi_blen[2] = 16;
+
+	/* Set default value for multicast hash bins */
+	plat->multicast_filter_bins = HASH_TABLE_SIZE;
+
+	/* Set default value for unicast filter entries */
+	plat->unicast_filter_entries = 1;
+
Quoted 8 lines

drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c static int stmmac_default_data(struct pci_dev *pdev, · line 201

Quoted 6 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +6 -0
+	/* Set the maxmtu to a default of JUMBO_LEN */
+	plat->maxmtu = JUMBO_LEN;
+
+	/* Set 32KB fifo size as the advertised fifo size in
+	 * the HW features is not the same as the HW implementation
+	 */

Hmm ? I'm curious, can you explain ?

The RTL comes with a 64KB selection in HW features. But the HW implementation only uses a 32KB RAM. This will be documented as errata.

Quoted 15 lines
Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +3 -0
+	plat->tx_fifo_size = 32768;
+	plat->rx_fifo_size = 32768;
+

drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c static int stmmac_default_data(struct pci_dev *pdev, · line 215

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +10 -0
+	return 0;
+}
+
+static int ehl_sgmii1g_data(struct pci_dev *pdev,
+			    struct plat_stmmacenet_data *plat) {
+	int ret;
+
+	/* Set common default data first */
+	ret = ehl_common_data(pdev, plat);
+

Regards
Weifeng