blob: cfcc28af3eea0dfc3013097b618dc825951a8e39 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001From: Felix Fietkau <nbd@nbd.name>
2Date: Thu, 15 Mar 2018 20:49:58 +0100
3Subject: [PATCH] net: 8021q: support hardware flow table offload
4
5Add the VLAN ID and protocol information
6
7Signed-off-by: Felix Fietkau <nbd@nbd.name>
8---
9
10--- a/net/8021q/vlan_dev.c
11+++ b/net/8021q/vlan_dev.c
12@@ -27,6 +27,11 @@
13 #include <linux/phy.h>
14 #include <net/arp.h>
15
16+#if IS_ENABLED(CONFIG_NF_FLOW_TABLE)
17+#include <linux/netfilter.h>
18+#include <net/netfilter/nf_flow_table.h>
19+#endif
20+
21 #include "vlan.h"
22 #include "vlanproc.h"
23 #include <linux/if_vlan.h>
24@@ -747,6 +752,27 @@ static int vlan_dev_get_iflink(const str
25 return real_dev->ifindex;
26 }
27
28+#if IS_ENABLED(CONFIG_NF_FLOW_TABLE)
29+static int vlan_dev_flow_offload_check(struct flow_offload_hw_path *path)
30+{
31+ struct net_device *dev = path->dev;
32+ struct vlan_dev_priv *vlan = vlan_dev_priv(dev);
33+
34+ if (path->flags & FLOW_OFFLOAD_PATH_VLAN)
35+ return -EEXIST;
36+
37+ path->flags |= FLOW_OFFLOAD_PATH_VLAN;
38+ path->vlan_proto = vlan->vlan_proto;
39+ path->vlan_id = vlan->vlan_id;
40+ path->dev = vlan->real_dev;
41+
42+ if (vlan->real_dev->netdev_ops->ndo_flow_offload_check)
43+ return vlan->real_dev->netdev_ops->ndo_flow_offload_check(path);
44+
45+ return 0;
46+}
47+#endif /* CONFIG_NF_FLOW_TABLE */
48+
49 static const struct ethtool_ops vlan_ethtool_ops = {
50 .get_link_ksettings = vlan_ethtool_get_link_ksettings,
51 .get_drvinfo = vlan_ethtool_get_drvinfo,
52@@ -785,6 +811,9 @@ static const struct net_device_ops vlan_
53 #endif
54 .ndo_fix_features = vlan_dev_fix_features,
55 .ndo_get_iflink = vlan_dev_get_iflink,
56+#if IS_ENABLED(CONFIG_NF_FLOW_TABLE)
57+ .ndo_flow_offload_check = vlan_dev_flow_offload_check,
58+#endif
59 };
60
61 static void vlan_dev_free(struct net_device *dev)