2 * Copyright (c) 2005-2011 Atheros Communications Inc.
3 * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.
4 * Copyright (c) 2018, The Linux Foundation. All rights reserved.
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 #include <linux/completion.h>
23 #include <linux/if_ether.h>
24 #include <linux/types.h>
25 #include <linux/pci.h>
26 #include <linux/uuid.h>
27 #include <linux/time.h>
32 #include "targaddrs.h"
36 #include "../dfs_pattern_detector.h"
42 #define MS(_v, _f) (((_v) & _f##_MASK) >> _f##_LSB)
43 #define SM(_v, _f) (((_v) << _f##_LSB) & _f##_MASK)
44 #define WO(_f) ((_f##_OFFSET) >> 2)
46 #define ATH10K_SCAN_ID 0
47 #define ATH10K_SCAN_CHANNEL_SWITCH_WMI_EVT_OVERHEAD 10 /* msec */
48 #define WMI_READY_TIMEOUT (5 * HZ)
49 #define ATH10K_FLUSH_TIMEOUT_HZ (5 * HZ)
50 #define ATH10K_CONNECTION_LOSS_HZ (3 * HZ)
51 #define ATH10K_NUM_CHANS 41
52 #define ATH10K_MAX_5G_CHAN 173
54 /* Antenna noise floor */
55 #define ATH10K_DEFAULT_NOISE_FLOOR -95
57 #define ATH10K_INVALID_RSSI 128
59 #define ATH10K_MAX_NUM_MGMT_PENDING 128
61 /* number of failed packets (20 packets with 16 sw reties each) */
62 #define ATH10K_KICKOUT_THRESHOLD (20 * 16)
65 * Use insanely high numbers to make sure that the firmware implementation
66 * won't start, we have the same functionality already in hostapd. Unit
69 #define ATH10K_KEEPALIVE_MIN_IDLE 3747
70 #define ATH10K_KEEPALIVE_MAX_IDLE 3895
71 #define ATH10K_KEEPALIVE_MAX_UNRESPONSIVE 3900
73 /* NAPI poll budget */
74 #define ATH10K_NAPI_BUDGET 64
76 /* SMBIOS type containing Board Data File Name Extension */
77 #define ATH10K_SMBIOS_BDF_EXT_TYPE 0xF8
79 /* SMBIOS type structure length (excluding strings-set) */
80 #define ATH10K_SMBIOS_BDF_EXT_LENGTH 0x9
82 /* Offset pointing to Board Data File Name Extension */
83 #define ATH10K_SMBIOS_BDF_EXT_OFFSET 0x8
85 /* Board Data File Name Extension string length.
86 * String format: BDF_<Customer ID>_<Extension>\0
88 #define ATH10K_SMBIOS_BDF_EXT_STR_LENGTH 0x20
90 /* The magic used by QCA spec */
91 #define ATH10K_SMBIOS_BDF_EXT_MAGIC "BDF_"
103 static inline const char *ath10k_bus_str(enum ath10k_bus bus)
110 case ATH10K_BUS_SDIO:
114 case ATH10K_BUS_SNOC:
121 enum ath10k_skb_flags {
122 ATH10K_SKB_F_NO_HWCRYPT = BIT(0),
123 ATH10K_SKB_F_DTIM_ZERO = BIT(1),
124 ATH10K_SKB_F_DELIVER_CAB = BIT(2),
125 ATH10K_SKB_F_MGMT = BIT(3),
126 ATH10K_SKB_F_QOS = BIT(4),
129 struct ath10k_skb_cb {
134 struct ieee80211_vif *vif;
135 struct ieee80211_txq *txq;
138 struct ath10k_skb_rxcb {
140 struct hlist_node hlist;
143 static inline struct ath10k_skb_cb *ATH10K_SKB_CB(struct sk_buff *skb)
145 BUILD_BUG_ON(sizeof(struct ath10k_skb_cb) >
146 IEEE80211_TX_INFO_DRIVER_DATA_SIZE);
147 return (struct ath10k_skb_cb *)&IEEE80211_SKB_CB(skb)->driver_data;
150 static inline struct ath10k_skb_rxcb *ATH10K_SKB_RXCB(struct sk_buff *skb)
152 BUILD_BUG_ON(sizeof(struct ath10k_skb_rxcb) > sizeof(skb->cb));
153 return (struct ath10k_skb_rxcb *)skb->cb;
156 #define ATH10K_RXCB_SKB(rxcb) \
157 container_of((void *)rxcb, struct sk_buff, cb)
159 static inline u32 host_interest_item_address(u32 item_offset)
161 return QCA988X_HOST_INTEREST_ADDRESS + item_offset;
168 struct ath10k_mem_chunk {
176 enum ath10k_htc_ep_id eid;
177 struct completion service_ready;
178 struct completion unified_ready;
179 struct completion barrier;
180 struct completion radar_confirm;
181 wait_queue_head_t tx_credits_wq;
182 DECLARE_BITMAP(svc_map, WMI_SERVICE_MAX);
183 struct wmi_cmd_map *cmd;
184 struct wmi_vdev_param_map *vdev_param;
185 struct wmi_pdev_param_map *pdev_param;
186 const struct wmi_ops *ops;
187 const struct wmi_peer_flags_map *peer_flags;
189 u32 mgmt_max_num_pending_tx;
191 /* Protected by data_lock */
192 struct idr mgmt_pending_tx;
196 struct ath10k_mem_chunk mem_chunks[WMI_MAX_MEM_REQS];
199 struct ath10k_fw_stats_peer {
200 struct list_head list;
202 u8 peer_macaddr[ETH_ALEN];
205 u32 peer_rx_rate; /* 10x only */
209 struct ath10k_fw_extd_stats_peer {
210 struct list_head list;
212 u8 peer_macaddr[ETH_ALEN];
216 struct ath10k_fw_stats_vdev {
217 struct list_head list;
222 u32 num_tx_frames[4];
224 u32 num_tx_frames_retries[4];
225 u32 num_tx_frames_failures[4];
230 u32 num_tx_not_acked;
231 u32 tx_rate_history[10];
232 u32 beacon_rssi_history[10];
235 struct ath10k_fw_stats_vdev_extd {
236 struct list_head list;
242 u32 ppdu_nonaggr_cnt;
243 u32 mpdu_sw_requeued;
245 u32 mpdu_suc_multitry;
248 u32 tx_ftm_suc_retry;
253 u32 rx_iftmr_dup_cnt;
256 struct ath10k_fw_stats_pdev {
257 struct list_head list;
261 u32 tx_frame_count; /* Cycles spent transmitting frames */
262 u32 rx_frame_count; /* Cycles spent receiving frames */
263 u32 rx_clear_count; /* Total channel busy time, evidently */
264 u32 cycle_count; /* Total on-channel time */
291 u32 sw_retry_failure;
292 u32 illgl_rate_phy_err;
293 u32 pdev_cont_xretry;
299 u32 seq_failed_queueing;
306 u32 mpdus_ack_failed;
310 s32 mid_ppdu_route_change;
327 struct ath10k_fw_stats {
329 struct list_head pdevs;
330 struct list_head vdevs;
331 struct list_head peers;
332 struct list_head peers_extd;
335 #define ATH10K_TPC_TABLE_TYPE_FLAG 1
336 #define ATH10K_TPC_PREAM_TABLE_END 0xFFFF
338 struct ath10k_tpc_table {
339 u32 pream_idx[WMI_TPC_RATE_MAX];
340 u8 rate_code[WMI_TPC_RATE_MAX];
341 char tpc_value[WMI_TPC_RATE_MAX][WMI_TPC_TX_N_CHAIN * WMI_TPC_BUF_SIZE];
344 struct ath10k_tpc_stats {
348 u32 twice_antenna_reduction;
349 u32 twice_max_rd_power;
350 s32 twice_antenna_gain;
355 u8 flag[WMI_TPC_FLAG];
356 struct ath10k_tpc_table tpc_table[WMI_TPC_FLAG];
359 struct ath10k_tpc_table_final {
360 u32 pream_idx[WMI_TPC_FINAL_RATE_MAX];
361 u8 rate_code[WMI_TPC_FINAL_RATE_MAX];
362 char tpc_value[WMI_TPC_FINAL_RATE_MAX][WMI_TPC_TX_N_CHAIN * WMI_TPC_BUF_SIZE];
365 struct ath10k_tpc_stats_final {
369 u32 twice_antenna_reduction;
370 u32 twice_max_rd_power;
371 s32 twice_antenna_gain;
376 u8 flag[WMI_TPC_FLAG];
377 struct ath10k_tpc_table_final tpc_table_final[WMI_TPC_FLAG];
380 struct ath10k_dfs_stats {
384 u32 pulses_discarded;
388 enum ath10k_radar_confirmation_state {
389 ATH10K_RADAR_CONFIRMATION_IDLE = 0,
390 ATH10K_RADAR_CONFIRMATION_INPROGRESS,
391 ATH10K_RADAR_CONFIRMATION_STOPPED,
394 struct ath10k_radar_found_info {
403 #define ATH10K_MAX_NUM_PEER_IDS (1 << 11) /* htt rx_desc limit */
406 struct list_head list;
407 struct ieee80211_vif *vif;
408 struct ieee80211_sta *sta;
413 DECLARE_BITMAP(peer_ids, ATH10K_MAX_NUM_PEER_IDS);
415 /* protected by ar->data_lock */
416 struct ieee80211_key_conf *keys[WMI_MAX_KEY_INDEX + 1];
420 struct list_head list;
421 unsigned long num_fw_queued;
422 unsigned long num_push_allowed;
425 enum ath10k_pkt_rx_err {
426 ATH10K_PKT_RX_ERR_FCS,
427 ATH10K_PKT_RX_ERR_TKIP,
428 ATH10K_PKT_RX_ERR_CRYPT,
429 ATH10K_PKT_RX_ERR_PEER_IDX_INVAL,
430 ATH10K_PKT_RX_ERR_MAX,
433 enum ath10k_ampdu_subfrm_num {
434 ATH10K_AMPDU_SUBFRM_NUM_10,
435 ATH10K_AMPDU_SUBFRM_NUM_20,
436 ATH10K_AMPDU_SUBFRM_NUM_30,
437 ATH10K_AMPDU_SUBFRM_NUM_40,
438 ATH10K_AMPDU_SUBFRM_NUM_50,
439 ATH10K_AMPDU_SUBFRM_NUM_60,
440 ATH10K_AMPDU_SUBFRM_NUM_MORE,
441 ATH10K_AMPDU_SUBFRM_NUM_MAX,
444 enum ath10k_amsdu_subfrm_num {
445 ATH10K_AMSDU_SUBFRM_NUM_1,
446 ATH10K_AMSDU_SUBFRM_NUM_2,
447 ATH10K_AMSDU_SUBFRM_NUM_3,
448 ATH10K_AMSDU_SUBFRM_NUM_4,
449 ATH10K_AMSDU_SUBFRM_NUM_MORE,
450 ATH10K_AMSDU_SUBFRM_NUM_MAX,
453 struct ath10k_sta_tid_stats {
454 unsigned long int rx_pkt_from_fw;
455 unsigned long int rx_pkt_unchained;
456 unsigned long int rx_pkt_drop_chained;
457 unsigned long int rx_pkt_drop_filter;
458 unsigned long int rx_pkt_err[ATH10K_PKT_RX_ERR_MAX];
459 unsigned long int rx_pkt_queued_for_mac;
460 unsigned long int rx_pkt_ampdu[ATH10K_AMPDU_SUBFRM_NUM_MAX];
461 unsigned long int rx_pkt_amsdu[ATH10K_AMSDU_SUBFRM_NUM_MAX];
465 struct ath10k_vif *arvif;
467 /* the following are protected by ar->data_lock */
468 u32 changed; /* IEEE80211_RC_* */
473 struct rate_info txrate;
475 struct work_struct update_wk;
478 #ifdef CONFIG_MAC80211_DEBUGFS
479 /* protected by conf_mutex */
482 /* Protected with ar->data_lock */
483 struct ath10k_sta_tid_stats tid_stats[IEEE80211_NUM_TIDS + 1];
487 #define ATH10K_VDEV_SETUP_TIMEOUT_HZ (5 * HZ)
489 enum ath10k_beacon_state {
490 ATH10K_BEACON_SCHEDULED = 0,
491 ATH10K_BEACON_SENDING,
496 struct list_head list;
500 enum wmi_vdev_type vdev_type;
501 enum wmi_vdev_subtype vdev_subtype;
504 struct sk_buff *beacon;
505 /* protected by data_lock */
506 enum ath10k_beacon_state beacon_state;
508 dma_addr_t beacon_paddr;
509 unsigned long tx_paused; /* arbitrary values defined by target */
512 struct ieee80211_vif *vif;
516 bool spectral_enabled;
521 struct ieee80211_key_conf *wep_keys[WMI_MAX_KEY_INDEX + 1];
535 u8 ssid[IEEE80211_MAX_SSID_LEN];
537 /* P2P_IE with NoA attribute for P2P_GO case */
545 int num_legacy_stations;
547 struct wmi_wmm_params_all_arg wmm_params;
548 struct work_struct ap_csa_work;
549 struct delayed_work connection_loss_work;
550 struct cfg80211_bitrate_mask bitrate_mask;
553 struct ath10k_vif_iter {
555 struct ath10k_vif *arvif;
558 /* Copy Engine register dump, protected by ce-lock */
559 struct ath10k_ce_crash_data {
567 struct ath10k_ce_crash_hdr {
569 __le32 reserved[3]; /* for future use */
570 struct ath10k_ce_crash_data entries[];
573 #define MAX_MEM_DUMP_TYPE 5
575 /* used for crash-dump storage, protected by data-lock */
576 struct ath10k_fw_crash_data {
578 struct timespec64 timestamp;
579 __le32 registers[REG_DUMP_COUNT_QCA988X];
580 struct ath10k_ce_crash_data ce_crash_data[CE_COUNT_MAX];
583 size_t ramdump_buf_len;
586 struct ath10k_debug {
587 struct dentry *debugfs_phy;
589 struct ath10k_fw_stats fw_stats;
590 struct completion fw_stats_complete;
593 unsigned long htt_stats_mask;
594 struct delayed_work htt_stats_dwork;
595 struct ath10k_dfs_stats dfs_stats;
596 struct ath_dfs_pool_stats dfs_pool_stats;
598 /* used for tpc-dump storage, protected by data-lock */
599 struct ath10k_tpc_stats *tpc_stats;
600 struct ath10k_tpc_stats_final *tpc_stats_final;
602 struct completion tpc_complete;
604 /* protected by conf_mutex */
613 ATH10K_STATE_OFF = 0,
616 /* When doing firmware recovery the device is first powered down.
617 * mac80211 is supposed to call in to start() hook later on. It is
618 * however possible that driver unloading and firmware crash overlap.
619 * mac80211 can wait on conf_mutex in stop() while the device is
620 * stopped in ath10k_core_restart() work holding conf_mutex. The state
621 * RESTARTED means that the device is up and mac80211 has started hw
622 * reconfiguration. Once mac80211 is done with the reconfiguration we
623 * set the state to STATE_ON in reconfig_complete().
625 ATH10K_STATE_RESTARTING,
626 ATH10K_STATE_RESTARTED,
628 /* The device has crashed while restarting hw. This state is like ON
629 * but commands are blocked in HTC and -ECOMM response is given. This
630 * prevents completion timeouts and makes the driver more responsive to
631 * userspace commands. This is also prevents recursive recovery.
639 enum ath10k_firmware_mode {
640 /* the default mode, standard 802.11 functionality */
641 ATH10K_FIRMWARE_MODE_NORMAL,
643 /* factory tests etc */
644 ATH10K_FIRMWARE_MODE_UTF,
647 enum ath10k_fw_features {
648 /* wmi_mgmt_rx_hdr contains extra RSSI information */
649 ATH10K_FW_FEATURE_EXT_WMI_MGMT_RX = 0,
651 /* Firmware from 10X branch. Deprecated, don't use in new code. */
652 ATH10K_FW_FEATURE_WMI_10X = 1,
654 /* firmware support tx frame management over WMI, otherwise it's HTT */
655 ATH10K_FW_FEATURE_HAS_WMI_MGMT_TX = 2,
657 /* Firmware does not support P2P */
658 ATH10K_FW_FEATURE_NO_P2P = 3,
660 /* Firmware 10.2 feature bit. The ATH10K_FW_FEATURE_WMI_10X feature
661 * bit is required to be set as well. Deprecated, don't use in new
664 ATH10K_FW_FEATURE_WMI_10_2 = 4,
666 /* Some firmware revisions lack proper multi-interface client powersave
667 * implementation. Enabling PS could result in connection drops,
668 * traffic stalls, etc.
670 ATH10K_FW_FEATURE_MULTI_VIF_PS_SUPPORT = 5,
672 /* Some firmware revisions have an incomplete WoWLAN implementation
673 * despite WMI service bit being advertised. This feature flag is used
674 * to distinguish whether WoWLAN is really supported or not.
676 ATH10K_FW_FEATURE_WOWLAN_SUPPORT = 6,
678 /* Don't trust error code from otp.bin */
679 ATH10K_FW_FEATURE_IGNORE_OTP_RESULT = 7,
681 /* Some firmware revisions pad 4th hw address to 4 byte boundary making
682 * it 8 bytes long in Native Wifi Rx decap.
684 ATH10K_FW_FEATURE_NO_NWIFI_DECAP_4ADDR_PADDING = 8,
686 /* Firmware supports bypassing PLL setting on init. */
687 ATH10K_FW_FEATURE_SUPPORTS_SKIP_CLOCK_INIT = 9,
689 /* Raw mode support. If supported, FW supports receiving and trasmitting
690 * frames in raw mode.
692 ATH10K_FW_FEATURE_RAW_MODE_SUPPORT = 10,
694 /* Firmware Supports Adaptive CCA*/
695 ATH10K_FW_FEATURE_SUPPORTS_ADAPTIVE_CCA = 11,
697 /* Firmware supports management frame protection */
698 ATH10K_FW_FEATURE_MFP_SUPPORT = 12,
700 /* Firmware supports pull-push model where host shares it's software
701 * queue state with firmware and firmware generates fetch requests
702 * telling host which queues to dequeue tx from.
704 * Primary function of this is improved MU-MIMO performance with
707 ATH10K_FW_FEATURE_PEER_FLOW_CONTROL = 13,
709 /* Firmware supports BT-Coex without reloading firmware via pdev param.
710 * To support Bluetooth coexistence pdev param, WMI_COEX_GPIO_SUPPORT of
711 * extended resource config should be enabled always. This firmware IE
712 * is used to configure WMI_COEX_GPIO_SUPPORT.
714 ATH10K_FW_FEATURE_BTCOEX_PARAM = 14,
716 /* Unused flag and proven to be not working, enable this if you want
717 * to experiment sending NULL func data frames in HTT TX
719 ATH10K_FW_FEATURE_SKIP_NULL_FUNC_WAR = 15,
721 /* Firmware allow other BSS mesh broadcast/multicast frames without
722 * creating monitor interface. Appropriate rxfilters are programmed for
723 * mesh vdev by firmware itself. This feature flags will be used for
724 * not creating monitor vdev while configuring mesh node.
726 ATH10K_FW_FEATURE_ALLOWS_MESH_BCAST = 16,
728 /* Firmware does not support power save in station mode. */
729 ATH10K_FW_FEATURE_NO_PS = 17,
731 /* Firmware allows management tx by reference instead of by value. */
732 ATH10K_FW_FEATURE_MGMT_TX_BY_REF = 18,
734 /* Firmware load is done externally, not by bmi */
735 ATH10K_FW_FEATURE_NON_BMI = 19,
738 ATH10K_FW_FEATURE_COUNT,
741 enum ath10k_dev_flags {
742 /* Indicates that ath10k device is during CAC phase of DFS */
744 ATH10K_FLAG_CORE_REGISTERED,
746 /* Device has crashed and needs to restart. This indicates any pending
747 * waiters should immediately cancel instead of waiting for a time out.
749 ATH10K_FLAG_CRASH_FLUSH,
751 /* Use Raw mode instead of native WiFi Tx/Rx encap mode.
752 * Raw mode supports both hardware and software crypto. Native WiFi only
753 * supports hardware crypto.
755 ATH10K_FLAG_RAW_MODE,
757 /* Disable HW crypto engine */
758 ATH10K_FLAG_HW_CRYPTO_DISABLED,
760 /* Bluetooth coexistance enabled */
763 /* Per Station statistics service */
764 ATH10K_FLAG_PEER_STATS,
767 enum ath10k_cal_mode {
768 ATH10K_CAL_MODE_FILE,
771 ATH10K_PRE_CAL_MODE_FILE,
772 ATH10K_PRE_CAL_MODE_DT,
773 ATH10K_CAL_MODE_EEPROM,
776 enum ath10k_crypt_mode {
777 /* Only use hardware crypto engine */
778 ATH10K_CRYPT_MODE_HW,
779 /* Only use software crypto engine */
780 ATH10K_CRYPT_MODE_SW,
783 static inline const char *ath10k_cal_mode_str(enum ath10k_cal_mode mode)
786 case ATH10K_CAL_MODE_FILE:
788 case ATH10K_CAL_MODE_OTP:
790 case ATH10K_CAL_MODE_DT:
792 case ATH10K_PRE_CAL_MODE_FILE:
793 return "pre-cal-file";
794 case ATH10K_PRE_CAL_MODE_DT:
796 case ATH10K_CAL_MODE_EEPROM:
803 enum ath10k_scan_state {
805 ATH10K_SCAN_STARTING,
807 ATH10K_SCAN_ABORTING,
810 static inline const char *ath10k_scan_state_str(enum ath10k_scan_state state)
813 case ATH10K_SCAN_IDLE:
815 case ATH10K_SCAN_STARTING:
817 case ATH10K_SCAN_RUNNING:
819 case ATH10K_SCAN_ABORTING:
826 enum ath10k_tx_pause_reason {
827 ATH10K_TX_PAUSE_Q_FULL,
831 struct ath10k_fw_file {
832 const struct firmware *firmware;
834 char fw_version[ETHTOOL_FWVERS_LEN];
836 DECLARE_BITMAP(fw_features, ATH10K_FW_FEATURE_COUNT);
838 enum ath10k_fw_wmi_op_version wmi_op_version;
839 enum ath10k_fw_htt_op_version htt_op_version;
841 const void *firmware_data;
844 const void *otp_data;
847 const void *codeswap_data;
850 /* The original idea of struct ath10k_fw_file was that it only
851 * contains struct firmware and pointers to various parts (actual
852 * firmware binary, otp, metadata etc) of the file. This seg_info
853 * is actually created separate but as this is used similarly as
854 * the other firmware components it's more convenient to have it
857 struct ath10k_swap_code_seg_info *firmware_swap_code_seg_info;
860 struct ath10k_fw_components {
861 const struct firmware *board;
862 const void *board_data;
865 struct ath10k_fw_file fw_file;
868 struct ath10k_per_peer_tx_stats {
884 struct ath_common ath_common;
885 struct ieee80211_hw *hw;
886 struct ieee80211_ops *ops;
888 u8 mac_addr[ETH_ALEN];
890 enum ath10k_hw_rev hw_rev;
895 u32 fw_version_minor;
896 u16 fw_version_release;
897 u16 fw_version_build;
898 u32 fw_stats_req_mask;
906 u32 max_spatial_stream;
907 /* protected by conf_mutex */
916 const struct ath10k_hif_ops *ops;
919 struct completion target_suspend;
921 const struct ath10k_hw_regs *regs;
922 const struct ath10k_hw_ce_regs *hw_ce_regs;
923 const struct ath10k_hw_values *hw_values;
924 struct ath10k_bmi bmi;
925 struct ath10k_wmi wmi;
926 struct ath10k_htc htc;
927 struct ath10k_htt htt;
929 struct ath10k_hw_params hw_params;
931 /* contains the firmware images used with ATH10K_FIRMWARE_MODE_NORMAL */
932 struct ath10k_fw_components normal_mode_fw;
934 /* READ-ONLY images of the running firmware, which can be either
935 * normal or UTF. Do not modify, release etc!
937 const struct ath10k_fw_components *running_fw;
939 const struct firmware *pre_cal_file;
940 const struct firmware *cal_file;
945 u32 subsystem_vendor;
946 u32 subsystem_device;
952 char bdf_ext[ATH10K_SMBIOS_BDF_EXT_STR_LENGTH];
957 enum ath10k_cal_mode cal_mode;
960 struct completion started;
961 struct completion completed;
962 struct completion on_channel;
963 struct delayed_work timeout;
964 enum ath10k_scan_state state;
972 struct ieee80211_supported_band sbands[NUM_NL80211_BANDS];
975 /* should never be NULL; needed for regular htt rx */
976 struct ieee80211_channel *rx_channel;
978 /* valid during scan; needed for mgmt rx during scan */
979 struct ieee80211_channel *scan_channel;
981 /* current operating channel definition */
982 struct cfg80211_chan_def chandef;
984 /* currently configured operating channel in firmware */
985 struct ieee80211_channel *tgt_oper_chan;
987 unsigned long long free_vdev_map;
988 struct ath10k_vif *monitor_arvif;
991 bool monitor_started;
992 unsigned int filter_flags;
993 unsigned long dev_flags;
994 bool dfs_block_radar_events;
996 /* protected by conf_mutex */
998 int num_started_vdevs;
1000 /* Protected by conf-mutex */
1001 u8 cfg_tx_chainmask;
1002 u8 cfg_rx_chainmask;
1004 struct completion install_key_done;
1006 int last_wmi_vdev_start_status;
1007 struct completion vdev_setup_done;
1009 struct workqueue_struct *workqueue;
1010 /* Auxiliary workqueue */
1011 struct workqueue_struct *workqueue_aux;
1013 /* prevents concurrent FW reconfiguration */
1014 struct mutex conf_mutex;
1016 /* protects shared structure data */
1017 spinlock_t data_lock;
1018 /* protects: ar->txqs, artxq->list */
1019 spinlock_t txqs_lock;
1021 struct list_head txqs;
1022 struct list_head arvifs;
1023 struct list_head peers;
1024 struct ath10k_peer *peer_map[ATH10K_MAX_NUM_PEER_IDS];
1025 wait_queue_head_t peer_mapping_wq;
1027 /* protected by conf_mutex */
1032 int max_num_stations;
1034 int max_num_tdls_vdevs;
1035 int num_active_peers;
1038 struct work_struct svc_rdy_work;
1039 struct sk_buff *svc_rdy_skb;
1041 struct work_struct offchan_tx_work;
1042 struct sk_buff_head offchan_tx_queue;
1043 struct completion offchan_tx_completed;
1044 struct sk_buff *offchan_tx_skb;
1046 struct work_struct wmi_mgmt_tx_work;
1047 struct sk_buff_head wmi_mgmt_tx_queue;
1049 enum ath10k_state state;
1051 struct work_struct register_work;
1052 struct work_struct restart_work;
1054 /* cycle count is reported twice for each visited channel during scan.
1055 * access protected by data_lock
1057 u32 survey_last_rx_clear_count;
1058 u32 survey_last_cycle_count;
1059 struct survey_info survey[ATH10K_NUM_CHANS];
1061 /* Channel info events are expected to come in pairs without and with
1062 * COMPLETE flag set respectively for each channel visit during scan.
1064 * However there are deviations from this rule. This flag is used to
1065 * avoid reporting garbage data.
1067 bool ch_info_can_report_survey;
1068 struct completion bss_survey_done;
1070 struct dfs_pattern_detector *dfs_detector;
1072 unsigned long tx_paused; /* see ATH10K_TX_PAUSE_ */
1074 #ifdef CONFIG_ATH10K_DEBUGFS
1075 struct ath10k_debug debug;
1077 /* relay(fs) channel for spectral scan */
1078 struct rchan *rfs_chan_spec_scan;
1080 /* spectral_mode and spec_config are protected by conf_mutex */
1081 enum ath10k_spectral_mode mode;
1082 struct ath10k_spec_scan config;
1088 #ifdef CONFIG_DEV_COREDUMP
1090 struct ath10k_fw_crash_data *fw_crash_data;
1095 /* protected by conf_mutex */
1096 struct ath10k_fw_components utf_mode_fw;
1098 /* protected by data_lock */
1103 /* protected by data_lock */
1104 u32 fw_crash_counter;
1105 u32 fw_warm_reset_counter;
1106 u32 fw_cold_reset_counter;
1109 struct ath10k_thermal thermal;
1110 struct ath10k_wow wow;
1111 struct ath10k_per_peer_tx_stats peer_tx_stats;
1114 struct net_device napi_dev;
1115 struct napi_struct napi;
1117 struct work_struct set_coverage_class_work;
1118 /* protected by conf_mutex */
1120 /* writing also protected by data_lock */
1124 u32 reg_slottime_conf;
1125 u32 reg_slottime_orig;
1126 u32 reg_ack_cts_timeout_conf;
1127 u32 reg_ack_cts_timeout_orig;
1130 u32 ampdu_reference;
1134 u32 sta_tid_stats_mask;
1136 /* protected by data_lock */
1137 enum ath10k_radar_confirmation_state radar_conf_state;
1138 struct ath10k_radar_found_info last_radar_info;
1139 struct work_struct radar_confirmation_work;
1142 u8 drv_priv[0] __aligned(sizeof(void *));
1145 static inline bool ath10k_peer_stats_enabled(struct ath10k *ar)
1147 if (test_bit(ATH10K_FLAG_PEER_STATS, &ar->dev_flags) &&
1148 test_bit(WMI_SERVICE_PEER_STATS, ar->wmi.svc_map))
1154 extern unsigned long ath10k_coredump_mask;
1156 struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,
1157 enum ath10k_bus bus,
1158 enum ath10k_hw_rev hw_rev,
1159 const struct ath10k_hif_ops *hif_ops);
1160 void ath10k_core_destroy(struct ath10k *ar);
1161 void ath10k_core_get_fw_features_str(struct ath10k *ar,
1164 int ath10k_core_fetch_firmware_api_n(struct ath10k *ar, const char *name,
1165 struct ath10k_fw_file *fw_file);
1167 int ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode,
1168 const struct ath10k_fw_components *fw_components);
1169 int ath10k_wait_for_suspend(struct ath10k *ar, u32 suspend_opt);
1170 void ath10k_core_stop(struct ath10k *ar);
1171 int ath10k_core_register(struct ath10k *ar, u32 chip_id);
1172 void ath10k_core_unregister(struct ath10k *ar);
1174 #endif /* _CORE_H_ */