Skip to contentSkip to conversation

iwlwifi: updates intended for v5.15 2021-08-20

PATCH New Luca Coelho 2 participants 24 messages Aug 20, 2021 – Oct 22, 2021 Intel wireless wifi link (iwlwifi)

lore
Share & tools
lore
#0 lore raw

cover iwlwifi: updates intended for v5.15 2021-08-20

From: Luca Coelho <[email protected]>

Hi,

Here's the seventh set of patches intended for v5.15. It's the usual development, new features, cleanups and bugfixes.

The changes are:

* Support few new FW command versions;
* Ongoing work on support for Bz devices;
* Add new DHC framework to help with debugging of FW flows;
* Some other small fixes, clean-ups and improvements.

As usual, I'm pushing this to a pending branch, for kbuild bot, and will send a pull-request later.

Please review.

Cheers,
Luca.

Avraham Stern (2):
iwlwifi: mvm: add support for range request command version 13
iwlwifi: mvm: add support for resonder config command version 9

Dror Moshe (1):
iwlwifi: move get pnvm file name to a separate function

Gregory Greenman (1):
iwlwifi: mvm: introduce iwl_stored_beacon_notif_v3

Ilan Peer (1):
iwlwifi: mvm: Fix scan channel flags settings

Johannes Berg (1):
iwlwifi: mvm: don't use FW key ID in beacon protection

Luca Coelho (2):
iwlwifi: export DHC framework and add first public entry, twt_setup
iwlwifi: mvm: add fixed_rate debugfs entry to public DHC

Matti Gottlieb (3):
iwlwifi: Add support for getting rf id with blank otp
iwlwifi: Add support for more BZ HWs
iwlwifi: Start scratch debug register for Bz family

Shaul Triebitz (1):
iwlwifi: mvm: support broadcast TWT alone

 drivers/net/wireless/intel/iwlwifi/Kconfig    |   6 +
 .../net/wireless/intel/iwlwifi/cfg/22000.c    |  23 +++
 .../wireless/intel/iwlwifi/fw/api/commands.h  |   5 +
 .../net/wireless/intel/iwlwifi/fw/api/dhc.h   | 132 ++++++++++++
 .../wireless/intel/iwlwifi/fw/api/location.h  | 189 +++++++++++++++++-
 .../wireless/intel/iwlwifi/fw/api/offload.h   |  31 ++-
 .../net/wireless/intel/iwlwifi/fw/api/rs.h    |  40 +++-
 drivers/net/wireless/intel/iwlwifi/fw/dbg.c   |   2 +-
 drivers/net/wireless/intel/iwlwifi/fw/dump.c  |   7 +
 .../wireless/intel/iwlwifi/fw/error-dump.h    |   4 -
 drivers/net/wireless/intel/iwlwifi/fw/pnvm.c  |  13 +-
 drivers/net/wireless/intel/iwlwifi/fw/pnvm.h  |  20 ++
 .../net/wireless/intel/iwlwifi/iwl-config.h   |   3 +
 drivers/net/wireless/intel/iwlwifi/iwl-csr.h  |   7 +
 drivers/net/wireless/intel/iwlwifi/iwl-prph.h |  39 ++++
 .../wireless/intel/iwlwifi/mvm/constants.h    |   5 +-
 .../wireless/intel/iwlwifi/mvm/debugfs-vif.c  |  87 ++++++++
 .../net/wireless/intel/iwlwifi/mvm/debugfs.c  |  46 +++++
 .../intel/iwlwifi/mvm/ftm-initiator.c         |  85 ++++++--
 .../intel/iwlwifi/mvm/ftm-responder.c         |  27 ++-
 .../net/wireless/intel/iwlwifi/mvm/fw-api.h   |   3 +-
 .../net/wireless/intel/iwlwifi/mvm/mac-ctxt.c |  41 +++-
 drivers/net/wireless/intel/iwlwifi/mvm/ops.c  |   3 +-
 .../net/wireless/intel/iwlwifi/mvm/rs-fw.c    |  33 +++
 drivers/net/wireless/intel/iwlwifi/mvm/rs.h   |  10 +-
 drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c |  41 ++--
 drivers/net/wireless/intel/iwlwifi/mvm/scan.c |   2 +-
 drivers/net/wireless/intel/iwlwifi/pcie/drv.c | 111 ++++++++++
 .../wireless/intel/iwlwifi/pcie/trans-gen2.c  |   8 +-
 29 files changed, 939 insertions(+), 84 deletions(-)
 create mode 100644 drivers/net/wireless/intel/iwlwifi/fw/api/dhc.h
Signature · 1 line
2.33.0
#1 lore raw

PATCH 1/12 iwlwifi: mvm: add support for range request command version 13

From: Avraham Stern <[email protected]>

This version adds the following configuration options:
1. Set the BSS color for NDP ranging
2. Set the minimum and maximum time between measurements for non trigger based NDP ranging.
3. Terminate the session in case the responder requests LMR feedback.

---
 .../wireless/intel/iwlwifi/fw/api/location.h  | 119 +++++++++++++++++-
 .../wireless/intel/iwlwifi/mvm/constants.h    |   5 +-
 .../intel/iwlwifi/mvm/ftm-initiator.c         |  85 +++++++++++--
 3 files changed, 194 insertions(+), 15 deletions(-)
drivers/net/wireless/intel/iwlwifi/fw/api/location.h +118 -1
index 0e38eb1cd75d..0a8681d9687c 100644
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
 /*
  * Copyright (C) 2015-2017 Intel Deutschland GmbH
- * Copyright (C) 2018-2020 Intel Corporation
+ * Copyright (C) 2018-2021 Intel Corporation
  */
 #ifndef __iwl_fw_api_location_h__
 #define __iwl_fw_api_location_h__
@@ -489,6 +489,10 @@ struct iwl_tof_range_req_ap_entry_v2 {
  *      instead of fw internal values.
  * @IWL_INITIATOR_AP_FLAGS_PMF: request to protect the negotiation and LMR
  *      frames with protected management frames.
+ * @IWL_INITIATOR_AP_FLAGS_TERMINATE_ON_LMR_FEEDBACK: terminate the session if
+ *	the responder asked for LMR feedback although the initiator did not set
+ *	the LMR feedback bit in the FTM request. If not set, the initiator will
+ *	continue with the session and will provide the LMR feedback.
  */
 enum iwl_initiator_ap_flags {
 	IWL_INITIATOR_AP_FLAGS_ASAP = BIT(1),
@@ -504,6 +508,7 @@ enum iwl_initiator_ap_flags {
 	IWL_INITIATOR_AP_FLAGS_LMR_FEEDBACK = BIT(12),
 	IWL_INITIATOR_AP_FLAGS_USE_CALIB = BIT(13),
 	IWL_INITIATOR_AP_FLAGS_PMF = BIT(14),
+	IWL_INITIATOR_AP_FLAGS_TERMINATE_ON_LMR_FEEDBACK = BIT(15),
 };
 
 /**
@@ -794,6 +799,90 @@ struct iwl_tof_range_req_ap_entry_v8 {
 	u8 i2r_max_total_ltf;
 } __packed; /* LOCATION_RANGE_REQ_AP_ENTRY_CMD_API_S_VER_8 */
 
+/**
+ * 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.
+ * @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
+ *	reply from the AP.
+ * @bssid: AP's BSSID
+ * @burst_period: For EDCA based ranging: Recommended value to be sent to the
+ *	AP. Measurement periodicity In units of 100ms. ignored if
+ *	num_of_bursts_exp = 0.
+ *	For non trigger based NDP ranging, the maximum time between
+ *	measurements in units of milliseconds.
+ * @samples_per_burst: the number of FTMs pairs in single Burst (1-31);
+ * @num_of_bursts: Recommended value to be sent to the AP. 2s Exponent of
+ *	the number of measurement iterations (min 2^0 = 1, max 2^14)
+ * @sta_id: the station id of the AP. Only relevant when associated to the AP,
+ *	otherwise should be set to &IWL_MVM_INVALID_STA.
+ * @cipher: pairwise cipher suite for secured measurement.
+ *          &enum iwl_location_cipher.
+ * @hltk: HLTK to be used for secured 11az measurement
+ * @tk: TK to be used for secured 11az measurement
+ * @calib: An array of calibration values per FTM rx bandwidth.
+ *         If &IWL_INITIATOR_AP_FLAGS_USE_CALIB is set, the fw will use the
+ *         calibration value that corresponds to the rx bandwidth of the FTM
+ *         frame.
+ * @beacon_interval: beacon interval of the AP in TUs. Only required if
+ *	&IWL_INITIATOR_AP_FLAGS_TB is set.
+ * @bss_color: the BSS color of the responder. Only valid if
+ *	&IWL_INITIATOR_AP_FLAGS_TB or &IWL_INITIATOR_AP_FLAGS_NON_TB is set.
+ * @rx_pn: the next expected PN for protected management frames Rx. LE byte
+ *	order. Only valid if &IWL_INITIATOR_AP_FLAGS_SECURED is set and sta_id
+ *	is set to &IWL_MVM_INVALID_STA.
+ * @tx_pn: the next PN to use for protected management frames Tx. LE byte
+ *	order. Only valid if &IWL_INITIATOR_AP_FLAGS_SECURED is set and sta_id
+ *	is set to &IWL_MVM_INVALID_STA.
+ * @r2i_ndp_params: parameters for R2I NDP ranging negotiation.
+ *      bits 0 - 2: max LTF repetitions
+ *      bits 3 - 5: max number of spatial streams
+ *      bits 6 - 7: reserved
+ * @i2r_ndp_params: parameters for I2R NDP ranging negotiation.
+ *      bits 0 - 2: max LTF repetitions
+ *      bits 3 - 5: max number of spatial streams (supported values are < 2)
+ *      bits 6 - 7: reserved
+ * @r2i_max_total_ltf: R2I Max Total LTFs for NDP ranging negotiation.
+ *      One of &enum ieee80211_range_params_max_total_ltf.
+ * @i2r_max_total_ltf: I2R Max Total LTFs for NDP ranging negotiation.
+ *      One of &enum ieee80211_range_params_max_total_ltf.
+ * @bss_color: the BSS color of the responder. Only valid if
+ *	&IWL_INITIATOR_AP_FLAGS_NON_TB or &IWL_INITIATOR_AP_FLAGS_TB is set.
+ * @band: 0 for 5.2 GHz, 1 for 2.4 GHz, 2 for 6GHz
+ * @min_time_between_msr: For non trigger based NDP ranging, the minimum time
+ *	between measurements in units of milliseconds
+ */
+struct iwl_tof_range_req_ap_entry_v9 {
+	__le32 initiator_ap_flags;
+	u8 channel_num;
+	u8 format_bw;
+	u8 ctrl_ch_position;
+	u8 ftmr_max_retries;
+	u8 bssid[ETH_ALEN];
+	__le16 burst_period;
+	u8 samples_per_burst;
+	u8 num_of_bursts;
+	u8 sta_id;
+	u8 cipher;
+	u8 hltk[HLTK_11AZ_LEN];
+	u8 tk[TK_11AZ_LEN];
+	__le16 calib[IWL_TOF_BW_NUM];
+	u16 beacon_interval;
+	u8 rx_pn[IEEE80211_CCMP_PN_LEN];
+	u8 tx_pn[IEEE80211_CCMP_PN_LEN];
+	u8 r2i_ndp_params;
+	u8 i2r_ndp_params;
+	u8 r2i_max_total_ltf;
+	u8 i2r_max_total_ltf;
+	u8 bss_color;
+	u8 band;
+	__le16 min_time_between_msr;
+} __packed; /* LOCATION_RANGE_REQ_AP_ENTRY_CMD_API_S_VER_9 */
+
 /**
  * enum iwl_tof_response_mode
  * @IWL_MVM_TOF_RESPONSE_ASAP: report each AP measurement separately as soon as
@@ -1043,6 +1132,34 @@ struct iwl_tof_range_req_cmd_v12 {
 	struct iwl_tof_range_req_ap_entry_v8 ap[IWL_MVM_TOF_MAX_APS];
 } __packed; /* LOCATION_RANGE_REQ_CMD_API_S_VER_12 */
 
+/**
+ * struct iwl_tof_range_req_cmd_v13 - start measurement cmd
+ * @initiator_flags: see flags @ iwl_tof_initiator_flags
+ * @request_id: A Token incremented per request. The same Token will be
+ *		sent back in the range response
+ * @num_of_ap: Number of APs to measure (error if > IWL_MVM_TOF_MAX_APS)
+ * @range_req_bssid: ranging request BSSID
+ * @macaddr_mask: Bits set to 0 shall be copied from the MAC address template.
+ *		  Bits set to 1 shall be randomized by the UMAC
+ * @macaddr_template: MAC address template to use for non-randomized bits
+ * @req_timeout_ms: Requested timeout of the response in units of milliseconds.
+ *	This is the session time for completing the measurement.
+ * @tsf_mac_id: report the measurement start time for each ap in terms of the
+ *	TSF of this mac id. 0xff to disable TSF reporting.
+ * @ap: per-AP request data, see &struct iwl_tof_range_req_ap_entry_v9.
+ */
+struct iwl_tof_range_req_cmd_v13 {
+	__le32 initiator_flags;
+	u8 request_id;
+	u8 num_of_ap;
+	u8 range_req_bssid[ETH_ALEN];
+	u8 macaddr_mask[ETH_ALEN];
+	u8 macaddr_template[ETH_ALEN];
+	__le32 req_timeout_ms;
+	__le32 tsf_mac_id;
+	struct iwl_tof_range_req_ap_entry_v9 ap[IWL_MVM_TOF_MAX_APS];
+} __packed; /* LOCATION_RANGE_REQ_CMD_API_S_VER_13 */
+
 /*
  * enum iwl_tof_range_request_status - status of the sent request
  * @IWL_TOF_RANGE_REQUEST_STATUS_SUCCESSFUL - FW successfully received the
drivers/net/wireless/intel/iwlwifi/mvm/constants.h +4 -1
index 1343f25f1090..9d0d01f27d92 100644
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
 /*
  * Copyright (C) 2013-2015 Intel Mobile Communications GmbH
- * Copyright (C) 2013-2014, 2018-2020 Intel Corporation
+ * Copyright (C) 2013-2014, 2018-2021 Intel Corporation
  * Copyright (C) 2015 Intel Deutschland GmbH
  */
 #ifndef __MVM_CONSTANTS_H
@@ -93,6 +93,7 @@
 #define IWL_MVM_ENABLE_EBS			1
 #define IWL_MVM_FTM_INITIATOR_ALGO		IWL_TOF_ALGO_TYPE_MAX_LIKE
 #define IWL_MVM_FTM_INITIATOR_DYNACK		true
+#define IWL_MVM_FTM_LMR_FEEDBACK_TERMINATE	false
 #define IWL_MVM_FTM_R2I_MAX_REP			7
 #define IWL_MVM_FTM_I2R_MAX_REP			7
 #define IWL_MVM_FTM_R2I_MAX_STS			1
@@ -102,6 +103,8 @@
 #define IWL_MVM_FTM_INITIATOR_SECURE_LTF	false
 #define IWL_MVM_FTM_RESP_NDP_SUPPORT		true
 #define IWL_MVM_FTM_RESP_LMR_FEEDBACK_SUPPORT	true
+#define IWL_MVM_FTM_NON_TB_MIN_TIME_BETWEEN_MSR	5
+#define IWL_MVM_FTM_NON_TB_MAX_TIME_BETWEEN_MSR	1000
 #define IWL_MVM_D3_DEBUG			false
 #define IWL_MVM_USE_TWT				true
 #define IWL_MVM_AMPDU_CONSEC_DROPS_DELBA	10
drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c +72 -13

108 lines not on this page · raw message

Signature · 1 line
2.33.0
#2 lore raw

PATCH 2/12 iwlwifi: mvm: add support for resonder config command version 9

In reply to Luca Coelho

From: Avraham Stern <[email protected]>

This version adds the following configuration options:
1. Enable/disable setting the session id in the FTM frame
2. Set the BSS color for the responder
3. Set the minimum and maximum time between measurements for non trigger based NDP ranging.

---
 .../wireless/intel/iwlwifi/fw/api/location.h  | 70 +++++++++++++++++--
 .../intel/iwlwifi/mvm/ftm-responder.c         | 27 +++++--
 2 files changed, 88 insertions(+), 9 deletions(-)
drivers/net/wireless/intel/iwlwifi/fw/api/location.h +66 -4
index 0a8681d9687c..6bbb8b8c91cd 100644
@@ -151,6 +151,10 @@ enum iwl_tof_mcsi_enable {
  *	is valid
  * @IWL_TOF_RESPONDER_CMD_VALID_NDP_PARAMS: NDP parameters are valid
  * @IWL_TOF_RESPONDER_CMD_VALID_LMR_FEEDBACK: LMR feedback support is valid
+ * @IWL_TOF_RESPONDER_CMD_VALID_SESSION_ID: session id flag is valid
+ * @IWL_TOF_RESPONDER_CMD_VALID_BSS_COLOR: the bss_color field is valid
+ * @IWL_TOF_RESPONDER_CMD_VALID_MIN_MAX_TIME_BETWEEN_MSR: the
+ *	min_time_between_msr and max_time_between_msr fields are valid
  */
 enum iwl_tof_responder_cmd_valid_field {
 	IWL_TOF_RESPONDER_CMD_VALID_CHAN_INFO = BIT(0),
@@ -169,6 +173,9 @@ enum iwl_tof_responder_cmd_valid_field {
 	IWL_TOF_RESPONDER_CMD_VALID_NDP_SUPPORT = BIT(22),
 	IWL_TOF_RESPONDER_CMD_VALID_NDP_PARAMS = BIT(23),
 	IWL_TOF_RESPONDER_CMD_VALID_LMR_FEEDBACK = BIT(24),
+	IWL_TOF_RESPONDER_CMD_VALID_SESSION_ID = BIT(25),
+	IWL_TOF_RESPONDER_CMD_VALID_BSS_COLOR = BIT(26),
+	IWL_TOF_RESPONDER_CMD_VALID_MIN_MAX_TIME_BETWEEN_MSR = BIT(27),
 };
 
 /**
@@ -186,6 +193,8 @@ enum iwl_tof_responder_cmd_valid_field {
  * @IWL_TOF_RESPONDER_FLAGS_NDP_SUPPORT: support NDP ranging
  * @IWL_TOF_RESPONDER_FLAGS_LMR_FEEDBACK: request for LMR feedback if the
  *	initiator supports it
+ * @IWL_TOF_RESPONDER_FLAGS_SESSION_ID: send the session id in the initial FTM
+ *	frame.
  */
 enum iwl_tof_responder_cfg_flags {
 	IWL_TOF_RESPONDER_FLAGS_NON_ASAP_SUPPORT = BIT(0),
@@ -200,6 +209,7 @@ enum iwl_tof_responder_cfg_flags {
 	IWL_TOF_RESPONDER_FLAGS_FTM_TX_ANT = RATE_MCS_ANT_ABC_MSK,
 	IWL_TOF_RESPONDER_FLAGS_NDP_SUPPORT = BIT(24),
 	IWL_TOF_RESPONDER_FLAGS_LMR_FEEDBACK = BIT(25),
+	IWL_TOF_RESPONDER_FLAGS_SESSION_ID = BIT(27),
 };
 
 /**
@@ -297,13 +307,13 @@ struct iwl_tof_responder_config_cmd_v7 {
  * @r2i_ndp_params: parameters for R2I NDP.
  *	bits 0 - 2: max number of LTF repetitions
  *	bits 3 - 5: max number of spatial streams (supported values are < 2)
- *	bits 6 - 7: max number of total LTFs
- *		    (&enum ieee80211_range_params_max_total_ltf)
+ *	bits 6 - 7: max number of total LTFs see
+ *	&enum ieee80211_range_params_max_total_ltf
  * @i2r_ndp_params: parameters for I2R NDP.
  *	bits 0 - 2: max number of LTF repetitions
  *	bits 3 - 5: max number of spatial streams
- *	bits 6 - 7: max number of total LTFs
- *		    (&enum ieee80211_range_params_max_total_ltf)
+ *	bits 6 - 7: max number of total LTFs see
+ *	&enum ieee80211_range_params_max_total_ltf
  */
 struct iwl_tof_responder_config_cmd_v8 {
 	__le32 cmd_valid_fields;
@@ -322,6 +332,58 @@ struct iwl_tof_responder_config_cmd_v8 {
 	u8 i2r_ndp_params;
 } __packed; /* TOF_RESPONDER_CONFIG_CMD_API_S_VER_8 */
 
+/**
+ * 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.
+ * @bss_color: current AP bss_color
+ * @channel_num: current AP Channel
+ * @ctrl_ch_position: coding of the control channel position relative to
+ *	the center frequency, see iwl_mvm_get_ctrl_pos()
+ * @sta_id: index of the AP STA when in AP mode
+ * @reserved1: reserved
+ * @toa_offset: Artificial addition [pSec] for the ToA - to be used for debug
+ *	purposes, simulating station movement by adding various values
+ *	to this field
+ * @common_calib: XVT: common calibration value
+ * @specific_calib: XVT: specific calibration value
+ * @bssid: Current AP BSSID
+ * @r2i_ndp_params: parameters for R2I NDP.
+ *	bits 0 - 2: max number of LTF repetitions
+ *	bits 3 - 5: max number of spatial streams (supported values are < 2)
+ *	bits 6 - 7: max number of total LTFs see
+ *	&enum ieee80211_range_params_max_total_ltf
+ * @i2r_ndp_params: parameters for I2R NDP.
+ *	bits 0 - 2: max number of LTF repetitions
+ *	bits 3 - 5: max number of spatial streams
+ *	bits 6 - 7: max number of total LTFs see
+ *	&enum ieee80211_range_params_max_total_ltf
+ * @min_time_between_msr: for non trigger based NDP ranging, minimum time
+ *	between measurements in milliseconds.
+ * @max_time_between_msr: for non trigger based NDP ranging, maximum time
+ *	between measurements in milliseconds.
+ */
+struct iwl_tof_responder_config_cmd_v9 {
+	__le32 cmd_valid_fields;
+	__le32 responder_cfg_flags;
+	u8 format_bw;
+	u8 bss_color;
+	u8 channel_num;
+	u8 ctrl_ch_position;
+	u8 sta_id;
+	u8 reserved1;
+	__le16 toa_offset;
+	__le16 common_calib;
+	__le16 specific_calib;
+	u8 bssid[ETH_ALEN];
+	u8 r2i_ndp_params;
+	u8 i2r_ndp_params;
+	__le16 min_time_between_msr;
+	__le16 max_time_between_msr;
+} __packed; /* TOF_RESPONDER_CONFIG_CMD_API_S_VER_8 */
+
 #define IWL_LCI_CIVIC_IE_MAX_SIZE	400
 
 /**
drivers/net/wireless/intel/iwlwifi/mvm/ftm-responder.c +22 -5
index 5a249ea97eb2..eba5433c2626 100644
@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 /*
  * Copyright (C) 2015-2017 Intel Deutschland GmbH
- * Copyright (C) 2018-2020 Intel Corporation
+ * Copyright (C) 2018-2021 Intel Corporation
  */
 #include <net/cfg80211.h>
 #include <linux/etherdevice.h>
@@ -77,7 +77,7 @@ static int iwl_mvm_ftm_responder_set_bw_v2(struct cfg80211_chan_def *chandef,
 
 static void
 iwl_mvm_ftm_responder_set_ndp(struct iwl_mvm *mvm,
-			      struct iwl_tof_responder_config_cmd_v8 *cmd)
+			      struct iwl_tof_responder_config_cmd_v9 *cmd)
 {
 	/* Up to 2 R2I STS are allowed on the responder */
 	u32 r2i_max_sts = IWL_MVM_FTM_R2I_MAX_STS < 2 ?
@@ -104,7 +104,7 @@ iwl_mvm_ftm_responder_cmd(struct iwl_mvm *mvm,
 	 * field interpretation is different), so the same struct can be use
 	 * for all cases.
 	 */
-	struct iwl_tof_responder_config_cmd_v8 cmd = {
+	struct iwl_tof_responder_config_cmd_v9 cmd = {
 		.channel_num = chandef->chan->hw_value,
 		.cmd_valid_fields =
 			cpu_to_le32(IWL_TOF_RESPONDER_CMD_VALID_CHAN_INFO |
@@ -115,10 +115,27 @@ iwl_mvm_ftm_responder_cmd(struct iwl_mvm *mvm,
 	u8 cmd_ver = iwl_fw_lookup_cmd_ver(mvm->fw, LOCATION_GROUP,
 					   TOF_RESPONDER_CONFIG_CMD, 6);
 	int err;
+	int cmd_size;
 
 	lockdep_assert_held(&mvm->mutex);
 
-if (cmd_ver == 8)
+	/* Use a default of bss_color=1 for now */
+	if (cmd_ver == 9) {
+		cmd.cmd_valid_fields |=
+			cpu_to_le32(IWL_TOF_RESPONDER_CMD_VALID_BSS_COLOR |
+				    IWL_TOF_RESPONDER_CMD_VALID_MIN_MAX_TIME_BETWEEN_MSR);
+		cmd.bss_color = 1;
+		cmd.min_time_between_msr =
+			cpu_to_le16(IWL_MVM_FTM_NON_TB_MIN_TIME_BETWEEN_MSR);
+		cmd.max_time_between_msr =
+			cpu_to_le16(IWL_MVM_FTM_NON_TB_MAX_TIME_BETWEEN_MSR);
+		cmd_size = sizeof(struct iwl_tof_responder_config_cmd_v9);
+	} else {
+		/* All versions up to version 8 have the same size */
+		cmd_size = sizeof(struct iwl_tof_responder_config_cmd_v8);
+	}
+
+	if (cmd_ver >= 8)
 		iwl_mvm_ftm_responder_set_ndp(mvm, &cmd);
 
 	if (cmd_ver >= 7)
@@ -137,7 +154,7 @@ if (cmd_ver == 8)
 
 	return iwl_mvm_send_cmd_pdu(mvm, iwl_cmd_id(TOF_RESPONDER_CONFIG_CMD,
 						    LOCATION_GROUP, 0),
-				    0, sizeof(cmd), &cmd);
+				    0, cmd_size, &cmd);
 }
 
 static int
Signature · 1 line
2.33.0
#3 lore raw

Re: [PATCH 02/12] iwlwifi: mvm: add support for resonder config command version 9

Quoted 10 lines · Luca Coelho

From: Avraham Stern <[email protected]>

This version adds the following configuration options:
1. Enable/disable setting the session id in the FTM frame
2. Set the BSS color for the responder
3. Set the minimum and maximum time between measurements for non trigger based NDP ranging.

s/resonder/responder/

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#4 lore raw

Re: [PATCH 02/12] iwlwifi: mvm: add support for resonder config command version 9

Quoted 10 lines · Kalle Valo
Quoted 8 lines · Luca Coelho

From: Avraham Stern <[email protected]>

This version adds the following configuration options:
1. Enable/disable setting the session id in the FTM frame
2. Set the BSS color for the responder
3. Set the minimum and maximum time between measurements for non trigger based NDP ranging.

Quoted 4 lines
Quoted 2 lines

s/resonder/responder/

Thanks, I'll fix it.

--
Luca.

#5 lore raw

PATCH 3/12 iwlwifi: move get pnvm file name to a separate function

In reply to Luca Coelho

From: Dror Moshe <[email protected]>

Move code that generates the pnvm file name to a separate function, so that it can be reused.

---
 drivers/net/wireless/intel/iwlwifi/fw/pnvm.c | 13 ++-----------
 drivers/net/wireless/intel/iwlwifi/fw/pnvm.h | 20 ++++++++++++++++++++
 2 files changed, 22 insertions(+), 11 deletions(-)
drivers/net/wireless/intel/iwlwifi/fw/pnvm.c +2 -11
index 1de30bae7829..bbd8c31cbbec 100644
@@ -223,19 +223,10 @@ static int iwl_pnvm_parse(struct iwl_trans *trans, const u8 *data,
 static int iwl_pnvm_get_from_fs(struct iwl_trans *trans, u8 **data, size_t *len)
 {
 	const struct firmware *pnvm;
-	char pnvm_name[64];
+	char pnvm_name[MAX_PNVM_NAME];
 	int ret;
 
-	/*
-	 * The prefix unfortunately includes a hyphen at the end, so
-	 * don't add the dot here...
-	 */
-	snprintf(pnvm_name, sizeof(pnvm_name), "%spnvm",
-		 trans->cfg->fw_name_pre);
-
-	/* ...but replace the hyphen with the dot here. */
-	if (strlen(trans->cfg->fw_name_pre) < sizeof(pnvm_name))
-		pnvm_name[strlen(trans->cfg->fw_name_pre) - 1] = '.';
+	iwl_pnvm_get_fs_name(trans, pnvm_name, sizeof(pnvm_name));
 
 	ret = firmware_request_nowarn(&pnvm, pnvm_name, trans->dev);
 	if (ret) {
drivers/net/wireless/intel/iwlwifi/fw/pnvm.h +20 -0
index 61d3d4e0b7d9..203c367dd4de 100644
@@ -12,7 +12,27 @@
 
 #define MVM_UCODE_PNVM_TIMEOUT	(HZ / 4)
 
+#define MAX_PNVM_NAME  64
+
 int iwl_pnvm_load(struct iwl_trans *trans,
 		  struct iwl_notif_wait_data *notif_wait);
 
+static inline
+void iwl_pnvm_get_fs_name(struct iwl_trans *trans,
+			  u8 *pnvm_name, size_t max_len)
+{
+	int pre_len;
+
+	/*
+	 * The prefix unfortunately includes a hyphen at the end, so
+	 * don't add the dot here...
+	 */
+	snprintf(pnvm_name, max_len, "%spnvm", trans->cfg->fw_name_pre);
+
+	/* ...but replace the hyphen with the dot here. */
+	pre_len = strlen(trans->cfg->fw_name_pre);
+	if (pre_len < max_len && pre_len > 0)
+		pnvm_name[pre_len - 1] = '.';
+}
+
 #endif /* __IWL_PNVM_H__ */
Signature · 1 line
2.33.0
#6 lore raw

PATCH 4/12 iwlwifi: mvm: introduce iwl_stored_beacon_notif_v3

In reply to Luca Coelho

From: Gregory Greenman <[email protected]>

The new version sends station id in the notification. It's still not used, but need to adjust the code since the offset of the data was changed.

---
 .../wireless/intel/iwlwifi/fw/api/offload.h   | 31 +++++++++++++++++--
 .../net/wireless/intel/iwlwifi/mvm/mac-ctxt.c | 26 ++++++++++++++--
 drivers/net/wireless/intel/iwlwifi/mvm/ops.c  |  2 +-
 3 files changed, 52 insertions(+), 7 deletions(-)
drivers/net/wireless/intel/iwlwifi/fw/api/offload.h +28 -3
index f06214d418aa..5204aa94e72a 100644
@@ -3,6 +3,7 @@
  * Copyright (C) 2012-2014 Intel Corporation
  * Copyright (C) 2013-2015 Intel Mobile Communications GmbH
  * Copyright (C) 2016-2017 Intel Deutschland GmbH
+ * Copyright (C) 2021 Intel Corporation
  */
 #ifndef __iwl_fw_api_offload_h__
 #define __iwl_fw_api_offload_h__
@@ -20,7 +21,7 @@ enum iwl_prot_offload_subcmd_ids {
 #define MAX_STORED_BEACON_SIZE 600
 
 /**
- * struct iwl_stored_beacon_notif - Stored beacon notification
+ * struct iwl_stored_beacon_notif_common - Stored beacon notif common fields
  *
  * @system_time: system time on air rise
  * @tsf: TSF on air rise
@@ -29,9 +30,8 @@ enum iwl_prot_offload_subcmd_ids {
  * @channel: channel this beacon was received on
  * @rates: rate in ucode internal format
  * @byte_count: frame's byte count
- * @data: beacon data, length in @byte_count
  */
-struct iwl_stored_beacon_notif {
+struct iwl_stored_beacon_notif_common {
 	__le32 system_time;
 	__le64 tsf;
 	__le32 beacon_timestamp;
@@ -39,7 +39,32 @@ struct iwl_stored_beacon_notif {
 	__le16 channel;
 	__le32 rates;
 	__le32 byte_count;
+} __packed;
+
+/**
+ * struct iwl_stored_beacon_notif - Stored beacon notification
+ *
+ * @common: fields common for all versions
+ * @data: beacon data, length in @byte_count
+ */
+struct iwl_stored_beacon_notif_v2 {
+	struct iwl_stored_beacon_notif_common common;
 	u8 data[MAX_STORED_BEACON_SIZE];
 } __packed; /* WOWLAN_STROED_BEACON_INFO_S_VER_2 */
 
+/**
+ * struct iwl_stored_beacon_notif_v3 - Stored beacon notification
+ *
+ * @common: fields common for all versions
+ * @sta_id: station for which the beacon was received
+ * @reserved: reserved for alignment
+ * @data: beacon data, length in @byte_count
+ */
+struct iwl_stored_beacon_notif_v3 {
+	struct iwl_stored_beacon_notif_common common;
+	u8 sta_id;
+	u8 reserved[3];
+	u8 data[MAX_STORED_BEACON_SIZE];
+} __packed; /* WOWLAN_STROED_BEACON_INFO_S_VER_3 */
+
 #endif /* __iwl_fw_api_offload_h__ */
drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c +23 -3
index 2fbc1a3bbdca..1ebd4654d18e 100644
@@ -1432,14 +1432,34 @@ void iwl_mvm_rx_stored_beacon_notif(struct iwl_mvm *mvm,
 {
 	struct iwl_rx_packet *pkt = rxb_addr(rxb);
 	unsigned int pkt_len = iwl_rx_packet_payload_len(pkt);
-	struct iwl_stored_beacon_notif *sb = (void *)pkt->data;
+	struct iwl_stored_beacon_notif_common *sb = (void *)pkt->data;
 	struct ieee80211_rx_status rx_status;
 	struct sk_buff *skb;
+	u8 *data;
 	u32 size = le32_to_cpu(sb->byte_count);
+	int ver = iwl_fw_lookup_cmd_ver(mvm->fw, PROT_OFFLOAD_GROUP,
+					STORED_BEACON_NTF, 0);
 
-	if (size == 0 || pkt_len < struct_size(sb, data, size))
+	if (size == 0)
 		return;
 
+	/* handle per-version differences */
+	if (ver <= 2) {
+		struct iwl_stored_beacon_notif_v2 *sb_v2 = (void *)pkt->data;
+
+		if (pkt_len < struct_size(sb_v2, data, size))
+			return;
+
+		data = sb_v2->data;
+	} else {
+		struct iwl_stored_beacon_notif_v3 *sb_v3 = (void *)pkt->data;
+
+		if (pkt_len < struct_size(sb_v3, data, size))
+			return;
+
+		data = sb_v3->data;
+	}
+
 	skb = alloc_skb(size, GFP_ATOMIC);
 	if (!skb) {
 		IWL_ERR(mvm, "alloc_skb failed\n");
@@ -1460,7 +1480,7 @@ void iwl_mvm_rx_stored_beacon_notif(struct iwl_mvm *mvm,
 					       rx_status.band);
 
 	/* copy the data */
-	skb_put_data(skb, sb->data, size);
+	skb_put_data(skb, data, size);
 	memcpy(IEEE80211_SKB_RXCB(skb), &rx_status, sizeof(rx_status));
 
 	/* pass it as regular rx to mac80211 */
drivers/net/wireless/intel/iwlwifi/mvm/ops.c +1 -1
index 8ce937f8445a..6f60018feed1 100644
@@ -373,7 +373,7 @@ static const struct iwl_rx_handlers iwl_mvm_rx_handlers[] = {
 		       struct iwl_mfu_assert_dump_notif),
 	RX_HANDLER_GRP(PROT_OFFLOAD_GROUP, STORED_BEACON_NTF,
 		       iwl_mvm_rx_stored_beacon_notif, RX_HANDLER_SYNC,
-		       struct iwl_stored_beacon_notif),
+		       struct iwl_stored_beacon_notif_v2),
 	RX_HANDLER_GRP(DATA_PATH_GROUP, MU_GROUP_MGMT_NOTIF,
 		       iwl_mvm_mu_mimo_grp_notif, RX_HANDLER_SYNC,
 		       struct iwl_mu_group_mgmt_notif),
Signature · 1 line
2.33.0
#7 lore raw

PATCH 5/12 iwlwifi: mvm: support broadcast TWT alone

In reply to Luca Coelho

From: Shaul Triebitz <[email protected]>

Tell the firmware about broadcast TWT support even if individual TWT is not supported.
In that case the firmware will negotiate only
a broadcast TWT session.

---
 drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c +7 -8
index 1ebd4654d18e..fd352b2624a6 100644
@@ -647,15 +647,14 @@ static int iwl_mvm_mac_ctxt_cmd_sta(struct iwl_mvm *mvm,
 
 	if (vif->bss_conf.he_support && !iwlwifi_mod_params.disable_11ax) {
 		cmd.filter_flags |= cpu_to_le32(MAC_FILTER_IN_11AX);
-		if (vif->bss_conf.twt_requester && IWL_MVM_USE_TWT) {
+		if (vif->bss_conf.twt_requester && IWL_MVM_USE_TWT)
 			ctxt_sta->data_policy |= cpu_to_le32(TWT_SUPPORTED);
-			if (vif->bss_conf.twt_protected)
-				ctxt_sta->data_policy |=
-					cpu_to_le32(PROTECTED_TWT_SUPPORTED);
-			if (vif->bss_conf.twt_broadcast)
-				ctxt_sta->data_policy |=
-					cpu_to_le32(BROADCAST_TWT_SUPPORTED);
-		}
+		if (vif->bss_conf.twt_protected)
+			ctxt_sta->data_policy |=
+				cpu_to_le32(PROTECTED_TWT_SUPPORTED);
+		if (vif->bss_conf.twt_broadcast)
+			ctxt_sta->data_policy |=
+				cpu_to_le32(BROADCAST_TWT_SUPPORTED);
 	}
 
 
Signature · 1 line
2.33.0
#8 lore raw

PATCH 6/12 iwlwifi: mvm: Fix scan channel flags settings

In reply to Luca Coelho

From: Ilan Peer <[email protected]>

The iwl_mvm_scan_ch_n_aps_flag() is called with a variable before the value of the variable is set. Fix it.

---
 drivers/net/wireless/intel/iwlwifi/mvm/scan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/mvm/scan.c +1 -1
index e1b436e805b1..d78e436fa8b5 100644
@@ -1648,7 +1648,7 @@ iwl_mvm_umac_scan_cfg_channels_v6(struct iwl_mvm *mvm,
 		struct iwl_scan_channel_cfg_umac *cfg = &cp->channel_config[i];
 		u32 n_aps_flag =
 			iwl_mvm_scan_ch_n_aps_flag(vif_type,
-						   cfg->v2.channel_num);
+						   channels[i]->hw_value);
 
 		cfg->flags = cpu_to_le32(flags | n_aps_flag);
 		cfg->v2.channel_num = channels[i]->hw_value;
Signature · 1 line
2.33.0
#9 lore raw

PATCH 7/12 iwlwifi: mvm: don't use FW key ID in beacon protection

In reply to Luca Coelho

From: Johannes Berg <[email protected]>

To check beacon protection had a mismatch of the key ID we currently use the key ID from the firmware, but firmware side we want to clean up the API to stop reporting this.

Instead, check the IWL_RX_MPDU_STATUS_KEY_VALID bit that indicates that the firmware used the correct key, and if that's set but we get invalid MIC/replay use the key ID from the frame to look up the key and notify mac80211 of MIC error or replay. Since both keys must have the same cipher and thus MIC length, we can use either of them to look up the MIC length.

---
 drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c | 41 ++++++++++++-------
 1 file changed, 27 insertions(+), 14 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c +27 -14
index 06cc03820dd5..c12f303cf652 100644
@@ -279,7 +279,6 @@ static int iwl_mvm_rx_mgmt_prot(struct ieee80211_sta *sta,
 {
 	struct iwl_mvm_sta *mvmsta;
 	struct iwl_mvm_vif *mvmvif;
-	u8 fwkeyid = u32_get_bits(status, IWL_RX_MPDU_STATUS_KEY);
 	u8 keyid;
 	struct ieee80211_key_conf *key;
 	u32 len = le16_to_cpu(desc->mpdu_len);
@@ -299,6 +298,10 @@ static int iwl_mvm_rx_mgmt_prot(struct ieee80211_sta *sta,
 	if (!ieee80211_is_beacon(hdr->frame_control))
 		return 0;
 
+	/* key mismatch - will also report !MIC_OK but we shouldn't count it */
+	if (!(status & IWL_RX_MPDU_STATUS_KEY_VALID))
+		return -1;
+
 	/* good cases */
 	if (likely(status & IWL_RX_MPDU_STATUS_MIC_OK &&
 		   !(status & IWL_RX_MPDU_STATUS_REPLAY_ERROR)))
@@ -309,26 +312,36 @@ static int iwl_mvm_rx_mgmt_prot(struct ieee80211_sta *sta,
 
 	mvmsta = iwl_mvm_sta_from_mac80211(sta);
 
-	/* what? */
-	if (fwkeyid != 6 && fwkeyid != 7)
-		return -1;
-
 	mvmvif = iwl_mvm_vif_from_mac80211(mvmsta->vif);
 
-	key = rcu_dereference(mvmvif->bcn_prot.keys[fwkeyid - 6]);
-	if (!key)
-		return -1;
+	/*
+	 * both keys will have the same cipher and MIC length, use
+	 * whichever one is available
+	 */
+	key = rcu_dereference(mvmvif->bcn_prot.keys[0]);
+	if (!key) {
+		key = rcu_dereference(mvmvif->bcn_prot.keys[1]);
+		if (!key)
+			return -1;
+	}
 
 	if (len < key->icv_len + IEEE80211_GMAC_PN_LEN + 2)
 		return -1;
 
-	/*
-	 * See if the key ID matches - if not this may be due to a
-	 * switch and the firmware may erroneously report !MIC_OK.
-	 */
+	/* get the real key ID */
 	keyid = frame[len - key->icv_len - IEEE80211_GMAC_PN_LEN - 2];
-	if (keyid != fwkeyid)
-		return -1;
+	/* and if that's the other key, look it up */
+	if (keyid != key->keyidx) {
+		/*
+		 * shouldn't happen since firmware checked, but be safe
+		 * in case the MIC length is wrong too, for example
+		 */
+		if (keyid != 6 && keyid != 7)
+			return -1;
+		key = rcu_dereference(mvmvif->bcn_prot.keys[keyid - 6]);
+		if (!key)
+			return -1;
+	}
 
 	/* Report status to mac80211 */
 	if (!(status & IWL_RX_MPDU_STATUS_MIC_OK))
Signature · 1 line
2.33.0
#10 lore raw

PATCH 8/12 iwlwifi: export DHC framework and add first public entry, twt_setup

In reply to Luca Coelho

From: Luca Coelho <[email protected]>

Export the debug host command framework and add the twt_setup entry. This will allow external parties to use these debugging features. More entries can be added later on.

---
 drivers/net/wireless/intel/iwlwifi/Kconfig    |   6 +
 .../wireless/intel/iwlwifi/fw/api/commands.h  |   5 +
 .../net/wireless/intel/iwlwifi/fw/api/dhc.h   | 122 ++++++++++++++++++
 .../wireless/intel/iwlwifi/mvm/debugfs-vif.c  |  87 +++++++++++++
 .../net/wireless/intel/iwlwifi/mvm/fw-api.h   |   3 +-
 drivers/net/wireless/intel/iwlwifi/mvm/ops.c  |   1 +
 6 files changed, 223 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/wireless/intel/iwlwifi/fw/api/dhc.h
drivers/net/wireless/intel/iwlwifi/Kconfig +6 -0
index 1085afbefba8..0b2c6c945bc0 100644
@@ -92,6 +92,12 @@ config IWLWIFI_BCAST_FILTERING
 	  If unsure, don't enable this option, as some programs might
 	  expect incoming broadcasts for their normal operations.
 
+config IWLWIFI_DHC
+	bool "Enable debug host commands"
+	help
+	  This option enables the debug host command API.  It's used
+	  for debugging and validation purposes.
+
 menu "Debugging Options"
 
 config IWLWIFI_DEBUG
drivers/net/wireless/intel/iwlwifi/fw/api/commands.h +5 -0
index ee6b5844a871..b07e75be8679 100644
@@ -495,6 +495,11 @@ enum iwl_legacy_cmds {
 	 */
 	DTS_MEASUREMENT_NOTIFICATION = 0xdd,
 
+	/**
+	 * @DEBUG_HOST_COMMAND: &struct iwl_dhc_cmd
+	 */
+	DEBUG_HOST_COMMAND = 0xf1,
+
 	/**
 	 * @LDBG_CONFIG_CMD: configure continuous trace recording
 	 */
drivers/net/wireless/intel/iwlwifi/fw/api/dhc.h new file +122 -0

122 lines not on this page · raw message

drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c +87 -0

105 lines not on this page · raw message

drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h +2 -1
index 73a82f07dc59..aa18d802de8e 100644
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
 /*
- * Copyright (C) 2012-2014, 2018, 2020 Intel Corporation
+ * Copyright (C) 2012-2014, 2018, 2020-2021 Intel Corporation
  * Copyright (C) 2013-2015 Intel Mobile Communications GmbH
  * Copyright (C) 2016-2017 Intel Deutschland GmbH
  */
@@ -37,5 +37,6 @@
 #include "fw/api/location.h"
 #include "fw/api/tx.h"
 #include "fw/api/rfi.h"
+#include "fw/api/dhc.h"
 
 #endif /* __fw_api_h__ */
drivers/net/wireless/intel/iwlwifi/mvm/ops.c +1 -0
index 6f60018feed1..51eb52003cb1 100644
@@ -493,6 +493,7 @@ static const struct iwl_hcmd_names iwl_mvm_legacy_names[] = {
 	HCMD_NAME(SCAN_ITERATION_COMPLETE),
 	HCMD_NAME(D0I3_END_CMD),
 	HCMD_NAME(LTR_CONFIG),
+	HCMD_NAME(DEBUG_HOST_COMMAND),
 	HCMD_NAME(LDBG_CONFIG_CMD),
 };
 
Signature · 1 line
2.33.0
#11 lore raw

Re: [PATCH 08/12] iwlwifi: export DHC framework and add first public entry, twt_setup

Quoted 7 lines · Luca Coelho

From: Luca Coelho <[email protected]>

Export the debug host command framework and add the twt_setup entry. This will allow external parties to use these debugging features. More entries can be added later on.

[...]

drivers/net/wireless/intel/iwlwifi/Kconfig config IWLWIFI_BCAST_FILTERING · line 100

Quoted 12 lines
drivers/net/wireless/intel/iwlwifi/Kconfig +6 -0
@@ -92,6 +92,12 @@ config IWLWIFI_BCAST_FILTERING
 	  If unsure, don't enable this option, as some programs might
 	  expect incoming broadcasts for their normal operations.
 
+config IWLWIFI_DHC
+	bool "Enable debug host commands"
+	help
+	  This option enables the debug host command API.  It's used
+	  for debugging and validation purposes.
+

Why a new Kconfig option? Those should not be added lightly.

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#12 lore raw

Re: [PATCH 08/12] iwlwifi: export DHC framework and add first public entry, twt_setup

Quoted 19 lines · Kalle Valo
Quoted 7 lines · Luca Coelho

From: Luca Coelho <[email protected]>

Export the debug host command framework and add the twt_setup entry. This will allow external parties to use these debugging features. More entries can be added later on.

[...]

Quoted 7 lines
drivers/net/wireless/intel/iwlwifi/Kconfig +0 -0
@@ -92,6 +92,12 @@ config IWLWIFI_BCAST_FILTERING

  If unsure, don't enable this option, as some programs might expect incoming broadcasts for their normal operations.

Quoted 8 lines

drivers/net/wireless/intel/iwlwifi/Kconfig config IWLWIFI_BCAST_FILTERING · line 100

Quoted 6 lines
drivers/net/wireless/intel/iwlwifi/Kconfig +6 -0
+config IWLWIFI_DHC
+	bool "Enable debug host commands"
+	help
+	  This option enables the debug host command API.  It's used
+	  for debugging and validation purposes.
+

Why a new Kconfig option? Those should not be added lightly.

This is a debugging feature that is not really needed in production kernels, so we prefer to allow it to be removed so we don't waste resources.

We're publishing this for a few reasons:

1. it will help prevent rebasing mistakes when sending patches upstream from our internal tree, because a lot of this code is spread around the driver;

2. in some occasions, we may ask advanced users to enable it so we can get more data and run more tests in case of tricky bugs;

3. for the specific case of twt_setup, this allows running some TWT test scenarios with our driver that wouldn't be easily available otherwise.

Is it okay to keep it?

--
Cheers,
Luca.

#13 lore raw

Re: [PATCH 08/12] iwlwifi: export DHC framework and add first public entry, twt_setup

Quoted 39 lines · Luca Coelho
Quoted 19 lines · Kalle Valo
Quoted 7 lines · Luca Coelho

From: Luca Coelho <[email protected]>

Export the debug host command framework and add the twt_setup entry. This will allow external parties to use these debugging features. More entries can be added later on.

[...]

Quoted 7 lines
drivers/net/wireless/intel/iwlwifi/Kconfig +0 -0
@@ -92,6 +92,12 @@ config IWLWIFI_BCAST_FILTERING

  If unsure, don't enable this option, as some programs might expect incoming broadcasts for their normal operations.

Quoted 8 lines

drivers/net/wireless/intel/iwlwifi/Kconfig config IWLWIFI_BCAST_FILTERING · line 100

Quoted 6 lines
drivers/net/wireless/intel/iwlwifi/Kconfig +6 -0
+config IWLWIFI_DHC
+	bool "Enable debug host commands"
+	help
+	  This option enables the debug host command API.  It's used
+	  for debugging and validation purposes.
+

Why a new Kconfig option? Those should not be added lightly.

This is a debugging feature that is not really needed in production kernels, so we prefer to allow it to be removed so we don't waste resources.

We're publishing this for a few reasons:

1. it will help prevent rebasing mistakes when sending patches upstream from our internal tree, because a lot of this code is spread around the driver;

Quoted 8 lines

2. in some occasions, we may ask advanced users to enable it so we can get more data and run more tests in case of tricky bugs;

3. for the specific case of twt_setup, this allows running some TWT test scenarios with our driver that wouldn't be easily available otherwise.

Is it okay to keep it?

Johannes suggested to add "if EXPERT" here, so I'm going to do that and resend.

--
Cheers,
Luca.

#14 lore raw

Re: [PATCH 08/12] iwlwifi: export DHC framework and add first public entry, twt_setup

In reply to Luca Coelho
Quoted 29 lines · Luca Coelho
Quoted 19 lines · Kalle Valo
Quoted 7 lines · Luca Coelho

From: Luca Coelho <[email protected]>

Export the debug host command framework and add the twt_setup entry. This will allow external parties to use these debugging features. More entries can be added later on.

[...]

Quoted 7 lines
drivers/net/wireless/intel/iwlwifi/Kconfig +0 -0
@@ -92,6 +92,12 @@ config IWLWIFI_BCAST_FILTERING

  If unsure, don't enable this option, as some programs might expect incoming broadcasts for their normal operations.

Quoted 8 lines

drivers/net/wireless/intel/iwlwifi/Kconfig config IWLWIFI_BCAST_FILTERING · line 100

Quoted 6 lines
drivers/net/wireless/intel/iwlwifi/Kconfig +6 -0
+config IWLWIFI_DHC
+	bool "Enable debug host commands"
+	help
+	  This option enables the debug host command API.  It's used
+	  for debugging and validation purposes.
+

Why a new Kconfig option? Those should not be added lightly.

Quoted 3 lines

This is a debugging feature that is not really needed in production kernels, so we prefer to allow it to be removed so we don't waste resources.

What resources exactly? I would say if the admin or distro maintainer wants to save on resources he will disable IWLWIFI_DEBUGFS. Why do we need to have multiple Kconfig options for iwlwifi debugfs interface?

Quoted 6 lines

We're publishing this for a few reasons:

1. it will help prevent rebasing mistakes when sending patches upstream from our internal tree, because a lot of this code is spread around the driver;

Quoted 6 lines

2. in some occasions, we may ask advanced users to enable it so we can get more data and run more tests in case of tricky bugs;

3. for the specific case of twt_setup, this allows running some TWT test scenarios with our driver that wouldn't be easily available otherwise.

Sure, I understand all that. The better debug features we have in upstream the better. But I don't understand why a new Kconfig option is needed for DHC feature.

Quoted 1 line

Is it okay to keep it?

In the past Linus has stated his dislike of adding pointless Kconfig options, with which I strongly agree, and to me it looks like IWLWIFI_DHC is exactly that. So I'm very hesitant about this.

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#15 lore raw

Re: [PATCH 08/12] iwlwifi: export DHC framework and add first public entry, twt_setup

Quoted 56 lines · Kalle Valo
Quoted 29 lines · Luca Coelho
Quoted 19 lines · Kalle Valo
Quoted 7 lines · Luca Coelho

From: Luca Coelho <[email protected]>

Export the debug host command framework and add the twt_setup entry. This will allow external parties to use these debugging features. More entries can be added later on.

[...]

Quoted 7 lines
drivers/net/wireless/intel/iwlwifi/Kconfig +0 -0
@@ -92,6 +92,12 @@ config IWLWIFI_BCAST_FILTERING

  If unsure, don't enable this option, as some programs might expect incoming broadcasts for their normal operations.

Quoted 8 lines

drivers/net/wireless/intel/iwlwifi/Kconfig config IWLWIFI_BCAST_FILTERING · line 100

Quoted 6 lines
drivers/net/wireless/intel/iwlwifi/Kconfig +6 -0
+config IWLWIFI_DHC
+	bool "Enable debug host commands"
+	help
+	  This option enables the debug host command API.  It's used
+	  for debugging and validation purposes.
+

Why a new Kconfig option? Those should not be added lightly.

Quoted 3 lines

This is a debugging feature that is not really needed in production kernels, so we prefer to allow it to be removed so we don't waste resources.

What resources exactly? I would say if the admin or distro maintainer wants to save on resources he will disable IWLWIFI_DEBUGFS. Why do we need to have multiple Kconfig options for iwlwifi debugfs interface?

Quoted 6 lines

We're publishing this for a few reasons:

1. it will help prevent rebasing mistakes when sending patches upstream from our internal tree, because a lot of this code is spread around the driver;

Quoted 6 lines

2. in some occasions, we may ask advanced users to enable it so we can get more data and run more tests in case of tricky bugs;

3. for the specific case of twt_setup, this allows running some TWT test scenarios with our driver that wouldn't be easily available otherwise.

Sure, I understand all that. The better debug features we have in upstream the better. But I don't understand why a new Kconfig option is needed for DHC feature.

Quoted 5 lines
Quoted 1 line

Is it okay to keep it?

In the past Linus has stated his dislike of adding pointless Kconfig options, with which I strongly agree, and to me it looks like IWLWIFI_DHC is exactly that. So I'm very hesitant about this.

Okay, fair enough. I'll hold this back now, rework it without the Kconfig option and send it again in the future.

Thanks for the comments!

--
Cheers,
Luca.

#16 lore raw

PATCH 9/12 iwlwifi: mvm: add fixed_rate debugfs entry to public DHC

In reply to Luca Coelho

From: Luca Coelho <[email protected]>

Expose the fixed_rate debugfs entry wnen IWLWIFI_DHC_PUBLIC is enabled.

---
 .../net/wireless/intel/iwlwifi/fw/api/dhc.h   | 12 ++++-
 .../net/wireless/intel/iwlwifi/fw/api/rs.h    | 40 ++++++++++++++--
 .../net/wireless/intel/iwlwifi/mvm/debugfs.c  | 46 +++++++++++++++++++
 .../net/wireless/intel/iwlwifi/mvm/rs-fw.c    | 33 +++++++++++++
 drivers/net/wireless/intel/iwlwifi/mvm/rs.h   | 10 ++--
 5 files changed, 130 insertions(+), 11 deletions(-)
drivers/net/wireless/intel/iwlwifi/fw/api/dhc.h +11 -1
index 3ffc5904056f..481c942db2ec 100644
@@ -22,7 +22,17 @@ enum iwl_dhc_table_id {
 enum iwl_dhc_umac_integration_table {
 	/* @DHC_INT_UMAC_TWT_OPERATION: trigger a TWT operation */
 	DHC_INT_UMAC_TWT_OPERATION = 4,
-	/* @DHC_INTEGRATION_MAX: Maximum UMAC integration table entries */
+	/**
+	 * @DHC_INTEGRATION_TLC_DEBUG_CONFIG: TLC debug
+	 */
+	DHC_INTEGRATION_TLC_DEBUG_CONFIG = 1,
+	/**
+	 * @DHC_INT_UMAC_TWT_CONTROL: TWT hooks (like disable internal TWT triggers)
+	 */
+	DHC_INT_UMAC_TWT_CONTROL = 10,
+	/**
+	 * @DHC_INTEGRATION_MAX: Maximum UMAC integration table entries
+	 */
 	DHC_INTEGRATION_MAX
 };
 
drivers/net/wireless/intel/iwlwifi/fw/api/rs.h +37 -3
index fc2fa49e9825..f23766df236b 100644
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
 /*
- * Copyright (C) 2012-2014, 2018-2020 Intel Corporation
+ * Copyright (C) 2012-2014, 2018-2021 Intel Corporation
  * Copyright (C) 2017 Intel Deutschland GmbH
  */
 #ifndef __iwl_fw_api_rs_h__
@@ -184,8 +184,42 @@ struct iwl_tlc_update_notif {
 	__le32 amsdu_enabled;
 } __packed; /* TLC_MNG_UPDATE_NTFY_API_S_VER_2 */
 
-/*
- * These serve as indexes into
+#ifdef CONFIG_IWLWIFI_DHC
+/**
+ * enum iwl_tlc_debug_types - debug options
+ */
+enum iwl_tlc_debug_types {
+	/* @IWL_TLC_DEBUG_FIXED_RATE: set fixed rate for rate scaling */
+	IWL_TLC_DEBUG_FIXED_RATE,
+}; /* TLC_MNG_DEBUG_TYPES_API_E */
+#endif /* CONFIG_IWLWIFI_DHC */
+
+#ifdef CONFIG_IWLWIFI_DHC
+#define MAX_DATA_IN_DHC_TLC_CMD 10
+
+/**
+ * struct iwl_dhc_tlc_dbg - fixed debug config
+ * @sta_id: bit 0 - enable/disable, bits 1 - 7 hold station id
+ * @reserved1: reserved
+ * @type: type id of %enum iwl_tlc_debug_types
+ * @data: data to send
+ */
+struct iwl_dhc_tlc_cmd {
+	u8 sta_id;
+	u8 reserved1[3];
+	__le32 type;
+	__le32 data[MAX_DATA_IN_DHC_TLC_CMD];
+} __packed; /* TLC_MNG_DEBUG_CMD_S */
+#endif /* CONFIG_IWLWIFI_DHC */
+
+#define IWL_MAX_MCS_DISPLAY_SIZE        12
+
+struct iwl_rate_mcs_info {
+	char    mbps[IWL_MAX_MCS_DISPLAY_SIZE];
+	char    mcs[IWL_MAX_MCS_DISPLAY_SIZE];
+};
+
+/* These serve as indexes into
  * struct iwl_rate_info fw_rate_idx_to_plcp[IWL_RATE_COUNT];
  * TODO: avoid overlap between legacy and HT rates
  */
drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c +46 -0

64 lines not on this page · raw message

drivers/net/wireless/intel/iwlwifi/mvm/rs-fw.c +33 -0
index 2d58cb969918..dc12d8890021 100644
@@ -359,6 +359,39 @@ void iwl_mvm_tlc_update_notif(struct iwl_mvm *mvm,
 	rcu_read_unlock();
 }
 
+#ifdef CONFIG_IWLWIFI_DHC
+int iwl_rs_send_dhc(struct iwl_mvm *mvm, struct iwl_lq_sta_rs_fw *lq_sta,
+		    u32 type, u32 data)
+{
+	int ret;
+	struct iwl_dhc_cmd *dhc_cmd;
+	struct iwl_dhc_tlc_cmd *dhc_tlc_cmd;
+	u32 cmd_id = iwl_cmd_id(DEBUG_HOST_COMMAND, IWL_ALWAYS_LONG_GROUP, 0);
+
+	dhc_cmd = kzalloc(sizeof(*dhc_cmd) + sizeof(*dhc_tlc_cmd), GFP_KERNEL);
+	if (!dhc_cmd)
+		return -ENOMEM;
+
+	dhc_tlc_cmd = (void *)dhc_cmd->data;
+	dhc_tlc_cmd->sta_id = lq_sta->pers.sta_id;
+	dhc_tlc_cmd->type = cpu_to_le32(type);
+	dhc_tlc_cmd->data[0] = cpu_to_le32(data);
+	dhc_cmd->length = cpu_to_le32(sizeof(*dhc_tlc_cmd) >> 2);
+	dhc_cmd->index_and_mask =
+		cpu_to_le32(DHC_TABLE_INTEGRATION | DHC_TARGET_UMAC |
+			    DHC_INTEGRATION_TLC_DEBUG_CONFIG);
+
+	ret = iwl_mvm_send_cmd_pdu(mvm, cmd_id, CMD_ASYNC,
+				   sizeof(*dhc_cmd) + sizeof(*dhc_tlc_cmd),
+				   dhc_cmd);
+	if (ret)
+		IWL_ERR(mvm, "Failed to send TLC Debug command: %d\n", ret);
+
+	kfree(dhc_cmd);
+	return ret;
+}
+#endif /* CONFIG_IWLWIFI_DHC */
+
 u16 rs_fw_get_max_amsdu_len(struct ieee80211_sta *sta)
 {
 	struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
drivers/net/wireless/intel/iwlwifi/mvm/rs.h +3 -7
index 32104c9f8f5e..2b72d477a46f 100644
@@ -211,13 +211,6 @@ struct rs_rate {
 #define is_ht80(rate)         ((rate)->bw == RATE_MCS_CHAN_WIDTH_80)
 #define is_ht160(rate)        ((rate)->bw == RATE_MCS_CHAN_WIDTH_160)
 
-#define IWL_MAX_MCS_DISPLAY_SIZE	12
-
-struct iwl_rate_mcs_info {
-	char	mbps[IWL_MAX_MCS_DISPLAY_SIZE];
-	char	mcs[IWL_MAX_MCS_DISPLAY_SIZE];
-};
-
 /**
  * struct iwl_lq_sta_rs_fw - rate and related statistics for RS in FW
  * @last_rate_n_flags: last rate reported by FW
@@ -454,4 +447,7 @@ void iwl_mvm_tlc_update_notif(struct iwl_mvm *mvm,
 			      struct iwl_rx_cmd_buffer *rxb);
 
 u16 rs_fw_get_max_amsdu_len(struct ieee80211_sta *sta);
+
+int iwl_rs_send_dhc(struct iwl_mvm *mvm, struct iwl_lq_sta_rs_fw *lq_sta,
+		    u32 type, u32 data);
 #endif /* __rs__ */
Signature · 1 line
2.33.0
#17 lore raw

PATCH 10/12 iwlwifi: Add support for getting rf id with blank otp

In reply to Luca Coelho

From: Matti Gottlieb <[email protected]>

When having a blank OTP the only way to get the rf id and the cdb info is from prph registers.

Currently there is some implementation for this, but it is located in the wrong place in the code (should be before trying to understand what HW is connected and not after), and it has a partial implementation.

---
 drivers/net/wireless/intel/iwlwifi/fw/dbg.c   |  2 +-
 .../wireless/intel/iwlwifi/fw/error-dump.h    |  4 -
 drivers/net/wireless/intel/iwlwifi/iwl-prph.h | 38 ++++++++
 drivers/net/wireless/intel/iwlwifi/pcie/drv.c | 97 +++++++++++++++++++
 4 files changed, 136 insertions(+), 5 deletions(-)
drivers/net/wireless/intel/iwlwifi/fw/dbg.c +1 -1
index 6dcafd0a3d4b..b7f2f0662b82 100644
@@ -2077,7 +2077,7 @@ static u32 iwl_dump_ini_info(struct iwl_fw_runtime *fwrt,
 	 */
 	hw_type = CSR_HW_REV_TYPE(fwrt->trans->hw_rev);
 	if (hw_type == IWL_AX210_HW_TYPE) {
-		u32 prph_val = iwl_read_prph(fwrt->trans, WFPM_OTP_CFG1_ADDR);
+		u32 prph_val = iwl_read_prph(fwrt->trans, WFPM_OTP_CFG1_ADDR_GEN2);
 		u32 is_jacket = !!(prph_val & WFPM_OTP_CFG1_IS_JACKET_BIT);
 		u32 is_cdb = !!(prph_val & WFPM_OTP_CFG1_IS_CDB_BIT);
 		u32 masked_bits = is_jacket | (is_cdb << 1);
drivers/net/wireless/intel/iwlwifi/fw/error-dump.h +0 -4
index 521ca2bb0e92..9036b32ec765 100644
@@ -342,10 +342,6 @@ struct iwl_fw_ini_dump_cfg_name {
 #define IWL_AX210_HW_TYPE 0x42
 /* How many bits to roll when adding to the HW type of AX210 HW */
 #define IWL_AX210_HW_TYPE_ADDITION_SHIFT 12
-/* This prph is used to tell apart HW_TYPE == 0x42 NICs */
-#define WFPM_OTP_CFG1_ADDR 0xd03098
-#define WFPM_OTP_CFG1_IS_JACKET_BIT BIT(4)
-#define WFPM_OTP_CFG1_IS_CDB_BIT BIT(5)
 
 /* struct iwl_fw_ini_dump_info - ini dump information
  * @version: dump version
drivers/net/wireless/intel/iwlwifi/iwl-prph.h +38 -0
index d0a7d58336a9..972f8ba7a95f 100644
@@ -347,6 +347,12 @@
 #define RADIO_REG_SYS_MANUAL_DFT_0	0xAD4078
 #define RFIC_REG_RD			0xAD0470
 #define WFPM_CTRL_REG			0xA03030
+#define WFPM_CTRL_REG_GEN2		0xd03030
+#define WFPM_OTP_CFG1_ADDR		0x00a03098
+#define WFPM_OTP_CFG1_ADDR_GEN2		0x00d03098
+#define WFPM_OTP_CFG1_IS_JACKET_BIT	BIT(4)
+#define WFPM_OTP_CFG1_IS_CDB_BIT	BIT(5)
+
 #define WFPM_GP2			0xA030B4
 
 /* DBGI SRAM Register details */
@@ -399,10 +405,42 @@ enum {
 	LMPM_PAGE_PASS_NOTIF_POS = BIT(20),
 };
 
+/*
+ * struct iwl_crf_chip_id_reg
+ *
+ * type: bits 0-11
+ * reserved: bits 12-18
+ * slave_exist: bit 19
+ * dash: bits 20-23
+ * step: bits 24-26
+ * flavor: bits 27-31
+ */
+struct iwl_crf_chip_id_reg {
+	u32 type : 12;
+	u32 reserved : 7;
+	u32 slave_exist : 1;
+	u32 dash : 4;
+	u32 step : 4;
+	u32 flavor : 4;
+};
+
 #define UREG_CHICK		(0xA05C00)
 #define UREG_CHICK_MSI_ENABLE	BIT(24)
 #define UREG_CHICK_MSIX_ENABLE	BIT(25)
 
+#define SD_REG_VER		0xa29600
+#define SD_REG_VER_GEN2		0x00a2b800
+
+#define REG_CRF_ID_TYPE_JF_1			0x201
+#define REG_CRF_ID_TYPE_JF_2			0x202
+#define REG_CRF_ID_TYPE_HR_CDB			0x503
+#define REG_CRF_ID_TYPE_HR_NONE_CDB		0x504
+#define REG_CRF_ID_TYPE_HR_NONE_CDB_1X1	0x501
+#define REG_CRF_ID_TYPE_HR_NONE_CDB_CCP	0x532
+#define REG_CRF_ID_TYPE_GF			0x410
+#define REG_CRF_ID_TYPE_GF_TC			0xF08
+#define REG_CRF_ID_TYPE_MR			0x810
+
 #define HPM_DEBUG			0xA03440
 #define PERSISTENCE_BIT			BIT(12)
 #define PREG_WFPM_ACCESS		BIT(12)
drivers/net/wireless/intel/iwlwifi/pcie/drv.c +97 -0

109 lines not on this page · raw message

Signature · 1 line
2.33.0
#18 lore raw

Re: [PATCH 10/12] iwlwifi: Add support for getting rf id with blank otp

Quoted 12 lines · Luca Coelho

From: Matti Gottlieb <[email protected]>

When having a blank OTP the only way to get the rf id and the cdb info is from prph registers.

Currently there is some implementation for this, but it is located in the wrong place in the code (should be before trying to understand what HW is connected and not after), and it has a partial implementation.

[...]

Quoted 8 lines
drivers/net/wireless/intel/iwlwifi/iwl-prph.h +8 -0
+/*
+ * struct iwl_crf_chip_id_reg
+ *
+ * type: bits 0-11
+ * reserved: bits 12-18
+ * slave_exist: bit 19
+ * dash: bits 20-23
+ * step: bits 24-26

drivers/net/wireless/intel/iwlwifi/iwl-prph.h enum { · line 425

Quoted 10 lines
drivers/net/wireless/intel/iwlwifi/iwl-prph.h +10 -0
+ * flavor: bits 27-31
+ */
+struct iwl_crf_chip_id_reg {
+	u32 type : 12;
+	u32 reserved : 7;
+	u32 slave_exist : 1;
+	u32 dash : 4;
+	u32 step : 4;
+	u32 flavor : 4;
+};

This doesn't look endian safe.

drivers/net/wireless/intel/iwlwifi/pcie/drv.c static const struct iwl_dev_info iwl_dev_info_table[] = { · line 1201

Quoted 5 lines
drivers/net/wireless/intel/iwlwifi/pcie/drv.c +5 -0
+	/* Set CDB capabilities */
+	if (cdb & BIT(4)) {
+		iwl_trans->hw_rf_id += BIT(28);
+		IWL_INFO(iwl_trans, "Adding cdb to rf id\n");
+	}

Magic numbers.

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#19 lore raw

Re: [PATCH 10/12] iwlwifi: Add support for getting rf id with blank otp

Quoted 29 lines · Kalle Valo
Quoted 12 lines · Luca Coelho

From: Matti Gottlieb <[email protected]>

When having a blank OTP the only way to get the rf id and the cdb info is from prph registers.

Currently there is some implementation for this, but it is located in the wrong place in the code (should be before trying to understand what HW is connected and not after), and it has a partial implementation.

[...]

Quoted 12 lines
drivers/net/wireless/intel/iwlwifi/iwl-prph.h +12 -0
+/*
+ * struct iwl_crf_chip_id_reg
+ *
+ * type: bits 0-11
+ * reserved: bits 12-18
+ * slave_exist: bit 19
+ * dash: bits 20-23
+ * step: bits 24-26
+ * flavor: bits 27-31
+ */
+struct iwl_crf_chip_id_reg {
+	u32 type : 12;
Quoted 8 lines

drivers/net/wireless/intel/iwlwifi/iwl-prph.h enum { · line 425

Quoted 6 lines
drivers/net/wireless/intel/iwlwifi/iwl-prph.h +6 -0
+	u32 reserved : 7;
+	u32 slave_exist : 1;
+	u32 dash : 4;
+	u32 step : 4;
+	u32 flavor : 4;
+};

This doesn't look endian safe.

It's not exactly that this is not endian safe, but we had two issues:

1. AFAIK these bitfields are not guaranteed to be kept in order, so we shouldn't use them. I'll change it to decode this in some other way.

2. We are actually reading the register without caring for endianess. I will fix it.

Expect v2 soon.

--
Cheers,
Luca.

Quoted 8 lines

drivers/net/wireless/intel/iwlwifi/pcie/drv.c static const struct iwl_dev_info iwl_dev_info_table[] = { · line 1201

Quoted 5 lines
drivers/net/wireless/intel/iwlwifi/pcie/drv.c +5 -0
+	/* Set CDB capabilities */
+	if (cdb & BIT(4)) {
+		iwl_trans->hw_rf_id += BIT(28);
+		IWL_INFO(iwl_trans, "Adding cdb to rf id\n");
+	}

Magic numbers.

#20 lore raw

Re: [PATCH 10/12] iwlwifi: Add support for getting rf id with blank otp

Quoted 39 lines · Luca Coelho
Quoted 29 lines · Kalle Valo
Quoted 12 lines · Luca Coelho

From: Matti Gottlieb <[email protected]>

When having a blank OTP the only way to get the rf id and the cdb info is from prph registers.

Currently there is some implementation for this, but it is located in the wrong place in the code (should be before trying to understand what HW is connected and not after), and it has a partial implementation.

[...]

Quoted 12 lines
drivers/net/wireless/intel/iwlwifi/iwl-prph.h +12 -0
+/*
+ * struct iwl_crf_chip_id_reg
+ *
+ * type: bits 0-11
+ * reserved: bits 12-18
+ * slave_exist: bit 19
+ * dash: bits 20-23
+ * step: bits 24-26
+ * flavor: bits 27-31
+ */
+struct iwl_crf_chip_id_reg {
+	u32 type : 12;
Quoted 8 lines

drivers/net/wireless/intel/iwlwifi/iwl-prph.h enum { · line 425

Quoted 6 lines
drivers/net/wireless/intel/iwlwifi/iwl-prph.h +6 -0
+	u32 reserved : 7;
+	u32 slave_exist : 1;
+	u32 dash : 4;
+	u32 step : 4;
+	u32 flavor : 4;
+};

This doesn't look endian safe.

Quoted 7 lines

It's not exactly that this is not endian safe, but we had two issues:

1. AFAIK these bitfields are not guaranteed to be kept in order, so we shouldn't use them. I'll change it to decode this in some other way.

2. We are actually reading the register without caring for endianess. I will fix it.

Oops, as Johannes pointed out offline, this is not an issue, actually. I got confused with some places where we do cpu_to_le32() after reading, which is the opposite and essentially proves that the read is in cpu-endianess. So I won't "fix" it. ;)

--
Cheers,
Luca.

#21 lore raw

Re: [PATCH 10/12] iwlwifi: Add support for getting rf id with blank otp

Quoted 45 lines · Luca Coelho
Quoted 44 lines · Luca Coelho
Quoted 29 lines · Kalle Valo
Quoted 12 lines · Luca Coelho

From: Matti Gottlieb <[email protected]>

When having a blank OTP the only way to get the rf id and the cdb info is from prph registers.

Currently there is some implementation for this, but it is located in the wrong place in the code (should be before trying to understand what HW is connected and not after), and it has a partial implementation.

[...]

Quoted 12 lines
drivers/net/wireless/intel/iwlwifi/iwl-prph.h +12 -0
+/*
+ * struct iwl_crf_chip_id_reg
+ *
+ * type: bits 0-11
+ * reserved: bits 12-18
+ * slave_exist: bit 19
+ * dash: bits 20-23
+ * step: bits 24-26
+ * flavor: bits 27-31
+ */
+struct iwl_crf_chip_id_reg {
+	u32 type : 12;
Quoted 8 lines

drivers/net/wireless/intel/iwlwifi/iwl-prph.h enum { · line 425

Quoted 6 lines
drivers/net/wireless/intel/iwlwifi/iwl-prph.h +6 -0
+	u32 reserved : 7;
+	u32 slave_exist : 1;
+	u32 dash : 4;
+	u32 step : 4;
+	u32 flavor : 4;
+};

This doesn't look endian safe.

It's not exactly that this is not endian safe, but we had two issues:

1. AFAIK these bitfields are not guaranteed to be kept in order, so we shouldn't use them. I'll change it to decode this in some other way.

Quoted 7 lines
Quoted 2 lines

2. We are actually reading the register without caring for endianess. I will fix it.

Oops, as Johannes pointed out offline, this is not an issue, actually. I got confused with some places where we do cpu_to_le32() after reading, which is the opposite and essentially proves that the read is in cpu-endianess. So I won't "fix" it. ;)

Good that endian is handled properly, thanks for checking.

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#22 lore raw

PATCH 11/12 iwlwifi: Add support for more BZ HWs

In reply to Luca Coelho

From: Matti Gottlieb <[email protected]>

Add support for GA and for BZ with FM rf.

---
 .../net/wireless/intel/iwlwifi/cfg/22000.c    | 23 +++++++++++++++++++
 .../net/wireless/intel/iwlwifi/iwl-config.h   |  3 +++
 drivers/net/wireless/intel/iwlwifi/iwl-prph.h |  1 +
 drivers/net/wireless/intel/iwlwifi/pcie/drv.c | 14 +++++++++++
 4 files changed, 41 insertions(+)
drivers/net/wireless/intel/iwlwifi/cfg/22000.c +23 -0
index 52d1d391f4c6..1950482b3829 100644
@@ -53,6 +53,9 @@
 #define IWL_BZ_A_GF_A_FW_PRE		"iwlwifi-bz-a0-gf-a0-"
 #define IWL_BZ_A_GF4_A_FW_PRE		"iwlwifi-bz-a0-gf4-a0-"
 #define IWL_BZ_A_MR_A_FW_PRE		"iwlwifi-bz-a0-mr-a0-"
+#define IWL_BZ_A_FM_A_FW_PRE		"iwlwifi-bz-a0-fm-a0-"
+#define IWL_GL_A_FM_A_FW_PRE		"iwlwifi-gl-a0-fm7-a0-"
+
 
 #define IWL_QU_B_HR_B_MODULE_FIRMWARE(api) \
 	IWL_QU_B_HR_B_FW_PRE __stringify(api) ".ucode"
@@ -106,6 +109,10 @@
 	IWL_BZ_A_GF4_A_FW_PRE __stringify(api) ".ucode"
 #define IWL_BZ_A_MR_A_MODULE_FIRMWARE(api) \
 	IWL_BZ_A_MR_A_FW_PRE __stringify(api) ".ucode"
+#define IWL_BZ_A_FM_A_MODULE_FIRMWARE(api) \
+		IWL_BZ_A_FM_A_FW_PRE __stringify(api) ".ucode"
+#define IWL_GL_A_FM_A_MODULE_FIRMWARE(api) \
+		IWL_GL_A_FM_A_FW_PRE __stringify(api) ".ucode"
 
 static const struct iwl_base_params iwl_22000_base_params = {
 	.eeprom_size = OTP_LOW_IMAGE_SIZE_32K,
@@ -850,6 +857,20 @@ const struct iwl_cfg iwl_cfg_bz_a0_mr_a0 = {
 	.num_rbds = IWL_NUM_RBDS_AX210_HE,
 };
 
+const struct iwl_cfg iwl_cfg_bz_a0_fm_a0 = {
+	.fw_name_pre = IWL_BZ_A_FM_A_FW_PRE,
+	.uhb_supported = true,
+	IWL_DEVICE_BZ,
+	.num_rbds = IWL_NUM_RBDS_AX210_HE,
+};
+
+const struct iwl_cfg iwl_cfg_gl_a0_fm_a0 = {
+	.fw_name_pre = IWL_GL_A_FM_A_FW_PRE,
+	.uhb_supported = true,
+	IWL_DEVICE_BZ,
+	.num_rbds = IWL_NUM_RBDS_AX210_HE,
+};
+
 MODULE_FIRMWARE(IWL_QU_B_HR_B_MODULE_FIRMWARE(IWL_22000_UCODE_API_MAX));
 MODULE_FIRMWARE(IWL_QNJ_B_HR_B_MODULE_FIRMWARE(IWL_22000_UCODE_API_MAX));
 MODULE_FIRMWARE(IWL_QU_C_HR_B_MODULE_FIRMWARE(IWL_22000_UCODE_API_MAX));
@@ -876,3 +897,5 @@ MODULE_FIRMWARE(IWL_BZ_A_HR_B_MODULE_FIRMWARE(IWL_22000_UCODE_API_MAX));
 MODULE_FIRMWARE(IWL_BZ_A_GF_A_MODULE_FIRMWARE(IWL_22000_UCODE_API_MAX));
 MODULE_FIRMWARE(IWL_BZ_A_GF4_A_MODULE_FIRMWARE(IWL_22000_UCODE_API_MAX));
 MODULE_FIRMWARE(IWL_BZ_A_MR_A_MODULE_FIRMWARE(IWL_22000_UCODE_API_MAX));
+MODULE_FIRMWARE(IWL_BZ_A_FM_A_MODULE_FIRMWARE(IWL_22000_UCODE_API_MAX));
+MODULE_FIRMWARE(IWL_GL_A_FM_A_MODULE_FIRMWARE(IWL_22000_UCODE_API_MAX));
drivers/net/wireless/intel/iwlwifi/iwl-config.h +3 -0
index 7eb534df5331..f55f08d4d511 100644
@@ -420,6 +420,7 @@ struct iwl_cfg {
 #define IWL_CFG_MAC_TYPE_SOF		0x43
 #define IWL_CFG_MAC_TYPE_MA		0x44
 #define IWL_CFG_MAC_TYPE_BZ		0x46
+#define IWL_CFG_MAC_TYPE_GL		0x47
 
 #define IWL_CFG_RF_TYPE_TH		0x105
 #define IWL_CFG_RF_TYPE_TH1		0x108
@@ -628,6 +629,8 @@ extern const struct iwl_cfg iwl_cfg_bz_a0_hr_b0;
 extern const struct iwl_cfg iwl_cfg_bz_a0_gf_a0;
 extern const struct iwl_cfg iwl_cfg_bz_a0_gf4_a0;
 extern const struct iwl_cfg iwl_cfg_bz_a0_mr_a0;
+extern const struct iwl_cfg iwl_cfg_bz_a0_fm_a0;
+extern const struct iwl_cfg iwl_cfg_gl_a0_fm_a0;
 #endif /* CONFIG_IWLMVM */
 
 #endif /* __IWL_CONFIG_H__ */
drivers/net/wireless/intel/iwlwifi/iwl-prph.h +1 -0
index 972f8ba7a95f..2ab5315dd803 100644
@@ -440,6 +440,7 @@ struct iwl_crf_chip_id_reg {
 #define REG_CRF_ID_TYPE_GF			0x410
 #define REG_CRF_ID_TYPE_GF_TC			0xF08
 #define REG_CRF_ID_TYPE_MR			0x810
+#define REG_CRF_ID_TYPE_FM			0x910
 
 #define HPM_DEBUG			0xA03440
 #define PERSISTENCE_BIT			BIT(12)
drivers/net/wireless/intel/iwlwifi/pcie/drv.c +14 -0
index 01011aa01bbf..3942924b8d1f 100644
@@ -1109,6 +1109,17 @@ static const struct iwl_dev_info iwl_dev_info_table[] = {
 		      IWL_CFG_RF_TYPE_MR, IWL_CFG_ANY,
 		      IWL_CFG_ANY, IWL_CFG_ANY, IWL_CFG_NO_CDB,
 		      iwl_cfg_bz_a0_mr_a0, iwl_bz_name),
+	_IWL_DEV_INFO(IWL_CFG_ANY, IWL_CFG_ANY,
+		      IWL_CFG_MAC_TYPE_BZ, IWL_CFG_ANY,
+		      IWL_CFG_RF_TYPE_FM, IWL_CFG_ANY,
+		      IWL_CFG_ANY, IWL_CFG_ANY, IWL_CFG_NO_CDB,
+		      iwl_cfg_bz_a0_fm_a0, iwl_bz_name),
+	_IWL_DEV_INFO(IWL_CFG_ANY, IWL_CFG_ANY,
+		      IWL_CFG_MAC_TYPE_GL, IWL_CFG_ANY,
+		      IWL_CFG_RF_TYPE_FM, IWL_CFG_ANY,
+		      IWL_CFG_ANY, IWL_CFG_ANY, IWL_CFG_NO_CDB,
+		      iwl_cfg_gl_a0_fm_a0, iwl_bz_name),
+
 
 /* So with GF */
 	_IWL_DEV_INFO(IWL_CFG_ANY, IWL_CFG_ANY,
@@ -1179,6 +1190,9 @@ static int get_crf_id(struct iwl_trans *iwl_trans)
 		case REG_CRF_ID_TYPE_MR:
 			iwl_trans->hw_rf_id = (IWL_CFG_RF_TYPE_MR << 12);
 			break;
+		case REG_CRF_ID_TYPE_FM:
+			iwl_trans->hw_rf_id = (IWL_CFG_RF_TYPE_FM << 12);
+			break;
 		default:
 			ret = -EIO;
 			IWL_ERR(iwl_trans,
Signature · 1 line
2.33.0
#23 lore raw

PATCH 12/12 iwlwifi: Start scratch debug register for Bz family

In reply to Luca Coelho

From: Matti Gottlieb <[email protected]>

Start scratch debug register for Bz family. This register is used for FW debug, and the driver should start this register with a fixed value, during init, and upon an error, should read it, and add it to the dump.

---
 drivers/net/wireless/intel/iwlwifi/fw/dump.c         | 7 +++++++
 drivers/net/wireless/intel/iwlwifi/iwl-csr.h         | 7 +++++++
 drivers/net/wireless/intel/iwlwifi/pcie/trans-gen2.c | 8 +++++---
 3 files changed, 19 insertions(+), 3 deletions(-)
drivers/net/wireless/intel/iwlwifi/fw/dump.c +7 -0
index a1842205e86a..1f9cf4e40547 100644
@@ -328,6 +328,13 @@ static void iwl_fwrt_dump_tcm_error_log(struct iwl_fw_runtime *fwrt)
 	for (i = 0; i < ARRAY_SIZE(table.sw_status); i++)
 		IWL_ERR(fwrt, "0x%08X | tcm SW status[%d]\n",
 			table.sw_status[i], i);
+
+	if (trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_BZ) {
+		u32 scratch = iwl_read32(trans, CSR_FUNC_SCRATCH);
+
+		IWL_ERR(fwrt, "Function Scratch status:\n");
+		IWL_ERR(fwrt, "0x%08X | Func Scratch\n", scratch);
+	}
 }
 
 static void iwl_fwrt_dump_iml_error_log(struct iwl_fw_runtime *fwrt)
drivers/net/wireless/intel/iwlwifi/iwl-csr.h +7 -0
index cf796403c45c..2c4d70fb32fa 100644
@@ -34,6 +34,7 @@
 #define CSR_GPIO_IN             (CSR_BASE+0x018) /* read external chip pins */
 #define CSR_RESET               (CSR_BASE+0x020) /* busmaster enable, NMI, etc*/
 #define CSR_GP_CNTRL            (CSR_BASE+0x024)
+#define CSR_FUNC_SCRATCH        (CSR_BASE+0x02c) /* Scratch register - used for FW dbg */
 
 /* 2nd byte of CSR_INT_COALESCING, not accessible via iwl_write32()! */
 #define CSR_INT_PERIODIC_REG	(CSR_BASE+0x005)
@@ -135,6 +136,12 @@
 #define CSR_DBG_HPET_MEM_REG		(CSR_BASE+0x240)
 #define CSR_DBG_LINK_PWR_MGMT_REG	(CSR_BASE+0x250)
 
+/*
+ * Scratch register initial configuration - this is set on init, and read
+ * during a error FW error.
+ */
+#define CSR_FUNC_SCRATCH_INIT_VALUE		(0x01010101)
+
 /* Bits for CSR_HW_IF_CONFIG_REG */
 #define CSR_HW_IF_CONFIG_REG_MSK_MAC_DASH	(0x00000003)
 #define CSR_HW_IF_CONFIG_REG_MSK_MAC_STEP	(0x0000000C)
drivers/net/wireless/intel/iwlwifi/pcie/trans-gen2.c +5 -3
index bf0c32a74ca4..53bc5b7d8d5c 100644
@@ -466,13 +466,15 @@ int iwl_trans_pcie_gen2_start_fw(struct iwl_trans *trans,
 
 	iwl_pcie_set_ltr(trans);
 
-	if (trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_BZ)
+	if (trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_BZ) {
+		iwl_write32(trans, CSR_FUNC_SCRATCH, CSR_FUNC_SCRATCH_INIT_VALUE);
 		iwl_set_bit(trans, CSR_GP_CNTRL,
 			    CSR_GP_CNTRL_REG_FLAG_ROM_START);
-	else if (trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_AX210)
+	} else if (trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_AX210) {
 		iwl_write_umac_prph(trans, UREG_CPU_INIT_RUN, 1);
-	else
+	} else {
 		iwl_write_prph(trans, UREG_CPU_INIT_RUN, 1);
+	}
 
 	/* re-check RF-Kill state since we may have missed the interrupt */
 	hw_rfkill = iwl_pcie_check_hw_rf_kill(trans);
Signature · 1 line
2.33.0