]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
wifi: cfg80211: Add utility API to get radio index from channel
authorVasanthakumar Thiagarajan <vasanthakumar.thiagarajan@oss.qualcomm.com>
Tue, 27 May 2025 08:41:43 +0000 (14:11 +0530)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 20 Jun 2025 08:44:05 +0000 (10:44 +0200)
Add utility API cfg80211_get_radio_idx_by_chan() to retrieve the radio
index corresponding to a given channel in a multi-radio wiphy.

This utility function can be used when we want to check the radio-specific
data for a channel in a multi-radio wiphy. For example, it can help
determine the radio index required to handle a scan request. This index
can then be used to decide whether the scan can proceed without
interfering with ongoing DFS operations on another radio.

Signed-off-by: Vasanthakumar Thiagarajan <vasanthakumar.thiagarajan@oss.qualcomm.com>
Co-developed-by: Raj Kumar Bhagat <quic_rajkbhag@quicinc.com>
Signed-off-by: Raj Kumar Bhagat <quic_rajkbhag@quicinc.com>
Link: https://patch.msgid.link/20250527-mlo-dfs-acs-v2-1-92c2f37c81d9@quicinc.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
include/net/cfg80211.h
net/wireless/util.c

index d1848dc8ec99df36592517b46d58223be9bee7e5..7719a90ab4d75045983ac8a63360fd90472cbb7d 100644 (file)
@@ -9372,6 +9372,17 @@ int cfg80211_iter_combinations(struct wiphy *wiphy,
                               void (*iter)(const struct ieee80211_iface_combination *c,
                                            void *data),
                               void *data);
+/**
+ * cfg80211_get_radio_idx_by_chan - get the radio index by the channel
+ *
+ * @wiphy: the wiphy
+ * @chan: channel for which the supported radio index is required
+ *
+ * Return: radio index on success or a negative error code
+ */
+int cfg80211_get_radio_idx_by_chan(struct wiphy *wiphy,
+                                  const struct ieee80211_channel *chan);
+
 
 /**
  * cfg80211_stop_iface - trigger interface disconnection
index ed868c0f7ca8ed7a9e85e70c10a738f592eac1d6..e438f883f085b3aed0c0438d94957f08aa2c6688 100644 (file)
@@ -2516,6 +2516,30 @@ int cfg80211_check_combinations(struct wiphy *wiphy,
 }
 EXPORT_SYMBOL(cfg80211_check_combinations);
 
+int cfg80211_get_radio_idx_by_chan(struct wiphy *wiphy,
+                                  const struct ieee80211_channel *chan)
+{
+       const struct wiphy_radio *radio;
+       int i, j;
+       u32 freq;
+
+       if (!chan)
+               return -EINVAL;
+
+       freq = ieee80211_channel_to_khz(chan);
+       for (i = 0; i < wiphy->n_radio; i++) {
+               radio = &wiphy->radio[i];
+               for (j = 0; j < radio->n_freq_range; j++) {
+                       if (freq >= radio->freq_range[j].start_freq &&
+                           freq < radio->freq_range[j].end_freq)
+                               return i;
+               }
+       }
+
+       return -ENOENT;
+}
+EXPORT_SYMBOL(cfg80211_get_radio_idx_by_chan);
+
 int ieee80211_get_ratemask(struct ieee80211_supported_band *sband,
                           const u8 *rates, unsigned int n_rates,
                           u32 *mask)