TOF_RANGE_RESPONSE_NOTIF = 0xFF,
};
+/**
+ * enum iwl_location_frame_format - location frame formats
+ * @IWL_LOCATION_FRAME_FORMAT_LEGACY: legacy
+ * @IWL_LOCATION_FRAME_FORMAT_HT: HT
+ * @IWL_LOCATION_FRAME_FORMAT_VHT: VHT
+ * @IWL_LOCATION_FRAME_FORMAT_HE: HE
+ */
+enum iwl_location_frame_format {
+ IWL_LOCATION_FRAME_FORMAT_LEGACY,
+ IWL_LOCATION_FRAME_FORMAT_HT,
+ IWL_LOCATION_FRAME_FORMAT_VHT,
+ IWL_LOCATION_FRAME_FORMAT_HE,
+};
+
+/**
+ * enum iwl_location_bw - location bandwidth selection
+ * @IWL_LOCATION_BW_20MHZ: 20 MHz
+ * @IWL_LOCATION_BW_40MHZ: 40 MHz
+ * @IWL_LOCATION_BW_80MHZ: 80 MHz
+ * @IWL_LOCATION_BW_160MHZ: 160 MHz
+ * @IWL_LOCATION_BW_320MHZ: 320 MHz
+ */
+enum iwl_location_bw {
+ IWL_LOCATION_BW_20MHZ,
+ IWL_LOCATION_BW_40MHZ,
+ IWL_LOCATION_BW_80MHZ,
+ IWL_LOCATION_BW_160MHZ,
+ IWL_LOCATION_BW_320MHZ,
+};
+
+/**
+ * enum iwl_location_format_bw - format/BW encoding
+ * @IWL_LOCATION_FMT_BW_FORMAT: &enum iwl_location_frame_format
+ * @IWL_LOCATION_FMT_BW_BANDWIDTH: &enum iwl_location_bw
+ */
+enum iwl_location_format_bw {
+ IWL_LOCATION_FMT_BW_FORMAT = 0x0f,
+ IWL_LOCATION_FMT_BW_BANDWIDTH = 0xf0,
+};
+
/**
* struct iwl_tof_config_cmd - ToF configuration
* @tof_disabled: indicates if ToF is disabled (or not)
* struct iwl_tof_responder_config_cmd_v7 - ToF AP mode (for debug)
* @cmd_valid_fields: &iwl_tof_responder_cmd_valid_field
* @responder_cfg_flags: &iwl_tof_responder_cfg_flags
- * @format_bw: bits 0 - 3: &enum iwl_location_frame_format.
- * bits 4 - 7: &enum iwl_location_bw.
+ * @format_bw: &enum iwl_location_format_bw
* @rate: current AP rate
* @channel_num: current AP Channel
* @ctrl_ch_position: coding of the control channel position relative to
* struct iwl_tof_responder_config_cmd_v8 - ToF AP mode (for debug)
* @cmd_valid_fields: &iwl_tof_responder_cmd_valid_field
* @responder_cfg_flags: &iwl_tof_responder_cfg_flags
- * @format_bw: bits 0 - 3: &enum iwl_location_frame_format.
- * bits 4 - 7: &enum iwl_location_bw.
+ * @format_bw: &enum iwl_location_format_bw
* @rate: current AP rate
* @channel_num: current AP Channel
* @ctrl_ch_position: coding of the control channel position relative to
* struct iwl_tof_responder_config_cmd_v9 - ToF AP mode (for debug)
* @cmd_valid_fields: &iwl_tof_responder_cmd_valid_field
* @responder_cfg_flags: &iwl_tof_responder_cfg_flags
- * @format_bw: bits 0 - 3: &enum iwl_location_frame_format.
- * bits 4 - 7: &enum iwl_location_bw.
+ * @format_bw: &enum iwl_location_format_bw
* @bss_color: current AP bss_color
* @channel_num: current AP Channel
* @ctrl_ch_position: coding of the control channel position relative to
* struct iwl_tof_responder_config_cmd - ToF AP mode
* @cmd_valid_fields: &iwl_tof_responder_cmd_valid_field
* @responder_cfg_flags: &iwl_tof_responder_cfg_flags
- * @format_bw: bits 0 - 3: &enum iwl_location_frame_format.
- * bits 4 - 7: &enum iwl_location_bw.
+ * @format_bw: &enum iwl_location_format_bw
* @bss_color: current AP bss_color
* @channel_num: current AP Channel
* @ctrl_ch_position: coding of the control channel position relative to
__le32 tsf_delta;
} __packed; /* LOCATION_RANGE_REQ_AP_ENTRY_CMD_API_S_VER_3 */
-/**
- * enum iwl_location_frame_format - location frame formats
- * @IWL_LOCATION_FRAME_FORMAT_LEGACY: legacy
- * @IWL_LOCATION_FRAME_FORMAT_HT: HT
- * @IWL_LOCATION_FRAME_FORMAT_VHT: VHT
- * @IWL_LOCATION_FRAME_FORMAT_HE: HE
- */
-enum iwl_location_frame_format {
- IWL_LOCATION_FRAME_FORMAT_LEGACY,
- IWL_LOCATION_FRAME_FORMAT_HT,
- IWL_LOCATION_FRAME_FORMAT_VHT,
- IWL_LOCATION_FRAME_FORMAT_HE,
-};
-
-/**
- * enum iwl_location_bw - location bandwidth selection
- * @IWL_LOCATION_BW_20MHZ: 20MHz
- * @IWL_LOCATION_BW_40MHZ: 40MHz
- * @IWL_LOCATION_BW_80MHZ: 80MHz
- * @IWL_LOCATION_BW_160MHZ: 160MHz
- */
-enum iwl_location_bw {
- IWL_LOCATION_BW_20MHZ,
- IWL_LOCATION_BW_40MHZ,
- IWL_LOCATION_BW_80MHZ,
- IWL_LOCATION_BW_160MHZ,
-};
-
#define TK_11AZ_LEN 32
-#define LOCATION_BW_POS 4
-
/**
* struct iwl_tof_range_req_ap_entry_v4 - AP configuration parameters
* @initiator_ap_flags: see &enum iwl_initiator_ap_flags.
* @channel_num: AP Channel number
- * @format_bw: bits 0 - 3: &enum iwl_location_frame_format.
- * bits 4 - 7: &enum iwl_location_bw.
+ * @format_bw: &enum iwl_location_format_bw
* @ctrl_ch_position: Coding of the control channel position relative to the
* center frequency, see iwl_mvm_get_ctrl_pos().
* @ftmr_max_retries: Max number of retries to send the FTMR in case of no
* struct iwl_tof_range_req_ap_entry_v6 - AP configuration parameters
* @initiator_ap_flags: see &enum iwl_initiator_ap_flags.
* @channel_num: AP Channel number
- * @format_bw: bits 0 - 3: &enum iwl_location_frame_format.
- * bits 4 - 7: &enum iwl_location_bw.
+ * @format_bw: &enum iwl_location_format_bw
* @ctrl_ch_position: Coding of the control channel position relative to the
* center frequency, see iwl_mvm_get_ctrl_pos().
* @ftmr_max_retries: Max number of retries to send the FTMR in case of no
* struct iwl_tof_range_req_ap_entry_v7 - AP configuration parameters
* @initiator_ap_flags: see &enum iwl_initiator_ap_flags.
* @channel_num: AP Channel number
- * @format_bw: bits 0 - 3: &enum iwl_location_frame_format.
- * bits 4 - 7: &enum iwl_location_bw.
+ * @format_bw: &enum iwl_location_format_bw
* @ctrl_ch_position: Coding of the control channel position relative to the
* center frequency, see iwl_mvm_get_ctrl_pos().
* @ftmr_max_retries: Max number of retries to send the FTMR in case of no
* struct iwl_tof_range_req_ap_entry_v8 - AP configuration parameters
* @initiator_ap_flags: see &enum iwl_initiator_ap_flags.
* @channel_num: AP Channel number
- * @format_bw: bits 0 - 3: &enum iwl_location_frame_format.
- * bits 4 - 7: &enum iwl_location_bw.
+ * @format_bw: &enum iwl_location_format_bw
* @ctrl_ch_position: Coding of the control channel position relative to the
* center frequency, see iwl_mvm_get_ctrl_pos().
* @ftmr_max_retries: Max number of retries to send the FTMR in case of no
* struct iwl_tof_range_req_ap_entry_v9 - AP configuration parameters
* @initiator_ap_flags: see &enum iwl_initiator_ap_flags.
* @channel_num: AP Channel number
- * @format_bw: bits 0 - 3: &enum iwl_location_frame_format.
- * bits 4 - 7: &enum iwl_location_bw.
+ * @format_bw: &enum iwl_location_format_bw
* @ctrl_ch_position: Coding of the control channel position relative to the
* center frequency, see iwl_mvm_get_ctrl_pos().
* @ftmr_max_retries: Max number of retries to send the FTMR in case of no
* @initiator_ap_flags: see &enum iwl_initiator_ap_flags.
* @band: 0 for 5.2 GHz, 1 for 2.4 GHz, 2 for 6GHz
* @channel_num: AP Channel number
- * @format_bw: bits 0 - 3: &enum iwl_location_frame_format.
- * bits 4 - 7: &enum iwl_location_bw.
+ * @format_bw: &enum iwl_location_format_bw
* @ctrl_ch_position: Coding of the control channel position relative to the
* center frequency, see iwl_mvm_get_ctrl_pos().
* @bssid: AP's BSSID
switch (peer->chandef.width) {
case NL80211_CHAN_WIDTH_20_NOHT:
- target->format_bw = IWL_LOCATION_FRAME_FORMAT_LEGACY;
- target->format_bw |= IWL_LOCATION_BW_20MHZ << LOCATION_BW_POS;
+ target->format_bw = u8_encode_bits(IWL_LOCATION_FRAME_FORMAT_LEGACY,
+ IWL_LOCATION_FMT_BW_FORMAT);
+ target->format_bw |= u8_encode_bits(IWL_LOCATION_BW_20MHZ,
+ IWL_LOCATION_FMT_BW_BANDWIDTH);
break;
case NL80211_CHAN_WIDTH_20:
- target->format_bw = IWL_LOCATION_FRAME_FORMAT_HT;
- target->format_bw |= IWL_LOCATION_BW_20MHZ << LOCATION_BW_POS;
+ target->format_bw = u8_encode_bits(IWL_LOCATION_FRAME_FORMAT_HT,
+ IWL_LOCATION_FMT_BW_FORMAT);
+ target->format_bw |= u8_encode_bits(IWL_LOCATION_BW_20MHZ,
+ IWL_LOCATION_FMT_BW_BANDWIDTH);
break;
case NL80211_CHAN_WIDTH_40:
- target->format_bw = IWL_LOCATION_FRAME_FORMAT_HT;
- target->format_bw |= IWL_LOCATION_BW_40MHZ << LOCATION_BW_POS;
+ target->format_bw = u8_encode_bits(IWL_LOCATION_FRAME_FORMAT_HT,
+ IWL_LOCATION_FMT_BW_FORMAT);
+ target->format_bw |= u8_encode_bits(IWL_LOCATION_BW_40MHZ,
+ IWL_LOCATION_FMT_BW_BANDWIDTH);
break;
case NL80211_CHAN_WIDTH_80:
- target->format_bw = IWL_LOCATION_FRAME_FORMAT_VHT;
- target->format_bw |= IWL_LOCATION_BW_80MHZ << LOCATION_BW_POS;
+ target->format_bw = u8_encode_bits(IWL_LOCATION_FRAME_FORMAT_VHT,
+ IWL_LOCATION_FMT_BW_FORMAT);
+ target->format_bw |= u8_encode_bits(IWL_LOCATION_BW_80MHZ,
+ IWL_LOCATION_FMT_BW_BANDWIDTH);
break;
case NL80211_CHAN_WIDTH_160:
- target->format_bw = IWL_LOCATION_FRAME_FORMAT_HE;
- target->format_bw |= IWL_LOCATION_BW_160MHZ << LOCATION_BW_POS;
+ target->format_bw = u8_encode_bits(IWL_LOCATION_FRAME_FORMAT_HE,
+ IWL_LOCATION_FMT_BW_FORMAT);
+ target->format_bw |= u8_encode_bits(IWL_LOCATION_BW_160MHZ,
+ IWL_LOCATION_FMT_BW_BANDWIDTH);
break;
default:
IWL_ERR(mld, "Unsupported BW in FTM request (%d)\n",
switch (peer->chandef.width) {
case NL80211_CHAN_WIDTH_20_NOHT:
- *format_bw = IWL_LOCATION_FRAME_FORMAT_LEGACY;
- *format_bw |= IWL_LOCATION_BW_20MHZ << LOCATION_BW_POS;
+ *format_bw = u8_encode_bits(IWL_LOCATION_FRAME_FORMAT_LEGACY,
+ IWL_LOCATION_FMT_BW_FORMAT);
+ *format_bw |= u8_encode_bits(IWL_LOCATION_BW_20MHZ,
+ IWL_LOCATION_FMT_BW_BANDWIDTH);
break;
case NL80211_CHAN_WIDTH_20:
- *format_bw = IWL_LOCATION_FRAME_FORMAT_HT;
- *format_bw |= IWL_LOCATION_BW_20MHZ << LOCATION_BW_POS;
+ *format_bw = u8_encode_bits(IWL_LOCATION_FRAME_FORMAT_HT,
+ IWL_LOCATION_FMT_BW_FORMAT);
+ *format_bw |= u8_encode_bits(IWL_LOCATION_BW_20MHZ,
+ IWL_LOCATION_FMT_BW_BANDWIDTH);
break;
case NL80211_CHAN_WIDTH_40:
- *format_bw = IWL_LOCATION_FRAME_FORMAT_HT;
- *format_bw |= IWL_LOCATION_BW_40MHZ << LOCATION_BW_POS;
+ *format_bw = u8_encode_bits(IWL_LOCATION_FRAME_FORMAT_HT,
+ IWL_LOCATION_FMT_BW_FORMAT);
+ *format_bw |= u8_encode_bits(IWL_LOCATION_BW_40MHZ,
+ IWL_LOCATION_FMT_BW_BANDWIDTH);
break;
case NL80211_CHAN_WIDTH_80:
- *format_bw = IWL_LOCATION_FRAME_FORMAT_VHT;
- *format_bw |= IWL_LOCATION_BW_80MHZ << LOCATION_BW_POS;
+ *format_bw = u8_encode_bits(IWL_LOCATION_FRAME_FORMAT_VHT,
+ IWL_LOCATION_FMT_BW_FORMAT);
+ *format_bw |= u8_encode_bits(IWL_LOCATION_BW_80MHZ,
+ IWL_LOCATION_FMT_BW_BANDWIDTH);
break;
case NL80211_CHAN_WIDTH_160:
cmd_ver = iwl_fw_lookup_cmd_ver(mvm->fw,
IWL_FW_CMD_VER_UNKNOWN);
if (cmd_ver >= 13) {
- *format_bw = IWL_LOCATION_FRAME_FORMAT_HE;
- *format_bw |= IWL_LOCATION_BW_160MHZ << LOCATION_BW_POS;
+ *format_bw = u8_encode_bits(IWL_LOCATION_FRAME_FORMAT_HE,
+ IWL_LOCATION_FMT_BW_FORMAT);
+ *format_bw |= u8_encode_bits(IWL_LOCATION_BW_160MHZ,
+ IWL_LOCATION_FMT_BW_BANDWIDTH);
break;
}
fallthrough;
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
/*
* Copyright (C) 2015-2017 Intel Deutschland GmbH
- * Copyright (C) 2018-2024 Intel Corporation
+ * Copyright (C) 2018-2024, 2026 Intel Corporation
*/
#include <net/cfg80211.h>
#include <linux/etherdevice.h>
{
switch (chandef->width) {
case NL80211_CHAN_WIDTH_20_NOHT:
- *format_bw = IWL_LOCATION_FRAME_FORMAT_LEGACY;
- *format_bw |= IWL_LOCATION_BW_20MHZ << LOCATION_BW_POS;
+ *format_bw = u8_encode_bits(IWL_LOCATION_FRAME_FORMAT_LEGACY,
+ IWL_LOCATION_FMT_BW_FORMAT);
+ *format_bw |= u8_encode_bits(IWL_LOCATION_BW_20MHZ,
+ IWL_LOCATION_FMT_BW_BANDWIDTH);
break;
case NL80211_CHAN_WIDTH_20:
- *format_bw = IWL_LOCATION_FRAME_FORMAT_HT;
- *format_bw |= IWL_LOCATION_BW_20MHZ << LOCATION_BW_POS;
+ *format_bw = u8_encode_bits(IWL_LOCATION_FRAME_FORMAT_HT,
+ IWL_LOCATION_FMT_BW_FORMAT);
+ *format_bw |= u8_encode_bits(IWL_LOCATION_BW_20MHZ,
+ IWL_LOCATION_FMT_BW_BANDWIDTH);
break;
case NL80211_CHAN_WIDTH_40:
- *format_bw = IWL_LOCATION_FRAME_FORMAT_HT;
- *format_bw |= IWL_LOCATION_BW_40MHZ << LOCATION_BW_POS;
+ *format_bw = u8_encode_bits(IWL_LOCATION_FRAME_FORMAT_HT,
+ IWL_LOCATION_FMT_BW_FORMAT);
+ *format_bw |= u8_encode_bits(IWL_LOCATION_BW_40MHZ,
+ IWL_LOCATION_FMT_BW_BANDWIDTH);
*ctrl_ch_position = iwl_mvm_get_ctrl_pos(chandef);
break;
case NL80211_CHAN_WIDTH_80:
- *format_bw = IWL_LOCATION_FRAME_FORMAT_VHT;
- *format_bw |= IWL_LOCATION_BW_80MHZ << LOCATION_BW_POS;
+ *format_bw = u8_encode_bits(IWL_LOCATION_FRAME_FORMAT_VHT,
+ IWL_LOCATION_FMT_BW_FORMAT);
+ *format_bw |= u8_encode_bits(IWL_LOCATION_BW_80MHZ,
+ IWL_LOCATION_FMT_BW_BANDWIDTH);
*ctrl_ch_position = iwl_mvm_get_ctrl_pos(chandef);
break;
case NL80211_CHAN_WIDTH_160:
if (cmd_ver >= 9) {
- *format_bw = IWL_LOCATION_FRAME_FORMAT_HE;
- *format_bw |= IWL_LOCATION_BW_160MHZ << LOCATION_BW_POS;
+ *format_bw = u8_encode_bits(IWL_LOCATION_FRAME_FORMAT_HE,
+ IWL_LOCATION_FMT_BW_FORMAT);
+ *format_bw |= u8_encode_bits(IWL_LOCATION_BW_160MHZ,
+ IWL_LOCATION_FMT_BW_BANDWIDTH);
*ctrl_ch_position = iwl_mvm_get_ctrl_pos(chandef);
break;
}