7140c6877ebe6ccccf4372f72683a6ec1f70f216
[openwrt/staging/wigyori.git] /
1 --- a/drivers/net/ethernet/mediatek/mtk_ppe_offload.c
2 +++ b/drivers/net/ethernet/mediatek/mtk_ppe_offload.c
3 @@ -7,6 +7,7 @@
4 #include <linux/rhashtable.h>
5 #include <linux/if_ether.h>
6 #include <linux/ip.h>
7 +#include <linux/ipv6.h>
8 #include <net/flow_offload.h>
9 #include <net/pkt_cls.h>
10 #include <net/dsa.h>
11 @@ -20,6 +21,11 @@ struct mtk_flow_data {
12 __be32 src_addr;
13 __be32 dst_addr;
14 } v4;
15 +
16 + struct {
17 + struct in6_addr src_addr;
18 + struct in6_addr dst_addr;
19 + } v6;
20 };
21
22 __be16 src_port;
23 @@ -64,6 +70,14 @@ mtk_flow_set_ipv4_addr(struct mtk_foe_en
24 data->v4.dst_addr, data->dst_port);
25 }
26
27 +static int
28 +mtk_flow_set_ipv6_addr(struct mtk_foe_entry *foe, struct mtk_flow_data *data)
29 +{
30 + return mtk_foe_entry_set_ipv6_tuple(foe,
31 + data->v6.src_addr.s6_addr32, data->src_port,
32 + data->v6.dst_addr.s6_addr32, data->dst_port);
33 +}
34 +
35 static void
36 mtk_flow_offload_mangle_eth(const struct flow_action_entry *act, void *eth)
37 {
38 @@ -254,6 +268,9 @@ mtk_flow_offload_replace(struct mtk_eth
39 case FLOW_DISSECTOR_KEY_IPV4_ADDRS:
40 offload_type = MTK_PPE_PKT_TYPE_IPV4_HNAPT;
41 break;
42 + case FLOW_DISSECTOR_KEY_IPV6_ADDRS:
43 + offload_type = MTK_PPE_PKT_TYPE_IPV6_ROUTE_5T;
44 + break;
45 default:
46 return -EOPNOTSUPP;
47 }
48 @@ -289,6 +306,17 @@ mtk_flow_offload_replace(struct mtk_eth
49 mtk_flow_set_ipv4_addr(&foe, &data, false);
50 }
51
52 + if (addr_type == FLOW_DISSECTOR_KEY_IPV6_ADDRS) {
53 + struct flow_match_ipv6_addrs addrs;
54 +
55 + flow_rule_match_ipv6_addrs(rule, &addrs);
56 +
57 + data.v6.src_addr = addrs.key->src;
58 + data.v6.dst_addr = addrs.key->dst;
59 +
60 + mtk_flow_set_ipv6_addr(&foe, &data);
61 + }
62 +
63 flow_action_for_each(i, act, &rule->action) {
64 if (act->id != FLOW_ACTION_MANGLE)
65 continue;