mac80211: allow low-level drivers to set netdev feature bits
authorArik Nemtsov <arik@wizery.com>
Thu, 10 May 2012 13:18:26 +0000 (16:18 +0300)
committerJohn W. Linville <linville@tuxdriver.com>
Tue, 5 Jun 2012 19:21:46 +0000 (15:21 -0400)
Low level drivers can now set certain netdev feature bits in
netdev_features member of the ieee80211_hw struct. These will be
propagated to every netdev created from this HW.

The white-listed features currently include only ones related to HW
checksumming.

Signed-off-by: Arik Nemtsov <arik@wizery.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
include/net/mac80211.h
net/mac80211/iface.c
net/mac80211/main.c

index 1937c7d98304fc0ecfd6d7315c9e3cbb9e93a557..0286c0476e44d0f7234439cf086a89d8445f0be8 100644 (file)
@@ -1297,6 +1297,10 @@ enum ieee80211_hw_flags {
  *     reports, by default it is set to _MCS, _GI and _BW but doesn't
  *     include _FMT. Use %IEEE80211_RADIOTAP_MCS_HAVE_* values, only
  *     adding _BW is supported today.
+ *
+ * @netdev_features: netdev features to be set in each netdev created
+ *     from this HW. Note only HW checksum features are currently
+ *     compatible with mac80211. Other feature bits will be rejected.
  */
 struct ieee80211_hw {
        struct ieee80211_conf conf;
@@ -1319,6 +1323,7 @@ struct ieee80211_hw {
        u8 max_tx_aggregation_subframes;
        u8 offchannel_tx_hw_queue;
        u8 radiotap_mcs_details;
+       netdev_features_t netdev_features;
 };
 
 /**
index d4c19a7773db24b12bacf0407330ebccd75ba772..f970e0b3c4b94564c19e9e23246b9970b789324d 100644 (file)
@@ -1352,6 +1352,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;
+
        ret = register_netdevice(ndev);
        if (ret)
                goto fail;
index f5548e953259e6f517ed19a77286e8d7e0e1e531..779ac613ee57a1dd9003d426a5e4b9e4d3d4c24f 100644 (file)
@@ -682,6 +682,7 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
        enum ieee80211_band band;
        int channels, max_bitrates;
        bool supp_ht;
+       netdev_features_t feature_whitelist;
        static const u32 cipher_suites[] = {
                /* keep WEP first, it may be removed below */
                WLAN_CIPHER_SUITE_WEP40,
@@ -708,6 +709,12 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
        if ((hw->flags & IEEE80211_HW_SCAN_WHILE_IDLE) && !local->ops->hw_scan)
                return -EINVAL;
 
+       /* Only HW csum features are currently compatible with mac80211 */
+       feature_whitelist = NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
+                           NETIF_F_HW_CSUM;
+       if (WARN_ON(hw->netdev_features & ~feature_whitelist))
+               return -EINVAL;
+
        if (hw->max_report_rates == 0)
                hw->max_report_rates = hw->max_rates;