blob: 7e8993c6af97ad9a0da8a4809a41978d0fa257d5 [file] [log] [blame]
developer43a264f2024-03-26 14:09:54 +08001From 02ac6da3f76e0da03d30d5b7b59f24190495accd Mon Sep 17 00:00:00 2001
developer79e690d2022-12-13 17:05:25 +08002From: Sujuan Chen <sujuan.chen@mediatek.com>
3Date: Wed, 18 May 2022 15:10:22 +0800
developerd243af02023-12-21 14:49:33 +08004Subject: [PATCH 09/37] mtk: mac80211: add fill receive path ops to get wed idx
developer79e690d2022-12-13 17:05:25 +08005
6Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
7---
developerd5789dc2023-03-27 11:22:06 +08008 include/net/mac80211.h | 5 +++++
developer79e690d2022-12-13 17:05:25 +08009 net/mac80211/driver-ops.h | 13 +++++++++++++
developerd5789dc2023-03-27 11:22:06 +080010 net/mac80211/iface.c | 23 +++++++++++++++++++++++
developer79e690d2022-12-13 17:05:25 +080011 net/mac80211/util.c | 9 +++++++++
developerd5789dc2023-03-27 11:22:06 +080012 4 files changed, 50 insertions(+)
developer79e690d2022-12-13 17:05:25 +080013
14diff --git a/include/net/mac80211.h b/include/net/mac80211.h
developer43a264f2024-03-26 14:09:54 +080015index dcff7af..65ba482 100644
developer79e690d2022-12-13 17:05:25 +080016--- a/include/net/mac80211.h
17+++ b/include/net/mac80211.h
developer43a264f2024-03-26 14:09:54 +080018@@ -4258,6 +4258,8 @@ struct ieee80211_prep_tx_info {
developerd5789dc2023-03-27 11:22:06 +080019 * 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
developer79e690d2022-12-13 17:05:25 +080022+ * @net_fill_receive_path: Called from .ndo_fill_receive_path in order to
23+ * get a path for hardware flow offloading
developerd5789dc2023-03-27 11:22:06 +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
developer43a264f2024-03-26 14:09:54 +080027@@ -4634,6 +4636,9 @@ struct ieee80211_ops {
developerd5789dc2023-03-27 11:22:06 +080028 struct ieee80211_sta *sta,
29 struct net_device_path_ctx *ctx,
30 struct net_device_path *path);
developer79e690d2022-12-13 17:05:25 +080031+ int (*net_fill_receive_path)(struct ieee80211_hw *hw,
32+ struct net_device_path_ctx *ctx,
33+ struct net_device_path *path);
developerd5789dc2023-03-27 11:22:06 +080034 int (*change_vif_links)(struct ieee80211_hw *hw,
35 struct ieee80211_vif *vif,
36 u16 old_links, u16 new_links,
developer79e690d2022-12-13 17:05:25 +080037diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h
developer43a264f2024-03-26 14:09:54 +080038index 7d8cec9..576f893 100644
developer79e690d2022-12-13 17:05:25 +080039--- a/net/mac80211/driver-ops.h
40+++ b/net/mac80211/driver-ops.h
developer43a264f2024-03-26 14:09:54 +080041@@ -1524,6 +1524,19 @@ static inline int drv_net_fill_forward_path(struct ieee80211_local *local,
developerd5789dc2023-03-27 11:22:06 +080042 return ret;
43 }
developer79e690d2022-12-13 17:05:25 +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+
developerd5789dc2023-03-27 11:22:06 +080058 static inline int drv_net_setup_tc(struct ieee80211_local *local,
59 struct ieee80211_sub_if_data *sdata,
60 struct net_device *dev,
developer79e690d2022-12-13 17:05:25 +080061diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
developer43a264f2024-03-26 14:09:54 +080062index 6e3bfb4..4de8d3d 100644
developer79e690d2022-12-13 17:05:25 +080063--- a/net/mac80211/iface.c
64+++ b/net/mac80211/iface.c
developere35b8e42023-10-16 11:04:00 +080065@@ -930,6 +930,28 @@ out:
developer79e690d2022-12-13 17:05:25 +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+
developer79e690d2022-12-13 17:05:25 +080091 static const struct net_device_ops ieee80211_dataif_8023_ops = {
92 .ndo_open = ieee80211_open,
93 .ndo_stop = ieee80211_stop,
developere35b8e42023-10-16 11:04:00 +080094@@ -939,6 +961,7 @@ static const struct net_device_ops ieee80211_dataif_8023_ops = {
developer79e690d2022-12-13 17:05:25 +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,
developerd5789dc2023-03-27 11:22:06 +080098+ .ndo_fill_receive_path = ieee80211_netdev_fill_receive_path,
99 .ndo_setup_tc = ieee80211_netdev_setup_tc,
developer79e690d2022-12-13 17:05:25 +0800100 };
101
developer79e690d2022-12-13 17:05:25 +0800102diff --git a/net/mac80211/util.c b/net/mac80211/util.c
developer43a264f2024-03-26 14:09:54 +0800103index 172173b..fd82488 100644
developer79e690d2022-12-13 17:05:25 +0800104--- a/net/mac80211/util.c
105+++ b/net/mac80211/util.c
developere35b8e42023-10-16 11:04:00 +0800106@@ -868,6 +868,15 @@ struct wireless_dev *ieee80211_vif_to_wdev(struct ieee80211_vif *vif)
developer79e690d2022-12-13 17:05:25 +0800107 }
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--
developerd243af02023-12-21 14:49:33 +08001232.18.0
developer79e690d2022-12-13 17:05:25 +0800124