Skip to content

Commit 5f46566

Browse files
panjaneyjmberg-intel
authored andcommitted
wifi: iwlwifi: extend TAS_CONFIG cmd support for v5
Extend TAS_CONFIG to send exact data read from bios to firmware without filtering/altering bios data. This enables driver becoming purely a pipe for TAS features. Signed-off-by: Anjaneyulu <[email protected]> Signed-off-by: Miri Korenblit <[email protected]> Link: https://patch.msgid.link/20241231135726.f46d58e7cfd1.Ifd81e632fa3e7039b8d139ee0d1c24e09669dff5@changeid Signed-off-by: Johannes Berg <[email protected]>
1 parent d1f9e5e commit 5f46566

File tree

6 files changed

+169
-101
lines changed

6 files changed

+169
-101
lines changed

drivers/net/wireless/intel/iwlwifi/fw/acpi.c

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -262,13 +262,14 @@ int iwl_acpi_get_tas_table(struct iwl_fw_runtime *fwrt,
262262
struct iwl_tas_data *tas_data)
263263
{
264264
union acpi_object *wifi_pkg, *data;
265-
int ret, tbl_rev, i, block_list_size, enabled;
265+
int ret, tbl_rev, block_list_size, enabled;
266+
u32 tas_selection;
266267

267268
data = iwl_acpi_get_object(fwrt->dev, ACPI_WTAS_METHOD);
268269
if (IS_ERR(data))
269270
return PTR_ERR(data);
270271

271-
/* try to read wtas table revision 1 or revision 0*/
272+
/* try to read wtas table */
272273
wifi_pkg = iwl_acpi_get_wifi_pkg(fwrt->dev, data,
273274
ACPI_WTAS_WIFI_DATA_SIZE,
274275
&tbl_rev);
@@ -277,27 +278,23 @@ int iwl_acpi_get_tas_table(struct iwl_fw_runtime *fwrt,
277278
goto out_free;
278279
}
279280

280-
if ((tbl_rev == 2 || tbl_rev == 1) &&
281-
wifi_pkg->package.elements[1].type == ACPI_TYPE_INTEGER) {
282-
u32 tas_selection =
283-
(u32)wifi_pkg->package.elements[1].integer.value;
284-
285-
enabled = iwl_parse_tas_selection(fwrt, tas_data,
286-
tas_selection, tbl_rev);
287-
288-
} else if (tbl_rev == 0 &&
289-
wifi_pkg->package.elements[1].type == ACPI_TYPE_INTEGER) {
290-
enabled = !!wifi_pkg->package.elements[1].integer.value;
291-
} else {
281+
if (tbl_rev < 0 || tbl_rev > 2 ||
282+
wifi_pkg->package.elements[1].type != ACPI_TYPE_INTEGER) {
292283
ret = -EINVAL;
293284
goto out_free;
294285
}
295286

296-
if (!enabled) {
297-
IWL_DEBUG_RADIO(fwrt, "TAS not enabled\n");
298-
ret = 0;
299-
goto out_free;
300-
}
287+
tas_selection = (u32)wifi_pkg->package.elements[1].integer.value;
288+
enabled = tas_selection & IWL_WTAS_ENABLED_MSK;
289+
290+
IWL_DEBUG_RADIO(fwrt, "TAS selection as read from BIOS: 0x%x\n",
291+
tas_selection);
292+
tas_data->table_source = BIOS_SOURCE_ACPI;
293+
tas_data->table_revision = tbl_rev;
294+
tas_data->tas_selection = tas_selection;
295+
296+
IWL_DEBUG_RADIO(fwrt, "TAS %s enabled\n",
297+
enabled ? "is" : "not");
301298

302299
IWL_DEBUG_RADIO(fwrt, "Reading TAS table revision %d\n", tbl_rev);
303300
if (wifi_pkg->package.elements[2].type != ACPI_TYPE_INTEGER ||
@@ -308,13 +305,14 @@ int iwl_acpi_get_tas_table(struct iwl_fw_runtime *fwrt,
308305
ret = -EINVAL;
309306
goto out_free;
310307
}
308+
311309
block_list_size = wifi_pkg->package.elements[2].integer.value;
312-
tas_data->block_list_size = cpu_to_le32(block_list_size);
310+
tas_data->block_list_size = block_list_size;
313311

314312
IWL_DEBUG_RADIO(fwrt, "TAS array size %u\n", block_list_size);
315313

316-
for (i = 0; i < block_list_size; i++) {
317-
u32 country;
314+
for (int i = 0; i < block_list_size; i++) {
315+
u16 country;
318316

319317
if (wifi_pkg->package.elements[3 + i].type !=
320318
ACPI_TYPE_INTEGER) {
@@ -325,11 +323,11 @@ int iwl_acpi_get_tas_table(struct iwl_fw_runtime *fwrt,
325323
}
326324

327325
country = wifi_pkg->package.elements[3 + i].integer.value;
328-
tas_data->block_list_array[i] = cpu_to_le32(country);
326+
tas_data->block_list_array[i] = country;
329327
IWL_DEBUG_RADIO(fwrt, "TAS block list country %d\n", country);
330328
}
331329

332-
ret = 1;
330+
ret = enabled;
333331
out_free:
334332
kfree(data);
335333
return ret;

drivers/net/wireless/intel/iwlwifi/fw/api/nvm-reg.h

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,14 +487,54 @@ struct iwl_tas_config_cmd_v4 {
487487
u8 uhb_allowed_flags;
488488
} __packed; /* TAS_CONFIG_CMD_API_S_VER_4 */
489489

490-
struct iwl_tas_config_cmd {
490+
struct iwl_tas_config_cmd_v2_v4 {
491491
struct iwl_tas_config_cmd_common common;
492492
union {
493493
struct iwl_tas_config_cmd_v3 v3;
494494
struct iwl_tas_config_cmd_v4 v4;
495495
};
496496
};
497497

498+
/**
499+
* enum bios_source - source of bios data
500+
* @BIOS_SOURCE_NONE: BIOS source is not defined
501+
* @BIOS_SOURCE_ACPI: BIOS source is ACPI
502+
* @BIOS_SOURCE_UEFI: BIOS source is UEFI
503+
*/
504+
enum bios_source {
505+
BIOS_SOURCE_NONE,
506+
BIOS_SOURCE_ACPI,
507+
BIOS_SOURCE_UEFI,
508+
};
509+
510+
/**
511+
* struct bios_value_u32 - BIOS configuration.
512+
* @table_source: see &enum bios_source
513+
* @table_revision: table revision.
514+
* @reserved: reserved
515+
* @value: value in bios.
516+
*/
517+
struct bios_value_u32 {
518+
u8 table_source;
519+
u8 table_revision;
520+
u8 reserved[2];
521+
__le32 value;
522+
} __packed; /* BIOS_TABLE_SOURCE_U32_S_VER_1 */
523+
524+
/**
525+
* struct iwl_tas_config_cmd - configures the TAS.
526+
* @block_list_size: size of relevant field in block_list_array
527+
* @block_list_array: list of countries where TAS must be disabled
528+
* @reserved: reserved
529+
* @tas_config_info: see @struct bios_value_u32
530+
*/
531+
struct iwl_tas_config_cmd {
532+
__le16 block_list_size;
533+
__le16 block_list_array[IWL_WTAS_BLACK_LIST_MAX];
534+
u8 reserved[2];
535+
struct bios_value_u32 tas_config_info;
536+
} __packed; /* TAS_CONFIG_CMD_API_S_VER_5 */
537+
498538
/**
499539
* enum iwl_lari_config_masks - bit masks for the various LARI config operations
500540
* @LARI_CONFIG_DISABLE_11AC_UKRAINE_MSK: disable 11ac in ukraine

drivers/net/wireless/intel/iwlwifi/fw/regulatory.c

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -430,30 +430,31 @@ bool iwl_is_tas_approved(void)
430430
}
431431
IWL_EXPORT_SYMBOL(iwl_is_tas_approved);
432432

433-
int iwl_parse_tas_selection(struct iwl_fw_runtime *fwrt,
434-
struct iwl_tas_data *tas_data,
435-
const u32 tas_selection, u8 tbl_rev)
433+
struct iwl_tas_selection_data
434+
iwl_parse_tas_selection(const u32 tas_selection_in, const u8 tbl_rev)
436435
{
437-
u8 override_iec = u32_get_bits(tas_selection,
436+
struct iwl_tas_selection_data tas_selection_out = {};
437+
u8 override_iec = u32_get_bits(tas_selection_in,
438438
IWL_WTAS_OVERRIDE_IEC_MSK);
439-
u8 canada_tas_uhb = u32_get_bits(tas_selection,
439+
u8 canada_tas_uhb = u32_get_bits(tas_selection_in,
440440
IWL_WTAS_CANADA_UHB_MSK);
441-
u8 enabled_iec = u32_get_bits(tas_selection, IWL_WTAS_ENABLE_IEC_MSK);
442-
u8 usa_tas_uhb = u32_get_bits(tas_selection, IWL_WTAS_USA_UHB_MSK);
443-
int enabled = tas_selection & IWL_WTAS_ENABLED_MSK;
444-
445-
IWL_DEBUG_RADIO(fwrt, "TAS selection as read from BIOS: 0x%x\n",
446-
tas_selection);
447-
448-
tas_data->usa_tas_uhb_allowed = usa_tas_uhb;
449-
tas_data->override_tas_iec = override_iec;
450-
tas_data->enable_tas_iec = enabled_iec;
441+
u8 enabled_iec = u32_get_bits(tas_selection_in,
442+
IWL_WTAS_ENABLE_IEC_MSK);
443+
u8 usa_tas_uhb = u32_get_bits(tas_selection_in,
444+
IWL_WTAS_USA_UHB_MSK);
445+
446+
if (tbl_rev > 0) {
447+
tas_selection_out.usa_tas_uhb_allowed = usa_tas_uhb;
448+
tas_selection_out.override_tas_iec = override_iec;
449+
tas_selection_out.enable_tas_iec = enabled_iec;
450+
}
451451

452452
if (tbl_rev > 1)
453-
tas_data->canada_tas_uhb_allowed = canada_tas_uhb;
453+
tas_selection_out.canada_tas_uhb_allowed = canada_tas_uhb;
454454

455-
return enabled;
455+
return tas_selection_out;
456456
}
457+
IWL_EXPORT_SYMBOL(iwl_parse_tas_selection);
457458

458459
static __le32 iwl_get_lari_config_bitmap(struct iwl_fw_runtime *fwrt)
459460
{

drivers/net/wireless/intel/iwlwifi/fw/regulatory.h

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,19 @@
4040
#define IWL_PPAG_ETSI_CHINA_MASK 3
4141
#define IWL_PPAG_REV3_MASK 0x7FF
4242

43-
#define IWL_WTAS_ENABLED_MSK 0x1
44-
#define IWL_WTAS_OVERRIDE_IEC_MSK 0x2
45-
#define IWL_WTAS_ENABLE_IEC_MSK 0x4
43+
#define IWL_WTAS_ENABLED_MSK BIT(0)
44+
#define IWL_WTAS_OVERRIDE_IEC_MSK BIT(1)
45+
#define IWL_WTAS_ENABLE_IEC_MSK BIT(2)
4646
#define IWL_WTAS_CANADA_UHB_MSK BIT(15)
4747
#define IWL_WTAS_USA_UHB_MSK BIT(16)
4848

49+
struct iwl_tas_selection_data {
50+
u8 override_tas_iec:1,
51+
enable_tas_iec:1,
52+
usa_tas_uhb_allowed:1,
53+
canada_tas_uhb_allowed:1;
54+
};
55+
4956
#define BIOS_MCC_CHINA 0x434e
5057

5158
/*
@@ -98,12 +105,11 @@ struct iwl_ppag_chain {
98105
};
99106

100107
struct iwl_tas_data {
101-
__le32 block_list_size;
102-
__le32 block_list_array[IWL_WTAS_BLACK_LIST_MAX];
103-
u8 override_tas_iec:1,
104-
enable_tas_iec:1,
105-
usa_tas_uhb_allowed:1,
106-
canada_tas_uhb_allowed:1;
108+
u8 block_list_size;
109+
u16 block_list_array[IWL_WTAS_BLACK_LIST_MAX];
110+
u8 table_source;
111+
u8 table_revision;
112+
u32 tas_selection;
107113
};
108114

109115
/* For DSM revision 0 and 4 */
@@ -185,9 +191,8 @@ bool iwl_is_ppag_approved(struct iwl_fw_runtime *fwrt);
185191

186192
bool iwl_is_tas_approved(void);
187193

188-
int iwl_parse_tas_selection(struct iwl_fw_runtime *fwrt,
189-
struct iwl_tas_data *tas_data,
190-
const u32 tas_selection, u8 tbl_rev);
194+
struct iwl_tas_selection_data
195+
iwl_parse_tas_selection(const u32 tas_selection, const u8 tbl_rev);
191196

192197
int iwl_bios_get_wrds_table(struct iwl_fw_runtime *fwrt);
193198

drivers/net/wireless/intel/iwlwifi/fw/uefi.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ int iwl_uefi_get_tas_table(struct iwl_fw_runtime *fwrt,
570570
struct iwl_tas_data *tas_data)
571571
{
572572
struct uefi_cnv_var_wtas *uefi_tas;
573-
int ret = 0, enabled, i;
573+
int ret, enabled;
574574

575575
uefi_tas = iwl_uefi_get_verified_variable(fwrt->trans, IWL_UEFI_WTAS_NAME,
576576
"WTAS", sizeof(*uefi_tas), NULL);
@@ -585,15 +585,16 @@ int iwl_uefi_get_tas_table(struct iwl_fw_runtime *fwrt,
585585
goto out;
586586
}
587587

588-
enabled = iwl_parse_tas_selection(fwrt, tas_data,
589-
uefi_tas->tas_selection,
590-
uefi_tas->revision);
588+
IWL_DEBUG_RADIO(fwrt, "TAS selection as read from BIOS: 0x%x\n",
589+
uefi_tas->tas_selection);
591590

592-
if (!enabled) {
593-
IWL_DEBUG_RADIO(fwrt, "TAS not enabled\n");
594-
ret = 0;
595-
goto out;
596-
}
591+
enabled = uefi_tas->tas_selection & IWL_WTAS_ENABLED_MSK;
592+
tas_data->table_source = BIOS_SOURCE_UEFI;
593+
tas_data->table_revision = uefi_tas->revision;
594+
tas_data->tas_selection = uefi_tas->tas_selection;
595+
596+
IWL_DEBUG_RADIO(fwrt, "TAS %s enabled\n",
597+
enabled ? "is" : "not");
597598

598599
IWL_DEBUG_RADIO(fwrt, "Reading TAS table revision %d\n",
599600
uefi_tas->revision);
@@ -603,15 +604,16 @@ int iwl_uefi_get_tas_table(struct iwl_fw_runtime *fwrt,
603604
ret = -EINVAL;
604605
goto out;
605606
}
606-
tas_data->block_list_size = cpu_to_le32(uefi_tas->black_list_size);
607+
608+
tas_data->block_list_size = uefi_tas->black_list_size;
607609
IWL_DEBUG_RADIO(fwrt, "TAS array size %u\n", uefi_tas->black_list_size);
608610

609-
for (i = 0; i < uefi_tas->black_list_size; i++) {
610-
tas_data->block_list_array[i] =
611-
cpu_to_le32(uefi_tas->black_list[i]);
611+
for (u8 i = 0; i < uefi_tas->black_list_size; i++) {
612+
tas_data->block_list_array[i] = uefi_tas->black_list[i];
612613
IWL_DEBUG_RADIO(fwrt, "TAS block list country %d\n",
613614
uefi_tas->black_list[i]);
614615
}
616+
ret = enabled;
615617
out:
616618
kfree(uefi_tas);
617619
return ret;

0 commit comments

Comments
 (0)