aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/net/cfg80211.h27
-rw-r--r--net/wireless/util.c44
2 files changed, 64 insertions, 7 deletions
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 9496fe5ea6b4..3dd2cb465540 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -4715,6 +4715,33 @@ int cfg80211_check_combinations(struct wiphy *wiphy,
4715 const u8 radar_detect, 4715 const u8 radar_detect,
4716 const int iftype_num[NUM_NL80211_IFTYPES]); 4716 const int iftype_num[NUM_NL80211_IFTYPES]);
4717 4717
4718/**
4719 * cfg80211_iter_combinations - iterate over matching combinations
4720 *
4721 * @wiphy: the wiphy
4722 * @num_different_channels: the number of different channels we want
4723 * to use for verification
4724 * @radar_detect: a bitmap where each bit corresponds to a channel
4725 * width where radar detection is needed, as in the definition of
4726 * &struct ieee80211_iface_combination.@radar_detect_widths
4727 * @iftype_num: array with the numbers of interfaces of each interface
4728 * type. The index is the interface type as specified in &enum
4729 * nl80211_iftype.
4730 * @iter: function to call for each matching combination
4731 * @data: pointer to pass to iter function
4732 *
4733 * This function can be called by the driver to check what possible
4734 * combinations it fits in at a given moment, e.g. for channel switching
4735 * purposes.
4736 */
4737int cfg80211_iter_combinations(struct wiphy *wiphy,
4738 const int num_different_channels,
4739 const u8 radar_detect,
4740 const int iftype_num[NUM_NL80211_IFTYPES],
4741 void (*iter)(const struct ieee80211_iface_combination *c,
4742 void *data),
4743 void *data);
4744
4718/* Logging, debugging and troubleshooting/diagnostic helpers. */ 4745/* Logging, debugging and troubleshooting/diagnostic helpers. */
4719 4746
4720/* wiphy_printk helpers, similar to dev_printk */ 4747/* wiphy_printk helpers, similar to dev_printk */
diff --git a/net/wireless/util.c b/net/wireless/util.c
index d032a31828f1..d8b599575a5e 100644
--- a/net/wireless/util.c
+++ b/net/wireless/util.c
@@ -1263,10 +1263,13 @@ int cfg80211_validate_beacon_int(struct cfg80211_registered_device *rdev,
1263 return res; 1263 return res;
1264} 1264}
1265 1265
1266int cfg80211_check_combinations(struct wiphy *wiphy, 1266int cfg80211_iter_combinations(struct wiphy *wiphy,
1267 const int num_different_channels, 1267 const int num_different_channels,
1268 const u8 radar_detect, 1268 const u8 radar_detect,
1269 const int iftype_num[NUM_NL80211_IFTYPES]) 1269 const int iftype_num[NUM_NL80211_IFTYPES],
1270 void (*iter)(const struct ieee80211_iface_combination *c,
1271 void *data),
1272 void *data)
1270{ 1273{
1271 int i, j, iftype; 1274 int i, j, iftype;
1272 int num_interfaces = 0; 1275 int num_interfaces = 0;
@@ -1323,13 +1326,40 @@ int cfg80211_check_combinations(struct wiphy *wiphy,
1323 /* This combination covered all interface types and 1326 /* This combination covered all interface types and
1324 * supported the requested numbers, so we're good. 1327 * supported the requested numbers, so we're good.
1325 */ 1328 */
1326 kfree(limits); 1329
1327 return 0; 1330 (*iter)(c, data);
1328 cont: 1331 cont:
1329 kfree(limits); 1332 kfree(limits);
1330 } 1333 }
1331 1334
1332 return -EBUSY; 1335 return 0;
1336}
1337EXPORT_SYMBOL(cfg80211_iter_combinations);
1338
1339static void
1340cfg80211_iter_sum_ifcombs(const struct ieee80211_iface_combination *c,
1341 void *data)
1342{
1343 int *num = data;
1344 (*num)++;
1345}
1346
1347int cfg80211_check_combinations(struct wiphy *wiphy,
1348 const int num_different_channels,
1349 const u8 radar_detect,
1350 const int iftype_num[NUM_NL80211_IFTYPES])
1351{
1352 int err, num = 0;
1353
1354 err = cfg80211_iter_combinations(wiphy, num_different_channels,
1355 radar_detect, iftype_num,
1356 cfg80211_iter_sum_ifcombs, &num);
1357 if (err)
1358 return err;
1359 if (num == 0)
1360 return -EBUSY;
1361
1362 return 0;
1333} 1363}
1334EXPORT_SYMBOL(cfg80211_check_combinations); 1364EXPORT_SYMBOL(cfg80211_check_combinations);
1335 1365