mirror of
https://github.com/openwrt/openwrt.git
synced 2025-01-11 15:33:03 +00:00
1bfcc1ea8a
Brings lots of driver updates and API changes needed for mt76 updates. Disable iwlwifi and ath11k on 5.15, since backport is too difficult, and the only remaining targets won't need those drivers. Signed-off-by: Felix Fietkau <nbd@nbd.name>
70 lines
1.8 KiB
Diff
70 lines
1.8 KiB
Diff
From: Felix Fietkau <nbd@nbd.name>
|
|
Date: Fri, 7 Jun 2024 17:58:54 +0200
|
|
Subject: [PATCH] wifi: cfg80211: add helper for checking if a chandef is
|
|
valid on a radio
|
|
|
|
Check if the full channel width is in the radio's frequency range.
|
|
|
|
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
|
---
|
|
|
|
--- a/include/net/cfg80211.h
|
|
+++ b/include/net/cfg80211.h
|
|
@@ -6485,6 +6485,15 @@ static inline bool cfg80211_channel_is_p
|
|
}
|
|
|
|
/**
|
|
+ * cfg80211_radio_chandef_valid - Check if the radio supports the chandef
|
|
+ *
|
|
+ * @radio: wiphy radio
|
|
+ * @chandef: chandef for current channel
|
|
+ */
|
|
+bool cfg80211_radio_chandef_valid(const struct wiphy_radio *radio,
|
|
+ const struct cfg80211_chan_def *chandef);
|
|
+
|
|
+/**
|
|
* ieee80211_get_response_rate - get basic rate for a given rate
|
|
*
|
|
* @sband: the band to look for rates in
|
|
--- a/net/wireless/util.c
|
|
+++ b/net/wireless/util.c
|
|
@@ -2884,3 +2884,38 @@ cfg80211_get_iftype_ext_capa(struct wiph
|
|
return NULL;
|
|
}
|
|
EXPORT_SYMBOL(cfg80211_get_iftype_ext_capa);
|
|
+
|
|
+static bool
|
|
+ieee80211_radio_freq_range_valid(const struct wiphy_radio *radio,
|
|
+ u32 freq, u32 width)
|
|
+{
|
|
+ const struct wiphy_radio_freq_range *r;
|
|
+ int i;
|
|
+
|
|
+ for (i = 0; i < radio->n_freq_range; i++) {
|
|
+ r = &radio->freq_range[i];
|
|
+ if (freq - width / 2 >= r->start_freq &&
|
|
+ freq + width / 2 <= r->end_freq)
|
|
+ return true;
|
|
+ }
|
|
+
|
|
+ return false;
|
|
+}
|
|
+
|
|
+bool cfg80211_radio_chandef_valid(const struct wiphy_radio *radio,
|
|
+ const struct cfg80211_chan_def *chandef)
|
|
+{
|
|
+ u32 freq, width;
|
|
+
|
|
+ freq = ieee80211_chandef_to_khz(chandef);
|
|
+ width = nl80211_chan_width_to_mhz(chandef->width);
|
|
+ if (!ieee80211_radio_freq_range_valid(radio, freq, width))
|
|
+ return false;
|
|
+
|
|
+ freq = MHZ_TO_KHZ(chandef->center_freq2);
|
|
+ if (freq && !ieee80211_radio_freq_range_valid(radio, freq, width))
|
|
+ return false;
|
|
+
|
|
+ return true;
|
|
+}
|
|
+EXPORT_SYMBOL(cfg80211_radio_chandef_valid);
|