]> Pileus Git - ~andy/linux/commitdiff
cfg80211: check radar interface combinations
authorSimon Wunderlich <simon.wunderlich@s2003.tu-chemnitz.de>
Tue, 8 Jan 2013 13:04:07 +0000 (14:04 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 16 Jan 2013 22:41:54 +0000 (23:41 +0100)
To ease further DFS development regarding interface combinations, use
the interface combinations structure to test for radar capabilities.
Drivers can specify which channel widths they support, and in which
modes. Right now only a single AP interface is allowed, but as the
DFS code evolves other combinations can be enabled.

Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
include/net/cfg80211.h
include/uapi/linux/nl80211.h
net/wireless/core.c
net/wireless/core.h
net/wireless/nl80211.c
net/wireless/util.c

index f1686d460e6b08deaaeede1bfaf9db6cfe590f08..970da442067615ab49526397ef559c0ec5c740ea 100644 (file)
@@ -2125,6 +2125,7 @@ struct ieee80211_iface_limit {
  * @beacon_int_infra_match: In this combination, the beacon intervals
  *     between infrastructure and AP types must match. This is required
  *     only in special cases.
+ * @radar_detect_widths: bitmap of channel widths supported for radar detection
  *
  * These examples can be expressed as follows:
  *
@@ -2177,6 +2178,7 @@ struct ieee80211_iface_combination {
        u16 max_interfaces;
        u8 n_limits;
        bool beacon_int_infra_match;
+       u8 radar_detect_widths;
 };
 
 struct mac_address {
index d01c16220dc5727b6ea6a7396d6cae41af70a57d..e6eeb4ba5dc58c83ce20c7773a1f20819e883d36 100644 (file)
@@ -2984,6 +2984,8 @@ enum nl80211_iface_limit_attrs {
  *     the infrastructure network's beacon interval.
  * @NL80211_IFACE_COMB_NUM_CHANNELS: u32 attribute specifying how many
  *     different channels may be used within this group.
+ * @NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS: u32 attribute containing the bitmap
+ *     of supported channel widths for radar detection.
  * @NUM_NL80211_IFACE_COMB: number of attributes
  * @MAX_NL80211_IFACE_COMB: highest attribute number
  *
@@ -3016,6 +3018,7 @@ enum nl80211_if_combination_attrs {
        NL80211_IFACE_COMB_MAXNUM,
        NL80211_IFACE_COMB_STA_AP_BI_MATCH,
        NL80211_IFACE_COMB_NUM_CHANNELS,
+       NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS,
 
        /* keep last */
        NUM_NL80211_IFACE_COMB,
index 747dd9365a44ff7ce336c5db1f70d6a466cf6d0d..0e702cdc60434ef53a31884b64883405c155b2b6 100644 (file)
@@ -382,8 +382,11 @@ static int wiphy_verify_combinations(struct wiphy *wiphy)
 
                c = &wiphy->iface_combinations[i];
 
-               /* Combinations with just one interface aren't real */
-               if (WARN_ON(c->max_interfaces < 2))
+               /*
+                * Combinations with just one interface aren't real,
+                * however we make an exception for DFS.
+                */
+               if (WARN_ON((c->max_interfaces < 2) && !c->radar_detect_widths))
                        return -EINVAL;
 
                /* Need at least one channel */
@@ -398,6 +401,11 @@ static int wiphy_verify_combinations(struct wiphy *wiphy)
                                CFG80211_MAX_NUM_DIFFERENT_CHANNELS))
                        return -EINVAL;
 
+               /* DFS only works on one channel. */
+               if (WARN_ON(c->radar_detect_widths &&
+                           (c->num_different_channels > 1)))
+                       return -EINVAL;
+
                if (WARN_ON(!c->n_limits))
                        return -EINVAL;
 
index f342267e36207969b3dba3bfc071bc440082268e..8396f7671c8db682c87baf657f607ae883e4128c 100644 (file)
@@ -425,7 +425,8 @@ int cfg80211_can_use_iftype_chan(struct cfg80211_registered_device *rdev,
                                 struct wireless_dev *wdev,
                                 enum nl80211_iftype iftype,
                                 struct ieee80211_channel *chan,
-                                enum cfg80211_chan_mode chanmode);
+                                enum cfg80211_chan_mode chanmode,
+                                u8 radar_detect);
 
 static inline int
 cfg80211_can_change_interface(struct cfg80211_registered_device *rdev,
@@ -433,7 +434,7 @@ cfg80211_can_change_interface(struct cfg80211_registered_device *rdev,
                              enum nl80211_iftype iftype)
 {
        return cfg80211_can_use_iftype_chan(rdev, wdev, iftype, NULL,
-                                           CHAN_MODE_UNDEFINED);
+                                           CHAN_MODE_UNDEFINED, 0);
 }
 
 static inline int
@@ -450,7 +451,7 @@ cfg80211_can_use_chan(struct cfg80211_registered_device *rdev,
                      enum cfg80211_chan_mode chanmode)
 {
        return cfg80211_can_use_iftype_chan(rdev, wdev, wdev->iftype,
-                                           chan, chanmode);
+                                           chan, chanmode, 0);
 }
 
 void
index df82a5c9faeea1705e20b695a01ccb3595a038bf..33de80364c5cd183f344b8cc72f03810855141f3 100644 (file)
@@ -856,6 +856,9 @@ static int nl80211_put_iface_combinations(struct wiphy *wiphy,
                    nla_put_u32(msg, NL80211_IFACE_COMB_MAXNUM,
                                c->max_interfaces))
                        goto nla_put_failure;
+               if (nla_put_u32(msg, NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS,
+                               c->radar_detect_widths))
+                       goto nla_put_failure;
 
                nla_nest_end(msg, nl_combi);
        }
index 16d76a807c2fac022294aa33cb0336bb89bab38b..1c2795d52db0a9d1a6cae01e836918e788be6314 100644 (file)
@@ -1184,7 +1184,8 @@ int cfg80211_can_use_iftype_chan(struct cfg80211_registered_device *rdev,
                                 struct wireless_dev *wdev,
                                 enum nl80211_iftype iftype,
                                 struct ieee80211_channel *chan,
-                                enum cfg80211_chan_mode chanmode)
+                                enum cfg80211_chan_mode chanmode,
+                                u8 radar_detect)
 {
        struct wireless_dev *wdev_iter;
        u32 used_iftypes = BIT(iftype);
@@ -1195,14 +1196,45 @@ int cfg80211_can_use_iftype_chan(struct cfg80211_registered_device *rdev,
        enum cfg80211_chan_mode chmode;
        int num_different_channels = 0;
        int total = 1;
+       bool radar_required;
        int i, j;
 
        ASSERT_RTNL();
        lockdep_assert_held(&rdev->devlist_mtx);
 
+       if (WARN_ON(hweight32(radar_detect) > 1))
+               return -EINVAL;
+
+       switch (iftype) {
+       case NL80211_IFTYPE_ADHOC:
+       case NL80211_IFTYPE_AP:
+       case NL80211_IFTYPE_AP_VLAN:
+       case NL80211_IFTYPE_MESH_POINT:
+       case NL80211_IFTYPE_P2P_GO:
+       case NL80211_IFTYPE_WDS:
+               radar_required = !!(chan->flags & IEEE80211_CHAN_RADAR);
+               break;
+       case NL80211_IFTYPE_P2P_CLIENT:
+       case NL80211_IFTYPE_STATION:
+       case NL80211_IFTYPE_MONITOR:
+               radar_required = false;
+               break;
+       case NL80211_IFTYPE_P2P_DEVICE:
+       case NUM_NL80211_IFTYPES:
+       case NL80211_IFTYPE_UNSPECIFIED:
+       default:
+               return -EINVAL;
+       }
+
+       if (radar_required && !radar_detect)
+               return -EINVAL;
+
        /* Always allow software iftypes */
-       if (rdev->wiphy.software_iftypes & BIT(iftype))
+       if (rdev->wiphy.software_iftypes & BIT(iftype)) {
+               if (radar_detect)
+                       return -EINVAL;
                return 0;
+       }
 
        memset(num, 0, sizeof(num));
        memset(used_channels, 0, sizeof(used_channels));
@@ -1275,7 +1307,7 @@ int cfg80211_can_use_iftype_chan(struct cfg80211_registered_device *rdev,
                used_iftypes |= BIT(wdev_iter->iftype);
        }
 
-       if (total == 1)
+       if (total == 1 && !radar_detect)
                return 0;
 
        for (i = 0; i < rdev->wiphy.n_iface_combinations; i++) {
@@ -1308,6 +1340,9 @@ int cfg80211_can_use_iftype_chan(struct cfg80211_registered_device *rdev,
                        }
                }
 
+               if (radar_detect && !(c->radar_detect_widths & radar_detect))
+                       goto cont;
+
                /*
                 * Finally check that all iftypes that we're currently
                 * using are actually part of this combination. If they