blob: 6d58e480b5750ddd3734ad189180910f375c22c9 [file] [log] [blame]
developer4eb49d92022-12-05 11:29:56 +08001From f1d42518adad5791f668a46d3cad3a5efc5f0a30 Mon Sep 17 00:00:00 2001
developerf79ad452022-07-12 11:37:54 +08002From: Sujuan Chen <sujuan.chen@mediatek.com>
3Date: Wed, 18 May 2022 15:10:22 +0800
developer4eb49d92022-12-05 11:29:56 +08004Subject: [PATCH 99901/99901] mac80211: mtk: add fill receive path ops to get
5 wed idx
developerf79ad452022-07-12 11:37:54 +08006
7Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
8---
9 include/net/mac80211.h | 12 ++++++++++++
10 net/mac80211/driver-ops.h | 13 +++++++++++++
11 net/mac80211/iface.c | 24 ++++++++++++++++++++++++
12 net/mac80211/util.c | 9 +++++++++
13 4 files changed, 58 insertions(+)
14 mode change 100644 => 100755 include/net/mac80211.h
15 mode change 100644 => 100755 net/mac80211/util.c
16
17diff --git a/include/net/mac80211.h b/include/net/mac80211.h
18old mode 100644
19new mode 100755
developer3609d782022-11-29 18:07:22 +080020index 95e5e66..9a38b9f
developerf79ad452022-07-12 11:37:54 +080021--- a/include/net/mac80211.h
22+++ b/include/net/mac80211.h
developer3609d782022-11-29 18:07:22 +080023@@ -1796,6 +1796,13 @@ struct ieee80211_vif *wdev_to_ieee80211_vif(struct wireless_dev *wdev);
developerf79ad452022-07-12 11:37:54 +080024 */
25 struct wireless_dev *ieee80211_vif_to_wdev(struct ieee80211_vif *vif);
26
27+/**
28+ * ieee80211_vif_to_wdev - return a net_device struct from a vif
29+ * @vif: the vif to get the net_device for
30+ */
31+struct net_device *ieee80211_vif_to_netdev(struct ieee80211_vif *vif);
32+
33+
34 /**
35 * enum ieee80211_key_flags - key flags
36 *
developer3609d782022-11-29 18:07:22 +080037@@ -3962,6 +3969,8 @@ struct ieee80211_prep_tx_info {
developerf79ad452022-07-12 11:37:54 +080038 * disable background CAC/radar detection.
39 * @net_fill_forward_path: Called from .ndo_fill_forward_path in order to
40 * resolve a path for hardware flow offloading
41+ * @net_fill_receive_path: Called from .ndo_fill_receive_path in order to
42+ * get a path for hardware flow offloading
43 */
44 struct ieee80211_ops {
45 void (*tx)(struct ieee80211_hw *hw,
developer3609d782022-11-29 18:07:22 +080046@@ -4297,6 +4306,9 @@ struct ieee80211_ops {
developerf79ad452022-07-12 11:37:54 +080047 struct ieee80211_sta *sta,
48 struct net_device_path_ctx *ctx,
49 struct net_device_path *path);
50+ int (*net_fill_receive_path)(struct ieee80211_hw *hw,
51+ struct net_device_path_ctx *ctx,
52+ struct net_device_path *path);
53 };
54
55 /**
56diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h
57index d2b68ef..27da75e 100644
58--- a/net/mac80211/driver-ops.h
59+++ b/net/mac80211/driver-ops.h
60@@ -1508,4 +1508,17 @@ static inline int drv_net_fill_forward_path(struct ieee80211_local *local,
61 return ret;
62 }
63
64+static inline int drv_net_fill_receive_path(struct ieee80211_local *local,
65+ struct net_device_path_ctx *ctx,
66+ struct net_device_path *path)
67+{
68+ int ret = -EOPNOTSUPP;
69+
70+ if (local->ops->net_fill_receive_path)
71+ ret = local->ops->net_fill_receive_path(&local->hw,
72+ ctx, path);
73+
74+ return ret;
75+}
76+
77 #endif /* __MAC80211_DRIVER_OPS */
78diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
developer3609d782022-11-29 18:07:22 +080079index 455791f..98b2369 100644
developerf79ad452022-07-12 11:37:54 +080080--- a/net/mac80211/iface.c
81+++ b/net/mac80211/iface.c
developer18dec8f2022-10-25 12:20:54 +080082@@ -910,6 +910,29 @@ out:
developerf79ad452022-07-12 11:37:54 +080083 return ret;
84 }
85
86+static int ieee80211_netdev_fill_receive_path(struct net_device_path_ctx *ctx,
87+ struct net_device_path *path)
88+{
89+ struct ieee80211_sub_if_data *sdata;
90+ struct ieee80211_local *local;
91+ int ret = -ENOENT;
92+
93+ sdata = IEEE80211_DEV_TO_SUB_IF(ctx->dev);
94+ local = sdata->local;
95+
96+ if (!local->ops->net_fill_receive_path)
97+ return -EOPNOTSUPP;
98+
99+ rcu_read_lock();
100+
101+ ret = drv_net_fill_receive_path(local, ctx, path);
102+
103+ rcu_read_unlock();
104+
105+ return ret;
106+}
107+
108+
109 static const struct net_device_ops ieee80211_dataif_8023_ops = {
110 #if LINUX_VERSION_IS_LESS(4,10,0)
111 .ndo_change_mtu = __change_mtu,
developer18dec8f2022-10-25 12:20:54 +0800112@@ -928,6 +951,7 @@ static const struct net_device_ops ieee80211_dataif_8023_ops = {
developerf79ad452022-07-12 11:37:54 +0800113 .ndo_get_stats64 = bp_ieee80211_get_stats64,
114 #endif
115 .ndo_fill_forward_path = ieee80211_netdev_fill_forward_path,
116+ .ndo_fill_receive_path = ieee80211_netdev_fill_receive_path,
117 };
118
119 static bool ieee80211_iftype_supports_hdr_offload(enum nl80211_iftype iftype)
120diff --git a/net/mac80211/util.c b/net/mac80211/util.c
121old mode 100644
122new mode 100755
developer3609d782022-11-29 18:07:22 +0800123index 8d36b05..d26a2b8
developerf79ad452022-07-12 11:37:54 +0800124--- a/net/mac80211/util.c
125+++ b/net/mac80211/util.c
126@@ -898,6 +898,15 @@ struct wireless_dev *ieee80211_vif_to_wdev(struct ieee80211_vif *vif)
127 }
128 EXPORT_SYMBOL_GPL(ieee80211_vif_to_wdev);
129
130+struct net_device *ieee80211_vif_to_netdev(struct ieee80211_vif *vif)
131+{
132+ if (!vif)
133+ return NULL;
134+
135+ return vif_to_sdata(vif)->dev;
136+}
137+EXPORT_SYMBOL_GPL(ieee80211_vif_to_netdev);
138+
139 /*
140 * Nothing should have been stuffed into the workqueue during
141 * the suspend->resume cycle. Since we can't check each caller
142--
developer3609d782022-11-29 18:07:22 +08001432.36.1
developerf79ad452022-07-12 11:37:54 +0800144