blob: c32e2a037daade1e5d93e1ff20d04d8da6210256 [file] [log] [blame]
From a4cd8f81a63827647e88021cbcfc479f024221cb Mon Sep 17 00:00:00 2001
From: Sujuan Chen <sujuan.chen@mediatek.com>
Date: Fri, 23 Dec 2022 18:12:41 +0800
Subject: [PATCH 14/19] mac80211: mtk: register .ndo_setup_tc to support
wifi2wifi offload
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
---
include/net/mac80211.h | 5 +++++
net/mac80211/iface.c | 26 ++++++++++++++++++++++++++
2 files changed, 31 insertions(+)
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index d1d7fc3..1de9fad 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -4227,6 +4227,8 @@ struct ieee80211_prep_tx_info {
* In fact, cannot change from having valid_links and not having them.
* @net_fill_receive_path: Called from .ndo_fill_receive_path in order to
* get a path for hardware flow offloading
+ * @net_setup_tc: Called from .ndo_setup_tc in order to register flowblock
+ * callback function
*/
struct ieee80211_ops {
void (*tx)(struct ieee80211_hw *hw,
@@ -4585,6 +4587,9 @@ struct ieee80211_ops {
int (*net_fill_receive_path)(struct ieee80211_hw *hw,
struct net_device_path_ctx *ctx,
struct net_device_path *path);
+ int (*net_setup_tc)(struct ieee80211_hw *hw,
+ struct net_device *dev,
+ int type, void *type_data);
};
/**
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index 6e76b23..b80fb66 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -942,6 +942,30 @@ static int ieee80211_netdev_fill_receive_path(struct net_device_path_ctx *ctx,
return ret;
}
+static int ieee80211_netdev_setup_tc(struct net_device *dev,
+ enum tc_setup_type type, void *type_data)
+{
+ struct ieee80211_sub_if_data *sdata;
+ struct ieee80211_local *local;
+ int ret = -ENOENT;
+
+ sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+ local = sdata->local;
+
+ if (!local->ops->net_setup_tc)
+ return -EOPNOTSUPP;
+
+ if (!type_data)
+ return -EINVAL;
+
+ rcu_read_lock();
+
+ ret = local->ops->net_setup_tc(&local->hw, dev, (int)type, type_data);
+
+ rcu_read_unlock();
+
+ return ret;
+}
static const struct net_device_ops ieee80211_dataif_8023_ops = {
.ndo_open = ieee80211_open,
@@ -953,6 +977,7 @@ static const struct net_device_ops ieee80211_dataif_8023_ops = {
.ndo_get_stats64 = ieee80211_get_stats64,
.ndo_fill_forward_path = ieee80211_netdev_fill_forward_path,
.ndo_fill_receive_path = ieee80211_netdev_fill_receive_path,
+ .ndo_setup_tc = ieee80211_netdev_setup_tc,
};
static bool ieee80211_iftype_supports_hdr_offload(enum nl80211_iftype iftype)
@@ -1482,6 +1507,7 @@ static void ieee80211_if_setup(struct net_device *dev)
ether_setup(dev);
dev->priv_flags &= ~IFF_TX_SKB_SHARING;
dev->priv_flags |= IFF_NO_QUEUE;
+ dev->features |= NETIF_F_HW_TC;
dev->netdev_ops = &ieee80211_dataif_ops;
dev->needs_free_netdev = true;
dev->priv_destructor = ieee80211_if_free;
--
2.18.0