18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/******************************************************************************
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Copyright(c) 2003 - 2014, 2020 Intel Corporation. All rights reserved.
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * Contact Information:
78c2ecf20Sopenharmony_ci *  Intel Linux Wireless <linuxwifi@intel.com>
88c2ecf20Sopenharmony_ci * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
98c2ecf20Sopenharmony_ci *
108c2ecf20Sopenharmony_ci *****************************************************************************/
118c2ecf20Sopenharmony_ci/*
128c2ecf20Sopenharmony_ci * Please use this file (dev.h) for driver implementation definitions.
138c2ecf20Sopenharmony_ci * Please use commands.h for uCode API definitions.
148c2ecf20Sopenharmony_ci */
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci#ifndef __iwl_dev_h__
178c2ecf20Sopenharmony_ci#define __iwl_dev_h__
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#include <linux/interrupt.h>
208c2ecf20Sopenharmony_ci#include <linux/kernel.h>
218c2ecf20Sopenharmony_ci#include <linux/wait.h>
228c2ecf20Sopenharmony_ci#include <linux/leds.h>
238c2ecf20Sopenharmony_ci#include <linux/slab.h>
248c2ecf20Sopenharmony_ci#include <linux/mutex.h>
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci#include "fw/img.h"
278c2ecf20Sopenharmony_ci#include "iwl-eeprom-parse.h"
288c2ecf20Sopenharmony_ci#include "iwl-csr.h"
298c2ecf20Sopenharmony_ci#include "iwl-debug.h"
308c2ecf20Sopenharmony_ci#include "iwl-agn-hw.h"
318c2ecf20Sopenharmony_ci#include "iwl-op-mode.h"
328c2ecf20Sopenharmony_ci#include "fw/notif-wait.h"
338c2ecf20Sopenharmony_ci#include "iwl-trans.h"
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci#include "led.h"
368c2ecf20Sopenharmony_ci#include "power.h"
378c2ecf20Sopenharmony_ci#include "rs.h"
388c2ecf20Sopenharmony_ci#include "tt.h"
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci/* CT-KILL constants */
418c2ecf20Sopenharmony_ci#define CT_KILL_THRESHOLD_LEGACY   110 /* in Celsius */
428c2ecf20Sopenharmony_ci#define CT_KILL_THRESHOLD	   114 /* in Celsius */
438c2ecf20Sopenharmony_ci#define CT_KILL_EXIT_THRESHOLD     95  /* in Celsius */
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci/* Default noise level to report when noise measurement is not available.
468c2ecf20Sopenharmony_ci *   This may be because we're:
478c2ecf20Sopenharmony_ci *   1)  Not associated  no beacon statistics being sent to driver)
488c2ecf20Sopenharmony_ci *   2)  Scanning (noise measurement does not apply to associated channel)
498c2ecf20Sopenharmony_ci * Use default noise value of -127 ... this is below the range of measurable
508c2ecf20Sopenharmony_ci *   Rx dBm for all agn devices, so it can indicate "unmeasurable" to user.
518c2ecf20Sopenharmony_ci *   Also, -127 works better than 0 when averaging frames with/without
528c2ecf20Sopenharmony_ci *   noise info (e.g. averaging might be done in app); measured dBm values are
538c2ecf20Sopenharmony_ci *   always negative ... using a negative value as the default keeps all
548c2ecf20Sopenharmony_ci *   averages within an s8's (used in some apps) range of negative values. */
558c2ecf20Sopenharmony_ci#define IWL_NOISE_MEAS_NOT_AVAILABLE (-127)
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci/*
588c2ecf20Sopenharmony_ci * RTS threshold here is total size [2347] minus 4 FCS bytes
598c2ecf20Sopenharmony_ci * Per spec:
608c2ecf20Sopenharmony_ci *   a value of 0 means RTS on all data/management packets
618c2ecf20Sopenharmony_ci *   a value > max MSDU size means no RTS
628c2ecf20Sopenharmony_ci * else RTS for data/management frames where MPDU is larger
638c2ecf20Sopenharmony_ci *   than RTS value.
648c2ecf20Sopenharmony_ci */
658c2ecf20Sopenharmony_ci#define DEFAULT_RTS_THRESHOLD     2347U
668c2ecf20Sopenharmony_ci#define MIN_RTS_THRESHOLD         0U
678c2ecf20Sopenharmony_ci#define MAX_RTS_THRESHOLD         2347U
688c2ecf20Sopenharmony_ci#define MAX_MSDU_SIZE		  2304U
698c2ecf20Sopenharmony_ci#define MAX_MPDU_SIZE		  2346U
708c2ecf20Sopenharmony_ci#define DEFAULT_BEACON_INTERVAL   200U
718c2ecf20Sopenharmony_ci#define	DEFAULT_SHORT_RETRY_LIMIT 7U
728c2ecf20Sopenharmony_ci#define	DEFAULT_LONG_RETRY_LIMIT  4U
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci#define IWL_NUM_SCAN_RATES         (2)
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci#define IEEE80211_DATA_LEN              2304
788c2ecf20Sopenharmony_ci#define IEEE80211_4ADDR_LEN             30
798c2ecf20Sopenharmony_ci#define IEEE80211_HLEN                  (IEEE80211_4ADDR_LEN)
808c2ecf20Sopenharmony_ci#define IEEE80211_FRAME_LEN             (IEEE80211_DATA_LEN + IEEE80211_HLEN)
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_ci#define SUP_RATE_11A_MAX_NUM_CHANNELS  8
838c2ecf20Sopenharmony_ci#define SUP_RATE_11B_MAX_NUM_CHANNELS  4
848c2ecf20Sopenharmony_ci#define SUP_RATE_11G_MAX_NUM_CHANNELS  12
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci#define IWL_SUPPORTED_RATES_IE_LEN         8
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci#define IWL_INVALID_RATE     0xFF
898c2ecf20Sopenharmony_ci#define IWL_INVALID_VALUE    -1
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ciunion iwl_ht_rate_supp {
928c2ecf20Sopenharmony_ci	u16 rates;
938c2ecf20Sopenharmony_ci	struct {
948c2ecf20Sopenharmony_ci		u8 siso_rate;
958c2ecf20Sopenharmony_ci		u8 mimo_rate;
968c2ecf20Sopenharmony_ci	};
978c2ecf20Sopenharmony_ci};
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_cistruct iwl_ht_config {
1008c2ecf20Sopenharmony_ci	bool single_chain_sufficient;
1018c2ecf20Sopenharmony_ci	enum ieee80211_smps_mode smps; /* current smps mode */
1028c2ecf20Sopenharmony_ci};
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ci/* QoS structures */
1058c2ecf20Sopenharmony_cistruct iwl_qos_info {
1068c2ecf20Sopenharmony_ci	int qos_active;
1078c2ecf20Sopenharmony_ci	struct iwl_qosparam_cmd def_qos_parm;
1088c2ecf20Sopenharmony_ci};
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_ci/**
1118c2ecf20Sopenharmony_ci * enum iwl_agg_state
1128c2ecf20Sopenharmony_ci *
1138c2ecf20Sopenharmony_ci * The state machine of the BA agreement establishment / tear down.
1148c2ecf20Sopenharmony_ci * These states relate to a specific RA / TID.
1158c2ecf20Sopenharmony_ci *
1168c2ecf20Sopenharmony_ci * @IWL_AGG_OFF: aggregation is not used
1178c2ecf20Sopenharmony_ci * @IWL_AGG_STARTING: aggregation are starting (between start and oper)
1188c2ecf20Sopenharmony_ci * @IWL_AGG_ON: aggregation session is up
1198c2ecf20Sopenharmony_ci * @IWL_EMPTYING_HW_QUEUE_ADDBA: establishing a BA session - waiting for the
1208c2ecf20Sopenharmony_ci *	HW queue to be empty from packets for this RA /TID.
1218c2ecf20Sopenharmony_ci * @IWL_EMPTYING_HW_QUEUE_DELBA: tearing down a BA session - waiting for the
1228c2ecf20Sopenharmony_ci *	HW queue to be empty from packets for this RA /TID.
1238c2ecf20Sopenharmony_ci */
1248c2ecf20Sopenharmony_cienum iwl_agg_state {
1258c2ecf20Sopenharmony_ci	IWL_AGG_OFF = 0,
1268c2ecf20Sopenharmony_ci	IWL_AGG_STARTING,
1278c2ecf20Sopenharmony_ci	IWL_AGG_ON,
1288c2ecf20Sopenharmony_ci	IWL_EMPTYING_HW_QUEUE_ADDBA,
1298c2ecf20Sopenharmony_ci	IWL_EMPTYING_HW_QUEUE_DELBA,
1308c2ecf20Sopenharmony_ci};
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci/**
1338c2ecf20Sopenharmony_ci * struct iwl_ht_agg - aggregation state machine
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_ci * This structs holds the states for the BA agreement establishment and tear
1368c2ecf20Sopenharmony_ci * down. It also holds the state during the BA session itself. This struct is
1378c2ecf20Sopenharmony_ci * duplicated for each RA / TID.
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_ci * @rate_n_flags: Rate at which Tx was attempted. Holds the data between the
1408c2ecf20Sopenharmony_ci *	Tx response (REPLY_TX), and the block ack notification
1418c2ecf20Sopenharmony_ci *	(REPLY_COMPRESSED_BA).
1428c2ecf20Sopenharmony_ci * @state: state of the BA agreement establishment / tear down.
1438c2ecf20Sopenharmony_ci * @txq_id: Tx queue used by the BA session
1448c2ecf20Sopenharmony_ci * @ssn: the first packet to be sent in AGG HW queue in Tx AGG start flow, or
1458c2ecf20Sopenharmony_ci *	the first packet to be sent in legacy HW queue in Tx AGG stop flow.
1468c2ecf20Sopenharmony_ci *	Basically when next_reclaimed reaches ssn, we can tell mac80211 that
1478c2ecf20Sopenharmony_ci *	we are ready to finish the Tx AGG stop / start flow.
1488c2ecf20Sopenharmony_ci * @wait_for_ba: Expect block-ack before next Tx reply
1498c2ecf20Sopenharmony_ci */
1508c2ecf20Sopenharmony_cistruct iwl_ht_agg {
1518c2ecf20Sopenharmony_ci	u32 rate_n_flags;
1528c2ecf20Sopenharmony_ci	enum iwl_agg_state state;
1538c2ecf20Sopenharmony_ci	u16 txq_id;
1548c2ecf20Sopenharmony_ci	u16 ssn;
1558c2ecf20Sopenharmony_ci	bool wait_for_ba;
1568c2ecf20Sopenharmony_ci};
1578c2ecf20Sopenharmony_ci
1588c2ecf20Sopenharmony_ci/**
1598c2ecf20Sopenharmony_ci * struct iwl_tid_data - one for each RA / TID
1608c2ecf20Sopenharmony_ci
1618c2ecf20Sopenharmony_ci * This structs holds the states for each RA / TID.
1628c2ecf20Sopenharmony_ci
1638c2ecf20Sopenharmony_ci * @seq_number: the next WiFi sequence number to use
1648c2ecf20Sopenharmony_ci * @next_reclaimed: the WiFi sequence number of the next packet to be acked.
1658c2ecf20Sopenharmony_ci *	This is basically (last acked packet++).
1668c2ecf20Sopenharmony_ci * @agg: aggregation state machine
1678c2ecf20Sopenharmony_ci */
1688c2ecf20Sopenharmony_cistruct iwl_tid_data {
1698c2ecf20Sopenharmony_ci	u16 seq_number;
1708c2ecf20Sopenharmony_ci	u16 next_reclaimed;
1718c2ecf20Sopenharmony_ci	struct iwl_ht_agg agg;
1728c2ecf20Sopenharmony_ci};
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_ci/*
1758c2ecf20Sopenharmony_ci * Structure should be accessed with sta_lock held. When station addition
1768c2ecf20Sopenharmony_ci * is in progress (IWL_STA_UCODE_INPROGRESS) it is possible to access only
1778c2ecf20Sopenharmony_ci * the commands (iwl_addsta_cmd and iwl_link_quality_cmd) without sta_lock
1788c2ecf20Sopenharmony_ci * held.
1798c2ecf20Sopenharmony_ci */
1808c2ecf20Sopenharmony_cistruct iwl_station_entry {
1818c2ecf20Sopenharmony_ci	struct iwl_addsta_cmd sta;
1828c2ecf20Sopenharmony_ci	u8 used, ctxid;
1838c2ecf20Sopenharmony_ci	struct iwl_link_quality_cmd *lq;
1848c2ecf20Sopenharmony_ci};
1858c2ecf20Sopenharmony_ci
1868c2ecf20Sopenharmony_ci/*
1878c2ecf20Sopenharmony_ci * iwl_station_priv: Driver's private station information
1888c2ecf20Sopenharmony_ci *
1898c2ecf20Sopenharmony_ci * When mac80211 creates a station it reserves some space (hw->sta_data_size)
1908c2ecf20Sopenharmony_ci * in the structure for use by driver. This structure is places in that
1918c2ecf20Sopenharmony_ci * space.
1928c2ecf20Sopenharmony_ci */
1938c2ecf20Sopenharmony_cistruct iwl_station_priv {
1948c2ecf20Sopenharmony_ci	struct iwl_rxon_context *ctx;
1958c2ecf20Sopenharmony_ci	struct iwl_lq_sta lq_sta;
1968c2ecf20Sopenharmony_ci	atomic_t pending_frames;
1978c2ecf20Sopenharmony_ci	bool client;
1988c2ecf20Sopenharmony_ci	bool asleep;
1998c2ecf20Sopenharmony_ci	u8 max_agg_bufsize;
2008c2ecf20Sopenharmony_ci	u8 sta_id;
2018c2ecf20Sopenharmony_ci};
2028c2ecf20Sopenharmony_ci
2038c2ecf20Sopenharmony_ci/**
2048c2ecf20Sopenharmony_ci * struct iwl_vif_priv - driver's private per-interface information
2058c2ecf20Sopenharmony_ci *
2068c2ecf20Sopenharmony_ci * When mac80211 allocates a virtual interface, it can allocate
2078c2ecf20Sopenharmony_ci * space for us to put data into.
2088c2ecf20Sopenharmony_ci */
2098c2ecf20Sopenharmony_cistruct iwl_vif_priv {
2108c2ecf20Sopenharmony_ci	struct iwl_rxon_context *ctx;
2118c2ecf20Sopenharmony_ci	u8 ibss_bssid_sta_id;
2128c2ecf20Sopenharmony_ci};
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_cistruct iwl_sensitivity_ranges {
2158c2ecf20Sopenharmony_ci	u16 min_nrg_cck;
2168c2ecf20Sopenharmony_ci
2178c2ecf20Sopenharmony_ci	u16 nrg_th_cck;
2188c2ecf20Sopenharmony_ci	u16 nrg_th_ofdm;
2198c2ecf20Sopenharmony_ci
2208c2ecf20Sopenharmony_ci	u16 auto_corr_min_ofdm;
2218c2ecf20Sopenharmony_ci	u16 auto_corr_min_ofdm_mrc;
2228c2ecf20Sopenharmony_ci	u16 auto_corr_min_ofdm_x1;
2238c2ecf20Sopenharmony_ci	u16 auto_corr_min_ofdm_mrc_x1;
2248c2ecf20Sopenharmony_ci
2258c2ecf20Sopenharmony_ci	u16 auto_corr_max_ofdm;
2268c2ecf20Sopenharmony_ci	u16 auto_corr_max_ofdm_mrc;
2278c2ecf20Sopenharmony_ci	u16 auto_corr_max_ofdm_x1;
2288c2ecf20Sopenharmony_ci	u16 auto_corr_max_ofdm_mrc_x1;
2298c2ecf20Sopenharmony_ci
2308c2ecf20Sopenharmony_ci	u16 auto_corr_max_cck;
2318c2ecf20Sopenharmony_ci	u16 auto_corr_max_cck_mrc;
2328c2ecf20Sopenharmony_ci	u16 auto_corr_min_cck;
2338c2ecf20Sopenharmony_ci	u16 auto_corr_min_cck_mrc;
2348c2ecf20Sopenharmony_ci
2358c2ecf20Sopenharmony_ci	u16 barker_corr_th_min;
2368c2ecf20Sopenharmony_ci	u16 barker_corr_th_min_mrc;
2378c2ecf20Sopenharmony_ci	u16 nrg_th_cca;
2388c2ecf20Sopenharmony_ci};
2398c2ecf20Sopenharmony_ci
2408c2ecf20Sopenharmony_ci/******************************************************************************
2418c2ecf20Sopenharmony_ci *
2428c2ecf20Sopenharmony_ci * Functions implemented in core module which are forward declared here
2438c2ecf20Sopenharmony_ci * for use by iwl-[4-5].c
2448c2ecf20Sopenharmony_ci *
2458c2ecf20Sopenharmony_ci * NOTE:  The implementation of these functions are not hardware specific
2468c2ecf20Sopenharmony_ci * which is why they are in the core module files.
2478c2ecf20Sopenharmony_ci *
2488c2ecf20Sopenharmony_ci * Naming convention --
2498c2ecf20Sopenharmony_ci * iwl_         <-- Is part of iwlwifi
2508c2ecf20Sopenharmony_ci * iwlXXXX_     <-- Hardware specific (implemented in iwl-XXXX.c for XXXX)
2518c2ecf20Sopenharmony_ci *
2528c2ecf20Sopenharmony_ci ****************************************************************************/
2538c2ecf20Sopenharmony_civoid iwl_update_chain_flags(struct iwl_priv *priv);
2548c2ecf20Sopenharmony_ciextern const u8 iwl_bcast_addr[ETH_ALEN];
2558c2ecf20Sopenharmony_ci
2568c2ecf20Sopenharmony_ci#define IWL_OPERATION_MODE_AUTO     0
2578c2ecf20Sopenharmony_ci#define IWL_OPERATION_MODE_HT_ONLY  1
2588c2ecf20Sopenharmony_ci#define IWL_OPERATION_MODE_MIXED    2
2598c2ecf20Sopenharmony_ci#define IWL_OPERATION_MODE_20MHZ    3
2608c2ecf20Sopenharmony_ci
2618c2ecf20Sopenharmony_ci#define TX_POWER_IWL_ILLEGAL_VOLTAGE -10000
2628c2ecf20Sopenharmony_ci
2638c2ecf20Sopenharmony_ci/* Sensitivity and chain noise calibration */
2648c2ecf20Sopenharmony_ci#define INITIALIZATION_VALUE		0xFFFF
2658c2ecf20Sopenharmony_ci#define IWL_CAL_NUM_BEACONS		16
2668c2ecf20Sopenharmony_ci#define MAXIMUM_ALLOWED_PATHLOSS	15
2678c2ecf20Sopenharmony_ci
2688c2ecf20Sopenharmony_ci#define CHAIN_NOISE_MAX_DELTA_GAIN_CODE 3
2698c2ecf20Sopenharmony_ci
2708c2ecf20Sopenharmony_ci#define MAX_FA_OFDM  50
2718c2ecf20Sopenharmony_ci#define MIN_FA_OFDM  5
2728c2ecf20Sopenharmony_ci#define MAX_FA_CCK   50
2738c2ecf20Sopenharmony_ci#define MIN_FA_CCK   5
2748c2ecf20Sopenharmony_ci
2758c2ecf20Sopenharmony_ci#define AUTO_CORR_STEP_OFDM       1
2768c2ecf20Sopenharmony_ci
2778c2ecf20Sopenharmony_ci#define AUTO_CORR_STEP_CCK     3
2788c2ecf20Sopenharmony_ci#define AUTO_CORR_MAX_TH_CCK   160
2798c2ecf20Sopenharmony_ci
2808c2ecf20Sopenharmony_ci#define NRG_DIFF               2
2818c2ecf20Sopenharmony_ci#define NRG_STEP_CCK           2
2828c2ecf20Sopenharmony_ci#define NRG_MARGIN             8
2838c2ecf20Sopenharmony_ci#define MAX_NUMBER_CCK_NO_FA 100
2848c2ecf20Sopenharmony_ci
2858c2ecf20Sopenharmony_ci#define AUTO_CORR_CCK_MIN_VAL_DEF    (125)
2868c2ecf20Sopenharmony_ci
2878c2ecf20Sopenharmony_ci#define CHAIN_A             0
2888c2ecf20Sopenharmony_ci#define CHAIN_B             1
2898c2ecf20Sopenharmony_ci#define CHAIN_C             2
2908c2ecf20Sopenharmony_ci#define CHAIN_NOISE_DELTA_GAIN_INIT_VAL 4
2918c2ecf20Sopenharmony_ci#define ALL_BAND_FILTER			0xFF00
2928c2ecf20Sopenharmony_ci#define IN_BAND_FILTER			0xFF
2938c2ecf20Sopenharmony_ci#define MIN_AVERAGE_NOISE_MAX_VALUE	0xFFFFFFFF
2948c2ecf20Sopenharmony_ci
2958c2ecf20Sopenharmony_ci#define NRG_NUM_PREV_STAT_L     20
2968c2ecf20Sopenharmony_ci#define NUM_RX_CHAINS           3
2978c2ecf20Sopenharmony_ci
2988c2ecf20Sopenharmony_cienum iwlagn_false_alarm_state {
2998c2ecf20Sopenharmony_ci	IWL_FA_TOO_MANY = 0,
3008c2ecf20Sopenharmony_ci	IWL_FA_TOO_FEW = 1,
3018c2ecf20Sopenharmony_ci	IWL_FA_GOOD_RANGE = 2,
3028c2ecf20Sopenharmony_ci};
3038c2ecf20Sopenharmony_ci
3048c2ecf20Sopenharmony_cienum iwlagn_chain_noise_state {
3058c2ecf20Sopenharmony_ci	IWL_CHAIN_NOISE_ALIVE = 0,  /* must be 0 */
3068c2ecf20Sopenharmony_ci	IWL_CHAIN_NOISE_ACCUMULATE,
3078c2ecf20Sopenharmony_ci	IWL_CHAIN_NOISE_CALIBRATED,
3088c2ecf20Sopenharmony_ci	IWL_CHAIN_NOISE_DONE,
3098c2ecf20Sopenharmony_ci};
3108c2ecf20Sopenharmony_ci
3118c2ecf20Sopenharmony_ci/* Sensitivity calib data */
3128c2ecf20Sopenharmony_cistruct iwl_sensitivity_data {
3138c2ecf20Sopenharmony_ci	u32 auto_corr_ofdm;
3148c2ecf20Sopenharmony_ci	u32 auto_corr_ofdm_mrc;
3158c2ecf20Sopenharmony_ci	u32 auto_corr_ofdm_x1;
3168c2ecf20Sopenharmony_ci	u32 auto_corr_ofdm_mrc_x1;
3178c2ecf20Sopenharmony_ci	u32 auto_corr_cck;
3188c2ecf20Sopenharmony_ci	u32 auto_corr_cck_mrc;
3198c2ecf20Sopenharmony_ci
3208c2ecf20Sopenharmony_ci	u32 last_bad_plcp_cnt_ofdm;
3218c2ecf20Sopenharmony_ci	u32 last_fa_cnt_ofdm;
3228c2ecf20Sopenharmony_ci	u32 last_bad_plcp_cnt_cck;
3238c2ecf20Sopenharmony_ci	u32 last_fa_cnt_cck;
3248c2ecf20Sopenharmony_ci
3258c2ecf20Sopenharmony_ci	u32 nrg_curr_state;
3268c2ecf20Sopenharmony_ci	u32 nrg_prev_state;
3278c2ecf20Sopenharmony_ci	u32 nrg_value[10];
3288c2ecf20Sopenharmony_ci	u8  nrg_silence_rssi[NRG_NUM_PREV_STAT_L];
3298c2ecf20Sopenharmony_ci	u32 nrg_silence_ref;
3308c2ecf20Sopenharmony_ci	u32 nrg_energy_idx;
3318c2ecf20Sopenharmony_ci	u32 nrg_silence_idx;
3328c2ecf20Sopenharmony_ci	u32 nrg_th_cck;
3338c2ecf20Sopenharmony_ci	s32 nrg_auto_corr_silence_diff;
3348c2ecf20Sopenharmony_ci	u32 num_in_cck_no_fa;
3358c2ecf20Sopenharmony_ci	u32 nrg_th_ofdm;
3368c2ecf20Sopenharmony_ci
3378c2ecf20Sopenharmony_ci	u16 barker_corr_th_min;
3388c2ecf20Sopenharmony_ci	u16 barker_corr_th_min_mrc;
3398c2ecf20Sopenharmony_ci	u16 nrg_th_cca;
3408c2ecf20Sopenharmony_ci};
3418c2ecf20Sopenharmony_ci
3428c2ecf20Sopenharmony_ci/* Chain noise (differential Rx gain) calib data */
3438c2ecf20Sopenharmony_cistruct iwl_chain_noise_data {
3448c2ecf20Sopenharmony_ci	u32 active_chains;
3458c2ecf20Sopenharmony_ci	u32 chain_noise_a;
3468c2ecf20Sopenharmony_ci	u32 chain_noise_b;
3478c2ecf20Sopenharmony_ci	u32 chain_noise_c;
3488c2ecf20Sopenharmony_ci	u32 chain_signal_a;
3498c2ecf20Sopenharmony_ci	u32 chain_signal_b;
3508c2ecf20Sopenharmony_ci	u32 chain_signal_c;
3518c2ecf20Sopenharmony_ci	u16 beacon_count;
3528c2ecf20Sopenharmony_ci	u8 disconn_array[NUM_RX_CHAINS];
3538c2ecf20Sopenharmony_ci	u8 delta_gain_code[NUM_RX_CHAINS];
3548c2ecf20Sopenharmony_ci	u8 radio_write;
3558c2ecf20Sopenharmony_ci	u8 state;
3568c2ecf20Sopenharmony_ci};
3578c2ecf20Sopenharmony_ci
3588c2ecf20Sopenharmony_cienum {
3598c2ecf20Sopenharmony_ci	MEASUREMENT_READY = (1 << 0),
3608c2ecf20Sopenharmony_ci	MEASUREMENT_ACTIVE = (1 << 1),
3618c2ecf20Sopenharmony_ci};
3628c2ecf20Sopenharmony_ci
3638c2ecf20Sopenharmony_ci/* reply_tx_statistics (for _agn devices) */
3648c2ecf20Sopenharmony_cistruct reply_tx_error_statistics {
3658c2ecf20Sopenharmony_ci	u32 pp_delay;
3668c2ecf20Sopenharmony_ci	u32 pp_few_bytes;
3678c2ecf20Sopenharmony_ci	u32 pp_bt_prio;
3688c2ecf20Sopenharmony_ci	u32 pp_quiet_period;
3698c2ecf20Sopenharmony_ci	u32 pp_calc_ttak;
3708c2ecf20Sopenharmony_ci	u32 int_crossed_retry;
3718c2ecf20Sopenharmony_ci	u32 short_limit;
3728c2ecf20Sopenharmony_ci	u32 long_limit;
3738c2ecf20Sopenharmony_ci	u32 fifo_underrun;
3748c2ecf20Sopenharmony_ci	u32 drain_flow;
3758c2ecf20Sopenharmony_ci	u32 rfkill_flush;
3768c2ecf20Sopenharmony_ci	u32 life_expire;
3778c2ecf20Sopenharmony_ci	u32 dest_ps;
3788c2ecf20Sopenharmony_ci	u32 host_abort;
3798c2ecf20Sopenharmony_ci	u32 bt_retry;
3808c2ecf20Sopenharmony_ci	u32 sta_invalid;
3818c2ecf20Sopenharmony_ci	u32 frag_drop;
3828c2ecf20Sopenharmony_ci	u32 tid_disable;
3838c2ecf20Sopenharmony_ci	u32 fifo_flush;
3848c2ecf20Sopenharmony_ci	u32 insuff_cf_poll;
3858c2ecf20Sopenharmony_ci	u32 fail_hw_drop;
3868c2ecf20Sopenharmony_ci	u32 sta_color_mismatch;
3878c2ecf20Sopenharmony_ci	u32 unknown;
3888c2ecf20Sopenharmony_ci};
3898c2ecf20Sopenharmony_ci
3908c2ecf20Sopenharmony_ci/* reply_agg_tx_statistics (for _agn devices) */
3918c2ecf20Sopenharmony_cistruct reply_agg_tx_error_statistics {
3928c2ecf20Sopenharmony_ci	u32 underrun;
3938c2ecf20Sopenharmony_ci	u32 bt_prio;
3948c2ecf20Sopenharmony_ci	u32 few_bytes;
3958c2ecf20Sopenharmony_ci	u32 abort;
3968c2ecf20Sopenharmony_ci	u32 last_sent_ttl;
3978c2ecf20Sopenharmony_ci	u32 last_sent_try;
3988c2ecf20Sopenharmony_ci	u32 last_sent_bt_kill;
3998c2ecf20Sopenharmony_ci	u32 scd_query;
4008c2ecf20Sopenharmony_ci	u32 bad_crc32;
4018c2ecf20Sopenharmony_ci	u32 response;
4028c2ecf20Sopenharmony_ci	u32 dump_tx;
4038c2ecf20Sopenharmony_ci	u32 delay_tx;
4048c2ecf20Sopenharmony_ci	u32 unknown;
4058c2ecf20Sopenharmony_ci};
4068c2ecf20Sopenharmony_ci
4078c2ecf20Sopenharmony_ci/*
4088c2ecf20Sopenharmony_ci * schedule the timer to wake up every UCODE_TRACE_PERIOD milliseconds
4098c2ecf20Sopenharmony_ci * to perform continuous uCode event logging operation if enabled
4108c2ecf20Sopenharmony_ci */
4118c2ecf20Sopenharmony_ci#define UCODE_TRACE_PERIOD (10)
4128c2ecf20Sopenharmony_ci
4138c2ecf20Sopenharmony_ci/*
4148c2ecf20Sopenharmony_ci * iwl_event_log: current uCode event log position
4158c2ecf20Sopenharmony_ci *
4168c2ecf20Sopenharmony_ci * @ucode_trace: enable/disable ucode continuous trace timer
4178c2ecf20Sopenharmony_ci * @num_wraps: how many times the event buffer wraps
4188c2ecf20Sopenharmony_ci * @next_entry:  the entry just before the next one that uCode would fill
4198c2ecf20Sopenharmony_ci * @non_wraps_count: counter for no wrap detected when dump ucode events
4208c2ecf20Sopenharmony_ci * @wraps_once_count: counter for wrap once detected when dump ucode events
4218c2ecf20Sopenharmony_ci * @wraps_more_count: counter for wrap more than once detected
4228c2ecf20Sopenharmony_ci *		      when dump ucode events
4238c2ecf20Sopenharmony_ci */
4248c2ecf20Sopenharmony_cistruct iwl_event_log {
4258c2ecf20Sopenharmony_ci	bool ucode_trace;
4268c2ecf20Sopenharmony_ci	u32 num_wraps;
4278c2ecf20Sopenharmony_ci	u32 next_entry;
4288c2ecf20Sopenharmony_ci	int non_wraps_count;
4298c2ecf20Sopenharmony_ci	int wraps_once_count;
4308c2ecf20Sopenharmony_ci	int wraps_more_count;
4318c2ecf20Sopenharmony_ci};
4328c2ecf20Sopenharmony_ci
4338c2ecf20Sopenharmony_ci#define IWL_DELAY_NEXT_FORCE_RF_RESET  (HZ*3)
4348c2ecf20Sopenharmony_ci
4358c2ecf20Sopenharmony_ci/* BT Antenna Coupling Threshold (dB) */
4368c2ecf20Sopenharmony_ci#define IWL_BT_ANTENNA_COUPLING_THRESHOLD	(35)
4378c2ecf20Sopenharmony_ci
4388c2ecf20Sopenharmony_ci/* Firmware reload counter and Timestamp */
4398c2ecf20Sopenharmony_ci#define IWL_MIN_RELOAD_DURATION		1000 /* 1000 ms */
4408c2ecf20Sopenharmony_ci#define IWL_MAX_CONTINUE_RELOAD_CNT	4
4418c2ecf20Sopenharmony_ci
4428c2ecf20Sopenharmony_ci
4438c2ecf20Sopenharmony_cistruct iwl_rf_reset {
4448c2ecf20Sopenharmony_ci	int reset_request_count;
4458c2ecf20Sopenharmony_ci	int reset_success_count;
4468c2ecf20Sopenharmony_ci	int reset_reject_count;
4478c2ecf20Sopenharmony_ci	unsigned long last_reset_jiffies;
4488c2ecf20Sopenharmony_ci};
4498c2ecf20Sopenharmony_ci
4508c2ecf20Sopenharmony_cienum iwl_rxon_context_id {
4518c2ecf20Sopenharmony_ci	IWL_RXON_CTX_BSS,
4528c2ecf20Sopenharmony_ci	IWL_RXON_CTX_PAN,
4538c2ecf20Sopenharmony_ci
4548c2ecf20Sopenharmony_ci	NUM_IWL_RXON_CTX
4558c2ecf20Sopenharmony_ci};
4568c2ecf20Sopenharmony_ci
4578c2ecf20Sopenharmony_ci/* extend beacon time format bit shifting  */
4588c2ecf20Sopenharmony_ci/*
4598c2ecf20Sopenharmony_ci * for _agn devices
4608c2ecf20Sopenharmony_ci * bits 31:22 - extended
4618c2ecf20Sopenharmony_ci * bits 21:0  - interval
4628c2ecf20Sopenharmony_ci */
4638c2ecf20Sopenharmony_ci#define IWLAGN_EXT_BEACON_TIME_POS	22
4648c2ecf20Sopenharmony_ci
4658c2ecf20Sopenharmony_cistruct iwl_rxon_context {
4668c2ecf20Sopenharmony_ci	struct ieee80211_vif *vif;
4678c2ecf20Sopenharmony_ci
4688c2ecf20Sopenharmony_ci	u8 mcast_queue;
4698c2ecf20Sopenharmony_ci	u8 ac_to_queue[IEEE80211_NUM_ACS];
4708c2ecf20Sopenharmony_ci	u8 ac_to_fifo[IEEE80211_NUM_ACS];
4718c2ecf20Sopenharmony_ci
4728c2ecf20Sopenharmony_ci	/*
4738c2ecf20Sopenharmony_ci	 * We could use the vif to indicate active, but we
4748c2ecf20Sopenharmony_ci	 * also need it to be active during disabling when
4758c2ecf20Sopenharmony_ci	 * we already removed the vif for type setting.
4768c2ecf20Sopenharmony_ci	 */
4778c2ecf20Sopenharmony_ci	bool always_active, is_active;
4788c2ecf20Sopenharmony_ci
4798c2ecf20Sopenharmony_ci	bool ht_need_multiple_chains;
4808c2ecf20Sopenharmony_ci
4818c2ecf20Sopenharmony_ci	enum iwl_rxon_context_id ctxid;
4828c2ecf20Sopenharmony_ci
4838c2ecf20Sopenharmony_ci	u32 interface_modes, exclusive_interface_modes;
4848c2ecf20Sopenharmony_ci	u8 unused_devtype, ap_devtype, ibss_devtype, station_devtype;
4858c2ecf20Sopenharmony_ci
4868c2ecf20Sopenharmony_ci	/*
4878c2ecf20Sopenharmony_ci	 * We declare this const so it can only be
4888c2ecf20Sopenharmony_ci	 * changed via explicit cast within the
4898c2ecf20Sopenharmony_ci	 * routines that actually update the physical
4908c2ecf20Sopenharmony_ci	 * hardware.
4918c2ecf20Sopenharmony_ci	 */
4928c2ecf20Sopenharmony_ci	const struct iwl_rxon_cmd active;
4938c2ecf20Sopenharmony_ci	struct iwl_rxon_cmd staging;
4948c2ecf20Sopenharmony_ci
4958c2ecf20Sopenharmony_ci	struct iwl_rxon_time_cmd timing;
4968c2ecf20Sopenharmony_ci
4978c2ecf20Sopenharmony_ci	struct iwl_qos_info qos_data;
4988c2ecf20Sopenharmony_ci
4998c2ecf20Sopenharmony_ci	u8 bcast_sta_id, ap_sta_id;
5008c2ecf20Sopenharmony_ci
5018c2ecf20Sopenharmony_ci	u8 rxon_cmd, rxon_assoc_cmd, rxon_timing_cmd;
5028c2ecf20Sopenharmony_ci	u8 qos_cmd;
5038c2ecf20Sopenharmony_ci	u8 wep_key_cmd;
5048c2ecf20Sopenharmony_ci
5058c2ecf20Sopenharmony_ci	struct iwl_wep_key wep_keys[WEP_KEYS_MAX];
5068c2ecf20Sopenharmony_ci	u8 key_mapping_keys;
5078c2ecf20Sopenharmony_ci
5088c2ecf20Sopenharmony_ci	__le32 station_flags;
5098c2ecf20Sopenharmony_ci
5108c2ecf20Sopenharmony_ci	int beacon_int;
5118c2ecf20Sopenharmony_ci
5128c2ecf20Sopenharmony_ci	struct {
5138c2ecf20Sopenharmony_ci		bool non_gf_sta_present;
5148c2ecf20Sopenharmony_ci		u8 protection;
5158c2ecf20Sopenharmony_ci		bool enabled, is_40mhz;
5168c2ecf20Sopenharmony_ci		u8 extension_chan_offset;
5178c2ecf20Sopenharmony_ci	} ht;
5188c2ecf20Sopenharmony_ci};
5198c2ecf20Sopenharmony_ci
5208c2ecf20Sopenharmony_cienum iwl_scan_type {
5218c2ecf20Sopenharmony_ci	IWL_SCAN_NORMAL,
5228c2ecf20Sopenharmony_ci	IWL_SCAN_RADIO_RESET,
5238c2ecf20Sopenharmony_ci};
5248c2ecf20Sopenharmony_ci
5258c2ecf20Sopenharmony_ci/**
5268c2ecf20Sopenharmony_ci * struct iwl_hw_params
5278c2ecf20Sopenharmony_ci *
5288c2ecf20Sopenharmony_ci * Holds the module parameters
5298c2ecf20Sopenharmony_ci *
5308c2ecf20Sopenharmony_ci * @tx_chains_num: Number of TX chains
5318c2ecf20Sopenharmony_ci * @rx_chains_num: Number of RX chains
5328c2ecf20Sopenharmony_ci * @ct_kill_threshold: temperature threshold - in hw dependent unit
5338c2ecf20Sopenharmony_ci * @ct_kill_exit_threshold: when to reeable the device - in hw dependent unit
5348c2ecf20Sopenharmony_ci *	relevant for 1000, 6000 and up
5358c2ecf20Sopenharmony_ci * @struct iwl_sensitivity_ranges: range of sensitivity values
5368c2ecf20Sopenharmony_ci * @use_rts_for_aggregation: use rts/cts protection for HT traffic
5378c2ecf20Sopenharmony_ci */
5388c2ecf20Sopenharmony_cistruct iwl_hw_params {
5398c2ecf20Sopenharmony_ci	u8  tx_chains_num;
5408c2ecf20Sopenharmony_ci	u8  rx_chains_num;
5418c2ecf20Sopenharmony_ci	bool use_rts_for_aggregation;
5428c2ecf20Sopenharmony_ci	u32 ct_kill_threshold;
5438c2ecf20Sopenharmony_ci	u32 ct_kill_exit_threshold;
5448c2ecf20Sopenharmony_ci
5458c2ecf20Sopenharmony_ci	const struct iwl_sensitivity_ranges *sens;
5468c2ecf20Sopenharmony_ci};
5478c2ecf20Sopenharmony_ci
5488c2ecf20Sopenharmony_ci/**
5498c2ecf20Sopenharmony_ci * struct iwl_dvm_bt_params - DVM specific BT (coex) parameters
5508c2ecf20Sopenharmony_ci * @advanced_bt_coexist: support advanced bt coexist
5518c2ecf20Sopenharmony_ci * @bt_init_traffic_load: specify initial bt traffic load
5528c2ecf20Sopenharmony_ci * @bt_prio_boost: default bt priority boost value
5538c2ecf20Sopenharmony_ci * @agg_time_limit: maximum number of uSec in aggregation
5548c2ecf20Sopenharmony_ci * @bt_sco_disable: uCode should not response to BT in SCO/ESCO mode
5558c2ecf20Sopenharmony_ci */
5568c2ecf20Sopenharmony_cistruct iwl_dvm_bt_params {
5578c2ecf20Sopenharmony_ci	bool advanced_bt_coexist;
5588c2ecf20Sopenharmony_ci	u8 bt_init_traffic_load;
5598c2ecf20Sopenharmony_ci	u32 bt_prio_boost;
5608c2ecf20Sopenharmony_ci	u16 agg_time_limit;
5618c2ecf20Sopenharmony_ci	bool bt_sco_disable;
5628c2ecf20Sopenharmony_ci	bool bt_session_2;
5638c2ecf20Sopenharmony_ci};
5648c2ecf20Sopenharmony_ci
5658c2ecf20Sopenharmony_ci/**
5668c2ecf20Sopenharmony_ci * struct iwl_dvm_cfg - DVM firmware specific device configuration
5678c2ecf20Sopenharmony_ci * @set_hw_params: set hardware parameters
5688c2ecf20Sopenharmony_ci * @set_channel_switch: send channel switch command
5698c2ecf20Sopenharmony_ci * @nic_config: apply device specific configuration
5708c2ecf20Sopenharmony_ci * @temperature: read temperature
5718c2ecf20Sopenharmony_ci * @adv_thermal_throttle: support advance thermal throttle
5728c2ecf20Sopenharmony_ci * @support_ct_kill_exit: support ct kill exit condition
5738c2ecf20Sopenharmony_ci * @plcp_delta_threshold: plcp error rate threshold used to trigger
5748c2ecf20Sopenharmony_ci *	radio tuning when there is a high receiving plcp error rate
5758c2ecf20Sopenharmony_ci * @chain_noise_scale: default chain noise scale used for gain computation
5768c2ecf20Sopenharmony_ci * @hd_v2: v2 of enhanced sensitivity value, used for 2000 series and up
5778c2ecf20Sopenharmony_ci * @no_idle_support: do not support idle mode
5788c2ecf20Sopenharmony_ci * @bt_params: pointer to BT parameters
5798c2ecf20Sopenharmony_ci * @need_temp_offset_calib: need to perform temperature offset calibration
5808c2ecf20Sopenharmony_ci * @no_xtal_calib: some devices do not need crystal calibration data,
5818c2ecf20Sopenharmony_ci *	don't send it to those
5828c2ecf20Sopenharmony_ci * @temp_offset_v2: support v2 of temperature offset calibration
5838c2ecf20Sopenharmony_ci * @adv_pm: advanced power management
5848c2ecf20Sopenharmony_ci */
5858c2ecf20Sopenharmony_cistruct iwl_dvm_cfg {
5868c2ecf20Sopenharmony_ci	void (*set_hw_params)(struct iwl_priv *priv);
5878c2ecf20Sopenharmony_ci	int (*set_channel_switch)(struct iwl_priv *priv,
5888c2ecf20Sopenharmony_ci				  struct ieee80211_channel_switch *ch_switch);
5898c2ecf20Sopenharmony_ci	void (*nic_config)(struct iwl_priv *priv);
5908c2ecf20Sopenharmony_ci	void (*temperature)(struct iwl_priv *priv);
5918c2ecf20Sopenharmony_ci
5928c2ecf20Sopenharmony_ci	const struct iwl_dvm_bt_params *bt_params;
5938c2ecf20Sopenharmony_ci	s32 chain_noise_scale;
5948c2ecf20Sopenharmony_ci	u8 plcp_delta_threshold;
5958c2ecf20Sopenharmony_ci	bool adv_thermal_throttle;
5968c2ecf20Sopenharmony_ci	bool support_ct_kill_exit;
5978c2ecf20Sopenharmony_ci	bool hd_v2;
5988c2ecf20Sopenharmony_ci	bool no_idle_support;
5998c2ecf20Sopenharmony_ci	bool need_temp_offset_calib;
6008c2ecf20Sopenharmony_ci	bool no_xtal_calib;
6018c2ecf20Sopenharmony_ci	bool temp_offset_v2;
6028c2ecf20Sopenharmony_ci	bool adv_pm;
6038c2ecf20Sopenharmony_ci};
6048c2ecf20Sopenharmony_ci
6058c2ecf20Sopenharmony_cistruct iwl_wipan_noa_data {
6068c2ecf20Sopenharmony_ci	struct rcu_head rcu_head;
6078c2ecf20Sopenharmony_ci	u32 length;
6088c2ecf20Sopenharmony_ci	u8 data[];
6098c2ecf20Sopenharmony_ci};
6108c2ecf20Sopenharmony_ci
6118c2ecf20Sopenharmony_ci/* Calibration disabling bit mask */
6128c2ecf20Sopenharmony_cienum {
6138c2ecf20Sopenharmony_ci	IWL_CALIB_ENABLE_ALL			= 0,
6148c2ecf20Sopenharmony_ci
6158c2ecf20Sopenharmony_ci	IWL_SENSITIVITY_CALIB_DISABLED		= BIT(0),
6168c2ecf20Sopenharmony_ci	IWL_CHAIN_NOISE_CALIB_DISABLED		= BIT(1),
6178c2ecf20Sopenharmony_ci	IWL_TX_POWER_CALIB_DISABLED		= BIT(2),
6188c2ecf20Sopenharmony_ci
6198c2ecf20Sopenharmony_ci	IWL_CALIB_DISABLE_ALL			= 0xFFFFFFFF,
6208c2ecf20Sopenharmony_ci};
6218c2ecf20Sopenharmony_ci
6228c2ecf20Sopenharmony_ci#define IWL_OP_MODE_GET_DVM(_iwl_op_mode) \
6238c2ecf20Sopenharmony_ci	((struct iwl_priv *) ((_iwl_op_mode)->op_mode_specific))
6248c2ecf20Sopenharmony_ci
6258c2ecf20Sopenharmony_ci#define IWL_MAC80211_GET_DVM(_hw) \
6268c2ecf20Sopenharmony_ci	((struct iwl_priv *) ((struct iwl_op_mode *) \
6278c2ecf20Sopenharmony_ci	(_hw)->priv)->op_mode_specific)
6288c2ecf20Sopenharmony_ci
6298c2ecf20Sopenharmony_cistruct iwl_priv {
6308c2ecf20Sopenharmony_ci
6318c2ecf20Sopenharmony_ci	struct iwl_trans *trans;
6328c2ecf20Sopenharmony_ci	struct device *dev;		/* for debug prints only */
6338c2ecf20Sopenharmony_ci	const struct iwl_cfg *cfg;
6348c2ecf20Sopenharmony_ci	const struct iwl_fw *fw;
6358c2ecf20Sopenharmony_ci	const struct iwl_dvm_cfg *lib;
6368c2ecf20Sopenharmony_ci	unsigned long status;
6378c2ecf20Sopenharmony_ci
6388c2ecf20Sopenharmony_ci	spinlock_t sta_lock;
6398c2ecf20Sopenharmony_ci	struct mutex mutex;
6408c2ecf20Sopenharmony_ci
6418c2ecf20Sopenharmony_ci	unsigned long transport_queue_stop;
6428c2ecf20Sopenharmony_ci	bool passive_no_rx;
6438c2ecf20Sopenharmony_ci#define IWL_INVALID_MAC80211_QUEUE	0xff
6448c2ecf20Sopenharmony_ci	u8 queue_to_mac80211[IWL_MAX_HW_QUEUES];
6458c2ecf20Sopenharmony_ci	atomic_t queue_stop_count[IWL_MAX_HW_QUEUES];
6468c2ecf20Sopenharmony_ci
6478c2ecf20Sopenharmony_ci	unsigned long agg_q_alloc[BITS_TO_LONGS(IWL_MAX_HW_QUEUES)];
6488c2ecf20Sopenharmony_ci
6498c2ecf20Sopenharmony_ci	/* ieee device used by generic ieee processing code */
6508c2ecf20Sopenharmony_ci	struct ieee80211_hw *hw;
6518c2ecf20Sopenharmony_ci
6528c2ecf20Sopenharmony_ci	struct napi_struct *napi;
6538c2ecf20Sopenharmony_ci
6548c2ecf20Sopenharmony_ci	struct list_head calib_results;
6558c2ecf20Sopenharmony_ci
6568c2ecf20Sopenharmony_ci	struct workqueue_struct *workqueue;
6578c2ecf20Sopenharmony_ci
6588c2ecf20Sopenharmony_ci	struct iwl_hw_params hw_params;
6598c2ecf20Sopenharmony_ci
6608c2ecf20Sopenharmony_ci	enum nl80211_band band;
6618c2ecf20Sopenharmony_ci	u8 valid_contexts;
6628c2ecf20Sopenharmony_ci
6638c2ecf20Sopenharmony_ci	void (*rx_handlers[REPLY_MAX])(struct iwl_priv *priv,
6648c2ecf20Sopenharmony_ci				       struct iwl_rx_cmd_buffer *rxb);
6658c2ecf20Sopenharmony_ci
6668c2ecf20Sopenharmony_ci	struct iwl_notif_wait_data notif_wait;
6678c2ecf20Sopenharmony_ci
6688c2ecf20Sopenharmony_ci	/* spectrum measurement report caching */
6698c2ecf20Sopenharmony_ci	struct iwl_spectrum_notification measure_report;
6708c2ecf20Sopenharmony_ci	u8 measurement_status;
6718c2ecf20Sopenharmony_ci
6728c2ecf20Sopenharmony_ci	/* ucode beacon time */
6738c2ecf20Sopenharmony_ci	u32 ucode_beacon_time;
6748c2ecf20Sopenharmony_ci	int missed_beacon_threshold;
6758c2ecf20Sopenharmony_ci
6768c2ecf20Sopenharmony_ci	/* track IBSS manager (last beacon) status */
6778c2ecf20Sopenharmony_ci	u32 ibss_manager;
6788c2ecf20Sopenharmony_ci
6798c2ecf20Sopenharmony_ci	/* jiffies when last recovery from statistics was performed */
6808c2ecf20Sopenharmony_ci	unsigned long rx_statistics_jiffies;
6818c2ecf20Sopenharmony_ci
6828c2ecf20Sopenharmony_ci	/*counters */
6838c2ecf20Sopenharmony_ci	u32 rx_handlers_stats[REPLY_MAX];
6848c2ecf20Sopenharmony_ci
6858c2ecf20Sopenharmony_ci	/* rf reset */
6868c2ecf20Sopenharmony_ci	struct iwl_rf_reset rf_reset;
6878c2ecf20Sopenharmony_ci
6888c2ecf20Sopenharmony_ci	/* firmware reload counter and timestamp */
6898c2ecf20Sopenharmony_ci	unsigned long reload_jiffies;
6908c2ecf20Sopenharmony_ci	int reload_count;
6918c2ecf20Sopenharmony_ci	bool ucode_loaded;
6928c2ecf20Sopenharmony_ci
6938c2ecf20Sopenharmony_ci	u8 plcp_delta_threshold;
6948c2ecf20Sopenharmony_ci
6958c2ecf20Sopenharmony_ci	/* thermal calibration */
6968c2ecf20Sopenharmony_ci	s32 temperature;	/* Celsius */
6978c2ecf20Sopenharmony_ci	s32 last_temperature;
6988c2ecf20Sopenharmony_ci
6998c2ecf20Sopenharmony_ci	struct iwl_wipan_noa_data __rcu *noa_data;
7008c2ecf20Sopenharmony_ci
7018c2ecf20Sopenharmony_ci	/* Scan related variables */
7028c2ecf20Sopenharmony_ci	unsigned long scan_start;
7038c2ecf20Sopenharmony_ci	unsigned long scan_start_tsf;
7048c2ecf20Sopenharmony_ci	void *scan_cmd;
7058c2ecf20Sopenharmony_ci	enum nl80211_band scan_band;
7068c2ecf20Sopenharmony_ci	struct cfg80211_scan_request *scan_request;
7078c2ecf20Sopenharmony_ci	struct ieee80211_vif *scan_vif;
7088c2ecf20Sopenharmony_ci	enum iwl_scan_type scan_type;
7098c2ecf20Sopenharmony_ci	u8 scan_tx_ant[NUM_NL80211_BANDS];
7108c2ecf20Sopenharmony_ci	u8 mgmt_tx_ant;
7118c2ecf20Sopenharmony_ci
7128c2ecf20Sopenharmony_ci	/* max number of station keys */
7138c2ecf20Sopenharmony_ci	u8 sta_key_max_num;
7148c2ecf20Sopenharmony_ci
7158c2ecf20Sopenharmony_ci	bool new_scan_threshold_behaviour;
7168c2ecf20Sopenharmony_ci
7178c2ecf20Sopenharmony_ci	bool wowlan;
7188c2ecf20Sopenharmony_ci
7198c2ecf20Sopenharmony_ci	/* EEPROM MAC addresses */
7208c2ecf20Sopenharmony_ci	struct mac_address addresses[2];
7218c2ecf20Sopenharmony_ci
7228c2ecf20Sopenharmony_ci	struct iwl_rxon_context contexts[NUM_IWL_RXON_CTX];
7238c2ecf20Sopenharmony_ci
7248c2ecf20Sopenharmony_ci	__le16 switch_channel;
7258c2ecf20Sopenharmony_ci
7268c2ecf20Sopenharmony_ci	u8 start_calib;
7278c2ecf20Sopenharmony_ci	struct iwl_sensitivity_data sensitivity_data;
7288c2ecf20Sopenharmony_ci	struct iwl_chain_noise_data chain_noise_data;
7298c2ecf20Sopenharmony_ci	__le16 sensitivity_tbl[HD_TABLE_SIZE];
7308c2ecf20Sopenharmony_ci	__le16 enhance_sensitivity_tbl[ENHANCE_HD_TABLE_ENTRIES];
7318c2ecf20Sopenharmony_ci
7328c2ecf20Sopenharmony_ci	struct iwl_ht_config current_ht_config;
7338c2ecf20Sopenharmony_ci
7348c2ecf20Sopenharmony_ci	/* Rate scaling data */
7358c2ecf20Sopenharmony_ci	u8 retry_rate;
7368c2ecf20Sopenharmony_ci
7378c2ecf20Sopenharmony_ci	int activity_timer_active;
7388c2ecf20Sopenharmony_ci
7398c2ecf20Sopenharmony_ci	struct iwl_power_mgr power_data;
7408c2ecf20Sopenharmony_ci	struct iwl_tt_mgmt thermal_throttle;
7418c2ecf20Sopenharmony_ci
7428c2ecf20Sopenharmony_ci	/* station table variables */
7438c2ecf20Sopenharmony_ci	int num_stations;
7448c2ecf20Sopenharmony_ci	struct iwl_station_entry stations[IWLAGN_STATION_COUNT];
7458c2ecf20Sopenharmony_ci	unsigned long ucode_key_table;
7468c2ecf20Sopenharmony_ci	struct iwl_tid_data tid_data[IWLAGN_STATION_COUNT][IWL_MAX_TID_COUNT];
7478c2ecf20Sopenharmony_ci	atomic_t num_aux_in_flight;
7488c2ecf20Sopenharmony_ci
7498c2ecf20Sopenharmony_ci	u8 mac80211_registered;
7508c2ecf20Sopenharmony_ci
7518c2ecf20Sopenharmony_ci	/* Indication if ieee80211_ops->open has been called */
7528c2ecf20Sopenharmony_ci	u8 is_open;
7538c2ecf20Sopenharmony_ci
7548c2ecf20Sopenharmony_ci	enum nl80211_iftype iw_mode;
7558c2ecf20Sopenharmony_ci
7568c2ecf20Sopenharmony_ci	/* Last Rx'd beacon timestamp */
7578c2ecf20Sopenharmony_ci	u64 timestamp;
7588c2ecf20Sopenharmony_ci
7598c2ecf20Sopenharmony_ci	struct {
7608c2ecf20Sopenharmony_ci		__le32 flag;
7618c2ecf20Sopenharmony_ci		struct statistics_general_common common;
7628c2ecf20Sopenharmony_ci		struct statistics_rx_non_phy rx_non_phy;
7638c2ecf20Sopenharmony_ci		struct statistics_rx_phy rx_ofdm;
7648c2ecf20Sopenharmony_ci		struct statistics_rx_ht_phy rx_ofdm_ht;
7658c2ecf20Sopenharmony_ci		struct statistics_rx_phy rx_cck;
7668c2ecf20Sopenharmony_ci		struct statistics_tx tx;
7678c2ecf20Sopenharmony_ci#ifdef CONFIG_IWLWIFI_DEBUGFS
7688c2ecf20Sopenharmony_ci		struct statistics_bt_activity bt_activity;
7698c2ecf20Sopenharmony_ci		__le32 num_bt_kills, accum_num_bt_kills;
7708c2ecf20Sopenharmony_ci#endif
7718c2ecf20Sopenharmony_ci		spinlock_t lock;
7728c2ecf20Sopenharmony_ci	} statistics;
7738c2ecf20Sopenharmony_ci#ifdef CONFIG_IWLWIFI_DEBUGFS
7748c2ecf20Sopenharmony_ci	struct {
7758c2ecf20Sopenharmony_ci		struct statistics_general_common common;
7768c2ecf20Sopenharmony_ci		struct statistics_rx_non_phy rx_non_phy;
7778c2ecf20Sopenharmony_ci		struct statistics_rx_phy rx_ofdm;
7788c2ecf20Sopenharmony_ci		struct statistics_rx_ht_phy rx_ofdm_ht;
7798c2ecf20Sopenharmony_ci		struct statistics_rx_phy rx_cck;
7808c2ecf20Sopenharmony_ci		struct statistics_tx tx;
7818c2ecf20Sopenharmony_ci		struct statistics_bt_activity bt_activity;
7828c2ecf20Sopenharmony_ci	} accum_stats, delta_stats, max_delta_stats;
7838c2ecf20Sopenharmony_ci#endif
7848c2ecf20Sopenharmony_ci
7858c2ecf20Sopenharmony_ci	/*
7868c2ecf20Sopenharmony_ci	 * reporting the number of tids has AGG on. 0 means
7878c2ecf20Sopenharmony_ci	 * no AGGREGATION
7888c2ecf20Sopenharmony_ci	 */
7898c2ecf20Sopenharmony_ci	u8 agg_tids_count;
7908c2ecf20Sopenharmony_ci
7918c2ecf20Sopenharmony_ci	struct iwl_rx_phy_res last_phy_res;
7928c2ecf20Sopenharmony_ci	u32 ampdu_ref;
7938c2ecf20Sopenharmony_ci	bool last_phy_res_valid;
7948c2ecf20Sopenharmony_ci
7958c2ecf20Sopenharmony_ci	/*
7968c2ecf20Sopenharmony_ci	 * chain noise reset and gain commands are the
7978c2ecf20Sopenharmony_ci	 * two extra calibration commands follows the standard
7988c2ecf20Sopenharmony_ci	 * phy calibration commands
7998c2ecf20Sopenharmony_ci	 */
8008c2ecf20Sopenharmony_ci	u8 phy_calib_chain_noise_reset_cmd;
8018c2ecf20Sopenharmony_ci	u8 phy_calib_chain_noise_gain_cmd;
8028c2ecf20Sopenharmony_ci
8038c2ecf20Sopenharmony_ci	/* counts reply_tx error */
8048c2ecf20Sopenharmony_ci	struct reply_tx_error_statistics reply_tx_stats;
8058c2ecf20Sopenharmony_ci	struct reply_agg_tx_error_statistics reply_agg_tx_stats;
8068c2ecf20Sopenharmony_ci
8078c2ecf20Sopenharmony_ci	/* bt coex */
8088c2ecf20Sopenharmony_ci	u8 bt_enable_flag;
8098c2ecf20Sopenharmony_ci	u8 bt_status;
8108c2ecf20Sopenharmony_ci	u8 bt_traffic_load, last_bt_traffic_load;
8118c2ecf20Sopenharmony_ci	bool bt_ch_announce;
8128c2ecf20Sopenharmony_ci	bool bt_full_concurrent;
8138c2ecf20Sopenharmony_ci	__le32 kill_ack_mask;
8148c2ecf20Sopenharmony_ci	__le32 kill_cts_mask;
8158c2ecf20Sopenharmony_ci	__le16 bt_valid;
8168c2ecf20Sopenharmony_ci	bool reduced_txpower;
8178c2ecf20Sopenharmony_ci	u16 bt_on_thresh;
8188c2ecf20Sopenharmony_ci	u16 bt_duration;
8198c2ecf20Sopenharmony_ci	u16 dynamic_frag_thresh;
8208c2ecf20Sopenharmony_ci	u8 bt_ci_compliance;
8218c2ecf20Sopenharmony_ci	struct work_struct bt_traffic_change_work;
8228c2ecf20Sopenharmony_ci	bool bt_enable_pspoll;
8238c2ecf20Sopenharmony_ci	struct iwl_rxon_context *cur_rssi_ctx;
8248c2ecf20Sopenharmony_ci	bool bt_is_sco;
8258c2ecf20Sopenharmony_ci
8268c2ecf20Sopenharmony_ci	struct work_struct restart;
8278c2ecf20Sopenharmony_ci	struct work_struct scan_completed;
8288c2ecf20Sopenharmony_ci	struct work_struct abort_scan;
8298c2ecf20Sopenharmony_ci
8308c2ecf20Sopenharmony_ci	struct work_struct beacon_update;
8318c2ecf20Sopenharmony_ci	struct iwl_rxon_context *beacon_ctx;
8328c2ecf20Sopenharmony_ci	struct sk_buff *beacon_skb;
8338c2ecf20Sopenharmony_ci	void *beacon_cmd;
8348c2ecf20Sopenharmony_ci
8358c2ecf20Sopenharmony_ci	struct work_struct tt_work;
8368c2ecf20Sopenharmony_ci	struct work_struct ct_enter;
8378c2ecf20Sopenharmony_ci	struct work_struct ct_exit;
8388c2ecf20Sopenharmony_ci	struct work_struct start_internal_scan;
8398c2ecf20Sopenharmony_ci	struct work_struct tx_flush;
8408c2ecf20Sopenharmony_ci	struct work_struct bt_full_concurrency;
8418c2ecf20Sopenharmony_ci	struct work_struct bt_runtime_config;
8428c2ecf20Sopenharmony_ci
8438c2ecf20Sopenharmony_ci	struct delayed_work scan_check;
8448c2ecf20Sopenharmony_ci
8458c2ecf20Sopenharmony_ci	/* TX Power settings */
8468c2ecf20Sopenharmony_ci	s8 tx_power_user_lmt;
8478c2ecf20Sopenharmony_ci	s8 tx_power_next;
8488c2ecf20Sopenharmony_ci
8498c2ecf20Sopenharmony_ci#ifdef CONFIG_IWLWIFI_DEBUGFS
8508c2ecf20Sopenharmony_ci	/* debugfs */
8518c2ecf20Sopenharmony_ci	struct dentry *debugfs_dir;
8528c2ecf20Sopenharmony_ci	u32 dbgfs_sram_offset, dbgfs_sram_len;
8538c2ecf20Sopenharmony_ci	bool disable_ht40;
8548c2ecf20Sopenharmony_ci	void *wowlan_sram;
8558c2ecf20Sopenharmony_ci#endif /* CONFIG_IWLWIFI_DEBUGFS */
8568c2ecf20Sopenharmony_ci
8578c2ecf20Sopenharmony_ci	struct iwl_nvm_data *nvm_data;
8588c2ecf20Sopenharmony_ci	/* eeprom blob for debugfs */
8598c2ecf20Sopenharmony_ci	u8 *eeprom_blob;
8608c2ecf20Sopenharmony_ci	size_t eeprom_blob_size;
8618c2ecf20Sopenharmony_ci
8628c2ecf20Sopenharmony_ci	struct work_struct txpower_work;
8638c2ecf20Sopenharmony_ci	u32 calib_disabled;
8648c2ecf20Sopenharmony_ci	struct work_struct run_time_calib_work;
8658c2ecf20Sopenharmony_ci	struct timer_list statistics_periodic;
8668c2ecf20Sopenharmony_ci	struct timer_list ucode_trace;
8678c2ecf20Sopenharmony_ci
8688c2ecf20Sopenharmony_ci	struct iwl_event_log event_log;
8698c2ecf20Sopenharmony_ci
8708c2ecf20Sopenharmony_ci#ifdef CONFIG_IWLWIFI_LEDS
8718c2ecf20Sopenharmony_ci	struct led_classdev led;
8728c2ecf20Sopenharmony_ci	unsigned long blink_on, blink_off;
8738c2ecf20Sopenharmony_ci	bool led_registered;
8748c2ecf20Sopenharmony_ci#endif
8758c2ecf20Sopenharmony_ci
8768c2ecf20Sopenharmony_ci	/* WoWLAN GTK rekey data */
8778c2ecf20Sopenharmony_ci	u8 kck[NL80211_KCK_LEN], kek[NL80211_KEK_LEN];
8788c2ecf20Sopenharmony_ci	__le64 replay_ctr;
8798c2ecf20Sopenharmony_ci	__le16 last_seq_ctl;
8808c2ecf20Sopenharmony_ci	bool have_rekey_data;
8818c2ecf20Sopenharmony_ci#ifdef CONFIG_PM_SLEEP
8828c2ecf20Sopenharmony_ci	struct wiphy_wowlan_support wowlan_support;
8838c2ecf20Sopenharmony_ci#endif
8848c2ecf20Sopenharmony_ci
8858c2ecf20Sopenharmony_ci	/* device_pointers: pointers to ucode event tables */
8868c2ecf20Sopenharmony_ci	struct {
8878c2ecf20Sopenharmony_ci		u32 error_event_table;
8888c2ecf20Sopenharmony_ci		u32 log_event_table;
8898c2ecf20Sopenharmony_ci	} device_pointers;
8908c2ecf20Sopenharmony_ci
8918c2ecf20Sopenharmony_ci	/* indicator of loaded ucode image */
8928c2ecf20Sopenharmony_ci	enum iwl_ucode_type cur_ucode;
8938c2ecf20Sopenharmony_ci}; /*iwl_priv */
8948c2ecf20Sopenharmony_ci
8958c2ecf20Sopenharmony_cistatic inline struct iwl_rxon_context *
8968c2ecf20Sopenharmony_ciiwl_rxon_ctx_from_vif(struct ieee80211_vif *vif)
8978c2ecf20Sopenharmony_ci{
8988c2ecf20Sopenharmony_ci	struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv;
8998c2ecf20Sopenharmony_ci
9008c2ecf20Sopenharmony_ci	return vif_priv->ctx;
9018c2ecf20Sopenharmony_ci}
9028c2ecf20Sopenharmony_ci
9038c2ecf20Sopenharmony_ci#define for_each_context(priv, ctx)				\
9048c2ecf20Sopenharmony_ci	for (ctx = &priv->contexts[IWL_RXON_CTX_BSS];		\
9058c2ecf20Sopenharmony_ci	     ctx < &priv->contexts[NUM_IWL_RXON_CTX]; ctx++)	\
9068c2ecf20Sopenharmony_ci		if (priv->valid_contexts & BIT(ctx->ctxid))
9078c2ecf20Sopenharmony_ci
9088c2ecf20Sopenharmony_cistatic inline int iwl_is_associated_ctx(struct iwl_rxon_context *ctx)
9098c2ecf20Sopenharmony_ci{
9108c2ecf20Sopenharmony_ci	return (ctx->active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0;
9118c2ecf20Sopenharmony_ci}
9128c2ecf20Sopenharmony_ci
9138c2ecf20Sopenharmony_cistatic inline int iwl_is_associated(struct iwl_priv *priv,
9148c2ecf20Sopenharmony_ci				    enum iwl_rxon_context_id ctxid)
9158c2ecf20Sopenharmony_ci{
9168c2ecf20Sopenharmony_ci	return iwl_is_associated_ctx(&priv->contexts[ctxid]);
9178c2ecf20Sopenharmony_ci}
9188c2ecf20Sopenharmony_ci
9198c2ecf20Sopenharmony_cistatic inline int iwl_is_any_associated(struct iwl_priv *priv)
9208c2ecf20Sopenharmony_ci{
9218c2ecf20Sopenharmony_ci	struct iwl_rxon_context *ctx;
9228c2ecf20Sopenharmony_ci	for_each_context(priv, ctx)
9238c2ecf20Sopenharmony_ci		if (iwl_is_associated_ctx(ctx))
9248c2ecf20Sopenharmony_ci			return true;
9258c2ecf20Sopenharmony_ci	return false;
9268c2ecf20Sopenharmony_ci}
9278c2ecf20Sopenharmony_ci
9288c2ecf20Sopenharmony_ci#endif				/* __iwl_dev_h__ */
929