Commit 084e0452 authored by Miri Korenblit's avatar Miri Korenblit Committed by Johannes Berg

wifi: iwlwifi: read WTAS table from UEFI

Try to read the WTAS table from UEFI first,
and if the WIFI UEFI tables are unlocked or the
table doesn't exist - try to read it from ACPI.
Signed-off-by: default avatarMiri Korenblit <miriam.rachel.korenblit@intel.com>
Reviewed-by: default avatarGregory Greenman <gregory.greenman@intel.com>
Link: https://msgid.link/20240131091413.45e6ff7b5063.Id3aec70887e14533b10d564f32c0cf5f2a14b792@changeid
[move uefi_tables_lock_status outside ifdef to fix build errors]
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 3bc67e7c
...@@ -249,8 +249,7 @@ iwl_acpi_get_wifi_pkg(struct device *dev, ...@@ -249,8 +249,7 @@ iwl_acpi_get_wifi_pkg(struct device *dev,
tbl_rev); tbl_rev);
} }
int iwl_acpi_get_tas_table(struct iwl_fw_runtime *fwrt,
int iwl_acpi_get_tas(struct iwl_fw_runtime *fwrt,
struct iwl_tas_data *tas_data) struct iwl_tas_data *tas_data)
{ {
union acpi_object *wifi_pkg, *data; union acpi_object *wifi_pkg, *data;
...@@ -326,7 +325,6 @@ int iwl_acpi_get_tas(struct iwl_fw_runtime *fwrt, ...@@ -326,7 +325,6 @@ int iwl_acpi_get_tas(struct iwl_fw_runtime *fwrt,
kfree(data); kfree(data);
return ret; return ret;
} }
IWL_EXPORT_SYMBOL(iwl_acpi_get_tas);
int iwl_acpi_get_mcc(struct device *dev, char *mcc) int iwl_acpi_get_mcc(struct device *dev, char *mcc)
{ {
......
...@@ -175,7 +175,7 @@ int iwl_acpi_get_ewrd_table(struct iwl_fw_runtime *fwrt); ...@@ -175,7 +175,7 @@ int iwl_acpi_get_ewrd_table(struct iwl_fw_runtime *fwrt);
int iwl_acpi_get_wgds_table(struct iwl_fw_runtime *fwrt); int iwl_acpi_get_wgds_table(struct iwl_fw_runtime *fwrt);
int iwl_acpi_get_tas(struct iwl_fw_runtime *fwrt, int iwl_acpi_get_tas_table(struct iwl_fw_runtime *fwrt,
struct iwl_tas_data *data); struct iwl_tas_data *data);
__le32 iwl_acpi_get_lari_config_bitmap(struct iwl_fw_runtime *fwrt); __le32 iwl_acpi_get_lari_config_bitmap(struct iwl_fw_runtime *fwrt);
...@@ -237,7 +237,7 @@ static inline int iwl_acpi_get_wgds_table(struct iwl_fw_runtime *fwrt) ...@@ -237,7 +237,7 @@ static inline int iwl_acpi_get_wgds_table(struct iwl_fw_runtime *fwrt)
return 1; return 1;
} }
static inline int iwl_acpi_get_tas(struct iwl_fw_runtime *fwrt, static inline int iwl_acpi_get_tas_table(struct iwl_fw_runtime *fwrt,
struct iwl_tas_data *data) struct iwl_tas_data *data)
{ {
return -ENOENT; return -ENOENT;
......
...@@ -9,22 +9,32 @@ ...@@ -9,22 +9,32 @@
#include "fw/runtime.h" #include "fw/runtime.h"
#include "fw/uefi.h" #include "fw/uefi.h"
#define IWL_BIOS_TABLE_LOADER(__name) \ #define GET_BIOS_TABLE(__name, ...) \
int iwl_bios_get_ ## __name ## _table(struct iwl_fw_runtime *fwrt) \ do { \
{ \
int ret = -ENOENT; \ int ret = -ENOENT; \
if (fwrt->uefi_tables_lock_status > UEFI_WIFI_GUID_UNLOCKED) \ if (fwrt->uefi_tables_lock_status > UEFI_WIFI_GUID_UNLOCKED) \
ret = iwl_uefi_get_ ## __name ## _table(fwrt); \ ret = iwl_uefi_get_ ## __name(__VA_ARGS__); \
if (ret < 0) \ if (ret < 0) \
ret = iwl_acpi_get_ ## __name ## _table(fwrt); \ ret = iwl_acpi_get_ ## __name(__VA_ARGS__); \
return ret; \ return ret; \
} \ } while (0)
IWL_EXPORT_SYMBOL(iwl_bios_get_ ## __name ## _table)
IWL_BIOS_TABLE_LOADER(wrds); #define IWL_BIOS_TABLE_LOADER(__name) \
IWL_BIOS_TABLE_LOADER(ewrd); int iwl_bios_get_ ## __name(struct iwl_fw_runtime *fwrt) \
IWL_BIOS_TABLE_LOADER(wgds); {GET_BIOS_TABLE(__name, fwrt); } \
IWL_BIOS_TABLE_LOADER(ppag); IWL_EXPORT_SYMBOL(iwl_bios_get_ ## __name)
#define IWL_BIOS_TABLE_LOADER_DATA(__name, data_type) \
int iwl_bios_get_ ## __name(struct iwl_fw_runtime *fwrt, \
data_type * data) \
{GET_BIOS_TABLE(__name, fwrt, data); } \
IWL_EXPORT_SYMBOL(iwl_bios_get_ ## __name)
IWL_BIOS_TABLE_LOADER(wrds_table);
IWL_BIOS_TABLE_LOADER(ewrd_table);
IWL_BIOS_TABLE_LOADER(wgds_table);
IWL_BIOS_TABLE_LOADER(ppag_table);
IWL_BIOS_TABLE_LOADER_DATA(tas_table, struct iwl_tas_data);
static const struct dmi_system_id dmi_ppag_approved_list[] = { static const struct dmi_system_id dmi_ppag_approved_list[] = {
{ .ident = "HP", { .ident = "HP",
......
...@@ -133,4 +133,8 @@ int iwl_bios_get_ewrd_table(struct iwl_fw_runtime *fwrt); ...@@ -133,4 +133,8 @@ int iwl_bios_get_ewrd_table(struct iwl_fw_runtime *fwrt);
int iwl_bios_get_wgds_table(struct iwl_fw_runtime *fwrt); int iwl_bios_get_wgds_table(struct iwl_fw_runtime *fwrt);
int iwl_bios_get_ppag_table(struct iwl_fw_runtime *fwrt); int iwl_bios_get_ppag_table(struct iwl_fw_runtime *fwrt);
int iwl_bios_get_tas_table(struct iwl_fw_runtime *fwrt,
struct iwl_tas_data *data);
#endif /* __fw_regulatory_h__ */ #endif /* __fw_regulatory_h__ */
...@@ -179,8 +179,8 @@ struct iwl_fw_runtime { ...@@ -179,8 +179,8 @@ struct iwl_fw_runtime {
struct iwl_sar_offset_mapping_cmd sgom_table; struct iwl_sar_offset_mapping_cmd sgom_table;
bool sgom_enabled; bool sgom_enabled;
struct iwl_uats_table_cmd uats_table; struct iwl_uats_table_cmd uats_table;
u8 uefi_tables_lock_status;
#endif #endif
u8 uefi_tables_lock_status;
bool uats_enabled; bool uats_enabled;
}; };
......
...@@ -550,3 +550,51 @@ int iwl_uefi_get_ppag_table(struct iwl_fw_runtime *fwrt) ...@@ -550,3 +550,51 @@ int iwl_uefi_get_ppag_table(struct iwl_fw_runtime *fwrt)
kfree(data); kfree(data);
return ret; return ret;
} }
int iwl_uefi_get_tas_table(struct iwl_fw_runtime *fwrt,
struct iwl_tas_data *tas_data)
{
struct uefi_cnv_var_wtas *uefi_tas;
int ret = 0, enabled, i;
uefi_tas = iwl_uefi_get_verified_variable(fwrt->trans, IWL_UEFI_WTAS_NAME,
"WTAS", sizeof(*uefi_tas), NULL);
if (IS_ERR(uefi_tas))
return -EINVAL;
if (uefi_tas->revision != IWL_UEFI_WTAS_REVISION) {
ret = -EINVAL;
IWL_DEBUG_RADIO(fwrt, "Unsupported UEFI WTAS revision:%d\n",
uefi_tas->revision);
goto out;
}
enabled = iwl_parse_tas_selection(fwrt, tas_data,
uefi_tas->tas_selection);
if (!enabled) {
IWL_DEBUG_RADIO(fwrt, "TAS not enabled\n");
ret = 0;
goto out;
}
IWL_DEBUG_RADIO(fwrt, "Reading TAS table revision %d\n",
uefi_tas->revision);
if (uefi_tas->black_list_size > IWL_WTAS_BLACK_LIST_MAX) {
IWL_DEBUG_RADIO(fwrt, "TAS invalid array size %d\n",
uefi_tas->black_list_size);
ret = -EINVAL;
goto out;
}
tas_data->block_list_size = cpu_to_le32(uefi_tas->black_list_size);
IWL_DEBUG_RADIO(fwrt, "TAS array size %u\n", uefi_tas->black_list_size);
for (i = 0; i < uefi_tas->black_list_size; i++) {
tas_data->block_list_array[i] =
cpu_to_le32(uefi_tas->black_list[i]);
IWL_DEBUG_RADIO(fwrt, "TAS block list country %d\n",
uefi_tas->black_list[i]);
}
out:
kfree(uefi_tas);
return ret;
}
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#define IWL_UEFI_EWRD_NAME L"UefiCnvWlanEWRD" #define IWL_UEFI_EWRD_NAME L"UefiCnvWlanEWRD"
#define IWL_UEFI_WGDS_NAME L"UefiCnvWlanWGDS" #define IWL_UEFI_WGDS_NAME L"UefiCnvWlanWGDS"
#define IWL_UEFI_PPAG_NAME L"UefiCnvWlanPPAG" #define IWL_UEFI_PPAG_NAME L"UefiCnvWlanPPAG"
#define IWL_UEFI_WTAS_NAME L"UefiCnvWlanWTAS"
#define IWL_SGOM_MAP_SIZE 339 #define IWL_SGOM_MAP_SIZE 339
#define IWL_UATS_MAP_SIZE 339 #define IWL_UATS_MAP_SIZE 339
...@@ -25,6 +26,7 @@ ...@@ -25,6 +26,7 @@
#define IWL_UEFI_WGDS_REVISION 3 #define IWL_UEFI_WGDS_REVISION 3
#define IWL_UEFI_MIN_PPAG_REV 1 #define IWL_UEFI_MIN_PPAG_REV 1
#define IWL_UEFI_MAX_PPAG_REV 3 #define IWL_UEFI_MAX_PPAG_REV 3
#define IWL_UEFI_WTAS_REVISION 1
struct pnvm_sku_package { struct pnvm_sku_package {
u8 rev; u8 rev;
...@@ -115,6 +117,19 @@ struct uefi_cnv_var_ppag { ...@@ -115,6 +117,19 @@ struct uefi_cnv_var_ppag {
struct iwl_ppag_chain ppag_chains[IWL_NUM_CHAIN_LIMITS]; struct iwl_ppag_chain ppag_chains[IWL_NUM_CHAIN_LIMITS];
} __packed; } __packed;
/* struct uefi_cnv_var_wtas - WTAS tabled as defined in UEFI
* @revision: the revision of the table
* @tas_selection: different options of TAS enablement.
* @black_list_size: the number of defined entried in the black list
* @black_list: a list of countries that are not allowed to use the TAS feature
*/
struct uefi_cnv_var_wtas {
u8 revision;
u32 tas_selection;
u8 black_list_size;
u16 black_list[IWL_WTAS_BLACK_LIST_MAX];
} __packed;
/* /*
* This is known to be broken on v4.19 and to work on v5.4. Until we * This is known to be broken on v4.19 and to work on v5.4. Until we
* figure out why this is the case and how to make it work, simply * figure out why this is the case and how to make it work, simply
...@@ -133,6 +148,8 @@ int iwl_uefi_get_wrds_table(struct iwl_fw_runtime *fwrt); ...@@ -133,6 +148,8 @@ int iwl_uefi_get_wrds_table(struct iwl_fw_runtime *fwrt);
int iwl_uefi_get_ewrd_table(struct iwl_fw_runtime *fwrt); int iwl_uefi_get_ewrd_table(struct iwl_fw_runtime *fwrt);
int iwl_uefi_get_wgds_table(struct iwl_fw_runtime *fwrt); int iwl_uefi_get_wgds_table(struct iwl_fw_runtime *fwrt);
int iwl_uefi_get_ppag_table(struct iwl_fw_runtime *fwrt); int iwl_uefi_get_ppag_table(struct iwl_fw_runtime *fwrt);
int iwl_uefi_get_tas_table(struct iwl_fw_runtime *fwrt,
struct iwl_tas_data *data);
#else /* CONFIG_EFI */ #else /* CONFIG_EFI */
static inline void *iwl_uefi_get_pnvm(struct iwl_trans *trans, size_t *len) static inline void *iwl_uefi_get_pnvm(struct iwl_trans *trans, size_t *len)
{ {
...@@ -183,6 +200,12 @@ static inline int iwl_uefi_get_ppag_table(struct iwl_fw_runtime *fwrt) ...@@ -183,6 +200,12 @@ static inline int iwl_uefi_get_ppag_table(struct iwl_fw_runtime *fwrt)
{ {
return -ENOENT; return -ENOENT;
} }
static inline int iwl_uefi_get_tas_table(struct iwl_fw_runtime *fwrt,
struct iwl_tas_data *data)
{
return -ENOENT;
}
#endif /* CONFIG_EFI */ #endif /* CONFIG_EFI */
#if defined(CONFIG_EFI) && defined(CONFIG_ACPI) #if defined(CONFIG_EFI) && defined(CONFIG_ACPI)
......
...@@ -1108,10 +1108,6 @@ static int iwl_mvm_ppag_init(struct iwl_mvm *mvm) ...@@ -1108,10 +1108,6 @@ static int iwl_mvm_ppag_init(struct iwl_mvm *mvm)
return iwl_mvm_ppag_send_cmd(mvm); return iwl_mvm_ppag_send_cmd(mvm);
} }
#ifdef CONFIG_ACPI
static bool iwl_mvm_add_to_tas_block_list(__le32 *list, __le32 *le_size, unsigned int mcc) static bool iwl_mvm_add_to_tas_block_list(__le32 *list, __le32 *le_size, unsigned int mcc)
{ {
int i; int i;
...@@ -1149,7 +1145,7 @@ static void iwl_mvm_tas_init(struct iwl_mvm *mvm) ...@@ -1149,7 +1145,7 @@ static void iwl_mvm_tas_init(struct iwl_mvm *mvm)
return; return;
} }
ret = iwl_acpi_get_tas(&mvm->fwrt, &data); ret = iwl_bios_get_tas_table(&mvm->fwrt, &data);
if (ret < 0) { if (ret < 0) {
IWL_DEBUG_RADIO(mvm, IWL_DEBUG_RADIO(mvm,
"TAS table invalid or unavailable. (%d)\n", "TAS table invalid or unavailable. (%d)\n",
...@@ -1205,6 +1201,8 @@ static void iwl_mvm_tas_init(struct iwl_mvm *mvm) ...@@ -1205,6 +1201,8 @@ static void iwl_mvm_tas_init(struct iwl_mvm *mvm)
IWL_DEBUG_RADIO(mvm, "failed to send TAS_CONFIG (%d)\n", ret); IWL_DEBUG_RADIO(mvm, "failed to send TAS_CONFIG (%d)\n", ret);
} }
#ifdef CONFIG_ACPI
static u8 iwl_mvm_eval_dsm_rfi(struct iwl_mvm *mvm) static u8 iwl_mvm_eval_dsm_rfi(struct iwl_mvm *mvm)
{ {
u8 value; u8 value;
...@@ -1345,10 +1343,6 @@ static void iwl_mvm_lari_cfg(struct iwl_mvm *mvm) ...@@ -1345,10 +1343,6 @@ static void iwl_mvm_lari_cfg(struct iwl_mvm *mvm)
#else /* CONFIG_ACPI */ #else /* CONFIG_ACPI */
static void iwl_mvm_tas_init(struct iwl_mvm *mvm)
{
}
static void iwl_mvm_lari_cfg(struct iwl_mvm *mvm) static void iwl_mvm_lari_cfg(struct iwl_mvm *mvm)
{ {
} }
......
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