* [PATCH net-next 0/5] net: add HPE GXP UMAC support
@ 2026-12-05 22:51 Michal Gorlas
2026-12-05 22:51 ` [PATCH net-next 1/5] dt-bindings: reset: add HPE GXP reset controller Michal Gorlas
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Michal Gorlas @ 2026-12-05 22:51 UTC (permalink / raw)
To: Jean-Marie Verdun, Nick Hawkins, Philipp Zabel, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Marcello Sylvester Bauer, Russell King
Cc: Tan Siewert, devicetree, linux-kernel, netdev, Georg Hackel
Add Ethernet driver for the UMAC controller found on HPE GXP SoCs.
The GXP includes two controllers, first is connected to an external
Marvell PHY via an SGMII interface and the second one uses NC-SI
for sideband communication with the host NIC.
The code is based on an implementation written by HPE in a hard-fork
downstream that is available as tarball [1]. The UMAC driver is
currently used on the HPE Proliant Gen11 boards that run OpenBMC [2].
Parts of the code were submitted previously back in 2023 [3].
For stopping the interface while the traffic flows, and for the timeout
handling, also add reset controller, so that we can ensure
that the DMA engine stopped before freeing buffers. It uses the
reset-simple.
Each UMAC block contains its own MDIO controller, however, these are a
bit "weird" on this hardware, i.e. the internal SGMII PCS instances are
both reachable only through the MDIO controller of the second UMAC
block. So the first UMAC uses its external PHY and the PCS from the
second block's bus. This was handled the same in the HPE's downstream
device tree.
Tested the following on DL365 Gen11: multicast, RX/TX integrity,
repeated renegotiation, unbind/rebind, no lockdep reports on a build
with PROVE_LOCKING, NC-SI traffic, 1000/100 full, 100 half and 10 full duplex.
[1] - https://osfci.tech/ci/get_custom_repo
[2] - https://github.com/canopybmc/canopybmc/releases/tag/2026.06
[3] - https://lore.kernel.org/all/20230816215220.114118-1-nick.hawkins@hpe.com/
Signed-off-by: Michal Gorlas <michal.gorlas@9elements.com>
---
Marcello Sylvester Bauer (1):
dt-bindings: net: add HPE GXP UMAC Ethernet controller
Michal Gorlas (4):
dt-bindings: reset: add HPE GXP reset controller
reset: simple: add HPE GXP support
net: ethernet: add HPE GXP UMAC driver
MAINTAINERS: Add HPE GXP UMAC entry
.../devicetree/bindings/net/hpe,gxp-umac.yaml | 156 +++
.../devicetree/bindings/reset/hpe,gxp-reset.yaml | 40 +
MAINTAINERS | 9 +
drivers/net/ethernet/Kconfig | 1 +
drivers/net/ethernet/Makefile | 1 +
drivers/net/ethernet/hpe/Kconfig | 37 +
drivers/net/ethernet/hpe/Makefile | 6 +
drivers/net/ethernet/hpe/gxp_umac.c | 1407 ++++++++++++++++++++
drivers/net/ethernet/hpe/gxp_umac.h | 117 ++
drivers/reset/Kconfig | 3 +-
drivers/reset/reset-simple.c | 1 +
11 files changed, 1777 insertions(+), 1 deletion(-)
---
base-commit: ccb81d5e317b0ae2cc66ca1c628c0ca907928f94
change-id: 20261205-umac-b33a66122424
Best regards,
--
Michal Gorlas <michal.gorlas@9elements.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH net-next 1/5] dt-bindings: reset: add HPE GXP reset controller
2026-12-05 22:51 [PATCH net-next 0/5] net: add HPE GXP UMAC support Michal Gorlas
@ 2026-12-05 22:51 ` Michal Gorlas
2026-12-05 22:51 ` [PATCH net-next 2/5] reset: simple: add HPE GXP support Michal Gorlas
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Michal Gorlas @ 2026-12-05 22:51 UTC (permalink / raw)
To: Jean-Marie Verdun, Nick Hawkins, Philipp Zabel, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Marcello Sylvester Bauer, Russell King
Cc: Tan Siewert, devicetree, linux-kernel, netdev
Add bindings for the HPE GXP SoC reset controller. Consists
of a single register which holds one reset line per bit. A
line is asserted while its bit is set.
Signed-off-by: Michal Gorlas <michal.gorlas@9elements.com>
---
.../devicetree/bindings/reset/hpe,gxp-reset.yaml | 40 ++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/Documentation/devicetree/bindings/reset/hpe,gxp-reset.yaml b/Documentation/devicetree/bindings/reset/hpe,gxp-reset.yaml
new file mode 100644
index 000000000000..715e26f8fe41
--- /dev/null
+++ b/Documentation/devicetree/bindings/reset/hpe,gxp-reset.yaml
@@ -0,0 +1,40 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/reset/hpe,gxp-reset.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: HPE GXP Reset controller
+
+maintainers:
+ - Michal Gorlas <michal.gorlas@9elements.com>
+
+description: |
+ Reset controller of the HPE GXP SoC. The register holds one reset
+ line per bit. A line is asserted while the bit is set.
+
+properties:
+ compatible:
+ const: hpe,gxp-reset
+
+ reg:
+ maxItems: 1
+
+ '#reset-cells':
+ const: 1
+ description: Bit number of the reset line.
+
+required:
+ - compatible
+ - reg
+ - '#reset-cells'
+
+additionalProperties: false
+
+examples:
+ - |
+ reset-controller@c00000c0 {
+ compatible = "hpe,gxp-reset";
+ reg = <0xc00000c0 0x4>;
+ #reset-cells = <1>;
+ };
--
2.56.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next 2/5] reset: simple: add HPE GXP support
2026-12-05 22:51 [PATCH net-next 0/5] net: add HPE GXP UMAC support Michal Gorlas
2026-12-05 22:51 ` [PATCH net-next 1/5] dt-bindings: reset: add HPE GXP reset controller Michal Gorlas
@ 2026-12-05 22:51 ` Michal Gorlas
2026-12-05 22:51 ` [PATCH net-next 3/5] dt-bindings: net: add HPE GXP UMAC Ethernet controller Michal Gorlas
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Michal Gorlas @ 2026-12-05 22:51 UTC (permalink / raw)
To: Jean-Marie Verdun, Nick Hawkins, Philipp Zabel, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Marcello Sylvester Bauer, Russell King
Cc: Tan Siewert, devicetree, linux-kernel, netdev
Reuse reset-simple driver for the HPE GXP reset controller.
It is used on the GXP SoCs for the UMAC controller resetting.
Signed-off-by: Michal Gorlas <michal.gorlas@9elements.com>
---
drivers/reset/Kconfig | 3 ++-
drivers/reset/reset-simple.c | 1 +
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig
index eda9c698a95f..fb20f52451fe 100644
--- a/drivers/reset/Kconfig
+++ b/drivers/reset/Kconfig
@@ -297,7 +297,7 @@ config RESET_SCMI
config RESET_SIMPLE
bool "Simple Reset Controller Driver" if COMPILE_TEST || EXPERT
- default ARCH_ASPEED || ARCH_BCMBCA || ARCH_BITMAIN || ARCH_REALTEK || ARCH_SOPHGO || ARCH_STM32 || (ARCH_INTEL_SOCFPGA && ARM64) || ARCH_SUNXI || ARC
+ default ARCH_ASPEED || ARCH_BCMBCA || ARCH_BITMAIN || ARCH_HPE_GXP || ARCH_REALTEK || ARCH_SOPHGO || ARCH_STM32 || (ARCH_INTEL_SOCFPGA && ARM64) || ARCH_SUNXI || ARC
depends on HAS_IOMEM
help
This enables a simple reset controller driver for reset lines that
@@ -313,6 +313,7 @@ config RESET_SIMPLE
- Allwinner SoCs
- SiFive FU740 SoCs
- Sophgo SoCs
+ - HPE GXP SoCs
config RESET_SKY1
bool "Cix Sky1 reset controller"
diff --git a/drivers/reset/reset-simple.c b/drivers/reset/reset-simple.c
index 85e3ac55cccf..d1d4c471b181 100644
--- a/drivers/reset/reset-simple.c
+++ b/drivers/reset/reset-simple.c
@@ -155,6 +155,7 @@ static const struct of_device_id reset_simple_dt_ids[] = {
.data = &reset_simple_active_low },
{ .compatible = "sophgo,sg2042-reset",
.data = &reset_simple_active_low },
+ { .compatible = "hpe,gxp-reset" },
{ /* sentinel */ },
};
--
2.56.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next 3/5] dt-bindings: net: add HPE GXP UMAC Ethernet controller
2026-12-05 22:51 [PATCH net-next 0/5] net: add HPE GXP UMAC support Michal Gorlas
2026-12-05 22:51 ` [PATCH net-next 1/5] dt-bindings: reset: add HPE GXP reset controller Michal Gorlas
2026-12-05 22:51 ` [PATCH net-next 2/5] reset: simple: add HPE GXP support Michal Gorlas
@ 2026-12-05 22:51 ` Michal Gorlas
2026-12-05 22:51 ` [PATCH net-next 4/5] net: ethernet: add HPE GXP UMAC driver Michal Gorlas
2026-12-05 22:51 ` [PATCH net-next 5/5] MAINTAINERS: Add HPE GXP UMAC entry Michal Gorlas
4 siblings, 0 replies; 6+ messages in thread
From: Michal Gorlas @ 2026-12-05 22:51 UTC (permalink / raw)
To: Jean-Marie Verdun, Nick Hawkins, Philipp Zabel, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Marcello Sylvester Bauer, Russell King
Cc: Tan Siewert, devicetree, linux-kernel, netdev
From: Marcello Sylvester Bauer <marcello.bauer@9elements.com>
Add device tree bindings for the HPE GXP UMAC Ethernet controller and
its associated MDIO bus. The GXP SoC is used as the BMC in HPE ProLiant
Gen10 and Gen11 servers.
The GXP includes two UMAC Ethernet controllers:
- One connected to an external PHY for dedicated BMC management
- One using NC-SI for sideband communication with the host NIC
The UMAC reaches an external SGMII PHY through an internal SGMII PCS,
accessed through a Clause 22 register on a UMAC MDIO bus.
Signed-off-by: Marcello Sylvester Bauer <marcello.bauer@9elements.com>
Co-developed-by: Michal Gorlas <michal.gorlas@9elements.com>
Signed-off-by: Michal Gorlas <michal.gorlas@9elements.com>
---
.../devicetree/bindings/net/hpe,gxp-umac.yaml | 156 +++++++++++++++++++++
1 file changed, 156 insertions(+)
diff --git a/Documentation/devicetree/bindings/net/hpe,gxp-umac.yaml b/Documentation/devicetree/bindings/net/hpe,gxp-umac.yaml
new file mode 100644
index 000000000000..9cde099faaea
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/hpe,gxp-umac.yaml
@@ -0,0 +1,156 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/hpe,gxp-umac.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: HPE GXP UMAC Ethernet Controller
+
+maintainers:
+ - Marcello Sylvester Bauer <marcello.bauer@9elements.com>
+
+description:
+ The HPE GXP SoC includes two UMAC ethernet controllers for BMC
+ network connectivity. One is typically connected to an external
+ Marvell PHY for dedicated management and the other uses NCSI
+ for sideband communication with the host NIC.
+
+allOf:
+ - $ref: ethernet-controller.yaml#
+ - if:
+ required:
+ - use-ncsi
+ then:
+ properties:
+ phy-mode: false
+ phy-handle: false
+ pcs-handle: false
+ else:
+ required:
+ - phy-mode
+ - phy-handle
+ - pcs-handle
+
+properties:
+ compatible:
+ const: hpe,gxp-umac
+
+ reg:
+ maxItems: 1
+
+ interrupts:
+ maxItems: 1
+
+ resets:
+ maxItems: 1
+ description:
+ Reset line of the UMAC block. The line also includes UMAC's MDIO controller.
+
+ phy-handle:
+ description: Reference to the external PHY
+
+ phy-mode:
+ const: sgmii
+
+ phy-connection-type: false
+
+ fixed-link: false
+
+ managed: false
+
+ pcs-handle:
+ maxItems: 1
+ description: Phandle to the internal SGMII PCS
+
+ use-ncsi:
+ type: boolean
+ description:
+ Whether the device should use NCSI. Only one of the MACs can
+ support NCSI, and it requires a physical connection on the
+ board to be present. This property being set implies that the
+ physical connection is present and should be used.
+
+ mdio:
+ $ref: mdio.yaml#
+ unevaluatedProperties: false
+
+ properties:
+ clock-frequency: false
+ suppress-preamble: false
+
+ patternProperties:
+ '^ethernet-pcs@[0-9a-f]+$':
+ type: object
+ description:
+ Internal SGMII PCS bridging a GXP UMAC to an external SGMII PHY,
+ accessed through a Clause 22 register set.
+
+ properties:
+ compatible:
+ const: hpe,gxp-umac-pcs
+
+ reg:
+ maxItems: 1
+
+ required:
+ - compatible
+ - reg
+
+ additionalProperties: false
+
+required:
+ - compatible
+ - reg
+ - interrupts
+ - resets
+ - mdio
+
+unevaluatedProperties: false
+
+examples:
+ - |
+ ethernet@c0004000 {
+ compatible = "hpe,gxp-umac";
+ reg = <0xc0004000 0x100>;
+ interrupts = <10>;
+ resets = <&gxp_rst 2>;
+ nvmem-cells = <&mac0>;
+ nvmem-cell-names = "mac-address";
+ phy-handle = <&ext_phy0>;
+ pcs-handle = <&int_pcs0>;
+ phy-mode = "sgmii";
+
+ mdio {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ ext_phy0: ethernet-phy@0 {
+ reg = <0>;
+ };
+ };
+ };
+
+ ethernet@c0005000 {
+ compatible = "hpe,gxp-umac";
+ reg = <0xc0005000 0x100>;
+ interrupts = <11>;
+ resets = <&gxp_rst 7>;
+ nvmem-cells = <&mac1>;
+ nvmem-cell-names = "mac-address";
+ use-ncsi;
+
+ mdio {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ int_pcs0: ethernet-pcs@0 {
+ compatible = "hpe,gxp-umac-pcs";
+ reg = <0>;
+ };
+
+ ethernet-pcs@1 {
+ compatible = "hpe,gxp-umac-pcs";
+ reg = <1>;
+ };
+ };
+ };
--
2.56.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next 4/5] net: ethernet: add HPE GXP UMAC driver
2026-12-05 22:51 [PATCH net-next 0/5] net: add HPE GXP UMAC support Michal Gorlas
` (2 preceding siblings ...)
2026-12-05 22:51 ` [PATCH net-next 3/5] dt-bindings: net: add HPE GXP UMAC Ethernet controller Michal Gorlas
@ 2026-12-05 22:51 ` Michal Gorlas
2026-12-05 22:51 ` [PATCH net-next 5/5] MAINTAINERS: Add HPE GXP UMAC entry Michal Gorlas
4 siblings, 0 replies; 6+ messages in thread
From: Michal Gorlas @ 2026-12-05 22:51 UTC (permalink / raw)
To: Jean-Marie Verdun, Nick Hawkins, Philipp Zabel, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Marcello Sylvester Bauer, Russell King
Cc: Tan Siewert, devicetree, linux-kernel, netdev, Georg Hackel
Add the Ethernet MAC driver for the HPE GXP BMC SoC used in ProLiant
Gen10/Gen11 servers. The GXP includes two UMAC instances: one for
dedicated BMC management connected to an external PHY, and one for
NC-SI communication. The UMAC driver supports:
- SGMII via internal SGMII PHY modelled as phylink PCS
- NC-SI support for sideband management through host NIC
- NAPI with page_pool based RX ring
- Multicast hash filtering and promiscuous mode
- Standard ethtool operations
Co-developed-by: Jean-Marie Verdun <verdun@hpe.com>
Signed-off-by: Jean-Marie Verdun <verdun@hpe.com>
Co-developed-by: Marcello Sylvester Bauer <marcello.bauer@9elements.com>
Signed-off-by: Marcello Sylvester Bauer <marcello.bauer@9elements.com>
Signed-off-by: Georg Hackel <georg.hackel@9elements.com>
Signed-off-by: Michal Gorlas <michal.gorlas@9elements.com>
---
drivers/net/ethernet/Kconfig | 1 +
drivers/net/ethernet/Makefile | 1 +
drivers/net/ethernet/hpe/Kconfig | 37 +
drivers/net/ethernet/hpe/Makefile | 6 +
drivers/net/ethernet/hpe/gxp_umac.c | 1407 +++++++++++++++++++++++++++++++++++
drivers/net/ethernet/hpe/gxp_umac.h | 117 +++
6 files changed, 1569 insertions(+)
diff --git a/drivers/net/ethernet/Kconfig b/drivers/net/ethernet/Kconfig
index c2b0161d0bec..c6f3c722ca98 100644
--- a/drivers/net/ethernet/Kconfig
+++ b/drivers/net/ethernet/Kconfig
@@ -65,6 +65,7 @@ source "drivers/net/ethernet/freescale/Kconfig"
source "drivers/net/ethernet/fungible/Kconfig"
source "drivers/net/ethernet/google/Kconfig"
source "drivers/net/ethernet/hisilicon/Kconfig"
+source "drivers/net/ethernet/hpe/Kconfig"
source "drivers/net/ethernet/huawei/Kconfig"
source "drivers/net/ethernet/i825xx/Kconfig"
source "drivers/net/ethernet/ibm/Kconfig"
diff --git a/drivers/net/ethernet/Makefile b/drivers/net/ethernet/Makefile
index a306dae23bcb..65e00a93049b 100644
--- a/drivers/net/ethernet/Makefile
+++ b/drivers/net/ethernet/Makefile
@@ -44,6 +44,7 @@ obj-$(CONFIG_NET_VENDOR_FREESCALE) += freescale/
obj-$(CONFIG_NET_VENDOR_FUNGIBLE) += fungible/
obj-$(CONFIG_NET_VENDOR_GOOGLE) += google/
obj-$(CONFIG_NET_VENDOR_HISILICON) += hisilicon/
+obj-$(CONFIG_NET_VENDOR_HPE) += hpe/
obj-$(CONFIG_NET_VENDOR_HUAWEI) += huawei/
obj-$(CONFIG_NET_VENDOR_IBM) += ibm/
obj-$(CONFIG_NET_VENDOR_INTEL) += intel/
diff --git a/drivers/net/ethernet/hpe/Kconfig b/drivers/net/ethernet/hpe/Kconfig
new file mode 100644
index 000000000000..6375f0373644
--- /dev/null
+++ b/drivers/net/ethernet/hpe/Kconfig
@@ -0,0 +1,37 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# HPE network device configuration
+
+config NET_VENDOR_HPE
+ bool "Hewlett Packard Enterprise devices"
+ default y
+ depends on ARCH_HPE || COMPILE_TEST
+ help
+ If you have a network (Ethernet) card belonging to this class, say Y.
+
+ Note that the answer to this question doesn't directly affect the
+ kernel: saying N will just cause the configurator to skip all
+ the questions about HPE devices. If you say Y, you will be asked
+ for your specific card in the following questions.
+
+if NET_VENDOR_HPE
+
+config GXP_UMAC
+ tristate "HPE GXP UMAC support"
+ depends on ARCH_HPE || COMPILE_TEST
+ depends on NET_NCSI
+ depends on HAS_IOMEM
+ select CRC32
+ select PHYLINK
+ select PAGE_POOL
+ select RESET_CONTROLLER
+ help
+ This driver supports the UMAC ethernet controller found on
+ HPE GXP BMC SoCs. The GXP is used in HPE ProLiant Gen10/Gen11
+ servers. Say Y here if you want to use the ethernet interface
+ on these systems.
+
+ To compile this driver as a module, choose M here. The module
+ will be called gxp_umac.
+
+endif # NET_VENDOR_HPE
diff --git a/drivers/net/ethernet/hpe/Makefile b/drivers/net/ethernet/hpe/Makefile
new file mode 100644
index 000000000000..654b6b947106
--- /dev/null
+++ b/drivers/net/ethernet/hpe/Makefile
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Makefile for HPE network device drivers
+#
+
+obj-$(CONFIG_GXP_UMAC) += gxp_umac.o
diff --git a/drivers/net/ethernet/hpe/gxp_umac.c b/drivers/net/ethernet/hpe/gxp_umac.c
new file mode 100644
index 000000000000..4e417cb75720
--- /dev/null
+++ b/drivers/net/ethernet/hpe/gxp_umac.c
@@ -0,0 +1,1407 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * HPE GXP UMAC Ethernet driver
+ *
+ * Copyright (C) 2019 Hewlett Packard Enterprise Development LP.
+ * Copyright (C) 2026 9elements GmbH
+ */
+
+#include <linux/bitfield.h>
+#include <linux/crc32.h>
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/dma-mapping.h>
+#include <linux/err.h>
+#include <linux/etherdevice.h>
+#include <linux/ethtool.h>
+#include <linux/interrupt.h>
+#include <linux/io.h>
+#include <linux/mdio.h>
+#include <linux/mii.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/netdevice.h>
+#include <linux/of.h>
+#include <linux/of_mdio.h>
+#include <linux/of_net.h>
+#include <linux/phy.h>
+#include <linux/phylink.h>
+#include <linux/platform_device.h>
+#include <linux/reset.h>
+#include <linux/rtnetlink.h>
+#include <linux/spinlock.h>
+#include <linux/workqueue.h>
+#include <net/ncsi.h>
+#include <net/netdev_queues.h>
+#include <net/page_pool/helpers.h>
+
+#include "gxp_umac.h"
+
+#define DRV_NAME "gxp-umac"
+
+struct umac_priv {
+ struct platform_device *pdev;
+ void __iomem *base;
+
+ struct phylink_config phylink_config;
+ struct phylink *phylink;
+ phy_interface_t phy_mode;
+
+ struct mdio_device *pcs_phy;
+ struct phylink_pcs pcs;
+
+ struct umac_tx_descs *tx_descs;
+ struct umac_rx_descs *rx_descs;
+ dma_addr_t tx_descs_dma_addr;
+ dma_addr_t rx_descs_dma_addr;
+
+ unsigned int rx_offset[UMAC_MAX_RX_DESC_ENTRIES];
+ struct page *rx_page[UMAC_MAX_RX_DESC_ENTRIES];
+ struct page_pool *page_pool;
+
+ struct sk_buff *tx_skb[UMAC_MAX_TX_DESC_ENTRIES];
+ dma_addr_t tx_dma[UMAC_MAX_TX_DESC_ENTRIES];
+
+ /* For UMAC_INTERRUPT */
+ spinlock_t lock;
+
+ /* For phylink ops */
+ struct mutex cfg_lock;
+
+ /* For MAC reset */
+ struct mutex reset_lock;
+
+ int duplex;
+ int speed;
+ bool link;
+
+ bool promisc;
+
+ struct reset_control *rst;
+ u32 mc_hash[2];
+
+ struct work_struct tx_timeout_task;
+ unsigned int tx_done;
+ unsigned int tx_cur;
+ unsigned int rx_cur;
+
+ struct napi_struct napi;
+ struct net_device *ndev;
+
+ struct ncsi_dev *ncsidev;
+ bool use_ncsi;
+
+ struct mii_bus *mii_bus;
+};
+
+static int umac_ioctl(struct net_device *ndev, struct ifreq *ifr, int cmd)
+{
+ struct umac_priv *umac = netdev_priv(ndev);
+
+ if (!netif_running(ndev))
+ return -EINVAL;
+
+ if (umac->use_ncsi)
+ return -EOPNOTSUPP;
+
+ return phylink_mii_ioctl(umac->phylink, ifr, cmd);
+}
+
+static void umac_set_mac_address(struct net_device *ndev, const u8 *addr)
+{
+ struct umac_priv *umac = netdev_priv(ndev);
+ unsigned int value;
+
+ value = addr[0] << 8 | addr[1];
+ writel(value, umac->base + UMAC_MAC_ADDR_HI);
+ value = addr[2] << 8 | addr[3];
+ writel(value, umac->base + UMAC_MAC_ADDR_MID);
+ value = addr[4] << 8 | addr[5];
+ writel(value, umac->base + UMAC_MAC_ADDR_LO);
+}
+
+static int umac_eth_mac_addr(struct net_device *ndev, void *p)
+{
+ int ret;
+
+ ret = eth_mac_addr(ndev, p);
+ if (ret)
+ return ret;
+
+ umac_set_mac_address(ndev, ndev->dev_addr);
+ return 0;
+}
+
+static void umac_channel_enable(struct umac_priv *umac)
+{
+ unsigned int value;
+
+ value = readl(umac->base + UMAC_CONFIG_STATUS);
+ value |= UMAC_CFG_TXEN | UMAC_CFG_RXEN;
+ writel(value, umac->base + UMAC_CONFIG_STATUS);
+
+ writel(0, umac->base + UMAC_RING_PROMPT);
+}
+
+static void umac_channel_disable(struct umac_priv *umac)
+{
+ writel(0, umac->base + UMAC_CONFIG_STATUS);
+ readl(umac->base + UMAC_CONFIG_STATUS);
+}
+
+static int umac_mdio_op(struct umac_priv *umac, int addr, int regnum, u32 dir)
+{
+ u32 val;
+
+ val = readl(umac->base + UMAC_MDIO_MII);
+ val &= ~(UMAC_MDIO_PHY_ADDR | UMAC_MDIO_REG_ADDR | UMAC_MDIO_MRNW);
+ val |= FIELD_PREP(UMAC_MDIO_PHY_ADDR, addr) |
+ FIELD_PREP(UMAC_MDIO_REG_ADDR, regnum) | dir;
+ writel(val, umac->base + UMAC_MDIO_MII);
+ writel(val | UMAC_MDIO_MOWNER, umac->base + UMAC_MDIO_MII);
+
+ return readl_poll_timeout(umac->base + UMAC_MDIO_MII, val,
+ !(val & UMAC_MDIO_MOWNER), UMAC_SLEEP_US,
+ UMAC_TIMEOUT_US);
+}
+
+static int umac_mdio_read(struct mii_bus *bus, int addr, int regnum)
+{
+ struct umac_priv *umac = bus->priv;
+ int ret;
+
+ mutex_lock(&umac->reset_lock);
+ ret = umac_mdio_op(umac, addr, regnum, UMAC_MDIO_MRNW);
+ if (!ret)
+ ret = readl(umac->base + UMAC_MDIO_DATA) & UMAC_MDIO_DATA_MASK;
+ mutex_unlock(&umac->reset_lock);
+
+ return ret;
+}
+
+static int umac_mdio_write(struct mii_bus *bus, int addr, int regnum, u16 val)
+{
+ struct umac_priv *umac = bus->priv;
+ int ret;
+
+ mutex_lock(&umac->reset_lock);
+ writel(val, umac->base + UMAC_MDIO_DATA);
+ ret = umac_mdio_op(umac, addr, regnum, 0);
+ mutex_unlock(&umac->reset_lock);
+
+ return ret;
+}
+
+static int umac_wait_idle(struct umac_priv *umac, u32 mask)
+{
+ u32 status;
+
+ return readl_poll_timeout(umac->base + UMAC_CONFIG_STATUS2, status,
+ (status & mask) == mask, UMAC_SLEEP_US,
+ UMAC_TIMEOUT_US);
+}
+
+static int umac_alloc_rings(struct net_device *ndev)
+{
+ struct umac_priv *umac = netdev_priv(ndev);
+ struct platform_device *pdev = umac->pdev;
+ int err;
+
+ err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
+ if (err) {
+ dev_warn(&pdev->dev, "No suitable DMA available\n");
+ return err;
+ }
+
+ umac->tx_descs =
+ dmam_alloc_coherent(&pdev->dev, sizeof(*umac->tx_descs),
+ &umac->tx_descs_dma_addr, GFP_KERNEL);
+ if (!umac->tx_descs)
+ return -ENOMEM;
+
+ umac->rx_descs =
+ dmam_alloc_coherent(&pdev->dev, sizeof(*umac->rx_descs),
+ &umac->rx_descs_dma_addr, GFP_KERNEL);
+ if (!umac->rx_descs)
+ return -ENOMEM;
+
+ return 0;
+}
+
+static int umac_create_page_pool(struct umac_priv *umac)
+{
+ struct page_pool_params pp = {
+ .order = 0,
+ .flags = PP_FLAG_DMA_MAP | PP_FLAG_DMA_SYNC_DEV,
+ .pool_size = UMAC_MAX_RX_DESC_ENTRIES,
+ .nid = NUMA_NO_NODE,
+ .dev = &umac->pdev->dev,
+ .napi = &umac->napi,
+ .netdev = umac->ndev,
+ .dma_dir = DMA_FROM_DEVICE,
+ .offset = 0,
+ .max_len = PAGE_SIZE,
+ };
+ struct page_pool *pool;
+
+ pool = page_pool_create(&pp);
+ if (IS_ERR(pool))
+ return PTR_ERR(pool);
+
+ umac->page_pool = pool;
+ return 0;
+}
+
+static void umac_rx_arm(struct umac_priv *umac, unsigned int i)
+{
+ struct umac_rx_desc_entry *prxdesc = &umac->rx_descs->entrylist[i];
+
+ prxdesc->dmaaddress = cpu_to_le32(page_pool_get_dma_addr(umac->rx_page[i])
+ + umac->rx_offset[i]);
+ prxdesc->count = cpu_to_le16(UMAC_MAX_RX_FRAME_SIZE);
+ dma_wmb();
+ WRITE_ONCE(prxdesc->status, cpu_to_le16(UMAC_RING_ENTRY_HW_OWN));
+}
+
+static int umac_rx_refill(struct umac_priv *umac, unsigned int i)
+{
+ unsigned int offset;
+ struct page *page;
+
+ page = page_pool_dev_alloc_frag(umac->page_pool, &offset,
+ UMAC_RX_BUF_SIZE);
+ if (!page)
+ return -ENOMEM;
+
+ umac->rx_page[i] = page;
+ umac->rx_offset[i] = offset;
+ umac_rx_arm(umac, i);
+
+ return 0;
+}
+
+static void umac_free_rx_pages(struct umac_priv *umac)
+{
+ unsigned int i;
+
+ for (i = 0; i < UMAC_MAX_RX_DESC_ENTRIES; i++) {
+ if (!umac->rx_page[i])
+ continue;
+
+ page_pool_put_full_page(umac->page_pool, umac->rx_page[i],
+ false);
+
+ umac->rx_page[i] = NULL;
+ }
+}
+
+static void umac_destroy_page_pool(struct umac_priv *umac)
+{
+ umac_free_rx_pages(umac);
+ page_pool_destroy(umac->page_pool);
+ umac->page_pool = NULL;
+}
+
+static int umac_alloc_rx_pages(struct umac_priv *umac)
+{
+ unsigned int i;
+
+ for (i = 0; i < UMAC_MAX_RX_DESC_ENTRIES; i++) {
+ if (umac_rx_refill(umac, i)) {
+ umac_free_rx_pages(umac);
+ return -ENOMEM;
+ }
+ }
+
+ return 0;
+}
+
+static void umac_free_tx_skbs(struct umac_priv *umac)
+{
+ struct device *dev = &umac->pdev->dev;
+ unsigned int i;
+
+ for (i = 0; i < UMAC_MAX_TX_DESC_ENTRIES; i++) {
+ if (!umac->tx_skb[i])
+ continue;
+
+ dma_unmap_single(dev, umac->tx_dma[i], umac->tx_skb[i]->len,
+ DMA_TO_DEVICE);
+ dev_kfree_skb_any(umac->tx_skb[i]);
+ umac->tx_skb[i] = NULL;
+ }
+
+ WRITE_ONCE(umac->tx_done, umac->tx_cur);
+ netdev_reset_queue(umac->ndev);
+}
+
+static void umac_drop_tx(struct umac_priv *umac)
+{
+ int ret;
+
+ umac_wait_idle(umac, UMAC_STS2_IDLE_MASK);
+
+ /*
+ * Disabling MAC when a transfer is in progress can leave it in a
+ * state where the first frame after re-enabling is lost. Thus reset
+ * here.
+ */
+ mutex_lock(&umac->reset_lock);
+ ret = reset_control_assert(umac->rst);
+ if (!ret) {
+ usleep_range(10000, 20000);
+ ret = reset_control_deassert(umac->rst);
+ }
+ mutex_unlock(&umac->reset_lock);
+
+ if (ret)
+ netdev_err(umac->ndev, "MAC reset failed: %d\n", ret);
+
+ umac_free_tx_skbs(umac);
+}
+
+static void umac_free_rings(void *data)
+{
+ struct umac_priv *umac = data;
+
+ umac_drop_tx(umac);
+ umac_destroy_page_pool(umac);
+}
+
+static void umac_init_ring_descriptors(struct net_device *ndev)
+{
+ struct umac_priv *umac = netdev_priv(ndev);
+ unsigned int i;
+
+ memset(umac->tx_descs, 0, sizeof(*umac->tx_descs));
+
+ for (i = 0; i < UMAC_MAX_RX_DESC_ENTRIES; i++)
+ umac_rx_arm(umac, i);
+
+ umac->tx_cur = 0;
+ umac->tx_done = 0;
+ umac->rx_cur = 0;
+}
+
+static int umac_init_hw(struct net_device *ndev)
+{
+ struct umac_priv *umac = netdev_priv(ndev);
+ unsigned long flags;
+ unsigned int value;
+
+ umac_channel_disable(umac);
+ if (umac_wait_idle(umac, UMAC_STS2_IDLE_MASK)) {
+ netdev_warn(ndev, "MAC failed to stop\n");
+ return -EBUSY;
+ }
+
+ writel(0, umac->base + UMAC_RING_PTR);
+ writel(0, umac->base + UMAC_CLEAR_STATUS);
+ writel(0, umac->base + UMAC_CKSUM_CONFIG);
+
+ value = FIELD_PREP(UMAC_TX_RING_SIZE_MASK,
+ UMAC_RING_SIZE_VAL(UMAC_MAX_TX_DESC_ENTRIES)) |
+ FIELD_PREP(UMAC_RX_RING_SIZE_MASK,
+ UMAC_RING_SIZE_VAL(UMAC_MAX_RX_DESC_ENTRIES));
+ writel(value, umac->base + UMAC_RING_SIZE);
+
+ writel(umac->rx_descs_dma_addr, umac->base + UMAC_RX_RING_ADDR);
+ writel(umac->tx_descs_dma_addr, umac->base + UMAC_TX_RING_ADDR);
+
+ writel(UMAC_DMA_CFG_BURST_SIZE, umac->base + UMAC_DMA_CONFIG);
+
+ spin_lock_irqsave(&umac->lock, flags);
+ writel(UMAC_RX_INT | UMAC_TX_INT, umac->base + UMAC_INTERRUPT);
+ spin_unlock_irqrestore(&umac->lock, flags);
+
+ umac_set_mac_address(ndev, ndev->dev_addr);
+ writel(umac->mc_hash[0], umac->base + UMAC_MC_ADDR_FILT_LO);
+ writel(umac->mc_hash[1], umac->base + UMAC_MC_ADDR_FILT_HI);
+
+ return 0;
+}
+
+static unsigned int umac_tx_avail(struct umac_priv *umac)
+{
+ return UMAC_MAX_TX_DESC_ENTRIES -
+ (READ_ONCE(umac->tx_cur) - READ_ONCE(umac->tx_done));
+}
+
+static netdev_tx_t umac_start_xmit(struct sk_buff *skb, struct net_device *ndev)
+{
+ struct netdev_queue *txq = netdev_get_tx_queue(ndev, 0);
+ struct umac_priv *umac = netdev_priv(ndev);
+ struct device *dev = &umac->pdev->dev;
+ struct umac_tx_desc_entry *ptxdesc;
+ unsigned int cur = umac->tx_cur;
+ unsigned int idx;
+ dma_addr_t dma;
+
+ if (unlikely(cur - READ_ONCE(umac->tx_done) >=
+ UMAC_MAX_TX_DESC_ENTRIES)) {
+ netif_stop_queue(ndev);
+ netdev_warn_once(ndev, "Tx Ring full when queue awake!\n");
+ return NETDEV_TX_BUSY;
+ }
+
+ if (skb_put_padto(skb, ETH_ZLEN)) {
+ DEV_STATS_INC(ndev, tx_dropped);
+ return NETDEV_TX_OK;
+ }
+
+ if (unlikely(skb->len > UMAC_MAX_FRAME_SIZE)) {
+ dev_err_ratelimited(dev, "send data %u bytes > %u\n", skb->len,
+ UMAC_MAX_FRAME_SIZE);
+ DEV_STATS_INC(ndev, tx_dropped);
+ dev_kfree_skb_any(skb);
+ return NETDEV_TX_OK;
+ }
+
+ dma = dma_map_single(dev, skb->data, skb->len, DMA_TO_DEVICE);
+ if (unlikely(dma_mapping_error(dev, dma))) {
+ DEV_STATS_INC(ndev, tx_dropped);
+ dev_kfree_skb_any(skb);
+ return NETDEV_TX_OK;
+ }
+
+ idx = cur % UMAC_MAX_TX_DESC_ENTRIES;
+ umac->tx_skb[idx] = skb;
+ umac->tx_dma[idx] = dma;
+
+ ptxdesc = &umac->tx_descs->entrylist[idx];
+ ptxdesc->dmaaddress = cpu_to_le32(dma);
+ ptxdesc->count = cpu_to_le16(skb->len);
+ ptxdesc->cksumoffset = cpu_to_le32(0);
+
+ skb_tx_timestamp(skb);
+ netdev_tx_sent_queue(txq, skb->len);
+
+ dma_wmb();
+ WRITE_ONCE(ptxdesc->status, cpu_to_le16(UMAC_RING_ENTRY_HW_OWN));
+
+ WRITE_ONCE(umac->tx_cur, cur + 1);
+ netif_txq_maybe_stop(txq, umac_tx_avail(umac), 1,
+ UMAC_MAX_TX_DESC_ENTRIES / 4);
+
+ if (!netdev_xmit_more() || netif_xmit_stopped(txq))
+ writel(0, umac->base + UMAC_RING_PROMPT);
+
+ return NETDEV_TX_OK;
+}
+
+static int umac_rx(struct net_device *ndev, int budget)
+{
+ struct umac_priv *umac = netdev_priv(ndev);
+ struct umac_rx_desc_entry *prxdesc;
+ struct sk_buff *skb;
+ unsigned int offset;
+ int rxpktcount = 0;
+ struct page *page;
+ unsigned int len;
+ u16 status;
+
+ while (rxpktcount < budget) {
+ prxdesc = &umac->rx_descs->entrylist[umac->rx_cur];
+ status = le16_to_cpu(READ_ONCE(prxdesc->status));
+ if (status & UMAC_RING_ENTRY_HW_OWN)
+ break;
+
+ dma_rmb();
+ len = le16_to_cpu(READ_ONCE(prxdesc->count));
+
+ offset = umac->rx_offset[umac->rx_cur];
+ page = umac->rx_page[umac->rx_cur];
+
+ if (unlikely(status & UMAC_RING_RX_ERR_MASK)) {
+ DEV_STATS_INC(ndev, rx_errors);
+ if (status & UMAC_RING_RX_CRC_ERR)
+ DEV_STATS_INC(ndev, rx_crc_errors);
+ if (status & UMAC_RING_RX_LEN_ERR)
+ DEV_STATS_INC(ndev, rx_length_errors);
+ if (status & UMAC_RING_RX_OVERRUN)
+ DEV_STATS_INC(ndev, rx_over_errors);
+ goto rearm;
+ }
+
+ if (unlikely(status & UMAC_RING_RX_FRAME_ERR)) {
+ DEV_STATS_INC(ndev, rx_errors);
+ DEV_STATS_INC(ndev, rx_frame_errors);
+ goto rearm;
+ }
+
+ if (unlikely(len < ETH_HLEN + ETH_FCS_LEN ||
+ len > UMAC_MAX_RX_FRAME_SIZE)) {
+ DEV_STATS_INC(ndev, rx_errors);
+ DEV_STATS_INC(ndev, rx_length_errors);
+ goto rearm;
+ }
+
+ len -= ETH_FCS_LEN;
+
+ skb = napi_alloc_skb(&umac->napi, ETH_HLEN);
+ if (unlikely(!skb))
+ goto drop;
+
+ if (unlikely(umac_rx_refill(umac, umac->rx_cur))) {
+ napi_consume_skb(skb, budget);
+ goto drop;
+ }
+
+ page_pool_dma_sync_for_cpu(umac->page_pool, page, offset, len);
+ skb_add_rx_frag(skb, 0, page, offset, len, UMAC_RX_BUF_SIZE);
+ skb_mark_for_recycle(skb);
+ __pskb_pull_tail(skb, ETH_HLEN);
+
+ skb->protocol = eth_type_trans(skb, ndev);
+ if (unlikely(skb->protocol == htons(ETH_P_NCSI) &&
+ skb_linearize(skb))) {
+ dev_kfree_skb_any(skb);
+ DEV_STATS_INC(ndev, rx_dropped);
+ goto next;
+ }
+ dev_sw_netstats_rx_add(ndev, len);
+ napi_gro_receive(&umac->napi, skb);
+ goto next;
+drop:
+ DEV_STATS_INC(ndev, rx_dropped);
+rearm:
+ umac_rx_arm(umac, umac->rx_cur);
+next:
+ umac->rx_cur = (umac->rx_cur + 1) % UMAC_MAX_RX_DESC_ENTRIES;
+ rxpktcount++;
+ }
+
+ if (rxpktcount)
+ writel(0, umac->base + UMAC_RING_PROMPT);
+
+ return rxpktcount;
+}
+
+static void umac_tx_done(struct net_device *ndev, int budget)
+{
+ struct netdev_queue *txq = netdev_get_tx_queue(ndev, 0);
+ struct umac_priv *umac = netdev_priv(ndev);
+ unsigned int cur = READ_ONCE(umac->tx_cur);
+ struct umac_tx_desc_entry *ptxdesc;
+ unsigned int done = umac->tx_done;
+ unsigned int pkts = 0, bytes = 0;
+ struct sk_buff *skb;
+ unsigned int idx;
+
+ while (done != cur) {
+ idx = done % UMAC_MAX_TX_DESC_ENTRIES;
+ ptxdesc = &umac->tx_descs->entrylist[idx];
+
+ if (le16_to_cpu(READ_ONCE(ptxdesc->status)) &
+ UMAC_RING_ENTRY_HW_OWN)
+ break;
+
+ dma_rmb();
+ skb = umac->tx_skb[idx];
+ dma_unmap_single(&umac->pdev->dev, umac->tx_dma[idx], skb->len,
+ DMA_TO_DEVICE);
+ pkts++;
+ bytes += skb->len;
+ napi_consume_skb(skb, budget);
+ umac->tx_skb[idx] = NULL;
+ done++;
+ }
+
+ if (!pkts)
+ return;
+
+ WRITE_ONCE(umac->tx_done, done);
+
+ dev_sw_netstats_tx_add(ndev, pkts, bytes);
+ netif_txq_completed_wake(txq, pkts, bytes, umac_tx_avail(umac),
+ UMAC_MAX_TX_DESC_ENTRIES / 4);
+}
+
+static void umac_irq_enable(struct umac_priv *umac)
+{
+ unsigned long flags;
+ unsigned int value;
+
+ spin_lock_irqsave(&umac->lock, flags);
+ value = readl(umac->base + UMAC_INTERRUPT);
+ value &= ~(UMAC_RX_INT | UMAC_TX_INT);
+ value |= (UMAC_RX_INTEN | UMAC_TX_INTEN);
+ writel(value, umac->base + UMAC_INTERRUPT);
+ spin_unlock_irqrestore(&umac->lock, flags);
+}
+
+static void umac_irq_disable(struct umac_priv *umac)
+{
+ unsigned long flags;
+ unsigned int value;
+
+ spin_lock_irqsave(&umac->lock, flags);
+ value = readl(umac->base + UMAC_INTERRUPT);
+ value |= (UMAC_RX_INT | UMAC_TX_INT);
+ value &= ~(UMAC_RX_INTEN | UMAC_TX_INTEN);
+ writel(value, umac->base + UMAC_INTERRUPT);
+ spin_unlock_irqrestore(&umac->lock, flags);
+}
+
+static irqreturn_t umac_interrupt(int irq, void *p_ndev)
+{
+ struct net_device *ndev = (struct net_device *)p_ndev;
+ struct umac_priv *umac = netdev_priv(ndev);
+
+ if (!(readl(umac->base + UMAC_INTERRUPT) & (UMAC_RX_INT | UMAC_TX_INT)))
+ return IRQ_NONE;
+
+ umac_irq_disable(umac);
+ napi_schedule(&umac->napi);
+
+ return IRQ_HANDLED;
+}
+
+static void umac_resync_ring_ptr(struct umac_priv *umac)
+{
+ struct netdev_queue *txq = netdev_get_tx_queue(umac->ndev, 0);
+ unsigned int rx = umac->rx_cur, tx, n;
+ u32 ptr;
+
+ for (n = 0; n < UMAC_MAX_RX_DESC_ENTRIES; n++) {
+ if (le16_to_cpu(READ_ONCE(umac->rx_descs->entrylist[rx].status))
+ & UMAC_RING_ENTRY_HW_OWN)
+ break;
+ rx = (rx + 1) % UMAC_MAX_RX_DESC_ENTRIES;
+ }
+
+ __netif_tx_lock_bh(txq);
+ tx = umac->tx_done;
+ while (tx != umac->tx_cur &&
+ !(le16_to_cpu(READ_ONCE(umac->tx_descs->entrylist[tx
+ % UMAC_MAX_TX_DESC_ENTRIES].status)) &
+ UMAC_RING_ENTRY_HW_OWN))
+ tx++;
+
+ ptr = readl(umac->base + UMAC_RING_PTR) &
+ ~(UMAC_TX_RING_PTR_MASK | UMAC_RX_RING_PTR_MASK);
+ ptr |= FIELD_PREP(UMAC_RX_RING_PTR_MASK, rx) |
+ FIELD_PREP(UMAC_TX_RING_PTR_MASK, tx % UMAC_MAX_TX_DESC_ENTRIES);
+ writel(ptr, umac->base + UMAC_RING_PTR);
+ __netif_tx_unlock_bh(txq);
+}
+
+static int umac_set_link(struct umac_priv *umac)
+{
+ u32 value;
+
+ umac_channel_disable(umac);
+ if (umac_wait_idle(umac, UMAC_STS2_IDLE_MASK)) {
+ netdev_err(umac->ndev, "MAC failed to stop\n");
+ return -EBUSY;
+ }
+
+ umac_resync_ring_ptr(umac);
+
+ value = readl(umac->base + UMAC_CONFIG_STATUS);
+ value &= ~(UMAC_CFG_GTX_CLK_EN | UMAC_CFG_TX_CLK_EN);
+ writel(value, umac->base + UMAC_CONFIG_STATUS);
+ udelay(2);
+
+ value &= ~(UMAC_CFG_GIGABIT_MODE | UMAC_CFG_FULL_DUPLEX |
+ UMAC_CFG_PROMISC);
+ if (umac->speed == SPEED_1000)
+ value |= UMAC_CFG_GTX_CLK_EN | UMAC_CFG_GIGABIT_MODE;
+ else
+ value |= UMAC_CFG_TX_CLK_EN;
+ if (umac->duplex == DUPLEX_FULL)
+ value |= UMAC_CFG_FULL_DUPLEX;
+ if (umac->promisc)
+ value |= UMAC_CFG_PROMISC;
+ writel(value, umac->base + UMAC_CONFIG_STATUS);
+ udelay(2);
+
+ umac_channel_enable(umac);
+
+ return 0;
+}
+
+static struct umac_priv *pcs_to_umac(struct phylink_pcs *pcs)
+{
+ return container_of(pcs, struct umac_priv, pcs);
+}
+
+static int umac_pcs_enable(struct phylink_pcs *pcs)
+{
+ struct mdio_device *mdio = pcs_to_umac(pcs)->pcs_phy;
+ int value;
+ int err;
+
+ err = mdiodev_modify(mdio, MII_BMCR, BMCR_LOOPBACK | BMCR_ANENABLE,
+ BMCR_RESET);
+ if (err)
+ return err;
+
+ err = read_poll_timeout(mdiodev_read, value,
+ value < 0 || !(value & BMCR_RESET),
+ UMAC_SLEEP_US, UMAC_TIMEOUT_US, true, mdio,
+ MII_BMCR);
+ if (err)
+ return err;
+
+ if (value < 0)
+ return value;
+
+ return 0;
+}
+
+static unsigned int umac_pcs_inband_caps(struct phylink_pcs *pcs,
+ phy_interface_t interface)
+{
+ return LINK_INBAND_DISABLE;
+}
+
+static void umac_pcs_get_state(struct phylink_pcs *pcs, unsigned int neg_mode,
+ struct phylink_link_state *state)
+{
+ phylink_mii_c22_pcs_get_state(pcs_to_umac(pcs)->pcs_phy, neg_mode,
+ state);
+}
+
+static int umac_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,
+ phy_interface_t interface,
+ const unsigned long *advertising,
+ bool permit_pause_to_mac)
+{
+ return phylink_mii_c22_pcs_config(pcs_to_umac(pcs)->pcs_phy, interface,
+ advertising, neg_mode);
+}
+
+static void umac_pcs_link_up(struct phylink_pcs *pcs, unsigned int neg_mode,
+ phy_interface_t interface, int speed, int duplex)
+{
+ struct mdio_device *mdio = pcs_to_umac(pcs)->pcs_phy;
+ u16 bmcr;
+ int val;
+
+ switch (speed) {
+ case SPEED_1000:
+ bmcr = BMCR_SPEED1000;
+ break;
+ case SPEED_100:
+ bmcr = BMCR_SPEED100;
+ break;
+ case SPEED_10:
+ bmcr = BMCR_SPEED10;
+ break;
+ default:
+ return;
+ }
+
+ if (duplex == DUPLEX_FULL)
+ bmcr |= BMCR_FULLDPLX;
+
+ if (mdiodev_modify(mdio, MII_BMCR,
+ BMCR_ANENABLE | BMCR_SPEED1000 | BMCR_SPEED100 |
+ BMCR_FULLDPLX,
+ bmcr | BMCR_RESET) < 0)
+ return;
+
+ if (read_poll_timeout(mdiodev_read, val, val < 0 || !(val & BMCR_RESET),
+ UMAC_SLEEP_US, UMAC_TIMEOUT_US, true, mdio,
+ MII_BMCR))
+ dev_err(&mdio->dev, "PCS reset timed out\n");
+}
+
+static const struct phylink_pcs_ops umac_pcs_ops = {
+ .pcs_enable = umac_pcs_enable,
+ .pcs_inband_caps = umac_pcs_inband_caps,
+ .pcs_get_state = umac_pcs_get_state,
+ .pcs_config = umac_pcs_config,
+ .pcs_link_up = umac_pcs_link_up,
+};
+
+static void umac_mac_config(struct phylink_config *config, unsigned int mode,
+ const struct phylink_link_state *state)
+{
+ /* nothing meaningful to do */
+}
+
+static void umac_mac_link_down(struct phylink_config *config, unsigned int mode,
+ phy_interface_t interface)
+{
+ struct umac_priv *umac = netdev_priv(to_net_dev(config->dev));
+ u32 value;
+
+ mutex_lock(&umac->cfg_lock);
+ umac->link = false;
+ value = readl(umac->base + UMAC_CONFIG_STATUS);
+ value &= ~(UMAC_CFG_TXEN | UMAC_CFG_RXEN);
+ writel(value, umac->base + UMAC_CONFIG_STATUS);
+ if (umac_wait_idle(umac, UMAC_STS2_IDLE_MASK))
+ netdev_warn(umac->ndev, "MAC failed to stop\n");
+ mutex_unlock(&umac->cfg_lock);
+}
+
+static void umac_mac_link_up(struct phylink_config *config,
+ struct phy_device *phy, unsigned int mode,
+ phy_interface_t interface, int speed, int duplex,
+ bool tx_pause, bool rx_pause)
+{
+ struct net_device *ndev = to_net_dev(config->dev);
+ struct umac_priv *umac = netdev_priv(ndev);
+ int err;
+
+ mutex_lock(&umac->cfg_lock);
+ umac->speed = speed;
+ umac->duplex = duplex;
+ umac->link = true;
+
+ if (netif_device_present(ndev)) {
+ napi_disable(&umac->napi);
+ umac_irq_disable(umac);
+ err = umac_set_link(umac);
+ napi_enable(&umac->napi);
+ umac_irq_enable(umac);
+ napi_schedule(&umac->napi);
+
+ if (err)
+ schedule_work(&umac->tx_timeout_task);
+ }
+
+ mutex_unlock(&umac->cfg_lock);
+}
+
+static int umac_set_rx_mode(struct net_device *ndev,
+ struct netdev_hw_addr_list *uc,
+ struct netdev_hw_addr_list *mc)
+{
+ struct umac_priv *umac = netdev_priv(ndev);
+ struct netdev_hw_addr *ha;
+ u32 hash[2] = {};
+ u32 value;
+
+ if (ndev->flags & (IFF_PROMISC | IFF_ALLMULTI)) {
+ hash[0] = ~0U;
+ hash[1] = ~0U;
+ } else {
+ netdev_hw_addr_list_for_each(ha, mc) {
+ u32 bit = ether_crc_le(ETH_ALEN, ha->addr) >> 26;
+
+ hash[bit >> 5] |= BIT(bit & 31);
+ }
+ }
+
+ mutex_lock(&umac->cfg_lock);
+ umac->mc_hash[0] = hash[0];
+ umac->mc_hash[1] = hash[1];
+ writel(umac->mc_hash[0], umac->base + UMAC_MC_ADDR_FILT_LO);
+ writel(umac->mc_hash[1], umac->base + UMAC_MC_ADDR_FILT_HI);
+
+ umac->promisc = !!(ndev->flags & IFF_PROMISC);
+ value = readl(umac->base + UMAC_CONFIG_STATUS);
+ if (umac->promisc)
+ value |= UMAC_CFG_PROMISC;
+ else
+ value &= ~UMAC_CFG_PROMISC;
+ writel(value, umac->base + UMAC_CONFIG_STATUS);
+ mutex_unlock(&umac->cfg_lock);
+
+ return 0;
+}
+
+static struct phylink_pcs *umac_mac_select_pcs(struct phylink_config *config,
+ phy_interface_t interface)
+{
+ struct umac_priv *umac = netdev_priv(to_net_dev(config->dev));
+
+ return &umac->pcs;
+}
+
+static const struct phylink_mac_ops umac_phylink_ops = {
+ .mac_select_pcs = umac_mac_select_pcs,
+ .mac_config = umac_mac_config,
+ .mac_link_down = umac_mac_link_down,
+ .mac_link_up = umac_mac_link_up,
+};
+
+static int umac_poll(struct napi_struct *napi, int budget)
+{
+ struct umac_priv *umac = container_of(napi, struct umac_priv, napi);
+ struct net_device *ndev = umac->ndev;
+ int rx_done;
+
+ umac_tx_done(ndev, budget);
+
+ rx_done = umac_rx(ndev, budget);
+
+ if (rx_done < budget && napi_complete_done(napi, rx_done))
+ umac_irq_enable(umac);
+
+ return rx_done;
+}
+
+static int umac_open(struct net_device *ndev)
+{
+ struct umac_priv *umac = netdev_priv(ndev);
+ int err;
+
+ err = request_irq(ndev->irq, umac_interrupt, 0, ndev->name, ndev);
+ if (err) {
+ netdev_err(ndev, "failed to register irq\n");
+ return err;
+ }
+
+ err = umac_create_page_pool(umac);
+ if (err) {
+ free_irq(ndev->irq, ndev);
+ return err;
+ }
+
+ err = umac_alloc_rx_pages(umac);
+ if (err) {
+ umac_destroy_page_pool(umac);
+ free_irq(ndev->irq, ndev);
+ return err;
+ }
+
+ umac_init_ring_descriptors(ndev);
+ err = umac_init_hw(ndev);
+ if (!err && umac->link)
+ err = umac_set_link(umac);
+ if (err) {
+ free_irq(ndev->irq, ndev);
+ umac_drop_tx(umac);
+ umac_destroy_page_pool(umac);
+ return err;
+ }
+
+ napi_enable(&umac->napi);
+ umac_irq_enable(umac);
+ napi_schedule(&umac->napi);
+
+ netif_start_queue(ndev);
+
+ if (!umac->use_ncsi) {
+ err = phylink_of_phy_connect(umac->phylink,
+ umac->pdev->dev.of_node, 0);
+ if (err)
+ goto cleanup;
+ phylink_start(umac->phylink);
+ return 0;
+ }
+
+ netif_carrier_on(ndev);
+
+ err = ncsi_start_dev(umac->ncsidev);
+ if (err) {
+ netdev_err(ndev, "failed to start ncsi\n");
+ goto cleanup;
+ }
+
+ return 0;
+
+cleanup:
+ netif_tx_disable(ndev);
+ netif_carrier_off(ndev);
+ umac_channel_disable(umac);
+ napi_disable(&umac->napi);
+ umac_irq_disable(umac);
+ free_irq(ndev->irq, ndev);
+
+ umac_drop_tx(umac);
+ umac_destroy_page_pool(umac);
+
+ return err;
+}
+
+static int umac_stop(struct net_device *ndev)
+{
+ struct umac_priv *umac = netdev_priv(ndev);
+
+ netif_tx_disable(ndev);
+
+ if (umac->use_ncsi) {
+ ncsi_stop_dev(umac->ncsidev);
+ netif_carrier_off(ndev);
+ } else {
+ phylink_stop(umac->phylink);
+ phylink_disconnect_phy(umac->phylink);
+ }
+
+ cancel_work(&umac->tx_timeout_task);
+
+ napi_disable(&umac->napi);
+ umac_irq_disable(umac);
+ free_irq(ndev->irq, ndev);
+
+ umac_channel_disable(umac);
+ /*
+ * Failed TX timeout recovery leaves the device detached.
+ * Attach it again so that the interface can be brought back up.
+ */
+ netif_device_attach(ndev);
+
+ umac_drop_tx(umac);
+ umac_destroy_page_pool(umac);
+
+ return 0;
+}
+
+static void umac_tx_timeout(struct net_device *ndev, unsigned int txqueue)
+{
+ struct umac_priv *umac = netdev_priv(ndev);
+
+ schedule_work(&umac->tx_timeout_task);
+}
+
+static void umac_tx_timeout_task(struct work_struct *work)
+{
+ struct net_device *ndev;
+ struct umac_priv *umac;
+
+ umac = container_of(work, struct umac_priv, tx_timeout_task);
+ ndev = umac->ndev;
+
+ rtnl_lock();
+
+ if (!netif_running(ndev))
+ goto unlock;
+
+ mutex_lock(&umac->cfg_lock);
+
+ netdev_err(ndev, "restarting after TX timeout\n");
+ napi_disable(&umac->napi);
+ netif_tx_disable(ndev);
+ umac_irq_disable(umac);
+ umac_channel_disable(umac);
+ umac_drop_tx(umac);
+
+ umac_init_ring_descriptors(ndev);
+ if (umac_init_hw(ndev))
+ goto fail;
+
+ if (umac->link && umac_set_link(umac))
+ goto fail;
+
+ napi_enable(&umac->napi);
+ umac_irq_enable(umac);
+ napi_schedule(&umac->napi);
+
+ netif_trans_update(ndev);
+ netif_wake_queue(ndev);
+
+ mutex_unlock(&umac->cfg_lock);
+ rtnl_unlock();
+ return;
+
+fail:
+ netif_device_detach(ndev);
+ napi_enable(&umac->napi);
+ mutex_unlock(&umac->cfg_lock);
+unlock:
+ rtnl_unlock();
+}
+
+static int umac_ethtool_get_link_ksettings(struct net_device *ndev,
+ struct ethtool_link_ksettings *cmd)
+{
+ struct umac_priv *umac = netdev_priv(ndev);
+
+ if (umac->use_ncsi)
+ return -EOPNOTSUPP;
+
+ return phylink_ethtool_ksettings_get(umac->phylink, cmd);
+}
+
+static int
+umac_ethtool_set_link_ksettings(struct net_device *ndev,
+ const struct ethtool_link_ksettings *cmd)
+{
+ struct umac_priv *umac = netdev_priv(ndev);
+
+ if (umac->use_ncsi)
+ return -EOPNOTSUPP;
+
+ return phylink_ethtool_ksettings_set(umac->phylink, cmd);
+}
+
+static int umac_ethtool_nway_reset(struct net_device *ndev)
+{
+ struct umac_priv *umac = netdev_priv(ndev);
+
+ if (umac->use_ncsi)
+ return -EOPNOTSUPP;
+
+ return phylink_ethtool_nway_reset(umac->phylink);
+}
+
+static const struct ethtool_ops umac_ethtool_ops = {
+ .get_ts_info = ethtool_op_get_ts_info,
+ .get_link_ksettings = umac_ethtool_get_link_ksettings,
+ .set_link_ksettings = umac_ethtool_set_link_ksettings,
+ .nway_reset = umac_ethtool_nway_reset,
+ .get_link = ethtool_op_get_link,
+};
+
+static const struct net_device_ops umac_netdev_ops = {
+ .ndo_open = umac_open,
+ .ndo_stop = umac_stop,
+ .ndo_start_xmit = umac_start_xmit,
+ .ndo_get_stats64 = dev_get_tstats64,
+ .ndo_eth_ioctl = umac_ioctl,
+ .ndo_tx_timeout = umac_tx_timeout,
+ .ndo_validate_addr = eth_validate_addr,
+ .ndo_set_mac_address = umac_eth_mac_addr,
+ .ndo_set_rx_mode_async = umac_set_rx_mode,
+};
+
+static int umac_init_mac_address(struct net_device *ndev)
+{
+ struct umac_priv *umac = netdev_priv(ndev);
+ struct device *dev = &umac->pdev->dev;
+ int ret;
+
+ ret = of_get_ethdev_address(dev->of_node, ndev);
+ if (ret == -EPROBE_DEFER)
+ return ret;
+
+ if (ret) {
+ eth_hw_addr_random(ndev);
+ dev_warn(dev, "using random MAC address %pM\n", ndev->dev_addr);
+ }
+
+ return 0;
+}
+
+static void umac_ncsi_handler(struct ncsi_dev *ncsidev)
+{
+ if (unlikely(ncsidev->state != ncsi_dev_state_functional))
+ return;
+
+ netdev_info(ncsidev->dev, "NCSI interface %s\n",
+ ncsidev->link_up ? "up" : "down");
+}
+
+static void umac_cancel_tx_timeout(void *data)
+{
+ struct umac_priv *umac = data;
+
+ cancel_work_sync(&umac->tx_timeout_task);
+}
+
+static void umac_cleanup_phys(void *data)
+{
+ struct umac_priv *umac = data;
+
+ if (umac->phylink) {
+ phylink_destroy(umac->phylink);
+ umac->phylink = NULL;
+ }
+
+ if (umac->pcs_phy) {
+ put_device(&umac->pcs_phy->dev);
+ umac->pcs_phy = NULL;
+ }
+}
+
+static void umac_unregister_ncsi(void *data)
+{
+ struct umac_priv *umac = data;
+
+ rtnl_lock();
+ dev_close(umac->ndev);
+ netif_device_detach(umac->ndev);
+ rtnl_unlock();
+ ncsi_unregister_dev(umac->ncsidev);
+}
+
+static int umac_setup_phy(struct net_device *ndev)
+{
+ struct umac_priv *umac = netdev_priv(ndev);
+ struct device_node *pcs_np;
+ struct device_node *np;
+ int err;
+
+ np = umac->pdev->dev.of_node;
+
+ if (umac->use_ncsi) {
+ umac->speed = SPEED_100;
+ umac->duplex = DUPLEX_FULL;
+ umac->link = true;
+ return 0;
+ }
+
+ err = of_get_phy_mode(np, &umac->phy_mode);
+ if (err)
+ return err;
+
+ pcs_np = of_parse_phandle(np, "pcs-handle", 0);
+ if (!pcs_np)
+ return -EINVAL;
+
+ umac->pcs_phy = of_mdio_find_device(pcs_np);
+ of_node_put(pcs_np);
+ if (!umac->pcs_phy)
+ return -EPROBE_DEFER;
+
+ if (umac->pcs_phy->bus != umac->mii_bus &&
+ !device_link_add(&umac->pdev->dev, umac->pcs_phy->bus->parent,
+ DL_FLAG_AUTOREMOVE_CONSUMER)) {
+ put_device(&umac->pcs_phy->dev);
+ umac->pcs_phy = NULL;
+ return -EINVAL;
+ }
+
+ umac->pcs.ops = &umac_pcs_ops;
+ __set_bit(PHY_INTERFACE_MODE_SGMII, umac->pcs.supported_interfaces);
+ __set_bit(PHY_INTERFACE_MODE_SGMII,
+ umac->phylink_config.supported_interfaces);
+
+ umac->phylink_config.dev = &ndev->dev;
+ umac->phylink_config.type = PHYLINK_NETDEV;
+ umac->phylink_config.mac_capabilities = MAC_10 | MAC_100 | MAC_1000FD;
+
+ umac->phylink = phylink_create(&umac->phylink_config,
+ of_fwnode_handle(np), umac->phy_mode,
+ &umac_phylink_ops);
+
+ if (IS_ERR(umac->phylink)) {
+ err = PTR_ERR(umac->phylink);
+ umac->phylink = NULL;
+ umac_cleanup_phys(umac);
+ return err;
+ }
+
+ return 0;
+}
+
+static int umac_probe(struct platform_device *pdev)
+{
+ struct device_node *mdio_np;
+ struct net_device *ndev;
+ struct umac_priv *umac;
+ int ret;
+
+ ndev = devm_alloc_etherdev(&pdev->dev, sizeof(*umac));
+ if (!ndev)
+ return -ENOMEM;
+
+ SET_NETDEV_DEV(ndev, &pdev->dev);
+
+ umac = netdev_priv(ndev);
+ umac->pdev = pdev;
+ umac->ndev = ndev;
+ spin_lock_init(&umac->lock);
+ mutex_init(&umac->cfg_lock);
+ mutex_init(&umac->reset_lock);
+
+ umac->base = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(umac->base))
+ return PTR_ERR(umac->base);
+
+ ndev->irq = platform_get_irq(pdev, 0);
+ if (ndev->irq < 0)
+ return ndev->irq;
+
+ platform_set_drvdata(pdev, ndev);
+
+ ndev->netdev_ops = &umac_netdev_ops;
+ ndev->ethtool_ops = &umac_ethtool_ops;
+ ndev->pcpu_stat_type = NETDEV_PCPU_STAT_TSTATS;
+ ndev->max_mtu = UMAC_MAX_PAYLOAD_SIZE;
+ ndev->features |= NETIF_F_VLAN_CHALLENGED;
+
+ umac->rst =
+ devm_reset_control_get_exclusive_deasserted(&pdev->dev, NULL);
+ if (IS_ERR(umac->rst))
+ return dev_err_probe(&pdev->dev, PTR_ERR(umac->rst),
+ "failed to get reset\n");
+
+ ret = umac_init_mac_address(ndev);
+ if (ret)
+ return dev_err_probe(&pdev->dev, ret,
+ "failed to set MAC address\n");
+ umac_channel_disable(umac);
+
+ umac->use_ncsi = of_property_read_bool(pdev->dev.of_node, "use-ncsi");
+
+ ret = umac_alloc_rings(ndev);
+ if (ret)
+ return dev_err_probe(&pdev->dev, ret,
+ "failed to allocate rings\n");
+
+ ret = devm_add_action_or_reset(&pdev->dev, umac_free_rings, umac);
+ if (ret)
+ return ret;
+
+ umac->mii_bus = devm_mdiobus_alloc(&pdev->dev);
+ if (!umac->mii_bus)
+ return -ENOMEM;
+
+ umac->mii_bus->name = "gxp-umac-mdio";
+ snprintf(umac->mii_bus->id, MII_BUS_ID_SIZE, "%s",
+ dev_name(&pdev->dev));
+ umac->mii_bus->parent = &pdev->dev;
+ umac->mii_bus->priv = umac;
+ umac->mii_bus->read = umac_mdio_read;
+ umac->mii_bus->write = umac_mdio_write;
+
+ mdio_np = of_get_child_by_name(pdev->dev.of_node, "mdio");
+ ret = devm_of_mdiobus_register(&pdev->dev, umac->mii_bus, mdio_np);
+ of_node_put(mdio_np);
+ if (ret)
+ return dev_err_probe(&pdev->dev, ret,
+ "failed to register MDIO bus\n");
+
+ ret = umac_setup_phy(ndev);
+ if (ret)
+ return dev_err_probe(&pdev->dev, ret, "failed to setup PHY\n");
+
+ ret = devm_add_action_or_reset(&pdev->dev, umac_cleanup_phys, umac);
+ if (ret)
+ return ret;
+
+ netif_napi_add(ndev, &umac->napi, umac_poll);
+
+ INIT_WORK(&umac->tx_timeout_task, umac_tx_timeout_task);
+ ret = devm_add_action_or_reset(&pdev->dev, umac_cancel_tx_timeout,
+ umac);
+ if (ret)
+ return ret;
+
+ if (umac->use_ncsi) {
+ dev_info(&pdev->dev, "Using NCSI interface\n");
+ umac->ncsidev = ncsi_register_dev(ndev, umac_ncsi_handler);
+ if (!umac->ncsidev)
+ return -ENODEV;
+ }
+
+ ret = devm_register_netdev(&pdev->dev, ndev);
+ if (ret) {
+ if (umac->use_ncsi)
+ ncsi_unregister_dev(umac->ncsidev);
+ return ret;
+ }
+
+ if (umac->use_ncsi)
+ return devm_add_action_or_reset(&pdev->dev,
+ umac_unregister_ncsi, umac);
+
+ return 0;
+}
+
+static const struct of_device_id umac_of_matches[] = {
+ { .compatible = "hpe,gxp-umac" },
+ { }
+};
+MODULE_DEVICE_TABLE(of, umac_of_matches);
+
+static struct platform_driver umac_driver = {
+ .driver = {
+ .name = DRV_NAME,
+ .of_match_table = umac_of_matches,
+ },
+ .probe = umac_probe,
+};
+
+module_platform_driver(umac_driver);
+
+MODULE_AUTHOR("Michal Gorlas <michal.gorlas@9elements.com>");
+MODULE_DESCRIPTION("HPE GXP UMAC driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/net/ethernet/hpe/gxp_umac.h b/drivers/net/ethernet/hpe/gxp_umac.h
new file mode 100644
index 000000000000..284dcf177a35
--- /dev/null
+++ b/drivers/net/ethernet/hpe/gxp_umac.h
@@ -0,0 +1,117 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * HPE GXP UMAC ethernet driver
+ *
+ * Copyright (C) 2019 Hewlett Packard Enterprise Development LP.
+ * Copyright (C) 2026 9elements GmbH
+ */
+
+#ifndef _GXP_UMAC_H_
+#define _GXP_UMAC_H_
+
+#include <linux/bits.h>
+#include <linux/types.h>
+
+#define UMAC_CONFIG_STATUS 0x00
+#define UMAC_CFG_PROMISC BIT(15)
+#define UMAC_CFG_TXEN BIT(12)
+#define UMAC_CFG_RXEN BIT(11)
+#define UMAC_CFG_GTX_CLK_EN BIT(10)
+#define UMAC_CFG_TX_CLK_EN BIT(9)
+#define UMAC_CFG_GIGABIT_MODE BIT(2)
+#define UMAC_CFG_FULL_DUPLEX BIT(0)
+
+#define UMAC_RING_PTR 0x04
+#define UMAC_TX_RING_PTR_MASK GENMASK(30, 16)
+#define UMAC_RX_RING_PTR_MASK GENMASK(14, 0)
+
+#define UMAC_RING_PROMPT 0x08
+#define UMAC_CLEAR_STATUS 0x0C
+#define UMAC_CKSUM_CONFIG 0x10
+
+#define UMAC_RING_SIZE 0x14
+#define UMAC_TX_RING_SIZE_MASK GENMASK(31, 24)
+#define UMAC_RX_RING_SIZE_MASK GENMASK(23, 16)
+#define UMAC_RING_SIZE_VAL(n) ((n) / 4 - 1)
+
+#define UMAC_MAC_ADDR_HI 0x18
+#define UMAC_MAC_ADDR_MID 0x1C
+#define UMAC_MAC_ADDR_LO 0x20
+#define UMAC_MC_ADDR_FILT_HI 0x24
+#define UMAC_MC_ADDR_FILT_LO 0x28
+
+#define UMAC_CONFIG_STATUS2 0x2C
+#define UMAC_STS2_TX_IDLE BIT(16)
+#define UMAC_STS2_RX_IDLE BIT(15)
+#define UMAC_STS2_IDLE_MASK (UMAC_STS2_TX_IDLE | UMAC_STS2_RX_IDLE)
+
+#define UMAC_INTERRUPT 0x30
+#define UMAC_RX_INTEN BIT(3)
+#define UMAC_RX_INT BIT(2)
+#define UMAC_TX_INTEN BIT(1)
+#define UMAC_TX_INT BIT(0)
+
+#define UMAC_RX_RING_ADDR 0x4C
+#define UMAC_TX_RING_ADDR 0x50
+
+#define UMAC_DMA_CONFIG 0x54
+#define UMAC_DMA_CFG_BURST_SIZE 0x22
+
+#define UMAC_MDIO_MII 0x80
+#define UMAC_MDIO_PHY_ADDR GENMASK(20, 16)
+#define UMAC_MDIO_MOWNER BIT(9)
+#define UMAC_MDIO_MRNW BIT(8)
+#define UMAC_MDIO_REG_ADDR GENMASK(4, 0)
+#define UMAC_MDIO_DATA 0x84
+#define UMAC_MDIO_DATA_MASK GENMASK(15, 0)
+
+#define UMAC_MAX_TX_DESC_ENTRIES 256
+#define UMAC_MAX_RX_DESC_ENTRIES 256
+#define UMAC_MAX_RX_FRAME_SIZE 1536
+#define UMAC_RX_BUF_SIZE 2048
+
+#define UMAC_MAX_PAYLOAD_SIZE 1500
+#define UMAC_MAX_FRAME_SIZE 1514
+
+#define UMAC_TIMEOUT_US 10000
+#define UMAC_SLEEP_US 100
+
+#define UMAC_RING_ENTRY_HW_OWN BIT(15)
+#define UMAC_RING_RX_FRAME_ERR BIT(14)
+#define UMAC_RING_RX_CRC_ERR BIT(13)
+#define UMAC_RING_RX_LEN_ERR BIT(12)
+#define UMAC_RING_RX_OVERRUN BIT(11)
+#define UMAC_RING_RX_MII_ERR BIT(7)
+#define UMAC_RING_RX_CAR_EXT_ERR BIT(6)
+#define UMAC_RING_RX_BAD_PAUSE_ERR BIT(5)
+#define UMAC_RING_RX_ERR_MASK \
+ (UMAC_RING_RX_CRC_ERR | UMAC_RING_RX_LEN_ERR | UMAC_RING_RX_OVERRUN | \
+ UMAC_RING_RX_MII_ERR | UMAC_RING_RX_CAR_EXT_ERR | \
+ UMAC_RING_RX_BAD_PAUSE_ERR)
+
+struct umac_rx_desc_entry {
+ __le32 dmaaddress;
+ __le16 status;
+ __le16 count;
+ __le16 checksum;
+ __le16 control;
+ __le32 reserved;
+} __aligned(16);
+
+struct umac_rx_descs {
+ struct umac_rx_desc_entry entrylist[UMAC_MAX_RX_DESC_ENTRIES];
+};
+
+struct umac_tx_desc_entry {
+ __le32 dmaaddress;
+ __le16 status;
+ __le16 count;
+ __le32 cksumoffset;
+ __le32 reserved;
+} __aligned(16);
+
+struct umac_tx_descs {
+ struct umac_tx_desc_entry entrylist[UMAC_MAX_TX_DESC_ENTRIES];
+};
+
+#endif
--
2.56.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next 5/5] MAINTAINERS: Add HPE GXP UMAC entry
2026-12-05 22:51 [PATCH net-next 0/5] net: add HPE GXP UMAC support Michal Gorlas
` (3 preceding siblings ...)
2026-12-05 22:51 ` [PATCH net-next 4/5] net: ethernet: add HPE GXP UMAC driver Michal Gorlas
@ 2026-12-05 22:51 ` Michal Gorlas
4 siblings, 0 replies; 6+ messages in thread
From: Michal Gorlas @ 2026-12-05 22:51 UTC (permalink / raw)
To: Jean-Marie Verdun, Nick Hawkins, Philipp Zabel, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Marcello Sylvester Bauer, Russell King
Cc: Tan Siewert, devicetree, linux-kernel, netdev
Create a section for HPE GXP UMAC.
Signed-off-by: Michal Gorlas <michal.gorlas@9elements.com>
---
MAINTAINERS | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/MAINTAINERS b/MAINTAINERS
index 05b2d9e36b6d..67468e22c5d2 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -12282,6 +12282,15 @@ S: Maintained
F: Documentation/hwmon/hp-wmi-sensors.rst
F: drivers/hwmon/hp-wmi-sensors.c
+HPE GXP UMAC DRIVER
+M: Michal Gorlas <michal.gorlas@9elements.com>
+M: Marcello Sylvester Bauer <marcello.bauer@9elements.com>
+L: netdev@vger.kernel.org
+S: Maintained
+F: Documentation/devicetree/bindings/net/hpe,gxp-umac.yaml
+F: Documentation/devicetree/bindings/reset/hpe,gxp-reset.yaml
+F: drivers/net/ethernet/hpe/
+
HPET: High Precision Event Timers driver
M: Clemens Ladisch <clemens@ladisch.de>
S: Maintained
--
2.56.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-12-05 22:52 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-05 22:51 [PATCH net-next 0/5] net: add HPE GXP UMAC support Michal Gorlas
2026-12-05 22:51 ` [PATCH net-next 1/5] dt-bindings: reset: add HPE GXP reset controller Michal Gorlas
2026-12-05 22:51 ` [PATCH net-next 2/5] reset: simple: add HPE GXP support Michal Gorlas
2026-12-05 22:51 ` [PATCH net-next 3/5] dt-bindings: net: add HPE GXP UMAC Ethernet controller Michal Gorlas
2026-12-05 22:51 ` [PATCH net-next 4/5] net: ethernet: add HPE GXP UMAC driver Michal Gorlas
2026-12-05 22:51 ` [PATCH net-next 5/5] MAINTAINERS: Add HPE GXP UMAC entry Michal Gorlas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox