blob: c32e2a037daade1e5d93e1ff20d04d8da6210256 [file] [log] [blame]
developeraab83332023-03-07 18:17:19 +08001From a4cd8f81a63827647e88021cbcfc479f024221cb Mon Sep 17 00:00:00 2001
developer0ed66722022-12-29 15:09:39 +08002From: Sujuan Chen <sujuan.chen@mediatek.com>
3Date: Fri, 23 Dec 2022 18:12:41 +0800
developeraab83332023-03-07 18:17:19 +08004Subject: [PATCH 14/19] mac80211: mtk: register .ndo_setup_tc to support
developer1413c882023-02-15 00:01:06 +08005 wifi2wifi offload
developer0ed66722022-12-29 15:09:39 +08006
7Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
8---
9 include/net/mac80211.h | 5 +++++
10 net/mac80211/iface.c | 26 ++++++++++++++++++++++++++
11 2 files changed, 31 insertions(+)
12
13diff --git a/include/net/mac80211.h b/include/net/mac80211.h
developeraab83332023-03-07 18:17:19 +080014index d1d7fc3..1de9fad 100644
developer0ed66722022-12-29 15:09:39 +080015--- a/include/net/mac80211.h
16+++ b/include/net/mac80211.h
developeraab83332023-03-07 18:17:19 +080017@@ -4227,6 +4227,8 @@ struct ieee80211_prep_tx_info {
developer0ed66722022-12-29 15:09:39 +080018 * In fact, cannot change from having valid_links and not having them.
19 * @net_fill_receive_path: Called from .ndo_fill_receive_path in order to
20 * get a path for hardware flow offloading
21+ * @net_setup_tc: Called from .ndo_setup_tc in order to register flowblock
22+ * callback function
23 */
24 struct ieee80211_ops {
25 void (*tx)(struct ieee80211_hw *hw,
developeraab83332023-03-07 18:17:19 +080026@@ -4585,6 +4587,9 @@ struct ieee80211_ops {
developer0ed66722022-12-29 15:09:39 +080027 int (*net_fill_receive_path)(struct ieee80211_hw *hw,
28 struct net_device_path_ctx *ctx,
29 struct net_device_path *path);
30+ int (*net_setup_tc)(struct ieee80211_hw *hw,
31+ struct net_device *dev,
32+ int type, void *type_data);
33 };
34
35 /**
36diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
37index 6e76b23..b80fb66 100644
38--- a/net/mac80211/iface.c
39+++ b/net/mac80211/iface.c
40@@ -942,6 +942,30 @@ static int ieee80211_netdev_fill_receive_path(struct net_device_path_ctx *ctx,
41 return ret;
42 }
43
44+static int ieee80211_netdev_setup_tc(struct net_device *dev,
45+ enum tc_setup_type type, void *type_data)
46+{
47+ struct ieee80211_sub_if_data *sdata;
48+ struct ieee80211_local *local;
49+ int ret = -ENOENT;
50+
51+ sdata = IEEE80211_DEV_TO_SUB_IF(dev);
52+ local = sdata->local;
53+
54+ if (!local->ops->net_setup_tc)
55+ return -EOPNOTSUPP;
56+
57+ if (!type_data)
58+ return -EINVAL;
59+
60+ rcu_read_lock();
61+
62+ ret = local->ops->net_setup_tc(&local->hw, dev, (int)type, type_data);
63+
64+ rcu_read_unlock();
65+
66+ return ret;
67+}
68
69 static const struct net_device_ops ieee80211_dataif_8023_ops = {
70 .ndo_open = ieee80211_open,
71@@ -953,6 +977,7 @@ static const struct net_device_ops ieee80211_dataif_8023_ops = {
72 .ndo_get_stats64 = ieee80211_get_stats64,
73 .ndo_fill_forward_path = ieee80211_netdev_fill_forward_path,
74 .ndo_fill_receive_path = ieee80211_netdev_fill_receive_path,
75+ .ndo_setup_tc = ieee80211_netdev_setup_tc,
76 };
77
78 static bool ieee80211_iftype_supports_hdr_offload(enum nl80211_iftype iftype)
79@@ -1482,6 +1507,7 @@ static void ieee80211_if_setup(struct net_device *dev)
80 ether_setup(dev);
81 dev->priv_flags &= ~IFF_TX_SKB_SHARING;
82 dev->priv_flags |= IFF_NO_QUEUE;
83+ dev->features |= NETIF_F_HW_TC;
84 dev->netdev_ops = &ieee80211_dataif_ops;
85 dev->needs_free_netdev = true;
86 dev->priv_destructor = ieee80211_if_free;
87--
developeraab83332023-03-07 18:17:19 +0800882.18.0
developer0ed66722022-12-29 15:09:39 +080089