1 From: David Bentham <db260179@gmail.com>
2 Date: Mon, 21 Feb 2022 15:36:16 +0100
3 Subject: [PATCH] net: ethernet: mtk_eth_soc: add ipv6 flow offload
6 Add the missing IPv6 flow offloading support for routing only.
7 Hardware flow offloading is done by the packet processing engine (PPE)
8 of the Ethernet MAC and as it doesn't support mangling of IPv6 packets,
9 IPv6 NAT cannot be supported.
11 Signed-off-by: David Bentham <db260179@gmail.com>
12 Signed-off-by: Felix Fietkau <nbd@nbd.name>
15 --- a/drivers/net/ethernet/mediatek/mtk_ppe_offload.c
16 +++ b/drivers/net/ethernet/mediatek/mtk_ppe_offload.c
18 #include <linux/if_ether.h>
19 #include <linux/rhashtable.h>
21 +#include <linux/ipv6.h>
22 #include <net/flow_offload.h>
23 #include <net/pkt_cls.h>
25 @@ -20,6 +21,11 @@ struct mtk_flow_data {
31 + struct in6_addr src_addr;
32 + struct in6_addr dst_addr;
37 @@ -65,6 +71,14 @@ mtk_flow_set_ipv4_addr(struct mtk_foe_en
38 data->v4.dst_addr, data->dst_port);
42 +mtk_flow_set_ipv6_addr(struct mtk_foe_entry *foe, struct mtk_flow_data *data)
44 + return mtk_foe_entry_set_ipv6_tuple(foe,
45 + data->v6.src_addr.s6_addr32, data->src_port,
46 + data->v6.dst_addr.s6_addr32, data->dst_port);
50 mtk_flow_offload_mangle_eth(const struct flow_action_entry *act, void *eth)
52 @@ -296,6 +310,9 @@ mtk_flow_offload_replace(struct mtk_eth
53 case FLOW_DISSECTOR_KEY_IPV4_ADDRS:
54 offload_type = MTK_PPE_PKT_TYPE_IPV4_HNAPT;
56 + case FLOW_DISSECTOR_KEY_IPV6_ADDRS:
57 + offload_type = MTK_PPE_PKT_TYPE_IPV6_ROUTE_5T;
62 @@ -331,6 +348,17 @@ mtk_flow_offload_replace(struct mtk_eth
63 mtk_flow_set_ipv4_addr(&foe, &data, false);
66 + if (addr_type == FLOW_DISSECTOR_KEY_IPV6_ADDRS) {
67 + struct flow_match_ipv6_addrs addrs;
69 + flow_rule_match_ipv6_addrs(rule, &addrs);
71 + data.v6.src_addr = addrs.key->src;
72 + data.v6.dst_addr = addrs.key->dst;
74 + mtk_flow_set_ipv6_addr(&foe, &data);
77 flow_action_for_each(i, act, &rule->action) {
78 if (act->id != FLOW_ACTION_MANGLE)