Commit 91c28b83 authored by Shahar S Matityahu's avatar Shahar S Matityahu Committed by Luca Coelho
Browse files

iwlwifi: dbg: move trans debug fields to a separate struct



Unite iwl_trans debug related fields under iwl_trans_debug struct to
increase readability and keep iwl_trans clean.

Signed-off-by: default avatarShahar S Matityahu <shahar.s.matityahu@intel.com>
Signed-off-by: default avatarLuca Coelho <luciano.coelho@intel.com>
parent 1d45a700
Loading
Loading
Loading
Loading
+23 −21
Original line number Diff line number Diff line
@@ -1155,10 +1155,10 @@ iwl_dump_ini_mon_dram_iter(struct iwl_fw_runtime *fwrt,
		return -EBUSY;

	range->dram_base_addr = cpu_to_le64(start_addr);
	range->range_data_size = cpu_to_le32(fwrt->trans->fw_mon[idx].size);
	range->range_data_size = cpu_to_le32(fwrt->trans->dbg.fw_mon[idx].size);

	memcpy(range->data, fwrt->trans->fw_mon[idx].block,
	       fwrt->trans->fw_mon[idx].size);
	memcpy(range->data, fwrt->trans->dbg.fw_mon[idx].block,
	       fwrt->trans->dbg.fw_mon[idx].size);

	return sizeof(*range) + le32_to_cpu(range->range_data_size);
}
@@ -1581,8 +1581,8 @@ static u32 iwl_dump_ini_mon_dram_get_size(struct iwl_fw_runtime *fwrt,
	u32 size = sizeof(struct iwl_fw_ini_monitor_dump) +
		sizeof(struct iwl_fw_ini_error_dump_range);

	if (fwrt->trans->num_blocks)
		size += fwrt->trans->fw_mon[0].size;
	if (fwrt->trans->dbg.num_blocks)
		size += fwrt->trans->dbg.fw_mon[0].size;

	return size;
}
@@ -1735,7 +1735,8 @@ static void iwl_dump_ini_info(struct iwl_fw_runtime *fwrt,

	dump->version = cpu_to_le32(IWL_INI_DUMP_VER);
	dump->trigger_id = trigger->trigger_id;
	dump->is_external_cfg = cpu_to_le32(fwrt->trans->external_ini_loaded);
	dump->is_external_cfg =
		cpu_to_le32(fwrt->trans->dbg.external_ini_loaded);

	dump->ver_type = cpu_to_le32(fwrt->dump.fw_ver.type);
	dump->ver_subtype = cpu_to_le32(fwrt->dump.fw_ver.subtype);
@@ -1842,7 +1843,7 @@ static int iwl_fw_ini_get_trigger_len(struct iwl_fw_runtime *fwrt,
				ret_size += hdr_len + size;
			break;
		case IWL_FW_INI_REGION_DRAM_BUFFER:
			if (!fwrt->trans->num_blocks)
			if (!fwrt->trans->dbg.num_blocks)
				break;
			size = iwl_dump_ini_mon_dram_get_size(fwrt, reg);
			if (size)
@@ -2097,7 +2098,7 @@ int iwl_fw_dbg_collect_desc(struct iwl_fw_runtime *fwrt,
	u32 trig_type = le32_to_cpu(desc->trig_desc.type);
	int ret;

	if (fwrt->trans->ini_valid) {
	if (fwrt->trans->dbg.ini_valid) {
		ret = iwl_fw_dbg_ini_collect(fwrt, trig_type);
		if (!ret)
			iwl_fw_free_dump_desc(fwrt);
@@ -2374,7 +2375,7 @@ static void iwl_fw_dbg_collect_sync(struct iwl_fw_runtime *fwrt, u8 wk_idx)
	iwl_fw_dbg_stop_recording(fwrt, &params);

	IWL_DEBUG_FW_INFO(fwrt, "WRT: data collection start\n");
	if (fwrt->trans->ini_valid)
	if (fwrt->trans->dbg.ini_valid)
		iwl_fw_error_ini_dump(fwrt, wk_idx);
	else
		iwl_fw_error_dump(fwrt);
@@ -2474,7 +2475,8 @@ iwl_fw_dbg_buffer_allocation(struct iwl_fw_runtime *fwrt, u32 size)
	void *virtual_addr = NULL;
	dma_addr_t phys_addr;

	if (WARN_ON_ONCE(trans->num_blocks == ARRAY_SIZE(trans->fw_mon)))
	if (WARN_ON_ONCE(trans->dbg.num_blocks ==
			 ARRAY_SIZE(trans->dbg.fw_mon)))
		return;

	virtual_addr =
@@ -2488,12 +2490,12 @@ iwl_fw_dbg_buffer_allocation(struct iwl_fw_runtime *fwrt, u32 size)

	IWL_DEBUG_FW(trans,
		     "Allocated DRAM buffer[%d], size=0x%x\n",
		     trans->num_blocks, size);
		     trans->dbg.num_blocks, size);

	trans->fw_mon[trans->num_blocks].block = virtual_addr;
	trans->fw_mon[trans->num_blocks].physical = phys_addr;
	trans->fw_mon[trans->num_blocks].size = size;
	trans->num_blocks++;
	trans->dbg.fw_mon[trans->dbg.num_blocks].block = virtual_addr;
	trans->dbg.fw_mon[trans->dbg.num_blocks].physical = phys_addr;
	trans->dbg.fw_mon[trans->dbg.num_blocks].size = size;
	trans->dbg.num_blocks++;
}

static void iwl_fw_dbg_buffer_apply(struct iwl_fw_runtime *fwrt,
@@ -2511,7 +2513,7 @@ static void iwl_fw_dbg_buffer_apply(struct iwl_fw_runtime *fwrt,
		.data[0] = &ldbg_cmd,
		.len[0] = sizeof(ldbg_cmd),
	};
	int block_idx = trans->num_blocks;
	int block_idx = trans->dbg.num_blocks;
	u32 buf_location = le32_to_cpu(alloc->tlv.buffer_location);

	if (buf_location == IWL_FW_INI_LOCATION_SRAM_PATH) {
@@ -2529,13 +2531,13 @@ static void iwl_fw_dbg_buffer_apply(struct iwl_fw_runtime *fwrt,
	if (!alloc->is_alloc) {
		iwl_fw_dbg_buffer_allocation(fwrt,
					     le32_to_cpu(alloc->tlv.size));
		if (block_idx == trans->num_blocks)
		if (block_idx == trans->dbg.num_blocks)
			return;
		alloc->is_alloc = 1;
	}

	/* First block is assigned via registers / context info */
	if (trans->num_blocks == 1)
	if (trans->dbg.num_blocks == 1)
		return;

	IWL_DEBUG_FW(trans,
@@ -2543,7 +2545,7 @@ static void iwl_fw_dbg_buffer_apply(struct iwl_fw_runtime *fwrt,

	cmd->num_frags = cpu_to_le32(1);
	cmd->fragments[0].address =
		cpu_to_le64(trans->fw_mon[block_idx].physical);
		cpu_to_le64(trans->dbg.fw_mon[block_idx].physical);
	cmd->fragments[0].size = alloc->tlv.size;
	cmd->allocation_id = alloc->tlv.allocation_id;
	cmd->buffer_location = alloc->tlv.buffer_location;
@@ -2835,7 +2837,7 @@ static void iwl_fw_dbg_ini_reset_cfg(struct iwl_fw_runtime *fwrt)
void iwl_fw_dbg_apply_point(struct iwl_fw_runtime *fwrt,
			    enum iwl_fw_ini_apply_point apply_point)
{
	void *data = &fwrt->trans->apply_points[apply_point];
	void *data = &fwrt->trans->dbg.apply_points[apply_point];

	IWL_DEBUG_FW(fwrt, "WRT: enabling apply point %d\n", apply_point);

@@ -2844,7 +2846,7 @@ void iwl_fw_dbg_apply_point(struct iwl_fw_runtime *fwrt,

	_iwl_fw_dbg_apply_point(fwrt, data, apply_point, false);

	data = &fwrt->trans->apply_points_ext[apply_point];
	data = &fwrt->trans->dbg.apply_points_ext[apply_point];
	_iwl_fw_dbg_apply_point(fwrt, data, apply_point, true);
}
IWL_EXPORT_SYMBOL(iwl_fw_dbg_apply_point);
+12 −12
Original line number Diff line number Diff line
@@ -202,7 +202,7 @@ _iwl_fw_dbg_trigger_on(struct iwl_fw_runtime *fwrt,
{
	struct iwl_fw_dbg_trigger_tlv *trig;

	if (fwrt->trans->ini_valid)
	if (fwrt->trans->dbg.ini_valid)
		return NULL;

	if (!iwl_fw_dbg_trigger_enabled(fwrt->fw, id))
@@ -229,7 +229,7 @@ iwl_fw_ini_trigger_on(struct iwl_fw_runtime *fwrt,
	struct iwl_fw_ini_trigger *trig;
	u32 usec;

	if (!fwrt->trans->ini_valid || id == IWL_FW_TRIGGER_ID_INVALID ||
	if (!fwrt->trans->dbg.ini_valid || id == IWL_FW_TRIGGER_ID_INVALID ||
	    id >= IWL_FW_TRIGGER_ID_NUM || !fwrt->dump.active_trigs[id].active)
		return false;

@@ -301,7 +301,7 @@ _iwl_fw_dbg_stop_recording(struct iwl_trans *trans,
	usleep_range(700, 1000);
	iwl_write_umac_prph(trans, DBGC_OUT_CTRL, 0);
#ifdef CONFIG_IWLWIFI_DEBUGFS
	trans->dbg_rec_on = false;
	trans->dbg.rec_on = false;
#endif
}

@@ -336,7 +336,7 @@ _iwl_fw_dbg_restart_recording(struct iwl_trans *trans,
static inline void iwl_fw_set_dbg_rec_on(struct iwl_fw_runtime *fwrt)
{
	if (fwrt->fw->dbg.dest_tlv && fwrt->cur_fw_img == IWL_UCODE_REGULAR)
		fwrt->trans->dbg_rec_on = true;
		fwrt->trans->dbg.rec_on = true;
}
#endif

@@ -452,28 +452,28 @@ void iwl_fwrt_stop_device(struct iwl_fw_runtime *fwrt);
static inline void iwl_fw_lmac1_set_alive_err_table(struct iwl_trans *trans,
						    u32 lmac_error_event_table)
{
	if (!(trans->error_event_table_tlv_status &
	if (!(trans->dbg.error_event_table_tlv_status &
	      IWL_ERROR_EVENT_TABLE_LMAC1) ||
	    WARN_ON(trans->lmac_error_event_table[0] !=
	    WARN_ON(trans->dbg.lmac_error_event_table[0] !=
		    lmac_error_event_table))
		trans->lmac_error_event_table[0] = lmac_error_event_table;
		trans->dbg.lmac_error_event_table[0] = lmac_error_event_table;
}

static inline void iwl_fw_umac_set_alive_err_table(struct iwl_trans *trans,
						   u32 umac_error_event_table)
{
	if (!(trans->error_event_table_tlv_status &
	if (!(trans->dbg.error_event_table_tlv_status &
	      IWL_ERROR_EVENT_TABLE_UMAC) ||
	    WARN_ON(trans->umac_error_event_table !=
	    WARN_ON(trans->dbg.umac_error_event_table !=
		    umac_error_event_table))
		trans->umac_error_event_table = umac_error_event_table;
		trans->dbg.umac_error_event_table = umac_error_event_table;
}

static inline void iwl_fw_error_collect(struct iwl_fw_runtime *fwrt)
{
	if (fwrt->trans->ini_valid && fwrt->trans->hw_error) {
	if (fwrt->trans->dbg.ini_valid && fwrt->trans->dbg.hw_error) {
		_iwl_fw_dbg_ini_collect(fwrt, IWL_FW_TRIGGER_ID_FW_HW_ERROR);
		fwrt->trans->hw_error = false;
		fwrt->trans->dbg.hw_error = false;
	} else {
		iwl_fw_dbg_collect_desc(fwrt, &iwl_dump_desc_assert, false, 0);
	}
+16 −16
Original line number Diff line number Diff line
@@ -81,9 +81,9 @@ void iwl_fw_dbg_copy_tlv(struct iwl_trans *trans, struct iwl_ucode_tlv *tlv,
		return;

	if (ext)
		data = &trans->apply_points_ext[apply_point];
		data = &trans->dbg.apply_points_ext[apply_point];
	else
		data = &trans->apply_points[apply_point];
		data = &trans->dbg.apply_points[apply_point];

	/* add room for is_alloc field in &iwl_fw_ini_allocation_data struct */
	if (le32_to_cpu(tlv->type) == IWL_UCODE_TLV_TYPE_BUFFER_ALLOCATION) {
@@ -172,14 +172,14 @@ void iwl_alloc_dbg_tlv(struct iwl_trans *trans, size_t len, const u8 *data,
		}

		if (ext) {
			trans->apply_points_ext[i].data = mem;
			trans->apply_points_ext[i].size = size[i];
			trans->dbg.apply_points_ext[i].data = mem;
			trans->dbg.apply_points_ext[i].size = size[i];
		} else {
			trans->apply_points[i].data = mem;
			trans->apply_points[i].size = size[i];
			trans->dbg.apply_points[i].data = mem;
			trans->dbg.apply_points[i].size = size[i];
		}

		trans->ini_valid = true;
		trans->dbg.ini_valid = true;
	}
}

@@ -187,14 +187,14 @@ void iwl_fw_dbg_free(struct iwl_trans *trans)
{
	int i;

	for (i = 0; i < ARRAY_SIZE(trans->apply_points); i++) {
		kfree(trans->apply_points[i].data);
		trans->apply_points[i].size = 0;
		trans->apply_points[i].offset = 0;
	for (i = 0; i < ARRAY_SIZE(trans->dbg.apply_points); i++) {
		kfree(trans->dbg.apply_points[i].data);
		trans->dbg.apply_points[i].size = 0;
		trans->dbg.apply_points[i].offset = 0;

		kfree(trans->apply_points_ext[i].data);
		trans->apply_points_ext[i].size = 0;
		trans->apply_points_ext[i].offset = 0;
		kfree(trans->dbg.apply_points_ext[i].data);
		trans->dbg.apply_points_ext[i].size = 0;
		trans->dbg.apply_points_ext[i].offset = 0;
	}
}

@@ -243,7 +243,7 @@ void iwl_load_fw_dbg_tlv(struct device *dev, struct iwl_trans *trans)
	const struct firmware *fw;
	int res;

	if (trans->external_ini_loaded || !iwlwifi_mod_params.enable_ini)
	if (trans->dbg.external_ini_loaded || !iwlwifi_mod_params.enable_ini)
		return;

	res = request_firmware(&fw, "iwl-dbg-tlv.ini", dev);
@@ -253,6 +253,6 @@ void iwl_load_fw_dbg_tlv(struct device *dev, struct iwl_trans *trans)
	iwl_alloc_dbg_tlv(trans, fw->size, fw->data, true);
	iwl_parse_fw_dbg_tlv(trans, fw->data, fw->size);

	trans->external_ini_loaded = true;
	trans->dbg.external_ini_loaded = true;
	release_firmware(fw);
}
+4 −4
Original line number Diff line number Diff line
@@ -1114,10 +1114,10 @@ static int iwl_parse_tlv_firmware(struct iwl_drv *drv,
			if (drv->trans->cfg->device_family <
			    IWL_DEVICE_FAMILY_22000)
				break;
			drv->trans->umac_error_event_table =
			drv->trans->dbg.umac_error_event_table =
				le32_to_cpu(dbg_ptrs->error_info_addr) &
				~FW_ADDR_CACHE_CONTROL;
			drv->trans->error_event_table_tlv_status |=
			drv->trans->dbg.error_event_table_tlv_status |=
				IWL_ERROR_EVENT_TABLE_UMAC;
			break;
			}
@@ -1130,10 +1130,10 @@ static int iwl_parse_tlv_firmware(struct iwl_drv *drv,
			if (drv->trans->cfg->device_family <
			    IWL_DEVICE_FAMILY_22000)
				break;
			drv->trans->lmac_error_event_table[0] =
			drv->trans->dbg.lmac_error_event_table[0] =
				le32_to_cpu(dbg_ptrs->error_event_table_ptr) &
				~FW_ADDR_CACHE_CONTROL;
			drv->trans->error_event_table_tlv_status |=
			drv->trans->dbg.error_event_table_tlv_status |=
				IWL_ERROR_EVENT_TABLE_LMAC1;
			break;
			}
+43 −30
Original line number Diff line number Diff line
@@ -721,6 +721,48 @@ struct iwl_self_init_dram {
	int paging_cnt;
};

/**
 * struct iwl_trans_debug - transport debug related data
 *
 * @n_dest_reg: num of reg_ops in %dbg_dest_tlv
 * @rec_on: true iff there is a fw debug recording currently active
 * @dest_tlv: points to the destination TLV for debug
 * @conf_tlv: array of pointers to configuration TLVs for debug
 * @trigger_tlv: array of pointers to triggers TLVs for debug
 * @lmac_error_event_table: addrs of lmacs error tables
 * @umac_error_event_table: addr of umac error table
 * @error_event_table_tlv_status: bitmap that indicates what error table
 *	pointers was recevied via TLV. uses enum &iwl_error_event_table_status
 * @external_ini_loaded: indicates if an external ini cfg was given
 * @ini_valid: indicates if debug ini mode is on
 * @num_blocks: number of blocks in fw_mon
 * @fw_mon: address of the buffers for firmware monitor
 * @hw_error: equals true if hw error interrupt was received from the FW
 */
struct iwl_trans_debug {
	u8 n_dest_reg;
	bool rec_on;

	const struct iwl_fw_dbg_dest_tlv_v1 *dest_tlv;
	const struct iwl_fw_dbg_conf_tlv *conf_tlv[FW_DBG_CONF_MAX];
	struct iwl_fw_dbg_trigger_tlv * const *trigger_tlv;

	u32 lmac_error_event_table[2];
	u32 umac_error_event_table;
	unsigned int error_event_table_tlv_status;

	bool external_ini_loaded;
	bool ini_valid;

	struct iwl_apply_point_data apply_points[IWL_FW_INI_APPLY_NUM];
	struct iwl_apply_point_data apply_points_ext[IWL_FW_INI_APPLY_NUM];

	int num_blocks;
	struct iwl_dram_data fw_mon[IWL_FW_INI_APPLY_NUM];

	bool hw_error;
};

/**
 * struct iwl_trans - transport common data
 *
@@ -750,24 +792,12 @@ struct iwl_self_init_dram {
 * @rx_mpdu_cmd_hdr_size: used for tracing, amount of data before the
 *	start of the 802.11 header in the @rx_mpdu_cmd
 * @dflt_pwr_limit: default power limit fetched from the platform (ACPI)
 * @dbg_dest_tlv: points to the destination TLV for debug
 * @dbg_conf_tlv: array of pointers to configuration TLVs for debug
 * @dbg_trigger_tlv: array of pointers to triggers TLVs for debug
 * @dbg_n_dest_reg: num of reg_ops in %dbg_dest_tlv
 * @num_blocks: number of blocks in fw_mon
 * @fw_mon: address of the buffers for firmware monitor
 * @system_pm_mode: the system-wide power management mode in use.
 *	This mode is set dynamically, depending on the WoWLAN values
 *	configured from the userspace at runtime.
 * @runtime_pm_mode: the runtime power management mode in use.  This
 *	mode is set during the initialization phase and is not
 *	supposed to change during runtime.
 * @dbg_rec_on: true iff there is a fw debug recording currently active
 * @lmac_error_event_table: addrs of lmacs error tables
 * @umac_error_event_table: addr of umac error table
 * @error_event_table_tlv_status: bitmap that indicates what error table
 *	pointers was recevied via TLV. use enum &iwl_error_event_table_status
 * @hw_error: equals true if hw error interrupt was received from the FW
 */
struct iwl_trans {
	const struct iwl_trans_ops *ops;
@@ -808,29 +838,12 @@ struct iwl_trans {
	struct lockdep_map sync_cmd_lockdep_map;
#endif

	struct iwl_apply_point_data apply_points[IWL_FW_INI_APPLY_NUM];
	struct iwl_apply_point_data apply_points_ext[IWL_FW_INI_APPLY_NUM];

	bool external_ini_loaded;
	bool ini_valid;

	const struct iwl_fw_dbg_dest_tlv_v1 *dbg_dest_tlv;
	const struct iwl_fw_dbg_conf_tlv *dbg_conf_tlv[FW_DBG_CONF_MAX];
	struct iwl_fw_dbg_trigger_tlv * const *dbg_trigger_tlv;
	u8 dbg_n_dest_reg;
	int num_blocks;
	struct iwl_dram_data fw_mon[IWL_FW_INI_APPLY_NUM];
	struct iwl_trans_debug dbg;
	struct iwl_self_init_dram init_dram;

	enum iwl_plat_pm_mode system_pm_mode;
	enum iwl_plat_pm_mode runtime_pm_mode;
	bool suspending;
	bool dbg_rec_on;

	u32 lmac_error_event_table[2];
	u32 umac_error_event_table;
	unsigned int error_event_table_tlv_status;
	bool hw_error;

	/* pointer to trans specific struct */
	/*Ensure that this pointer will always be aligned to sizeof pointer */
Loading