blob: 3c2cd27ba5963a96b772a903ea71ab001ccde91a [file] [log] [blame]
developer3262bf82022-07-12 11:37:54 +08001From bf39e0bef2dff4419f51b7a8bb7da3de04a38bd7 Mon Sep 17 00:00:00 2001
2From: Sujuan Chen <sujuan.chen@mediatek.com>
3Date: Wed, 18 May 2022 15:10:22 +0800
4Subject: [PATCH] add fill receive path ops to get wed idx
5
6Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
7---
8 include/net/mac80211.h | 12 ++++++++++++
9 net/mac80211/driver-ops.h | 13 +++++++++++++
10 net/mac80211/iface.c | 24 ++++++++++++++++++++++++
11 net/mac80211/util.c | 9 +++++++++
12 4 files changed, 58 insertions(+)
13 mode change 100644 => 100755 include/net/mac80211.h
14 mode change 100644 => 100755 net/mac80211/util.c
15
16diff --git a/include/net/mac80211.h b/include/net/mac80211.h
17old mode 100644
18new mode 100755
19index 1f6ddf6..17672ac
20--- a/include/net/mac80211.h
21+++ b/include/net/mac80211.h
22@@ -1791,6 +1791,13 @@ struct ieee80211_vif *wdev_to_ieee80211_vif(struct wireless_dev *wdev);
23 */
24 struct wireless_dev *ieee80211_vif_to_wdev(struct ieee80211_vif *vif);
25
26+/**
27+ * ieee80211_vif_to_wdev - return a net_device struct from a vif
28+ * @vif: the vif to get the net_device for
29+ */
30+struct net_device *ieee80211_vif_to_netdev(struct ieee80211_vif *vif);
31+
32+
33 /**
34 * enum ieee80211_key_flags - key flags
35 *
36@@ -3957,6 +3964,8 @@ struct ieee80211_prep_tx_info {
37 * disable background CAC/radar detection.
38 * @net_fill_forward_path: Called from .ndo_fill_forward_path in order to
39 * resolve a path for hardware flow offloading
40+ * @net_fill_receive_path: Called from .ndo_fill_receive_path in order to
41+ * get a path for hardware flow offloading
42 */
43 struct ieee80211_ops {
44 void (*tx)(struct ieee80211_hw *hw,
45@@ -4292,6 +4301,9 @@ struct ieee80211_ops {
46 struct ieee80211_sta *sta,
47 struct net_device_path_ctx *ctx,
48 struct net_device_path *path);
49+ int (*net_fill_receive_path)(struct ieee80211_hw *hw,
50+ struct net_device_path_ctx *ctx,
51+ struct net_device_path *path);
52 };
53
54 /**
55diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h
56index d2b68ef..27da75e 100644
57--- a/net/mac80211/driver-ops.h
58+++ b/net/mac80211/driver-ops.h
59@@ -1508,4 +1508,17 @@ static inline int drv_net_fill_forward_path(struct ieee80211_local *local,
60 return ret;
61 }
62
63+static inline int drv_net_fill_receive_path(struct ieee80211_local *local,
64+ struct net_device_path_ctx *ctx,
65+ struct net_device_path *path)
66+{
67+ int ret = -EOPNOTSUPP;
68+
69+ if (local->ops->net_fill_receive_path)
70+ ret = local->ops->net_fill_receive_path(&local->hw,
71+ ctx, path);
72+
73+ return ret;
74+}
75+
76 #endif /* __MAC80211_DRIVER_OPS */
77diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
78index 797fe24..a72bdea 100644
79--- a/net/mac80211/iface.c
80+++ b/net/mac80211/iface.c
81@@ -911,6 +911,29 @@ out:
82 return ret;
83 }
84
85+static int ieee80211_netdev_fill_receive_path(struct net_device_path_ctx *ctx,
86+ struct net_device_path *path)
87+{
88+ struct ieee80211_sub_if_data *sdata;
89+ struct ieee80211_local *local;
90+ int ret = -ENOENT;
91+
92+ sdata = IEEE80211_DEV_TO_SUB_IF(ctx->dev);
93+ local = sdata->local;
94+
95+ if (!local->ops->net_fill_receive_path)
96+ return -EOPNOTSUPP;
97+
98+ rcu_read_lock();
99+
100+ ret = drv_net_fill_receive_path(local, ctx, path);
101+
102+ rcu_read_unlock();
103+
104+ return ret;
105+}
106+
107+
108 static const struct net_device_ops ieee80211_dataif_8023_ops = {
109 #if LINUX_VERSION_IS_LESS(4,10,0)
110 .ndo_change_mtu = __change_mtu,
111@@ -929,6 +952,7 @@ static const struct net_device_ops ieee80211_dataif_8023_ops = {
112 .ndo_get_stats64 = bp_ieee80211_get_stats64,
113 #endif
114 .ndo_fill_forward_path = ieee80211_netdev_fill_forward_path,
115+ .ndo_fill_receive_path = ieee80211_netdev_fill_receive_path,
116 };
117
118 static bool ieee80211_iftype_supports_hdr_offload(enum nl80211_iftype iftype)
119diff --git a/net/mac80211/util.c b/net/mac80211/util.c
120old mode 100644
121new mode 100755
122index d85a39a..d515956
123--- a/net/mac80211/util.c
124+++ b/net/mac80211/util.c
125@@ -898,6 +898,15 @@ struct wireless_dev *ieee80211_vif_to_wdev(struct ieee80211_vif *vif)
126 }
127 EXPORT_SYMBOL_GPL(ieee80211_vif_to_wdev);
128
129+struct net_device *ieee80211_vif_to_netdev(struct ieee80211_vif *vif)
130+{
131+ if (!vif)
132+ return NULL;
133+
134+ return vif_to_sdata(vif)->dev;
135+}
136+EXPORT_SYMBOL_GPL(ieee80211_vif_to_netdev);
137+
138 /*
139 * Nothing should have been stuffed into the workqueue during
140 * the suspend->resume cycle. Since we can't check each caller
141--
1422.18.0
143