wifi: cfg80211: call reg_notifier for self managed wiphy from driver hint
authorWen Gong <quic_wgong@quicinc.com>
Wed, 1 Feb 2023 06:53:13 +0000 (01:53 -0500)
committerJohannes Berg <johannes.berg@intel.com>
Tue, 14 Feb 2023 11:37:39 +0000 (12:37 +0100)
Currently the regulatory driver does not call the regulatory callback
reg_notifier for self managed wiphys. Sometimes driver needs cfg80211
to calculate the info of ieee80211_channel such as flags and power,
and driver needs to get the info of ieee80211_channel after hint of
driver, but driver does not know when calculation of the info of
ieee80211_channel become finished, so add notify to driver in
reg_process_self_managed_hint() from cfg80211 is a good way, then
driver could get the correct info in callback of reg_notifier.

Signed-off-by: Wen Gong <quic_wgong@quicinc.com>
Link: https://lore.kernel.org/r/20230201065313.27203-1-quic_wgong@quicinc.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
include/net/cfg80211.h
net/wireless/reg.c

index c65f17d..15fb019 100644 (file)
@@ -4737,6 +4737,8 @@ struct cfg80211_ops {
  *     complete feature/interface combinations/etc. advertisement. No driver
  *     should set this flag for now.
  * @WIPHY_FLAG_SUPPORTS_EXT_KCK_32: The device supports 32-byte KCK keys.
+ * @WIPHY_FLAG_NOTIFY_REGDOM_BY_DRIVER: The device could handle reg notify for
+ *     NL80211_REGDOM_SET_BY_DRIVER.
  */
 enum wiphy_flags {
        WIPHY_FLAG_SUPPORTS_EXT_KEK_KCK         = BIT(0),
@@ -4762,6 +4764,7 @@ enum wiphy_flags {
        WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL        = BIT(21),
        WIPHY_FLAG_SUPPORTS_5_10_MHZ            = BIT(22),
        WIPHY_FLAG_HAS_CHANNEL_SWITCH           = BIT(23),
+       WIPHY_FLAG_NOTIFY_REGDOM_BY_DRIVER      = BIT(24),
 };
 
 /**
index af65196..0d40d6a 100644 (file)
@@ -3160,6 +3160,9 @@ static void reg_process_self_managed_hint(struct wiphy *wiphy)
        request.alpha2[1] = regd->alpha2[1];
        request.initiator = NL80211_REGDOM_SET_BY_DRIVER;
 
+       if (wiphy->flags & WIPHY_FLAG_NOTIFY_REGDOM_BY_DRIVER)
+               reg_call_notifier(wiphy, &request);
+
        nl80211_send_wiphy_reg_change_event(&request);
 }