From: Karol Jurczenia 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 Reviewed-by: Cezary Rojewski Signed-off-by: Karol Jurczenia Signed-off-by: Konrad Leszczynski --- .../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 #include #include +#include #include #include #include @@ -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