Commit 08666cbb authored by Felix Fietkau's avatar Felix Fietkau Committed by Jakub Kicinski
Browse files

net: ethernet: mtk_eth_soc: add support for configuring vlan rx offload



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: default avatarFelix Fietkau <nbd@nbd.name>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 19048703
Loading
Loading
Loading
Loading
+20 −5
Original line number Diff line number Diff line
@@ -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 */