Skip to content

Commit

Permalink
net: ethernet: mtk_eth_soc: add support for configuring vlan rx offload
Browse files Browse the repository at this point in the history
Keep the vlan rx offload feature in sync across all netdevs belonging to the
device, since the feature is global and can't be turned off per MAC

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Felix Fietkau authored and Jakub Kicinski committed Nov 16, 2022
1 parent 1904870 commit 08666cb
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions drivers/net/ethernet/mediatek/mtk_eth_soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2724,15 +2724,30 @@ static netdev_features_t mtk_fix_features(struct net_device *dev,

static int mtk_set_features(struct net_device *dev, netdev_features_t features)
{
int err = 0;
struct mtk_mac *mac = netdev_priv(dev);
struct mtk_eth *eth = mac->hw;
netdev_features_t diff = dev->features ^ features;
int i;

if (!((dev->features ^ features) & NETIF_F_LRO))
if ((diff & NETIF_F_LRO) && !(features & NETIF_F_LRO))
mtk_hwlro_netdev_disable(dev);

/* Set RX VLAN offloading */
if (!(diff & NETIF_F_HW_VLAN_CTAG_RX))
return 0;

if (!(features & NETIF_F_LRO))
mtk_hwlro_netdev_disable(dev);
mtk_w32(eth, !!(features & NETIF_F_HW_VLAN_CTAG_RX),
MTK_CDMP_EG_CTRL);

return err;
/* sync features with other MAC */
for (i = 0; i < MTK_MAC_COUNT; i++) {
if (!eth->netdev[i] || eth->netdev[i] == dev)
continue;
eth->netdev[i]->features &= ~NETIF_F_HW_VLAN_CTAG_RX;
eth->netdev[i]->features |= features & NETIF_F_HW_VLAN_CTAG_RX;
}

return 0;
}

/* wait for DMA to finish whatever it is doing before we start using it again */
Expand Down

0 comments on commit 08666cb

Please sign in to comment.