wifi: iwlwifi: mvm: add the firmware API for channel survey
authorBenjamin Berg <benjamin.berg@intel.com>
Mon, 6 May 2024 07:04:12 +0000 (10:04 +0300)
committerJohannes Berg <johannes.berg@intel.com>
Mon, 6 May 2024 14:33:25 +0000 (16:33 +0200)
When requested, the firmware can return per-channel survey information
generally used for ACS (automatic channel selection). Add the API for
this, which consists of a flag and a new channel survey notification.

Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://msgid.link/20240506095953.1facde532676.I3864ac4bc0fecb7fd5136e85c07585ab7100234b@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/intel/iwlwifi/fw/api/scan.h
drivers/net/wireless/intel/iwlwifi/mvm/ops.c

index 93078f8cc08c03d6b8c9b4fd0e8699845d175568..6684506f4fc481001b8b1d4497d2e8dfd7db2164 100644 (file)
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
 /*
- * Copyright (C) 2012-2014, 2018-2023 Intel Corporation
+ * Copyright (C) 2012-2014, 2018-2024 Intel Corporation
  * Copyright (C) 2013-2015 Intel Mobile Communications GmbH
  * Copyright (C) 2016-2017 Intel Deutschland GmbH
  */
  * enum iwl_scan_subcmd_ids - scan commands
  */
 enum iwl_scan_subcmd_ids {
+       /**
+        * @CHANNEL_SURVEY_NOTIF: &struct iwl_umac_scan_channel_survey_notif
+        */
+       CHANNEL_SURVEY_NOTIF = 0xFB,
        /**
         * @OFFLOAD_MATCH_INFO_NOTIF: &struct iwl_scan_offload_match_info
         */
@@ -62,6 +66,8 @@ struct iwl_ssid_ie {
 #define IWL_FAST_SCHED_SCAN_ITERATIONS 3
 #define IWL_MAX_SCHED_SCAN_PLANS 2
 
+#define IWL_MAX_NUM_NOISE_RESULTS 22
+
 enum scan_framework_client {
        SCAN_CLIENT_SCHED_SCAN          = BIT(0),
        SCAN_CLIENT_NETDETECT           = BIT(1),
@@ -642,10 +648,13 @@ enum iwl_umac_scan_general_flags {
  *     notification per channel or not.
  * @IWL_UMAC_SCAN_GEN_FLAGS2_ALLOW_CHNL_REORDER: Whether to allow channel
  *     reorder optimization or not.
+ * @IWL_UMAC_SCAN_GEN_FLAGS2_COLLECT_CHANNEL_STATS: Enable channel statistics
+ *     collection when #IWL_UMAC_SCAN_GEN_FLAGS_V2_FORCE_PASSIVE is set.
  */
 enum iwl_umac_scan_general_flags2 {
        IWL_UMAC_SCAN_GEN_FLAGS2_NOTIF_PER_CHNL         = BIT(0),
        IWL_UMAC_SCAN_GEN_FLAGS2_ALLOW_CHNL_REORDER     = BIT(1),
+       IWL_UMAC_SCAN_GEN_FLAGS2_COLLECT_CHANNEL_STATS  = BIT(3),
 };
 
 /**
@@ -1258,4 +1267,26 @@ struct iwl_umac_scan_iter_complete_notif {
        struct iwl_scan_results_notif results[];
 } __packed; /* SCAN_ITER_COMPLETE_NTF_UMAC_API_S_VER_2 */
 
+/**
+ * struct iwl_umac_scan_channel_survey_notif - data for survey
+ * @channel: the channel scanned
+ * @band: band of channel
+ * @noise: noise floor measurements in negative dBm, invalid 0xff
+ * @reserved: for future use and alignment
+ * @active_time: time in ms the radio was turned on (on the channel)
+ * @busy_time: time in ms the channel was sensed busy, 0 for a clean channel
+ * @tx_time: time the radio spent transmitting data
+ * @rx_time: time the radio spent receiving data
+ */
+struct iwl_umac_scan_channel_survey_notif {
+       __le32 channel;
+       __le32 band;
+       u8 noise[IWL_MAX_NUM_NOISE_RESULTS];
+       u8 reserved[2];
+       __le32 active_time;
+       __le32 busy_time;
+       __le32 tx_time;
+       __le32 rx_time;
+} __packed; /* SCAN_CHANNEL_SURVEY_NTF_API_S_VER_1 */
+
 #endif /* __iwl_fw_api_scan_h__ */
index b27a032079387cfa76ddc93d6ca60268d2e25796..c52e69743c804ba0c87a414439ef9c05b1acb32d 100644 (file)
@@ -651,6 +651,7 @@ static const struct iwl_hcmd_names iwl_mvm_statistics_names[] = {
  * Access is done through binary search
  */
 static const struct iwl_hcmd_names iwl_mvm_scan_names[] = {
+       HCMD_NAME(CHANNEL_SURVEY_NOTIF),
        HCMD_NAME(OFFLOAD_MATCH_INFO_NOTIF),
 };