Subject: [PATCH 1/3] net: amd-xgbe: add hardware ARP offload support

From: Raju Rangoju <[email-masked]>
Date: Mon, 2 Feb 2026 21:05:40 +0530

Add ARP offload functionality to the XGBE driver that enables the MAC
hardware to automatically respond to ARP requests without CPU
intervention, reducing system latency and power consumption.

The XGBE MAC supports ARP offloading through:
- MAC_ARP_ADDR register (offset 0x0c10): stores the IPv4 address for
  which the hardware should respond to ARP requests
- ARPEN bit in MAC_RCR register (bit 31): enables/disables the ARP
  offload feature

When enabled, the MAC hardware will automatically generate ARP replies
for requests targeting the configured IP address, without involving
the host CPU.

The feature requires the aoe (ARP Offload Engine) hardware capability
bit (ARPOFFSEL) to be set in the MAC_HWF0R register, which is checked
before enabling.

Signed-off-by: Raju Rangoju <[email-masked]>
---
 drivers/net/ethernet/amd/xgbe/xgbe-common.h |  3 +++
 drivers/net/ethernet/amd/xgbe/xgbe-dev.c    | 24 +++++++++++++++++++++
 drivers/net/ethernet/amd/xgbe/xgbe.h        |  4 ++++
 3 files changed, 31 insertions(+)

diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-common.h b/drivers/net/ethernet/amd/xgbe/xgbe-common.h
index 62b01de93db4..af95326c6b51 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-common.h
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-common.h
@@ -210,6 +210,7 @@
 #define MAC_MACA0LR			0x0304
 #define MAC_MACA1HR			0x0308
 #define MAC_MACA1LR			0x030c
+#define MAC_ARP_ADDR			0x0c10
 #define MAC_RSSCR			0x0c80
 #define MAC_RSSAR			0x0c88
 #define MAC_RSSDR			0x0c8c
@@ -400,6 +401,8 @@
 #define MAC_RCR_RE_WIDTH		1
 #define MAC_RCR_GPSL_INDEX		16
 #define MAC_RCR_GPSL_WIDTH		14
+#define MAC_RCR_ARPEN_INDEX		31
+#define MAC_RCR_ARPEN_WIDTH		1
 #define MAC_RFCR_PFCE_INDEX		8
 #define MAC_RFCR_PFCE_WIDTH		1
 #define MAC_RFCR_RFE_INDEX		0
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-dev.c b/drivers/net/ethernet/amd/xgbe/xgbe-dev.c
index b646ae575e6a..761195911f13 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-dev.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-dev.c
@@ -3597,3 +3597,27 @@ void xgbe_disable_mac_loopback(struct xgbe_prv_data *pdata)
 	/* Disable MAC loopback mode */
 	XGMAC_IOWRITE_BITS(pdata, MAC_RCR, LM, 0);
 }
+
+/**
+ * xgbe_enable_arp_offload - Enable hardware ARP offload
+ * @pdata: pointer to driver private data
+ * @ip_addr: IPv4 address (in host byte order) to respond to ARP requests
+ *
+ * Configures the MAC to automatically respond to ARP requests for the
+ * specified IP address without CPU intervention.
+ */
+void xgbe_enable_arp_offload(struct xgbe_prv_data *pdata, u32 ip_addr)
+{
+	XGMAC_IOWRITE(pdata, MAC_ARP_ADDR, ip_addr);
+	XGMAC_IOWRITE_BITS(pdata, MAC_RCR, ARPEN, 1);
+}
+
+/**
+ * xgbe_disable_arp_offload - Disable hardware ARP offload
+ * @pdata: pointer to driver private data
+ */
+void xgbe_disable_arp_offload(struct xgbe_prv_data *pdata)
+{
+	XGMAC_IOWRITE_BITS(pdata, MAC_RCR, ARPEN, 0);
+	XGMAC_IOWRITE(pdata, MAC_ARP_ADDR, 0);
+}
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe.h b/drivers/net/ethernet/amd/xgbe/xgbe.h
index 03ef0f548483..bf08628a7ce3 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe.h
+++ b/drivers/net/ethernet/amd/xgbe/xgbe.h
@@ -1333,6 +1333,10 @@ int xgbe_selftest_get_count(struct xgbe_prv_data *pdata);
 int xgbe_enable_mac_loopback(struct xgbe_prv_data *pdata);
 void xgbe_disable_mac_loopback(struct xgbe_prv_data *pdata);
 
+/* ARP offload */
+void xgbe_enable_arp_offload(struct xgbe_prv_data *pdata, u32 ip_addr);
+void xgbe_disable_arp_offload(struct xgbe_prv_data *pdata);
+
 #ifdef CONFIG_DEBUG_FS
 void xgbe_debugfs_init(struct xgbe_prv_data *);
 void xgbe_debugfs_exit(struct xgbe_prv_data *);
-- 
2.34.1