blob: a87a9ea9dbd2d97b6613eea02c65883ace9b10f8 [file] [log] [blame]
developer42c7a432024-07-12 14:39:29 +08001From e5612cde83ef67f8fa4633f7d364e05bac6e02a3 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
developer42c7a432024-07-12 14:39:29 +08004Subject: [PATCH 9901/9902] mac80211: mtk: add fill receive path ops to get wed
developer8effbd32023-04-17 15:57:28 +08005 idx
developerf79ad452022-07-12 11:37:54 +08006
7Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
8---
9 include/net/mac80211.h | 12 ++++++++++++
developer42c7a432024-07-12 14:39:29 +080010 net/mac80211/driver-ops.h | 14 +++++++++++++-
developerf79ad452022-07-12 11:37:54 +080011 net/mac80211/iface.c | 24 ++++++++++++++++++++++++
12 net/mac80211/util.c | 9 +++++++++
developer42c7a432024-07-12 14:39:29 +080013 4 files changed, 58 insertions(+), 1 deletion(-)
developerf79ad452022-07-12 11:37:54 +080014 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
developer42c7a432024-07-12 14:39:29 +080020index c6625c2..cb8b28d
developerf79ad452022-07-12 11:37:54 +080021--- a/include/net/mac80211.h
22+++ b/include/net/mac80211.h
developer8effbd32023-04-17 15:57:28 +080023@@ -1798,6 +1798,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 *
developer42c7a432024-07-12 14:39:29 +080037@@ -3982,6 +3989,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
developer42c7a432024-07-12 14:39:29 +080043 * @set_qos_map: Set QoS mapping information to driver.
developerf79ad452022-07-12 11:37:54 +080044 */
45 struct ieee80211_ops {
developer42c7a432024-07-12 14:39:29 +080046@@ -4320,6 +4329,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);
developer42c7a432024-07-12 14:39:29 +080053 int (*set_qos_map)(struct ieee80211_vif *vif,
54 struct cfg80211_qos_map *qos_map);
developerf79ad452022-07-12 11:37:54 +080055 };
developerf79ad452022-07-12 11:37:54 +080056diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h
developer42c7a432024-07-12 14:39:29 +080057index 91ea8b2..348f815 100644
developerf79ad452022-07-12 11:37:54 +080058--- a/net/mac80211/driver-ops.h
59+++ b/net/mac80211/driver-ops.h
developer42c7a432024-07-12 14:39:29 +080060@@ -1523,6 +1523,19 @@ static inline int drv_net_fill_forward_path(struct ieee80211_local *local,
developerf79ad452022-07-12 11:37:54 +080061 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+
developer42c7a432024-07-12 14:39:29 +080077 static inline int drv_set_qos_map(struct ieee80211_local *local,
78 struct ieee80211_sub_if_data *sdata,
79 struct cfg80211_qos_map *qos_map)
80@@ -1538,5 +1551,4 @@ static inline int drv_set_qos_map(struct ieee80211_local *local,
81
82 return ret;
83 }
84-
developerf79ad452022-07-12 11:37:54 +080085 #endif /* __MAC80211_DRIVER_OPS */
86diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
developer42c7a432024-07-12 14:39:29 +080087index 4b92867..c08bfbe 100644
developerf79ad452022-07-12 11:37:54 +080088--- a/net/mac80211/iface.c
89+++ b/net/mac80211/iface.c
developer42c7a432024-07-12 14:39:29 +080090@@ -933,6 +933,29 @@ out:
developerf79ad452022-07-12 11:37:54 +080091 return ret;
92 }
93
94+static int ieee80211_netdev_fill_receive_path(struct net_device_path_ctx *ctx,
95+ struct net_device_path *path)
96+{
97+ struct ieee80211_sub_if_data *sdata;
98+ struct ieee80211_local *local;
99+ int ret = -ENOENT;
100+
101+ sdata = IEEE80211_DEV_TO_SUB_IF(ctx->dev);
102+ local = sdata->local;
103+
104+ if (!local->ops->net_fill_receive_path)
105+ return -EOPNOTSUPP;
106+
107+ rcu_read_lock();
108+
109+ ret = drv_net_fill_receive_path(local, ctx, path);
110+
111+ rcu_read_unlock();
112+
113+ return ret;
114+}
115+
116+
117 static const struct net_device_ops ieee80211_dataif_8023_ops = {
118 #if LINUX_VERSION_IS_LESS(4,10,0)
119 .ndo_change_mtu = __change_mtu,
developer42c7a432024-07-12 14:39:29 +0800120@@ -951,6 +974,7 @@ static const struct net_device_ops ieee80211_dataif_8023_ops = {
developerf79ad452022-07-12 11:37:54 +0800121 .ndo_get_stats64 = bp_ieee80211_get_stats64,
122 #endif
123 .ndo_fill_forward_path = ieee80211_netdev_fill_forward_path,
124+ .ndo_fill_receive_path = ieee80211_netdev_fill_receive_path,
125 };
126
127 static bool ieee80211_iftype_supports_hdr_offload(enum nl80211_iftype iftype)
128diff --git a/net/mac80211/util.c b/net/mac80211/util.c
129old mode 100644
130new mode 100755
developer42c7a432024-07-12 14:39:29 +0800131index e07fe73..809eb37
developerf79ad452022-07-12 11:37:54 +0800132--- a/net/mac80211/util.c
133+++ b/net/mac80211/util.c
134@@ -898,6 +898,15 @@ struct wireless_dev *ieee80211_vif_to_wdev(struct ieee80211_vif *vif)
135 }
136 EXPORT_SYMBOL_GPL(ieee80211_vif_to_wdev);
137
138+struct net_device *ieee80211_vif_to_netdev(struct ieee80211_vif *vif)
139+{
140+ if (!vif)
141+ return NULL;
142+
143+ return vif_to_sdata(vif)->dev;
144+}
145+EXPORT_SYMBOL_GPL(ieee80211_vif_to_netdev);
146+
147 /*
148 * Nothing should have been stuffed into the workqueue during
149 * the suspend->resume cycle. Since we can't check each caller
150--
developer8effbd32023-04-17 15:57:28 +08001512.18.0
developerf79ad452022-07-12 11:37:54 +0800152