wifi: cfg80211: call reg_call_notifier on beacon hints
authorAbhishek Kumar <kuabhs@chromium.org>
Thu, 29 Jun 2023 03:52:54 +0000 (03:52 +0000)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 13 Sep 2023 10:34:01 +0000 (12:34 +0200)
Currently the channel property updates are not propagated to
driver. This causes issues in the discovery of hidden SSIDs and
fails to connect to them.
This change defines a new wiphy flag which when enabled by vendor
driver, the reg_call_notifier callback will be trigger on beacon
hints. This ensures that the channel property changes are visible
to the vendor driver. The vendor changes the channels for active
scans. This fixes the discovery issue of hidden SSID.

Signed-off-by: Abhishek Kumar <kuabhs@chromium.org>
Link: https://lore.kernel.org/r/20230629035254.1.I059fe585f9f9e896c2d51028ef804d197c8c009e@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
include/net/cfg80211.h
net/wireless/reg.c

index d69841f64459d167c78b40c963e8703fba3042c4..0551a38d6760ba31f8e7b56e3431df0b1c1a0594 100644 (file)
@@ -4861,6 +4861,8 @@ struct cfg80211_ops {
  * @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.
+ * @WIPHY_FLAG_CHANNEL_CHANGE_ON_BEACON: reg_call_notifier() is called if driver
+ *     set this flag to update channels on beacon hints.
  */
 enum wiphy_flags {
        WIPHY_FLAG_SUPPORTS_EXT_KEK_KCK         = BIT(0),
@@ -4887,6 +4889,7 @@ enum wiphy_flags {
        WIPHY_FLAG_SUPPORTS_5_10_MHZ            = BIT(22),
        WIPHY_FLAG_HAS_CHANNEL_SWITCH           = BIT(23),
        WIPHY_FLAG_NOTIFY_REGDOM_BY_DRIVER      = BIT(24),
+       WIPHY_FLAG_CHANNEL_CHANGE_ON_BEACON     = BIT(25),
 };
 
 /**
index 8a99eafa4b62f4e23601b6d48eb2c2504c4df293..33e2570f2bd6cd86204e710fa213864d3d85f414 100644 (file)
@@ -2151,6 +2151,13 @@ static bool reg_is_world_roaming(struct wiphy *wiphy)
        return false;
 }
 
+static void reg_call_notifier(struct wiphy *wiphy,
+                             struct regulatory_request *request)
+{
+       if (wiphy->reg_notifier)
+               wiphy->reg_notifier(wiphy, request);
+}
+
 static void handle_reg_beacon(struct wiphy *wiphy, unsigned int chan_idx,
                              struct reg_beacon *reg_beacon)
 {
@@ -2158,6 +2165,7 @@ static void handle_reg_beacon(struct wiphy *wiphy, unsigned int chan_idx,
        struct ieee80211_channel *chan;
        bool channel_changed = false;
        struct ieee80211_channel chan_before;
+       struct regulatory_request *lr = get_last_request();
 
        sband = wiphy->bands[reg_beacon->chan.band];
        chan = &sband->channels[chan_idx];
@@ -2183,8 +2191,11 @@ static void handle_reg_beacon(struct wiphy *wiphy, unsigned int chan_idx,
                channel_changed = true;
        }
 
-       if (channel_changed)
+       if (channel_changed) {
                nl80211_send_beacon_hint_event(wiphy, &chan_before, chan);
+               if (wiphy->flags & WIPHY_FLAG_CHANNEL_CHANGE_ON_BEACON)
+                       reg_call_notifier(wiphy, lr);
+       }
 }
 
 /*
@@ -2327,13 +2338,6 @@ static void reg_process_ht_flags(struct wiphy *wiphy)
                reg_process_ht_flags_band(wiphy, wiphy->bands[band]);
 }
 
-static void reg_call_notifier(struct wiphy *wiphy,
-                             struct regulatory_request *request)
-{
-       if (wiphy->reg_notifier)
-               wiphy->reg_notifier(wiphy, request);
-}
-
 static bool reg_wdev_chan_valid(struct wiphy *wiphy, struct wireless_dev *wdev)
 {
        struct cfg80211_chan_def chandef = {};