From: Karol Jurczenia <karol.jurczenia@intel.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: Konrad Leszczynski <konrad.leszczynski@intel.com>
Reviewed-by: Sebastian Basierski <sebastian.basierski@intel.com>
Signed-off-by: Karol Jurczenia <karol.jurczenia@intel.com>
---
.../net/ethernet/stmicro/stmmac/stmmac_main.c | 17 +++++++++++++++++
include/linux/stmmac.h | 1 +
2 files changed, 18 insertions(+)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 9cf7f85c10b6..e000dc7f0349 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -39,6 +39,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>
@@ -963,6 +964,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;
@@ -1075,6 +1078,20 @@ 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;
+
+ ifa = in_dev->ifa_list;
+ if (!ifa)
+ return;
+
+ stmmac_set_arp_offload(priv, priv->hw, true,
+ ntohl(ifa->ifa_address));
+ 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 26ddf95d23f9..aae522f37710 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
On Tue, Aug 26, 2025 at 01:32:44PM +0200, Konrad Leszczynski wrote:
> From: Karol Jurczenia <karol.jurczenia@intel.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: Konrad Leszczynski <konrad.leszczynski@intel.com>
> Reviewed-by: Sebastian Basierski <sebastian.basierski@intel.com>
> Signed-off-by: Karol Jurczenia <karol.jurczenia@intel.com>
Konrad,
AFAIK, as you are posting this patches, your SoB line needs to go here.
(And correspondingly, your Reviewed-by line should be removed.)
...
> @@ -1075,6 +1078,20 @@ 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;
> +
> + ifa = in_dev->ifa_list;
ifa_list is protected by RCU, so I think the code needs to take that into
account. E.g. by doing the following and making sure that the RCU read lock
is held.
ifa = rcu_dereference(idev->ifa_list);
Flagged by Sparse.
> + if (!ifa)
> + return;
> +
> + stmmac_set_arp_offload(priv, priv->hw, true,
> + ntohl(ifa->ifa_address));
> + 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 26ddf95d23f9..aae522f37710 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)
I see that the following patch in this series also makes use of this bit.
But I don't see any thing (platform) that sets this bit. Perhaps I'm
missing something. But I think that would be best included in the patchset
that adds this bit.
>
> struct plat_stmmacenet_data {
> int bus_id;
> --
> 2.34.1
>
>
Hi Konrad, kernel test robot noticed the following build errors: [auto build test ERROR on net-next/main] url: https://github.com/intel-lab-lkp/linux/commits/Konrad-Leszczynski/net-stmmac-replace-memcpy-with-strscpy-in-ethtool/20250826-193732 base: net-next/main patch link: https://lore.kernel.org/r/20250826113247.3481273-5-konrad.leszczynski%40intel.com patch subject: [PATCH net-next 4/7] net: stmmac: enable ARP Offload on mac_link_up() config: arm-randconfig-004-20250826 (https://download.01.org/0day-ci/archive/20250827/202508270007.sExKFhrN-lkp@intel.com/config) compiler: arm-linux-gnueabi-gcc (GCC) 10.5.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250827/202508270007.sExKFhrN-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202508270007.sExKFhrN-lkp@intel.com/ All errors (new ones prefixed by >>, old ones prefixed by <<): >> ERROR: modpost: "in_dev_finish_destroy" [drivers/net/ethernet/stmicro/stmmac/stmmac.ko] undefined! -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
© 2016 - 2026 Red Hat, Inc.