aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/util.c
diff options
context:
space:
mode:
authorMichal Kazior <michal.kazior@tieto.com>2014-04-09 09:29:23 -0400
committerJohannes Berg <johannes.berg@intel.com>2014-04-25 11:08:15 -0400
commit6fa001bc7e1ccd7482f0f089fb970d65a5aca59a (patch)
tree2dad9dc3fdbaa55969573136636a3588061d930e /net/mac80211/util.c
parent65a124dd719d6e90591e4756bb04e1719489705e (diff)
mac80211: add max channel calculation utility function
The utility function has no uses yet. It is aimed at future chanctx reservation management and channel switching. Signed-off-by: Michal Kazior <michal.kazior@tieto.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/mac80211/util.c')
-rw-r--r--net/mac80211/util.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 5a6cc3382ae9..7a376f826cf8 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -2873,3 +2873,45 @@ int ieee80211_check_combinations(struct ieee80211_sub_if_data *sdata,
2873 num_different_channels, 2873 num_different_channels,
2874 radar_detect, num); 2874 radar_detect, num);
2875} 2875}
2876
2877static void
2878ieee80211_iter_max_chans(const struct ieee80211_iface_combination *c,
2879 void *data)
2880{
2881 u32 *max_num_different_channels = data;
2882
2883 *max_num_different_channels = max(*max_num_different_channels,
2884 c->num_different_channels);
2885}
2886
2887int ieee80211_max_num_channels(struct ieee80211_local *local)
2888{
2889 struct ieee80211_sub_if_data *sdata;
2890 int num[NUM_NL80211_IFTYPES] = {};
2891 struct ieee80211_chanctx *ctx;
2892 int num_different_channels = 0;
2893 u8 radar_detect = 0;
2894 u32 max_num_different_channels = 1;
2895 int err;
2896
2897 lockdep_assert_held(&local->chanctx_mtx);
2898
2899 list_for_each_entry(ctx, &local->chanctx_list, list) {
2900 num_different_channels++;
2901
2902 if (ctx->conf.radar_enabled)
2903 radar_detect |= BIT(ctx->conf.def.width);
2904 }
2905
2906 list_for_each_entry_rcu(sdata, &local->interfaces, list)
2907 num[sdata->wdev.iftype]++;
2908
2909 err = cfg80211_iter_combinations(local->hw.wiphy,
2910 num_different_channels, radar_detect,
2911 num, ieee80211_iter_max_chans,
2912 &max_num_different_channels);
2913 if (err < 0)
2914 return err;
2915
2916 return max_num_different_channels;
2917}