mediatek: add kernel code for supporting offloading wlan->eth and wlan->wlan flows
Will be enabled by an upcoming mt76 update Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
@@ -0,0 +1,149 @@
|
||||
From: Felix Fietkau <nbd@nbd.name>
|
||||
Date: Mon, 20 Mar 2023 14:28:08 +0100
|
||||
Subject: [PATCH] wifi: mac80211: add support for letting drivers register tc
|
||||
offload support
|
||||
|
||||
On newer MediaTek SoCs (e.g. MT7986), WLAN->WLAN or WLAN->Ethernet flows can
|
||||
be offloaded by the SoC. In order to support that, the .ndo_setup_tc op is
|
||||
needed.
|
||||
|
||||
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
---
|
||||
|
||||
--- a/include/net/mac80211.h
|
||||
+++ b/include/net/mac80211.h
|
||||
@@ -4196,6 +4196,10 @@ struct ieee80211_prep_tx_info {
|
||||
* Note that a sta can also be inserted or removed with valid links,
|
||||
* i.e. passed to @sta_add/@sta_state with sta->valid_links not zero.
|
||||
* In fact, cannot change from having valid_links and not having them.
|
||||
+ * @net_setup_tc: Called from .ndo_setup_tc in order to prepare hardware
|
||||
+ * flow offloading for flows originating from the vif.
|
||||
+ * Note that the driver must not assume that the vif driver_data is valid
|
||||
+ * at this point, since the callback can be called during netdev teardown.
|
||||
*/
|
||||
struct ieee80211_ops {
|
||||
void (*tx)(struct ieee80211_hw *hw,
|
||||
@@ -4551,6 +4555,11 @@ struct ieee80211_ops {
|
||||
struct ieee80211_vif *vif,
|
||||
struct ieee80211_sta *sta,
|
||||
u16 old_links, u16 new_links);
|
||||
+ int (*net_setup_tc)(struct ieee80211_hw *hw,
|
||||
+ struct ieee80211_vif *vif,
|
||||
+ struct net_device *dev,
|
||||
+ enum tc_setup_type type,
|
||||
+ void *type_data);
|
||||
};
|
||||
|
||||
/**
|
||||
--- a/net/mac80211/driver-ops.h
|
||||
+++ b/net/mac80211/driver-ops.h
|
||||
@@ -1470,6 +1470,23 @@ static inline int drv_net_fill_forward_p
|
||||
return ret;
|
||||
}
|
||||
|
||||
+static inline int drv_net_setup_tc(struct ieee80211_local *local,
|
||||
+ struct ieee80211_sub_if_data *sdata,
|
||||
+ struct net_device *dev,
|
||||
+ enum tc_setup_type type, void *type_data)
|
||||
+{
|
||||
+ int ret = -EOPNOTSUPP;
|
||||
+
|
||||
+ sdata = get_bss_sdata(sdata);
|
||||
+ trace_drv_net_setup_tc(local, sdata, type);
|
||||
+ if (local->ops->net_setup_tc)
|
||||
+ ret = local->ops->net_setup_tc(&local->hw, &sdata->vif, dev,
|
||||
+ type, type_data);
|
||||
+ trace_drv_return_int(local, ret);
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
int drv_change_vif_links(struct ieee80211_local *local,
|
||||
struct ieee80211_sub_if_data *sdata,
|
||||
u16 old_links, u16 new_links,
|
||||
--- a/net/mac80211/ieee80211_i.h
|
||||
+++ b/net/mac80211/ieee80211_i.h
|
||||
@@ -1935,7 +1935,8 @@ void ieee80211_color_change_finalize_wor
|
||||
/* interface handling */
|
||||
#define MAC80211_SUPPORTED_FEATURES_TX (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | \
|
||||
NETIF_F_HW_CSUM | NETIF_F_SG | \
|
||||
- NETIF_F_HIGHDMA | NETIF_F_GSO_SOFTWARE)
|
||||
+ NETIF_F_HIGHDMA | NETIF_F_GSO_SOFTWARE | \
|
||||
+ NETIF_F_HW_TC)
|
||||
#define MAC80211_SUPPORTED_FEATURES_RX (NETIF_F_RXCSUM)
|
||||
#define MAC80211_SUPPORTED_FEATURES (MAC80211_SUPPORTED_FEATURES_TX | \
|
||||
MAC80211_SUPPORTED_FEATURES_RX)
|
||||
--- a/net/mac80211/iface.c
|
||||
+++ b/net/mac80211/iface.c
|
||||
@@ -813,6 +813,21 @@ ieee80211_get_stats64(struct net_device
|
||||
dev_fetch_sw_netstats(stats, dev->tstats);
|
||||
}
|
||||
|
||||
+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;
|
||||
+
|
||||
+ sdata = IEEE80211_DEV_TO_SUB_IF(dev);
|
||||
+ local = sdata->local;
|
||||
+
|
||||
+ if (!local->ops->net_setup_tc)
|
||||
+ return -EOPNOTSUPP;
|
||||
+
|
||||
+ return drv_net_setup_tc(local, sdata, dev, type, type_data);
|
||||
+}
|
||||
+
|
||||
static const struct net_device_ops ieee80211_dataif_ops = {
|
||||
.ndo_open = ieee80211_open,
|
||||
.ndo_stop = ieee80211_stop,
|
||||
@@ -821,6 +836,7 @@ static const struct net_device_ops ieee8
|
||||
.ndo_set_rx_mode = ieee80211_set_multicast_list,
|
||||
.ndo_set_mac_address = ieee80211_change_mac,
|
||||
.ndo_get_stats64 = ieee80211_get_stats64,
|
||||
+ .ndo_setup_tc = ieee80211_netdev_setup_tc,
|
||||
};
|
||||
|
||||
static u16 ieee80211_monitor_select_queue(struct net_device *dev,
|
||||
@@ -929,6 +945,7 @@ static const struct net_device_ops ieee8
|
||||
.ndo_set_mac_address = ieee80211_change_mac,
|
||||
.ndo_get_stats64 = ieee80211_get_stats64,
|
||||
.ndo_fill_forward_path = ieee80211_netdev_fill_forward_path,
|
||||
+ .ndo_setup_tc = ieee80211_netdev_setup_tc,
|
||||
};
|
||||
|
||||
static bool ieee80211_iftype_supports_hdr_offload(enum nl80211_iftype iftype)
|
||||
--- a/net/mac80211/trace.h
|
||||
+++ b/net/mac80211/trace.h
|
||||
@@ -2478,6 +2478,31 @@ DEFINE_EVENT(sta_event, drv_net_fill_for
|
||||
TP_ARGS(local, sdata, sta)
|
||||
);
|
||||
|
||||
+TRACE_EVENT(drv_net_setup_tc,
|
||||
+ TP_PROTO(struct ieee80211_local *local,
|
||||
+ struct ieee80211_sub_if_data *sdata,
|
||||
+ u8 type),
|
||||
+
|
||||
+ TP_ARGS(local, sdata, type),
|
||||
+
|
||||
+ TP_STRUCT__entry(
|
||||
+ LOCAL_ENTRY
|
||||
+ VIF_ENTRY
|
||||
+ __field(u8, type)
|
||||
+ ),
|
||||
+
|
||||
+ TP_fast_assign(
|
||||
+ LOCAL_ASSIGN;
|
||||
+ VIF_ASSIGN;
|
||||
+ __entry->type = type;
|
||||
+ ),
|
||||
+
|
||||
+ TP_printk(
|
||||
+ LOCAL_PR_FMT VIF_PR_FMT " type:%d\n",
|
||||
+ LOCAL_PR_ARG, VIF_PR_ARG, __entry->type
|
||||
+ )
|
||||
+);
|
||||
+
|
||||
TRACE_EVENT(drv_change_vif_links,
|
||||
TP_PROTO(struct ieee80211_local *local,
|
||||
struct ieee80211_sub_if_data *sdata,
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
--- a/include/net/mac80211.h
|
||||
+++ b/include/net/mac80211.h
|
||||
@@ -1645,6 +1645,7 @@ enum ieee80211_smps_mode {
|
||||
@@ -1671,6 +1671,7 @@ enum ieee80211_smps_mode {
|
||||
*
|
||||
* @power_level: requested transmit power (in dBm), backward compatibility
|
||||
* value only that is set to the minimum of all interfaces
|
||||
@@ -26,7 +26,7 @@
|
||||
*
|
||||
* @chandef: the channel definition to tune to
|
||||
* @radar_enabled: whether radar detection is enabled
|
||||
@@ -1665,6 +1666,7 @@ enum ieee80211_smps_mode {
|
||||
@@ -1691,6 +1692,7 @@ enum ieee80211_smps_mode {
|
||||
struct ieee80211_conf {
|
||||
u32 flags;
|
||||
int power_level, dynamic_ps_timeout;
|
||||
@@ -57,7 +57,7 @@
|
||||
__NL80211_ATTR_AFTER_LAST,
|
||||
--- a/net/mac80211/cfg.c
|
||||
+++ b/net/mac80211/cfg.c
|
||||
@@ -2998,6 +2998,19 @@ static int ieee80211_get_tx_power(struct
|
||||
@@ -3028,6 +3028,19 @@ static int ieee80211_get_tx_power(struct
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@
|
||||
static void ieee80211_rfkill_poll(struct wiphy *wiphy)
|
||||
{
|
||||
struct ieee80211_local *local = wiphy_priv(wiphy);
|
||||
@@ -4881,6 +4894,7 @@ const struct cfg80211_ops mac80211_confi
|
||||
@@ -4911,6 +4924,7 @@ const struct cfg80211_ops mac80211_confi
|
||||
.set_wiphy_params = ieee80211_set_wiphy_params,
|
||||
.set_tx_power = ieee80211_set_tx_power,
|
||||
.get_tx_power = ieee80211_get_tx_power,
|
||||
|
||||
Reference in New Issue
Block a user