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