diff options
Diffstat (limited to 'drivers/net/wireless/intel/iwlwifi/fw')
17 files changed, 423 insertions, 111 deletions
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/acpi.c b/drivers/net/wireless/intel/iwlwifi/fw/acpi.c index d8b7776a8dde..82a4f7e8ba54 100644 --- a/drivers/net/wireless/intel/iwlwifi/fw/acpi.c +++ b/drivers/net/wireless/intel/iwlwifi/fw/acpi.c @@ -9,9 +9,15 @@ #include "acpi.h" #include "fw/runtime.h" -static const guid_t intel_wifi_guid = GUID_INIT(0xF21202BF, 0x8F78, 0x4DC6, - 0xA5, 0xB3, 0x1F, 0x73, - 0x8E, 0x28, 0x5A, 0xDE); +const guid_t iwl_guid = GUID_INIT(0xF21202BF, 0x8F78, 0x4DC6, + 0xA5, 0xB3, 0x1F, 0x73, + 0x8E, 0x28, 0x5A, 0xDE); +IWL_EXPORT_SYMBOL(iwl_guid); + +const guid_t iwl_rfi_guid = GUID_INIT(0x7266172C, 0x220B, 0x4B29, + 0x81, 0x4F, 0x75, 0xE4, + 0xDD, 0x26, 0xB5, 0xFD); +IWL_EXPORT_SYMBOL(iwl_rfi_guid); static int iwl_acpi_get_handle(struct device *dev, acpi_string method, acpi_handle *ret_handle) @@ -64,11 +70,12 @@ IWL_EXPORT_SYMBOL(iwl_acpi_get_object); * function. */ static void *iwl_acpi_get_dsm_object(struct device *dev, int rev, int func, - union acpi_object *args) + union acpi_object *args, + const guid_t *guid) { union acpi_object *obj; - obj = acpi_evaluate_dsm(ACPI_HANDLE(dev), &intel_wifi_guid, rev, func, + obj = acpi_evaluate_dsm(ACPI_HANDLE(dev), guid, rev, func, args); if (!obj) { IWL_DEBUG_DEV_RADIO(dev, @@ -87,12 +94,13 @@ static void *iwl_acpi_get_dsm_object(struct device *dev, int rev, int func, * return 0 in success and the appropriate errno otherwise. */ static int iwl_acpi_get_dsm_integer(struct device *dev, int rev, int func, - u64 *value, size_t expected_size) + const guid_t *guid, u64 *value, + size_t expected_size) { union acpi_object *obj; int ret = 0; - obj = iwl_acpi_get_dsm_object(dev, rev, func, NULL); + obj = iwl_acpi_get_dsm_object(dev, rev, func, NULL, guid); if (IS_ERR(obj)) { IWL_DEBUG_DEV_RADIO(dev, "Failed to get DSM object. func= %d\n", @@ -137,12 +145,14 @@ out: /* * Evaluate a DSM with no arguments and a u8 return value, */ -int iwl_acpi_get_dsm_u8(struct device *dev, int rev, int func, u8 *value) +int iwl_acpi_get_dsm_u8(struct device *dev, int rev, int func, + const guid_t *guid, u8 *value) { int ret; u64 val; - ret = iwl_acpi_get_dsm_integer(dev, rev, func, &val, sizeof(u8)); + ret = iwl_acpi_get_dsm_integer(dev, rev, func, + guid, &val, sizeof(u8)); if (ret < 0) return ret; @@ -478,11 +488,16 @@ int iwl_sar_get_wrds_table(struct iwl_fw_runtime *fwrt) wifi_pkg = iwl_acpi_get_wifi_pkg(fwrt->dev, data, ACPI_WRDS_WIFI_DATA_SIZE, &tbl_rev); - if (IS_ERR(wifi_pkg) || tbl_rev != 0) { + if (IS_ERR(wifi_pkg)) { ret = PTR_ERR(wifi_pkg); goto out_free; } + if (tbl_rev != 0) { + ret = -EINVAL; + goto out_free; + } + if (wifi_pkg->package.elements[1].type != ACPI_TYPE_INTEGER) { ret = -EINVAL; goto out_free; @@ -516,11 +531,16 @@ int iwl_sar_get_ewrd_table(struct iwl_fw_runtime *fwrt) wifi_pkg = iwl_acpi_get_wifi_pkg(fwrt->dev, data, ACPI_EWRD_WIFI_DATA_SIZE, &tbl_rev); - if (IS_ERR(wifi_pkg) || tbl_rev != 0) { + if (IS_ERR(wifi_pkg)) { ret = PTR_ERR(wifi_pkg); goto out_free; } + if (tbl_rev != 0) { + ret = -EINVAL; + goto out_free; + } + if (wifi_pkg->package.elements[1].type != ACPI_TYPE_INTEGER || wifi_pkg->package.elements[2].type != ACPI_TYPE_INTEGER) { ret = -EINVAL; @@ -576,11 +596,17 @@ int iwl_sar_get_wgds_table(struct iwl_fw_runtime *fwrt) wifi_pkg = iwl_acpi_get_wifi_pkg(fwrt->dev, data, ACPI_WGDS_WIFI_DATA_SIZE, &tbl_rev); - if (IS_ERR(wifi_pkg) || tbl_rev > 1) { + + if (IS_ERR(wifi_pkg)) { ret = PTR_ERR(wifi_pkg); goto out_free; } + if (tbl_rev > 1) { + ret = -EINVAL; + goto out_free; + } + fwrt->geo_rev = tbl_rev; for (i = 0; i < ACPI_NUM_GEO_PROFILES; i++) { for (j = 0; j < ACPI_GEO_TABLE_SIZE; j++) { diff --git a/drivers/net/wireless/intel/iwlwifi/fw/acpi.h b/drivers/net/wireless/intel/iwlwifi/fw/acpi.h index 1cce30d1ef55..030c50082568 100644 --- a/drivers/net/wireless/intel/iwlwifi/fw/acpi.h +++ b/drivers/net/wireless/intel/iwlwifi/fw/acpi.h @@ -54,9 +54,9 @@ #define ACPI_WGDS_TABLE_SIZE 3 #define ACPI_PPAG_WIFI_DATA_SIZE ((IWL_NUM_CHAIN_LIMITS * \ - IWL_NUM_SUB_BANDS) + 3) + IWL_NUM_SUB_BANDS) + 2) #define ACPI_PPAG_WIFI_DATA_SIZE_V2 ((IWL_NUM_CHAIN_LIMITS * \ - IWL_NUM_SUB_BANDS_V2) + 3) + IWL_NUM_SUB_BANDS_V2) + 2) /* PPAG gain value bounds in 1/8 dBm */ #define ACPI_PPAG_MIN_LB -16 @@ -93,13 +93,27 @@ enum iwl_dsm_values_indonesia { DSM_VALUE_INDONESIA_MAX }; +/* DSM RFI uses a different GUID, so need separate definitions */ + +#define DSM_RFI_FUNC_ENABLE 3 + +enum iwl_dsm_values_rfi { + DSM_VALUE_RFI_ENABLE, + DSM_VALUE_RFI_DISABLE, + DSM_VALUE_RFI_MAX +}; + #ifdef CONFIG_ACPI struct iwl_fw_runtime; +extern const guid_t iwl_guid; +extern const guid_t iwl_rfi_guid; + void *iwl_acpi_get_object(struct device *dev, acpi_string method); -int iwl_acpi_get_dsm_u8(struct device *dev, int rev, int func, u8 *value); +int iwl_acpi_get_dsm_u8(struct device *dev, int rev, int func, + const guid_t *guid, u8 *value); union acpi_object *iwl_acpi_get_wifi_pkg(struct device *dev, union acpi_object *data, @@ -159,8 +173,8 @@ static inline void *iwl_acpi_get_dsm_object(struct device *dev, int rev, return ERR_PTR(-ENOENT); } -static inline -int iwl_acpi_get_dsm_u8(struct device *dev, int rev, int func, u8 *value) +static inline int iwl_acpi_get_dsm_u8(struct device *dev, int rev, int func, + const guid_t *guid, u8 *value) { return -ENOENT; } diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/commands.h b/drivers/net/wireless/intel/iwlwifi/fw/api/commands.h index b916b38b3092..c625d319142e 100644 --- a/drivers/net/wireless/intel/iwlwifi/fw/api/commands.h +++ b/drivers/net/wireless/intel/iwlwifi/fw/api/commands.h @@ -284,7 +284,7 @@ enum iwl_legacy_cmds { /* Phy */ /** - * @PHY_CONFIGURATION_CMD: &struct iwl_phy_cfg_cmd + * @PHY_CONFIGURATION_CMD: &struct iwl_phy_cfg_cmd_v1 or &struct iwl_phy_cfg_cmd_v3 */ PHY_CONFIGURATION_CMD = 0x6a, @@ -606,6 +606,16 @@ enum iwl_system_subcmd_ids { * @FW_ERROR_RECOVERY_CMD: &struct iwl_fw_error_recovery_cmd */ FW_ERROR_RECOVERY_CMD = 0x7, + + /** + * @RFI_CONFIG_CMD: &struct iwl_rfi_config_cmd + */ + RFI_CONFIG_CMD = 0xb, + + /** + * @RFI_GET_FREQ_TABLE_CMD: &struct iwl_rfi_config_cmd + */ + RFI_GET_FREQ_TABLE_CMD = 0xc, }; #endif /* __iwl_fw_api_commands_h__ */ diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/datapath.h b/drivers/net/wireless/intel/iwlwifi/fw/api/datapath.h index b472f08b06e6..d299bba3aa54 100644 --- a/drivers/net/wireless/intel/iwlwifi/fw/api/datapath.h +++ b/drivers/net/wireless/intel/iwlwifi/fw/api/datapath.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ /* - * Copyright (C) 2012-2014, 2018-2019 Intel Corporation + * Copyright (C) 2012-2014, 2018-2020 Intel Corporation * Copyright (C) 2013-2015 Intel Mobile Communications GmbH * Copyright (C) 2016-2017 Intel Deutschland GmbH */ @@ -53,6 +53,12 @@ enum iwl_data_path_subcmd_ids { CHEST_COLLECTOR_FILTER_CONFIG_CMD = 0x14, /** + * @MONITOR_NOTIF: Datapath monitoring notification, using + * &struct iwl_datapath_monitor_notif + */ + MONITOR_NOTIF = 0xF4, + + /** * @RX_NO_DATA_NOTIF: &struct iwl_rx_no_data */ RX_NO_DATA_NOTIF = 0xF5, @@ -153,4 +159,14 @@ struct iwl_channel_estimation_cfg { __le64 frame_types; } __packed; /* CHEST_COLLECTOR_FILTER_CMD_API_S_VER_1 */ +enum iwl_datapath_monitor_notif_type { + IWL_DP_MON_NOTIF_TYPE_EXT_CCA, +}; + +struct iwl_datapath_monitor_notif { + __le32 type; + u8 mac_id; + u8 reserved[3]; +} __packed; /* MONITOR_NTF_API_S_VER_1 */ + #endif /* __iwl_fw_api_datapath_h__ */ diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/debug.h b/drivers/net/wireless/intel/iwlwifi/fw/api/debug.h index ace0ef46001a..8adccd5da095 100644 --- a/drivers/net/wireless/intel/iwlwifi/fw/api/debug.h +++ b/drivers/net/wireless/intel/iwlwifi/fw/api/debug.h @@ -186,6 +186,21 @@ struct iwl_shared_mem_cfg { } __packed; /* SHARED_MEM_ALLOC_API_S_VER_4 */ /** + * struct iwl_mfuart_load_notif_v1 - mfuart image version & status + * ( MFUART_LOAD_NOTIFICATION = 0xb1 ) + * @installed_ver: installed image version + * @external_ver: external image version + * @status: MFUART loading status + * @duration: MFUART loading time +*/ +struct iwl_mfuart_load_notif_v1 { + __le32 installed_ver; + __le32 external_ver; + __le32 status; + __le32 duration; +} __packed; /* MFU_LOADER_NTFY_API_S_VER_1 */ + +/** * struct iwl_mfuart_load_notif - mfuart image version & status * ( MFUART_LOAD_NOTIFICATION = 0xb1 ) * @installed_ver: installed image version diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/location.h b/drivers/net/wireless/intel/iwlwifi/fw/api/location.h index 28aa28138908..ceeef8749765 100644 --- a/drivers/net/wireless/intel/iwlwifi/fw/api/location.h +++ b/drivers/net/wireless/intel/iwlwifi/fw/api/location.h @@ -12,7 +12,12 @@ enum iwl_location_subcmd_ids { /** * @TOF_RANGE_REQ_CMD: TOF ranging request, - * uses &struct iwl_tof_range_req_cmd + * uses one of &struct iwl_tof_range_req_cmd_v5, + * &struct iwl_tof_range_req_cmd_v7, + * &struct iwl_tof_range_req_cmd_v8, + * &struct iwl_tof_range_req_cmd_v9, + * &struct iwl_tof_range_req_cmd_v11, + * &struct iwl_tof_range_req_cmd_v7 */ TOF_RANGE_REQ_CMD = 0x0, /** diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/mac.h b/drivers/net/wireless/intel/iwlwifi/fw/api/mac.h index 2d03d7bb5da5..93084bbad534 100644 --- a/drivers/net/wireless/intel/iwlwifi/fw/api/mac.h +++ b/drivers/net/wireless/intel/iwlwifi/fw/api/mac.h @@ -452,6 +452,10 @@ struct iwl_he_pkt_ext { * enabled AGG, i.e. both BACK and non-BACK frames in a single AGG * @STA_CTXT_HE_MU_EDCA_CW: indicates that there is an element of MU EDCA * parameter set, i.e. the backoff counters for trig-based ACs + * @STA_CTXT_HE_NIC_NOT_ACK_ENABLED: mark that the NIC doesn't support receiving + * ACK-enabled AGG, (i.e. both BACK and non-BACK frames in single AGG). + * If the NIC is not ACK_ENABLED it may use the EOF-bit in first non-0 + * len delim to determine if AGG or single. * @STA_CTXT_HE_RU_2MHZ_BLOCK: indicates that 26-tone RU OFDMA transmission are * not allowed (as there are OBSS that might classify such transmissions as * radar pulses). @@ -466,6 +470,7 @@ enum iwl_he_sta_ctxt_flags { STA_CTXT_HE_CONST_TRIG_RND_ALLOC = BIT(10), STA_CTXT_HE_ACK_ENABLED = BIT(11), STA_CTXT_HE_MU_EDCA_CW = BIT(12), + STA_CTXT_HE_NIC_NOT_ACK_ENABLED = BIT(13), STA_CTXT_HE_RU_2MHZ_BLOCK = BIT(14), }; diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/nvm-reg.h b/drivers/net/wireless/intel/iwlwifi/fw/api/nvm-reg.h index b2706209b7d7..fbca9dd872e7 100644 --- a/drivers/net/wireless/intel/iwlwifi/fw/api/nvm-reg.h +++ b/drivers/net/wireless/intel/iwlwifi/fw/api/nvm-reg.h @@ -415,15 +415,26 @@ enum iwl_lari_config_masks { }; /** - * struct iwl_lari_config_change_cmd - change LARI configuration + * struct iwl_lari_config_change_cmd_v1 - change LARI configuration * @config_bitmap: bit map of the config commands. each bit will trigger a * different predefined FW config operation */ -struct iwl_lari_config_change_cmd { +struct iwl_lari_config_change_cmd_v1 { __le32 config_bitmap; } __packed; /* LARI_CHANGE_CONF_CMD_S_VER_1 */ /** + * struct iwl_lari_config_change_cmd_v2 - change LARI configuration + * @config_bitmap: bit map of the config commands. each bit will trigger a + * different predefined FW config operation + * @oem_uhb_allow_bitmap: bitmap of UHB enabled MCC sets + */ +struct iwl_lari_config_change_cmd_v2 { + __le32 config_bitmap; + __le32 oem_uhb_allow_bitmap; +} __packed; /* LARI_CHANGE_CONF_CMD_S_VER_2 */ + +/** * struct iwl_pnvm_init_complete_ntfy - PNVM initialization complete * @status: PNVM image loading status */ diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/rfi.h b/drivers/net/wireless/intel/iwlwifi/fw/api/rfi.h new file mode 100644 index 000000000000..c678b9aa9b55 --- /dev/null +++ b/drivers/net/wireless/intel/iwlwifi/fw/api/rfi.h @@ -0,0 +1,60 @@ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* + * Copyright (C) 2020 Intel Corporation + */ +#ifndef __iwl_fw_api_rfi_h__ +#define __iwl_fw_api_rfi_h__ + +#define IWL_RFI_LUT_ENTRY_CHANNELS_NUM 15 +#define IWL_RFI_LUT_SIZE 24 +#define IWL_RFI_LUT_INSTALLED_SIZE 4 + +/** + * struct iwl_rfi_lut_entry - an entry in the RFI frequency LUT. + * + * @freq: frequency + * @channels: channels that can be interfered at frequency freq (at most 15) + * @bands: the corresponding bands + */ +struct iwl_rfi_lut_entry { + __le16 freq; + u8 channels[IWL_RFI_LUT_ENTRY_CHANNELS_NUM]; + u8 bands[IWL_RFI_LUT_ENTRY_CHANNELS_NUM]; +} __packed; + +/** + * struct iwl_rfi_config_cmd - RFI configuration table + * + * @entry: a table can have 24 frequency/channel mappings + * @oem: specifies if this is the default table or set by OEM + */ +struct iwl_rfi_config_cmd { + struct iwl_rfi_lut_entry table[IWL_RFI_LUT_SIZE]; + u8 oem; + u8 reserved[3]; +} __packed; /* RFI_CONFIG_CMD_API_S_VER_1 */ + +/** + * iwl_rfi_freq_table_status - status of the frequency table query + * @RFI_FREQ_TABLE_OK: can be used + * @RFI_FREQ_TABLE_DVFS_NOT_READY: DVFS is not ready yet, should try later + * @RFI_FREQ_TABLE_DISABLED: the feature is disabled in FW + */ +enum iwl_rfi_freq_table_status { + RFI_FREQ_TABLE_OK, + RFI_FREQ_TABLE_DVFS_NOT_READY, + RFI_FREQ_TABLE_DISABLED, +}; + +/** + * struct iwl_rfi_freq_table_resp_cmd - get the rfi freq table used by FW + * + * @table: table used by FW + * @status: see &iwl_rfi_freq_table_status + */ +struct iwl_rfi_freq_table_resp_cmd { + struct iwl_rfi_lut_entry table[IWL_RFI_LUT_INSTALLED_SIZE]; + __le32 status; +} __packed; /* RFI_CONFIG_CMD_API_S_VER_1 */ + +#endif /* __iwl_fw_api_rfi_h__ */ diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/rx.h b/drivers/net/wireless/intel/iwlwifi/fw/api/rx.h index 821ed472ccff..2c74db823778 100644 --- a/drivers/net/wireless/intel/iwlwifi/fw/api/rx.h +++ b/drivers/net/wireless/intel/iwlwifi/fw/api/rx.h @@ -140,7 +140,8 @@ enum iwl_rx_phy_flags { * @RX_MPDU_RES_STATUS_SEC_TKIP_ENC: this frame is encrypted using TKIP * @RX_MPDU_RES_STATUS_SEC_EXT_ENC: this frame is encrypted using extension * algorithm - * @RX_MPDU_RES_STATUS_SEC_CCM_CMAC_ENC: this frame is encrypted using CCM_CMAC + * @RX_MPDU_RES_STATUS_SEC_CMAC_GMAC_ENC: this frame is protected using + * CMAC or GMAC * @RX_MPDU_RES_STATUS_SEC_ENC_ERR: this frame couldn't be decrypted * @RX_MPDU_RES_STATUS_SEC_ENC_MSK: bitmask of the encryption algorithm * @RX_MPDU_RES_STATUS_DEC_DONE: this frame has been successfully decrypted @@ -167,7 +168,7 @@ enum iwl_mvm_rx_status { RX_MPDU_RES_STATUS_SEC_CCM_ENC = (2 << 8), RX_MPDU_RES_STATUS_SEC_TKIP_ENC = (3 << 8), RX_MPDU_RES_STATUS_SEC_EXT_ENC = (4 << 8), - RX_MPDU_RES_STATUS_SEC_CCM_CMAC_ENC = (6 << 8), + RX_MPDU_RES_STATUS_SEC_CMAC_GMAC_ENC = (6 << 8), RX_MPDU_RES_STATUS_SEC_ENC_ERR = (7 << 8), RX_MPDU_RES_STATUS_SEC_ENC_MSK = (7 << 8), RX_MPDU_RES_STATUS_DEC_DONE = BIT(11), @@ -239,6 +240,8 @@ enum iwl_rx_mpdu_status { IWL_RX_MPDU_STATUS_ICV_OK = BIT(5), IWL_RX_MPDU_STATUS_MIC_OK = BIT(6), IWL_RX_MPDU_RES_STATUS_TTAK_OK = BIT(7), + /* overlayed since IWL_UCODE_TLV_API_DEPRECATE_TTAK */ + IWL_RX_MPDU_STATUS_REPLAY_ERROR = BIT(7), IWL_RX_MPDU_STATUS_SEC_MASK = 0x7 << 8, IWL_RX_MPDU_STATUS_SEC_UNKNOWN = IWL_RX_MPDU_STATUS_SEC_MASK, IWL_RX_MPDU_STATUS_SEC_NONE = 0x0 << 8, diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/scan.h b/drivers/net/wireless/intel/iwlwifi/fw/api/scan.h index 931c0f48de99..6b8ca35cec1a 100644 --- a/drivers/net/wireless/intel/iwlwifi/fw/api/scan.h +++ b/drivers/net/wireless/intel/iwlwifi/fw/api/scan.h @@ -542,7 +542,8 @@ struct iwl_scan_config_v2 { * struct iwl_scan_config * @enable_cam_mode: whether to enable CAM mode. * @enable_promiscouos_mode: whether to enable promiscouos mode - * @bcast_sta_id: the index of the station in the fw + * @bcast_sta_id: the index of the station in the fw. Deprecated starting with + * API version 5. * @reserved: reserved * @tx_chains: valid_tx antenna - ANT_* definitions * @rx_chains: valid_rx antenna - ANT_* definitions @@ -554,7 +555,7 @@ struct iwl_scan_config { u8 reserved; __le32 tx_chains; __le32 rx_chains; -} __packed; /* SCAN_CONFIG_DB_CMD_API_S_3 */ +} __packed; /* SCAN_CONFIG_DB_CMD_API_S_5 */ /** * enum iwl_umac_scan_flags - UMAC scan flags diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/tx.h b/drivers/net/wireless/intel/iwlwifi/fw/api/tx.h index b2d8ccf5f5dd..24e4a82a55da 100644 --- a/drivers/net/wireless/intel/iwlwifi/fw/api/tx.h +++ b/drivers/net/wireless/intel/iwlwifi/fw/api/tx.h @@ -20,6 +20,7 @@ * @TX_CMD_FLG_VHT_NDPA: mark frame is NDPA for VHT beamformer sequence * @TX_CMD_FLG_HT_NDPA: mark frame is NDPA for HT beamformer sequence * @TX_CMD_FLG_CSI_FDBK2HOST: mark to send feedback to host (only if good CRC) + * @TX_CMD_FLG_BT_PRIO_MASK: BT priority value * @TX_CMD_FLG_BT_PRIO_POS: the position of the BT priority (bit 11 is ignored * on old firmwares). * @TX_CMD_FLG_BT_DIS: disable BT priority for this frame @@ -51,6 +52,7 @@ enum iwl_tx_flags { TX_CMD_FLG_HT_NDPA = BIT(9), TX_CMD_FLG_CSI_FDBK2HOST = BIT(10), TX_CMD_FLG_BT_PRIO_POS = 11, + TX_CMD_FLG_BT_PRIO_MASK = BIT(11) | BIT(12), TX_CMD_FLG_BT_DIS = BIT(12), TX_CMD_FLG_SEQ_CTL = BIT(13), TX_CMD_FLG_MORE_FRAG = BIT(14), @@ -177,7 +179,7 @@ enum iwl_tx_offload_assist_flags_pos { * ( TX_CMD = 0x1c ) * @len: in bytes of the payload, see below for details * @offload_assist: TX offload configuration - * @tx_flags: combination of TX_CMD_FLG_* + * @tx_flags: combination of TX_CMD_FLG_*, see &enum iwl_tx_flags * @scratch: scratch buffer used by the device * @rate_n_flags: rate for *all* Tx attempts, if TX_CMD_FLG_STA_RATE_MSK is * cleared. Combination of RATE_MCS_* @@ -238,7 +240,7 @@ struct iwl_tx_cmd { __le16 pm_frame_timeout; __le16 reserved4; u8 payload[0]; - struct ieee80211_hdr hdr[]; + struct ieee80211_hdr hdr[0]; } __packed; /* TX_CMD_API_S_VER_6 */ struct iwl_dram_sec_info { @@ -855,6 +857,32 @@ struct iwl_tx_path_flush_cmd { __le16 reserved; } __packed; /* TX_PATH_FLUSH_CMD_API_S_VER_2 */ +#define IWL_TX_FLUSH_QUEUE_RSP 16 + +/** + * struct iwl_flush_queue_info - virtual flush queue info + * @queue_num: virtual queue id + * @read_before_flush: read pointer before flush + * @read_after_flush: read pointer after flush + */ +struct iwl_flush_queue_info { + __le16 tid; + __le16 queue_num; + __le16 read_before_flush; + __le16 read_after_flush; +} __packed; /* TFDQ_FLUSH_INFO_API_S_VER_1 */ + +/** + * struct iwl_tx_path_flush_cmd_rsp -- queue/FIFO flush command response + * @num_flushed_queues: number of queues in queues array + * @queues: all flushed queues + */ +struct iwl_tx_path_flush_cmd_rsp { + __le16 sta_id; + __le16 num_flushed_queues; + struct iwl_flush_queue_info queues[IWL_TX_FLUSH_QUEUE_RSP]; +} __packed; /* TX_PATH_FLUSH_CMD_RSP_API_S_VER_1 */ + /* Available options for the SCD_QUEUE_CFG HCMD */ enum iwl_scd_cfg_actions { SCD_CFG_DISABLE_QUEUE = 0x0, diff --git a/drivers/net/wireless/intel/iwlwifi/fw/dbg.c b/drivers/net/wireless/intel/iwlwifi/fw/dbg.c index 0f0a6727701b..504729663c35 100644 --- a/drivers/net/wireless/intel/iwlwifi/fw/dbg.c +++ b/drivers/net/wireless/intel/iwlwifi/fw/dbg.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause /* - * Copyright (C) 2005-2014, 2018-2020 Intel Corporation + * Copyright (C) 2005-2014, 2018-2021 Intel Corporation * Copyright (C) 2013-2015 Intel Mobile Communications GmbH * Copyright (C) 2015-2017 Intel Deutschland GmbH */ @@ -33,12 +33,11 @@ static void iwl_read_radio_regs(struct iwl_fw_runtime *fwrt, struct iwl_fw_error_dump_data **dump_data) { u8 *pos = (void *)(*dump_data)->data; - unsigned long flags; int i; IWL_DEBUG_INFO(fwrt, "WRT radio registers dump\n"); - if (!iwl_trans_grab_nic_access(fwrt->trans, &flags)) + if (!iwl_trans_grab_nic_access(fwrt->trans)) return; (*dump_data)->type = cpu_to_le32(IWL_FW_ERROR_DUMP_RADIO_REG); @@ -56,7 +55,7 @@ static void iwl_read_radio_regs(struct iwl_fw_runtime *fwrt, *dump_data = iwl_fw_error_next_data(*dump_data); - iwl_trans_release_nic_access(fwrt->trans, &flags); + iwl_trans_release_nic_access(fwrt->trans); } static void iwl_fwrt_dump_rxf(struct iwl_fw_runtime *fwrt, @@ -172,11 +171,10 @@ static void iwl_fw_dump_rxf(struct iwl_fw_runtime *fwrt, struct iwl_fw_error_dump_data **dump_data) { struct iwl_fwrt_shared_mem_cfg *cfg = &fwrt->smem_cfg; - unsigned long flags; IWL_DEBUG_INFO(fwrt, "WRT RX FIFO dump\n"); - if (!iwl_trans_grab_nic_access(fwrt->trans, &flags)) + if (!iwl_trans_grab_nic_access(fwrt->trans)) return; if (iwl_fw_dbg_type_on(fwrt, IWL_FW_ERROR_DUMP_RXF)) { @@ -194,7 +192,7 @@ static void iwl_fw_dump_rxf(struct iwl_fw_runtime *fwrt, LMAC2_PRPH_OFFSET, 2); } - iwl_trans_release_nic_access(fwrt->trans, &flags); + iwl_trans_release_nic_access(fwrt->trans); } static void iwl_fw_dump_txf(struct iwl_fw_runtime *fwrt, @@ -204,12 +202,11 @@ static void iwl_fw_dump_txf(struct iwl_fw_runtime *fwrt, struct iwl_fwrt_shared_mem_cfg *cfg = &fwrt->smem_cfg; u32 *fifo_data; u32 fifo_len; - unsigned long flags; int i, j; IWL_DEBUG_INFO(fwrt, "WRT TX FIFO dump\n"); - if (!iwl_trans_grab_nic_access(fwrt->trans, &flags)) + if (!iwl_trans_grab_nic_access(fwrt->trans)) return; if (iwl_fw_dbg_type_on(fwrt, IWL_FW_ERROR_DUMP_TXF)) { @@ -299,7 +296,7 @@ static void iwl_fw_dump_txf(struct iwl_fw_runtime *fwrt, } } - iwl_trans_release_nic_access(fwrt->trans, &flags); + iwl_trans_release_nic_access(fwrt->trans); } #define IWL8260_ICCM_OFFSET 0x44000 /* Only for B-step */ @@ -527,7 +524,6 @@ static void iwl_dump_prph(struct iwl_fw_runtime *fwrt, struct iwl_trans *trans = fwrt->trans; struct iwl_fw_error_dump_data **data = (struct iwl_fw_error_dump_data **)ptr; - unsigned long flags; u32 i; if (!data) @@ -535,7 +531,7 @@ static void iwl_dump_prph(struct iwl_fw_runtime *fwrt, IWL_DEBUG_INFO(trans, "WRT PRPH dump\n"); - if (!iwl_trans_grab_nic_access(trans, &flags)) + if (!iwl_trans_grab_nic_access(trans)) return; for (i = 0; i < range_len; i++) { @@ -558,7 +554,7 @@ static void iwl_dump_prph(struct iwl_fw_runtime *fwrt, *data = iwl_fw_error_next_data(*data); } - iwl_trans_release_nic_access(trans, &flags); + iwl_trans_release_nic_access(trans); } /* @@ -1048,7 +1044,6 @@ iwl_dump_ini_prph_phy_iter(struct iwl_fw_runtime *fwrt, u32 addr = le32_to_cpu(reg->addrs[idx]); u32 dphy_state; u32 dphy_addr; - unsigned long flags; int i; range->internal_base_addr = cpu_to_le32(addr); @@ -1060,7 +1055,7 @@ iwl_dump_ini_prph_phy_iter(struct iwl_fw_runtime *fwrt, indirect_wr_addr += le32_to_cpu(reg->dev_addr.offset); indirect_rd_addr += le32_to_cpu(reg->dev_addr.offset); - if (!iwl_trans_grab_nic_access(fwrt->trans, &flags)) + if (!iwl_trans_grab_nic_access(fwrt->trans)) return -EBUSY; dphy_addr = (reg->dev_addr.offset) ? WFPM_LMAC2_PS_CTL_RW : @@ -1082,7 +1077,7 @@ iwl_dump_ini_prph_phy_iter(struct iwl_fw_runtime *fwrt, *val++ = cpu_to_le32(prph_val); } - iwl_trans_release_nic_access(fwrt->trans, &flags); + iwl_trans_release_nic_access(fwrt->trans); return sizeof(*range) + le32_to_cpu(range->range_data_size); } @@ -1157,10 +1152,7 @@ static int iwl_dump_ini_dev_mem_iter(struct iwl_fw_runtime *fwrt, static int _iwl_dump_ini_paging_iter(struct iwl_fw_runtime *fwrt, void *range_ptr, int idx) { - /* increase idx by 1 since the pages are from 1 to - * fwrt->num_of_paging_blk + 1 - */ - struct page *page = fwrt->fw_paging_db[++idx].fw_paging_block; + struct page *page = fwrt->fw_paging_db[idx].fw_paging_block; struct iwl_fw_ini_error_dump_range *range = range_ptr; dma_addr_t addr = fwrt->fw_paging_db[idx].fw_paging_phys; u32 page_size = fwrt->fw_paging_db[idx].fw_paging_size; @@ -1183,6 +1175,9 @@ static int iwl_dump_ini_paging_iter(struct iwl_fw_runtime *fwrt, struct iwl_fw_ini_error_dump_range *range; u32 page_size; + /* all paged index start from 1 to skip CSS section */ + idx++; + if (!fwrt->trans->trans_cfg->gen2) return _iwl_dump_ini_paging_iter(fwrt, range_ptr, idx); @@ -1297,13 +1292,12 @@ static int iwl_dump_ini_txf_iter(struct iwl_fw_runtime *fwrt, u32 registers_num = iwl_tlv_array_len(reg_data->reg_tlv, reg, addrs); u32 registers_size = registers_num * sizeof(*reg_dump); __le32 *data; - unsigned long flags; int i; if (!iwl_ini_txf_iter(fwrt, reg_data, idx)) return -EIO; - if (!iwl_trans_grab_nic_access(fwrt->trans, &flags)) + if (!iwl_trans_grab_nic_access(fwrt->trans)) return -EBUSY; range->fifo_hdr.fifo_num = cpu_to_le32(iter->fifo); @@ -1345,7 +1339,7 @@ static int iwl_dump_ini_txf_iter(struct iwl_fw_runtime *fwrt, *data++ = cpu_to_le32(iwl_read_prph_no_grab(fwrt->trans, addr)); out: - iwl_trans_release_nic_access(fwrt->trans, &flags); + iwl_trans_release_nic_access(fwrt->trans); return sizeof(*range) + le32_to_cpu(range->range_data_size); } @@ -1429,14 +1423,13 @@ static int iwl_dump_ini_rxf_iter(struct iwl_fw_runtime *fwrt, u32 registers_num = iwl_tlv_array_len(reg_data->reg_tlv, reg, addrs); u32 registers_size = registers_num * sizeof(*reg_dump); __le32 *data; - unsigned long flags; int i; iwl_ini_get_rxf_data(fwrt, reg_data, &rxf_data); if (!rxf_data.size) return -EIO; - if (!iwl_trans_grab_nic_access(fwrt->trans, &flags)) + if (!iwl_trans_grab_nic_access(fwrt->trans)) return -EBUSY; range->fifo_hdr.fifo_num = cpu_to_le32(rxf_data.fifo_num); @@ -1479,7 +1472,7 @@ static int iwl_dump_ini_rxf_iter(struct iwl_fw_runtime *fwrt, *data++ = cpu_to_le32(iwl_read_prph_no_grab(fwrt->trans, addr)); out: - iwl_trans_release_nic_access(fwrt->trans, &flags); + iwl_trans_release_nic_access(fwrt->trans); return sizeof(*range) + le32_to_cpu(range->range_data_size); } @@ -1596,9 +1589,8 @@ iwl_dump_ini_mon_fill_header(struct iwl_fw_runtime *fwrt, { struct iwl_fw_ini_region_tlv *reg = (void *)reg_data->reg_tlv->data; u32 alloc_id = le32_to_cpu(reg->dram_alloc_id); - unsigned long flags; - if (!iwl_trans_grab_nic_access(fwrt->trans, &flags)) { + if (!iwl_trans_grab_nic_access(fwrt->trans)) { IWL_ERR(fwrt, "Failed to get monitor header\n"); return NULL; } @@ -1615,7 +1607,7 @@ iwl_dump_ini_mon_fill_header(struct iwl_fw_runtime *fwrt, data->cur_frag = iwl_get_mon_reg(fwrt, alloc_id, &addrs->cur_frag); - iwl_trans_release_nic_access(fwrt->trans, &flags); + iwl_trans_release_nic_access(fwrt->trans); data->header.version = cpu_to_le32(IWL_INI_DUMP_VER); @@ -1684,8 +1676,12 @@ static u32 iwl_dump_ini_mem_ranges(struct iwl_fw_runtime *fwrt, static u32 iwl_dump_ini_paging_ranges(struct iwl_fw_runtime *fwrt, struct iwl_dump_ini_region_data *reg_data) { - if (fwrt->trans->trans_cfg->gen2) - return fwrt->trans->init_dram.paging_cnt; + if (fwrt->trans->trans_cfg->gen2) { + if (fwrt->trans->init_dram.paging_cnt) + return fwrt->trans->init_dram.paging_cnt - 1; + else + return 0; + } return fwrt->num_of_paging_blk; } @@ -1750,15 +1746,13 @@ iwl_dump_ini_paging_get_size(struct iwl_fw_runtime *fwrt, u32 range_header_len = sizeof(struct iwl_fw_ini_error_dump_range); u32 size = sizeof(struct iwl_fw_ini_error_dump); - if (fwrt->trans->trans_cfg->gen2) { - for (i = 0; i < iwl_dump_ini_paging_ranges(fwrt, reg_data); i++) - size += range_header_len + - fwrt->trans->init_dram.paging[i].size; - } else { - for (i = 1; i <= iwl_dump_ini_paging_ranges(fwrt, reg_data); - i++) - size += range_header_len + - fwrt->fw_paging_db[i].fw_paging_size; + /* start from 1 to skip CSS section */ + for (i = 1; i <= iwl_dump_ini_paging_ranges(fwrt, reg_data); i++) { + size += range_header_len; + if (fwrt->trans->trans_cfg->gen2) + size += fwrt->trans->init_dram.paging[i].size; + else + size += fwrt->fw_paging_db[i].fw_paging_size; } return size; @@ -2071,7 +2065,8 @@ static u32 iwl_dump_ini_info(struct iwl_fw_runtime *fwrt, dump->umac_minor = cpu_to_le32(fwrt->dump.fw_ver.umac_minor); dump->fw_mon_mode = cpu_to_le32(fwrt->trans->dbg.ini_dest); - dump->regions_mask = trigger->regions_mask; + dump->regions_mask = trigger->regions_mask & + ~cpu_to_le64(fwrt->trans->dbg.unsupported_region_msk); dump->build_tag_len = cpu_to_le32(sizeof(dump->build_tag)); memcpy(dump->build_tag, fwrt->fw->human_readable, @@ -2200,7 +2195,8 @@ static u32 iwl_dump_ini_trigger(struct iwl_fw_runtime *fwrt, }; int i; u32 size = 0; - u64 regions_mask = le64_to_cpu(trigger->regions_mask); + u64 regions_mask = le64_to_cpu(trigger->regions_mask) & + ~(fwrt->trans->dbg.unsupported_region_msk); BUILD_BUG_ON(sizeof(trigger->regions_mask) != sizeof(regions_mask)); BUILD_BUG_ON((sizeof(trigger->regions_mask) * BITS_PER_BYTE) < @@ -2451,7 +2447,8 @@ int iwl_fw_dbg_error_collect(struct iwl_fw_runtime *fwrt, return -EIO; if (iwl_trans_dbg_ini_valid(fwrt->trans)) { - if (trig_type != FW_DBG_TRIGGER_ALIVE_TIMEOUT) + if (trig_type != FW_DBG_TRIGGER_ALIVE_TIMEOUT && + trig_type != FW_DBG_TRIGGER_DRIVER) return -EIO; iwl_dbg_tlv_time_point(fwrt, @@ -2758,7 +2755,6 @@ IWL_EXPORT_SYMBOL(iwl_fw_dbg_stop_sync); void iwl_fw_error_print_fseq_regs(struct iwl_fw_runtime *fwrt) { struct iwl_trans *trans = fwrt->trans; - unsigned long flags; int i; struct { u32 addr; @@ -2778,7 +2774,7 @@ void iwl_fw_error_print_fseq_regs(struct iwl_fw_runtime *fwrt) FSEQ_REG(CNVR_SCU_SD_REGS_SD_REG_ACTIVE_VDIG_MIRROR), }; - if (!iwl_trans_grab_nic_access(trans, &flags)) + if (!iwl_trans_grab_nic_access(trans)) return; IWL_ERR(fwrt, "Fseq Registers:\n"); @@ -2788,7 +2784,7 @@ void iwl_fw_error_print_fseq_regs(struct iwl_fw_runtime *fwrt) iwl_read_prph_no_grab(trans, fseq_regs[i].addr), fseq_regs[i].str); - iwl_trans_release_nic_access(trans, &flags); + iwl_trans_release_nic_access(trans); } IWL_EXPORT_SYMBOL(iwl_fw_error_print_fseq_regs); diff --git a/drivers/net/wireless/intel/iwlwifi/fw/file.h b/drivers/net/wireless/intel/iwlwifi/fw/file.h index 597bc88479ba..35dffcaf5aba 100644 --- a/drivers/net/wireless/intel/iwlwifi/fw/file.h +++ b/drivers/net/wireless/intel/iwlwifi/fw/file.h @@ -93,6 +93,7 @@ enum iwl_ucode_tlv_type { IWL_UCODE_TLV_FW_RECOVERY_INFO = 57, IWL_UCODE_TLV_HW_TYPE = 58, IWL_UCODE_TLV_FW_FSEQ_VERSION = 60, + IWL_UCODE_TLV_PHY_INTEGRATION_VERSION = 61, IWL_UCODE_TLV_PNVM_VERSION = 62, IWL_UCODE_TLV_PNVM_SKU = 64, @@ -439,6 +440,9 @@ enum iwl_ucode_tlv_capa { */ IWL_UCODE_TLV_CAPA_PSC_CHAN_SUPPORT = (__force iwl_ucode_tlv_capa_t)98, + IWL_UCODE_TLV_CAPA_BIGTK_SUPPORT = (__force iwl_ucode_tlv_capa_t)100, + IWL_UCODE_TLV_CAPA_RFIM_SUPPORT = (__force iwl_ucode_tlv_capa_t)102, + NUM_IWL_UCODE_TLV_CAPA #ifdef __CHECKER__ /* sparse says it cannot increment the previous enum member */ @@ -866,7 +870,7 @@ struct iwl_fw_dbg_trigger_time_event { * tx_bar: tid bitmap to configure on what tid the trigger should occur * when a BAR is send (for an Rx BlocAck session). * frame_timeout: tid bitmap to configure on what tid the trigger should occur - * when a frame times out in the reodering buffer. + * when a frame times out in the reordering buffer. */ struct iwl_fw_dbg_trigger_ba { __le16 rx_ba_start; diff --git a/drivers/net/wireless/intel/iwlwifi/fw/img.h b/drivers/net/wireless/intel/iwlwifi/fw/img.h index c93d247621ec..1dee4714e505 100644 --- a/drivers/net/wireless/intel/iwlwifi/fw/img.h +++ b/drivers/net/wireless/intel/iwlwifi/fw/img.h @@ -219,6 +219,9 @@ struct iwl_fw { u8 human_readable[FW_VER_HUMAN_READABLE_SZ]; struct iwl_fw_dbg dbg; + + u8 *phy_integration_ver; + u32 phy_integration_ver_len; }; static inline const char *get_fw_dbg_mode_string(int mode) diff --git a/drivers/net/wireless/intel/iwlwifi/fw/init.c b/drivers/net/wireless/intel/iwlwifi/fw/init.c index e317b051b8ed..986913f2fbd5 100644 --- a/drivers/net/wireless/intel/iwlwifi/fw/init.c +++ b/drivers/net/wireless/intel/iwlwifi/fw/init.c @@ -36,11 +36,13 @@ IWL_EXPORT_SYMBOL(iwl_fw_runtime_init); void iwl_fw_runtime_suspend(struct iwl_fw_runtime *fwrt) { iwl_fw_suspend_timestamp(fwrt); + iwl_dbg_tlv_time_point(fwrt, IWL_FW_INI_TIME_POINT_HOST_D3_START, NULL); } IWL_EXPORT_SYMBOL(iwl_fw_runtime_suspend); void iwl_fw_runtime_resume(struct iwl_fw_runtime *fwrt) { + iwl_dbg_tlv_time_point(fwrt, IWL_FW_INI_TIME_POINT_HOST_D3_END, NULL); iwl_fw_resume_timestamp(fwrt); } IWL_EXPORT_SYMBOL(iwl_fw_runtime_resume); diff --git a/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c b/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c index 895a907acdf0..40f2109a097f 100644 --- a/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c +++ b/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c @@ -1,9 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause -/****************************************************************************** - * - * Copyright(c) 2020 Intel Corporation - * - *****************************************************************************/ +/* + * Copyright(c) 2020-2021 Intel Corporation + */ #include "iwl-drv.h" #include "pnvm.h" @@ -12,6 +10,7 @@ #include "fw/api/commands.h" #include "fw/api/nvm-reg.h" #include "fw/api/alive.h" +#include <linux/efi.h> struct iwl_pnvm_section { __le32 offset; @@ -198,14 +197,14 @@ static int iwl_pnvm_parse(struct iwl_trans *trans, const u8 *data, le32_to_cpu(sku_id->data[1]), le32_to_cpu(sku_id->data[2])); + data += sizeof(*tlv) + ALIGN(tlv_len, 4); + len -= ALIGN(tlv_len, 4); + if (trans->sku_id[0] == le32_to_cpu(sku_id->data[0]) && trans->sku_id[1] == le32_to_cpu(sku_id->data[1]) && trans->sku_id[2] == le32_to_cpu(sku_id->data[2])) { int ret; - data += sizeof(*tlv) + ALIGN(tlv_len, 4); - len -= ALIGN(tlv_len, 4); - ret = iwl_pnvm_handle_section(trans, data, len); if (!ret) return 0; @@ -221,51 +220,165 @@ static int iwl_pnvm_parse(struct iwl_trans *trans, const u8 *data, return -ENOENT; } +#if defined(CONFIG_EFI) + +#define IWL_EFI_VAR_GUID EFI_GUID(0x92daaf2f, 0xc02b, 0x455b, \ + 0xb2, 0xec, 0xf5, 0xa3, \ + 0x59, 0x4f, 0x4a, 0xea) + +#define IWL_UEFI_OEM_PNVM_NAME L"UefiCnvWlanOemSignedPnvm" + +#define IWL_HARDCODED_PNVM_SIZE 4096 + +struct pnvm_sku_package { + u8 rev; + u8 reserved1[3]; + u32 total_size; + u8 n_skus; + u8 reserved2[11]; + u8 data[]; +}; + +static int iwl_pnvm_get_from_efi(struct iwl_trans *trans, + u8 **data, size_t *len) +{ + struct efivar_entry *pnvm_efivar; + struct pnvm_sku_package *package; + unsigned long package_size; + int err; + + pnvm_efivar = kzalloc(sizeof(*pnvm_efivar), GFP_KERNEL); + if (!pnvm_efivar) + return -ENOMEM; + + memcpy(&pnvm_efivar->var.VariableName, IWL_UEFI_OEM_PNVM_NAME, + sizeof(IWL_UEFI_OEM_PNVM_NAME)); + pnvm_efivar->var.VendorGuid = IWL_EFI_VAR_GUID; + + /* + * TODO: we hardcode a maximum length here, because reading + * from the UEFI is not working. To implement this properly, + * we have to call efivar_entry_size(). + */ + package_size = IWL_HARDCODED_PNVM_SIZE; + + package = kmalloc(package_size, GFP_KERNEL); + if (!package) { + err = -ENOMEM; + goto out; + } + + err = efivar_entry_get(pnvm_efivar, NULL, &package_size, package); + if (err) { + IWL_DEBUG_FW(trans, + "PNVM UEFI variable not found %d (len %lu)\n", + err, package_size); + goto out; + } + + IWL_DEBUG_FW(trans, "Read PNVM fro UEFI with size %lu\n", package_size); + + *data = kmemdup(package->data, *len, GFP_KERNEL); + if (!*data) + err = -ENOMEM; + *len = package_size - sizeof(*package); + +out: + kfree(package); + kfree(pnvm_efivar); + + return err; +} +#else /* CONFIG_EFI */ +static inline int iwl_pnvm_get_from_efi(struct iwl_trans *trans, + u8 **data, size_t *len) +{ + return -EOPNOTSUPP; +} +#endif /* CONFIG_EFI */ + +static int iwl_pnvm_get_from_fs(struct iwl_trans *trans, u8 **data, size_t *len) +{ + const struct firmware *pnvm; + char pnvm_name[64]; + int ret; + + /* + * The prefix unfortunately includes a hyphen at the end, so + * don't add the dot here... + */ + snprintf(pnvm_name, sizeof(pnvm_name), "%spnvm", + trans->cfg->fw_name_pre); + + /* ...but replace the hyphen with the dot here. */ + if (strlen(trans->cfg->fw_name_pre) < sizeof(pnvm_name)) + pnvm_name[strlen(trans->cfg->fw_name_pre) - 1] = '.'; + + ret = firmware_request_nowarn(&pnvm, pnvm_name, trans->dev); + if (ret) { + IWL_DEBUG_FW(trans, "PNVM file %s not found %d\n", + pnvm_name, ret); + return ret; + } + + *data = kmemdup(pnvm->data, pnvm->size, GFP_KERNEL); + if (!*data) + return -ENOMEM; + + *len = pnvm->size; + + return 0; +} + int iwl_pnvm_load(struct iwl_trans *trans, struct iwl_notif_wait_data *notif_wait) { + u8 *data; + size_t len; struct iwl_notification_wait pnvm_wait; static const u16 ntf_cmds[] = { WIDE_ID(REGULATORY_AND_NVM_GROUP, PNVM_INIT_COMPLETE_NTFY) }; + int ret; /* if the SKU_ID is empty, there's nothing to do */ if (!trans->sku_id[0] && !trans->sku_id[1] && !trans->sku_id[2]) return 0; - /* load from disk only if we haven't done it (or tried) before */ - if (!trans->pnvm_loaded) { - const struct firmware *pnvm; - char pnvm_name[64]; - int ret; + /* + * If we already loaded (or tried to load) it before, we just + * need to set it again. + */ + if (trans->pnvm_loaded) { + ret = iwl_trans_set_pnvm(trans, NULL, 0); + if (ret) + return ret; + goto skip_parse; + } + + /* First attempt to get the PNVM from BIOS */ + ret = iwl_pnvm_get_from_efi(trans, &data, &len); + if (!ret) + goto parse; + /* If it's not available, try from the filesystem */ + ret = iwl_pnvm_get_from_fs(trans, &data, &len); + if (ret) { /* - * The prefix unfortunately includes a hyphen at the end, so - * don't add the dot here... + * Pretend we've loaded it - at least we've tried and + * couldn't load it at all, so there's no point in + * trying again over and over. */ - snprintf(pnvm_name, sizeof(pnvm_name), "%spnvm", - trans->cfg->fw_name_pre); - - /* ...but replace the hyphen with the dot here. */ - if (strlen(trans->cfg->fw_name_pre) < sizeof(pnvm_name)) - pnvm_name[strlen(trans->cfg->fw_name_pre) - 1] = '.'; - - ret = firmware_request_nowarn(&pnvm, pnvm_name, trans->dev); - if (ret) { - IWL_DEBUG_FW(trans, "PNVM file %s not found %d\n", - pnvm_name, ret); - /* - * Pretend we've loaded it - at least we've tried and - * couldn't load it at all, so there's no point in - * trying again over and over. - */ - trans->pnvm_loaded = true; - } else { - iwl_pnvm_parse(trans, pnvm->data, pnvm->size); + trans->pnvm_loaded = true; - release_firmware(pnvm); - } + goto skip_parse; } +parse: + iwl_pnvm_parse(trans, data, len); + + kfree(data); + +skip_parse: iwl_init_notification_wait(notif_wait, &pnvm_wait, ntf_cmds, ARRAY_SIZE(ntf_cmds), iwl_pnvm_complete_fn, trans); |