blob: aab6297088b092153fa789fd076ee73aef626f69 [file] [log] [blame]
developer8eb72a32023-03-30 08:32:07 +08001From ff5cdddc754c347baa757ca225e18e40d8b263a4 Mon Sep 17 00:00:00 2001
developer4a339e82022-12-12 19:00:30 +08002From: Sujuan Chen <sujuan.chen@mediatek.com>
3Date: Wed, 18 May 2022 15:10:22 +0800
developer8eb72a32023-03-30 08:32:07 +08004Subject: [PATCH 12/15] mac80211: mtk: add fill receive path ops to get wed idx
developer4a339e82022-12-12 19:00:30 +08005
6Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
7---
developer6ca17562023-03-24 17:07:44 +08008 include/net/mac80211.h | 5 +++++
developer4a339e82022-12-12 19:00:30 +08009 net/mac80211/driver-ops.h | 13 +++++++++++++
developer6ca17562023-03-24 17:07:44 +080010 net/mac80211/iface.c | 23 +++++++++++++++++++++++
developer4a339e82022-12-12 19:00:30 +080011 net/mac80211/util.c | 9 +++++++++
developer6ca17562023-03-24 17:07:44 +080012 4 files changed, 50 insertions(+)
developer4a339e82022-12-12 19:00:30 +080013
14diff --git a/include/net/mac80211.h b/include/net/mac80211.h
developer6ca17562023-03-24 17:07:44 +080015index 6e5ad3e..cc02639 100644
developer4a339e82022-12-12 19:00:30 +080016--- a/include/net/mac80211.h
17+++ b/include/net/mac80211.h
developer6ca17562023-03-24 17:07:44 +080018@@ -4207,6 +4207,8 @@ struct ieee80211_prep_tx_info {
19 * disable background CAC/radar detection.
20 * @net_fill_forward_path: Called from .ndo_fill_forward_path in order to
21 * resolve a path for hardware flow offloading
developer4a339e82022-12-12 19:00:30 +080022+ * @net_fill_receive_path: Called from .ndo_fill_receive_path in order to
23+ * get a path for hardware flow offloading
developer6ca17562023-03-24 17:07:44 +080024 * @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@@ -4570,6 +4572,9 @@ struct ieee80211_ops {
28 struct ieee80211_sta *sta,
29 struct net_device_path_ctx *ctx,
30 struct net_device_path *path);
developer4a339e82022-12-12 19:00:30 +080031+ int (*net_fill_receive_path)(struct ieee80211_hw *hw,
32+ struct net_device_path_ctx *ctx,
33+ struct net_device_path *path);
developer6ca17562023-03-24 17:07:44 +080034 int (*change_vif_links)(struct ieee80211_hw *hw,
35 struct ieee80211_vif *vif,
36 u16 old_links, u16 new_links,
developer4a339e82022-12-12 19:00:30 +080037diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h
developer6ca17562023-03-24 17:07:44 +080038index 1c3a2c9..0057535 100644
developer4a339e82022-12-12 19:00:30 +080039--- a/net/mac80211/driver-ops.h
40+++ b/net/mac80211/driver-ops.h
developer6ca17562023-03-24 17:07:44 +080041@@ -1470,6 +1470,19 @@ static inline int drv_net_fill_forward_path(struct ieee80211_local *local,
42 return ret;
43 }
developer4a339e82022-12-12 19:00:30 +080044
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+
developer6ca17562023-03-24 17:07:44 +080058 static inline int drv_net_setup_tc(struct ieee80211_local *local,
59 struct ieee80211_sub_if_data *sdata,
60 struct net_device *dev,
developer4a339e82022-12-12 19:00:30 +080061diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
developer6ca17562023-03-24 17:07:44 +080062index a18f80d..b82065c 100644
developer4a339e82022-12-12 19:00:30 +080063--- a/net/mac80211/iface.c
64+++ b/net/mac80211/iface.c
developer6ca17562023-03-24 17:07:44 +080065@@ -936,6 +936,28 @@ out:
developer4a339e82022-12-12 19:00:30 +080066 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+
developer4a339e82022-12-12 19:00:30 +080091 static const struct net_device_ops ieee80211_dataif_8023_ops = {
92 .ndo_open = ieee80211_open,
93 .ndo_stop = ieee80211_stop,
developer6ca17562023-03-24 17:07:44 +080094@@ -945,6 +967,7 @@ static const struct net_device_ops ieee80211_dataif_8023_ops = {
developer4a339e82022-12-12 19:00:30 +080095 .ndo_set_mac_address = ieee80211_change_mac,
96 .ndo_get_stats64 = ieee80211_get_stats64,
97 .ndo_fill_forward_path = ieee80211_netdev_fill_forward_path,
developer6ca17562023-03-24 17:07:44 +080098+ .ndo_fill_receive_path = ieee80211_netdev_fill_receive_path,
99 .ndo_setup_tc = ieee80211_netdev_setup_tc,
developer4a339e82022-12-12 19:00:30 +0800100 };
101
developer4a339e82022-12-12 19:00:30 +0800102diff --git a/net/mac80211/util.c b/net/mac80211/util.c
developer6ca17562023-03-24 17:07:44 +0800103index 608f927..fd63ee3 100644
developer4a339e82022-12-12 19:00:30 +0800104--- a/net/mac80211/util.c
105+++ b/net/mac80211/util.c
106@@ -914,6 +914,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--
developeraab83332023-03-07 18:17:19 +08001232.18.0
developer4a339e82022-12-12 19:00:30 +0800124