Skip to content

Commit 502e84e

Browse files
nbd168davem330
authored andcommitted
net: ethernet: mtk_eth_soc: add flow offloading support
This adds support for offloading IPv4 routed flows, including SNAT/DNAT, one VLAN, PPPoE and DSA. Signed-off-by: Felix Fietkau <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ba37b7c commit 502e84e

File tree

4 files changed

+500
-2
lines changed

4 files changed

+500
-2
lines changed

drivers/net/ethernet/mediatek/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
#
55

66
obj-$(CONFIG_NET_MEDIATEK_SOC) += mtk_eth.o
7-
mtk_eth-y := mtk_eth_soc.o mtk_sgmii.o mtk_eth_path.o mtk_ppe.o mtk_ppe_debugfs.o
7+
mtk_eth-y := mtk_eth_soc.o mtk_sgmii.o mtk_eth_path.o mtk_ppe.o mtk_ppe_debugfs.o mtk_ppe_offload.o
88
obj-$(CONFIG_NET_MEDIATEK_STAR_EMAC) += mtk_star_emac.o

drivers/net/ethernet/mediatek/mtk_eth_soc.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2843,6 +2843,7 @@ static const struct net_device_ops mtk_netdev_ops = {
28432843
#ifdef CONFIG_NET_POLL_CONTROLLER
28442844
.ndo_poll_controller = mtk_poll_controller,
28452845
#endif
2846+
.ndo_setup_tc = mtk_eth_setup_tc,
28462847
};
28472848

28482849
static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)
@@ -3104,6 +3105,10 @@ static int mtk_probe(struct platform_device *pdev)
31043105
eth->base + MTK_ETH_PPE_BASE, 2);
31053106
if (err)
31063107
goto err_free_dev;
3108+
3109+
err = mtk_eth_offload_init(eth);
3110+
if (err)
3111+
goto err_free_dev;
31073112
}
31083113

31093114
for (i = 0; i < MTK_MAX_DEVS; i++) {

drivers/net/ethernet/mediatek/mtk_eth_soc.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/u64_stats_sync.h>
1616
#include <linux/refcount.h>
1717
#include <linux/phylink.h>
18+
#include <linux/rhashtable.h>
1819
#include "mtk_ppe.h"
1920

2021
#define MTK_QDMA_PAGE_SIZE 2048
@@ -41,7 +42,8 @@
4142
NETIF_F_HW_VLAN_CTAG_RX | \
4243
NETIF_F_SG | NETIF_F_TSO | \
4344
NETIF_F_TSO6 | \
44-
NETIF_F_IPV6_CSUM)
45+
NETIF_F_IPV6_CSUM |\
46+
NETIF_F_HW_TC)
4547
#define MTK_HW_FEATURES_MT7628 (NETIF_F_SG | NETIF_F_RXCSUM)
4648
#define NEXT_DESP_IDX(X, Y) (((X) + 1) & ((Y) - 1))
4749

@@ -914,6 +916,7 @@ struct mtk_eth {
914916
int ip_align;
915917

916918
struct mtk_ppe ppe;
919+
struct rhashtable flow_table;
917920
};
918921

919922
/* struct mtk_mac - the structure that holds the info about the MACs of the
@@ -958,4 +961,9 @@ int mtk_gmac_sgmii_path_setup(struct mtk_eth *eth, int mac_id);
958961
int mtk_gmac_gephy_path_setup(struct mtk_eth *eth, int mac_id);
959962
int mtk_gmac_rgmii_path_setup(struct mtk_eth *eth, int mac_id);
960963

964+
int mtk_eth_offload_init(struct mtk_eth *eth);
965+
int mtk_eth_setup_tc(struct net_device *dev, enum tc_setup_type type,
966+
void *type_data);
967+
968+
961969
#endif /* MTK_ETH_H */

0 commit comments

Comments
 (0)