mac80211: allow changing TX-related netdev features
authorJohannes Berg <johannes.berg@intel.com>
Fri, 31 Jan 2020 11:12:46 +0000 (13:12 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 7 Feb 2020 11:40:20 +0000 (12:40 +0100)
Set ndev->hw_features as well as ndev->features to allow
changing the TX-related features with ethtool.

We cannot (yet) change RX-related features since that
requires telling the driver about it and we have no API
for that yet.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/20200131111300.891737-10-luca@coelho.fi
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/ieee80211_i.h
net/mac80211/iface.c
net/mac80211/main.c

index e3cf24c..b895432 100644 (file)
@@ -1729,6 +1729,13 @@ int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
                             struct cfg80211_csa_settings *params);
 
 /* 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)
+#define MAC80211_SUPPORTED_FEATURES_RX (NETIF_F_RXCSUM)
+#define MAC80211_SUPPORTED_FEATURES    (MAC80211_SUPPORTED_FEATURES_TX | \
+                                        MAC80211_SUPPORTED_FEATURES_RX)
+
 int ieee80211_iface_init(void);
 void ieee80211_iface_exit(void);
 int ieee80211_if_add(struct ieee80211_local *local, const char *name,
index 9b833e1..99d913a 100644 (file)
@@ -8,7 +8,7 @@
  * Copyright 2008, Johannes Berg <johannes@sipsolutions.net>
  * Copyright 2013-2014  Intel Mobile Communications GmbH
  * Copyright (c) 2016        Intel Deutschland GmbH
- * Copyright (C) 2018 Intel Corporation
+ * Copyright (C) 2018-2019 Intel Corporation
  */
 #include <linux/slab.h>
 #include <linux/kernel.h>
@@ -1938,6 +1938,8 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name,
                        sdata->u.mgd.use_4addr = params->use_4addr;
 
                ndev->features |= local->hw.netdev_features;
+               ndev->hw_features |= ndev->features &
+                                       MAC80211_SUPPORTED_FEATURES_TX;
 
                netdev_set_default_ethtool_ops(ndev, &ieee80211_ethtool_ops);
 
index 34728cf..287dd05 100644 (file)
@@ -872,7 +872,6 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
        enum nl80211_band band;
        int channels, max_bitrates;
        bool supp_ht, supp_vht, supp_he;
-       netdev_features_t feature_whitelist;
        struct cfg80211_chan_def dflt_chandef = {};
 
        if (ieee80211_hw_check(hw, QUEUE_CONTROL) &&
@@ -931,10 +930,7 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
        }
 
        /* Only HW csum features are currently compatible with mac80211 */
-       feature_whitelist = NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
-                           NETIF_F_HW_CSUM | NETIF_F_SG | NETIF_F_HIGHDMA |
-                           NETIF_F_GSO_SOFTWARE | NETIF_F_RXCSUM;
-       if (WARN_ON(hw->netdev_features & ~feature_whitelist))
+       if (WARN_ON(hw->netdev_features & ~MAC80211_SUPPORTED_FEATURES))
                return -EINVAL;
 
        if (hw->max_report_rates == 0)