iwlwifi: dbg_ini: support debug info TLV
authorShahar S Matityahu <shahar.s.matityahu@intel.com>
Thu, 18 Apr 2019 07:15:19 +0000 (10:15 +0300)
committerLuca Coelho <luciano.coelho@intel.com>
Sat, 29 Jun 2019 07:08:06 +0000 (10:08 +0300)
Add support to debug info TLV.
The TLV contains human readable naming of the FW image and the
debug configuration.

Signed-off-by: Shahar S Matityahu <shahar.s.matityahu@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
drivers/net/wireless/intel/iwlwifi/fw/api/dbg-tlv.h
drivers/net/wireless/intel/iwlwifi/fw/dbg.c
drivers/net/wireless/intel/iwlwifi/fw/file.h
drivers/net/wireless/intel/iwlwifi/fw/runtime.h
drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c
drivers/net/wireless/intel/iwlwifi/iwl-drv.c

index f4202bc..aaf3974 100644 (file)
@@ -291,6 +291,28 @@ struct iwl_fw_ini_trigger_tlv {
        struct iwl_fw_ini_trigger trigger_config[];
 } __packed; /* FW_TLV_DEBUG_TRIGGERS_API_S_VER_1 */
 
+#define IWL_FW_INI_MAX_IMG_NAME_LEN 32
+#define IWL_FW_INI_MAX_DBG_CFG_NAME_LEN 64
+
+/**
+ * struct iwl_fw_ini_debug_info_tlv - (IWL_UCODE_TLV_TYPE_DEBUG_INFO)
+ *
+ * holds image name and debug configuration name
+ *
+ * @header: header
+ * @img_name_len: length of the image name string
+ * @img_name: image name string
+ * @dbg_cfg_name_len : length of the debug configuration name string
+ * @dbg_cfg_name: debug configuration name string
+ */
+struct iwl_fw_ini_debug_info_tlv {
+       struct iwl_fw_ini_header header;
+       __le32 img_name_len;
+       u8 img_name[IWL_FW_INI_MAX_IMG_NAME_LEN];
+       __le32 dbg_cfg_name_len;
+       u8 dbg_cfg_name[IWL_FW_INI_MAX_DBG_CFG_NAME_LEN];
+} __packed; /* FW_DEBUG_TLV_INFO_API_S_VER_1 */
+
 /**
  * enum iwl_fw_ini_trigger_id
  *
index f2fb259..935905e 100644 (file)
@@ -2373,6 +2373,38 @@ void iwl_fw_dbg_read_d3_debug_data(struct iwl_fw_runtime *fwrt)
 }
 IWL_EXPORT_SYMBOL(iwl_fw_dbg_read_d3_debug_data);
 
+static void iwl_fw_dbg_info_apply(struct iwl_fw_runtime *fwrt,
+                                 struct iwl_fw_ini_debug_info_tlv *dbg_info,
+                                 bool ext, enum iwl_fw_ini_apply_point pnt)
+{
+       u32 img_name_len = le32_to_cpu(dbg_info->img_name_len);
+       u32 dbg_cfg_name_len = le32_to_cpu(dbg_info->dbg_cfg_name_len);
+       const char err_str[] =
+               "WRT: ext=%d. Invalid %s name length %d, expected %d\n";
+
+       if (img_name_len != IWL_FW_INI_MAX_IMG_NAME_LEN) {
+               IWL_WARN(fwrt, err_str, ext, "image", img_name_len,
+                        IWL_FW_INI_MAX_IMG_NAME_LEN);
+               return;
+       }
+
+       if (dbg_cfg_name_len != IWL_FW_INI_MAX_DBG_CFG_NAME_LEN) {
+               IWL_WARN(fwrt, err_str, ext, "debug cfg", dbg_cfg_name_len,
+                        IWL_FW_INI_MAX_DBG_CFG_NAME_LEN);
+               return;
+       }
+
+       if (ext) {
+               memcpy(fwrt->dump.external_dbg_cfg_name, dbg_info->dbg_cfg_name,
+                      sizeof(fwrt->dump.external_dbg_cfg_name));
+       } else {
+               memcpy(fwrt->dump.img_name, dbg_info->img_name,
+                      sizeof(fwrt->dump.img_name));
+               memcpy(fwrt->dump.internal_dbg_cfg_name, dbg_info->dbg_cfg_name,
+                      sizeof(fwrt->dump.internal_dbg_cfg_name));
+       }
+}
+
 static void
 iwl_fw_dbg_buffer_allocation(struct iwl_fw_runtime *fwrt, u32 size)
 {
@@ -2679,6 +2711,9 @@ static void _iwl_fw_dbg_apply_point(struct iwl_fw_runtime *fwrt,
                u32 type = le32_to_cpu(tlv->type);
 
                switch (type) {
+               case IWL_UCODE_TLV_TYPE_DEBUG_INFO:
+                       iwl_fw_dbg_info_apply(fwrt, ini_tlv, ext, pnt);
+                       break;
                case IWL_UCODE_TLV_TYPE_BUFFER_ALLOCATION: {
                        struct iwl_fw_ini_allocation_data *buf_alloc = ini_tlv;
 
@@ -2714,22 +2749,34 @@ next:
        }
 }
 
+static void iwl_fw_dbg_ini_reset_cfg(struct iwl_fw_runtime *fwrt)
+{
+       int i;
+
+       for (i = 0; i < IWL_FW_INI_MAX_REGION_ID; i++)
+               fwrt->dump.active_regs[i] = NULL;
+
+       /* disable the triggers, used in recovery flow */
+       for (i = 0; i < IWL_FW_TRIGGER_ID_NUM; i++)
+               fwrt->dump.active_trigs[i].active = false;
+
+       memset(fwrt->dump.img_name, 0,
+              sizeof(fwrt->dump.img_name));
+       memset(fwrt->dump.internal_dbg_cfg_name, 0,
+              sizeof(fwrt->dump.internal_dbg_cfg_name));
+       memset(fwrt->dump.external_dbg_cfg_name, 0,
+              sizeof(fwrt->dump.external_dbg_cfg_name));
+}
+
 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];
-       int i;
 
        IWL_DEBUG_FW(fwrt, "WRT: enabling apply point %d\n", apply_point);
 
-       if (apply_point == IWL_FW_INI_APPLY_EARLY) {
-               for (i = 0; i < IWL_FW_INI_MAX_REGION_ID; i++)
-                       fwrt->dump.active_regs[i] = NULL;
-
-               /* disable the triggers, used in recovery flow */
-               for (i = 0; i < IWL_FW_TRIGGER_ID_NUM; i++)
-                       fwrt->dump.active_trigs[i].active = false;
-       }
+       if (apply_point == IWL_FW_INI_APPLY_EARLY)
+               iwl_fw_dbg_ini_reset_cfg(fwrt);
 
        _iwl_fw_dbg_apply_point(fwrt, data, apply_point, false);
 
index de9243d..71438c4 100644 (file)
@@ -151,12 +151,13 @@ enum iwl_ucode_tlv_type {
        IWL_UCODE_TLV_FW_RECOVERY_INFO  = 57,
        IWL_UCODE_TLV_FW_FSEQ_VERSION   = 60,
 
-       IWL_UCODE_TLV_TYPE_BUFFER_ALLOCATION    = IWL_UCODE_INI_TLV_GROUP + 0x1,
-       IWL_UCODE_TLV_DEBUG_BASE = IWL_UCODE_TLV_TYPE_BUFFER_ALLOCATION,
-       IWL_UCODE_TLV_TYPE_HCMD                 = IWL_UCODE_INI_TLV_GROUP + 0x2,
-       IWL_UCODE_TLV_TYPE_REGIONS              = IWL_UCODE_INI_TLV_GROUP + 0x3,
-       IWL_UCODE_TLV_TYPE_TRIGGERS             = IWL_UCODE_INI_TLV_GROUP + 0x4,
-       IWL_UCODE_TLV_TYPE_DEBUG_FLOW           = IWL_UCODE_INI_TLV_GROUP + 0x5,
+       IWL_UCODE_TLV_DEBUG_BASE                = IWL_UCODE_INI_TLV_GROUP,
+       IWL_UCODE_TLV_TYPE_DEBUG_INFO           = IWL_UCODE_TLV_DEBUG_BASE + 0,
+       IWL_UCODE_TLV_TYPE_BUFFER_ALLOCATION    = IWL_UCODE_TLV_DEBUG_BASE + 1,
+       IWL_UCODE_TLV_TYPE_HCMD                 = IWL_UCODE_TLV_DEBUG_BASE + 2,
+       IWL_UCODE_TLV_TYPE_REGIONS              = IWL_UCODE_TLV_DEBUG_BASE + 3,
+       IWL_UCODE_TLV_TYPE_TRIGGERS             = IWL_UCODE_TLV_DEBUG_BASE + 4,
+       IWL_UCODE_TLV_TYPE_DEBUG_FLOW           = IWL_UCODE_TLV_DEBUG_BASE + 5,
        IWL_UCODE_TLV_DEBUG_MAX = IWL_UCODE_TLV_TYPE_DEBUG_FLOW,
 
        /* TLVs 0x1000-0x2000 are for internal driver usage */
index e351ac7..07196a9 100644 (file)
@@ -146,6 +146,10 @@ struct iwl_fw_runtime {
                u32 umac_err_id;
                void *fifo_iter;
                struct timer_list periodic_trig;
+
+               u8 img_name[IWL_FW_INI_MAX_IMG_NAME_LEN];
+               u8 internal_dbg_cfg_name[IWL_FW_INI_MAX_DBG_CFG_NAME_LEN];
+               u8 external_dbg_cfg_name[IWL_FW_INI_MAX_DBG_CFG_NAME_LEN];
        } dump;
 #ifdef CONFIG_IWLWIFI_DEBUGFS
        struct {
index ba66f7f..fcc1c5c 100644 (file)
@@ -221,6 +221,7 @@ static int iwl_parse_fw_dbg_tlv(struct iwl_trans *trans, const u8 *data,
                data += sizeof(*tlv) + ALIGN(tlv_len, 4);
 
                switch (tlv_type) {
+               case IWL_UCODE_TLV_TYPE_DEBUG_INFO:
                case IWL_UCODE_TLV_TYPE_BUFFER_ALLOCATION:
                case IWL_UCODE_TLV_TYPE_HCMD:
                case IWL_UCODE_TLV_TYPE_REGIONS:
index fba2422..4d6249b 100644 (file)
@@ -1137,6 +1137,7 @@ static int iwl_parse_tlv_firmware(struct iwl_drv *drv,
                                IWL_ERROR_EVENT_TABLE_LMAC1;
                        break;
                        }
+               case IWL_UCODE_TLV_TYPE_DEBUG_INFO:
                case IWL_UCODE_TLV_TYPE_BUFFER_ALLOCATION:
                case IWL_UCODE_TLV_TYPE_HCMD:
                case IWL_UCODE_TLV_TYPE_REGIONS: