Commit cd6de838 authored by Shahar S Matityahu's avatar Shahar S Matityahu Committed by Luca Coelho

iwlwifi: dbg_ini: use regions ops array instead of switch case in dump flow

Make a static regions ops array and use it instead of switch case when
determining what op to use to collect a region.
Signed-off-by: default avatarShahar S Matityahu <shahar.s.matityahu@intel.com>
Signed-off-by: default avatarLuca Coelho <luciano.coelho@intel.com>
parent bdc62390
...@@ -1648,7 +1648,7 @@ struct iwl_dump_ini_mem_ops { ...@@ -1648,7 +1648,7 @@ struct iwl_dump_ini_mem_ops {
*/ */
static u32 iwl_dump_ini_mem(struct iwl_fw_runtime *fwrt, struct list_head *list, static u32 iwl_dump_ini_mem(struct iwl_fw_runtime *fwrt, struct list_head *list,
struct iwl_fw_ini_region_cfg *reg, struct iwl_fw_ini_region_cfg *reg,
struct iwl_dump_ini_mem_ops *ops) const struct iwl_dump_ini_mem_ops *ops)
{ {
struct iwl_fw_ini_dump_entry *entry; struct iwl_fw_ini_dump_entry *entry;
struct iwl_fw_error_dump_data *tlv; struct iwl_fw_error_dump_data *tlv;
...@@ -1656,8 +1656,8 @@ static u32 iwl_dump_ini_mem(struct iwl_fw_runtime *fwrt, struct list_head *list, ...@@ -1656,8 +1656,8 @@ static u32 iwl_dump_ini_mem(struct iwl_fw_runtime *fwrt, struct list_head *list,
u32 num_of_ranges, i, type = le32_to_cpu(reg->region_type), size; u32 num_of_ranges, i, type = le32_to_cpu(reg->region_type), size;
void *range; void *range;
if (WARN_ON(!ops || !ops->get_num_of_ranges || !ops->get_size || if (!ops->get_num_of_ranges || !ops->get_size || !ops->fill_mem_hdr ||
!ops->fill_mem_hdr || !ops->fill_range)) !ops->fill_range)
return 0; return 0;
size = ops->get_size(fwrt, reg); size = ops->get_size(fwrt, reg);
...@@ -1789,6 +1789,75 @@ static u32 iwl_dump_ini_info(struct iwl_fw_runtime *fwrt, ...@@ -1789,6 +1789,75 @@ static u32 iwl_dump_ini_info(struct iwl_fw_runtime *fwrt,
return entry->size; return entry->size;
} }
static const struct iwl_dump_ini_mem_ops iwl_dump_ini_region_ops[] = {
[IWL_FW_INI_REGION_INVALID] = {},
[IWL_FW_INI_REGION_DEVICE_MEMORY] = {
.get_num_of_ranges = iwl_dump_ini_mem_ranges,
.get_size = iwl_dump_ini_mem_get_size,
.fill_mem_hdr = iwl_dump_ini_mem_fill_header,
.fill_range = iwl_dump_ini_dev_mem_iter,
},
[IWL_FW_INI_REGION_PERIPHERY_MAC] = {
.get_num_of_ranges = iwl_dump_ini_mem_ranges,
.get_size = iwl_dump_ini_mem_get_size,
.fill_mem_hdr = iwl_dump_ini_mem_fill_header,
.fill_range = iwl_dump_ini_prph_iter,
},
[IWL_FW_INI_REGION_PERIPHERY_PHY] = {},
[IWL_FW_INI_REGION_PERIPHERY_AUX] = {},
[IWL_FW_INI_REGION_DRAM_BUFFER] = {
.get_num_of_ranges = iwl_dump_ini_mon_dram_ranges,
.get_size = iwl_dump_ini_mon_dram_get_size,
.fill_mem_hdr = iwl_dump_ini_mon_dram_fill_header,
.fill_range = iwl_dump_ini_mon_dram_iter,
},
[IWL_FW_INI_REGION_DRAM_IMR] = {},
[IWL_FW_INI_REGION_INTERNAL_BUFFER] = {
.get_num_of_ranges = iwl_dump_ini_mem_ranges,
.get_size = iwl_dump_ini_mon_smem_get_size,
.fill_mem_hdr = iwl_dump_ini_mon_smem_fill_header,
.fill_range = iwl_dump_ini_dev_mem_iter,
},
[IWL_FW_INI_REGION_TXF] = {
.get_num_of_ranges = iwl_dump_ini_txf_ranges,
.get_size = iwl_dump_ini_txf_get_size,
.fill_mem_hdr = iwl_dump_ini_mem_fill_header,
.fill_range = iwl_dump_ini_txf_iter,
},
[IWL_FW_INI_REGION_RXF] = {
.get_num_of_ranges = iwl_dump_ini_rxf_ranges,
.get_size = iwl_dump_ini_rxf_get_size,
.fill_mem_hdr = iwl_dump_ini_mem_fill_header,
.fill_range = iwl_dump_ini_rxf_iter,
},
[IWL_FW_INI_REGION_PAGING] = {
.fill_mem_hdr = iwl_dump_ini_mem_fill_header,
.get_num_of_ranges = iwl_dump_ini_paging_ranges,
.get_size = iwl_dump_ini_paging_get_size,
.fill_range = iwl_dump_ini_paging_iter,
},
[IWL_FW_INI_REGION_CSR] = {
.get_num_of_ranges = iwl_dump_ini_mem_ranges,
.get_size = iwl_dump_ini_mem_get_size,
.fill_mem_hdr = iwl_dump_ini_mem_fill_header,
.fill_range = iwl_dump_ini_csr_iter,
},
[IWL_FW_INI_REGION_NOTIFICATION] = {},
[IWL_FW_INI_REGION_DHC] = {},
[IWL_FW_INI_REGION_LMAC_ERROR_TABLE] = {
.get_num_of_ranges = iwl_dump_ini_mem_ranges,
.get_size = iwl_dump_ini_mem_get_size,
.fill_mem_hdr = iwl_dump_ini_mem_fill_header,
.fill_range = iwl_dump_ini_dev_mem_iter,
},
[IWL_FW_INI_REGION_UMAC_ERROR_TABLE] = {
.get_num_of_ranges = iwl_dump_ini_mem_ranges,
.get_size = iwl_dump_ini_mem_get_size,
.fill_mem_hdr = iwl_dump_ini_mem_fill_header,
.fill_range = iwl_dump_ini_dev_mem_iter,
},
};
static u32 iwl_dump_ini_trigger(struct iwl_fw_runtime *fwrt, static u32 iwl_dump_ini_trigger(struct iwl_fw_runtime *fwrt,
struct iwl_fw_ini_trigger *trigger, struct iwl_fw_ini_trigger *trigger,
struct list_head *list) struct list_head *list)
...@@ -1797,9 +1866,8 @@ static u32 iwl_dump_ini_trigger(struct iwl_fw_runtime *fwrt, ...@@ -1797,9 +1866,8 @@ static u32 iwl_dump_ini_trigger(struct iwl_fw_runtime *fwrt,
u32 size = 0; u32 size = 0;
for (i = 0; i < le32_to_cpu(trigger->num_regions); i++) { for (i = 0; i < le32_to_cpu(trigger->num_regions); i++) {
u32 reg_id = le32_to_cpu(trigger->data[i]); u32 reg_id = le32_to_cpu(trigger->data[i]), reg_type;
struct iwl_fw_ini_region_cfg *reg; struct iwl_fw_ini_region_cfg *reg;
struct iwl_dump_ini_mem_ops ops;
if (WARN_ON(reg_id >= ARRAY_SIZE(fwrt->dump.active_regs))) if (WARN_ON(reg_id >= ARRAY_SIZE(fwrt->dump.active_regs)))
continue; continue;
...@@ -1816,72 +1884,12 @@ static u32 iwl_dump_ini_trigger(struct iwl_fw_runtime *fwrt, ...@@ -1816,72 +1884,12 @@ static u32 iwl_dump_ini_trigger(struct iwl_fw_runtime *fwrt,
if (le32_to_cpu(reg->domain) != IWL_FW_INI_DBG_DOMAIN_ALWAYS_ON) if (le32_to_cpu(reg->domain) != IWL_FW_INI_DBG_DOMAIN_ALWAYS_ON)
continue; continue;
switch (le32_to_cpu(reg->region_type)) { reg_type = le32_to_cpu(reg->region_type);
case IWL_FW_INI_REGION_DEVICE_MEMORY: if (reg_type >= ARRAY_SIZE(iwl_dump_ini_region_ops))
case IWL_FW_INI_REGION_LMAC_ERROR_TABLE: continue;
case IWL_FW_INI_REGION_UMAC_ERROR_TABLE:
ops.get_num_of_ranges = iwl_dump_ini_mem_ranges; size += iwl_dump_ini_mem(fwrt, list, reg,
ops.get_size = iwl_dump_ini_mem_get_size; &iwl_dump_ini_region_ops[reg_type]);
ops.fill_mem_hdr = iwl_dump_ini_mem_fill_header;
ops.fill_range = iwl_dump_ini_dev_mem_iter;
size += iwl_dump_ini_mem(fwrt, list, reg, &ops);
break;
case IWL_FW_INI_REGION_PERIPHERY_MAC:
ops.get_num_of_ranges = iwl_dump_ini_mem_ranges;
ops.get_size = iwl_dump_ini_mem_get_size;
ops.fill_mem_hdr = iwl_dump_ini_mem_fill_header;
ops.fill_range = iwl_dump_ini_prph_iter;
size += iwl_dump_ini_mem(fwrt, list, reg, &ops);
break;
case IWL_FW_INI_REGION_DRAM_BUFFER:
ops.get_num_of_ranges = iwl_dump_ini_mon_dram_ranges;
ops.get_size = iwl_dump_ini_mon_dram_get_size;
ops.fill_mem_hdr = iwl_dump_ini_mon_dram_fill_header;
ops.fill_range = iwl_dump_ini_mon_dram_iter;
size += iwl_dump_ini_mem(fwrt, list, reg, &ops);
break;
case IWL_FW_INI_REGION_INTERNAL_BUFFER:
ops.get_num_of_ranges = iwl_dump_ini_mem_ranges;
ops.get_size = iwl_dump_ini_mon_smem_get_size;
ops.fill_mem_hdr = iwl_dump_ini_mon_smem_fill_header;
ops.fill_range = iwl_dump_ini_dev_mem_iter;
size += iwl_dump_ini_mem(fwrt, list, reg, &ops);
break;
case IWL_FW_INI_REGION_PAGING:
ops.fill_mem_hdr = iwl_dump_ini_mem_fill_header;
ops.get_num_of_ranges = iwl_dump_ini_paging_ranges;
ops.get_size = iwl_dump_ini_paging_get_size;
ops.fill_range = iwl_dump_ini_paging_iter;
size += iwl_dump_ini_mem(fwrt, list, reg, &ops);
break;
case IWL_FW_INI_REGION_TXF:
ops.get_num_of_ranges = iwl_dump_ini_txf_ranges;
ops.get_size = iwl_dump_ini_txf_get_size;
ops.fill_mem_hdr = iwl_dump_ini_mem_fill_header;
ops.fill_range = iwl_dump_ini_txf_iter;
size += iwl_dump_ini_mem(fwrt, list, reg, &ops);
break;
case IWL_FW_INI_REGION_RXF:
ops.get_num_of_ranges = iwl_dump_ini_rxf_ranges;
ops.get_size = iwl_dump_ini_rxf_get_size;
ops.fill_mem_hdr = iwl_dump_ini_mem_fill_header;
ops.fill_range = iwl_dump_ini_rxf_iter;
size += iwl_dump_ini_mem(fwrt, list, reg, &ops);
break;
case IWL_FW_INI_REGION_CSR:
ops.get_num_of_ranges = iwl_dump_ini_mem_ranges;
ops.get_size = iwl_dump_ini_mem_get_size;
ops.fill_mem_hdr = iwl_dump_ini_mem_fill_header;
ops.fill_range = iwl_dump_ini_csr_iter;
size += iwl_dump_ini_mem(fwrt, list, reg, &ops);
break;
case IWL_FW_INI_REGION_PERIPHERY_PHY:
case IWL_FW_INI_REGION_PERIPHERY_AUX:
case IWL_FW_INI_REGION_DRAM_IMR:
/* This is undefined yet */
default:
break;
}
} }
if (size) if (size)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment