1 /* SPDX-License-Identifier: BSD-3-Clause-Clear */
3 * Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
4 * Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.
10 #include <linux/types.h>
11 #include <linux/interrupt.h>
12 #include <linux/irq.h>
13 #include <linux/bitfield.h>
14 #include <linux/dmi.h>
15 #include <linux/ctype.h>
16 #include <linux/firmware.h>
17 #include <linux/panic_notifier.h>
32 #include "debugfs_htt_stats.h"
35 #define SM(_v, _f) (((_v) << _f##_LSB) & _f##_MASK)
37 #define ATH12K_TX_MGMT_NUM_PENDING_MAX 512
39 #define ATH12K_TX_MGMT_TARGET_MAX_SUPPORT_WMI 64
41 /* Pending management packets threshold for dropping probe responses */
42 #define ATH12K_PRB_RSP_DROP_THRESHOLD ((ATH12K_TX_MGMT_TARGET_MAX_SUPPORT_WMI * 3) / 4)
44 /* SMBIOS type containing Board Data File Name Extension */
45 #define ATH12K_SMBIOS_BDF_EXT_TYPE 0xF8
47 /* SMBIOS type structure length (excluding strings-set) */
48 #define ATH12K_SMBIOS_BDF_EXT_LENGTH 0x9
50 /* The magic used by QCA spec */
51 #define ATH12K_SMBIOS_BDF_EXT_MAGIC "BDF_"
53 #define ATH12K_INVALID_HW_MAC_ID 0xFF
54 #define ATH12K_CONNECTION_LOSS_HZ (3 * HZ)
55 #define ATH12K_RX_RATE_TABLE_NUM 320
56 #define ATH12K_RX_RATE_TABLE_11AX_NUM 576
58 #define ATH12K_MON_TIMER_INTERVAL 10
59 #define ATH12K_RESET_TIMEOUT_HZ (20 * HZ)
60 #define ATH12K_RESET_MAX_FAIL_COUNT_FIRST 3
61 #define ATH12K_RESET_MAX_FAIL_COUNT_FINAL 5
62 #define ATH12K_RESET_FAIL_TIMEOUT_HZ (20 * HZ)
63 #define ATH12K_RECONFIGURE_TIMEOUT_HZ (10 * HZ)
64 #define ATH12K_RECOVER_START_TIMEOUT_HZ (20 * HZ)
66 enum ath12k_bdf_search
{
67 ATH12K_BDF_SEARCH_DEFAULT
,
68 ATH12K_BDF_SEARCH_BUS_AND_BOARD
,
79 #define ATH12K_HT_MCS_MAX 7
80 #define ATH12K_VHT_MCS_MAX 9
81 #define ATH12K_HE_MCS_MAX 11
83 enum ath12k_crypt_mode
{
84 /* Only use hardware crypto engine */
86 /* Only use software crypto */
90 static inline enum wme_ac
ath12k_tid_to_ac(u32 tid
)
92 return (((tid
== 0) || (tid
== 3)) ? WME_AC_BE
:
93 ((tid
== 1) || (tid
== 2)) ? WME_AC_BK
:
94 ((tid
== 4) || (tid
== 5)) ? WME_AC_VI
:
98 static inline u64
ath12k_le32hilo_to_u64(__le32 hi
, __le32 lo
)
100 u64 hi64
= le32_to_cpu(hi
);
101 u64 lo64
= le32_to_cpu(lo
);
103 return (hi64
<< 32) | lo64
;
106 enum ath12k_skb_flags
{
107 ATH12K_SKB_HW_80211_ENCAP
= BIT(0),
108 ATH12K_SKB_CIPHER_SET
= BIT(1),
111 struct ath12k_skb_cb
{
114 struct ieee80211_vif
*vif
;
115 dma_addr_t paddr_ext_desc
;
120 struct ath12k_skb_rxcb
{
124 bool is_continuation
;
127 struct hal_rx_desc
*rx_desc
;
138 ATH12K_HW_QCN9274_HW10
,
139 ATH12K_HW_QCN9274_HW20
,
140 ATH12K_HW_WCN7850_HW20
143 enum ath12k_firmware_mode
{
144 /* the default mode, standard 802.11 functionality */
145 ATH12K_FIRMWARE_MODE_NORMAL
,
147 /* factory tests etc */
148 ATH12K_FIRMWARE_MODE_FTM
,
151 #define ATH12K_IRQ_NUM_MAX 57
152 #define ATH12K_EXT_IRQ_NUM_MAX 16
154 struct ath12k_ext_irq_grp
{
155 struct ath12k_base
*ab
;
156 u32 irqs
[ATH12K_EXT_IRQ_NUM_MAX
];
160 struct napi_struct napi
;
161 struct net_device
*napi_ndev
;
164 struct ath12k_smbios_bdf
{
165 struct dmi_header hdr
;
171 #define HEHANDLE_CAP_PHYINFO_SIZE 3
172 #define HECAP_PHYINFO_SIZE 9
173 #define HECAP_MACINFO_SIZE 5
174 #define HECAP_TXRX_MCS_NSS_SIZE 2
175 #define HECAP_PPET16_PPET8_MAX_SIZE 25
177 #define HE_PPET16_PPET8_SIZE 8
179 /* 802.11ax PPE (PPDU packet Extension) threshold */
180 struct he_ppe_threshold
{
183 u32 ppet16_ppet8_ru3_ru0
[HE_PPET16_PPET8_SIZE
];
187 u8 hecap_macinfo
[HECAP_MACINFO_SIZE
];
188 u32 hecap_rxmcsnssmap
;
189 u32 hecap_txmcsnssmap
;
190 u32 hecap_phyinfo
[HEHANDLE_CAP_PHYINFO_SIZE
];
191 struct he_ppe_threshold hecap_ppet
;
196 WMI_HOST_TP_SCALE_MAX
= 0,
197 WMI_HOST_TP_SCALE_50
= 1,
198 WMI_HOST_TP_SCALE_25
= 2,
199 WMI_HOST_TP_SCALE_12
= 3,
200 WMI_HOST_TP_SCALE_MIN
= 4,
201 WMI_HOST_TP_SCALE_SIZE
= 5,
204 enum ath12k_scan_state
{
206 ATH12K_SCAN_STARTING
,
208 ATH12K_SCAN_ABORTING
,
211 enum ath12k_dev_flags
{
213 ATH12K_FLAG_CRASH_FLUSH
,
214 ATH12K_FLAG_RAW_MODE
,
215 ATH12K_FLAG_HW_CRYPTO_DISABLED
,
216 ATH12K_FLAG_RECOVERY
,
217 ATH12K_FLAG_UNREGISTERING
,
218 ATH12K_FLAG_REGISTERED
,
219 ATH12K_FLAG_QMI_FAIL
,
220 ATH12K_FLAG_HTC_SUSPEND_COMPLETE
,
221 ATH12K_FLAG_CE_IRQ_ENABLED
,
222 ATH12K_FLAG_EXT_IRQ_ENABLED
,
225 struct ath12k_tx_conf
{
228 struct ieee80211_tx_queue_params tx_queue_params
;
231 struct ath12k_key_conf
{
232 enum set_key_cmd cmd
;
233 struct list_head list
;
234 struct ieee80211_sta
*sta
;
235 struct ieee80211_key_conf
*key
;
238 struct ath12k_vif_cache
{
239 struct ath12k_tx_conf tx_conf
;
240 struct ath12k_key_conf key_conf
;
241 u32 bss_conf_changed
;
244 struct ath12k_rekey_data
{
245 u8 kck
[NL80211_KCK_LEN
];
246 u8 kek
[NL80211_KCK_LEN
];
251 struct ath12k_link_vif
{
258 u8 hal_addr_search_flags
;
266 struct wmi_wmm_params_all_arg wmm_params
;
267 struct list_head list
;
273 struct cfg80211_bitrate_mask bitrate_mask
;
274 struct delayed_work connection_loss_work
;
275 int num_legacy_stations
;
276 int rtscts_prot_mode
;
280 struct ieee80211_chanctx_conf chanctx
;
284 struct ath12k_vif
*ahvif
;
285 struct ath12k_rekey_data rekey_data
;
289 enum wmi_vdev_type vdev_type
;
290 enum wmi_vdev_subtype vdev_subtype
;
291 struct ieee80211_vif
*vif
;
292 struct ath12k_hw
*ah
;
299 /* 127 stations; wmi limit */
303 u8 ssid
[IEEE80211_MAX_SSID_LEN
];
305 /* P2P_IE with NoA attribute for P2P_GO case */
316 struct ath12k_link_vif deflink
;
317 struct ath12k_link_vif __rcu
*link
[IEEE80211_MLD_MAX_NUM_LINKS
];
318 struct ath12k_vif_cache
*cache
[IEEE80211_MLD_MAX_NUM_LINKS
];
319 /* indicates bitmap of link vif created in FW */
322 /* Must be last - ends in a flexible-array member.
324 * FIXME: Driver should not copy struct ieee80211_chanctx_conf,
325 * especially because it has a flexible array. Find a better way.
327 struct ieee80211_chanctx_conf chanctx
;
330 struct ath12k_vif_iter
{
333 struct ath12k_link_vif
*arvif
;
336 #define HAL_AST_IDX_INVALID 0xFFFF
337 #define HAL_RX_MAX_MCS 12
338 #define HAL_RX_MAX_MCS_HT 31
339 #define HAL_RX_MAX_MCS_VHT 9
340 #define HAL_RX_MAX_MCS_HE 11
341 #define HAL_RX_MAX_NSS 8
342 #define HAL_RX_MAX_NUM_LEGACY_RATES 12
343 #define ATH12K_RX_RATE_TABLE_11AX_NUM 576
344 #define ATH12K_RX_RATE_TABLE_NUM 320
346 struct ath12k_rx_peer_rate_stats
{
347 u64 ht_mcs_count
[HAL_RX_MAX_MCS_HT
+ 1];
348 u64 vht_mcs_count
[HAL_RX_MAX_MCS_VHT
+ 1];
349 u64 he_mcs_count
[HAL_RX_MAX_MCS_HE
+ 1];
350 u64 nss_count
[HAL_RX_MAX_NSS
];
351 u64 bw_count
[HAL_RX_BW_MAX
];
352 u64 gi_count
[HAL_RX_GI_MAX
];
353 u64 legacy_count
[HAL_RX_MAX_NUM_LEGACY_RATES
];
354 u64 rx_rate
[ATH12K_RX_RATE_TABLE_11AX_NUM
];
357 struct ath12k_rx_peer_stats
{
360 u64 num_mpdu_fcs_err
;
363 u64 other_msdu_count
;
364 u64 ampdu_msdu_count
;
365 u64 non_ampdu_msdu_count
;
367 u64 beamformed_count
;
368 u64 mcs_count
[HAL_RX_MAX_MCS
+ 1];
369 u64 nss_count
[HAL_RX_MAX_NSS
];
370 u64 bw_count
[HAL_RX_BW_MAX
];
371 u64 gi_count
[HAL_RX_GI_MAX
];
372 u64 coding_count
[HAL_RX_SU_MU_CODING_MAX
];
373 u64 tid_count
[IEEE80211_NUM_TIDS
+ 1];
374 u64 pream_cnt
[HAL_RX_PREAMBLE_MAX
];
375 u64 reception_type
[HAL_RX_RECEPTION_TYPE_MAX
];
378 u64 ru_alloc_cnt
[HAL_RX_RU_ALLOC_TYPE_MAX
];
379 struct ath12k_rx_peer_rate_stats pkt_stats
;
380 struct ath12k_rx_peer_rate_stats byte_stats
;
383 #define ATH12K_HE_MCS_NUM 12
384 #define ATH12K_VHT_MCS_NUM 10
385 #define ATH12K_BW_NUM 5
386 #define ATH12K_NSS_NUM 4
387 #define ATH12K_LEGACY_NUM 12
388 #define ATH12K_GI_NUM 4
389 #define ATH12K_HT_MCS_NUM 32
391 enum ath12k_pkt_rx_err
{
392 ATH12K_PKT_RX_ERR_FCS
,
393 ATH12K_PKT_RX_ERR_TKIP
,
394 ATH12K_PKT_RX_ERR_CRYPT
,
395 ATH12K_PKT_RX_ERR_PEER_IDX_INVAL
,
396 ATH12K_PKT_RX_ERR_MAX
,
399 enum ath12k_ampdu_subfrm_num
{
400 ATH12K_AMPDU_SUBFRM_NUM_10
,
401 ATH12K_AMPDU_SUBFRM_NUM_20
,
402 ATH12K_AMPDU_SUBFRM_NUM_30
,
403 ATH12K_AMPDU_SUBFRM_NUM_40
,
404 ATH12K_AMPDU_SUBFRM_NUM_50
,
405 ATH12K_AMPDU_SUBFRM_NUM_60
,
406 ATH12K_AMPDU_SUBFRM_NUM_MORE
,
407 ATH12K_AMPDU_SUBFRM_NUM_MAX
,
410 enum ath12k_amsdu_subfrm_num
{
411 ATH12K_AMSDU_SUBFRM_NUM_1
,
412 ATH12K_AMSDU_SUBFRM_NUM_2
,
413 ATH12K_AMSDU_SUBFRM_NUM_3
,
414 ATH12K_AMSDU_SUBFRM_NUM_4
,
415 ATH12K_AMSDU_SUBFRM_NUM_MORE
,
416 ATH12K_AMSDU_SUBFRM_NUM_MAX
,
419 enum ath12k_counter_type
{
420 ATH12K_COUNTER_TYPE_BYTES
,
421 ATH12K_COUNTER_TYPE_PKTS
,
422 ATH12K_COUNTER_TYPE_MAX
,
425 enum ath12k_stats_type
{
426 ATH12K_STATS_TYPE_SUCC
,
427 ATH12K_STATS_TYPE_FAIL
,
428 ATH12K_STATS_TYPE_RETRY
,
429 ATH12K_STATS_TYPE_AMPDU
,
430 ATH12K_STATS_TYPE_MAX
,
433 struct ath12k_htt_data_stats
{
434 u64 legacy
[ATH12K_COUNTER_TYPE_MAX
][ATH12K_LEGACY_NUM
];
435 u64 ht
[ATH12K_COUNTER_TYPE_MAX
][ATH12K_HT_MCS_NUM
];
436 u64 vht
[ATH12K_COUNTER_TYPE_MAX
][ATH12K_VHT_MCS_NUM
];
437 u64 he
[ATH12K_COUNTER_TYPE_MAX
][ATH12K_HE_MCS_NUM
];
438 u64 bw
[ATH12K_COUNTER_TYPE_MAX
][ATH12K_BW_NUM
];
439 u64 nss
[ATH12K_COUNTER_TYPE_MAX
][ATH12K_NSS_NUM
];
440 u64 gi
[ATH12K_COUNTER_TYPE_MAX
][ATH12K_GI_NUM
];
441 u64 transmit_type
[ATH12K_COUNTER_TYPE_MAX
][HAL_RX_RECEPTION_TYPE_MAX
];
442 u64 ru_loc
[ATH12K_COUNTER_TYPE_MAX
][HAL_RX_RU_ALLOC_TYPE_MAX
];
445 struct ath12k_htt_tx_stats
{
446 struct ath12k_htt_data_stats stats
[ATH12K_STATS_TYPE_MAX
];
452 u32 mu_group
[MAX_MU_GROUP_ID
];
455 struct ath12k_per_ppdu_tx_stats
{
464 struct ath12k_wbm_tx_stats
{
465 u64 wbm_tx_comp_stats
[HAL_WBM_REL_HTT_TX_COMP_STATUS_MAX
];
468 struct ath12k_link_sta
{
469 struct ath12k_link_vif
*arvif
;
470 struct ath12k_sta
*ahsta
;
472 /* the following are protected by ar->data_lock */
473 u32 changed
; /* IEEE80211_RC_* */
478 struct wiphy_work update_wk
;
479 struct rate_info txrate
;
480 struct rate_info last_txrate
;
485 struct ath12k_rx_peer_stats
*rx_stats
;
486 struct ath12k_wbm_tx_stats
*wbm_tx_stats
;
491 enum hal_pn_type pn_type
;
492 struct ath12k_link_sta deflink
;
493 struct ath12k_link_sta __rcu
*link
[IEEE80211_MLD_MAX_NUM_LINKS
];
494 /* indicates bitmap of link sta created in FW */
498 #define ATH12K_MIN_5G_FREQ 4150
499 #define ATH12K_MIN_6G_FREQ 5925
500 #define ATH12K_MAX_6G_FREQ 7115
501 #define ATH12K_NUM_CHANS 101
502 #define ATH12K_MAX_5G_CHAN 173
504 enum ath12k_hw_state
{
507 ATH12K_HW_STATE_RESTARTING
,
508 ATH12K_HW_STATE_RESTARTED
,
509 ATH12K_HW_STATE_WEDGED
,
510 /* Add other states as required */
513 /* Antenna noise floor */
514 #define ATH12K_DEFAULT_NOISE_FLOOR -95
516 struct ath12k_fw_stats
{
519 struct list_head pdevs
;
520 struct list_head vdevs
;
521 struct list_head bcn
;
524 struct ath12k_dbg_htt_stats
{
525 enum ath12k_dbg_htt_ext_stats_type type
;
528 struct debug_htt_stats_req
*stats_req
;
531 struct ath12k_debug
{
532 struct dentry
*debugfs_pdev
;
533 struct dentry
*debugfs_pdev_symlink
;
534 struct ath12k_dbg_htt_stats htt_stats
;
537 struct ath12k_per_peer_tx_stats
{
554 #define ATH12K_FLUSH_TIMEOUT (5 * HZ)
555 #define ATH12K_VDEV_DELETE_TIMEOUT_HZ (5 * HZ)
558 struct ath12k_base
*ab
;
559 struct ath12k_pdev
*pdev
;
560 struct ath12k_hw
*ah
;
561 struct ath12k_wmi_pdev
*wmi
;
562 struct ath12k_pdev_dp dp
;
563 u8 mac_addr
[ETH_ALEN
];
566 struct ath12k_he ar_he
;
569 struct completion started
;
570 struct completion completed
;
571 struct completion on_channel
;
572 struct delayed_work timeout
;
573 enum ath12k_scan_state state
;
581 struct ieee80211_supported_band sbands
[NUM_NL80211_BANDS
];
582 struct ieee80211_sband_iftype_data
583 iftype
[NUM_NL80211_BANDS
][NUM_NL80211_IFTYPES
];
586 unsigned long dev_flags
;
587 unsigned int filter_flags
;
590 u32 txpower_limit_2g
;
591 u32 txpower_limit_5g
;
596 u32 max_num_stations
;
598 /* protects the radio specific data like debug stats, ppdu_stats_info stats,
599 * vdev_stop_status info, scan data, ath12k_sta info, ath12k_link_vif info,
600 * channel context data, survey info, test mode data.
602 spinlock_t data_lock
;
604 struct list_head arvifs
;
605 /* should never be NULL; needed for regular htt rx */
606 struct ieee80211_channel
*rx_channel
;
608 /* valid during scan; needed for mgmt rx during scan */
609 struct ieee80211_channel
*scan_channel
;
615 /* pdev_idx starts from 0 whereas pdev->pdev_id starts with 1 */
620 struct completion peer_assoc_done
;
621 struct completion peer_delete_done
;
623 int install_key_status
;
624 struct completion install_key_done
;
626 int last_wmi_vdev_start_status
;
627 struct completion vdev_setup_done
;
628 struct completion vdev_delete_done
;
632 u32 num_started_vdevs
;
633 u32 num_created_vdevs
;
634 unsigned long long allocated_vdev_map
;
636 struct idr txmgmt_idr
;
637 /* protects txmgmt_idr data */
638 spinlock_t txmgmt_idr_lock
;
639 atomic_t num_pending_mgmt_tx
;
640 wait_queue_head_t txmgmt_empty_waitq
;
642 /* cycle count is reported twice for each visited channel during scan.
643 * access protected by data_lock
645 u32 survey_last_rx_clear_count
;
646 u32 survey_last_cycle_count
;
648 /* Channel info events are expected to come in pairs without and with
649 * COMPLETE flag set respectively for each channel visit during scan.
651 * However there are deviations from this rule. This flag is used to
652 * avoid reporting garbage data.
654 bool ch_info_can_report_survey
;
655 struct survey_info survey
[ATH12K_NUM_CHANS
];
656 struct completion bss_survey_done
;
658 struct work_struct regd_update_work
;
660 struct work_struct wmi_mgmt_tx_work
;
661 struct sk_buff_head wmi_mgmt_tx_queue
;
663 struct ath12k_wow wow
;
664 struct completion target_suspend
;
665 bool target_suspend_ack
;
666 struct ath12k_per_peer_tx_stats peer_tx_stats
;
667 struct list_head ppdu_stats_info
;
668 u32 ppdu_stat_list_depth
;
670 struct ath12k_per_peer_tx_stats cached_stats
;
673 #ifdef CONFIG_ATH12K_DEBUGFS
674 struct ath12k_debug debug
;
677 bool dfs_block_radar_events
;
678 bool monitor_conf_enabled
;
679 bool monitor_vdev_created
;
680 bool monitor_started
;
690 struct ieee80211_hw
*hw
;
691 /* Protect the write operation of the hardware state ath12k_hw::state
692 * between hardware start<=>reconfigure<=>stop transitions.
694 struct mutex hw_mutex
;
695 enum ath12k_hw_state state
;
702 struct ath12k radio
[] __aligned(sizeof(void *));
705 struct ath12k_band_cap
{
707 u32 max_bw_supported
;
711 u32 he_cap_phy_info
[PSOC_HOST_MAX_PHY_SIZE
];
712 struct ath12k_wmi_ppe_threshold_arg he_ppet
;
714 u32 eht_cap_mac_info
[WMI_MAX_EHTCAP_MAC_SIZE
];
715 u32 eht_cap_phy_info
[WMI_MAX_EHTCAP_PHY_SIZE
];
720 struct ath12k_wmi_ppe_threshold_arg eht_ppet
;
721 u32 eht_cap_info_internal
;
724 struct ath12k_pdev_cap
{
732 u32 tx_chain_mask_shift
;
733 u32 rx_chain_mask_shift
;
734 struct ath12k_band_cap band
[NUM_NL80211_BANDS
];
737 struct mlo_timestamp
{
739 u32 sync_timestamp_lo_us
;
740 u32 sync_timestamp_hi_us
;
752 struct ath12k_pdev_cap cap
;
753 u8 mac_addr
[ETH_ALEN
];
754 struct mlo_timestamp timestamp
;
757 struct ath12k_fw_pdev
{
763 struct ath12k_board_data
{
764 const struct firmware
*fw
;
769 struct ath12k_soc_dp_tx_err_stats
{
770 /* TCL Ring Descriptor unavailable */
771 u32 desc_na
[DP_TCL_NUM_RING_MAX
];
772 /* Other failures during dp_tx due to mem allocation failure
773 * idr unavailable etc.
778 struct ath12k_soc_dp_stats
{
781 u32 rxdma_error
[HAL_REO_ENTR_RING_RXDMA_ECODE_MAX
];
782 u32 reo_error
[HAL_REO_DEST_RING_ERROR_CODE_MAX
];
783 u32 hal_reo_error
[DP_REO_DST_RING_MAX
];
784 struct ath12k_soc_dp_tx_err_stats tx_err
;
788 * enum ath12k_link_capable_flags - link capable flags
790 * Single/Multi link capability information
792 * @ATH12K_INTRA_DEVICE_MLO_SUPPORT: SLO/MLO form between the radio, where all
793 * the links (radios) present within a device.
794 * @ATH12K_INTER_DEVICE_MLO_SUPPORT: SLO/MLO form between the radio, where all
795 * the links (radios) present across the devices.
797 enum ath12k_link_capable_flags
{
798 ATH12K_INTRA_DEVICE_MLO_SUPPORT
= BIT(0),
799 ATH12K_INTER_DEVICE_MLO_SUPPORT
= BIT(1),
802 /* Master structure to hold the hw data which may be used in core module */
804 enum ath12k_hw_rev hw_rev
;
805 struct platform_device
*pdev
;
807 struct ath12k_qmi qmi
;
808 struct ath12k_wmi_base wmi_ab
;
809 struct completion fw_ready
;
812 /* HW channel counters frequency value in hertz common to all MACs */
815 struct ath12k_dump_file_data
*dump_data
;
816 size_t ath12k_coredump_len
;
817 struct work_struct dump_work
;
819 struct ath12k_htc htc
;
824 unsigned long mem_len
;
828 const struct ath12k_hif_ops
*ops
;
832 struct completion wakeup_completed
;
833 u32 wmi_conf_rx_decap_mode
;
837 struct timer_list rx_replenish_retry
;
838 struct ath12k_hal hal
;
839 /* To synchronize core_start/core_stop */
840 struct mutex core_lock
;
841 /* Protects data like peers */
842 spinlock_t base_lock
;
844 /* Single pdev device (struct ath12k_hw_params::single_pdev_only):
846 * Firmware maintains data for all bands but advertises a single
847 * phy to the host which is stored as a single element in this
852 * This array will contain as many elements as the number of
855 struct ath12k_pdev pdevs
[MAX_RADIOS
];
857 /* struct ath12k_hw_params::single_pdev_only devices use this to
858 * store phy specific data
860 struct ath12k_fw_pdev fw_pdev
[MAX_RADIOS
];
863 struct ath12k_pdev __rcu
*pdevs_active
[MAX_RADIOS
];
865 /* Holds information of wiphy (hw) registration.
867 * In Multi/Single Link Operation case, all pdevs are registered as
868 * a single wiphy. In other (legacy/Non-MLO) cases, each pdev is
869 * registered as separate wiphys.
871 struct ath12k_hw
*ah
[MAX_RADIOS
];
874 struct ath12k_wmi_hal_reg_capabilities_ext_arg hal_reg_cap
[MAX_RADIOS
];
875 unsigned long long free_vdev_map
;
876 unsigned long long free_vdev_stats_id_map
;
877 struct list_head peers
;
878 wait_queue_head_t peer_mapping_wq
;
879 u8 mac_addr
[ETH_ALEN
];
881 u32 wlan_init_status
;
882 int irq_num
[ATH12K_IRQ_NUM_MAX
];
883 struct ath12k_ext_irq_grp ext_irq_grp
[ATH12K_EXT_IRQ_GRP_NUM_MAX
];
884 struct napi_struct
*napi
;
885 struct ath12k_wmi_target_cap_arg target_caps
;
886 u32 ext_service_bitmap
[WMI_SERVICE_EXT_BM_SIZE
];
887 bool pdevs_macaddr_valid
;
889 const struct ath12k_hw_params
*hw_params
;
891 const struct firmware
*cal_file
;
893 /* Below regd's are protected by ab->data_lock */
894 /* This is the regd set for every radio
895 * by the firmware during initialization
897 struct ieee80211_regdomain
*default_regd
[MAX_RADIOS
];
898 /* This regd is set during dynamic country setting
899 * This may or may not be used during the runtime
901 struct ieee80211_regdomain
*new_regd
[MAX_RADIOS
];
903 /* Current DFS Regulatory */
904 enum ath12k_dfs_region dfs_region
;
905 struct ath12k_soc_dp_stats soc_stats
;
906 #ifdef CONFIG_ATH12K_DEBUGFS
907 struct dentry
*debugfs_soc
;
910 unsigned long dev_flags
;
911 struct completion driver_recovery
;
912 struct workqueue_struct
*workqueue
;
913 struct work_struct restart_work
;
914 struct workqueue_struct
*workqueue_aux
;
915 struct work_struct reset_work
;
916 atomic_t reset_count
;
917 atomic_t recovery_count
;
919 struct completion reset_complete
;
920 /* continuous recovery fail count */
921 atomic_t fail_cont_count
;
922 unsigned long reset_fail_timeout
;
924 /* protected by data_lock */
925 u32 fw_crash_counter
;
927 u32 pktlog_defs_checksum
;
929 struct ath12k_dbring_cap
*db_caps
;
932 struct timer_list mon_reap_timer
;
934 struct completion htc_suspend
;
936 u64 fw_soc_drop_count
;
937 bool static_window_map
;
939 struct work_struct rfkill_work
;
940 /* true means radio is on */
941 bool rfkill_radio_on
;
944 enum ath12k_bdf_search bdf_search
;
947 u32 subsystem_vendor
;
948 u32 subsystem_device
;
954 const struct firmware
*fw
;
957 const u8
*amss_dualmac_data
;
958 size_t amss_dualmac_len
;
962 DECLARE_BITMAP(fw_features
, ATH12K_FW_FEATURE_COUNT
);
965 const struct hal_rx_ops
*hal_rx_ops
;
967 /* mlo_capable_flags denotes the single/multi link operation
968 * capabilities of the Device.
970 * See enum ath12k_link_capable_flags
972 u8 mlo_capable_flags
;
974 struct completion restart_completed
;
981 bool acpi_tas_enable
;
982 bool acpi_bios_sar_enable
;
983 u8 tas_cfg
[ATH12K_ACPI_DSM_TAS_CFG_SIZE
];
984 u8 tas_sar_power_table
[ATH12K_ACPI_DSM_TAS_DATA_SIZE
];
985 u8 bios_sar_data
[ATH12K_ACPI_DSM_BIOS_SAR_DATA_SIZE
];
986 u8 geo_offset_data
[ATH12K_ACPI_DSM_GEO_OFFSET_DATA_SIZE
];
987 u8 cca_data
[ATH12K_ACPI_DSM_CCA_DATA_SIZE
];
988 u8 band_edge_power
[ATH12K_ACPI_DSM_BAND_EDGE_DATA_SIZE
];
991 #endif /* CONFIG_ACPI */
993 struct notifier_block panic_nb
;
996 u8 drv_priv
[] __aligned(sizeof(void *));
999 struct ath12k_pdev_map
{
1000 struct ath12k_base
*ab
;
1004 int ath12k_core_qmi_firmware_ready(struct ath12k_base
*ab
);
1005 int ath12k_core_pre_init(struct ath12k_base
*ab
);
1006 int ath12k_core_init(struct ath12k_base
*ath12k
);
1007 void ath12k_core_deinit(struct ath12k_base
*ath12k
);
1008 struct ath12k_base
*ath12k_core_alloc(struct device
*dev
, size_t priv_size
,
1009 enum ath12k_bus bus
);
1010 void ath12k_core_free(struct ath12k_base
*ath12k
);
1011 int ath12k_core_fetch_board_data_api_1(struct ath12k_base
*ab
,
1012 struct ath12k_board_data
*bd
,
1014 int ath12k_core_fetch_bdf(struct ath12k_base
*ath12k
,
1015 struct ath12k_board_data
*bd
);
1016 void ath12k_core_free_bdf(struct ath12k_base
*ab
, struct ath12k_board_data
*bd
);
1017 int ath12k_core_fetch_regdb(struct ath12k_base
*ab
, struct ath12k_board_data
*bd
);
1018 int ath12k_core_check_dt(struct ath12k_base
*ath12k
);
1019 int ath12k_core_check_smbios(struct ath12k_base
*ab
);
1020 void ath12k_core_halt(struct ath12k
*ar
);
1021 int ath12k_core_resume_early(struct ath12k_base
*ab
);
1022 int ath12k_core_resume(struct ath12k_base
*ab
);
1023 int ath12k_core_suspend(struct ath12k_base
*ab
);
1024 int ath12k_core_suspend_late(struct ath12k_base
*ab
);
1026 const struct firmware
*ath12k_core_firmware_request(struct ath12k_base
*ab
,
1027 const char *filename
);
1028 u32
ath12k_core_get_max_station_per_radio(struct ath12k_base
*ab
);
1029 u32
ath12k_core_get_max_peers_per_radio(struct ath12k_base
*ab
);
1030 u32
ath12k_core_get_max_num_tids(struct ath12k_base
*ab
);
1032 static inline const char *ath12k_scan_state_str(enum ath12k_scan_state state
)
1035 case ATH12K_SCAN_IDLE
:
1037 case ATH12K_SCAN_STARTING
:
1039 case ATH12K_SCAN_RUNNING
:
1041 case ATH12K_SCAN_ABORTING
:
1048 static inline struct ath12k_skb_cb
*ATH12K_SKB_CB(struct sk_buff
*skb
)
1050 BUILD_BUG_ON(sizeof(struct ath12k_skb_cb
) >
1051 IEEE80211_TX_INFO_DRIVER_DATA_SIZE
);
1052 return (struct ath12k_skb_cb
*)&IEEE80211_SKB_CB(skb
)->driver_data
;
1055 static inline struct ath12k_skb_rxcb
*ATH12K_SKB_RXCB(struct sk_buff
*skb
)
1057 BUILD_BUG_ON(sizeof(struct ath12k_skb_rxcb
) > sizeof(skb
->cb
));
1058 return (struct ath12k_skb_rxcb
*)skb
->cb
;
1061 static inline struct ath12k_vif
*ath12k_vif_to_ahvif(struct ieee80211_vif
*vif
)
1063 return (struct ath12k_vif
*)vif
->drv_priv
;
1066 static inline struct ath12k_sta
*ath12k_sta_to_ahsta(struct ieee80211_sta
*sta
)
1068 return (struct ath12k_sta
*)sta
->drv_priv
;
1071 static inline struct ieee80211_sta
*ath12k_ahsta_to_sta(struct ath12k_sta
*ahsta
)
1073 return container_of((void *)ahsta
, struct ieee80211_sta
, drv_priv
);
1076 static inline struct ieee80211_vif
*ath12k_ahvif_to_vif(struct ath12k_vif
*ahvif
)
1078 return container_of((void *)ahvif
, struct ieee80211_vif
, drv_priv
);
1081 static inline struct ath12k
*ath12k_ab_to_ar(struct ath12k_base
*ab
,
1084 return ab
->pdevs
[ath12k_hw_mac_id_to_pdev_id(ab
->hw_params
, mac_id
)].ar
;
1087 static inline void ath12k_core_create_firmware_path(struct ath12k_base
*ab
,
1088 const char *filename
,
1089 void *buf
, size_t buf_len
)
1091 snprintf(buf
, buf_len
, "%s/%s/%s", ATH12K_FW_DIR
,
1092 ab
->hw_params
->fw
.dir
, filename
);
1095 static inline const char *ath12k_bus_str(enum ath12k_bus bus
)
1098 case ATH12K_BUS_PCI
:
1105 static inline struct ath12k_hw
*ath12k_hw_to_ah(struct ieee80211_hw
*hw
)
1110 static inline struct ath12k
*ath12k_ah_to_ar(struct ath12k_hw
*ah
, u8 hw_link_id
)
1112 if (WARN(hw_link_id
>= ah
->num_radio
,
1113 "bad hw link id %d, so switch to default link\n", hw_link_id
))
1116 return &ah
->radio
[hw_link_id
];
1119 static inline struct ath12k_hw
*ath12k_ar_to_ah(struct ath12k
*ar
)
1124 static inline struct ieee80211_hw
*ath12k_ar_to_hw(struct ath12k
*ar
)
1129 #define for_each_ar(ah, ar, index) \
1130 for ((index) = 0; ((index) < (ah)->num_radio && \
1131 ((ar) = &(ah)->radio[(index)])); (index)++)
1132 #endif /* _CORE_H_ */