| From cd9544a72d01f115e97b4967f416b07691196e5f 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] 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 bf4469b..3b2b2bb 100644 |
| --- a/include/net/mac80211.h |
| +++ b/include/net/mac80211.h |
| @@ -3978,6 +3978,8 @@ struct ieee80211_prep_tx_info { |
| * resolve a path for hardware flow offloading |
| * @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, |
| @@ -4316,6 +4318,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 35f1233..43f6cb0 100644 |
| --- a/net/mac80211/iface.c |
| +++ b/net/mac80211/iface.c |
| @@ -932,6 +932,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 = { |
| #if LINUX_VERSION_IS_LESS(4,10,0) |
| @@ -952,6 +976,7 @@ static const struct net_device_ops ieee80211_dataif_8023_ops = { |
| #endif |
| .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) |
| @@ -1504,6 +1529,7 @@ static void ieee80211_if_setup(struct net_device *dev) |
| dev->priv_flags &= ~IFF_TX_SKB_SHARING; |
| dev->netdev_ops = &ieee80211_dataif_ops; |
| netdev_set_priv_destructor(dev, ieee80211_if_free); |
| + dev->features |= NETIF_F_HW_TC; |
| } |
| |
| static void ieee80211_if_setup_no_queue(struct net_device *dev) |
| -- |
| 2.18.0 |
| |