]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: iwlwifi: mvm: refactor scan channel description a bit
authorJohannes Berg <johannes.berg@intel.com>
Sun, 1 Sep 2024 04:17:50 +0000 (07:17 +0300)
committerJohannes Berg <johannes.berg@intel.com>
Tue, 3 Sep 2024 09:55:26 +0000 (11:55 +0200)
The channel number is at the same position across all versions
of the channel description struct, so move it out of the union
that versions it. Also add __packed annotations to all of the
sub-structs and the union so it's packed correctly, and fully
document the structure.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Reviewed-by: Ilan Peer <ilan.peer@intel.com>
Reviewed-by: Daniel Gabay <daniel.gabay@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/20240901071542.e31623ae4201.I1ea69a8ec3d39492f39d84e31fb105b159359c28@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/scan.c

index 0aefdf353b214f9f35923e3f682b29c7476c142b..f486d624500beb4ec0168c7f8b6a98500e9eed37 100644 (file)
@@ -731,39 +731,46 @@ enum iwl_umac_scan_general_params_flags2 {
  * struct iwl_scan_channel_cfg_umac
  * @flags:             bitmap - 0-19:  directed scan to i'th ssid.
  * @channel_num:       channel number 1-13 etc.
- * @band:              band of channel: 0 for 2GHz, 1 for 5GHz
- * @iter_count:                repetition count for the channel.
- * @iter_interval:     interval between two scan iterations on one channel.
+ * @v1:                        command version 1
+ * @v1.iter_count:     repetition count for the channel.
+ * @v1.iter_interval:  interval between two scan iterations on one channel.
+ * @v2:                        command versions 2-4
+ * @v2.band:           band of channel: 0 for 2GHz, 1 for 5GHz
+ * @v2.iter_count:     repetition count for the channel.
+ * @v2.iter_interval:  interval between two scan iterations on one channel.
+ * @v5:                        command versions 5 and up
+ * @v5.iter_count:     repetition count for the channel.
+ * @v5.iter_interval:  interval between two scan iterations on one channel.
+ * @v5.psd_20:         highest PSD value for all APs known so far
+ *                     on this channel.
  */
 struct  iwl_scan_channel_cfg_umac {
 #define IWL_CHAN_CFG_FLAGS_BAND_POS 30
        __le32 flags;
+       u8 channel_num;
 
        /* All versions are of the same size, so use a union without adjusting
         * the command size later
         */
        union {
                struct {
-                       u8 channel_num;
                        u8 iter_count;
                        __le16 iter_interval;
-               } v1;  /* SCAN_CHANNEL_CONFIG_API_S_VER_1 */
+               } __packed v1;  /* SCAN_CHANNEL_CONFIG_API_S_VER_1 */
                struct {
-                       u8 channel_num;
                        u8 band;
                        u8 iter_count;
                        u8 iter_interval;
-                } v2; /* SCAN_CHANNEL_CONFIG_API_S_VER_2
-                       * SCAN_CHANNEL_CONFIG_API_S_VER_3
-                       * SCAN_CHANNEL_CONFIG_API_S_VER_4
-                       */
+               } __packed v2; /* SCAN_CHANNEL_CONFIG_API_S_VER_2
+                               * SCAN_CHANNEL_CONFIG_API_S_VER_3
+                               * SCAN_CHANNEL_CONFIG_API_S_VER_4
+                               */
                struct {
-                       u8 channel_num;
                        u8 psd_20;
                        u8 iter_count;
                        u8 iter_interval;
-               } v5;  /* SCAN_CHANNEL_CONFIG_API_S_VER_5 */
-       };
+               } __packed v5;  /* SCAN_CHANNEL_CONFIG_API_S_VER_5 */
+       } __packed;
 } __packed;
 
 /**
index 4ae6339f87c7f14d0eb59fdae2866363a6d888be..296d8c5622074164b1193e3abf9b691f7b113d92 100644 (file)
@@ -1594,7 +1594,7 @@ iwl_mvm_umac_scan_cfg_channels(struct iwl_mvm *mvm,
 
        for (i = 0; i < n_channels; i++) {
                channel_cfg[i].flags = cpu_to_le32(flags);
-               channel_cfg[i].v1.channel_num = channels[i]->hw_value;
+               channel_cfg[i].channel_num = channels[i]->hw_value;
                if (iwl_mvm_is_scan_ext_chan_supported(mvm)) {
                        enum nl80211_band band = channels[i]->band;
 
@@ -1626,13 +1626,13 @@ iwl_mvm_umac_scan_cfg_channels_v4(struct iwl_mvm *mvm,
                        &cp->channel_config[i];
 
                cfg->flags = cpu_to_le32(flags);
-               cfg->v2.channel_num = channels[i]->hw_value;
+               cfg->channel_num = channels[i]->hw_value;
                cfg->v2.band = iwl_mvm_phy_band_from_nl80211(band);
                cfg->v2.iter_count = 1;
                cfg->v2.iter_interval = 0;
 
                iwl_mvm_scan_ch_add_n_aps_override(vif_type,
-                                                  cfg->v2.channel_num,
+                                                  cfg->channel_num,
                                                   cfg->v2.band, bitmap,
                                                   bitmap_n_entries);
        }
@@ -1656,7 +1656,7 @@ iwl_mvm_umac_scan_cfg_channels_v7(struct iwl_mvm *mvm,
                u8 iwl_band = iwl_mvm_phy_band_from_nl80211(band);
 
                cfg->flags = cpu_to_le32(flags | n_aps_flag);
-               cfg->v2.channel_num = channels[i]->hw_value;
+               cfg->channel_num = channels[i]->hw_value;
                if (cfg80211_channel_is_psc(channels[i]))
                        cfg->flags = 0;
                cfg->v2.iter_count = 1;
@@ -1778,7 +1778,7 @@ iwl_mvm_umac_scan_cfg_channels_v7_6g(struct iwl_mvm *mvm,
                    !params->n_6ghz_params && params->n_ssids)
                        continue;
 
-               cfg->v1.channel_num = params->channels[i]->hw_value;
+               cfg->channel_num = params->channels[i]->hw_value;
                if (version < 17)
                        cfg->v2.band = PHY_BAND_6;
                else
@@ -2466,7 +2466,7 @@ iwl_mvm_scan_umac_fill_ch_p_v7(struct iwl_mvm *mvm,
                        if (!cfg80211_channel_is_psc(channel))
                                continue;
 
-                       cfg->v5.channel_num = channel->hw_value;
+                       cfg->channel_num = channel->hw_value;
                        cfg->v5.iter_count = 1;
                        cfg->v5.iter_interval = 0;