Path: blob/main/sys/contrib/dev/iwlwifi/fw/runtime.h
48287 views
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */1/*2* Copyright (C) 2017 Intel Deutschland GmbH3* Copyright (C) 2018-2025 Intel Corporation4*/5#ifndef __iwl_fw_runtime_h__6#define __iwl_fw_runtime_h__78#include "iwl-config.h"9#include "iwl-trans.h"10#include "img.h"11#include "fw/api/debug.h"12#include "fw/api/paging.h"13#include "fw/api/power.h"14#include "iwl-nvm-utils.h"15#include "fw/acpi.h"16#include "fw/regulatory.h"1718struct iwl_fw_runtime_ops {19void (*dump_start)(void *ctx);20void (*dump_end)(void *ctx);21int (*send_hcmd)(void *ctx, struct iwl_host_cmd *host_cmd);22bool (*d3_debug_enable)(void *ctx);23};2425#define MAX_NUM_LMAC 226#define MAX_NUM_TCM 227#define MAX_NUM_RCM 228struct iwl_fwrt_shared_mem_cfg {29int num_lmacs;30int num_txfifo_entries;31struct {32u32 txfifo_size[TX_FIFO_MAX_NUM];33u32 rxfifo1_size;34} lmac[MAX_NUM_LMAC];35u32 rxfifo2_size;36u32 rxfifo2_control_size;37u32 internal_txfifo_addr;38u32 internal_txfifo_size[TX_FIFO_INTERNAL_MAX_NUM];39};4041#define IWL_FW_RUNTIME_DUMP_WK_NUM 54243/**44* struct iwl_fwrt_dump_data - dump data45* @trig: trigger the worker was scheduled upon46* @fw_pkt: packet received from FW47*48* Note that the decision which part of the union is used49* is based on iwl_trans_dbg_ini_valid(): the 'trig' part50* is used if it is %true, the 'desc' part otherwise.51*/52struct iwl_fwrt_dump_data {53union {54struct {55struct iwl_fw_ini_trigger_tlv *trig;56struct iwl_rx_packet *fw_pkt;57};58struct {59/* must be first to be same as 'trig' */60const struct iwl_fw_dump_desc *desc;61bool monitor_only;62};63};64};6566/**67* struct iwl_fwrt_wk_data - dump worker data struct68* @idx: index of the worker69* @wk: worker70*/71struct iwl_fwrt_wk_data {72u8 idx;73struct delayed_work wk;74struct iwl_fwrt_dump_data dump_data;75};7677/**78* struct iwl_txf_iter_data - Tx fifo iterator data struct79* @fifo: fifo number80* @lmac: lmac number81* @fifo_size: fifo size82* @internal_txf: non zero if fifo is internal Tx fifo83*/84struct iwl_txf_iter_data {85int fifo;86int lmac;87u32 fifo_size;88u8 internal_txf;89};9091/**92* struct iwl_fw_runtime - runtime data for firmware93* @fw: firmware image94* @cfg: NIC configuration95* @dev: device pointer96* @ops: user ops97* @ops_ctx: user ops context98* @fw_paging_db: paging database99* @num_of_paging_blk: number of paging blocks100* @num_of_pages_in_last_blk: number of pages in the last block101* @smem_cfg: saved firmware SMEM configuration102* @cur_fw_img: current firmware image, must be maintained by103* the driver by calling &iwl_fw_set_current_image()104* @dump: debug dump data105* @uats_table: AP type table106* @uats_valid: is AP type table valid107* @uefi_tables_lock_status: The status of the WIFI GUID UEFI variables lock:108* 0: Unlocked, 1 and 2: Locked.109* Only read the UEFI variables if locked.110* @sar_profiles: sar profiles as read from WRDS/EWRD BIOS tables111* @geo_profiles: geographic profiles as read from WGDS BIOS table112* @phy_filters: specific phy filters as read from WPFC BIOS table113* @ppag_bios_rev: PPAG BIOS revision114* @ppag_bios_source: see &enum bios_source115* @acpi_dsm_funcs_valid: bitmap indicating which DSM values are valid,116* zero (default initialization) means it hasn't been read yet,117* and BIT(0) is set when it has since function 0 also has this118* bitmap and is always supported119*/120struct iwl_fw_runtime {121struct iwl_trans *trans;122const struct iwl_fw *fw;123struct device *dev;124125const struct iwl_fw_runtime_ops *ops;126void *ops_ctx;127128const struct iwl_dump_sanitize_ops *sanitize_ops;129void *sanitize_ctx;130131/* Paging */132struct iwl_fw_paging fw_paging_db[NUM_OF_FW_PAGING_BLOCKS];133u16 num_of_paging_blk;134u16 num_of_pages_in_last_blk;135136enum iwl_ucode_type cur_fw_img;137138/* memory configuration */139struct iwl_fwrt_shared_mem_cfg smem_cfg;140141/* debug */142struct {143struct iwl_fwrt_wk_data wks[IWL_FW_RUNTIME_DUMP_WK_NUM];144unsigned long active_wks;145146u8 conf;147148/* ts of the beginning of a non-collect fw dbg data period */149unsigned long non_collect_ts_start[IWL_FW_INI_TIME_POINT_NUM];150u32 *d3_debug_data;151u32 lmac_err_id[MAX_NUM_LMAC];152u32 tcm_err_id[MAX_NUM_TCM];153u32 rcm_err_id[MAX_NUM_RCM];154u32 umac_err_id;155156struct iwl_txf_iter_data txf_iter_data;157158struct {159u8 type;160u8 subtype;161u32 lmac_major;162u32 lmac_minor;163u32 umac_major;164u32 umac_minor;165} fw_ver;166} dump;167struct {168#ifdef CONFIG_IWLWIFI_DEBUGFS169struct delayed_work wk;170u32 delay;171#endif172u64 seq;173} timestamp;174#ifdef CONFIG_IWLWIFI_DEBUGFS175bool tpc_enabled;176#endif /* CONFIG_IWLWIFI_DEBUGFS */177struct iwl_sar_profile sar_profiles[BIOS_SAR_MAX_PROFILE_NUM];178u8 sar_chain_a_profile;179u8 sar_chain_b_profile;180u8 reduced_power_flags;181struct iwl_geo_profile geo_profiles[BIOS_GEO_MAX_PROFILE_NUM];182u32 geo_rev;183u32 geo_num_profiles;184bool geo_enabled;185struct iwl_ppag_chain ppag_chains[IWL_NUM_CHAIN_LIMITS];186u32 ppag_flags;187u8 ppag_bios_rev;188u8 ppag_bios_source;189struct iwl_sar_offset_mapping_cmd sgom_table;190bool sgom_enabled;191struct iwl_mcc_allowed_ap_type_cmd uats_table;192bool uats_valid;193u8 uefi_tables_lock_status;194struct iwl_phy_specific_cfg phy_filters;195196#ifdef CONFIG_ACPI197u32 acpi_dsm_funcs_valid;198#endif199};200201void iwl_fw_runtime_init(struct iwl_fw_runtime *fwrt, struct iwl_trans *trans,202const struct iwl_fw *fw,203const struct iwl_fw_runtime_ops *ops, void *ops_ctx,204const struct iwl_dump_sanitize_ops *sanitize_ops,205void *sanitize_ctx,206struct dentry *dbgfs_dir);207208static inline void iwl_fw_runtime_free(struct iwl_fw_runtime *fwrt)209{210int i;211212kfree(fwrt->dump.d3_debug_data);213fwrt->dump.d3_debug_data = NULL;214215iwl_dbg_tlv_del_timers(fwrt->trans);216for (i = 0; i < IWL_FW_RUNTIME_DUMP_WK_NUM; i++)217cancel_delayed_work_sync(&fwrt->dump.wks[i].wk);218}219220void iwl_fw_runtime_suspend(struct iwl_fw_runtime *fwrt);221222void iwl_fw_runtime_resume(struct iwl_fw_runtime *fwrt);223224static inline void iwl_fw_set_current_image(struct iwl_fw_runtime *fwrt,225enum iwl_ucode_type cur_fw_img)226{227fwrt->cur_fw_img = cur_fw_img;228}229230int iwl_init_paging(struct iwl_fw_runtime *fwrt, enum iwl_ucode_type type);231void iwl_free_fw_paging(struct iwl_fw_runtime *fwrt);232233void iwl_get_shared_mem_conf(struct iwl_fw_runtime *fwrt);234int iwl_set_soc_latency(struct iwl_fw_runtime *fwrt);235int iwl_configure_rxq(struct iwl_fw_runtime *fwrt);236237#endif /* __iwl_fw_runtime_h__ */238239240