@@ -4532,6 +4532,15 @@ void cfg80211_report_wowlan_wakeup(struct wireless_dev *wdev,
*/
void cfg80211_crit_proto_stopped(struct wireless_dev *wdev, gfp_t gfp);
+/**
+ * ieee80211_get_num_enabled_channels - get the number of channels supported
+ * and enabled by the device.
+ * @wiphy: the wiphy
+ *
+ * Return: the number of channels supported and enabled by the device.
+ */
+unsigned int ieee80211_get_num_enabled_channels(struct wiphy *wiphy);
+
/* Logging, debugging and troubleshooting/diagnostic helpers. */
/* wiphy_printk helpers, similar to dev_printk */
@@ -1462,6 +1462,27 @@ int ieee80211_get_ratemask(struct ieee80211_supported_band *sband,
return 0;
}
+unsigned int ieee80211_get_num_enabled_channels(struct wiphy *wiphy)
+{
+ struct ieee80211_supported_band *sband;
+ unsigned int n_channels, i, j;
+
+ for (i = 0, n_channels = 0; i < IEEE80211_NUM_BANDS; i++) {
+ sband = wiphy->bands[i];
+ if (!sband)
+ continue;
+
+ for (j = 0; j < sband->n_channels; j++) {
+ if (!(sband->channels[j].flags &
+ IEEE80211_CHAN_DISABLED))
+ n_channels++;
+ }
+ }
+
+ return n_channels;
+}
+EXPORT_SYMBOL(ieee80211_get_num_enabled_channels);
+
/* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */
/* Ethernet-II snap header (RFC1042 for most EtherTypes) */
const unsigned char rfc1042_header[] __aligned(2) =
Add a utility function to get the number of channels enabled by the device. Signed-off-by: Ilan Peer <ilan.peer@intel.com> --- include/net/cfg80211.h | 9 +++++++++ net/wireless/util.c | 21 +++++++++++++++++++++ 2 files changed, 30 insertions(+)