developer | e0cba19 | 2023-07-28 07:08:38 +0800 | [diff] [blame^] | 1 | From fdc7f27785b716eae1e02df73c095ecfe2677d9f Mon Sep 17 00:00:00 2001 |
developer | d5c8ff1 | 2023-03-28 11:56:21 +0800 | [diff] [blame] | 2 | From: Sujuan Chen <sujuan.chen@mediatek.com> |
| 3 | Date: Tue, 28 Mar 2023 10:53:31 +0800 |
developer | e0cba19 | 2023-07-28 07:08:38 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 9902/9903] mac80211: mtk: add support for letting drivers |
developer | ed7222c | 2023-04-14 07:19:52 +0800 | [diff] [blame] | 5 | register tc offload support |
developer | d5c8ff1 | 2023-03-28 11:56:21 +0800 | [diff] [blame] | 6 | |
| 7 | On newer MediaTek SoCs (e.g. MT7986), WLAN->WLAN or WLAN->Ethernet flows can |
| 8 | be offloaded by the SoC. In order to support that, the .ndo_setup_tc op is |
| 9 | needed. |
| 10 | |
| 11 | Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com> |
| 12 | --- |
| 13 | include/net/mac80211.h | 9 +++++++++ |
| 14 | net/mac80211/driver-ops.h | 17 +++++++++++++++++ |
| 15 | net/mac80211/ieee80211_i.h | 3 ++- |
| 16 | net/mac80211/iface.c | 17 +++++++++++++++++ |
| 17 | net/mac80211/trace.h | 25 +++++++++++++++++++++++++ |
| 18 | 5 files changed, 70 insertions(+), 1 deletion(-) |
| 19 | |
| 20 | diff --git a/include/net/mac80211.h b/include/net/mac80211.h |
developer | e0cba19 | 2023-07-28 07:08:38 +0800 | [diff] [blame^] | 21 | index 8a71026..861bc9a 100755 |
developer | d5c8ff1 | 2023-03-28 11:56:21 +0800 | [diff] [blame] | 22 | --- a/include/net/mac80211.h |
| 23 | +++ b/include/net/mac80211.h |
developer | ed7222c | 2023-04-14 07:19:52 +0800 | [diff] [blame] | 24 | @@ -3984,6 +3984,10 @@ struct ieee80211_prep_tx_info { |
developer | d5c8ff1 | 2023-03-28 11:56:21 +0800 | [diff] [blame] | 25 | * resolve a path for hardware flow offloading |
| 26 | * @net_fill_receive_path: Called from .ndo_fill_receive_path in order to |
| 27 | * get a path for hardware flow offloading |
| 28 | + * @net_setup_tc: Called from .ndo_setup_tc in order to prepare hardware |
| 29 | + * flow offloading for flows originating from the vif. |
| 30 | + * Note that the driver must not assume that the vif driver_data is valid |
| 31 | + * at this point, since the callback can be called during netdev teardown. |
| 32 | */ |
| 33 | struct ieee80211_ops { |
| 34 | void (*tx)(struct ieee80211_hw *hw, |
developer | ed7222c | 2023-04-14 07:19:52 +0800 | [diff] [blame] | 35 | @@ -4324,6 +4328,11 @@ struct ieee80211_ops { |
developer | d5c8ff1 | 2023-03-28 11:56:21 +0800 | [diff] [blame] | 36 | int (*net_fill_receive_path)(struct ieee80211_hw *hw, |
| 37 | struct net_device_path_ctx *ctx, |
| 38 | struct net_device_path *path); |
| 39 | + int (*net_setup_tc)(struct ieee80211_hw *hw, |
| 40 | + struct ieee80211_vif *vif, |
| 41 | + struct net_device *dev, |
| 42 | + enum tc_setup_type type, |
| 43 | + void *type_data); |
| 44 | }; |
| 45 | |
| 46 | /** |
| 47 | diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h |
developer | ed7222c | 2023-04-14 07:19:52 +0800 | [diff] [blame] | 48 | index 88dedfc..3ceba5e 100644 |
developer | d5c8ff1 | 2023-03-28 11:56:21 +0800 | [diff] [blame] | 49 | --- a/net/mac80211/driver-ops.h |
| 50 | +++ b/net/mac80211/driver-ops.h |
developer | ed7222c | 2023-04-14 07:19:52 +0800 | [diff] [blame] | 51 | @@ -1536,4 +1536,21 @@ static inline int drv_net_fill_receive_path(struct ieee80211_local *local, |
developer | d5c8ff1 | 2023-03-28 11:56:21 +0800 | [diff] [blame] | 52 | return ret; |
| 53 | } |
| 54 | |
| 55 | +static inline int drv_net_setup_tc(struct ieee80211_local *local, |
| 56 | + struct ieee80211_sub_if_data *sdata, |
| 57 | + struct net_device *dev, |
| 58 | + enum tc_setup_type type, void *type_data) |
| 59 | +{ |
| 60 | + int ret = -EOPNOTSUPP; |
| 61 | + |
| 62 | + sdata = get_bss_sdata(sdata); |
| 63 | + trace_drv_net_setup_tc(local, sdata, type); |
| 64 | + if (local->ops->net_setup_tc) |
| 65 | + ret = local->ops->net_setup_tc(&local->hw, &sdata->vif, dev, |
| 66 | + type, type_data); |
| 67 | + trace_drv_return_int(local, ret); |
| 68 | + |
| 69 | + return ret; |
| 70 | +} |
| 71 | + |
| 72 | #endif /* __MAC80211_DRIVER_OPS */ |
| 73 | diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h |
| 74 | index 2519c14..fe7a03a 100644 |
| 75 | --- a/net/mac80211/ieee80211_i.h |
| 76 | +++ b/net/mac80211/ieee80211_i.h |
| 77 | @@ -1822,7 +1822,8 @@ void ieee80211_color_aging_work(struct work_struct *work); |
| 78 | /* interface handling */ |
| 79 | #define MAC80211_SUPPORTED_FEATURES_TX (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | \ |
| 80 | NETIF_F_HW_CSUM | NETIF_F_SG | \ |
| 81 | - NETIF_F_HIGHDMA | NETIF_F_GSO_SOFTWARE) |
| 82 | + NETIF_F_HIGHDMA | NETIF_F_GSO_SOFTWARE | \ |
| 83 | + NETIF_F_HW_TC) |
| 84 | #define MAC80211_SUPPORTED_FEATURES_RX (NETIF_F_RXCSUM) |
| 85 | #define MAC80211_SUPPORTED_FEATURES (MAC80211_SUPPORTED_FEATURES_TX | \ |
| 86 | MAC80211_SUPPORTED_FEATURES_RX) |
| 87 | diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c |
| 88 | index 8a4f4e1..f3bf837 100644 |
| 89 | --- a/net/mac80211/iface.c |
| 90 | +++ b/net/mac80211/iface.c |
| 91 | @@ -773,6 +773,21 @@ static int __change_mtu(struct net_device *ndev, int new_mtu){ |
| 92 | } |
| 93 | #endif |
| 94 | |
| 95 | +static int ieee80211_netdev_setup_tc(struct net_device *dev, |
| 96 | + enum tc_setup_type type, void *type_data) |
| 97 | +{ |
| 98 | + struct ieee80211_sub_if_data *sdata; |
| 99 | + struct ieee80211_local *local; |
| 100 | + |
| 101 | + sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 102 | + local = sdata->local; |
| 103 | + |
| 104 | + if (!local->ops->net_setup_tc) |
| 105 | + return -EOPNOTSUPP; |
| 106 | + |
| 107 | + return drv_net_setup_tc(local, sdata, dev, type, type_data); |
| 108 | +} |
| 109 | + |
| 110 | static const struct net_device_ops ieee80211_dataif_ops = { |
| 111 | #if LINUX_VERSION_IS_LESS(4,10,0) |
| 112 | .ndo_change_mtu = __change_mtu, |
| 113 | @@ -790,6 +805,7 @@ static const struct net_device_ops ieee80211_dataif_ops = { |
| 114 | #else |
| 115 | .ndo_get_stats64 = bp_ieee80211_get_stats64, |
| 116 | #endif |
| 117 | + .ndo_setup_tc = ieee80211_netdev_setup_tc, |
| 118 | |
| 119 | }; |
| 120 | |
| 121 | @@ -953,6 +969,7 @@ static const struct net_device_ops ieee80211_dataif_8023_ops = { |
| 122 | #endif |
| 123 | .ndo_fill_forward_path = ieee80211_netdev_fill_forward_path, |
| 124 | .ndo_fill_receive_path = ieee80211_netdev_fill_receive_path, |
| 125 | + .ndo_setup_tc = ieee80211_netdev_setup_tc, |
| 126 | }; |
| 127 | |
| 128 | static bool ieee80211_iftype_supports_hdr_offload(enum nl80211_iftype iftype) |
| 129 | diff --git a/net/mac80211/trace.h b/net/mac80211/trace.h |
developer | ed7222c | 2023-04-14 07:19:52 +0800 | [diff] [blame] | 130 | index 8770033..78d9803 100644 |
developer | d5c8ff1 | 2023-03-28 11:56:21 +0800 | [diff] [blame] | 131 | --- a/net/mac80211/trace.h |
| 132 | +++ b/net/mac80211/trace.h |
developer | ed7222c | 2023-04-14 07:19:52 +0800 | [diff] [blame] | 133 | @@ -2906,6 +2906,31 @@ DEFINE_EVENT(sta_event, drv_net_fill_forward_path, |
developer | d5c8ff1 | 2023-03-28 11:56:21 +0800 | [diff] [blame] | 134 | TP_ARGS(local, sdata, sta) |
| 135 | ); |
| 136 | |
| 137 | +TRACE_EVENT(drv_net_setup_tc, |
| 138 | + TP_PROTO(struct ieee80211_local *local, |
| 139 | + struct ieee80211_sub_if_data *sdata, |
| 140 | + u8 type), |
| 141 | + |
| 142 | + TP_ARGS(local, sdata, type), |
| 143 | + |
| 144 | + TP_STRUCT__entry( |
| 145 | + LOCAL_ENTRY |
| 146 | + VIF_ENTRY |
| 147 | + __field(u8, type) |
| 148 | + ), |
| 149 | + |
| 150 | + TP_fast_assign( |
| 151 | + LOCAL_ASSIGN; |
| 152 | + VIF_ASSIGN; |
| 153 | + __entry->type = type; |
| 154 | + ), |
| 155 | + |
| 156 | + TP_printk( |
| 157 | + LOCAL_PR_FMT VIF_PR_FMT " type:%d\n", |
| 158 | + LOCAL_PR_ARG, VIF_PR_ARG, __entry->type |
| 159 | + ) |
| 160 | +); |
| 161 | + |
| 162 | TRACE_EVENT(bss_color_bitmap, |
| 163 | TP_PROTO(u8 color, |
| 164 | u64 color_bitmap), |
| 165 | -- |
| 166 | 2.18.0 |
| 167 | |