Skip to contentSkip to conversation

net: stmmac: Add PCI driver support for BCM8958x

PATCH Superseded [email protected] 5 participants 21 messages Aug 14, 2024 – Aug 30, 2024

Subsystems (5)

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v4 cover net: stmmac: Add PCI driver support for BCM8958x

From: Jitendra Vegiraju <[email protected]>

This patchset adds basic PCI ethernet device driver support for Broadcom BCM8958x Automotive Ethernet switch SoC devices.

This SoC device has PCIe ethernet MAC attached to an integrated ethernet switch using XGMII interface. The PCIe ethernet controller is presented to the Linux host as PCI network device.

The following block diagram gives an overview of the application.

             +=================================+
             |       Host CPU/Linux            |
             +=================================+
                        || PCIe
                        ||
        +==========================================+
        |           +--------------+               |
        |           | PCIE Endpoint|               |
        |           | Ethernet     |               |
        |           | Controller   |               |
        |           |   DMA        |               |
        |           +--------------+               |
        |           |   MAC        |   BCM8958X    |
        |           +--------------+   SoC         |
        |               || XGMII                   |
        |               ||                         |
        |           +--------------+               |
        |           | Ethernet     |               |
        |           | switch       |               |
        |           +--------------+               |
        |             || || || ||                  |
        +==========================================+
                      || || || || More external interfaces

The MAC block on BCM8958x is based on Synopsis XGMAC 4.00a core. This MAC IP introduces new DMA architecture called Hyper-DMA for virtualization scalability.

Driver functionality specific to new MAC (DW25GMAC) is implemented in new file dw25gmac.c.

Management of integrated ethernet switch on this SoC is not handled by the PCIe interface.
This SoC device has PCIe ethernet MAC directly attached to an integrated ethernet switch using XGMII interface.

v3->v4:
Based on Serge's questions, received a confirmation from Synopsis that the MAC IP is indeed the new 25GMAC design.
Renamed all references of XGMAC4 to 25GMAC.
The patch series is rearranged slightly as follows.
Patch1 (new): Define HDMA mapping data structure in kernel's stmmac.h Patch2 (v3 Patch1): Adds dma_ops for dw25gmac in stmmac core
Renamed new files dwxgmac4.* to dw25gmac.* - Serge Semin Defined new Synopsis version and device id macros for DW25GMAC. Coverted bit operations to FIELD_PREP macros - Russell King Moved hwif.h to this patch, Sparse flagged warning - Simon Horman Defined macros for hardcoded values TDPS etc - Serge Semin Read number of PDMAs/VDMAs from hardware - Serge Semin
Patch3 (v3 Patch2): Hooks in hardware interface handling for dw25gmac
Resolved user_version quirks questions - Serge, Russell, Andrew Added new stmmac_hw entry for DW25GMAC. - Serge
Added logic to override synopsis_dev_id by glue driver.
Patch4 (v3 Patch3): Adds PCI driver for BCM8958x device
Define bitmmap macros for hardcoded values - Andrew Lunn Added per device software node - Andrew Lunn
Patch5(new/split): Adds BCM8958x driver to build system

v2->v3:
Addressed v2 comments from Andrew, Jakub, Russel and Simon. Based on suggestion by Russel and Andrew, added software node to create phylink in fixed-link mode.
Moved dwxgmac4 specific functions to new files dwxgmac4.c and dwxgmac4.h in stmmac core module.
Reorganized the code to use the existing glue logic support for xgmac in hwif.c and override ops functions for dwxgmac4 specific functions. The patch is split into three parts.
Patch#1 Adds dma_ops for dwxgmac4 in stmmac core
Patch#2 Hooks in the hardware interface handling for dwxgmac4 Patch#3 Adds PCI driver for BCM8958x device
https://lore.kernel.org/netdev/[email protected]/

v1->v2:
Minor fixes to address coding style issues.
Sent v2 too soon by mistake, without waiting for review comments. Received feedback on this version.
https://lore.kernel.org/netdev/[email protected]/

v1:
https://lore.kernel.org/netdev/[email protected]/

Jitendra Vegiraju (5):
Add HDMA mapping for dw25gmac support
Add basic dw25gmac support to stmmac core
Integrate dw25gmac into stmmac hwif handling
Add PCI driver support for BCM8958x
Add BCM8958x driver to build system

 MAINTAINERS                                   |   8 +
 drivers/net/ethernet/stmicro/stmmac/Kconfig   |  11 +
 drivers/net/ethernet/stmicro/stmmac/Makefile  |   3 +-
 drivers/net/ethernet/stmicro/stmmac/common.h  |   2 +
 .../net/ethernet/stmicro/stmmac/dw25gmac.c    | 173 ++++++
 .../net/ethernet/stmicro/stmmac/dw25gmac.h    |  90 +++
 .../net/ethernet/stmicro/stmmac/dwmac-brcm.c  | 530 ++++++++++++++++++
 .../ethernet/stmicro/stmmac/dwxgmac2_dma.c    |  31 +
 drivers/net/ethernet/stmicro/stmmac/hwif.c    |  25 +-
 drivers/net/ethernet/stmicro/stmmac/hwif.h    |   1 +
 drivers/net/ethernet/stmicro/stmmac/stmmac.h  |   1 +
 include/linux/stmmac.h                        |  50 ++
 12 files changed, 922 insertions(+), 3 deletions(-)
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/dw25gmac.c
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/dw25gmac.h
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-brcm.c
Signature · 1 line
2.34.1
#1 lore raw

PATCH v4 1/5 net: stmmac: Add HDMA mapping for dw25gmac support

From: Jitendra Vegiraju <[email protected]>

Add hdma configuration support in include/linux/stmmac.h file. The hdma configuration includes mapping of virtual DMAs to physical DMAs. Define a new data structure stmmac_hdma_cfg to provide the mapping.

---
 include/linux/stmmac.h | 50 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)
include/linux/stmmac.h +50 -0
index 338991c08f00..1775bd2b7c14 100644
@@ -89,6 +89,55 @@ struct stmmac_mdio_bus_data {
 	bool needs_reset;
 };
 
+/* DW25GMAC Hyper-DMA Overview
+ * Hyper-DMA allows support for large number of Virtual DMA(VDMA)
+ * channels using a smaller set of physical DMA channels(PDMA).
+ * This is supported by the  mapping of VDMAs to Traffic Class (TC)
+ * and PDMA to TC in each traffic direction as shown below.
+ *
+ *        VDMAs            Traffic Class      PDMA
+ *       +--------+          +------+         +-----------+
+ *       |VDMA0   |--------->| TC0  |-------->|PDMA0/TXQ0 |
+ *TX     +--------+   |----->+------+         +-----------+
+ *Host=> +--------+   |      +------+         +-----------+ => MAC
+ *SW     |VDMA1   |---+      | TC1  |    +--->|PDMA1/TXQ1 |
+ *       +--------+          +------+    |    +-----------+
+ *       +--------+          +------+----+    +-----------+
+ *       |VDMA2   |--------->| TC2  |-------->|PDMA2/TXQ1 |
+ *       +--------+          +------+         +-----------+
+ *            .                 .                 .
+ *       +--------+          +------+         +-----------+
+ *       |VDMAn-1 |--------->| TCx-1|-------->|PDMAm/TXQm |
+ *       +--------+          +------+         +-----------+
+ *
+ *       +------+          +------+         +------+
+ *       |PDMA0 |--------->| TC0  |-------->|VDMA0 |
+ *       +------+   |----->+------+         +------+
+ *MAC => +------+   |      +------+         +------+
+ *RXQs   |PDMA1 |---+      | TC1  |    +--->|VDMA1 |  => Host
+ *       +------+          +------+    |    +------+
+ *            .                 .                 .
+ */
+
+#define STMMAC_DW25GMAC_MAX_NUM_TX_VDMA		128
+#define STMMAC_DW25GMAC_MAX_NUM_RX_VDMA		128
+
+#define STMMAC_DW25GMAC_MAX_NUM_TX_PDMA		8
+#define STMMAC_DW25GMAC_MAX_NUM_RX_PDMA		10
+
+#define STMMAC_DW25GMAC_MAX_TC			8
+
+/* Hyper-DMA mapping configuration
+ * Traffic Class associated with each VDMA/PDMA mapping
+ * is stored in corresponding array entry.
+ */
+struct stmmac_hdma_cfg {
+	u8 tvdma_tc[STMMAC_DW25GMAC_MAX_NUM_TX_VDMA];
+	u8 rvdma_tc[STMMAC_DW25GMAC_MAX_NUM_RX_VDMA];
+	u8 tpdma_tc[STMMAC_DW25GMAC_MAX_NUM_TX_PDMA];
+	u8 rpdma_tc[STMMAC_DW25GMAC_MAX_NUM_RX_PDMA];
+};
+
 struct stmmac_dma_cfg {
 	int pbl;
 	int txpbl;
@@ -101,6 +150,7 @@ struct stmmac_dma_cfg {
 	bool multi_msi_en;
 	bool dche;
 	bool atds;
+	struct stmmac_hdma_cfg *hdma_cfg;
 };
 
 #define AXI_BLEN	7
Signature · 1 line
2.34.1
#2 lore raw

Re: [net-next v4 1/5] net: stmmac: Add HDMA mapping for dw25gmac support

Quoted 45 lines · On 8/14/2024 3:18 PM, [email protected] wrote:

From: Jitendra Vegiraju <[email protected]>

Add hdma configuration support in include/linux/stmmac.h file. The hdma configuration includes mapping of virtual DMAs to physical DMAs. Define a new data structure stmmac_hdma_cfg to provide the mapping.

---
 include/linux/stmmac.h | 50 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)
include/linux/stmmac.h +26 -0
index 338991c08f00..1775bd2b7c14 100644
@@ -89,6 +89,55 @@ struct stmmac_mdio_bus_data {
 	bool needs_reset;
 };
 
+/* DW25GMAC Hyper-DMA Overview
+ * Hyper-DMA allows support for large number of Virtual DMA(VDMA)
+ * channels using a smaller set of physical DMA channels(PDMA).
+ * This is supported by the  mapping of VDMAs to Traffic Class (TC)
+ * and PDMA to TC in each traffic direction as shown below.
+ *
+ *        VDMAs            Traffic Class      PDMA
+ *       +--------+          +------+         +-----------+
+ *       |VDMA0   |--------->| TC0  |-------->|PDMA0/TXQ0 |
+ *TX     +--------+   |----->+------+         +-----------+
+ *Host=> +--------+   |      +------+         +-----------+ => MAC
+ *SW     |VDMA1   |---+      | TC1  |    +--->|PDMA1/TXQ1 |
+ *       +--------+          +------+    |    +-----------+
+ *       +--------+          +------+----+    +-----------+
+ *       |VDMA2   |--------->| TC2  |-------->|PDMA2/TXQ1 |
+ *       +--------+          +------+         +-----------+
+ *            .                 .                 .
+ *       +--------+          +------+         +-----------+
+ *       |VDMAn-1 |--------->| TCx-1|-------->|PDMAm/TXQm |
+ *       +--------+          +------+         +-----------+
+ *
+ *       +------+          +------+         +------+
+ *       |PDMA0 |--------->| TC0  |-------->|VDMA0 |
+ *       +------+   |----->+------+         +------+
+ *MAC => +------+   |      +------+         +------+
+ *RXQs   |PDMA1 |---+      | TC1  |    +--->|VDMA1 |  => Host

include/linux/stmmac.h struct stmmac_mdio_bus_data { · line 127

Quoted 10 lines
include/linux/stmmac.h +10 -0
+ *       +------+          +------+    |    +------+
+ *            .                 .                 .
+ */
+
+#define STMMAC_DW25GMAC_MAX_NUM_TX_VDMA		128
+#define STMMAC_DW25GMAC_MAX_NUM_RX_VDMA		128
+
+#define STMMAC_DW25GMAC_MAX_NUM_TX_PDMA		8
+#define STMMAC_DW25GMAC_MAX_NUM_RX_PDMA		10
+

I have a query here.

Why do we need to hardcode the number of TX PDMA and RX PDMA to 8 an 10. On some platforms the number of supported TXPDMA and RXPDMA are 11 and 11 respectively ?

how do we overcome this problem, do we increase the value in such case?

Quoted 24 lines
include/linux/stmmac.h +14 -0
+#define STMMAC_DW25GMAC_MAX_TC			8
+
+/* Hyper-DMA mapping configuration
+ * Traffic Class associated with each VDMA/PDMA mapping
+ * is stored in corresponding array entry.
+ */
+struct stmmac_hdma_cfg {
+	u8 tvdma_tc[STMMAC_DW25GMAC_MAX_NUM_TX_VDMA];
+	u8 rvdma_tc[STMMAC_DW25GMAC_MAX_NUM_RX_VDMA];
+	u8 tpdma_tc[STMMAC_DW25GMAC_MAX_NUM_TX_PDMA];
+	u8 rpdma_tc[STMMAC_DW25GMAC_MAX_NUM_RX_PDMA];
+};
+
 struct stmmac_dma_cfg {
 	int pbl;
 	int txpbl;
@@ -101,6 +150,7 @@ struct stmmac_dma_cfg {
 	bool multi_msi_en;
 	bool dche;
 	bool atds;
+	struct stmmac_hdma_cfg *hdma_cfg;
 };
 
 #define AXI_BLEN	7
#3 lore raw

Re: [net-next v4 1/5] net: stmmac: Add HDMA mapping for dw25gmac support

Quoted 61 lines · Abhishek Chauhan (ABC)
Quoted 45 lines · On 8/14/2024 3:18 PM, [email protected] wrote:

From: Jitendra Vegiraju <[email protected]>

Add hdma configuration support in include/linux/stmmac.h file. The hdma configuration includes mapping of virtual DMAs to physical DMAs. Define a new data structure stmmac_hdma_cfg to provide the mapping.

---
 include/linux/stmmac.h | 50 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)
include/linux/stmmac.h +26 -0
index 338991c08f00..1775bd2b7c14 100644
@@ -89,6 +89,55 @@ struct stmmac_mdio_bus_data {
      bool needs_reset;
 };
 
+/* DW25GMAC Hyper-DMA Overview
+ * Hyper-DMA allows support for large number of Virtual DMA(VDMA)
+ * channels using a smaller set of physical DMA channels(PDMA).
+ * This is supported by the  mapping of VDMAs to Traffic Class (TC)
+ * and PDMA to TC in each traffic direction as shown below.
+ *
+ *        VDMAs            Traffic Class      PDMA
+ *       +--------+          +------+         +-----------+
+ *       |VDMA0   |--------->| TC0  |-------->|PDMA0/TXQ0 |
+ *TX     +--------+   |----->+------+         +-----------+
+ *Host=> +--------+   |      +------+         +-----------+ => MAC
+ *SW     |VDMA1   |---+      | TC1  |    +--->|PDMA1/TXQ1 |
+ *       +--------+          +------+    |    +-----------+
+ *       +--------+          +------+----+    +-----------+
+ *       |VDMA2   |--------->| TC2  |-------->|PDMA2/TXQ1 |
+ *       +--------+          +------+         +-----------+
+ *            .                 .                 .
+ *       +--------+          +------+         +-----------+
+ *       |VDMAn-1 |--------->| TCx-1|-------->|PDMAm/TXQm |
+ *       +--------+          +------+         +-----------+
+ *
+ *       +------+          +------+         +------+
+ *       |PDMA0 |--------->| TC0  |-------->|VDMA0 |
+ *       +------+   |----->+------+         +------+
+ *MAC => +------+   |      +------+         +------+
+ *RXQs   |PDMA1 |---+      | TC1  |    +--->|VDMA1 |  => Host

include/linux/stmmac.h struct stmmac_mdio_bus_data { · line 127

Quoted 10 lines
include/linux/stmmac.h +10 -0
+ *       +------+          +------+    |    +------+
+ *            .                 .                 .
+ */
+
+#define STMMAC_DW25GMAC_MAX_NUM_TX_VDMA              128
+#define STMMAC_DW25GMAC_MAX_NUM_RX_VDMA              128
+
+#define STMMAC_DW25GMAC_MAX_NUM_TX_PDMA              8
+#define STMMAC_DW25GMAC_MAX_NUM_RX_PDMA              10
+

I have a query here.

Quoted 4 lines

Why do we need to hardcode the number of TX PDMA and RX PDMA to 8 an 10. On some platforms the number of supported TXPDMA and RXPDMA are 11 and 11 respectively ?

how do we overcome this problem, do we increase the value in such case?

Hi Abhishek,
Agreed, we can make the mapping tables more generic.
We will replace static arrays with dynamically allocated memory by reading the TXPDMA and RXPDMA counts from hardware. Thanks

Quoted 24 lines
Quoted 24 lines
include/linux/stmmac.h +14 -0
+#define STMMAC_DW25GMAC_MAX_TC                       8
+
+/* Hyper-DMA mapping configuration
+ * Traffic Class associated with each VDMA/PDMA mapping
+ * is stored in corresponding array entry.
+ */
+struct stmmac_hdma_cfg {
+     u8 tvdma_tc[STMMAC_DW25GMAC_MAX_NUM_TX_VDMA];
+     u8 rvdma_tc[STMMAC_DW25GMAC_MAX_NUM_RX_VDMA];
+     u8 tpdma_tc[STMMAC_DW25GMAC_MAX_NUM_TX_PDMA];
+     u8 rpdma_tc[STMMAC_DW25GMAC_MAX_NUM_RX_PDMA];
+};
+
 struct stmmac_dma_cfg {
      int pbl;
      int txpbl;
@@ -101,6 +150,7 @@ struct stmmac_dma_cfg {
      bool multi_msi_en;
      bool dche;
      bool atds;
+     struct stmmac_hdma_cfg *hdma_cfg;
 };
 
 #define AXI_BLEN     7
#4 lore raw

Re: [net-next v4 1/5] net: stmmac: Add HDMA mapping for dw25gmac support

Quoted 65 lines · Jitendra Vegiraju
Quoted 63 lines · Abhishek Chauhan (ABC)
Quoted 45 lines · On 8/14/2024 3:18 PM, [email protected] wrote:

From: Jitendra Vegiraju <[email protected]>

Add hdma configuration support in include/linux/stmmac.h file. The hdma configuration includes mapping of virtual DMAs to physical DMAs. Define a new data structure stmmac_hdma_cfg to provide the mapping.

---
 include/linux/stmmac.h | 50 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)
include/linux/stmmac.h +26 -0
index 338991c08f00..1775bd2b7c14 100644
@@ -89,6 +89,55 @@ struct stmmac_mdio_bus_data {
      bool needs_reset;
 };
 
+/* DW25GMAC Hyper-DMA Overview
+ * Hyper-DMA allows support for large number of Virtual DMA(VDMA)
+ * channels using a smaller set of physical DMA channels(PDMA).
+ * This is supported by the  mapping of VDMAs to Traffic Class (TC)
+ * and PDMA to TC in each traffic direction as shown below.
+ *
+ *        VDMAs            Traffic Class      PDMA
+ *       +--------+          +------+         +-----------+
+ *       |VDMA0   |--------->| TC0  |-------->|PDMA0/TXQ0 |
+ *TX     +--------+   |----->+------+         +-----------+
+ *Host=> +--------+   |      +------+         +-----------+ => MAC
+ *SW     |VDMA1   |---+      | TC1  |    +--->|PDMA1/TXQ1 |
+ *       +--------+          +------+    |    +-----------+
+ *       +--------+          +------+----+    +-----------+
+ *       |VDMA2   |--------->| TC2  |-------->|PDMA2/TXQ1 |
+ *       +--------+          +------+         +-----------+
+ *            .                 .                 .
+ *       +--------+          +------+         +-----------+
+ *       |VDMAn-1 |--------->| TCx-1|-------->|PDMAm/TXQm |
+ *       +--------+          +------+         +-----------+
+ *
+ *       +------+          +------+         +------+
+ *       |PDMA0 |--------->| TC0  |-------->|VDMA0 |
+ *       +------+   |----->+------+         +------+
+ *MAC => +------+   |      +------+         +------+
+ *RXQs   |PDMA1 |---+      | TC1  |    +--->|VDMA1 |  => Host

include/linux/stmmac.h struct stmmac_mdio_bus_data { · line 127

Quoted 10 lines
include/linux/stmmac.h +10 -0
+ *       +------+          +------+    |    +------+
+ *            .                 .                 .
+ */
+
+#define STMMAC_DW25GMAC_MAX_NUM_TX_VDMA              128
+#define STMMAC_DW25GMAC_MAX_NUM_RX_VDMA              128
+
+#define STMMAC_DW25GMAC_MAX_NUM_TX_PDMA              8
+#define STMMAC_DW25GMAC_MAX_NUM_RX_PDMA              10
+

I have a query here.

Why do we need to hardcode the number of TX PDMA and RX PDMA to 8 an 10. On some platforms the number of supported TXPDMA and RXPDMA are 11 and 11 respectively ?

Quoted 7 lines
Quoted 2 lines

how do we overcome this problem, do we increase the value in such case?

Hi Abhishek,
Agreed, we can make the mapping tables more generic.
We will replace static arrays with dynamically allocated memory by reading the TXPDMA and RXPDMA counts from hardware. Thanks

That's a great idea. Thanks Jitendra. This way we do not have to hard code anything.

Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
include/linux/stmmac.h +14 -0
+#define STMMAC_DW25GMAC_MAX_TC                       8
+
+/* Hyper-DMA mapping configuration
+ * Traffic Class associated with each VDMA/PDMA mapping
+ * is stored in corresponding array entry.
+ */
+struct stmmac_hdma_cfg {
+     u8 tvdma_tc[STMMAC_DW25GMAC_MAX_NUM_TX_VDMA];
+     u8 rvdma_tc[STMMAC_DW25GMAC_MAX_NUM_RX_VDMA];
+     u8 tpdma_tc[STMMAC_DW25GMAC_MAX_NUM_TX_PDMA];
+     u8 rpdma_tc[STMMAC_DW25GMAC_MAX_NUM_RX_PDMA];
+};
+
 struct stmmac_dma_cfg {
      int pbl;
      int txpbl;
@@ -101,6 +150,7 @@ struct stmmac_dma_cfg {
      bool multi_msi_en;
      bool dche;
      bool atds;
+     struct stmmac_hdma_cfg *hdma_cfg;
 };
 
 #define AXI_BLEN     7
#5 lore raw

PATCH v4 2/5 net: stmmac: Add basic dw25gmac support to stmmac core

In reply to [email protected]

From: Jitendra Vegiraju <[email protected]>

The BCM8958x uses early adaptor version of DWC_xgmac version 4.00a for ethernet MAC. The DW25GMAC introduced in this version adds new DMA architecture called Hyper-DMA (HDMA) for virtualization scalability. This is realized by decoupling physical DMA channels(PDMA) from potentially large number of virtual DMA channels (VDMA). The VDMAs are software abastractions that map to PDMAs for frame transmission and reception.

To support the new HDMA architecture, a new instance of stmmac_dma_ops dw25gmac400_dma_ops is added.
Most of the other dma operation functions in existing dwxgamc2_dma.c file are reused where applicable.

---
 drivers/net/ethernet/stmicro/stmmac/Makefile  |   2 +-
 .../net/ethernet/stmicro/stmmac/dw25gmac.c    | 173 ++++++++++++++++++
 .../net/ethernet/stmicro/stmmac/dw25gmac.h    |  90 +++++++++
 .../ethernet/stmicro/stmmac/dwxgmac2_dma.c    |  31 ++++
 drivers/net/ethernet/stmicro/stmmac/hwif.h    |   1 +
 5 files changed, 296 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/dw25gmac.c
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/dw25gmac.h
drivers/net/ethernet/stmicro/stmmac/Makefile +1 -1
index c2f0e91f6bf8..967e8a9aa432 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_xdp.o stmmac_est.o \
+	      stmmac_xdp.o stmmac_est.o dw25gmac.o \
 	      $(stmmac-y)
 
 stmmac-$(CONFIG_STMMAC_SELFTESTS) += stmmac_selftests.o
drivers/net/ethernet/stmicro/stmmac/dw25gmac.c new file +173 -0

173 lines not on this page · raw message

drivers/net/ethernet/stmicro/stmmac/dw25gmac.h new file +90 -0

90 lines not on this page · raw message

drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c +31 -0
index 7840bc403788..02abfdd40270 100644
@@ -7,6 +7,7 @@
 #include <linux/iopoll.h>
 #include "stmmac.h"
 #include "dwxgmac2.h"
+#include "dw25gmac.h"
 
 static int dwxgmac2_dma_reset(void __iomem *ioaddr)
 {
@@ -641,3 +642,33 @@ const struct stmmac_dma_ops dwxgmac210_dma_ops = {
 	.enable_sph = dwxgmac2_enable_sph,
 	.enable_tbs = dwxgmac2_enable_tbs,
 };
+
+const struct stmmac_dma_ops dw25gmac400_dma_ops = {
+	.reset = dwxgmac2_dma_reset,
+	.init = dw25gmac_dma_init,
+	.init_chan = dwxgmac2_dma_init_chan,
+	.init_rx_chan = dw25gmac_dma_init_rx_chan,
+	.init_tx_chan = dw25gmac_dma_init_tx_chan,
+	.axi = dwxgmac2_dma_axi,
+	.dump_regs = dwxgmac2_dma_dump_regs,
+	.dma_rx_mode = dwxgmac2_dma_rx_mode,
+	.dma_tx_mode = dwxgmac2_dma_tx_mode,
+	.enable_dma_irq = dwxgmac2_enable_dma_irq,
+	.disable_dma_irq = dwxgmac2_disable_dma_irq,
+	.start_tx = dwxgmac2_dma_start_tx,
+	.stop_tx = dwxgmac2_dma_stop_tx,
+	.start_rx = dwxgmac2_dma_start_rx,
+	.stop_rx = dwxgmac2_dma_stop_rx,
+	.dma_interrupt = dwxgmac2_dma_interrupt,
+	.get_hw_feature = dwxgmac2_get_hw_feature,
+	.rx_watchdog = dwxgmac2_rx_watchdog,
+	.set_rx_ring_len = dwxgmac2_set_rx_ring_len,
+	.set_tx_ring_len = dwxgmac2_set_tx_ring_len,
+	.set_rx_tail_ptr = dwxgmac2_set_rx_tail_ptr,
+	.set_tx_tail_ptr = dwxgmac2_set_tx_tail_ptr,
+	.enable_tso = dwxgmac2_enable_tso,
+	.qmode = dwxgmac2_qmode,
+	.set_bfsize = dwxgmac2_set_bfsize,
+	.enable_sph = dwxgmac2_enable_sph,
+	.enable_tbs = dwxgmac2_enable_tbs,
+};
drivers/net/ethernet/stmicro/stmmac/hwif.h +1 -0
index 7e90f34b8c88..9764eadf72c2 100644
@@ -682,6 +682,7 @@ extern const struct stmmac_desc_ops dwxgmac210_desc_ops;
 extern const struct stmmac_mmc_ops dwmac_mmc_ops;
 extern const struct stmmac_mmc_ops dwxgmac_mmc_ops;
 extern const struct stmmac_est_ops dwmac510_est_ops;
+extern const struct stmmac_dma_ops dw25gmac400_dma_ops;
 
 #define GMAC_VERSION		0x00000020	/* GMAC CORE Version */
 #define GMAC4_VERSION		0x00000110	/* GMAC4+ CORE Version */
Signature · 1 line
2.34.1
#6 lore raw

PATCH v4 2/5 net: stmmac: Add basic dw25gmac support to stmmac core

Hi,

Quoted 6 lines

The BCM8958x uses early adaptor version of DWC_xgmac version 4.00a for ethernet MAC. The DW25GMAC introduced in this version adds new DMA architecture called Hyper-DMA (HDMA) for virtualization scalability. This is realized by decoupling physical DMA channels(PDMA) from potentially large number of virtual DMA channels (VDMA). The VDMAs are software abastractions that map to PDMAs for frame transmission and reception.

You should either run ./scripts/checkpatch.pl --strict --codespell --patch or use :set spell in vi to check for spelling mistakes

Quoted 87 lines

To support the new HDMA architecture, a new instance of stmmac_dma_ops dw25gmac400_dma_ops is added.
Most of the other dma operation functions in existing dwxgamc2_dma.c file are reused where applicable.

---
   drivers/net/ethernet/stmicro/stmmac/Makefile  |   2 +-
   .../net/ethernet/stmicro/stmmac/dw25gmac.c    | 173 ++++++++++++++++++
   .../net/ethernet/stmicro/stmmac/dw25gmac.h    |  90 +++++++++
   .../ethernet/stmicro/stmmac/dwxgmac2_dma.c    |  31 ++++
   drivers/net/ethernet/stmicro/stmmac/hwif.h    |   1 +
   5 files changed, 296 insertions(+), 1 deletion(-)

create mode 100644 drivers/net/ethernet/stmicro/stmmac/dw25gmac.c create mode 100644 drivers/net/ethernet/stmicro/stmmac/dw25gmac.h

drivers/net/ethernet/stmicro/stmmac/Makefile +1 -1
index c2f0e91f6bf8..967e8a9aa432 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_xdp.o stmmac_est.o \
+	      stmmac_xdp.o stmmac_est.o dw25gmac.o \
   	      $(stmmac-y)
 
   stmmac-$(CONFIG_STMMAC_SELFTESTS) += stmmac_selftests.o
drivers/net/ethernet/stmicro/stmmac/dw25gmac.c new file +51 -0
new file mode 100644
index 000000000000..7cb0ff4328c3
@@ -0,0 +1,173 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2024 Broadcom Corporation
+ */
+#include "dwxgmac2.h"
+#include "dw25gmac.h"
+
+static int rd_dma_ch_ind(void __iomem *ioaddr, u8 mode, u32 channel)
+{
+	u32 reg_val = 0;
+
+	reg_val |= FIELD_PREP(XXVGMAC_MODE_SELECT, mode);
+	reg_val |= FIELD_PREP(XXVGMAC_ADDR_OFFSET, channel);
+	reg_val |= XXVGMAC_CMD_TYPE | XXVGMAC_OB;
+	writel(reg_val, ioaddr + XXVGMAC_DMA_CH_IND_CONTROL);
+	return readl(ioaddr + XXVGMAC_DMA_CH_IND_DATA);
+}
+
+static void wr_dma_ch_ind(void __iomem *ioaddr, u8 mode, u32 channel, u32 val)
+{
+	u32 reg_val = 0;
+
+	writel(val, ioaddr + XXVGMAC_DMA_CH_IND_DATA);
+	reg_val |= FIELD_PREP(XXVGMAC_MODE_SELECT, mode);
+	reg_val |= FIELD_PREP(XXVGMAC_ADDR_OFFSET, channel);
+	reg_val |= XGMAC_OB;
+	writel(reg_val, ioaddr + XXVGMAC_DMA_CH_IND_CONTROL);
+}
+
+static void xgmac4_tp2tc_map(void __iomem *ioaddr, u8 pdma_ch, u32 tc_num)
+{
+	u32 val = 0;
+
+	val = rd_dma_ch_ind(ioaddr, MODE_TXEXTCFG, pdma_ch);
+	val &= ~XXVGMAC_TP2TCMP;
+	val |= FIELD_PREP(XXVGMAC_TP2TCMP, tc_num);
+	wr_dma_ch_ind(ioaddr, MODE_TXEXTCFG, pdma_ch, val);
+}
+
+static void xgmac4_rp2tc_map(void __iomem *ioaddr, u8 pdma_ch, u32 tc_num)
+{
+	u32 val = 0;
+
+	val = rd_dma_ch_ind(ioaddr, MODE_RXEXTCFG, pdma_ch);
+	val &= ~XXVGMAC_RP2TCMP;
+	val |= FIELD_PREP(XXVGMAC_RP2TCMP, tc_num);
+	wr_dma_ch_ind(ioaddr, MODE_RXEXTCFG, pdma_ch, val);
+}
+
+static u32 decode_vdma_count(u32 regval)
+{

drivers/net/ethernet/stmicro/stmmac/dw25gmac.c line 61

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dw25gmac.c new file +10 -0
+	/* compressed encoding for vdma count
+	 * regval: VDMA count
+	 * 0-15	 : 1 - 16
+	 * 16-19 : 20, 24, 28, 32
+	 * 20-23 : 40, 48, 56, 64
+	 * 24-27 : 80, 96, 112, 128
+	 */
+	if (regval < 16)
+		return regval + 1;
+	return (4 << ((regval - 16) / 4)) * ((regval % 4) + 5);

Is there a potential for regval to be out of bounds (regval > 27) that needed to be handled properly?

Quoted 136 lines
drivers/net/ethernet/stmicro/stmmac/dw25gmac.c new file +112 -0
+}
+
+void dw25gmac_dma_init(void __iomem *ioaddr,
+		       struct stmmac_dma_cfg *dma_cfg)
+{
+	u32 num_vdma_tx;
+	u32 num_vdma_rx;
+	u32 num_pdma_tx;
+	u32 num_pdma_rx;
+	u32 hw_cap;
+	u32 value;
+	u32 i;
+
+	hw_cap = readl(ioaddr + XGMAC_HW_FEATURE2);
+	num_pdma_tx = FIELD_GET(XGMAC_HWFEAT_TXQCNT, hw_cap) + 1;
+	num_pdma_rx = FIELD_GET(XGMAC_HWFEAT_RXQCNT, hw_cap) + 1;
+
+	num_vdma_tx = decode_vdma_count(FIELD_GET(XXVGMAC_HWFEAT_VDMA_TXCNT,
+						  hw_cap));
+	if (num_vdma_tx > STMMAC_DW25GMAC_MAX_NUM_TX_VDMA)
+		num_vdma_tx = STMMAC_DW25GMAC_MAX_NUM_TX_VDMA;
+	num_vdma_rx = decode_vdma_count(FIELD_GET(XXVGMAC_HWFEAT_VDMA_RXCNT,
+						  hw_cap));
+	if (num_vdma_rx > STMMAC_DW25GMAC_MAX_NUM_RX_VDMA)
+		num_vdma_rx = STMMAC_DW25GMAC_MAX_NUM_RX_VDMA;
+
+	value = readl(ioaddr + XGMAC_DMA_SYSBUS_MODE);
+	value &= ~(XGMAC_AAL | XGMAC_EAME);
+	if (dma_cfg->aal)
+		value |= XGMAC_AAL;
+	if (dma_cfg->eame)
+		value |= XGMAC_EAME;
+	writel(value, ioaddr + XGMAC_DMA_SYSBUS_MODE);
+
+	for (i = 0; i < num_vdma_tx; i++) {
+		value = rd_dma_ch_ind(ioaddr, MODE_TXDESCCTRL, i);
+		value &= ~XXVGMAC_TXDCSZ;
+		value |= FIELD_PREP(XXVGMAC_TXDCSZ,
+				    XXVGMAC_TXDCSZ_256BYTES);
+		value &= ~XXVGMAC_TDPS;
+		value |= FIELD_PREP(XXVGMAC_TDPS, XXVGMAC_TDPS_HALF);
+		wr_dma_ch_ind(ioaddr, MODE_TXDESCCTRL, i, value);
+	}
+
+	for (i = 0; i < num_vdma_rx; i++) {
+		value = rd_dma_ch_ind(ioaddr, MODE_RXDESCCTRL, i);
+		value &= ~XXVGMAC_RXDCSZ;
+		value |= FIELD_PREP(XXVGMAC_RXDCSZ,
+				    XXVGMAC_RXDCSZ_256BYTES);
+		value &= ~XXVGMAC_RDPS;
+		value |= FIELD_PREP(XXVGMAC_TDPS, XXVGMAC_RDPS_HALF);
+		wr_dma_ch_ind(ioaddr, MODE_RXDESCCTRL, i, value);
+	}
+
+	for (i = 0; i < num_pdma_tx; i++) {
+		value = rd_dma_ch_ind(ioaddr, MODE_TXEXTCFG, i);
+		value &= ~(XXVGMAC_TXPBL | XXVGMAC_TPBLX8_MODE);
+		if (dma_cfg->pblx8)
+			value |= XXVGMAC_TPBLX8_MODE;
+		value |= FIELD_PREP(XXVGMAC_TXPBL, dma_cfg->pbl);
+		wr_dma_ch_ind(ioaddr, MODE_TXEXTCFG, i, value);
+		xgmac4_tp2tc_map(ioaddr, i, dma_cfg->hdma_cfg->tpdma_tc[i]);
+	}
+
+	for (i = 0; i < num_pdma_rx; i++) {
+		value = rd_dma_ch_ind(ioaddr, MODE_RXEXTCFG, i);
+		value &= ~(XXVGMAC_RXPBL | XXVGMAC_RPBLX8_MODE);
+		if (dma_cfg->pblx8)
+			value |= XXVGMAC_RPBLX8_MODE;
+		value |= FIELD_PREP(XXVGMAC_RXPBL, dma_cfg->pbl);
+		wr_dma_ch_ind(ioaddr, MODE_RXEXTCFG, i, value);
+		xgmac4_rp2tc_map(ioaddr, i, dma_cfg->hdma_cfg->rpdma_tc[i]);
+	}
+}
+
+void dw25gmac_dma_init_tx_chan(struct stmmac_priv *priv,
+			       void __iomem *ioaddr,
+			       struct stmmac_dma_cfg *dma_cfg,
+			       dma_addr_t dma_addr, u32 chan)
+{
+	u32 value;
+
+	value = readl(ioaddr + XGMAC_DMA_CH_TX_CONTROL(chan));
+	value &= ~XXVGMAC_TVDMA2TCMP;
+	value |= FIELD_PREP(XXVGMAC_TVDMA2TCMP,
+			    dma_cfg->hdma_cfg->tvdma_tc[chan]);
+	writel(value, ioaddr + XGMAC_DMA_CH_TX_CONTROL(chan));
+
+	writel(upper_32_bits(dma_addr),
+	       ioaddr + XGMAC_DMA_CH_TxDESC_HADDR(chan));
+	writel(lower_32_bits(dma_addr),
+	       ioaddr + XGMAC_DMA_CH_TxDESC_LADDR(chan));
+}
+
+void dw25gmac_dma_init_rx_chan(struct stmmac_priv *priv,
+			       void __iomem *ioaddr,
+			       struct stmmac_dma_cfg *dma_cfg,
+			       dma_addr_t dma_addr, u32 chan)
+{
+	u32 value;
+
+	value = readl(ioaddr + XGMAC_DMA_CH_RX_CONTROL(chan));
+	value &= ~XXVGMAC_RVDMA2TCMP;
+	value |= FIELD_PREP(XXVGMAC_RVDMA2TCMP,
+			    dma_cfg->hdma_cfg->rvdma_tc[chan]);
+	writel(value, ioaddr + XGMAC_DMA_CH_RX_CONTROL(chan));
+
+	writel(upper_32_bits(dma_addr),
+	       ioaddr + XGMAC_DMA_CH_RxDESC_HADDR(chan));
+	writel(lower_32_bits(dma_addr),
+	       ioaddr + XGMAC_DMA_CH_RxDESC_LADDR(chan));
+}
drivers/net/ethernet/stmicro/stmmac/dw25gmac.h new file +18 -0
new file mode 100644
index 000000000000..c7fdf6624fea
@@ -0,0 +1,90 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/* Copyright (c) 2024 Broadcom Corporation
+ * DW25GMAC definitions.
+ */
+#ifndef __STMMAC_DW25GMAC_H__
+#define __STMMAC_DW25GMAC_H__
+
+/* Hardware features */
+#define XXVGMAC_HWFEAT_VDMA_RXCNT	GENMASK(16, 12)
+#define XXVGMAC_HWFEAT_VDMA_TXCNT	GENMASK(22, 18)
+
+/* DMA Indirect Registers*/
+#define XXVGMAC_DMA_CH_IND_CONTROL	0X00003080
+#define XXVGMAC_MODE_SELECT		GENMASK(27, 24)
+enum dma_ch_ind_modes {
+	MODE_TXEXTCFG	 = 0x0,	  /* Tx Extended Config */
+	MODE_RXEXTCFG	 = 0x1,	  /* Rx Extended Config */
+	MODE_TXDBGSTS	 = 0x2,	  /* Tx Debug Status */

drivers/net/ethernet/stmicro/stmmac/dw25gmac.h line 28

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dw25gmac.h new file +10 -0
+	MODE_RXDBGSTS	 = 0x3,	  /* Rx Debug Status */
+	MODE_TXDESCCTRL	 = 0x4,	  /* Tx Descriptor control */
+	MODE_RXDESCCTRL	 = 0x5,	  /* Rx Descriptor control */
+};
+
+#define XXVGMAC_ADDR_OFFSET		GENMASK(14, 8)
+#define XXVGMAC_AUTO_INCR		GENMASK(5, 4)
+#define XXVGMAC_CMD_TYPE			BIT(1)
+#define XXVGMAC_OB			BIT(0)
+#define XXVGMAC_DMA_CH_IND_DATA		0X00003084

nit: lower case please, 0x00003084.

Quoted 124 lines
drivers/net/ethernet/stmicro/stmmac/dw25gmac.h new file +62 -0
+
+/* TX Config definitions */
+#define XXVGMAC_TXPBL			GENMASK(29, 24)
+#define XXVGMAC_TPBLX8_MODE		BIT(19)
+#define XXVGMAC_TP2TCMP			GENMASK(18, 16)
+#define XXVGMAC_ORRQ			GENMASK(13, 8)
+
+/* RX Config definitions */
+#define XXVGMAC_RXPBL			GENMASK(29, 24)
+#define XXVGMAC_RPBLX8_MODE		BIT(19)
+#define XXVGMAC_RP2TCMP			GENMASK(18, 16)
+#define XXVGMAC_OWRQ			GENMASK(13, 8)
+
+/* Tx Descriptor control */
+#define XXVGMAC_TXDCSZ			GENMASK(2, 0)
+#define XXVGMAC_TXDCSZ_0BYTES		0
+#define XXVGMAC_TXDCSZ_64BYTES		1
+#define XXVGMAC_TXDCSZ_128BYTES		2
+#define XXVGMAC_TXDCSZ_256BYTES		3
+#define XXVGMAC_TDPS			GENMASK(5, 3)
+#define XXVGMAC_TDPS_ZERO		0
+#define XXVGMAC_TDPS_1_8TH		1
+#define XXVGMAC_TDPS_1_4TH		2
+#define XXVGMAC_TDPS_HALF		3
+#define XXVGMAC_TDPS_3_4TH		4
+
+/* Rx Descriptor control */
+#define XXVGMAC_RXDCSZ			GENMASK(2, 0)
+#define XXVGMAC_RXDCSZ_0BYTES		0
+#define XXVGMAC_RXDCSZ_64BYTES		1
+#define XXVGMAC_RXDCSZ_128BYTES		2
+#define XXVGMAC_RXDCSZ_256BYTES		3
+#define XXVGMAC_RDPS			GENMASK(5, 3)
+#define XXVGMAC_RDPS_ZERO		0
+#define XXVGMAC_RDPS_1_8TH		1
+#define XXVGMAC_RDPS_1_4TH		2
+#define XXVGMAC_RDPS_HALF		3
+#define XXVGMAC_RDPS_3_4TH		4
+
+/* DWCXG_DMA_CH(#i) Registers*/
+#define XXVGMAC_DSL			GENMASK(20, 18)
+#define XXVGMAC_MSS			GENMASK(13, 0)
+#define XXVGMAC_TFSEL			GENMASK(30, 29)
+#define XXVGMAC_TQOS			GENMASK(27, 24)
+#define XXVGMAC_IPBL			BIT(15)
+#define XXVGMAC_TVDMA2TCMP		GENMASK(6, 4)
+#define XXVGMAC_RPF			BIT(31)
+#define XXVGMAC_RVDMA2TCMP		GENMASK(30, 28)
+#define XXVGMAC_RQOS			GENMASK(27, 24)
+
+void dw25gmac_dma_init(void __iomem *ioaddr,
+		       struct stmmac_dma_cfg *dma_cfg);
+
+void dw25gmac_dma_init_tx_chan(struct stmmac_priv *priv,
+			       void __iomem *ioaddr,
+			       struct stmmac_dma_cfg *dma_cfg,
+			       dma_addr_t dma_addr, u32 chan);
+void dw25gmac_dma_init_rx_chan(struct stmmac_priv *priv,
+			       void __iomem *ioaddr,
+			       struct stmmac_dma_cfg *dma_cfg,
+			       dma_addr_t dma_addr, u32 chan);
+#endif /* __STMMAC_DW25GMAC_H__ */
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c +31 -0
index 7840bc403788..02abfdd40270 100644
@@ -7,6 +7,7 @@
   #include <linux/iopoll.h>
   #include "stmmac.h"
   #include "dwxgmac2.h"
+#include "dw25gmac.h"
 
   static int dwxgmac2_dma_reset(void __iomem *ioaddr)
   {
@@ -641,3 +642,33 @@ const struct stmmac_dma_ops dwxgmac210_dma_ops = {
   	.enable_sph = dwxgmac2_enable_sph,
   	.enable_tbs = dwxgmac2_enable_tbs,
   };
+
+const struct stmmac_dma_ops dw25gmac400_dma_ops = {
+	.reset = dwxgmac2_dma_reset,
+	.init = dw25gmac_dma_init,
+	.init_chan = dwxgmac2_dma_init_chan,
+	.init_rx_chan = dw25gmac_dma_init_rx_chan,
+	.init_tx_chan = dw25gmac_dma_init_tx_chan,
+	.axi = dwxgmac2_dma_axi,
+	.dump_regs = dwxgmac2_dma_dump_regs,
+	.dma_rx_mode = dwxgmac2_dma_rx_mode,
+	.dma_tx_mode = dwxgmac2_dma_tx_mode,
+	.enable_dma_irq = dwxgmac2_enable_dma_irq,
+	.disable_dma_irq = dwxgmac2_disable_dma_irq,
+	.start_tx = dwxgmac2_dma_start_tx,
+	.stop_tx = dwxgmac2_dma_stop_tx,
+	.start_rx = dwxgmac2_dma_start_rx,
+	.stop_rx = dwxgmac2_dma_stop_rx,
+	.dma_interrupt = dwxgmac2_dma_interrupt,
+	.get_hw_feature = dwxgmac2_get_hw_feature,
+	.rx_watchdog = dwxgmac2_rx_watchdog,
+	.set_rx_ring_len = dwxgmac2_set_rx_ring_len,
+	.set_tx_ring_len = dwxgmac2_set_tx_ring_len,
+	.set_rx_tail_ptr = dwxgmac2_set_rx_tail_ptr,
+	.set_tx_tail_ptr = dwxgmac2_set_tx_tail_ptr,
+	.enable_tso = dwxgmac2_enable_tso,
+	.qmode = dwxgmac2_qmode,
+	.set_bfsize = dwxgmac2_set_bfsize,
+	.enable_sph = dwxgmac2_enable_sph,
+	.enable_tbs = dwxgmac2_enable_tbs,
+};
drivers/net/ethernet/stmicro/stmmac/hwif.h +1 -0
index 7e90f34b8c88..9764eadf72c2 100644
@@ -682,6 +682,7 @@ extern const struct stmmac_desc_ops dwxgmac210_desc_ops;
   extern const struct stmmac_mmc_ops dwmac_mmc_ops;
   extern const struct stmmac_mmc_ops dwxgmac_mmc_ops;
   extern const struct stmmac_est_ops dwmac510_est_ops;
+extern const struct stmmac_dma_ops dw25gmac400_dma_ops;
 
   #define GMAC_VERSION		0x00000020	/* GMAC CORE Version */
   #define GMAC4_VERSION		0x00000110	/* GMAC4+ CORE Version */
Signature · 1 line
2.34.1
#7 lore raw

Re: [net-next v4 2/5] net: stmmac: Add basic dw25gmac support to stmmac core

Hi Amit,

Quoted 11 lines · Amit Singh Tomar

Hi,

Quoted 6 lines

The BCM8958x uses early adaptor version of DWC_xgmac version 4.00a for ethernet MAC. The DW25GMAC introduced in this version adds new DMA architecture called Hyper-DMA (HDMA) for virtualization scalability. This is realized by decoupling physical DMA channels(PDMA) from potentially large number of virtual DMA channels (VDMA). The VDMAs are software abastractions that map to PDMAs for frame transmission and reception.

You should either run ./scripts/checkpatch.pl --strict --codespell --patch or use :set spell in vi to check for spelling mistakes

Thank you, I will do that next time.

Quoted 6 lines
Quoted 6 lines
drivers/net/ethernet/stmicro/stmmac/dw25gmac.c new file +6 -0
+static u32 decode_vdma_count(u32 regval)
+{
+     /* compressed encoding for vdma count
+      * regval: VDMA count
+      * 0-15  : 1 - 16
+      * 16-19 : 20, 24, 28, 32
Quoted 8 lines

drivers/net/ethernet/stmicro/stmmac/dw25gmac.c line 61

Quoted 6 lines
drivers/net/ethernet/stmicro/stmmac/dw25gmac.c new file +6 -0
+      * 20-23 : 40, 48, 56, 64
+      * 24-27 : 80, 96, 112, 128
+      */
+     if (regval < 16)
+             return regval + 1;
+     return (4 << ((regval - 16) / 4)) * ((regval % 4) + 5);

Is there a potential for regval to be out of bounds (regval > 27) that needed to be handled properly?

The IP core documentation we have only defines support upto 128 VDMAs. The same formula should for higher values (bound by bitmask).

Quoted 9 lines
Quoted 9 lines
drivers/net/ethernet/stmicro/stmmac/dw25gmac.h new file +3 -0
new file mode 100644
index 000000000000..c7fdf6624fea
@@ -0,0 +1,90 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/* Copyright (c) 2024 Broadcom Corporation
+ * DW25GMAC definitions.
Quoted 8 lines

drivers/net/ethernet/stmicro/stmmac/dw25gmac.h line 28

Quoted 7 lines
drivers/net/ethernet/stmicro/stmmac/dw25gmac.h new file +7 -0
+ */
+
+#define XXVGMAC_ADDR_OFFSET          GENMASK(14, 8)
+#define XXVGMAC_AUTO_INCR            GENMASK(5, 4)
+#define XXVGMAC_CMD_TYPE                     BIT(1)
+#define XXVGMAC_OB                   BIT(0)
+#define XXVGMAC_DMA_CH_IND_DATA              0X00003084

nit: lower case please, 0x00003084.

Thanks, will fix it.

#8 lore raw

PATCH v4 3/5 net: stmmac: Integrate dw25gmac into stmmac hwif handling

In reply to [email protected]

From: Jitendra Vegiraju <[email protected]>

Integrate dw25gmac support into stmmac hardware interface handling. Added a new entry to the stmmac_hw table in hwif.c.
Define new macros DW25GMAC_CORE_4_00 and DW25GMAC_ID to identify 25GMAC device.
Since BCM8958x is an early adaptor device, the synopsis_id reported in HW is 0x32 and device_id is DWXGMAC_ID. Provide override support by defining synopsys_dev_id member in struct stmmac_priv so that driver specific setup functions can override the hardware reported values.

---
 drivers/net/ethernet/stmicro/stmmac/common.h |  2 ++
 drivers/net/ethernet/stmicro/stmmac/hwif.c   | 25 ++++++++++++++++++--
 drivers/net/ethernet/stmicro/stmmac/stmmac.h |  1 +
 3 files changed, 26 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/common.h +2 -0
index 684489156dce..46edbe73a124 100644
@@ -38,9 +38,11 @@
 #define DWXGMAC_CORE_2_10	0x21
 #define DWXGMAC_CORE_2_20	0x22
 #define DWXLGMAC_CORE_2_00	0x20
+#define DW25GMAC_CORE_4_00	0x40
 
 /* Device ID */
 #define DWXGMAC_ID		0x76
+#define DW25GMAC_ID		0x55
 #define DWXLGMAC_ID		0x27
 
 #define STMMAC_CHAN0	0	/* Always supported and default for all chips */
drivers/net/ethernet/stmicro/stmmac/hwif.c +23 -2
index 29367105df54..97e5594ddcda 100644
@@ -278,6 +278,27 @@ static const struct stmmac_hwif_entry {
 		.est = &dwmac510_est_ops,
 		.setup = dwxlgmac2_setup,
 		.quirks = stmmac_dwxlgmac_quirks,
+	}, {
+		.gmac = false,
+		.gmac4 = false,
+		.xgmac = true,
+		.min_id = DW25GMAC_CORE_4_00,
+		.dev_id = DW25GMAC_ID,
+		.regs = {
+			.ptp_off = PTP_XGMAC_OFFSET,
+			.mmc_off = MMC_XGMAC_OFFSET,
+			.est_off = EST_XGMAC_OFFSET,
+		},
+		.desc = &dwxgmac210_desc_ops,
+		.dma = &dw25gmac400_dma_ops,
+		.mac = &dwxgmac210_ops,
+		.hwtimestamp = &stmmac_ptp,
+		.mode = NULL,
+		.tc = &dwmac510_tc_ops,
+		.mmc = &dwxgmac_mmc_ops,
+		.est = &dwmac510_est_ops,
+		.setup = dwxgmac2_setup,
+		.quirks = NULL,
 	},
 };
 
@@ -304,7 +325,7 @@ int stmmac_hwif_init(struct stmmac_priv *priv)
 
 	/* Save ID for later use */
 	priv->synopsys_id = id;
-
+	priv->synopsys_dev_id = dev_id;
 	/* Lets assume some safe values first */
 	priv->ptpaddr = priv->ioaddr +
 		(needs_gmac4 ? PTP_GMAC4_OFFSET : PTP_GMAC3_X_OFFSET);
@@ -339,7 +360,7 @@ int stmmac_hwif_init(struct stmmac_priv *priv)
 		/* Use synopsys_id var because some setups can override this */
 		if (priv->synopsys_id < entry->min_id)
 			continue;
-		if (needs_xgmac && (dev_id ^ entry->dev_id))
+		if (needs_xgmac && (priv->synopsys_dev_id ^ entry->dev_id))
 			continue;
 
 		/* Only use generic HW helpers if needed */
drivers/net/ethernet/stmicro/stmmac/stmmac.h +1 -0
index b23b920eedb1..9784bbaf9a51 100644
@@ -282,6 +282,7 @@ struct stmmac_priv {
 	struct stmmac_counters mmc;
 	int hw_cap_support;
 	int synopsys_id;
+	int synopsys_dev_id;
 	u32 msg_enable;
 	int wolopts;
 	int wol_irq;
Signature · 1 line
2.34.1
#9 lore raw

Re: [net-next v4 3/5] net: stmmac: Integrate dw25gmac into stmmac hwif handling

Hi Jitendra

Quoted 55 lines · On Wed, Aug 14, 2024 at 03:18:16PM -0700, [email protected] wrote:

From: Jitendra Vegiraju <[email protected]>

Integrate dw25gmac support into stmmac hardware interface handling. Added a new entry to the stmmac_hw table in hwif.c.
Define new macros DW25GMAC_CORE_4_00 and DW25GMAC_ID to identify 25GMAC device.
Since BCM8958x is an early adaptor device, the synopsis_id reported in HW is 0x32 and device_id is DWXGMAC_ID. Provide override support by defining synopsys_dev_id member in struct stmmac_priv so that driver specific setup functions can override the hardware reported values.

---
 drivers/net/ethernet/stmicro/stmmac/common.h |  2 ++
 drivers/net/ethernet/stmicro/stmmac/hwif.c   | 25 ++++++++++++++++++--
 drivers/net/ethernet/stmicro/stmmac/stmmac.h |  1 +
 3 files changed, 26 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/common.h +2 -0
index 684489156dce..46edbe73a124 100644
@@ -38,9 +38,11 @@
 #define DWXGMAC_CORE_2_10	0x21
 #define DWXGMAC_CORE_2_20	0x22
 #define DWXLGMAC_CORE_2_00	0x20
+#define DW25GMAC_CORE_4_00	0x40
 
 /* Device ID */
 #define DWXGMAC_ID		0x76
+#define DW25GMAC_ID		0x55
 #define DWXLGMAC_ID		0x27
 
 #define STMMAC_CHAN0	0	/* Always supported and default for all chips */
drivers/net/ethernet/stmicro/stmmac/hwif.c +12 -0
index 29367105df54..97e5594ddcda 100644
@@ -278,6 +278,27 @@ static const struct stmmac_hwif_entry {
 		.est = &dwmac510_est_ops,
 		.setup = dwxlgmac2_setup,
 		.quirks = stmmac_dwxlgmac_quirks,
 
+	}, {
+		.gmac = false,
+		.gmac4 = false,
+		.xgmac = true,
+		.min_id = DW25GMAC_CORE_4_00,
+		.dev_id = DW25GMAC_ID,
+		.regs = {
+			.ptp_off = PTP_XGMAC_OFFSET,
+			.mmc_off = MMC_XGMAC_OFFSET,
+			.est_off = EST_XGMAC_OFFSET,
+		},
+		.desc = &dwxgmac210_desc_ops,

drivers/net/ethernet/stmicro/stmmac/hwif.c static const struct stmmac_hwif_entry { · line 303

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/hwif.c +9 -0
+		.dma = &dw25gmac400_dma_ops,
+		.mac = &dwxgmac210_ops,
+		.hwtimestamp = &stmmac_ptp,
+		.mode = NULL,
+		.tc = &dwmac510_tc_ops,
+		.mmc = &dwxgmac_mmc_ops,
+		.est = &dwmac510_est_ops,
+		.setup = dwxgmac2_setup,
+		.quirks = NULL,
 	},

This can be replaced with just:

+ }, {
+ .gmac = false,
+ .gmac4 = false,
+ .xgmac = true,
+ .min_id = DW25GMAC_CORE_4_00,
+ .dev_id = DWXGMAC_ID, /* Early DW 25GMAC IP-core had XGMAC ID */
+ .regs = {
+ .ptp_off = PTP_XGMAC_OFFSET,
+ .mmc_off = MMC_XGMAC_OFFSET,
+ .est_off = EST_XGMAC_OFFSET,
+ },
+ .desc = &dwxgmac210_desc_ops,
+ .dma = &dw25gmac400_dma_ops,
+ .mac = &dwxgmac210_ops,
+ .hwtimestamp = &stmmac_ptp,
+ .mode = NULL,
+ .tc = &dwmac510_tc_ops,
+ .mmc = &dwxgmac_mmc_ops,
+ .est = &dwmac510_est_ops,
+ .setup = dw25gmac_setup,
+ .quirks = NULL,

	}

and you won't need to pre-define the setup() method in the glue driver. Instead you can define a new dw25xgmac_setup() method in the dwxgmac2_core.c as it's done for the DW XGMAC/LXGMAC IP-cores.

Note if your device is capable to work with up to 10Gbps speed, then just set the plat_stmmacenet_data::max_speed field to SPEED_10000. Alternatively if you really need to specify the exact MAC capabilities, then you can implement what Russell suggested here sometime ago:
https://lore.kernel.org/netdev/Zf3ifH%[email protected]/

If you also have a DW 25GMAC-based device with 0x55 device ID, then just add another stmmac_hw[] array entry.

Quoted 25 lines
drivers/net/ethernet/stmicro/stmmac/hwif.c +2 -2
 };
@@ -304,7 +325,7 @@ int stmmac_hwif_init(struct stmmac_priv *priv)
 
 	/* Save ID for later use */
 	priv->synopsys_id = id;
-
+	priv->synopsys_dev_id = dev_id;
 	/* Lets assume some safe values first */
 	priv->ptpaddr = priv->ioaddr +
 		(needs_gmac4 ? PTP_GMAC4_OFFSET : PTP_GMAC3_X_OFFSET);
@@ -339,7 +360,7 @@ int stmmac_hwif_init(struct stmmac_priv *priv)
 		/* Use synopsys_id var because some setups can override this */
 		if (priv->synopsys_id < entry->min_id)
 			continue;
-		if (needs_xgmac && (dev_id ^ entry->dev_id))
+		if (needs_xgmac && (priv->synopsys_dev_id ^ entry->dev_id))
 			continue;
 
 		/* Only use generic HW helpers if needed */
drivers/net/ethernet/stmicro/stmmac/stmmac.h +0 -0
index b23b920eedb1..9784bbaf9a51 100644

drivers/net/ethernet/stmicro/stmmac/stmmac.h struct stmmac_priv { · line 286

Quoted 5 lines
drivers/net/ethernet/stmicro/stmmac/stmmac.h +1 -0
@@ -282,6 +282,7 @@ struct stmmac_priv {
 	struct stmmac_counters mmc;
 	int hw_cap_support;
 	int synopsys_id;
 
+	int synopsys_dev_id;

With the suggestion above implemented you won't need this.

-Serge(y)

Quoted 6 lines
drivers/net/ethernet/stmicro/stmmac/stmmac.h +0 -0
 	u32 msg_enable;
 	int wolopts;

int wol_irq;

Signature · 1 line
2.34.1
#10 lore raw

Re: [net-next v4 3/5] net: stmmac: Integrate dw25gmac into stmmac hwif handling

Hi Serge(y)
Thank you for reviewing the patch.

Quoted 99 lines · Serge Semin

Hi Jitendra

Quoted 55 lines · On Wed, Aug 14, 2024 at 03:18:16PM -0700, [email protected] wrote:

From: Jitendra Vegiraju <[email protected]>

Integrate dw25gmac support into stmmac hardware interface handling. Added a new entry to the stmmac_hw table in hwif.c.
Define new macros DW25GMAC_CORE_4_00 and DW25GMAC_ID to identify 25GMAC device.
Since BCM8958x is an early adaptor device, the synopsis_id reported in HW is 0x32 and device_id is DWXGMAC_ID. Provide override support by defining synopsys_dev_id member in struct stmmac_priv so that driver specific setup functions can override the hardware reported values.

---
 drivers/net/ethernet/stmicro/stmmac/common.h |  2 ++
 drivers/net/ethernet/stmicro/stmmac/hwif.c   | 25 ++++++++++++++++++--
 drivers/net/ethernet/stmicro/stmmac/stmmac.h |  1 +
 3 files changed, 26 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/common.h +2 -0
index 684489156dce..46edbe73a124 100644
@@ -38,9 +38,11 @@
 #define DWXGMAC_CORE_2_10    0x21
 #define DWXGMAC_CORE_2_20    0x22
 #define DWXLGMAC_CORE_2_00   0x20
+#define DW25GMAC_CORE_4_00   0x40
 
 /* Device ID */
 #define DWXGMAC_ID           0x76
+#define DW25GMAC_ID          0x55
 #define DWXLGMAC_ID          0x27
 
 #define STMMAC_CHAN0 0       /* Always supported and default for all chips */
drivers/net/ethernet/stmicro/stmmac/hwif.c +12 -0
index 29367105df54..97e5594ddcda 100644
@@ -278,6 +278,27 @@ static const struct stmmac_hwif_entry {
              .est = &dwmac510_est_ops,
              .setup = dwxlgmac2_setup,
              .quirks = stmmac_dwxlgmac_quirks,
 
+     }, {
+             .gmac = false,
+             .gmac4 = false,
+             .xgmac = true,
+             .min_id = DW25GMAC_CORE_4_00,
+             .dev_id = DW25GMAC_ID,
+             .regs = {
+                     .ptp_off = PTP_XGMAC_OFFSET,
+                     .mmc_off = MMC_XGMAC_OFFSET,
+                     .est_off = EST_XGMAC_OFFSET,
+             },
+             .desc = &dwxgmac210_desc_ops,

drivers/net/ethernet/stmicro/stmmac/hwif.c static const struct stmmac_hwif_entry { · line 303

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/hwif.c +9 -0
+             .dma = &dw25gmac400_dma_ops,
+             .mac = &dwxgmac210_ops,
+             .hwtimestamp = &stmmac_ptp,
+             .mode = NULL,
+             .tc = &dwmac510_tc_ops,
+             .mmc = &dwxgmac_mmc_ops,
+             .est = &dwmac510_est_ops,
+             .setup = dwxgmac2_setup,
+             .quirks = NULL,
      },

This can be replaced with just:

drivers/net/ethernet/stmicro/stmmac/hwif.c +21 -0
+       }, {
+               .gmac = false,
+               .gmac4 = false,
+               .xgmac = true,
+               .min_id = DW25GMAC_CORE_4_00,
+               .dev_id = DWXGMAC_ID, /* Early DW 25GMAC IP-core had XGMAC ID */
+               .regs = {
+                       .ptp_off = PTP_XGMAC_OFFSET,
+                       .mmc_off = MMC_XGMAC_OFFSET,
+                       .est_off = EST_XGMAC_OFFSET,
+               },
+               .desc = &dwxgmac210_desc_ops,
+               .dma = &dw25gmac400_dma_ops,
+               .mac = &dwxgmac210_ops,
+               .hwtimestamp = &stmmac_ptp,
+               .mode = NULL,
+               .tc = &dwmac510_tc_ops,
+               .mmc = &dwxgmac_mmc_ops,
+               .est = &dwmac510_est_ops,
+               .setup = dw25gmac_setup,
+               .quirks = NULL,
        }

and you won't need to pre-define the setup() method in the glue driver. Instead you can define a new dw25xgmac_setup() method in the dwxgmac2_core.c as it's done for the DW XGMAC/LXGMAC IP-cores.

Quoted 7 lines

Note if your device is capable to work with up to 10Gbps speed, then just set the plat_stmmacenet_data::max_speed field to SPEED_10000. Alternatively if you really need to specify the exact MAC capabilities, then you can implement what Russell suggested here sometime ago:
https://lore.kernel.org/netdev/Zf3ifH%[email protected]/

I like your suggestion to add one stmmac_hw[] array entry (entry_a) for this "early release" DW25GMAC IP and another entry (entry_b) for final DW25MAC IP, in the process eliminate the need for a new member variable in struct stmmac_priv.

However, I would like to bring to your attention that this device requires special handling for both synopsys_id and dev_id.
This device is reporting 0x32 for synopsys_id and 0x76(XGMAC) for dev_id. The final 25GMAC spec will have 0x40 for synopsys_id and 0x55(25GMAC) for dev_id.

So, in order to avoid falsely qualifying other XGMAC devices with synopsis_id >=0x32 as DW25GMAC, I am thinking we will have to overwrite the synopsys_id to 0x40 (DW25GMAC_CORE_4_00) in glue driver using existing glue driver override mechanism.

We can implement dw25gmac_setup() in dwxgmac2_core.c for generic 25GMAC case. But, this glue driver will have to rely on its own setup function to override the synopsys_id as DW25GMAC_CORE_4_00.

Do you think it looks reasonable?
If yes, do you want me to add the generic 25GMAC stmmac_hw[] entry ("entry_b") now or when
such a device becomes available for testing?

Quoted 4 lines

If you also have a DW 25GMAC-based device with 0x55 device ID, then just add another stmmac_hw[] array entry.

Quoted 8 lines
Quoted 6 lines
drivers/net/ethernet/stmicro/stmmac/hwif.c +0 -0
 };
      int hw_cap_support;
      int synopsys_id;

+ int synopsys_dev_id;

With the suggestion above implemented you won't need this.

Got it. Thanks.

Quoted 9 lines

-Serge(y)

Quoted 6 lines
      u32 msg_enable;
      int wolopts;
      int wol_irq;

--
2.34.1

#11 lore raw

Re: [net-next v4 3/5] net: stmmac: Integrate dw25gmac into stmmac hwif handling

Hi Jitendra

Quoted 116 lines · Jitendra Vegiraju

Hi Serge(y)
Thank you for reviewing the patch.

Quoted 99 lines · Serge Semin

Hi Jitendra

Quoted 55 lines · On Wed, Aug 14, 2024 at 03:18:16PM -0700, [email protected] wrote:

From: Jitendra Vegiraju <[email protected]>

Integrate dw25gmac support into stmmac hardware interface handling. Added a new entry to the stmmac_hw table in hwif.c.
Define new macros DW25GMAC_CORE_4_00 and DW25GMAC_ID to identify 25GMAC device.
Since BCM8958x is an early adaptor device, the synopsis_id reported in HW is 0x32 and device_id is DWXGMAC_ID. Provide override support by defining synopsys_dev_id member in struct stmmac_priv so that driver specific setup functions can override the hardware reported values.

---
 drivers/net/ethernet/stmicro/stmmac/common.h |  2 ++
 drivers/net/ethernet/stmicro/stmmac/hwif.c   | 25 ++++++++++++++++++--
 drivers/net/ethernet/stmicro/stmmac/stmmac.h |  1 +
 3 files changed, 26 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/common.h +2 -0
index 684489156dce..46edbe73a124 100644
@@ -38,9 +38,11 @@
 #define DWXGMAC_CORE_2_10    0x21
 #define DWXGMAC_CORE_2_20    0x22
 #define DWXLGMAC_CORE_2_00   0x20
+#define DW25GMAC_CORE_4_00   0x40
 
 /* Device ID */
 #define DWXGMAC_ID           0x76
+#define DW25GMAC_ID          0x55
 #define DWXLGMAC_ID          0x27
 
 #define STMMAC_CHAN0 0       /* Always supported and default for all chips */
drivers/net/ethernet/stmicro/stmmac/hwif.c +12 -0
index 29367105df54..97e5594ddcda 100644
@@ -278,6 +278,27 @@ static const struct stmmac_hwif_entry {
              .est = &dwmac510_est_ops,
              .setup = dwxlgmac2_setup,
              .quirks = stmmac_dwxlgmac_quirks,
 
+     }, {
+             .gmac = false,
+             .gmac4 = false,
+             .xgmac = true,
+             .min_id = DW25GMAC_CORE_4_00,
+             .dev_id = DW25GMAC_ID,
+             .regs = {
+                     .ptp_off = PTP_XGMAC_OFFSET,
+                     .mmc_off = MMC_XGMAC_OFFSET,
+                     .est_off = EST_XGMAC_OFFSET,
+             },
+             .desc = &dwxgmac210_desc_ops,

drivers/net/ethernet/stmicro/stmmac/hwif.c static const struct stmmac_hwif_entry { · line 303

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/hwif.c +9 -0
+             .dma = &dw25gmac400_dma_ops,
+             .mac = &dwxgmac210_ops,
+             .hwtimestamp = &stmmac_ptp,
+             .mode = NULL,
+             .tc = &dwmac510_tc_ops,
+             .mmc = &dwxgmac_mmc_ops,
+             .est = &dwmac510_est_ops,
+             .setup = dwxgmac2_setup,
+             .quirks = NULL,
      },

This can be replaced with just:

drivers/net/ethernet/stmicro/stmmac/hwif.c +21 -0
+       }, {
+               .gmac = false,
+               .gmac4 = false,
+               .xgmac = true,
+               .min_id = DW25GMAC_CORE_4_00,
+               .dev_id = DWXGMAC_ID, /* Early DW 25GMAC IP-core had XGMAC ID */
+               .regs = {
+                       .ptp_off = PTP_XGMAC_OFFSET,
+                       .mmc_off = MMC_XGMAC_OFFSET,
+                       .est_off = EST_XGMAC_OFFSET,
+               },
+               .desc = &dwxgmac210_desc_ops,
+               .dma = &dw25gmac400_dma_ops,
+               .mac = &dwxgmac210_ops,
+               .hwtimestamp = &stmmac_ptp,
+               .mode = NULL,
+               .tc = &dwmac510_tc_ops,
+               .mmc = &dwxgmac_mmc_ops,
+               .est = &dwmac510_est_ops,
+               .setup = dw25gmac_setup,
+               .quirks = NULL,
        }

and you won't need to pre-define the setup() method in the glue driver. Instead you can define a new dw25xgmac_setup() method in the dwxgmac2_core.c as it's done for the DW XGMAC/LXGMAC IP-cores.

Quoted 7 lines

Note if your device is capable to work with up to 10Gbps speed, then just set the plat_stmmacenet_data::max_speed field to SPEED_10000. Alternatively if you really need to specify the exact MAC capabilities, then you can implement what Russell suggested here sometime ago:
https://lore.kernel.org/netdev/Zf3ifH%[email protected]/

I like your suggestion to add one stmmac_hw[] array entry (entry_a) for this "early release" DW25GMAC IP and another entry (entry_b) for final DW25MAC IP, in the process eliminate the need for a new member variable in struct stmmac_priv.

Quoted 5 lines

However, I would like to bring to your attention that this device requires special handling for both synopsys_id and dev_id.
This device is reporting 0x32 for synopsys_id and 0x76(XGMAC) for dev_id. The final 25GMAC spec will have 0x40 for synopsys_id and 0x55(25GMAC) for dev_id.

For some reason I was thinking that your device had only the device ID pre-defined with the XGMAC value meanwhile the Synopsys ID was 0x40. Indeed you get to override both of these data in the platform-specific setup() method.

Quoted 11 lines

So, in order to avoid falsely qualifying other XGMAC devices with synopsis_id >=0x32 as DW25GMAC, I am thinking we will have to overwrite the synopsys_id to 0x40 (DW25GMAC_CORE_4_00) in glue driver using existing glue driver override mechanism.

We can implement dw25gmac_setup() in dwxgmac2_core.c for generic 25GMAC case. But, this glue driver will have to rely on its own setup function to override the synopsys_id as DW25GMAC_CORE_4_00.

Do you think it looks reasonable?

What I was trying to avoid was the setup() method re-definition just for the sake of the IP-core version override. Because if not for that you could have created and used the generic DW 25GMAC dw25gmac_setup() function.

One of the possible solutions I was thinking was to introduce the plat_stmmacenet_data::{snps_id,dev_id} fields and use their values in the stmmac_hwif_init() procedure instead of the data read from the MAC.VERSION CSR.

Another solution could be to add the plat_stmmacenet_data::has_25gmac field and fix the generic driver code to using it where it's relevant. Then you won't need to think about what actual Synopsys ID/Device ID since it would mean a whole new IP-core.

-Serge(y)

Quoted 28 lines

If yes, do you want me to add the generic 25GMAC stmmac_hw[] entry ("entry_b") now or when
such a device becomes available for testing?

Quoted 4 lines

If you also have a DW 25GMAC-based device with 0x55 device ID, then just add another stmmac_hw[] array entry.

Quoted 8 lines
Quoted 6 lines
drivers/net/ethernet/stmicro/stmmac/hwif.c +0 -0
 };
      int hw_cap_support;
      int synopsys_id;

+ int synopsys_dev_id;

With the suggestion above implemented you won't need this.

Got it. Thanks.

Quoted 9 lines

-Serge(y)

Quoted 6 lines
      u32 msg_enable;
      int wolopts;
      int wol_irq;

--
2.34.1

#12 lore raw

Re: [net-next v4 3/5] net: stmmac: Integrate dw25gmac into stmmac hwif handling

Quoted 118 lines · Serge Semin

Hi Jitendra

Quoted 86 lines · Jitendra Vegiraju

Hi Serge(y)
Thank you for reviewing the patch.

Quoted 69 lines · Serge Semin

Hi Jitendra

Quoted 25 lines · On Wed, Aug 14, 2024 at 03:18:16PM -0700, [email protected] wrote:

From: Jitendra Vegiraju <[email protected]>

Integrate dw25gmac support into stmmac hardware interface handling. Added a new entry to the stmmac_hw table in hwif.c.
Define new macros DW25GMAC_CORE_4_00 and DW25GMAC_ID to identify 25GMAC device.
Since BCM8958x is an early adaptor device, the synopsis_id reported in HW is 0x32 and device_id is DWXGMAC_ID. Provide override support by defining synopsys_dev_id member in struct stmmac_priv so that driver specific setup functions can override the hardware reported values.

---

drivers/net/ethernet/stmicro/stmmac/hwif.c +12 -0
+     }, {
+             .gmac = false,
+             .gmac4 = false,
+             .xgmac = true,
+             .min_id = DW25GMAC_CORE_4_00,
+             .dev_id = DW25GMAC_ID,
+             .regs = {
+                     .ptp_off = PTP_XGMAC_OFFSET,
+                     .mmc_off = MMC_XGMAC_OFFSET,
+                     .est_off = EST_XGMAC_OFFSET,
+             },
+             .desc = &dwxgmac210_desc_ops,

drivers/net/ethernet/stmicro/stmmac/hwif.c static const struct stmmac_hwif_entry { · line 302

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/hwif.c +9 -0
+             .dma = &dw25gmac400_dma_ops,
+             .mac = &dwxgmac210_ops,
+             .hwtimestamp = &stmmac_ptp,
+             .mode = NULL,
+             .tc = &dwmac510_tc_ops,
+             .mmc = &dwxgmac_mmc_ops,
+             .est = &dwmac510_est_ops,
+             .setup = dwxgmac2_setup,
+             .quirks = NULL,
      },

This can be replaced with just:

drivers/net/ethernet/stmicro/stmmac/hwif.c +21 -0
+       }, {
+               .gmac = false,
+               .gmac4 = false,
+               .xgmac = true,
+               .min_id = DW25GMAC_CORE_4_00,
+               .dev_id = DWXGMAC_ID, /* Early DW 25GMAC IP-core had XGMAC ID */
+               .regs = {
+                       .ptp_off = PTP_XGMAC_OFFSET,
+                       .mmc_off = MMC_XGMAC_OFFSET,
+                       .est_off = EST_XGMAC_OFFSET,
+               },
+               .desc = &dwxgmac210_desc_ops,
+               .dma = &dw25gmac400_dma_ops,
+               .mac = &dwxgmac210_ops,
+               .hwtimestamp = &stmmac_ptp,
+               .mode = NULL,
+               .tc = &dwmac510_tc_ops,
+               .mmc = &dwxgmac_mmc_ops,
+               .est = &dwmac510_est_ops,
+               .setup = dw25gmac_setup,
+               .quirks = NULL,
        }

and you won't need to pre-define the setup() method in the glue driver. Instead you can define a new dw25xgmac_setup() method in the dwxgmac2_core.c as it's done for the DW XGMAC/LXGMAC IP-cores.

Quoted 7 lines

Note if your device is capable to work with up to 10Gbps speed, then just set the plat_stmmacenet_data::max_speed field to SPEED_10000. Alternatively if you really need to specify the exact MAC capabilities, then you can implement what Russell suggested here sometime ago:
https://lore.kernel.org/netdev/Zf3ifH%[email protected]/

I like your suggestion to add one stmmac_hw[] array entry (entry_a) for this "early release" DW25GMAC IP and another entry (entry_b) for final DW25MAC IP, in the process eliminate the need for a new member variable in struct stmmac_priv.

Quoted 5 lines

However, I would like to bring to your attention that this device requires special handling for both synopsys_id and dev_id.
This device is reporting 0x32 for synopsys_id and 0x76(XGMAC) for dev_id. The final 25GMAC spec will have 0x40 for synopsys_id and 0x55(25GMAC) for dev_id.

For some reason I was thinking that your device had only the device ID pre-defined with the XGMAC value meanwhile the Synopsys ID was 0x40. Indeed you get to override both of these data in the platform-specific setup() method.

Quoted 11 lines

So, in order to avoid falsely qualifying other XGMAC devices with synopsis_id >=0x32 as DW25GMAC, I am thinking we will have to overwrite the synopsys_id to 0x40 (DW25GMAC_CORE_4_00) in glue driver using existing glue driver override mechanism.

We can implement dw25gmac_setup() in dwxgmac2_core.c for generic 25GMAC case. But, this glue driver will have to rely on its own setup function to override the synopsys_id as DW25GMAC_CORE_4_00.

Do you think it looks reasonable?

What I was trying to avoid was the setup() method re-definition just for the sake of the IP-core version override. Because if not for that you could have created and used the generic DW 25GMAC dw25gmac_setup() function.

Quoted 5 lines

One of the possible solutions I was thinking was to introduce the plat_stmmacenet_data::{snps_id,dev_id} fields and use their values in the stmmac_hwif_init() procedure instead of the data read from the MAC.VERSION CSR.

Hi Serge(y),
Thanks for the suggestions, I will implement this option since the code change is mostly local.
We will have to add following check in hwif.c
@@ -313,7 +313,10 @@ int stmmac_hwif_init(struct stmmac_priv *priv)

        u32 id, dev_id = 0;
        int i, ret;

- if (needs_gmac) {
+ if (priv->plat->snps_id && priv->plat->snps_dev_id) {
+ id = priv->plat->snps_id;
+ dev_id = priv->plat->snps_dev_id;

+       } else if (needs_gmac) {
                id = stmmac_get_id(priv, GMAC_VERSION);
Quoted 7 lines

Another solution could be to add the plat_stmmacenet_data::has_25gmac field and fix the generic driver code to using it where it's relevant. Then you won't need to think about what actual Synopsys ID/Device ID since it would mean a whole new IP-core.

-Serge(y)

#13 lore raw

PATCH v4 4/5 net: stmmac: Add PCI driver support for BCM8958x

In reply to [email protected]

From: Jitendra Vegiraju <[email protected]>

Add PCI ethernet driver support for Broadcom BCM8958x SoC devices used in automotive applications.

This SoC device has PCIe ethernet MAC attached to an integrated ethernet switch using XGMII interface. The PCIe ethernet controller is presented to the Linux host as PCI network device.

The following block diagram gives an overview of the application.

             +=================================+
             |       Host CPU/Linux            |
             +=================================+
                        || PCIe
                        ||
        +==========================================+
        |           +--------------+               |
        |           | PCIE Endpoint|               |
        |           | Ethernet     |               |
        |           | Controller   |               |
        |           |   DMA        |               |
        |           +--------------+               |
        |           |   MAC        |   BCM8958X    |
        |           +--------------+   SoC         |
        |               || XGMII                   |
        |               ||                         |
        |           +--------------+               |
        |           | Ethernet     |               |
        |           | switch       |               |
        |           +--------------+               |
        |             || || || ||                  |
        +==========================================+
                      || || || || More external interfaces

The MAC IP block on BCM8958x is based on Synopsis XGMAC 4.00a core. This driver uses common dwxgmac2 code where applicable.
Driver functionality specific to this MAC is implemented in dw25gmac.c. The glue driver is responsible for setting up hdma mappings.

Management of integrated ethernet switch on this SoC is not handled by the PCIe interface.
Since BCM8958x is an early adaptor device, override the hardware reported synopsis versions with actual DW25MAC versions that support hdma.

This SoC device has PCIe ethernet MAC directly attached to an integrated ethernet switch using XGMII interface. Since device tree support is not available on this platform, a software node is created to enable fixed-link support using phylink driver.

---
 .../net/ethernet/stmicro/stmmac/dwmac-brcm.c  | 530 ++++++++++++++++++
 1 file changed, 530 insertions(+)
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-brcm.c
drivers/net/ethernet/stmicro/stmmac/dwmac-brcm.c new file +530 -0
new file mode 100644
index 000000000000..4384f45e86b1
@@ -0,0 +1,530 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/* Copyright (c) 2024 Broadcom Corporation
+ *
+ * PCI driver for ethernet interface of BCM8958X automotive switch chip.
+ *
+ * High level block diagram of the device.
+ *              +=================================+
+ *              |       Host CPU/Linux            |
+ *              +=================================+
+ *                         || PCIe
+ *                         ||
+ *         +==========================================+
+ *         |           +--------------+               |
+ *         |           | PCIE Endpoint|               |
+ *         |           | Ethernet     |               |
+ *         |           | Controller   |               |
+ *         |           |   DMA        |               |
+ *         |           +--------------+               |
+ *         |           |   MAC        |   BCM8958X    |
+ *         |           +--------------+   SoC         |
+ *         |               || XGMII                   |
+ *         |               ||                         |
+ *         |           +--------------+               |
+ *         |           | Ethernet     |               |
+ *         |           | switch       |               |
+ *         |           +--------------+               |
+ *         |             || || || ||                  |
+ *         +==========================================+
+ *                       || || || || More external interfaces
+ *
+ * This SoC device has PCIe ethernet MAC directly attached to an integrated
+ * ethernet switch using XGMII interface. Since devicetree support is not
+ * available on this platform, a software node is created to enable
+ * fixed-link support using phylink driver.
+ */
+
+#include <linux/clk-provider.h>
+#include <linux/dmi.h>
+#include <linux/pci.h>
+#include <linux/phy.h>
+
+#include "stmmac.h"
+#include "dwxgmac2.h"
+
+#define PCI_DEVICE_ID_BROADCOM_BCM8958X		0xa00d
+#define BRCM_MAX_MTU				1500
+#define READ_POLL_DELAY_US			100
+#define READ_POLL_TIMEOUT_US			10000
+#define DWMAC_125MHZ				125000000
+#define DWMAC_250MHZ				250000000
+#define BRCM_XGMAC_NUM_VLAN_FILTERS		32
+
+/* TX and RX Queue counts */
+#define BRCM_TX_Q_COUNT				4
+#define BRCM_RX_Q_COUNT				4
+
+#define BRCM_XGMAC_DMA_TX_SIZE			1024
+#define BRCM_XGMAC_DMA_RX_SIZE			1024
+#define BRCM_XGMAC_BAR0_MASK			BIT(0)
+
+#define BRCM_XGMAC_IOMEM_MISC_REG_OFFSET	0x0
+#define BRCM_XGMAC_IOMEM_MBOX_REG_OFFSET	0x1000
+#define BRCM_XGMAC_IOMEM_CFG_REG_OFFSET		0x3000
+
+#define XGMAC_MMC_CTRL_RCHM_DISABLE		BIT(31)
+#define XGMAC_PCIE_CFG_MSIX_ADDR_MATCH_LOW	0x940
+#define XGMAC_PCIE_CFG_MSIX_ADDR_MATCH_LO_VALUE	0x00000001
+#define XGMAC_PCIE_CFG_MSIX_ADDR_MATCH_HIGH	0x944
+#define XGMAC_PCIE_CFG_MSIX_ADDR_MATCH_HI_VALUE	0x88000000
+
+#define XGMAC_PCIE_MISC_MII_CTRL_OFFSET			0x4
+#define XGMAC_PCIE_MISC_MII_CTRL_PAUSE_RX		BIT(0)
+#define XGMAC_PCIE_MISC_MII_CTRL_PAUSE_TX		BIT(1)
+#define XGMAC_PCIE_MISC_MII_CTRL_LINK_UP		BIT(2)
+#define XGMAC_PCIE_MISC_PCIESS_CTRL_OFFSET		0x8
+#define XGMAC_PCIE_MISC_PCIESS_CTRL_EN_MSI_MSIX		BIT(9)
+#define XGMAC_PCIE_MISC_MSIX_ADDR_MATCH_LO_OFFSET	0x90
+#define XGMAC_PCIE_MISC_MSIX_ADDR_MATCH_LO_VALUE	0x00000001
+#define XGMAC_PCIE_MISC_MSIX_ADDR_MATCH_HI_OFFSET	0x94
+#define XGMAC_PCIE_MISC_MSIX_ADDR_MATCH_HI_VALUE	0x88000000
+#define XGMAC_PCIE_MISC_MSIX_VECTOR_MAP_EP2HOST0_OFFSET	0x700
+#define XGMAC_PCIE_MISC_MSIX_VECTOR_MAP_EP2HOST0_VALUE	1
+#define XGMAC_PCIE_MISC_MSIX_VECTOR_MAP_EP2HOST1_OFFSET	0x704
+#define XGMAC_PCIE_MISC_MSIX_VECTOR_MAP_EP2HOST1_VALUE	1
+#define XGMAC_PCIE_MISC_MSIX_VECTOR_MAP_EP2HOST_DBELL_OFFSET	0x728
+#define XGMAC_PCIE_MISC_MSIX_VECTOR_MAP_EP2HOST_DBELL_VALUE	1
+#define XGMAC_PCIE_MISC_MSIX_VECTOR_MAP_SBD_ALL_OFFSET	0x740
+#define XGMAC_PCIE_MISC_MSIX_VECTOR_MAP_SBD_ALL_VALUE	0
+
+#define XGMAC_PCIE_MISC_FUNC_RESOURCES_PF0_OFFSET	0x804
+
+/* MSIX Vector map register starting offsets */
+#define XGMAC_PCIE_MISC_MSIX_VECTOR_MAP_RX0_PF0_OFFSET	0x840
+#define XGMAC_PCIE_MISC_MSIX_VECTOR_MAP_TX0_PF0_OFFSET	0x890
+#define BRCM_MAX_DMA_CHANNEL_PAIRS		4
+
+#define BRCM_XGMAC_MSI_MAC_VECTOR		0
+#define BRCM_XGMAC_MSI_RX_VECTOR_START		9
+#define BRCM_XGMAC_MSI_TX_VECTOR_START		10
+
+static char *fixed_link_node_name = "fixed-link";
+
+static const struct property_entry fixed_link_properties[] = {
+	PROPERTY_ENTRY_U32("speed", 10000),
+	PROPERTY_ENTRY_BOOL("full-duplex"),
+	PROPERTY_ENTRY_BOOL("pause"),
+	{ }
+};
+
+struct brcm_priv_data {
+	void __iomem *mbox_regs;    /* MBOX  Registers*/
+	void __iomem *misc_regs;    /* MISC  Registers*/
+	void __iomem *xgmac_regs;   /* XGMAC Registers*/
+	struct software_node fixed_link_node;
+};
+
+struct dwxgmac_brcm_pci_info {
+	int (*setup)(struct pci_dev *pdev, struct plat_stmmacenet_data *plat);
+};
+
+static void misc_iowrite(struct brcm_priv_data *brcm_priv,
+			 u32 reg, u32 val)
+{
+	iowrite32(val, brcm_priv->misc_regs + reg);
+}
+
+static struct mac_device_info *dwxgmac_brcm_setup(void *ppriv)
+{
+	struct stmmac_priv *priv = ppriv;
+	struct mac_device_info *mac;
+
+	mac = devm_kzalloc(priv->device, sizeof(*mac), GFP_KERNEL);
+	if (!mac)
+		return NULL;
+	/** Update both Synopsys ID and DEVID **/
+	priv->synopsys_id = DW25GMAC_CORE_4_00;
+	priv->synopsys_dev_id = DW25GMAC_ID;
+	priv->dma_conf.dma_tx_size = BRCM_XGMAC_DMA_TX_SIZE;
+	priv->dma_conf.dma_rx_size = BRCM_XGMAC_DMA_RX_SIZE;
+	priv->plat->rss_en = 1;
+	mac->pcsr = priv->ioaddr;
+	priv->dev->priv_flags |= IFF_UNICAST_FLT;
+	mac->multicast_filter_bins = priv->plat->multicast_filter_bins;
+	mac->unicast_filter_entries = priv->plat->unicast_filter_entries;
+	mac->mcast_bits_log2 = 0;
+
+	if (mac->multicast_filter_bins)
+		mac->mcast_bits_log2 = ilog2(mac->multicast_filter_bins);
+
+	mac->link.duplex = DUPLEX_FULL;
+	mac->link.caps = (MAC_ASYM_PAUSE | MAC_SYM_PAUSE | MAC_10000FD);
+	mac->link.xgmii.speed10000 = XGMAC_CONFIG_SS_10000;
+	mac->link.speed_mask = XGMAC_CONFIG_SS_MASK;
+
+	return mac;
+}
+
+static void dwxgmac_brcm_common_default_data(struct plat_stmmacenet_data *plat)
+{
+	int i;
+
+	plat->has_xgmac = 1;
+	plat->force_sf_dma_mode = 1;
+	plat->mac_port_sel_speed = SPEED_10000;
+	plat->clk_ptp_rate = DWMAC_125MHZ;
+	plat->clk_ref_rate = DWMAC_250MHZ;
+	plat->setup = dwxgmac_brcm_setup;
+	plat->tx_coe = 1;
+	plat->rx_coe = 1;
+	plat->max_speed = SPEED_10000;
+
+	/* 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 device's default */
+	plat->maxmtu = BRCM_MAX_MTU;
+
+	/* Set default number of RX and TX queues to use */
+	plat->tx_queues_to_use = BRCM_TX_Q_COUNT;
+	plat->rx_queues_to_use = BRCM_RX_Q_COUNT;
+
+	plat->tx_sched_algorithm = MTL_TX_ALGORITHM_SP;
+	for (i = 0; i < plat->tx_queues_to_use; i++) {
+		plat->tx_queues_cfg[i].use_prio = false;
+		plat->tx_queues_cfg[i].prio = 0;
+		plat->tx_queues_cfg[i].mode_to_use = MTL_QUEUE_AVB;
+		plat->dma_cfg->hdma_cfg->tvdma_tc[i] = i;
+		plat->dma_cfg->hdma_cfg->tpdma_tc[i] = i;
+	}
+
+	plat->rx_sched_algorithm = MTL_RX_ALGORITHM_SP;
+	for (i = 0; i < plat->rx_queues_to_use; i++) {
+		plat->rx_queues_cfg[i].use_prio = false;
+		plat->rx_queues_cfg[i].mode_to_use = MTL_QUEUE_AVB;
+		plat->rx_queues_cfg[i].pkt_route = 0x0;
+		plat->rx_queues_cfg[i].chan = i;
+		plat->dma_cfg->hdma_cfg->rvdma_tc[i] = i;
+		plat->dma_cfg->hdma_cfg->rpdma_tc[i] = i;
+	}
+}
+
+static int dwxgmac_brcm_default_data(struct pci_dev *pdev,
+				     struct plat_stmmacenet_data *plat)
+{
+	/* Set common default data first */
+	dwxgmac_brcm_common_default_data(plat);
+
+	plat->bus_id = 0;
+	plat->phy_addr = 0;
+	plat->phy_interface = PHY_INTERFACE_MODE_USXGMII;
+
+	plat->dma_cfg->pbl = 32;
+	plat->dma_cfg->pblx8 = 0;
+	plat->dma_cfg->aal = 0;
+	plat->dma_cfg->eame = 1;
+
+	plat->axi->axi_wr_osr_lmt = 31;
+	plat->axi->axi_rd_osr_lmt = 31;
+	plat->axi->axi_fb = 0;
+	plat->axi->axi_blen[0] = 4;
+	plat->axi->axi_blen[1] = 8;
+	plat->axi->axi_blen[2] = 16;
+	plat->axi->axi_blen[3] = 32;
+	plat->axi->axi_blen[4] = 64;
+	plat->axi->axi_blen[5] = 128;
+	plat->axi->axi_blen[6] = 256;
+
+	plat->msi_mac_vec = BRCM_XGMAC_MSI_MAC_VECTOR;
+	plat->msi_rx_base_vec = BRCM_XGMAC_MSI_RX_VECTOR_START;
+	plat->msi_tx_base_vec = BRCM_XGMAC_MSI_TX_VECTOR_START;
+
+	return 0;
+}
+
+static struct dwxgmac_brcm_pci_info dwxgmac_brcm_pci_info = {
+	.setup = dwxgmac_brcm_default_data,
+};
+
+static int brcm_config_multi_msi(struct pci_dev *pdev,
+				 struct plat_stmmacenet_data *plat,
+				 struct stmmac_resources *res)
+{
+	int ret;
+	int i;
+
+	if (plat->msi_rx_base_vec >= STMMAC_MSI_VEC_MAX ||
+	    plat->msi_tx_base_vec >= STMMAC_MSI_VEC_MAX) {
+		dev_err(&pdev->dev, "%s: Invalid RX & TX vector defined\n",
+			__func__);
+		return -EINVAL;
+	}
+
+	ret = pci_alloc_irq_vectors(pdev, 2, STMMAC_MSI_VEC_MAX,
+				    PCI_IRQ_MSI | PCI_IRQ_MSIX);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "%s: multi MSI enablement failed\n",
+			__func__);
+		return ret;
+	}
+
+	/* For RX MSI */
+	for (i = 0; i < plat->rx_queues_to_use; i++)
+		res->rx_irq[i] = pci_irq_vector(pdev,
+						plat->msi_rx_base_vec + i * 2);
+
+	/* For TX MSI */
+	for (i = 0; i < plat->tx_queues_to_use; i++)
+		res->tx_irq[i] = pci_irq_vector(pdev,
+						plat->msi_tx_base_vec + i * 2);
+
+	if (plat->msi_mac_vec < STMMAC_MSI_VEC_MAX)
+		res->irq = pci_irq_vector(pdev, plat->msi_mac_vec);
+
+	plat->flags |= STMMAC_FLAG_MULTI_MSI_EN;
+	plat->flags |= STMMAC_FLAG_TSO_EN;
+
+	return 0;
+}
+
+static int dwxgmac_brcm_pci_probe(struct pci_dev *pdev,
+				  const struct pci_device_id *id)
+{
+	struct dwxgmac_brcm_pci_info *info =
+		(struct dwxgmac_brcm_pci_info *)id->driver_data;
+	struct plat_stmmacenet_data *plat;
+	struct brcm_priv_data *brcm_priv;
+	struct stmmac_resources res;
+	struct device *dev;
+	int rx_offset;
+	int tx_offset;
+	int vector;
+	int ret;
+
+	dev = &pdev->dev;
+
+	brcm_priv = devm_kzalloc(&pdev->dev, sizeof(*brcm_priv), GFP_KERNEL);
+	if (!brcm_priv)
+		return -ENOMEM;
+
+	plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL);
+	if (!plat)
+		return -ENOMEM;
+
+	plat->dma_cfg = devm_kzalloc(&pdev->dev, sizeof(*plat->dma_cfg),
+				     GFP_KERNEL);
+	if (!plat->dma_cfg)
+		return -ENOMEM;
+
+	plat->dma_cfg->hdma_cfg = devm_kzalloc(&pdev->dev,
+					       sizeof(*plat->dma_cfg->hdma_cfg),
+					       GFP_KERNEL);
+	if (!plat->dma_cfg->hdma_cfg)
+		return -ENOMEM;
+
+	plat->axi = devm_kzalloc(&pdev->dev, sizeof(*plat->axi), GFP_KERNEL);
+	if (!plat->axi)
+		return -ENOMEM;
+
+	/* This device is directly attached to the switch chip internal to the
+	 * SoC using XGMII interface. Since no MDIO is present, register
+	 * fixed-link software_node to create phylink.
+	 */
+	plat->port_node = fwnode_create_software_node(NULL, NULL);
+	brcm_priv->fixed_link_node.name = fixed_link_node_name;
+	brcm_priv->fixed_link_node.properties = fixed_link_properties;
+	brcm_priv->fixed_link_node.parent = to_software_node(plat->port_node);
+	device_add_software_node(dev, &brcm_priv->fixed_link_node);
+
+	/* Disable D3COLD as our device does not support it */
+	pci_d3cold_disable(pdev);
+
+	/* Enable PCI device */
+	ret = pcim_enable_device(pdev);
+	if (ret) {
+		dev_err(&pdev->dev, "%s: ERROR: failed to enable device\n",
+			__func__);
+		return ret;
+	}
+
+	/* Get the base address of device */
+	ret = pcim_iomap_regions(pdev, BRCM_XGMAC_BAR0_MASK, pci_name(pdev));
+	if (ret)
+		goto err_disable_device;
+	pci_set_master(pdev);
+
+	memset(&res, 0, sizeof(res));
+	res.addr = pcim_iomap_table(pdev)[0];
+	/* MISC Regs */
+	brcm_priv->misc_regs = res.addr + BRCM_XGMAC_IOMEM_MISC_REG_OFFSET;
+	/* MBOX Regs */
+	brcm_priv->mbox_regs = res.addr + BRCM_XGMAC_IOMEM_MBOX_REG_OFFSET;
+	/* XGMAC config Regs */
+	res.addr += BRCM_XGMAC_IOMEM_CFG_REG_OFFSET;
+	brcm_priv->xgmac_regs = res.addr;
+
+	plat->bsp_priv = brcm_priv;
+
+	/* Initialize all MSI vectors to invalid so that it can be set
+	 * according to platform data settings below.
+	 * Note: MSI vector takes value from 0 up to 31 (STMMAC_MSI_VEC_MAX)
+	 */
+	plat->msi_mac_vec = STMMAC_MSI_VEC_MAX;
+	plat->msi_wol_vec = STMMAC_MSI_VEC_MAX;
+	plat->msi_lpi_vec = STMMAC_MSI_VEC_MAX;
+	plat->msi_sfty_ce_vec = STMMAC_MSI_VEC_MAX;
+	plat->msi_sfty_ue_vec = STMMAC_MSI_VEC_MAX;
+	plat->msi_rx_base_vec = STMMAC_MSI_VEC_MAX;
+	plat->msi_tx_base_vec = STMMAC_MSI_VEC_MAX;
+
+	ret = info->setup(pdev, plat);
+	if (ret)
+		goto err_disable_device;
+
+	pci_write_config_dword(pdev, XGMAC_PCIE_CFG_MSIX_ADDR_MATCH_LOW,
+			       XGMAC_PCIE_CFG_MSIX_ADDR_MATCH_LO_VALUE);
+	pci_write_config_dword(pdev, XGMAC_PCIE_CFG_MSIX_ADDR_MATCH_HIGH,
+			       XGMAC_PCIE_CFG_MSIX_ADDR_MATCH_HI_VALUE);
+
+	misc_iowrite(brcm_priv, XGMAC_PCIE_MISC_MSIX_ADDR_MATCH_LO_OFFSET,
+		     XGMAC_PCIE_MISC_MSIX_ADDR_MATCH_LO_VALUE);
+	misc_iowrite(brcm_priv, XGMAC_PCIE_MISC_MSIX_ADDR_MATCH_HI_OFFSET,
+		     XGMAC_PCIE_MISC_MSIX_ADDR_MATCH_HI_VALUE);
+
+	/* SBD Interrupt */
+	misc_iowrite(brcm_priv, XGMAC_PCIE_MISC_MSIX_VECTOR_MAP_SBD_ALL_OFFSET,
+		     XGMAC_PCIE_MISC_MSIX_VECTOR_MAP_SBD_ALL_VALUE);
+	/* EP_DOORBELL Interrupt */
+	misc_iowrite(brcm_priv,
+		     XGMAC_PCIE_MISC_MSIX_VECTOR_MAP_EP2HOST_DBELL_OFFSET,
+		     XGMAC_PCIE_MISC_MSIX_VECTOR_MAP_EP2HOST_DBELL_VALUE);
+	/* EP_H0 Interrupt */
+	misc_iowrite(brcm_priv,
+		     XGMAC_PCIE_MISC_MSIX_VECTOR_MAP_EP2HOST0_OFFSET,
+		     XGMAC_PCIE_MISC_MSIX_VECTOR_MAP_EP2HOST0_VALUE);
+	/* EP_H1 Interrupt */
+	misc_iowrite(brcm_priv,
+		     XGMAC_PCIE_MISC_MSIX_VECTOR_MAP_EP2HOST1_OFFSET,
+		     XGMAC_PCIE_MISC_MSIX_VECTOR_MAP_EP2HOST1_VALUE);
+
+	rx_offset = XGMAC_PCIE_MISC_MSIX_VECTOR_MAP_RX0_PF0_OFFSET;
+	tx_offset = XGMAC_PCIE_MISC_MSIX_VECTOR_MAP_TX0_PF0_OFFSET;
+	vector = BRCM_XGMAC_MSI_RX_VECTOR_START;
+	for (int i = 0; i < BRCM_MAX_DMA_CHANNEL_PAIRS; i++) {
+		/* RX Interrupt */
+		misc_iowrite(brcm_priv, rx_offset, vector++);
+		/* TX Interrupt */
+		misc_iowrite(brcm_priv, tx_offset, vector++);
+		rx_offset += 4;
+		tx_offset += 4;
+	}
+
+	/* Enable Switch Link */
+	misc_iowrite(brcm_priv, XGMAC_PCIE_MISC_MII_CTRL_OFFSET,
+		     XGMAC_PCIE_MISC_MII_CTRL_PAUSE_RX |
+		     XGMAC_PCIE_MISC_MII_CTRL_PAUSE_TX |
+		     XGMAC_PCIE_MISC_MII_CTRL_LINK_UP);
+	/* Enable MSI-X */
+	misc_iowrite(brcm_priv, XGMAC_PCIE_MISC_PCIESS_CTRL_OFFSET,
+		     XGMAC_PCIE_MISC_PCIESS_CTRL_EN_MSI_MSIX);
+
+	ret = brcm_config_multi_msi(pdev, plat, &res);
+	if (ret) {
+		dev_err(&pdev->dev,
+			"%s: ERROR: failed to enable IRQ\n", __func__);
+		goto err_disable_msi;
+	}
+
+	ret = stmmac_dvr_probe(&pdev->dev, plat, &res);
+	if (ret)
+		goto err_disable_msi;
+
+	return ret;
+
+err_disable_msi:
+	pci_free_irq_vectors(pdev);
+err_disable_device:
+	pci_disable_device(pdev);
+
+	return ret;
+}
+
+static void dwxgmac_brcm_software_node_remove(struct pci_dev *pdev)
+{
+	struct fwnode_handle *fwnode;
+	struct stmmac_priv *priv;
+	struct net_device *ndev;
+	struct device *dev;
+
+	dev = &pdev->dev;
+	ndev = dev_get_drvdata(dev);
+	priv = netdev_priv(ndev);
+	fwnode = priv->plat->port_node;
+
+	fwnode_remove_software_node(fwnode);
+	device_remove_software_node(dev);
+}
+
+static void dwxgmac_brcm_pci_remove(struct pci_dev *pdev)
+{
+	stmmac_dvr_remove(&pdev->dev);
+	pci_free_irq_vectors(pdev);
+	pcim_iounmap_regions(pdev, BRCM_XGMAC_BAR0_MASK);
+	pci_clear_master(pdev);
+	dwxgmac_brcm_software_node_remove(pdev);
+}
+
+static int __maybe_unused dwxgmac_brcm_pci_suspend(struct device *dev)
+{
+	struct pci_dev *pdev = to_pci_dev(dev);
+	int ret;
+
+	ret = stmmac_suspend(dev);
+	if (ret)
+		return ret;
+
+	ret = pci_save_state(pdev);
+	if (ret)
+		return ret;
+
+	pci_disable_device(pdev);
+	pci_wake_from_d3(pdev, true);
+
+	return 0;
+}
+
+static int __maybe_unused dwxgmac_brcm_pci_resume(struct device *dev)
+{
+	struct pci_dev *pdev = to_pci_dev(dev);
+	int ret;
+
+	pci_restore_state(pdev);
+	pci_set_power_state(pdev, PCI_D0);
+
+	ret = pci_enable_device(pdev);
+	if (ret)
+		return ret;
+
+	pci_set_master(pdev);
+
+	return stmmac_resume(dev);
+}
+
+static SIMPLE_DEV_PM_OPS(dwxgmac_brcm_pm_ops,
+			 dwxgmac_brcm_pci_suspend,
+			 dwxgmac_brcm_pci_resume);
+
+static const struct pci_device_id dwxgmac_brcm_id_table[] = {
+	{ PCI_DEVICE_DATA(BROADCOM, BCM8958X, &dwxgmac_brcm_pci_info) },
+	{}
+};
+
+MODULE_DEVICE_TABLE(pci, dwxgmac_brcm_id_table);
+
+static struct pci_driver dwxgmac_brcm_pci_driver = {
+	.name = "brcm-bcm8958x",
+	.id_table = dwxgmac_brcm_id_table,
+	.probe	= dwxgmac_brcm_pci_probe,
+	.remove = dwxgmac_brcm_pci_remove,
+	.driver = {
+		.pm = &dwxgmac_brcm_pm_ops,
+	},
+};
+
+module_pci_driver(dwxgmac_brcm_pci_driver);
+
+MODULE_DESCRIPTION("Broadcom 10G Automotive Ethernet PCIe driver");
+MODULE_LICENSE("GPL");
Signature · 1 line
2.34.1
maintainer
#14 lore raw

drivers/net/ethernet/stmicro/stmmac/dwmac-brcm.c line 501

Quoted 8 lines · On Wed, 14 Aug 2024 15:18:17 -0700 [email protected] wrote:
drivers/net/ethernet/stmicro/stmmac/dwmac-brcm.c new file +8 -0
+	pci_restore_state(pdev);
+	pci_set_power_state(pdev, PCI_D0);
+
+	ret = pci_enable_device(pdev);
+	if (ret)
+		return ret;
+
+	pci_set_master(pdev);

pci_restore_state() doesn't restore master and enable?

#15 lore raw
Quoted 12 lines · Jakub Kicinski

drivers/net/ethernet/stmicro/stmmac/dwmac-brcm.c line 501

Quoted 8 lines · On Wed, 14 Aug 2024 15:18:17 -0700 [email protected] wrote:
drivers/net/ethernet/stmicro/stmmac/dwmac-brcm.c new file +8 -0
+     pci_restore_state(pdev);
+     pci_set_power_state(pdev, PCI_D0);
+
+     ret = pci_enable_device(pdev);
+     if (ret)
+             return ret;
+
+     pci_set_master(pdev);

pci_restore_state() doesn't restore master and enable?

Hi Jakub,
Thanks for the feedback. You are correct, The pci_enable_device() and pci_set_master() calls are not necessary.
We did more testing without these calls.
We will remove the calls.
Thanks

#16 lore raw

PATCH v4 4/5 net: stmmac: Add PCI driver support for BCM8958x

In reply to [email protected]

Hi,

Quoted 255 lines

This SoC device has PCIe ethernet MAC directly attached to an integrated ethernet switch using XGMII interface. Since device tree support is not available on this platform, a software node is created to enable fixed-link support using phylink driver.

---
   .../net/ethernet/stmicro/stmmac/dwmac-brcm.c  | 530 ++++++++++++++++++
   1 file changed, 530 insertions(+)

create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-brcm.c

drivers/net/ethernet/stmicro/stmmac/dwmac-brcm.c new file +237 -0
new file mode 100644
index 000000000000..4384f45e86b1
@@ -0,0 +1,530 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/* Copyright (c) 2024 Broadcom Corporation
+ *
+ * PCI driver for ethernet interface of BCM8958X automotive switch chip.
+ *
+ * High level block diagram of the device.
+ *              +=================================+
+ *              |       Host CPU/Linux            |
+ *              +=================================+
+ *                         || PCIe
+ *                         ||
+ *         +==========================================+
+ *         |           +--------------+               |
+ *         |           | PCIE Endpoint|               |
+ *         |           | Ethernet     |               |
+ *         |           | Controller   |               |
+ *         |           |   DMA        |               |
+ *         |           +--------------+               |
+ *         |           |   MAC        |   BCM8958X    |
+ *         |           +--------------+   SoC         |
+ *         |               || XGMII                   |
+ *         |               ||                         |
+ *         |           +--------------+               |
+ *         |           | Ethernet     |               |
+ *         |           | switch       |               |
+ *         |           +--------------+               |
+ *         |             || || || ||                  |
+ *         +==========================================+
+ *                       || || || || More external interfaces
+ *
+ * This SoC device has PCIe ethernet MAC directly attached to an integrated
+ * ethernet switch using XGMII interface. Since devicetree support is not
+ * available on this platform, a software node is created to enable
+ * fixed-link support using phylink driver.
+ */
+
+#include <linux/clk-provider.h>
+#include <linux/dmi.h>
+#include <linux/pci.h>
+#include <linux/phy.h>
+
+#include "stmmac.h"
+#include "dwxgmac2.h"
+
+#define PCI_DEVICE_ID_BROADCOM_BCM8958X		0xa00d
+#define BRCM_MAX_MTU				1500
+#define READ_POLL_DELAY_US			100
+#define READ_POLL_TIMEOUT_US			10000
+#define DWMAC_125MHZ				125000000
+#define DWMAC_250MHZ				250000000
+#define BRCM_XGMAC_NUM_VLAN_FILTERS		32
+
+/* TX and RX Queue counts */
+#define BRCM_TX_Q_COUNT				4
+#define BRCM_RX_Q_COUNT				4
+
+#define BRCM_XGMAC_DMA_TX_SIZE			1024
+#define BRCM_XGMAC_DMA_RX_SIZE			1024
+#define BRCM_XGMAC_BAR0_MASK			BIT(0)
+
+#define BRCM_XGMAC_IOMEM_MISC_REG_OFFSET	0x0
+#define BRCM_XGMAC_IOMEM_MBOX_REG_OFFSET	0x1000
+#define BRCM_XGMAC_IOMEM_CFG_REG_OFFSET		0x3000
+
+#define XGMAC_MMC_CTRL_RCHM_DISABLE		BIT(31)
+#define XGMAC_PCIE_CFG_MSIX_ADDR_MATCH_LOW	0x940
+#define XGMAC_PCIE_CFG_MSIX_ADDR_MATCH_LO_VALUE	0x00000001
+#define XGMAC_PCIE_CFG_MSIX_ADDR_MATCH_HIGH	0x944
+#define XGMAC_PCIE_CFG_MSIX_ADDR_MATCH_HI_VALUE	0x88000000
+
+#define XGMAC_PCIE_MISC_MII_CTRL_OFFSET			0x4
+#define XGMAC_PCIE_MISC_MII_CTRL_PAUSE_RX		BIT(0)
+#define XGMAC_PCIE_MISC_MII_CTRL_PAUSE_TX		BIT(1)
+#define XGMAC_PCIE_MISC_MII_CTRL_LINK_UP		BIT(2)
+#define XGMAC_PCIE_MISC_PCIESS_CTRL_OFFSET		0x8
+#define XGMAC_PCIE_MISC_PCIESS_CTRL_EN_MSI_MSIX		BIT(9)
+#define XGMAC_PCIE_MISC_MSIX_ADDR_MATCH_LO_OFFSET	0x90
+#define XGMAC_PCIE_MISC_MSIX_ADDR_MATCH_LO_VALUE	0x00000001
+#define XGMAC_PCIE_MISC_MSIX_ADDR_MATCH_HI_OFFSET	0x94
+#define XGMAC_PCIE_MISC_MSIX_ADDR_MATCH_HI_VALUE	0x88000000
+#define XGMAC_PCIE_MISC_MSIX_VECTOR_MAP_EP2HOST0_OFFSET	0x700
+#define XGMAC_PCIE_MISC_MSIX_VECTOR_MAP_EP2HOST0_VALUE	1
+#define XGMAC_PCIE_MISC_MSIX_VECTOR_MAP_EP2HOST1_OFFSET	0x704
+#define XGMAC_PCIE_MISC_MSIX_VECTOR_MAP_EP2HOST1_VALUE	1
+#define XGMAC_PCIE_MISC_MSIX_VECTOR_MAP_EP2HOST_DBELL_OFFSET	0x728
+#define XGMAC_PCIE_MISC_MSIX_VECTOR_MAP_EP2HOST_DBELL_VALUE	1
+#define XGMAC_PCIE_MISC_MSIX_VECTOR_MAP_SBD_ALL_OFFSET	0x740
+#define XGMAC_PCIE_MISC_MSIX_VECTOR_MAP_SBD_ALL_VALUE	0
+
+#define XGMAC_PCIE_MISC_FUNC_RESOURCES_PF0_OFFSET	0x804
+
+/* MSIX Vector map register starting offsets */
+#define XGMAC_PCIE_MISC_MSIX_VECTOR_MAP_RX0_PF0_OFFSET	0x840
+#define XGMAC_PCIE_MISC_MSIX_VECTOR_MAP_TX0_PF0_OFFSET	0x890
+#define BRCM_MAX_DMA_CHANNEL_PAIRS		4
+
+#define BRCM_XGMAC_MSI_MAC_VECTOR		0
+#define BRCM_XGMAC_MSI_RX_VECTOR_START		9
+#define BRCM_XGMAC_MSI_TX_VECTOR_START		10
+
+static char *fixed_link_node_name = "fixed-link";
+
+static const struct property_entry fixed_link_properties[] = {
+	PROPERTY_ENTRY_U32("speed", 10000),
+	PROPERTY_ENTRY_BOOL("full-duplex"),
+	PROPERTY_ENTRY_BOOL("pause"),
+	{ }
+};
+
+struct brcm_priv_data {
+	void __iomem *mbox_regs;    /* MBOX  Registers*/
+	void __iomem *misc_regs;    /* MISC  Registers*/
+	void __iomem *xgmac_regs;   /* XGMAC Registers*/
+	struct software_node fixed_link_node;
+};
+
+struct dwxgmac_brcm_pci_info {
+	int (*setup)(struct pci_dev *pdev, struct plat_stmmacenet_data *plat);
+};
+
+static void misc_iowrite(struct brcm_priv_data *brcm_priv,
+			 u32 reg, u32 val)
+{
+	iowrite32(val, brcm_priv->misc_regs + reg);
+}
+
+static struct mac_device_info *dwxgmac_brcm_setup(void *ppriv)
+{
+	struct stmmac_priv *priv = ppriv;
+	struct mac_device_info *mac;
+
+	mac = devm_kzalloc(priv->device, sizeof(*mac), GFP_KERNEL);
+	if (!mac)
+		return NULL;
+	/** Update both Synopsys ID and DEVID **/
+	priv->synopsys_id = DW25GMAC_CORE_4_00;
+	priv->synopsys_dev_id = DW25GMAC_ID;
+	priv->dma_conf.dma_tx_size = BRCM_XGMAC_DMA_TX_SIZE;
+	priv->dma_conf.dma_rx_size = BRCM_XGMAC_DMA_RX_SIZE;
+	priv->plat->rss_en = 1;
+	mac->pcsr = priv->ioaddr;
+	priv->dev->priv_flags |= IFF_UNICAST_FLT;
+	mac->multicast_filter_bins = priv->plat->multicast_filter_bins;
+	mac->unicast_filter_entries = priv->plat->unicast_filter_entries;
+	mac->mcast_bits_log2 = 0;
+
+	if (mac->multicast_filter_bins)
+		mac->mcast_bits_log2 = ilog2(mac->multicast_filter_bins);
+
+	mac->link.duplex = DUPLEX_FULL;
+	mac->link.caps = (MAC_ASYM_PAUSE | MAC_SYM_PAUSE | MAC_10000FD);
+	mac->link.xgmii.speed10000 = XGMAC_CONFIG_SS_10000;
+	mac->link.speed_mask = XGMAC_CONFIG_SS_MASK;
+
+	return mac;
+}
+
+static void dwxgmac_brcm_common_default_data(struct plat_stmmacenet_data *plat)
+{
+	int i;
+
+	plat->has_xgmac = 1;
+	plat->force_sf_dma_mode = 1;
+	plat->mac_port_sel_speed = SPEED_10000;
+	plat->clk_ptp_rate = DWMAC_125MHZ;
+	plat->clk_ref_rate = DWMAC_250MHZ;
+	plat->setup = dwxgmac_brcm_setup;
+	plat->tx_coe = 1;
+	plat->rx_coe = 1;
+	plat->max_speed = SPEED_10000;
+
+	/* 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 device's default */
+	plat->maxmtu = BRCM_MAX_MTU;
+
+	/* Set default number of RX and TX queues to use */
+	plat->tx_queues_to_use = BRCM_TX_Q_COUNT;
+	plat->rx_queues_to_use = BRCM_RX_Q_COUNT;
+
+	plat->tx_sched_algorithm = MTL_TX_ALGORITHM_SP;
+	for (i = 0; i < plat->tx_queues_to_use; i++) {
+		plat->tx_queues_cfg[i].use_prio = false;
+		plat->tx_queues_cfg[i].prio = 0;
+		plat->tx_queues_cfg[i].mode_to_use = MTL_QUEUE_AVB;
+		plat->dma_cfg->hdma_cfg->tvdma_tc[i] = i;
+		plat->dma_cfg->hdma_cfg->tpdma_tc[i] = i;
+	}
+
+	plat->rx_sched_algorithm = MTL_RX_ALGORITHM_SP;
+	for (i = 0; i < plat->rx_queues_to_use; i++) {
+		plat->rx_queues_cfg[i].use_prio = false;
+		plat->rx_queues_cfg[i].mode_to_use = MTL_QUEUE_AVB;
+		plat->rx_queues_cfg[i].pkt_route = 0x0;
+		plat->rx_queues_cfg[i].chan = i;
+		plat->dma_cfg->hdma_cfg->rvdma_tc[i] = i;
+		plat->dma_cfg->hdma_cfg->rpdma_tc[i] = i;
+	}
+}
+
+static int dwxgmac_brcm_default_data(struct pci_dev *pdev,
+				     struct plat_stmmacenet_data *plat)
+{
+	/* Set common default data first */
+	dwxgmac_brcm_common_default_data(plat);
+
+	plat->bus_id = 0;
+	plat->phy_addr = 0;
+	plat->phy_interface = PHY_INTERFACE_MODE_USXGMII;
+
+	plat->dma_cfg->pbl = 32;
+	plat->dma_cfg->pblx8 = 0;
+	plat->dma_cfg->aal = 0;
+	plat->dma_cfg->eame = 1;
+
+	plat->axi->axi_wr_osr_lmt = 31;
+	plat->axi->axi_rd_osr_lmt = 31;
+	plat->axi->axi_fb = 0;
+	plat->axi->axi_blen[0] = 4;
+	plat->axi->axi_blen[1] = 8;
+	plat->axi->axi_blen[2] = 16;
+	plat->axi->axi_blen[3] = 32;
+	plat->axi->axi_blen[4] = 64;
+	plat->axi->axi_blen[5] = 128;
+	plat->axi->axi_blen[6] = 256;
+
+	plat->msi_mac_vec = BRCM_XGMAC_MSI_MAC_VECTOR;
+	plat->msi_rx_base_vec = BRCM_XGMAC_MSI_RX_VECTOR_START;
+	plat->msi_tx_base_vec = BRCM_XGMAC_MSI_TX_VECTOR_START;
+
+	return 0;
+}
+

drivers/net/ethernet/stmicro/stmmac/dwmac-brcm.c line 247

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-brcm.c new file +10 -0
+static struct dwxgmac_brcm_pci_info dwxgmac_brcm_pci_info = {
+	.setup = dwxgmac_brcm_default_data,
+};
+
+static int brcm_config_multi_msi(struct pci_dev *pdev,
+				 struct plat_stmmacenet_data *plat,
+				 struct stmmac_resources *res)
+{
+	int ret;
+	int i;

nit: This can be merged into single line.

Quoted 183 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-brcm.c new file +183 -0
+
+	if (plat->msi_rx_base_vec >= STMMAC_MSI_VEC_MAX ||
+	    plat->msi_tx_base_vec >= STMMAC_MSI_VEC_MAX) {
+		dev_err(&pdev->dev, "%s: Invalid RX & TX vector defined\n",
+			__func__);
+		return -EINVAL;
+	}
+
+	ret = pci_alloc_irq_vectors(pdev, 2, STMMAC_MSI_VEC_MAX,
+				    PCI_IRQ_MSI | PCI_IRQ_MSIX);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "%s: multi MSI enablement failed\n",
+			__func__);
+		return ret;
+	}
+
+	/* For RX MSI */
+	for (i = 0; i < plat->rx_queues_to_use; i++)
+		res->rx_irq[i] = pci_irq_vector(pdev,
+						plat->msi_rx_base_vec + i * 2);
+
+	/* For TX MSI */
+	for (i = 0; i < plat->tx_queues_to_use; i++)
+		res->tx_irq[i] = pci_irq_vector(pdev,
+						plat->msi_tx_base_vec + i * 2);
+
+	if (plat->msi_mac_vec < STMMAC_MSI_VEC_MAX)
+		res->irq = pci_irq_vector(pdev, plat->msi_mac_vec);
+
+	plat->flags |= STMMAC_FLAG_MULTI_MSI_EN;
+	plat->flags |= STMMAC_FLAG_TSO_EN;
+
+	return 0;
+}
+
+static int dwxgmac_brcm_pci_probe(struct pci_dev *pdev,
+				  const struct pci_device_id *id)
+{
+	struct dwxgmac_brcm_pci_info *info =
+		(struct dwxgmac_brcm_pci_info *)id->driver_data;
+	struct plat_stmmacenet_data *plat;
+	struct brcm_priv_data *brcm_priv;
+	struct stmmac_resources res;
+	struct device *dev;
+	int rx_offset;
+	int tx_offset;
+	int vector;
+	int ret;
+
+	dev = &pdev->dev;
+
+	brcm_priv = devm_kzalloc(&pdev->dev, sizeof(*brcm_priv), GFP_KERNEL);
+	if (!brcm_priv)
+		return -ENOMEM;
+
+	plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL);
+	if (!plat)
+		return -ENOMEM;
+
+	plat->dma_cfg = devm_kzalloc(&pdev->dev, sizeof(*plat->dma_cfg),
+				     GFP_KERNEL);
+	if (!plat->dma_cfg)
+		return -ENOMEM;
+
+	plat->dma_cfg->hdma_cfg = devm_kzalloc(&pdev->dev,
+					       sizeof(*plat->dma_cfg->hdma_cfg),
+					       GFP_KERNEL);
+	if (!plat->dma_cfg->hdma_cfg)
+		return -ENOMEM;
+
+	plat->axi = devm_kzalloc(&pdev->dev, sizeof(*plat->axi), GFP_KERNEL);
+	if (!plat->axi)
+		return -ENOMEM;
+
+	/* This device is directly attached to the switch chip internal to the
+	 * SoC using XGMII interface. Since no MDIO is present, register
+	 * fixed-link software_node to create phylink.
+	 */
+	plat->port_node = fwnode_create_software_node(NULL, NULL);
+	brcm_priv->fixed_link_node.name = fixed_link_node_name;
+	brcm_priv->fixed_link_node.properties = fixed_link_properties;
+	brcm_priv->fixed_link_node.parent = to_software_node(plat->port_node);
+	device_add_software_node(dev, &brcm_priv->fixed_link_node);
+
+	/* Disable D3COLD as our device does not support it */
+	pci_d3cold_disable(pdev);
+
+	/* Enable PCI device */
+	ret = pcim_enable_device(pdev);
+	if (ret) {
+		dev_err(&pdev->dev, "%s: ERROR: failed to enable device\n",
+			__func__);
+		return ret;
+	}
+
+	/* Get the base address of device */
+	ret = pcim_iomap_regions(pdev, BRCM_XGMAC_BAR0_MASK, pci_name(pdev));
+	if (ret)
+		goto err_disable_device;
+	pci_set_master(pdev);
+
+	memset(&res, 0, sizeof(res));
+	res.addr = pcim_iomap_table(pdev)[0];
+	/* MISC Regs */
+	brcm_priv->misc_regs = res.addr + BRCM_XGMAC_IOMEM_MISC_REG_OFFSET;
+	/* MBOX Regs */
+	brcm_priv->mbox_regs = res.addr + BRCM_XGMAC_IOMEM_MBOX_REG_OFFSET;
+	/* XGMAC config Regs */
+	res.addr += BRCM_XGMAC_IOMEM_CFG_REG_OFFSET;
+	brcm_priv->xgmac_regs = res.addr;
+
+	plat->bsp_priv = brcm_priv;
+
+	/* Initialize all MSI vectors to invalid so that it can be set
+	 * according to platform data settings below.
+	 * Note: MSI vector takes value from 0 up to 31 (STMMAC_MSI_VEC_MAX)
+	 */
+	plat->msi_mac_vec = STMMAC_MSI_VEC_MAX;
+	plat->msi_wol_vec = STMMAC_MSI_VEC_MAX;
+	plat->msi_lpi_vec = STMMAC_MSI_VEC_MAX;
+	plat->msi_sfty_ce_vec = STMMAC_MSI_VEC_MAX;
+	plat->msi_sfty_ue_vec = STMMAC_MSI_VEC_MAX;
+	plat->msi_rx_base_vec = STMMAC_MSI_VEC_MAX;
+	plat->msi_tx_base_vec = STMMAC_MSI_VEC_MAX;
+
+	ret = info->setup(pdev, plat);
+	if (ret)
+		goto err_disable_device;
+
+	pci_write_config_dword(pdev, XGMAC_PCIE_CFG_MSIX_ADDR_MATCH_LOW,
+			       XGMAC_PCIE_CFG_MSIX_ADDR_MATCH_LO_VALUE);
+	pci_write_config_dword(pdev, XGMAC_PCIE_CFG_MSIX_ADDR_MATCH_HIGH,
+			       XGMAC_PCIE_CFG_MSIX_ADDR_MATCH_HI_VALUE);
+
+	misc_iowrite(brcm_priv, XGMAC_PCIE_MISC_MSIX_ADDR_MATCH_LO_OFFSET,
+		     XGMAC_PCIE_MISC_MSIX_ADDR_MATCH_LO_VALUE);
+	misc_iowrite(brcm_priv, XGMAC_PCIE_MISC_MSIX_ADDR_MATCH_HI_OFFSET,
+		     XGMAC_PCIE_MISC_MSIX_ADDR_MATCH_HI_VALUE);
+
+	/* SBD Interrupt */
+	misc_iowrite(brcm_priv, XGMAC_PCIE_MISC_MSIX_VECTOR_MAP_SBD_ALL_OFFSET,
+		     XGMAC_PCIE_MISC_MSIX_VECTOR_MAP_SBD_ALL_VALUE);
+	/* EP_DOORBELL Interrupt */
+	misc_iowrite(brcm_priv,
+		     XGMAC_PCIE_MISC_MSIX_VECTOR_MAP_EP2HOST_DBELL_OFFSET,
+		     XGMAC_PCIE_MISC_MSIX_VECTOR_MAP_EP2HOST_DBELL_VALUE);
+	/* EP_H0 Interrupt */
+	misc_iowrite(brcm_priv,
+		     XGMAC_PCIE_MISC_MSIX_VECTOR_MAP_EP2HOST0_OFFSET,
+		     XGMAC_PCIE_MISC_MSIX_VECTOR_MAP_EP2HOST0_VALUE);
+	/* EP_H1 Interrupt */
+	misc_iowrite(brcm_priv,
+		     XGMAC_PCIE_MISC_MSIX_VECTOR_MAP_EP2HOST1_OFFSET,
+		     XGMAC_PCIE_MISC_MSIX_VECTOR_MAP_EP2HOST1_VALUE);
+
+	rx_offset = XGMAC_PCIE_MISC_MSIX_VECTOR_MAP_RX0_PF0_OFFSET;
+	tx_offset = XGMAC_PCIE_MISC_MSIX_VECTOR_MAP_TX0_PF0_OFFSET;
+	vector = BRCM_XGMAC_MSI_RX_VECTOR_START;
+	for (int i = 0; i < BRCM_MAX_DMA_CHANNEL_PAIRS; i++) {
+		/* RX Interrupt */
+		misc_iowrite(brcm_priv, rx_offset, vector++);
+		/* TX Interrupt */
+		misc_iowrite(brcm_priv, tx_offset, vector++);
+		rx_offset += 4;
+		tx_offset += 4;
+	}
+
+	/* Enable Switch Link */
+	misc_iowrite(brcm_priv, XGMAC_PCIE_MISC_MII_CTRL_OFFSET,
+		     XGMAC_PCIE_MISC_MII_CTRL_PAUSE_RX |
+		     XGMAC_PCIE_MISC_MII_CTRL_PAUSE_TX |
+		     XGMAC_PCIE_MISC_MII_CTRL_LINK_UP);
+	/* Enable MSI-X */
+	misc_iowrite(brcm_priv, XGMAC_PCIE_MISC_PCIESS_CTRL_OFFSET,
+		     XGMAC_PCIE_MISC_PCIESS_CTRL_EN_MSI_MSIX);
+
+	ret = brcm_config_multi_msi(pdev, plat, &res);
+	if (ret) {
+		dev_err(&pdev->dev,
+			"%s: ERROR: failed to enable IRQ\n", __func__);
+		goto err_disable_msi;
+	}
+

drivers/net/ethernet/stmicro/stmmac/dwmac-brcm.c line 440

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-brcm.c new file +10 -0
+	ret = stmmac_dvr_probe(&pdev->dev, plat, &res);
+	if (ret)
+		goto err_disable_msi;
+
+	return ret;
+
+err_disable_msi:
+	pci_free_irq_vectors(pdev);
+err_disable_device:
+	pci_disable_device(pdev);

Shouldn't pcim_iounmap_region be called here to unmap and release PCI BARs?

Quoted 94 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-brcm.c new file +90 -0
+
+	return ret;
+}
+
+static void dwxgmac_brcm_software_node_remove(struct pci_dev *pdev)
+{
+	struct fwnode_handle *fwnode;
+	struct stmmac_priv *priv;
+	struct net_device *ndev;
+	struct device *dev;
+
+	dev = &pdev->dev;
+	ndev = dev_get_drvdata(dev);
+	priv = netdev_priv(ndev);
+	fwnode = priv->plat->port_node;
+
+	fwnode_remove_software_node(fwnode);
+	device_remove_software_node(dev);
+}
+
+static void dwxgmac_brcm_pci_remove(struct pci_dev *pdev)
+{
+	stmmac_dvr_remove(&pdev->dev);
+	pci_free_irq_vectors(pdev);
+	pcim_iounmap_regions(pdev, BRCM_XGMAC_BAR0_MASK);
+	pci_clear_master(pdev);
+	dwxgmac_brcm_software_node_remove(pdev);
+}
+
+static int __maybe_unused dwxgmac_brcm_pci_suspend(struct device *dev)
+{
+	struct pci_dev *pdev = to_pci_dev(dev);
+	int ret;
+
+	ret = stmmac_suspend(dev);
+	if (ret)
+		return ret;
+
+	ret = pci_save_state(pdev);
+	if (ret)
+		return ret;
+
+	pci_disable_device(pdev);
+	pci_wake_from_d3(pdev, true);
+
+	return 0;
+}
+
+static int __maybe_unused dwxgmac_brcm_pci_resume(struct device *dev)
+{
+	struct pci_dev *pdev = to_pci_dev(dev);
+	int ret;
+
+	pci_restore_state(pdev);
+	pci_set_power_state(pdev, PCI_D0);
+
+	ret = pci_enable_device(pdev);
+	if (ret)
+		return ret;
+
+	pci_set_master(pdev);
+
+	return stmmac_resume(dev);
+}
+
+static SIMPLE_DEV_PM_OPS(dwxgmac_brcm_pm_ops,
+			 dwxgmac_brcm_pci_suspend,
+			 dwxgmac_brcm_pci_resume);
+
+static const struct pci_device_id dwxgmac_brcm_id_table[] = {
+	{ PCI_DEVICE_DATA(BROADCOM, BCM8958X, &dwxgmac_brcm_pci_info) },
+	{}
+};
+
+MODULE_DEVICE_TABLE(pci, dwxgmac_brcm_id_table);
+
+static struct pci_driver dwxgmac_brcm_pci_driver = {
+	.name = "brcm-bcm8958x",
+	.id_table = dwxgmac_brcm_id_table,
+	.probe	= dwxgmac_brcm_pci_probe,
+	.remove = dwxgmac_brcm_pci_remove,
+	.driver = {
+		.pm = &dwxgmac_brcm_pm_ops,
+	},
+};
+
+module_pci_driver(dwxgmac_brcm_pci_driver);
+
+MODULE_DESCRIPTION("Broadcom 10G Automotive Ethernet PCIe driver");
+MODULE_LICENSE("GPL");
Signature · 1 line
2.34.1
#17 lore raw

Hi Amit,
Thanks for the review comments.

Quoted 8 lines · Amit Singh Tomar

Hi,

drivers/net/ethernet/stmicro/stmmac/dwmac-brcm.c line 247

Quoted 3 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-brcm.c new file +3 -0
+{
+     int ret;
+     int i;

nit: This can be merged into single line.

Thanks, I will fix it.

Quoted 5 lines

drivers/net/ethernet/stmicro/stmmac/dwmac-brcm.c line 440

Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-brcm.c new file +4 -0
+err_disable_msi:
+     pci_free_irq_vectors(pdev);
+err_disable_device:
+     pci_disable_device(pdev);

Shouldn't pcim_iounmap_region be called here to unmap and release PCI BARs?

My understanding is that for managed API calls pcim_iomap_regions(), we don't need to do explicit clean up.
Please let me know if that's not the case.
Just realized that pci_disable_device() in cleanup is not required since the driver is using pcim_enable_device().

#18 lore raw

Hi,

Quoted 22 lines

Hi Amit,
Thanks for the review comments.

Quoted 8 lines · Amit Singh Tomar

Hi,

drivers/net/ethernet/stmicro/stmmac/dwmac-brcm.c line 247

Quoted 3 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-brcm.c new file +3 -0
+{
+     int ret;
+     int i;

nit: This can be merged into single line.

Thanks, I will fix it.

Quoted 5 lines

drivers/net/ethernet/stmicro/stmmac/dwmac-brcm.c line 440

Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-brcm.c new file +4 -0
+err_disable_msi:
+     pci_free_irq_vectors(pdev);
+err_disable_device:
+     pci_disable_device(pdev);

Shouldn't pcim_iounmap_region be called here to unmap and release PCI BARs?

Quoted 6 lines

My understanding is that for managed API calls pcim_iomap_regions(), we don't need to do explicit clean up.
Please let me know if that's not the case.
Just realized that pci_disable_device() in cleanup is not required since the driver is using pcim_enable_device().

You're right, I just looked into the pcim_iomap_regions(), and it seems to handle the cleanup process itself.
https://elixir.bootlin.com/linux/v6.10.6/source/drivers/pci/devres.c#L387

Thanks,
-Amit

#19 lore raw

PATCH v4 5/5 net: stmmac: Add BCM8958x driver to build system

In reply to [email protected]

From: Jitendra Vegiraju <[email protected]>

Add PCI driver for BCM8958x to the linux build system and update MAINTAINERS file.

---
 MAINTAINERS                                  |  8 ++++++++
 drivers/net/ethernet/stmicro/stmmac/Kconfig  | 11 +++++++++++
 drivers/net/ethernet/stmicro/stmmac/Makefile |  1 +
 3 files changed, 20 insertions(+)
MAINTAINERS +8 -0
index 7b291c3a9aa4..174e77446f73 100644
@@ -4350,6 +4350,14 @@ N:	brcmstb
 N:	bcm7038
 N:	bcm7120
 
+BROADCOM BCM8958X ETHERNET DRIVER
+M:	Jitendra Vegiraju <[email protected]>
+R:	Broadcom internal kernel review list <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/net/ethernet/stmicro/stmmac/dwmac-brcm.c
+F:	drivers/net/ethernet/stmicro/stmmac/dwxgmac4.*
+
 BROADCOM BCMBCA ARM ARCHITECTURE
 M:	William Zhang <[email protected]>
 M:	Anand Gore <[email protected]>
drivers/net/ethernet/stmicro/stmmac/Kconfig +11 -0
index 05cc07b8f48c..47c9db123b03 100644
@@ -298,6 +298,17 @@ config DWMAC_LOONGSON
 	  This selects the LOONGSON PCI bus support for the stmmac driver,
 	  Support for ethernet controller on Loongson-2K1000 SoC and LS7A1000 bridge.
 
+config DWMAC_BRCM
+	tristate "Broadcom XGMAC support"
+	depends on STMMAC_ETH && PCI
+	depends on COMMON_CLK
+	help
+	  Support for ethernet controllers on Broadcom BCM8958x SoCs.
+
+	  This selects Broadcom XGMAC specific PCI bus support for the
+	  stmmac driver. This driver provides the glue layer on top of the
+	  stmmac driver required for the Broadcom BCM8958x SoC devices.
+
 config STMMAC_PCI
 	tristate "STMMAC PCI bus support"
 	depends on STMMAC_ETH && PCI
drivers/net/ethernet/stmicro/stmmac/Makefile +1 -0
index 967e8a9aa432..517981b9e93a 100644
@@ -41,4 +41,5 @@ dwmac-altr-socfpga-objs := dwmac-socfpga.o
 obj-$(CONFIG_STMMAC_PCI)	+= stmmac-pci.o
 obj-$(CONFIG_DWMAC_INTEL)	+= dwmac-intel.o
 obj-$(CONFIG_DWMAC_LOONGSON)	+= dwmac-loongson.o
+obj-$(CONFIG_DWMAC_BRCM)	+= dwmac-brcm.o
 stmmac-pci-objs:= stmmac_pci.o
Signature · 1 line
2.34.1
#20 lore raw
In reply to [email protected]

Hi Jitendra

Quoted 59 lines · On Wed, Aug 14, 2024 at 03:18:13PM -0700, [email protected] wrote:

From: Jitendra Vegiraju <[email protected]>

This patchset adds basic PCI ethernet device driver support for Broadcom BCM8958x Automotive Ethernet switch SoC devices.

This SoC device has PCIe ethernet MAC attached to an integrated ethernet switch using XGMII interface. The PCIe ethernet controller is presented to the Linux host as PCI network device.

The following block diagram gives an overview of the application.

             +=================================+
             |       Host CPU/Linux            |
             +=================================+
                        || PCIe
                        ||
        +==========================================+
        |           +--------------+               |
        |           | PCIE Endpoint|               |
        |           | Ethernet     |               |
        |           | Controller   |               |
        |           |   DMA        |               |
        |           +--------------+               |
        |           |   MAC        |   BCM8958X    |
        |           +--------------+   SoC         |
        |               || XGMII                   |
        |               ||                         |
        |           +--------------+               |
        |           | Ethernet     |               |
        |           | switch       |               |
        |           +--------------+               |
        |             || || || ||                  |
        +==========================================+
                      || || || || More external interfaces

The MAC block on BCM8958x is based on Synopsis XGMAC 4.00a core. This MAC IP introduces new DMA architecture called Hyper-DMA for virtualization scalability.

Driver functionality specific to new MAC (DW25GMAC) is implemented in new file dw25gmac.c.

Management of integrated ethernet switch on this SoC is not handled by the PCIe interface.
This SoC device has PCIe ethernet MAC directly attached to an integrated ethernet switch using XGMII interface.

v3->v4:
Based on Serge's questions, received a confirmation from Synopsis that the MAC IP is indeed the new 25GMAC design.
Renamed all references of XGMAC4 to 25GMAC.
The patch series is rearranged slightly as follows.
Patch1 (new): Define HDMA mapping data structure in kernel's stmmac.h Patch2 (v3 Patch1): Adds dma_ops for dw25gmac in stmmac core
Renamed new files dwxgmac4.* to dw25gmac.* - Serge Semin Defined new Synopsis version and device id macros for DW25GMAC. Coverted bit operations to FIELD_PREP macros - Russell King Moved hwif.h to this patch, Sparse flagged warning - Simon Horman Defined macros for hardcoded values TDPS etc - Serge Semin Read number of PDMAs/VDMAs from hardware - Serge Semin

Quoted 8 lines

Patch3 (v3 Patch2): Hooks in hardware interface handling for dw25gmac
Resolved user_version quirks questions - Serge, Russell, Andrew Added new stmmac_hw entry for DW25GMAC. - Serge
Added logic to override synopsis_dev_id by glue driver.
Patch4 (v3 Patch3): Adds PCI driver for BCM8958x device
Define bitmmap macros for hardcoded values - Andrew Lunn Added per device software node - Andrew Lunn
Patch5(new/split): Adds BCM8958x driver to build system

Thanks for the series update and I'm sorry for abandoning the v3 discussion. I had to work on another urgent task. I'll get back to reviewing your patch set on the next week.

-Serge(y)

Quoted 51 lines

v2->v3:
Addressed v2 comments from Andrew, Jakub, Russel and Simon. Based on suggestion by Russel and Andrew, added software node to create phylink in fixed-link mode.
Moved dwxgmac4 specific functions to new files dwxgmac4.c and dwxgmac4.h in stmmac core module.
Reorganized the code to use the existing glue logic support for xgmac in hwif.c and override ops functions for dwxgmac4 specific functions. The patch is split into three parts.
Patch#1 Adds dma_ops for dwxgmac4 in stmmac core
Patch#2 Hooks in the hardware interface handling for dwxgmac4 Patch#3 Adds PCI driver for BCM8958x device
https://lore.kernel.org/netdev/[email protected]/

v1->v2:
Minor fixes to address coding style issues.
Sent v2 too soon by mistake, without waiting for review comments. Received feedback on this version.
https://lore.kernel.org/netdev/[email protected]/

v1:

   https://lore.kernel.org/netdev/[email protected]/

Jitendra Vegiraju (5):
Add HDMA mapping for dw25gmac support
Add basic dw25gmac support to stmmac core
Integrate dw25gmac into stmmac hwif handling
Add PCI driver support for BCM8958x
Add BCM8958x driver to build system

 MAINTAINERS                                   |   8 +
 drivers/net/ethernet/stmicro/stmmac/Kconfig   |  11 +
 drivers/net/ethernet/stmicro/stmmac/Makefile  |   3 +-
 drivers/net/ethernet/stmicro/stmmac/common.h  |   2 +
 .../net/ethernet/stmicro/stmmac/dw25gmac.c    | 173 ++++++
 .../net/ethernet/stmicro/stmmac/dw25gmac.h    |  90 +++
 .../net/ethernet/stmicro/stmmac/dwmac-brcm.c  | 530 ++++++++++++++++++
 .../ethernet/stmicro/stmmac/dwxgmac2_dma.c    |  31 +
 drivers/net/ethernet/stmicro/stmmac/hwif.c    |  25 +-
 drivers/net/ethernet/stmicro/stmmac/hwif.h    |   1 +
 drivers/net/ethernet/stmicro/stmmac/stmmac.h  |   1 +
 include/linux/stmmac.h                        |  50 ++
 12 files changed, 922 insertions(+), 3 deletions(-)
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/dw25gmac.c
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/dw25gmac.h
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-brcm.c
Signature · 1 line
2.34.1