aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@nbd.name>2020-09-17 19:14:13 +0200
committerFelix Fietkau <nbd@nbd.name>2020-09-17 21:08:32 +0200
commit4fb58813f94ac6cc8167138e23a92189fe50b258 (patch)
treef18f793361bebd9f945e4dce3eccd88b012241c3
parent520074e57ef3eacf85ab58995d1bb39b6c8c7180 (diff)
downloadupstream-4fb58813f94ac6cc8167138e23a92189fe50b258.tar.gz
upstream-4fb58813f94ac6cc8167138e23a92189fe50b258.tar.bz2
upstream-4fb58813f94ac6cc8167138e23a92189fe50b258.zip
mediatek: fix hardware flow offload
Add support for dealing with DSA ports Signed-off-by: Felix Fietkau <nbd@nbd.name>
-rw-r--r--target/linux/generic/pending-5.4/647-net-dsa-support-hardware-flow-table-offload.patch78
-rw-r--r--target/linux/mediatek/patches-5.4/0999-hnat.patch18
2 files changed, 95 insertions, 1 deletions
diff --git a/target/linux/generic/pending-5.4/647-net-dsa-support-hardware-flow-table-offload.patch b/target/linux/generic/pending-5.4/647-net-dsa-support-hardware-flow-table-offload.patch
new file mode 100644
index 0000000000..392a37b345
--- /dev/null
+++ b/target/linux/generic/pending-5.4/647-net-dsa-support-hardware-flow-table-offload.patch
@@ -0,0 +1,78 @@
+From: Felix Fietkau <nbd@nbd.name>
+Date: Thu, 17 Sep 2020 18:41:23 +0200
+Subject: [PATCH] net: dsa: support hardware flow table offload
+
+Look up the master device and the port id
+
+Signed-off-by: Felix Fietkau <nbd@nbd.name>
+---
+
+--- a/include/net/netfilter/nf_flow_table.h
++++ b/include/net/netfilter/nf_flow_table.h
+@@ -90,6 +90,7 @@ struct flow_offload {
+ #define FLOW_OFFLOAD_PATH_ETHERNET BIT(0)
+ #define FLOW_OFFLOAD_PATH_VLAN BIT(1)
+ #define FLOW_OFFLOAD_PATH_PPPOE BIT(2)
++#define FLOW_OFFLOAD_PATH_DSA BIT(3)
+
+ struct flow_offload_hw_path {
+ struct net_device *dev;
+@@ -100,6 +101,7 @@ struct flow_offload_hw_path {
+ u16 vlan_proto;
+ u16 vlan_id;
+ u16 pppoe_sid;
++ u16 dsa_port;
+ };
+
+ #define NF_FLOW_TIMEOUT (30 * HZ)
+--- a/net/dsa/slave.c
++++ b/net/dsa/slave.c
+@@ -19,6 +19,10 @@
+ #include <linux/if_bridge.h>
+ #include <linux/netpoll.h>
+ #include <linux/ptp_classify.h>
++#if IS_ENABLED(CONFIG_NF_FLOW_TABLE)
++#include <linux/netfilter.h>
++#include <net/netfilter/nf_flow_table.h>
++#endif
+
+ #include "dsa_priv.h"
+
+@@ -1221,6 +1225,27 @@ static struct devlink_port *dsa_slave_ge
+ return dp->ds->devlink ? &dp->devlink_port : NULL;
+ }
+
++#if IS_ENABLED(CONFIG_NF_FLOW_TABLE)
++static int dsa_flow_offload_check(struct flow_offload_hw_path *path)
++{
++ struct net_device *dev = path->dev;
++ struct dsa_port *dp;
++
++ if (!(path->flags & FLOW_OFFLOAD_PATH_ETHERNET))
++ return -EINVAL;
++
++ dp = dsa_slave_to_port(dev);
++ path->dsa_port = dp->index;
++ path->dev = dsa_slave_to_master(dev);
++ path->flags |= FLOW_OFFLOAD_PATH_DSA;
++
++ if (path->dev->netdev_ops->ndo_flow_offload_check)
++ return path->dev->netdev_ops->ndo_flow_offload_check(path);
++
++ return 0;
++}
++#endif /* CONFIG_NF_FLOW_TABLE */
++
+ static const struct net_device_ops dsa_slave_netdev_ops = {
+ .ndo_open = dsa_slave_open,
+ .ndo_stop = dsa_slave_close,
+@@ -1245,6 +1270,9 @@ static const struct net_device_ops dsa_s
+ .ndo_vlan_rx_add_vid = dsa_slave_vlan_rx_add_vid,
+ .ndo_vlan_rx_kill_vid = dsa_slave_vlan_rx_kill_vid,
+ .ndo_get_devlink_port = dsa_slave_get_devlink_port,
++#if IS_ENABLED(CONFIG_NF_FLOW_TABLE)
++ .ndo_flow_offload_check = dsa_flow_offload_check,
++#endif
+ };
+
+ static struct device_type dsa_type = {
diff --git a/target/linux/mediatek/patches-5.4/0999-hnat.patch b/target/linux/mediatek/patches-5.4/0999-hnat.patch
index 685c741043..f86c882eb2 100644
--- a/target/linux/mediatek/patches-5.4/0999-hnat.patch
+++ b/target/linux/mediatek/patches-5.4/0999-hnat.patch
@@ -321,7 +321,7 @@
#endif /* MTK_ETH_H */
--- /dev/null
+++ b/drivers/net/ethernet/mediatek/mtk_offload.c
-@@ -0,0 +1,593 @@
+@@ -0,0 +1,609 @@
+/* This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License
@@ -430,6 +430,22 @@
+ }
+ }
+
++ if (dest->flags & FLOW_OFFLOAD_PATH_DSA) {
++ entry->bfib1.vlan_layer = 1;
++
++ entry->ipv4_hnapt.bfib1.vpm = 0;
++ entry->ipv4_hnapt.etype = BIT(dest->dsa_port);
++
++ if (dest->flags & FLOW_OFFLOAD_PATH_VLAN) {
++ if (dest->vlan_proto != htons(ETH_P_8021Q))
++ return -EINVAL;
++
++ entry->ipv4_hnapt.etype |= BIT(8);
++ } else {
++ entry->ipv4_hnapt.vlan1 = 0;
++ }
++ }
++
+ return 0;
+}
+