blob: 15214709d28093725ea1b626aa0ec0fef335ea90 [file] [log] [blame]
developer66e89bc2024-04-23 14:50:01 +08001From 5c16c13e56474ee77a9bd8ea59aeaeaae8923ea8 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 15/61] mtk: mac80211: add fill receive path ops to get wed idx
5
6Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
developer66e89bc2024-04-23 14:50:01 +08007---
8 include/net/mac80211.h | 5 +++++
9 net/mac80211/driver-ops.h | 13 +++++++++++++
10 net/mac80211/iface.c | 23 +++++++++++++++++++++++
11 net/mac80211/util.c | 9 +++++++++
12 4 files changed, 50 insertions(+)
13
14diff --git a/include/net/mac80211.h b/include/net/mac80211.h
15index 8cda233..01cfcc0 100644
16--- a/include/net/mac80211.h
17+++ b/include/net/mac80211.h
18@@ -4390,6 +4390,8 @@ struct ieee80211_prep_tx_info {
19 * resolve a path for hardware flow offloading
20 * @can_activate_links: Checks if a specific active_links bitmap is
21 * supported by the driver.
22+ * @net_fill_receive_path: Called from .ndo_fill_receive_path in order to
23+ * get a path for hardware flow offloading
24 * @change_vif_links: Change the valid links on an interface, note that while
25 * removing the old link information is still valid (link_conf pointer),
26 * but may immediately disappear after the function returns. The old or
27@@ -4778,6 +4780,9 @@ struct ieee80211_ops {
28 bool (*can_activate_links)(struct ieee80211_hw *hw,
29 struct ieee80211_vif *vif,
30 u16 active_links);
31+ int (*net_fill_receive_path)(struct ieee80211_hw *hw,
32+ struct net_device_path_ctx *ctx,
33+ struct net_device_path *path);
34 int (*change_vif_links)(struct ieee80211_hw *hw,
35 struct ieee80211_vif *vif,
36 u16 old_links, u16 new_links,
37diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h
38index 1eda9ec..9be87b8 100644
39--- a/net/mac80211/driver-ops.h
40+++ b/net/mac80211/driver-ops.h
41@@ -1649,6 +1649,19 @@ static inline int drv_net_fill_forward_path(struct ieee80211_local *local,
42 return ret;
43 }
44
45+static inline int drv_net_fill_receive_path(struct ieee80211_local *local,
46+ struct net_device_path_ctx *ctx,
47+ struct net_device_path *path)
48+{
49+ int ret = -EOPNOTSUPP;
50+
51+ if (local->ops->net_fill_receive_path)
52+ ret = local->ops->net_fill_receive_path(&local->hw,
53+ ctx, path);
54+
55+ return ret;
56+}
57+
58 static inline int drv_net_setup_tc(struct ieee80211_local *local,
59 struct ieee80211_sub_if_data *sdata,
60 struct net_device *dev,
61diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
62index 6363e8c..0ae31a9 100644
63--- a/net/mac80211/iface.c
64+++ b/net/mac80211/iface.c
65@@ -988,6 +988,28 @@ out:
66 return ret;
67 }
68
69+static int ieee80211_netdev_fill_receive_path(struct net_device_path_ctx *ctx,
70+ struct net_device_path *path)
71+{
72+ struct ieee80211_sub_if_data *sdata;
73+ struct ieee80211_local *local;
74+ int ret = -ENOENT;
75+
76+ sdata = IEEE80211_DEV_TO_SUB_IF(ctx->dev);
77+ local = sdata->local;
78+
79+ if (!local->ops->net_fill_receive_path)
80+ return -EOPNOTSUPP;
81+
82+ rcu_read_lock();
83+
84+ ret = drv_net_fill_receive_path(local, ctx, path);
85+
86+ rcu_read_unlock();
87+
88+ return ret;
89+}
90+
91 static const struct net_device_ops ieee80211_dataif_8023_ops = {
92 #if LINUX_VERSION_IS_LESS(4,10,0)
93 .ndo_change_mtu = __change_mtu,
94@@ -1006,6 +1028,7 @@ static const struct net_device_ops ieee80211_dataif_8023_ops = {
95 #endif
96
97 .ndo_fill_forward_path = ieee80211_netdev_fill_forward_path,
98+ .ndo_fill_receive_path = ieee80211_netdev_fill_receive_path,
99 .ndo_setup_tc = ieee80211_netdev_setup_tc,
100 };
101
102diff --git a/net/mac80211/util.c b/net/mac80211/util.c
103index cda398d..dd06bd2 100644
104--- a/net/mac80211/util.c
105+++ b/net/mac80211/util.c
106@@ -874,6 +874,15 @@ struct wireless_dev *ieee80211_vif_to_wdev(struct ieee80211_vif *vif)
107 }
108 EXPORT_SYMBOL_GPL(ieee80211_vif_to_wdev);
109
110+struct net_device *ieee80211_vif_to_netdev(struct ieee80211_vif *vif)
111+{
112+ if (!vif)
113+ return NULL;
114+
115+ return vif_to_sdata(vif)->dev;
116+}
117+EXPORT_SYMBOL_GPL(ieee80211_vif_to_netdev);
118+
119 /*
120 * Nothing should have been stuffed into the workqueue during
121 * the suspend->resume cycle. Since we can't check each caller
122--
1232.39.2
124