lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250828144558.304304-2-konrad.leszczynski@intel.com>
Date: Thu, 28 Aug 2025 16:45:55 +0200
From: Konrad Leszczynski <konrad.leszczynski@...el.com>
To: davem@...emloft.net,
	andrew+netdev@...n.ch,
	edumazet@...gle.com,
	kuba@...nel.org,
	pabeni@...hat.com
Cc: netdev@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	cezary.rojewski@...el.com,
	sebastian.basierski@...el.com,
	Karol Jurczenia <karol.jurczenia@...el.com>,
	Konrad Leszczynski <konrad.leszczynski@...el.com>
Subject: [PATCH net-next 1/4] net: stmmac: enable ARP Offload on mac_link_up()

From: Karol Jurczenia <karol.jurczenia@...el.com>

Add Address Resolution Protocol (ARP) Offload support in
stmmac_mac_link_up() to enable ARP Offload beside the selftests.

Introduce STMMAC_FLAG_ARP_OFFLOAD_EN flag, which is used to enable the
feature with the stmmac_set_arp_offload().

Reviewed-by: Sebastian Basierski <sebastian.basierski@...el.com>
Reviewed-by: Cezary Rojewski <cezary.rojewski@...el.com>
Signed-off-by: Karol Jurczenia <karol.jurczenia@...el.com>
Signed-off-by: Konrad Leszczynski <konrad.leszczynski@...el.com>
---
 .../net/ethernet/stmicro/stmmac/stmmac_main.c  | 18 ++++++++++++++++++
 include/linux/stmmac.h                         |  1 +
 2 files changed, 19 insertions(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index fa3d26c28502..244ef484bb88 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -40,6 +40,7 @@
 #include <linux/phylink.h>
 #include <linux/udp.h>
 #include <linux/bpf_trace.h>
+#include <linux/inetdevice.h>
 #include <net/page_pool/helpers.h>
 #include <net/pkt_cls.h>
 #include <net/xdp_sock_drv.h>
@@ -964,6 +965,8 @@ static void stmmac_mac_link_up(struct phylink_config *config,
 			       bool tx_pause, bool rx_pause)
 {
 	struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev));
+	struct in_device *in_dev;
+	struct in_ifaddr *ifa;
 	unsigned int flow_ctrl;
 	u32 old_ctrl, ctrl;
 	int ret;
@@ -1076,6 +1079,21 @@ static void stmmac_mac_link_up(struct phylink_config *config,
 
 	if (priv->plat->flags & STMMAC_FLAG_HWTSTAMP_CORRECT_LATENCY)
 		stmmac_hwtstamp_correct_latency(priv, priv);
+
+	if (priv->plat->flags & STMMAC_FLAG_ARP_OFFLOAD_EN) {
+		in_dev = in_dev_get(priv->dev);
+		if (!in_dev)
+			return;
+
+		rcu_read_lock();
+		ifa = rcu_dereference(in_dev->ifa_list);
+		if (ifa)
+			stmmac_set_arp_offload(priv, priv->hw, true,
+					       ntohl(ifa->ifa_address));
+		rcu_read_unlock();
+
+		__in_dev_put(in_dev);
+	}
 }
 
 static void stmmac_mac_disable_tx_lpi(struct phylink_config *config)
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index e284f04964bf..afb45d8eb840 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -185,6 +185,7 @@ struct dwmac4_addrs {
 #define STMMAC_FLAG_EN_TX_LPI_CLOCKGATING	BIT(11)
 #define STMMAC_FLAG_EN_TX_LPI_CLK_PHY_CAP	BIT(12)
 #define STMMAC_FLAG_HWTSTAMP_CORRECT_LATENCY	BIT(13)
+#define STMMAC_FLAG_ARP_OFFLOAD_EN		BIT(14)
 
 struct plat_stmmacenet_data {
 	int bus_id;
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ