developer | 0ed6672 | 2022-12-29 15:09:39 +0800 | [diff] [blame] | 1 | From 1ca2a807a8067e585e628e6eb4721e7fee00acd6 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 dd9e834..d98312e 100644 |
| 15 | --- a/include/net/mac80211.h |
| 16 | +++ b/include/net/mac80211.h |
| 17 | @@ -4188,6 +4188,8 @@ struct ieee80211_prep_tx_info { |
| 18 | * 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, |
| 26 | @@ -4546,6 +4548,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 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 | -- |
| 88 | 2.18.0 |
| 89 | |