aboutsummaryrefslogtreecommitdiffstats
path: root/net/wireless/util.c
diff options
context:
space:
mode:
authorSimon Wunderlich <simon.wunderlich@s2003.tu-chemnitz.de>2013-01-08 08:04:07 -0500
committerJohannes Berg <johannes.berg@intel.com>2013-01-16 17:41:54 -0500
commit11c4a075db2f8774d37544342c8cb9752b4db9e1 (patch)
treedbd28f1bbac2a42ebe4aade8d1a4bc2871431924 /net/wireless/util.c
parentcee00a959c0a86571e6f99cf42f0261d7e54d2ae (diff)
cfg80211: check radar interface combinations
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>
Diffstat (limited to 'net/wireless/util.c')
-rw-r--r--net/wireless/util.c41
1 files changed, 38 insertions, 3 deletions
diff --git a/net/wireless/util.c b/net/wireless/util.c
index 16d76a807c2f..1c2795d52db0 100644
--- a/net/wireless/util.c
+++ b/net/wireless/util.c
@@ -1184,7 +1184,8 @@ int cfg80211_can_use_iftype_chan(struct cfg80211_registered_device *rdev,
1184 struct wireless_dev *wdev, 1184 struct wireless_dev *wdev,
1185 enum nl80211_iftype iftype, 1185 enum nl80211_iftype iftype,
1186 struct ieee80211_channel *chan, 1186 struct ieee80211_channel *chan,
1187 enum cfg80211_chan_mode chanmode) 1187 enum cfg80211_chan_mode chanmode,
1188 u8 radar_detect)
1188{ 1189{
1189 struct wireless_dev *wdev_iter; 1190 struct wireless_dev *wdev_iter;
1190 u32 used_iftypes = BIT(iftype); 1191 u32 used_iftypes = BIT(iftype);
@@ -1195,14 +1196,45 @@ int cfg80211_can_use_iftype_chan(struct cfg80211_registered_device *rdev,
1195 enum cfg80211_chan_mode chmode; 1196 enum cfg80211_chan_mode chmode;
1196 int num_different_channels = 0; 1197 int num_different_channels = 0;
1197 int total = 1; 1198 int total = 1;
1199 bool radar_required;
1198 int i, j; 1200 int i, j;
1199 1201
1200 ASSERT_RTNL(); 1202 ASSERT_RTNL();
1201 lockdep_assert_held(&rdev->devlist_mtx); 1203 lockdep_assert_held(&rdev->devlist_mtx);
1202 1204
1205 if (WARN_ON(hweight32(radar_detect) > 1))
1206 return -EINVAL;
1207
1208 switch (iftype) {
1209 case NL80211_IFTYPE_ADHOC:
1210 case NL80211_IFTYPE_AP:
1211 case NL80211_IFTYPE_AP_VLAN:
1212 case NL80211_IFTYPE_MESH_POINT:
1213 case NL80211_IFTYPE_P2P_GO:
1214 case NL80211_IFTYPE_WDS:
1215 radar_required = !!(chan->flags & IEEE80211_CHAN_RADAR);
1216 break;
1217 case NL80211_IFTYPE_P2P_CLIENT:
1218 case NL80211_IFTYPE_STATION:
1219 case NL80211_IFTYPE_MONITOR:
1220 radar_required = false;
1221 break;
1222 case NL80211_IFTYPE_P2P_DEVICE:
1223 case NUM_NL80211_IFTYPES:
1224 case NL80211_IFTYPE_UNSPECIFIED:
1225 default:
1226 return -EINVAL;
1227 }
1228
1229 if (radar_required && !radar_detect)
1230 return -EINVAL;
1231
1203 /* Always allow software iftypes */ 1232 /* Always allow software iftypes */
1204 if (rdev->wiphy.software_iftypes & BIT(iftype)) 1233 if (rdev->wiphy.software_iftypes & BIT(iftype)) {
1234 if (radar_detect)
1235 return -EINVAL;
1205 return 0; 1236 return 0;
1237 }
1206 1238
1207 memset(num, 0, sizeof(num)); 1239 memset(num, 0, sizeof(num));
1208 memset(used_channels, 0, sizeof(used_channels)); 1240 memset(used_channels, 0, sizeof(used_channels));
@@ -1275,7 +1307,7 @@ int cfg80211_can_use_iftype_chan(struct cfg80211_registered_device *rdev,
1275 used_iftypes |= BIT(wdev_iter->iftype); 1307 used_iftypes |= BIT(wdev_iter->iftype);
1276 } 1308 }
1277 1309
1278 if (total == 1) 1310 if (total == 1 && !radar_detect)
1279 return 0; 1311 return 0;
1280 1312
1281 for (i = 0; i < rdev->wiphy.n_iface_combinations; i++) { 1313 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,
1308 } 1340 }
1309 } 1341 }
1310 1342
1343 if (radar_detect && !(c->radar_detect_widths & radar_detect))
1344 goto cont;
1345
1311 /* 1346 /*
1312 * Finally check that all iftypes that we're currently 1347 * Finally check that all iftypes that we're currently
1313 * using are actually part of this combination. If they 1348 * using are actually part of this combination. If they