iwlwifi: yoyo: support region TLV version 2
authorMukesh Sisodiya <mukesh.sisodiya@intel.com>
Sat, 12 Jun 2021 11:32:45 +0000 (14:32 +0300)
committerLuca Coelho <luciano.coelho@intel.com>
Tue, 22 Jun 2021 12:11:23 +0000 (15:11 +0300)
Region TLV version 2 now includes more data, but it is not
relevant for the driver.
In order to support this new version, just mask the new part out.

Signed-off-by: Mukesh Sisodiya <mukesh.sisodiya@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20210612142637.60dd4c60ab49.I44fe02af389d3ab089363bf9bde0d99a4c1ff383@changeid
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/iwl-dbg-tlv.c

index 996d5cc..5a2d9a1 100644 (file)
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
 /*
- * Copyright (C) 2018-2020 Intel Corporation
+ * Copyright (C) 2018-2021 Intel Corporation
  */
 #ifndef __iwl_fw_dbg_tlv_h__
 #define __iwl_fw_dbg_tlv_h__
@@ -11,6 +11,7 @@
 #define IWL_FW_INI_MAX_NAME                    32
 #define IWL_FW_INI_MAX_CFG_NAME                        64
 #define IWL_FW_INI_DOMAIN_ALWAYS_ON            0
+#define IWL_FW_INI_REGION_V2_MASK              0x0000FFFF
 
 /**
  * struct iwl_fw_ini_hcmd
index cc4e18c..5a534d7 100644 (file)
@@ -1933,6 +1933,13 @@ static u32 iwl_dump_ini_mem(struct iwl_fw_runtime *fwrt, struct list_head *list,
        u32 num_of_ranges, i, size;
        void *range;
 
+       /*
+        * The higher part of the ID in version 2 is irrelevant for
+        * us, so mask it out.
+        */
+       if (le32_to_cpu(reg->hdr.version) == 2)
+               id &= IWL_FW_INI_REGION_V2_MASK;
+
        if (!ops->get_num_of_ranges || !ops->get_size || !ops->fill_mem_hdr ||
            !ops->fill_range)
                return 0;
@@ -1957,7 +1964,7 @@ static u32 iwl_dump_ini_mem(struct iwl_fw_runtime *fwrt, struct list_head *list,
        num_of_ranges = ops->get_num_of_ranges(fwrt, reg_data);
 
        header = (void *)tlv->data;
-       header->region_id = reg->id;
+       header->region_id = cpu_to_le32(id);
        header->num_of_ranges = cpu_to_le32(num_of_ranges);
        header->name_len = cpu_to_le32(IWL_FW_INI_MAX_NAME);
        memcpy(header->name, reg->name, IWL_FW_INI_MAX_NAME);
index 4cd8c39..0ddd255 100644 (file)
@@ -57,7 +57,7 @@ dbg_ver_table[IWL_DBG_TLV_TYPE_NUM] = {
        [IWL_DBG_TLV_TYPE_DEBUG_INFO]   = {.min_ver = 1, .max_ver = 1,},
        [IWL_DBG_TLV_TYPE_BUF_ALLOC]    = {.min_ver = 1, .max_ver = 1,},
        [IWL_DBG_TLV_TYPE_HCMD]         = {.min_ver = 1, .max_ver = 1,},
-       [IWL_DBG_TLV_TYPE_REGION]       = {.min_ver = 1, .max_ver = 1,},
+       [IWL_DBG_TLV_TYPE_REGION]       = {.min_ver = 1, .max_ver = 2,},
        [IWL_DBG_TLV_TYPE_TRIGGER]      = {.min_ver = 1, .max_ver = 1,},
 };
 
@@ -178,9 +178,20 @@ static int iwl_dbg_tlv_alloc_region(struct iwl_trans *trans,
        u32 type = le32_to_cpu(reg->type);
        u32 tlv_len = sizeof(*tlv) + le32_to_cpu(tlv->length);
 
+       /*
+        * The higher part of the ID in version 2 is irrelevant for
+        * us, so mask it out.
+        */
+       if (le32_to_cpu(reg->hdr.version) == 2)
+               id &= IWL_FW_INI_REGION_V2_MASK;
+
        if (le32_to_cpu(tlv->length) < sizeof(*reg))
                return -EINVAL;
 
+       /* for safe use of a string from FW, limit it to IWL_FW_INI_MAX_NAME */
+       IWL_DEBUG_FW(trans, "WRT: parsing region: %.*s\n",
+                    IWL_FW_INI_MAX_NAME, reg->name);
+
        if (id >= IWL_FW_INI_MAX_REGION_ID) {
                IWL_ERR(trans, "WRT: Invalid region id %u\n", id);
                return -EINVAL;