developer | feeda73 | 2022-12-27 10:19:39 +0800 | [diff] [blame] | 1 | From cd9544a72d01f115e97b4967f416b07691196e5f Mon Sep 17 00:00:00 2001 |
| 2 | From: Sujuan Chen <sujuan.chen@mediatek.com> |
| 3 | Date: Fri, 23 Dec 2022 18:12:41 +0800 |
| 4 | Subject: [PATCH] mac80211: mtk: register .ndo_setup_tc to support wifi2wifi |
| 5 | offload |
| 6 | |
| 7 | Signed-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 | |
| 13 | diff --git a/include/net/mac80211.h b/include/net/mac80211.h |
| 14 | index bf4469b..3b2b2bb 100644 |
| 15 | --- a/include/net/mac80211.h |
| 16 | +++ b/include/net/mac80211.h |
| 17 | @@ -3978,6 +3978,8 @@ struct ieee80211_prep_tx_info { |
| 18 | * resolve a path for hardware flow offloading |
| 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, |
| 26 | @@ -4316,6 +4318,9 @@ struct ieee80211_ops { |
| 27 | 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 | /** |
| 36 | diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c |
| 37 | index 35f1233..43f6cb0 100644 |
| 38 | --- a/net/mac80211/iface.c |
| 39 | +++ b/net/mac80211/iface.c |
| 40 | @@ -932,6 +932,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 | #if LINUX_VERSION_IS_LESS(4,10,0) |
| 71 | @@ -952,6 +976,7 @@ static const struct net_device_ops ieee80211_dataif_8023_ops = { |
| 72 | #endif |
| 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 | @@ -1504,6 +1529,7 @@ static void ieee80211_if_setup(struct net_device *dev) |
| 80 | dev->priv_flags &= ~IFF_TX_SKB_SHARING; |
| 81 | dev->netdev_ops = &ieee80211_dataif_ops; |
| 82 | netdev_set_priv_destructor(dev, ieee80211_if_free); |
| 83 | + dev->features |= NETIF_F_HW_TC; |
| 84 | } |
| 85 | |
| 86 | static void ieee80211_if_setup_no_queue(struct net_device *dev) |
| 87 | -- |
| 88 | 2.18.0 |
| 89 | |