Skip to content

Commit 817b2fd

Browse files
db260179davem330
authored andcommitted
net: ethernet: mtk_eth_soc: add ipv6 flow offload support
Add the missing IPv6 flow offloading support for routing only. Hardware flow offloading is done by the packet processing engine (PPE) of the Ethernet MAC and as it doesn't support mangling of IPv6 packets, IPv6 NAT cannot be supported. Signed-off-by: David Bentham <[email protected]> Signed-off-by: Felix Fietkau <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e9b65ec commit 817b2fd

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

drivers/net/ethernet/mediatek/mtk_ppe_offload.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <linux/if_ether.h>
77
#include <linux/rhashtable.h>
88
#include <linux/ip.h>
9+
#include <linux/ipv6.h>
910
#include <net/flow_offload.h>
1011
#include <net/pkt_cls.h>
1112
#include <net/dsa.h>
@@ -20,6 +21,11 @@ struct mtk_flow_data {
2021
__be32 src_addr;
2122
__be32 dst_addr;
2223
} v4;
24+
25+
struct {
26+
struct in6_addr src_addr;
27+
struct in6_addr dst_addr;
28+
} v6;
2329
};
2430

2531
__be16 src_port;
@@ -65,6 +71,14 @@ mtk_flow_set_ipv4_addr(struct mtk_foe_entry *foe, struct mtk_flow_data *data,
6571
data->v4.dst_addr, data->dst_port);
6672
}
6773

74+
static int
75+
mtk_flow_set_ipv6_addr(struct mtk_foe_entry *foe, struct mtk_flow_data *data)
76+
{
77+
return mtk_foe_entry_set_ipv6_tuple(foe,
78+
data->v6.src_addr.s6_addr32, data->src_port,
79+
data->v6.dst_addr.s6_addr32, data->dst_port);
80+
}
81+
6882
static void
6983
mtk_flow_offload_mangle_eth(const struct flow_action_entry *act, void *eth)
7084
{
@@ -296,6 +310,9 @@ mtk_flow_offload_replace(struct mtk_eth *eth, struct flow_cls_offload *f)
296310
case FLOW_DISSECTOR_KEY_IPV4_ADDRS:
297311
offload_type = MTK_PPE_PKT_TYPE_IPV4_HNAPT;
298312
break;
313+
case FLOW_DISSECTOR_KEY_IPV6_ADDRS:
314+
offload_type = MTK_PPE_PKT_TYPE_IPV6_ROUTE_5T;
315+
break;
299316
default:
300317
return -EOPNOTSUPP;
301318
}
@@ -331,6 +348,17 @@ mtk_flow_offload_replace(struct mtk_eth *eth, struct flow_cls_offload *f)
331348
mtk_flow_set_ipv4_addr(&foe, &data, false);
332349
}
333350

351+
if (addr_type == FLOW_DISSECTOR_KEY_IPV6_ADDRS) {
352+
struct flow_match_ipv6_addrs addrs;
353+
354+
flow_rule_match_ipv6_addrs(rule, &addrs);
355+
356+
data.v6.src_addr = addrs.key->src;
357+
data.v6.dst_addr = addrs.key->dst;
358+
359+
mtk_flow_set_ipv6_addr(&foe, &data);
360+
}
361+
334362
flow_action_for_each(i, act, &rule->action) {
335363
if (act->id != FLOW_ACTION_MANGLE)
336364
continue;

0 commit comments

Comments
 (0)