iwlwifi: dbg_ini: differentiate ax210 hw with same hw type
authorLiad Kaufman <liad.kaufman@intel.com>
Sat, 25 Apr 2020 10:04:59 +0000 (13:04 +0300)
committerLuca Coelho <luciano.coelho@intel.com>
Fri, 8 May 2020 06:53:12 +0000 (09:53 +0300)
There are several "flavors" of HW that have the same HW type, but
can be told apart after reading a certain perph register. This
is easy to do in runtime, but more complicated to do when looking
at the logs offline.

To make it easier to tell apart these "flavors" when looking at
the dumped dbg info, add these bits to the HW type, allowing
simple differentiation.

Signed-off-by: Liad Kaufman <liad.kaufman@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20200425130140.330ea11d17ae.Ie59b25430a308090b15112ac6deedf4fbf487ff1@changeid
drivers/net/wireless/intel/iwlwifi/fw/dbg.c
drivers/net/wireless/intel/iwlwifi/fw/error-dump.h

index 2a271aa..4d3687c 100644 (file)
@@ -1958,6 +1958,7 @@ static u32 iwl_dump_ini_info(struct iwl_fw_runtime *fwrt,
        struct iwl_fw_ini_dump_cfg_name *cfg_name;
        u32 size = sizeof(*tlv) + sizeof(*dump);
        u32 num_of_cfg_names = 0;
+       u32 hw_type;
 
        list_for_each_entry(node, &fwrt->trans->dbg.debug_info_tlv_list, list) {
                size += sizeof(*cfg_name);
@@ -1986,7 +1987,26 @@ static u32 iwl_dump_ini_info(struct iwl_fw_runtime *fwrt,
        dump->ver_subtype = cpu_to_le32(fwrt->dump.fw_ver.subtype);
 
        dump->hw_step = cpu_to_le32(CSR_HW_REV_STEP(fwrt->trans->hw_rev));
-       dump->hw_type = cpu_to_le32(CSR_HW_REV_TYPE(fwrt->trans->hw_rev));
+
+       /*
+        * Several HWs all have type == 0x42, so we'll override this value
+        * according to the detected HW
+        */
+       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 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);
+
+               /*
+                * The HW type depends on certain bits in this case, so add
+                * these bits to the HW type. We won't have collisions since we
+                * add these bits after the highest possible bit in the mask.
+                */
+               hw_type |= masked_bits << IWL_AX210_HW_TYPE_ADDITION_SHIFT;
+       }
+       dump->hw_type = cpu_to_le32(hw_type);
 
        dump->rf_id_flavor =
                cpu_to_le32(CSR_HW_RFID_FLAVOR(fwrt->trans->hw_rf_id));
index f008e1b..72bfc64 100644 (file)
@@ -8,7 +8,7 @@
  * Copyright(c) 2014 Intel Corporation. All rights reserved.
  * Copyright(c) 2014 - 2015 Intel Mobile Communications GmbH
  * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
- * Copyright (C) 2018 - 2019 Intel Corporation
+ * Copyright (C) 2018 - 2020 Intel Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of version 2 of the GNU General Public License as
@@ -31,7 +31,7 @@
  * Copyright(c) 2014 Intel Corporation. All rights reserved.
  * Copyright(c) 2014 - 2015 Intel Mobile Communications GmbH
  * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
- * Copyright (C) 2018 - 2019 Intel Corporation
+ * Copyright (C) 2018 - 2020 Intel Corporation
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -394,6 +394,15 @@ struct iwl_fw_ini_dump_cfg_name {
        u8 cfg_name[IWL_FW_INI_MAX_CFG_NAME];
 } __packed;
 
+/* AX210's HW type */
+#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
  * @time_point: time point that caused the dump collection