Add 10GbE support in stmmac using XGMAC2
Subsystems (5)
cover Add 10GbE support in stmmac using XGMAC2
This series adds support for 10Gigabit IP in stmmac. The IP is called XGMAC2 and has many similarities with GMAC4. Due to this, its relatively easy to incorporate this new IP into stmmac driver by adding a new block and filling the necessary callbacks.
The functionality added by this series is still reduced but its only a starting point which will later be expanded.
I splitted the patches into funcionality and to ease the review. Only the patch 8/9 really enables the XGMAC2 block by adding a new compatible string.
Jose Abreu (9):
net: stmmac: Add XGMAC 2.10 HWIF entry
net: stmmac: Add MAC related callbacks for XGMAC2
net: stmmac: Add DMA related callbacks for XGMAC2
net: stmmac: Add descriptor related callbacks for XGMAC2
net: stmmac: Add MDIO related functions for XGMAC2
net: stmmac: Add PTP support for XGMAC2
net: stmmac: Integrate XGMAC into main driver flow
net: stmmac: Add the bindings parsing for XGMAC2
bindings: net: stmmac: Add the bindings documentation for XGMAC2.
Documentation/devicetree/bindings/net/stmmac.txt | 3 +- drivers/net/ethernet/stmicro/stmmac/Makefile | 3 +- drivers/net/ethernet/stmicro/stmmac/common.h | 17 +- .../net/ethernet/stmicro/stmmac/dwmac-generic.c | 2 + drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h | 226 ++++++++++++ .../net/ethernet/stmicro/stmmac/dwxgmac2_core.c | 371 +++++++++++++++++++ .../net/ethernet/stmicro/stmmac/dwxgmac2_descs.c | 280 ++++++++++++++ drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c | 410 +++++++++++++++++++++ drivers/net/ethernet/stmicro/stmmac/hwif.c | 31 +- drivers/net/ethernet/stmicro/stmmac/hwif.h | 3 + drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 55 ++- drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 88 +++++ .../net/ethernet/stmicro/stmmac/stmmac_platform.c | 6 + drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c | 6 +- drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h | 1 + include/linux/stmmac.h | 1 + 16 files changed, 1481 insertions(+), 22 deletions(-) create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c
Signature · 1 line
2.7.4
PATCH 1/9 net: stmmac: Add XGMAC 2.10 HWIF entry
Add a new entry to HWIF table for XGMAC 2.10. For now we fill it with empty callbacks which will be added in posterior patches.
--- drivers/net/ethernet/stmicro/stmmac/common.h | 14 +++++++------ drivers/net/ethernet/stmicro/stmmac/hwif.c | 31 ++++++++++++++++++++++++++-- include/linux/stmmac.h | 1 + 3 files changed, 38 insertions(+), 8 deletions(-)
drivers/net/ethernet/stmicro/stmmac/common.h +8 -6
@@ -36,12 +36,14 @@#include "mmc.h" /* Synopsys Core versions */ -#define DWMAC_CORE_3_40 0x34 -#define DWMAC_CORE_3_50 0x35 -#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_3_40 0x34 +#define DWMAC_CORE_3_50 0x35 +#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 DWXGMAC_CORE_2_10 0x21 +#define STMMAC_CHAN0 0/* Always supported and default for all chips */ /* These need to be power of two, and >= 4 */
drivers/net/ethernet/stmicro/stmmac/hwif.c +29 -2
@@ -72,6 +72,7 @@ static int stmmac_dwmac4_quirks(struct stmmac_priv *priv) static const struct stmmac_hwif_entry { bool gmac; bool gmac4; + bool xgmac; u32 min_id; const struct stmmac_regs_off regs; const void *desc;
@@ -87,6 +88,7 @@ static const struct stmmac_hwif_entry { { .gmac = false, .gmac4 = false, + .xgmac = false, .min_id = 0, .regs = { .ptp_off = PTP_GMAC3_X_OFFSET,
@@ -103,6 +105,7 @@ static const struct stmmac_hwif_entry { }, { .gmac = true, .gmac4 = false, + .xgmac = false, .min_id = 0, .regs = { .ptp_off = PTP_GMAC3_X_OFFSET,
@@ -119,6 +122,7 @@ static const struct stmmac_hwif_entry { }, { .gmac = false, .gmac4 = true, + .xgmac = false, .min_id = 0, .regs = { .ptp_off = PTP_GMAC4_OFFSET,
@@ -135,6 +139,7 @@ static const struct stmmac_hwif_entry { }, { .gmac = false, .gmac4 = true, + .xgmac = false, .min_id = DWMAC_CORE_4_00, .regs = { .ptp_off = PTP_GMAC4_OFFSET,
@@ -151,6 +156,7 @@ static const struct stmmac_hwif_entry { }, { .gmac = false, .gmac4 = true, + .xgmac = false, .min_id = DWMAC_CORE_4_10, .regs = { .ptp_off = PTP_GMAC4_OFFSET,
@@ -167,6 +173,7 @@ static const struct stmmac_hwif_entry { }, { .gmac = false, .gmac4 = true, + .xgmac = false, .min_id = DWMAC_CORE_5_10, .regs = { .ptp_off = PTP_GMAC4_OFFSET,
@@ -180,11 +187,29 @@ static const struct stmmac_hwif_entry { .tc = &dwmac510_tc_ops, .setup = dwmac4_setup, .quirks = NULL, - } + }, { + .gmac = false, + .gmac4 = false, + .xgmac = true, + .min_id = DWXGMAC_CORE_2_10, + .regs = { + .ptp_off = 0, + .mmc_off = 0, + }, + .desc = NULL, + .dma = NULL, + .mac = NULL, + .hwtimestamp = NULL, + .mode = NULL, + .tc = NULL, + .setup = NULL, + .quirks = NULL, + }, };int stmmac_hwif_init (struct stmmac_priv *priv) { +bool needs_xgmac = priv->plat->has_xgmac;bool needs_gmac4 = priv->plat->has_gmac4;bool needs_gmac = priv->plat->has_gmac;const struct stmmac_hwif_entry *entry;
@@ -195,7 +220,7 @@ int stmmac_hwif_init(struct stmmac_priv *priv)if (needs_gmac) { id =stmmac_get_id (priv,GMAC_VERSION ); - }else if (needs_gmac4) { + }else if (needs_gmac4 || needs_xgmac) { id =stmmac_get_id (priv,GMAC4_VERSION ); }else { id =0 ;
@@ -229,6 +254,8 @@ int stmmac_hwif_init(struct stmmac_priv *priv)continue ;if (needs_gmac4 ^ entry->gmac4)continue ; +if (needs_xgmac ^ entry->xgmac) +continue ;/* Use synopsys_id var because some setups can override this */ if (priv->synopsys_id < entry->min_id)continue ;
include/linux/stmmac.h +1 -0
@@ -190,5 +190,6 @@ struct plat_stmmacenet_data {bool tso_en;int mac_port_sel_speed;bool en_tx_lpi_clockgating; + int has_xgmac; };#endif
Signature · 1 line
2.7.4
PATCH 2/9 net: stmmac: Add MAC related callbacks for XGMAC2
In reply to Jose AbreuAdd the MAC related callbacks for the new IP block XGMAC2.
--- drivers/net/ethernet/stmicro/stmmac/Makefile | 2 +- drivers/net/ethernet/stmicro/stmmac/common.h | 3 + drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h | 140 ++++++++ .../net/ethernet/stmicro/stmmac/dwxgmac2_core.c | 371 +++++++++++++++++++++ drivers/net/ethernet/stmicro/stmmac/hwif.c | 4 +- drivers/net/ethernet/stmicro/stmmac/hwif.h | 1 + 6 files changed, 518 insertions(+), 3 deletions(-) create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c
drivers/net/ethernet/stmicro/stmmac/Makefile +1 -1
@@ -5,7 +5,7 @@ stmmac-objs:= stmmac_main.o stmmac_ethtool.o stmmac_mdio.o ring_mode.o \ dwmac100_core.o dwmac100_dma.o enh_desc.o norm_desc.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 $(stmmac-y) + stmmac_tc.o dwxgmac2_core.o $(stmmac-y) # Ordering matters. Generic driver must be last. obj-$(CONFIG_STMMAC_PLATFORM) += stmmac-platform.o
drivers/net/ethernet/stmicro/stmmac/common.h +3 -0
@@ -400,6 +400,8 @@ struct mac_link {u32 speed10;u32 speed100;u32 speed1000; +u32 speed2500; +u32 speed10000;u32 duplex; };
@@ -441,6 +443,7 @@ struct stmmac_rx_routing {int dwmac100_setup (struct stmmac_priv *priv);int dwmac1000_setup (struct stmmac_priv *priv);int dwmac4_setup (struct stmmac_priv *priv); +int dwxgmac2_setup (struct stmmac_priv *priv);void stmmac_set_mac_addr (void __iomem *ioaddr,u8 addr[6 ],unsigned int high,unsigned int low);
drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h new file +140 -0
140 lines not on this page · raw message
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c new file +371 -0
371 lines not on this page · raw message
drivers/net/ethernet/stmicro/stmmac/hwif.c +2 -2
@@ -198,11 +198,11 @@ static const struct stmmac_hwif_entry { }, .desc = NULL, .dma = NULL, - .mac = NULL, + .mac = &dwxgmac210_ops, .hwtimestamp = NULL, .mode = NULL, .tc = NULL, - .setup = NULL, + .setup = dwxgmac2_setup, .quirks = NULL, }, };
drivers/net/ethernet/stmicro/stmmac/hwif.h +1 -0
@@ -479,6 +479,7 @@ 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_tc_ops dwmac510_tc_ops; +extern const struct stmmac_ops dwxgmac210_ops;#define GMAC_VERSION 0x00000020/* GMAC CORE Version */ #define GMAC4_VERSION 0x00000110/* GMAC4+ CORE Version */
Signature · 1 line
2.7.4
PATCH 3/9 net: stmmac: Add DMA related callbacks for XGMAC2
In reply to Jose AbreuAdd the DMA related callbacks for the new IP block XGMAC2.
--- drivers/net/ethernet/stmicro/stmmac/Makefile | 2 +- drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h | 56 +++ drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c | 410 +++++++++++++++++++++ drivers/net/ethernet/stmicro/stmmac/hwif.c | 2 +- drivers/net/ethernet/stmicro/stmmac/hwif.h | 1 + 5 files changed, 469 insertions(+), 2 deletions(-) create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c
drivers/net/ethernet/stmicro/stmmac/Makefile +1 -1
@@ -5,7 +5,7 @@ stmmac-objs:= stmmac_main.o stmmac_ethtool.o stmmac_mdio.o ring_mode.o \ dwmac100_core.o dwmac100_dma.o enh_desc.o norm_desc.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 $(stmmac-y) + stmmac_tc.o dwxgmac2_core.o dwxgmac2_dma.o $(stmmac-y) # Ordering matters. Generic driver must be last. obj-$(CONFIG_STMMAC_PLATFORM) += stmmac-platform.o
drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h +56 -0
60 lines not on this page · raw message
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c new file +410 -0
410 lines not on this page · raw message
drivers/net/ethernet/stmicro/stmmac/hwif.c +1 -1
@@ -197,7 +197,7 @@ static const struct stmmac_hwif_entry { .mmc_off = 0, }, .desc = NULL, - .dma = NULL, + .dma = &dwxgmac210_dma_ops, .mac = &dwxgmac210_ops, .hwtimestamp = NULL, .mode = NULL,
drivers/net/ethernet/stmicro/stmmac/hwif.h +1 -0
@@ -480,6 +480,7 @@ extern const struct stmmac_dma_ops dwmac410_dma_ops;extern const struct stmmac_ops dwmac510_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;#define GMAC_VERSION 0x00000020/* GMAC CORE Version */ #define GMAC4_VERSION 0x00000110/* GMAC4+ CORE Version */
Signature · 1 line
2.7.4
PATCH 4/9 net: stmmac: Add descriptor related callbacks for XGMAC2
In reply to Jose AbreuAdd the descriptor related callbacks for the new IP block XGMAC2.
--- drivers/net/ethernet/stmicro/stmmac/Makefile | 3 +- drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h | 30 +++ .../net/ethernet/stmicro/stmmac/dwxgmac2_descs.c | 280 +++++++++++++++++++++ drivers/net/ethernet/stmicro/stmmac/hwif.c | 2 +- drivers/net/ethernet/stmicro/stmmac/hwif.h | 1 + 5 files changed, 314 insertions(+), 2 deletions(-) create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c
drivers/net/ethernet/stmicro/stmmac/Makefile +2 -1
@@ -5,7 +5,8 @@ stmmac-objs:= stmmac_main.o stmmac_ethtool.o stmmac_mdio.o ring_mode.o \ dwmac100_core.o dwmac100_dma.o enh_desc.o norm_desc.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 $(stmmac-y) + stmmac_tc.o dwxgmac2_core.o dwxgmac2_dma.o dwxgmac2_descs.o \ + $(stmmac-y) # Ordering matters. Generic driver must be last. obj-$(CONFIG_STMMAC_PLATFORM) += stmmac-platform.o
drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h +30 -0
@@ -193,4 +193,34 @@#define XGMAC_TPS BIT(1)#define XGMAC_TI BIT(0) +/* Descriptors */ +#define XGMAC_TDES2_IOC BIT(31) +#define XGMAC_TDES2_TTSE BIT(30) +#define XGMAC_TDES2_B2L GENMASK(29, 16) +#define XGMAC_TDES2_B2L_SHIFT 16 +#define XGMAC_TDES2_B1L GENMASK(13, 0) +#define XGMAC_TDES3_OWN BIT(31) +#define XGMAC_TDES3_CTXT BIT(30) +#define XGMAC_TDES3_FD BIT(29) +#define XGMAC_TDES3_LD BIT(28) +#define XGMAC_TDES3_CPC GENMASK(27, 26) +#define XGMAC_TDES3_CPC_SHIFT 26 +#define XGMAC_TDES3_TCMSSV BIT(26) +#define XGMAC_TDES3_THL GENMASK(22, 19) +#define XGMAC_TDES3_THL_SHIFT 19 +#define XGMAC_TDES3_TSE BIT(18) +#define XGMAC_TDES3_CIC GENMASK(17, 16) +#define XGMAC_TDES3_CIC_SHIFT 16 +#define XGMAC_TDES3_TPL GENMASK(17, 0) +#define XGMAC_TDES3_FL GENMASK(14, 0) +#define XGMAC_RDES3_OWN BIT(31) +#define XGMAC_RDES3_CTXT BIT(30) +#define XGMAC_RDES3_IOC BIT(30) +#define XGMAC_RDES3_LD BIT(28) +#define XGMAC_RDES3_CDA BIT(27) +#define XGMAC_RDES3_ES BIT(15) +#define XGMAC_RDES3_PL GENMASK(13, 0) +#define XGMAC_RDES3_TSD BIT(6) +#define XGMAC_RDES3_TSA BIT(4) +#endif /* __STMMAC_DWXGMAC2_H__ */
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c new file +280 -0
280 lines not on this page · raw message
drivers/net/ethernet/stmicro/stmmac/hwif.c +1 -1
@@ -196,7 +196,7 @@ static const struct stmmac_hwif_entry { .ptp_off = 0, .mmc_off = 0, }, - .desc = NULL, + .desc = &dwxgmac210_desc_ops, .dma = &dwxgmac210_dma_ops, .mac = &dwxgmac210_ops, .hwtimestamp = NULL,
drivers/net/ethernet/stmicro/stmmac/hwif.h +1 -0
@@ -481,6 +481,7 @@ extern const struct stmmac_ops dwmac510_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; +extern const struct stmmac_desc_ops dwxgmac210_desc_ops;#define GMAC_VERSION 0x00000020/* GMAC CORE Version */ #define GMAC4_VERSION 0x00000110/* GMAC4+ CORE Version */
Signature · 1 line
2.7.4
PATCH 5/9 net: stmmac: Add MDIO related functions for XGMAC2
In reply to Jose AbreuAdd the MDIO related funcionalities for the new IP block XGMAC2.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 88 +++++++++++++++++++++++ 1 file changed, 88 insertions(+)
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +88 -0
@@ -39,6 +39,88 @@#define MII_GMAC4_WRITE (1 << MII_GMAC4_GOC_SHIFT)#define MII_GMAC4_READ (3 << MII_GMAC4_GOC_SHIFT) +/* XGMAC defines */ +#define MII_XGMAC_CMD_SHIFT 16 +#define MII_XGMAC_WRITE (1 << MII_XGMAC_CMD_SHIFT) +#define MII_XGMAC_READ (3 << MII_XGMAC_CMD_SHIFT) +#define MII_XGMAC_BUSY BIT(22) + +static int stmmac_xgmac2_mdio_read (struct stmmac_priv *priv,int phyaddr, +int phyreg) +{ +unsigned int mii_address = priv->hw->mii.addr; +unsigned int mii_data = priv->hw->mii.data; +u32 tmp, addr, value =MII_XGMAC_BUSY ; +int data; + +if (phyreg &MII_ADDR_C45 ) { + addr = ((phyreg >>16 ) &0x1f ) <<21 ; + addr |= (phyaddr <<16 ) | (phyreg &0xffff ); + }else { +if (phyaddr >=4 ) +return -ENODEV ; +writel (~0x0 , priv->ioaddr +0x220 ); + addr = (phyaddr <<16 ) | (phyreg &0x1f ); + } + + value |= (priv->clk_csr << priv->hw->mii.clk_csr_shift) + & priv->hw->mii.clk_csr_mask; + value |=BIT (18 ); + value |=MII_XGMAC_READ ; + +if (readl_poll_timeout (priv->ioaddr + mii_data, tmp, + !(tmp &MII_XGMAC_BUSY ),100 ,10000 )) +return -EBUSY ; + +writel (addr, priv->ioaddr + mii_address); +writel (value, priv->ioaddr + mii_data); + +if (readl_poll_timeout (priv->ioaddr + mii_data, tmp, + !(tmp &MII_XGMAC_BUSY ),100 ,10000 )) +return -EBUSY ; + +/* Read the data from the MII data register */ + data = (int )readl (priv->ioaddr + mii_data) &GENMASK (15 ,0 ); + +return data; +} + +static int stmmac_xgmac2_mdio_write (struct stmmac_priv *priv,int phyaddr, +int phyreg,u16 phydata) +{ +unsigned int mii_address = priv->hw->mii.addr; +unsigned int mii_data = priv->hw->mii.data; +u32 addr, tmp, value =MII_XGMAC_BUSY ; + +if (phyreg &MII_ADDR_C45 ) { + addr = ((phyreg >>16 ) &0x1f ) <<21 ; + addr |= (phyaddr <<16 ) | (phyreg &0xffff ); + }else { +if (phyaddr >=4 ) +return -ENODEV ; +writel (~0x0 , priv->ioaddr +0x220 ); + addr = (phyaddr <<16 ) | (phyreg &0x1f ); + } + + value |= (priv->clk_csr << priv->hw->mii.clk_csr_shift) + & priv->hw->mii.clk_csr_mask; + value |= phydata |BIT (18 ); + value |=MII_XGMAC_WRITE ; + +/* Wait until any existing MII operation is complete */ +if (readl_poll_timeout (priv->ioaddr + mii_data, tmp, + !(tmp &MII_XGMAC_BUSY ),100 ,10000 )) +return -EBUSY ; + +/* Set the MII address register to write */ +writel (addr, priv->ioaddr + mii_address); +writel (value, priv->ioaddr + mii_data); + +/* Wait until any existing MII operation is complete */ +return readl_poll_timeout (priv->ioaddr + mii_data, tmp, + !(tmp &MII_XGMAC_BUSY ),100 ,10000 ); +} +/** * stmmac_mdio_read * @bus: points to the mii_bus structure
@@ -59,6 +141,9 @@ static int stmmac_mdio_read(struct mii_bus *bus, int phyaddr, int phyreg)int data;u32 value =MII_BUSY ; +if (priv->plat->has_xgmac) +return stmmac_xgmac2_mdio_read (priv, phyaddr, phyreg); + value |= (phyaddr << priv->hw->mii.addr_shift) & priv->hw->mii.addr_mask; value |= (phyreg << priv->hw->mii.reg_shift) & priv->hw->mii.reg_mask;
@@ -101,6 +186,9 @@ static int stmmac_mdio_write(struct mii_bus *bus, int phyaddr, int phyreg,u32 v;u32 value =MII_BUSY ; +if (priv->plat->has_xgmac) +return stmmac_xgmac2_mdio_write (priv, phyaddr, phyreg, phydata); + value |= (phyaddr << priv->hw->mii.addr_shift) & priv->hw->mii.addr_mask; value |= (phyreg << priv->hw->mii.reg_shift) & priv->hw->mii.reg_mask;
Signature · 1 line
2.7.4
PATCH 6/9 net: stmmac: Add PTP support for XGMAC2
In reply to Jose AbreuXGMAC2 uses the same engine of timestamping as GMAC4. Let's use the same callbacks.
--- drivers/net/ethernet/stmicro/stmmac/hwif.c | 4 ++-- drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c | 6 ++++-- drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h | 1 + 3 files changed, 7 insertions(+), 4 deletions(-)
drivers/net/ethernet/stmicro/stmmac/hwif.c +2 -2
@@ -193,13 +193,13 @@ static const struct stmmac_hwif_entry { .xgmac = true, .min_id = DWXGMAC_CORE_2_10, .regs = { - .ptp_off = 0, + .ptp_off = PTP_XGMAC_OFFSET, .mmc_off = 0, }, .desc = &dwxgmac210_desc_ops, .dma = &dwxgmac210_dma_ops, .mac = &dwxgmac210_ops, - .hwtimestamp = NULL, + .hwtimestamp = &stmmac_ptp, .mode = NULL, .tc = NULL, .setup = dwxgmac2_setup,
drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c +4 -2
@@ -71,6 +71,9 @@ static int stmmac_adjust_time(struct ptp_clock_info *ptp, s64 delta)u32 sec, nsec;u32 quotient, reminder;int neg_adj =0 ; +bool xmac; + + xmac = priv->plat->has_gmac4 || priv->plat->has_xgmac;if (delta <0 ) { neg_adj =1 ;
@@ -82,8 +85,7 @@ static int stmmac_adjust_time(struct ptp_clock_info *ptp, s64 delta) nsec = reminder;spin_lock_irqsave (&priv->ptp_lock, flags); -stmmac_adjust_systime (priv, priv->ptpaddr, sec, nsec, neg_adj, - priv->plat->has_gmac4); +stmmac_adjust_systime (priv, priv->ptpaddr, sec, nsec, neg_adj, xmac);spin_unlock_irqrestore (&priv->ptp_lock, flags);return 0 ;
drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h +1 -0
@@ -21,6 +21,7 @@#ifndef __STMMAC_PTP_H__#define __STMMAC_PTP_H__ +#define PTP_XGMAC_OFFSET 0xd00#define PTP_GMAC4_OFFSET 0xb00#define PTP_GMAC3_X_OFFSET 0x700
Signature · 1 line
2.7.4
PATCH 7/9 net: stmmac: Integrate XGMAC into main driver flow
In reply to Jose AbreuNow that we have all the XGMAC related callbacks, lets start integrating this IP block into main driver.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 55 ++++++++++++++++++----- 1 file changed, 45 insertions(+), 10 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +45 -10
@@ -51,6 +51,7 @@#include <linux/reset.h> #include <linux/of_mdio.h> #include "dwmac1000.h" +#include "dwxgmac2.h" #include "hwif.h" #define STMMAC_ALIGN (x) L1_CACHE_ALIGN(x)
@@ -262,6 +263,21 @@ static void stmmac_clk_csr_set(struct stmmac_priv *priv)else priv->clk_csr =0 ; } + +if (priv->plat->has_xgmac) { +if (clk_rate >400000000 ) + priv->clk_csr =0x5 ; +else if (clk_rate >350000000 ) + priv->clk_csr =0x4 ; +else if (clk_rate >300000000 ) + priv->clk_csr =0x3 ; +else if (clk_rate >250000000 ) + priv->clk_csr =0x2 ; +else if (clk_rate >150000000 ) + priv->clk_csr =0x1 ; +else + priv->clk_csr =0x0 ; + } }static void print_pkt (unsigned char *buf,int len)
@@ -498,7 +514,7 @@ static void stmmac_get_rx_hwtstamp(struct stmmac_priv *priv, struct dma_desc *p,if (!priv->hwts_rx_en)return ;/* For GMAC4, the valid timestamp is from CTX next desc. */ -if (priv->plat->has_gmac4) +if (priv->plat->has_gmac4 || priv->plat->has_xgmac) desc = np;/* Check if timestamp is available */
@@ -540,6 +556,9 @@ static int stmmac_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr)u32 ts_event_en =0 ;u32 value =0 ;u32 sec_inc; +bool xmac; + + xmac = priv->plat->has_gmac4 || priv->plat->has_xgmac;if (!(priv->dma_cap.time_stamp || priv->adv_ts)) {netdev_alert (priv->dev,"No support for HW time stamping\n" );
@@ -575,7 +594,7 @@ static int stmmac_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr)/* PTP v1, UDP, any kind of event packet */ config.rx_filter =HWTSTAMP_FILTER_PTP_V1_L4_EVENT ;/* take time stamp for all event messages */ -if (priv->plat->has_gmac4) +if (xmac) snap_type_sel =PTP_GMAC4_TCR_SNAPTYPSEL_1 ;else snap_type_sel =PTP_TCR_SNAPTYPSEL_1 ;
@@ -610,7 +629,7 @@ static int stmmac_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr) config.rx_filter =HWTSTAMP_FILTER_PTP_V2_L4_EVENT ; ptp_v2 =PTP_TCR_TSVER2ENA ;/* take time stamp for all event messages */ -if (priv->plat->has_gmac4) +if (xmac) snap_type_sel =PTP_GMAC4_TCR_SNAPTYPSEL_1 ;else snap_type_sel =PTP_TCR_SNAPTYPSEL_1 ;
@@ -647,7 +666,7 @@ static int stmmac_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr) config.rx_filter =HWTSTAMP_FILTER_PTP_V2_EVENT ; ptp_v2 =PTP_TCR_TSVER2ENA ;/* take time stamp for all event messages */ -if (priv->plat->has_gmac4) +if (xmac) snap_type_sel =PTP_GMAC4_TCR_SNAPTYPSEL_1 ;else snap_type_sel =PTP_TCR_SNAPTYPSEL_1 ;
@@ -718,7 +737,7 @@ static int stmmac_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr)/* program Sub Second Increment reg */ stmmac_config_sub_second_increment (priv, priv->ptpaddr, priv->plat->clk_ptp_rate, - priv->plat->has_gmac4, &sec_inc); + xmac, &sec_inc); temp =div_u64 (1000000000ULL , sec_inc);/* Store sub second increment and flags for later use */
@@ -755,12 +774,14 @@ static int stmmac_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr)*/ static int stmmac_init_ptp (struct stmmac_priv *priv) { +bool xmac = priv->plat->has_gmac4 || priv->plat->has_xgmac; +if (!(priv->dma_cap.time_stamp || priv->dma_cap.atime_stamp))return -EOPNOTSUPP ; priv->adv_ts =0 ; -/* Check if adv_ts can be enabled for dwmac 4.x core */ -if (priv->plat->has_gmac4 && priv->dma_cap.atime_stamp) +/* Check if adv_ts can be enabled for dwmac 4.x / xgmac core */ +if (xmac && priv->dma_cap.atime_stamp) priv->adv_ts =1 ;/* Dwmac 3.x core with extend_desc can support adv_ts */ else if (priv->extend_desc && priv->dma_cap.atime_stamp)
@@ -842,6 +863,12 @@ static void stmmac_adjust_link(struct net_device *dev) new_state = true; ctrl &= ~priv->hw->link.speed_mask;switch (phydev->speed) { +case SPEED_10000 : + ctrl |= priv->hw->link.speed10000; +break ; +case SPEED_2500 : + ctrl |= priv->hw->link.speed2500; +break ;case SPEED_1000 : ctrl |= priv->hw->link.speed1000;break ;
@@ -3305,6 +3332,9 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)int coe = priv->hw->rx_csum;unsigned int next_entry;unsigned int count =0 ; +bool xmac; + + xmac = priv->plat->has_gmac4 || priv->plat->has_xgmac;if (netif_msg_rx_status (priv)) {void *rx_head;
@@ -3406,7 +3436,7 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)* in case of GMAC4 because it needs * to refill the used descriptors, always. */ -if (unlikely (!priv->plat->has_gmac4 && +if (unlikely (!xmac && ((frame_len < priv->rx_copybreak) ||stmmac_rx_threshold_count (rx_q)))) { skb = netdev_alloc_skb_ip_align(priv->dev,
@@ -3642,7 +3672,9 @@ static irqreturn_t stmmac_interrupt(int irq, void *dev_id)u32 tx_cnt = priv->plat->tx_queues_to_use;u32 queues_count;u32 queue; +bool xmac; + xmac = priv->plat->has_gmac4 || priv->plat->has_xgmac; queues_count = (rx_cnt > tx_cnt) ? rx_cnt : tx_cnt;if (priv->irq_wake)
@@ -3661,7 +3693,7 @@ static irqreturn_t stmmac_interrupt(int irq, void *dev_id)return IRQ_HANDLED ;/* To handle GMAC own interrupts */ -if ((priv->plat->has_gmac) || (priv->plat->has_gmac4)) { +if ((priv->plat->has_gmac) || xmac) {int status =stmmac_host_irq_status (priv, priv->hw, &priv->xstats);int mtl_status;
@@ -4269,6 +4301,8 @@ int stmmac_dvr_probe(struct device *device, ndev->min_mtu =ETH_ZLEN -ETH_HLEN ;if ((priv->plat->enh_desc) || (priv->synopsys_id >=DWMAC_CORE_4_00 )) ndev->max_mtu =JUMBO_LEN ; +else if (priv->plat->has_xgmac) + ndev->max_mtu =XGMAC_JUMBO_LEN ;else ndev->max_mtu =SKB_MAX_HEAD (NET_SKB_PAD +NET_IP_ALIGN );/* Will not overwrite ndev->max_mtu if plat->maxmtu > ndev->max_mtu
@@ -4290,7 +4324,8 @@ int stmmac_dvr_probe(struct device *device,* has to be disable and this can be done by passing the * riwt_off field from the platform. */ -if ((priv->synopsys_id >=DWMAC_CORE_3_50 ) && (!priv->plat->riwt_off)) { +if (((priv->synopsys_id >=DWMAC_CORE_3_50 ) || + (priv->plat->has_xgmac)) && (!priv->plat->riwt_off)) { priv->use_riwt =1 ;dev_info (priv->device,"Enable RX Mitigation via HW Watchdog Timer\n" );
Signature · 1 line
2.7.4
PATCH 8/9 net: stmmac: Add the bindings parsing for XGMAC2
In reply to Jose AbreuAdd the bindings parsing for XGMAC2 IP block.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-generic.c | 2 ++ drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 6 ++++++ 2 files changed, 8 insertions(+)
drivers/net/ethernet/stmicro/stmmac/dwmac-generic.c +2 -0
@@ -78,6 +78,8 @@ static const struct of_device_id dwmac_generic_match[] = { { .compatible = "snps,dwmac-4.00"}, { .compatible = "snps,dwmac-4.10a"}, { .compatible = "snps,dwmac"}, + { .compatible = "snps,dwxgmac-2.10"}, + { .compatible = "snps,dwxgmac"}, { } };MODULE_DEVICE_TABLE (of, dwmac_generic_match);
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +6 -0
@@ -486,6 +486,12 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) plat->force_sf_dma_mode =1 ; } +if (of_device_is_compatible (np,"snps,dwxgmac" )) { + plat->has_xgmac =1 ; + plat->pmt =1 ; + plat->tso_en =of_property_read_bool (np,"snps,tso" ); + } + dma_cfg =devm_kzalloc (&pdev->dev,sizeof (*dma_cfg),GFP_KERNEL );if (!dma_cfg) {
Signature · 1 line
2.7.4
PATCH 9/9 bindings: net: stmmac: Add the bindings documentation for XGMAC2.
In reply to Jose AbreuAdds the documentation for XGMAC2 DT bindings.
--- Documentation/devicetree/bindings/net/stmmac.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/net/stmmac.txt +2 -1
@@ -1,7 +1,8 @@ * STMicroelectronics 10/100/1000 Ethernet driver (GMAC) Required properties: -- compatible: Should be "snps,dwmac-<ip_version>", "snps,dwmac" +- compatible: Should be "snps,dwmac-<ip_version>", "snps,dwmac" or + "snps,dwxgmac-<ip_version", "snps,dwxgmac". For backwards compatibility: "st,spear600-gmac" is also supported. - reg: Address and length of the register set for the device - interrupt-parent: Should be the phandle for the interrupt controller
Signature · 1 line
2.7.4
Re: [PATCH net-next 9/9] bindings: net: stmmac: Add the bindings documentation for XGMAC2.
Hello!
Quoted 16 lines · Jose Abreu
Adds the documentation for XGMAC2 DT bindings.
Signed-off-by Jose Abreu <[email protected]>Cc David S. Miller <[email protected]>Cc Joao Pinto <[email protected]>Cc Giuseppe Cavallaro <[email protected]>Cc Alexandre Torgue <[email protected]>--- Documentation/devicetree/bindings/net/stmmac.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)Documentation/devicetree/bindings/net/stmmac.txt +0
-0
Documentation/devicetree/bindings/net/stmmac.txt line 5
Quoted 6 lines
Documentation/devicetree/bindings/net/stmmac.txt +2
-1@@ -1,7 +1,8 @@ * STMicroelectronics 10/100/1000 Ethernet driver (GMAC) Required properties: -- compatible: Should be "snps,dwmac-<ip_version>", "snps,dwmac" +- compatible: Should be "snps,dwmac-<ip_version>", "snps,dwmac" or + "snps,dwxgmac-<ip_version", "snps,dwxgmac".
^ missing >
[...]
MBR, Sergei
Re: [PATCH net-next 5/9] net: stmmac: Add MDIO related functions for XGMAC2
In reply to Jose AbreuHi Jose
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c line 58
Quoted 11 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +11
-0+static int stmmac_xgmac2_mdio_read (struct stmmac_priv *priv,int phyaddr, +int phyreg) +{ +unsigned int mii_address = priv->hw->mii.addr; +unsigned int mii_data = priv->hw->mii.data; +u32 tmp, addr, value =MII_XGMAC_BUSY ; +int data; + +if (phyreg &MII_ADDR_C45 ) { + addr = ((phyreg >>16 ) &0x1f ) <<21 ; + addr |= (phyaddr <<16 ) | (phyreg &0xffff );
Do you need to tell the hardware this is a C45 transfer? Normally an extra bit needs setting somewhere.
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c line 61
Quoted 3 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +3
-0+ }else { +if (phyaddr >=4 ) +return -ENODEV ;
Can the MDIO bus be external? If so, is there a reason why there cannot be a PHY at addresses > 4. So maybe there is an Ethernet switch, which needs lots of addresses? And C45 can have devices > 4 but C22 cannot?
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c line 68
Quoted 7 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +7
-0+writel (~0x0 , priv->ioaddr +0x220 ); + addr = (phyaddr <<16 ) | (phyreg &0x1f ); + } + + value |= (priv->clk_csr << priv->hw->mii.clk_csr_shift) + & priv->hw->mii.clk_csr_mask; + value |=BIT (18 );
Please add a #define for this bit.
Quoted 5 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +5
-0+ value |=MII_XGMAC_READ ; + +if (readl_poll_timeout (priv->ioaddr + mii_data, tmp, + !(tmp &MII_XGMAC_BUSY ),100 ,10000 )) +return -EBUSY ;
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c line 83
Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +10
-0+ +writel (addr, priv->ioaddr + mii_address); +writel (value, priv->ioaddr + mii_data); + +if (readl_poll_timeout (priv->ioaddr + mii_data, tmp, + !(tmp &MII_XGMAC_BUSY ),100 ,10000 )) +return -EBUSY ; + +/* Read the data from the MII data register */ + data = (int )readl (priv->ioaddr + mii_data) &GENMASK (15 ,0 );
Is the cast needed? And why use GENMASK here, but not in all the other places you have masks in this code?
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c static int stmmac_mdio_read(struct mii_bus *bus, int phyaddr, int phyreg) · line 145
Quoted 9 lines
/**
*stmmac_mdio_read
* @bus: points to themii_busstructuredrivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +2
-0@@ -59,6 +141,9 @@ static int stmmac_mdio_read(struct mii_bus *bus, int phyaddr, int phyreg)int data;u32 value =MII_BUSY ; +if (priv->plat->has_xgmac) +return stmmac_xgmac2_mdio_read (priv, phyaddr, phyreg);
It would be cleaner to instead do this in stmmac_mdio_register() when setting new_bus->read.
Andrew
Re: [PATCH net-next 7/9] net: stmmac: Integrate XGMAC into main driver flow
In reply to Jose Abreudrivers/net/ethernet/stmicro/stmmac/stmmac_main.c static void stmmac_adjust_link(struct net_device *dev) · line 874
Quoted 13 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +6
-0@@ -842,6 +863,12 @@ static void stmmac_adjust_link(struct net_device *dev) new_state = true; ctrl &= ~priv->hw->link.speed_mask;switch (phydev->speed) { +case SPEED_10000 : + ctrl |= priv->hw->link.speed10000; +break ; +case SPEED_2500 : + ctrl |= priv->hw->link.speed2500; +break ;case SPEED_1000 : ctrl |= priv->hw->link.speed1000;break ;
Hi Jose
What PHY did you test this with?
10G phys change the interface mode when the speed change. In general, 10/100/1000G copper uses SGMII. A 1G SFP optical module generally wants 1000Base-X. 2.5G wants 2500Base-X, 10G copper wants 10GKR, etc.
So your adjust link callback needs to look at phydev->interface and reconfigure the MAC as requested.
You might also want to consider moving from phylib to phylink. It has a better interface for things like this, and makes support for SFP interfaces much easier. A MAC which supports 10G is likely to be used with SFPs...
Andrew
Re: [PATCH net-next 7/9] net: stmmac: Integrate XGMAC into main driver flow
Hi Andrew,
Thanks for the review!
Quoted 15 lines · Andrew Lunn
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static void stmmac_adjust_link(struct net_device *dev) · line 874
Quoted 13 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +6
-0@@ -842,6 +863,12 @@ static void stmmac_adjust_link(struct net_device *dev) new_state = true; ctrl &= ~priv->hw->link.speed_mask;switch (phydev->speed) { +case SPEED_10000 : + ctrl |= priv->hw->link.speed10000; +break ; +case SPEED_2500 : + ctrl |= priv->hw->link.speed2500; +break ;case SPEED_1000 : ctrl |= priv->hw->link.speed1000;break ;Hi Jose
Quoted 1 line
What PHY did you test this with?
We had some shipping issues with the 10G phy so right now I'm using a 1G phy ... I would expect that as MDIO is used in both phys then phylib would take care of everything as long as I specify in the DT the right interface (SGMII) ... Am I making a wrong assumption?
Quoted 7 lines
10G phys change the interface mode when the speed change. In general, 10/100/1000G copper uses SGMII. A 1G SFP optical module generally wants 1000Base-X. 2.5G wants 2500Base-X, 10G copper wants 10GKR, etc.
So your adjust link callback needs to look at
phydev->interfaceand reconfigure the MAC as requested.
Sorry, I'm not a phy expert but as long as I use MDIO shouldn't this be transparent to MAC? I mean, there are no registers about the interface to use in XGMAC2, there is only this speed selection register that its implemented already in the stmmac_adjust_link.
Quoted 5 lines
You might also want to consider moving from phylib to phylink. It has a better interface for things like this, and makes support for SFP interfaces much easier. A MAC which supports 10G is likely to be used with SFPs...
Ok, I will take a look into it.
Thanks and Best Regards,
Jose Miguel Abreu
Quoted 2 lines
Andrew
Re: [PATCH net-next 5/9] net: stmmac: Add MDIO related functions for XGMAC2
In reply to Andrew LunnHi Andrew,
Quoted 15 lines · Andrew Lunn
Hi Jose
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c line 58
Quoted 11 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +11
-0+static int stmmac_xgmac2_mdio_read (struct stmmac_priv *priv,int phyaddr, +int phyreg) +{ +unsigned int mii_address = priv->hw->mii.addr; +unsigned int mii_data = priv->hw->mii.data; +u32 tmp, addr, value =MII_XGMAC_BUSY ; +int data; + +if (phyreg &MII_ADDR_C45 ) { + addr = ((phyreg >>16 ) &0x1f ) <<21 ; + addr |= (phyaddr <<16 ) | (phyreg &0xffff );Do you need to tell the hardware this is a C45 transfer? Normally an extra bit needs setting somewhere.
The organization of addr reg is the following:
DA [25:21] | PA [20:16] | RA [15:0]
DA is Device Address, PA is Port Address and RA is Register Address.
Quoted 8 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c line 61
Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +3
-0+ }else { +if (phyaddr >=4 ) +return -ENODEV ;Can the MDIO bus be external? If so, is there a reason why there cannot be a PHY at addresses > 4. So maybe there is an Ethernet switch, which needs lots of addresses? And C45 can have devices > 4 but C22 cannot?
Only ports 0 to 3 can be configured as C22 ports, according to databook. This for MDIO bus trough controller.
Quoted 9 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c line 68
Quoted 8 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +7
-0+writel (~0x0 , priv->ioaddr +0x220 ); + addr = (phyaddr <<16 ) | (phyreg &0x1f ); + } + + value |= (priv->clk_csr << priv->hw->mii.clk_csr_shift) + & priv->hw->mii.clk_csr_mask; + value |=BIT (18 );Please add a #define for this bit.
Ok.
Quoted 10 lines
Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +9
-0+ value |=MII_XGMAC_READ ; + +if (readl_poll_timeout (priv->ioaddr + mii_data, tmp, + !(tmp &MII_XGMAC_BUSY ),100 ,10000 )) +return -EBUSY ; + +writel (addr, priv->ioaddr + mii_address); +writel (value, priv->ioaddr + mii_data); +
Quoted 8 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c line 83
Quoted 6 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +6
-0+if (readl_poll_timeout (priv->ioaddr + mii_data, tmp, + !(tmp &MII_XGMAC_BUSY ),100 ,10000 )) +return -EBUSY ; + +/* Read the data from the MII data register */ + data = (int )readl (priv->ioaddr + mii_data) &GENMASK (15 ,0 );Is the cast needed? And why use GENMASK here, but not in all the other places you have masks in this code?
The GENMASK is needed, notice how we set more values into mii_data (clk_csr, bit(18), cmd), this is not cleared by XGMAC2 upon the completion of the operation ...
Quoted 8 lines
Quoted 8 lines
/**
*stmmac_mdio_read
* @bus: points to themii_busstructuredrivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +0
-0@@ -59,6 +141,9 @@ static int stmmac_mdio_read(struct mii_bus *bus, int phyaddr, int phyreg)int data;u32 value =MII_BUSY ;
Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c static int stmmac_mdio_read(struct mii_bus *bus, int phyaddr, int phyreg) · line 145
Quoted 2 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +2
-0+if (priv->plat->has_xgmac) +return stmmac_xgmac2_mdio_read (priv, phyaddr, phyreg);It would be cleaner to instead do this in
stmmac_mdio_register()when settingnew_bus->read.
Makes sense! Thanks!
Thanks and Best Regards,
Jose Miguel Abreu
Quoted 2 lines
Andrew
Re: [PATCH net-next 7/9] net: stmmac: Integrate XGMAC into main driver flow
In reply to Jose AbreuQuoted 20 lines · Jose Abreu
Hi Andrew,
Thanks for the review!
Quoted 15 lines · Andrew Lunn
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static void stmmac_adjust_link(struct net_device *dev) · line 874
Quoted 13 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +6
-0@@ -842,6 +863,12 @@ static void stmmac_adjust_link(struct net_device *dev) new_state = true; ctrl &= ~priv->hw->link.speed_mask;switch (phydev->speed) { +case SPEED_10000 : + ctrl |= priv->hw->link.speed10000; +break ; +case SPEED_2500 : + ctrl |= priv->hw->link.speed2500; +break ;case SPEED_1000 : ctrl |= priv->hw->link.speed1000;break ;Hi Jose
Quoted 4 lines
Quoted 1 line
What PHY did you test this with?
We had some shipping issues with the 10G phy so right now I'm using a 1G phy ...
Please add that to the commit message. It is useful for people to know this is untested above 1G, and so probably broken....
Quoted 10 lines
I would expect that as MDIO is used in both
phys then phylib would take care of everything as long as I specify in the DT the right interface (SGMII) ... Am I making a wrong assumption?Quoted 5 lines
10G phys change the interface mode when the speed change. In general, 10/100/1000G copper uses SGMII. A 1G SFP optical module generally wants 1000Base-X. 2.5G wants 2500Base-X, 10G copper wants 10GKR, etc.
Quoted 8 lines
Quoted 2 lines
So your adjust link callback needs to look at
phydev->interfaceand reconfigure the MAC as requested.Sorry, I'm not a phy expert but as long as I use MDIO shouldn't this be transparent to MAC? I mean, there are no registers about the interface to use in XGMAC2, there is only this speed selection register that its implemented already in the
stmmac_adjust_link.
MDIO is the control plane used to manage the PHY. But here we are talking about the data plane. As i said, the link between the MAC and PHY will need to change depending on what the PHY is doing. SGMII will work for 10/100/1000, but nothing above that. It could be this speed register also changes the SERDES configuration, but you really should confirm this and find out exactly what it is doing. There can be multiple ways of doing one speed, e.g. SGMII at 1G. So if the PHY wants you to do 1000Base-X and the MAC can only do SGMII, you need to be raising an error. phylink makes this simpler. It ask the MAC driver for all the modes it supports. It will then not ask the MAC to swap to something it does not support.
I suggest you get the datasheet for the PHY you are expecting to get, once shipping is fixed. See what it says about its MAC side interface. You can also look at the Marvell 10G driver, e.g. mv3310_update_interface().
Andrew
Re: [PATCH net-next 5/9] net: stmmac: Add MDIO related functions for XGMAC2
In reply to Jose AbreuQuoted 19 lines · Jose Abreu
Hi Andrew,
Quoted 15 lines · Andrew Lunn
Hi Jose
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c line 58
Quoted 11 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +11
-0+static int stmmac_xgmac2_mdio_read (struct stmmac_priv *priv,int phyaddr, +int phyreg) +{ +unsigned int mii_address = priv->hw->mii.addr; +unsigned int mii_data = priv->hw->mii.data; +u32 tmp, addr, value =MII_XGMAC_BUSY ; +int data; + +if (phyreg &MII_ADDR_C45 ) { + addr = ((phyreg >>16 ) &0x1f ) <<21 ; + addr |= (phyaddr <<16 ) | (phyreg &0xffff );Do you need to tell the hardware this is a C45 transfer? Normally an extra bit needs setting somewhere.
Quoted 4 lines
The organization of addr reg is the following:
DA [25:21] | PA [20:16] | RA [15:0]DA is Device Address, PA is Port Address and RA is Register Address.
Hi Jose
Please read my question. That is not what i asked.
Quoted 11 lines
Quoted 8 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c line 61
Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +3
-0+ }else { +if (phyaddr >=4 ) +return -ENODEV ;Can the MDIO bus be external? If so, is there a reason why there cannot be a PHY at addresses > 4. So maybe there is an Ethernet switch, which needs lots of addresses? And C45 can have devices > 4 but C22 cannot?
Only ports 0 to 3 can be configured as C22 ports, according to databook.
Please add a comment about this. And EOPNOTSUP might be a better error code.
Quoted 18 lines
Quoted 9 lines
Quoted 9 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +9
-0+ value |=MII_XGMAC_READ ; + +if (readl_poll_timeout (priv->ioaddr + mii_data, tmp, + !(tmp &MII_XGMAC_BUSY ),100 ,10000 )) +return -EBUSY ; + +writel (addr, priv->ioaddr + mii_address); +writel (value, priv->ioaddr + mii_data); +Quoted 8 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c line 83
Quoted 6 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +6
-0+if (readl_poll_timeout (priv->ioaddr + mii_data, tmp, + !(tmp &MII_XGMAC_BUSY ),100 ,10000 )) +return -EBUSY ; + +/* Read the data from the MII data register */ + data = (int )readl (priv->ioaddr + mii_data) &GENMASK (15 ,0 );Is the cast needed? And why use GENMASK here, but not in all the other places you have masks in this code?
Quoted 3 lines
The GENMASK is needed, notice how we set more values into
mii_data(clk_csr, bit(18), cmd), this is not cleared by XGMAC2 upon the completion of the operation ...
Again, please read my question. That is not what i asked.
Has C45 been tested? Does the 1G PHY you have support C45 transfers?
Andrew
Re: [PATCH net-next 7/9] net: stmmac: Integrate XGMAC into main driver flow
In reply to Andrew LunnHi Andrew,
Quoted 21 lines · Andrew Lunn
Quoted 20 lines · Jose Abreu
Hi Andrew,
Thanks for the review!
Quoted 15 lines · Andrew Lunn
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static void stmmac_adjust_link(struct net_device *dev) · line 874
Quoted 13 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +6
-0@@ -842,6 +863,12 @@ static void stmmac_adjust_link(struct net_device *dev) new_state = true; ctrl &= ~priv->hw->link.speed_mask;switch (phydev->speed) { +case SPEED_10000 : + ctrl |= priv->hw->link.speed10000; +break ; +case SPEED_2500 : + ctrl |= priv->hw->link.speed2500; +break ;case SPEED_1000 : ctrl |= priv->hw->link.speed1000;break ;Hi Jose
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
What PHY did you test this with?
We had some shipping issues with the 10G phy so right now I'm using a 1G phy ...
Please add that to the commit message. It is useful for people to know this is untested above 1G, and so probably broken....
Ok, will do.
Quoted 17 lines
Quoted 10 lines
I would expect that as MDIO is used in both
phys then phylib would take care of everything as long as I specify in the DT the right interface (SGMII) ... Am I making a wrong assumption?Quoted 4 lines
10G phys change the interface mode when the speed change. In general, 10/100/1000G copper uses SGMII. A 1G SFP optical module generally wants 1000Base-X. 2.5G wants 2500Base-X, 10G copper wants 10GKR, etc.
Quoted 7 lines
Quoted 2 lines
So your adjust link callback needs to look at
phydev->interfaceand reconfigure the MAC as requested.Sorry, I'm not a phy expert but as long as I use MDIO shouldn't this be transparent to MAC? I mean, there are no registers about the interface to use in XGMAC2, there is only this speed selection register that its implemented already in the
stmmac_adjust_link.
Quoted 4 lines
MDIO is the control plane used to manage the PHY. But here we are talking about the data plane. As i said, the link between the MAC and PHY will need to change depending on what the PHY is doing. SGMII will work for 10/100/1000, but nothing above that.
Sorry, I made a mistake. Where it reads SGMII in my reply I was referring to XGMII.
Quoted 8 lines
It could be this speed
register also changes the SERDES configuration, but you really should confirm this and find out exactly what it is doing. There can be multiple ways of doing one speed, e.g. SGMII at 1G. So if the PHY wants you to do 1000Base-X and the MAC can only do SGMII, you need to be raising an error. phylink makes this simpler. It ask the MAC driver for all the modes it supports. It will then not ask the MAC to swap to something it does not support.
Ok. XGMII support is optional in the MAC so I will need to add a check for that.
Thanks and Best Regards,
Jose Miguel Abreu
Quoted 7 lines
I suggest you get the datasheet for the PHY you are expecting to get, once shipping is fixed. See what it says about its MAC side interface. You can also look at the Marvell 10G driver, e.g.
mv3310_update_interface().Andrew
Re: [PATCH net-next 7/9] net: stmmac: Integrate XGMAC into main driver flow
Quoted 2 lines
Sorry, I made a mistake. Where it reads SGMII in my reply I was referring to XGMII.
So you have XGMII between the MAC and the PHY. That should support 2.5G, 5G and 10G. What i don't know is if you can also do 10/100/1000 over XGMII?
How are you currently connecting your 1G PHY to the MAC? XGMII is a big parallel bus, where as SGMII is a small serial bus.
I would say, before this patchset goes anywhere, you need to test 10/100/1000/2.5G/10G, with at least one PHY.
Alternatively, take out support for 2.5G/10G and C45, and post patches for just > 1G and C22. That you can test and you know works. You can add the rest later.
Andrew
Re: [PATCH net-next 7/9] net: stmmac: Integrate XGMAC into main driver flow
Quoted 5 lines · Andrew Lunn
Quoted 2 lines
Sorry, I made a mistake. Where it reads SGMII in my reply I was referring to XGMII.
So you have XGMII between the MAC and the PHY. That should support 2.5G, 5G and 10G. What i don't know is if you can also do 10/100/1000 over XGMII?
Acording to databook I can only do 1G/2.5G and 10G.
Quoted 3 lines
How are you currently connecting your 1G PHY to the MAC? XGMII is a big parallel bus, where as SGMII is a small serial bus.
I will check with HW team because I've no idea how is this connected ...
Quoted 7 lines
I would say, before this patchset goes anywhere, you need to test 10/100/1000/2.5G/10G, with at least one PHY.
Alternatively, take out support for 2.5G/10G and C45, and post patches for just > 1G and C22. That you can test and you know works. You can add the rest later.
Looks like a plan. So, I will remove the adjust_link speed selection for > 1g and the C45 support. I will leave the SS selection in dwxgmac2_core_init (patch 2/9) as this makes no difference because only 1g will be selected for now. I will also clearly refer in cover letter the BW results for 1g tests.
Later on I will add support for 10g once shipping arrives.
Looks okay?
Thanks and Best Regards,
Jose Miguel Abreu
Quoted 2 lines
Andrew
Re: [PATCH net-next 7/9] net: stmmac: Integrate XGMAC into main driver flow
Quoted 9 lines
Looks like a plan. So, I will remove the
adjust_linkspeed selection for > 1g and the C45 support. I will leave the SS selection indwxgmac2_core_init(patch 2/9) as this makes no difference because only 1g will be selected for now. I will also clearly refer in cover letter the BW results for 1g tests.Later on I will add support for 10g once shipping arrives.
Looks okay?
Hi Jose
Yes, this is good.
Thanks
Andrew