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