]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
wifi: mac80211: Track NAN interface start/stop
authorIlan Peer <ilan.peer@intel.com>
Mon, 8 Sep 2025 11:13:04 +0000 (14:13 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Nov 2025 20:34:28 +0000 (15:34 -0500)
[ Upstream commit 8f79d2f13dd3b0af00a5303d4ff913767dd7684e ]

In case that NAN is started, mark the device as non idle,
and set LED triggering similar to scan and ROC. Set the
device to idle once NAN is stopped.

Signed-off-by: Ilan Peer <ilan.peer@intel.com>
Reviewed-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/20250908140015.2711d62fce22.I9b9f826490e50967a66788d713b0eba985879873@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/mac80211/cfg.c
net/mac80211/ieee80211_i.h
net/mac80211/iface.c

index 2890dde9b3bf4a095e3c23da634029a6d60f8cb0..2df4df75f19572acdc4c11ce4f0156f9171dbfb5 100644 (file)
@@ -285,6 +285,9 @@ static int ieee80211_start_nan(struct wiphy *wiphy,
 
        lockdep_assert_wiphy(sdata->local->hw.wiphy);
 
+       if (sdata->u.nan.started)
+               return -EALREADY;
+
        ret = ieee80211_check_combinations(sdata, NULL, 0, 0, -1);
        if (ret < 0)
                return ret;
@@ -294,12 +297,18 @@ static int ieee80211_start_nan(struct wiphy *wiphy,
                return ret;
 
        ret = drv_start_nan(sdata->local, sdata, conf);
-       if (ret)
+       if (ret) {
                ieee80211_sdata_stop(sdata);
+               return ret;
+       }
 
-       sdata->u.nan.conf = *conf;
+       sdata->u.nan.started = true;
+       ieee80211_recalc_idle(sdata->local);
 
-       return ret;
+       sdata->u.nan.conf.master_pref = conf->master_pref;
+       sdata->u.nan.conf.bands = conf->bands;
+
+       return 0;
 }
 
 static void ieee80211_stop_nan(struct wiphy *wiphy,
@@ -307,8 +316,13 @@ static void ieee80211_stop_nan(struct wiphy *wiphy,
 {
        struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
 
+       if (!sdata->u.nan.started)
+               return;
+
        drv_stop_nan(sdata->local, sdata);
+       sdata->u.nan.started = false;
        ieee80211_sdata_stop(sdata);
+       ieee80211_recalc_idle(sdata->local);
 }
 
 static int ieee80211_nan_change_conf(struct wiphy *wiphy,
index 2f017dbbcb975c392ecb17609faf047765150cb9..f0ac51cf66e61ec8184b7640f2fb4ec40dd1371c 100644 (file)
@@ -949,11 +949,13 @@ struct ieee80211_if_mntr {
  * struct ieee80211_if_nan - NAN state
  *
  * @conf: current NAN configuration
+ * @started: true iff NAN is started
  * @func_lock: lock for @func_inst_ids
  * @function_inst_ids: a bitmap of available instance_id's
  */
 struct ieee80211_if_nan {
        struct cfg80211_nan_conf conf;
+       bool started;
 
        /* protects function_inst_ids */
        spinlock_t func_lock;
index 209d6ffa8e4261c7a644e5b2b8e40574a4e534b1..69a8a2c21d8df86a3081581e8cf39981f3568b49 100644 (file)
@@ -108,6 +108,7 @@ static u32 __ieee80211_recalc_idle(struct ieee80211_local *local,
 {
        bool working, scanning, active;
        unsigned int led_trig_start = 0, led_trig_stop = 0;
+       struct ieee80211_sub_if_data *iter;
 
        lockdep_assert_wiphy(local->hw.wiphy);
 
@@ -118,6 +119,14 @@ static u32 __ieee80211_recalc_idle(struct ieee80211_local *local,
        working = !local->ops->remain_on_channel &&
                  !list_empty(&local->roc_list);
 
+       list_for_each_entry(iter, &local->interfaces, list) {
+               if (iter->vif.type == NL80211_IFTYPE_NAN &&
+                   iter->u.nan.started) {
+                       working = true;
+                       break;
+               }
+       }
+
        scanning = test_bit(SCAN_SW_SCANNING, &local->scanning) ||
                   test_bit(SCAN_ONCHANNEL_SCANNING, &local->scanning);