1 /* SPDX-License-Identifier: BSD-3-Clause-Clear */ 2 /* 3 * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved. 4 */ 5 6 #ifndef ATH11K_CORE_H 7 #define ATH11K_CORE_H 8 9 #include <linux/types.h> 10 #include <linux/interrupt.h> 11 #include <linux/irq.h> 12 #include <linux/bitfield.h> 13 #include "qmi.h" 14 #include "htc.h" 15 #include "wmi.h" 16 #include "hal.h" 17 #include "dp.h" 18 #include "ce.h" 19 #include "mac.h" 20 #include "hw.h" 21 #include "hal_rx.h" 22 #include "reg.h" 23 #include "thermal.h" 24 #include "dbring.h" 25 #include "spectral.h" 26 27 #define SM(_v, _f) (((_v) << _f##_LSB) & _f##_MASK) 28 29 #define ATH11K_TX_MGMT_NUM_PENDING_MAX 512 30 31 #define ATH11K_TX_MGMT_TARGET_MAX_SUPPORT_WMI 64 32 33 /* Pending management packets threshold for dropping probe responses */ 34 #define ATH11K_PRB_RSP_DROP_THRESHOLD ((ATH11K_TX_MGMT_TARGET_MAX_SUPPORT_WMI * 3) / 4) 35 36 #define ATH11K_INVALID_HW_MAC_ID 0xFF 37 #define ATH11K_CONNECTION_LOSS_HZ (3 * HZ) 38 39 extern unsigned int ath11k_frame_mode; 40 41 #define ATH11K_MON_TIMER_INTERVAL 10 42 43 enum ath11k_supported_bw { 44 ATH11K_BW_20 = 0, 45 ATH11K_BW_40 = 1, 46 ATH11K_BW_80 = 2, 47 ATH11K_BW_160 = 3, 48 }; 49 50 enum ath11k_bdf_search { 51 ATH11K_BDF_SEARCH_DEFAULT, 52 ATH11K_BDF_SEARCH_BUS_AND_BOARD, 53 }; 54 55 enum wme_ac { 56 WME_AC_BE, 57 WME_AC_BK, 58 WME_AC_VI, 59 WME_AC_VO, 60 WME_NUM_AC 61 }; 62 63 #define ATH11K_HT_MCS_MAX 7 64 #define ATH11K_VHT_MCS_MAX 9 65 #define ATH11K_HE_MCS_MAX 11 66 67 enum ath11k_crypt_mode { 68 /* Only use hardware crypto engine */ 69 ATH11K_CRYPT_MODE_HW, 70 /* Only use software crypto */ 71 ATH11K_CRYPT_MODE_SW, 72 }; 73 74 static inline enum wme_ac ath11k_tid_to_ac(u32 tid) 75 { 76 return (((tid == 0) || (tid == 3)) ? WME_AC_BE : 77 ((tid == 1) || (tid == 2)) ? WME_AC_BK : 78 ((tid == 4) || (tid == 5)) ? WME_AC_VI : 79 WME_AC_VO); 80 } 81 82 enum ath11k_skb_flags { 83 ATH11K_SKB_HW_80211_ENCAP = BIT(0), 84 ATH11K_SKB_CIPHER_SET = BIT(1), 85 }; 86 87 struct ath11k_skb_cb { 88 dma_addr_t paddr; 89 u8 eid; 90 u8 flags; 91 u32 cipher; 92 struct ath11k *ar; 93 struct ieee80211_vif *vif; 94 } __packed; 95 96 struct ath11k_skb_rxcb { 97 dma_addr_t paddr; 98 bool is_first_msdu; 99 bool is_last_msdu; 100 bool is_continuation; 101 bool is_mcbc; 102 bool is_eapol; 103 struct hal_rx_desc *rx_desc; 104 u8 err_rel_src; 105 u8 err_code; 106 u8 mac_id; 107 u8 unmapped; 108 u8 is_frag; 109 u8 tid; 110 u16 peer_id; 111 u16 seq_no; 112 }; 113 114 enum ath11k_hw_rev { 115 ATH11K_HW_IPQ8074, 116 ATH11K_HW_QCA6390_HW20, 117 ATH11K_HW_IPQ6018_HW10, 118 ATH11K_HW_QCN9074_HW10, 119 ATH11K_HW_WCN6855_HW20, 120 }; 121 122 enum ath11k_firmware_mode { 123 /* the default mode, standard 802.11 functionality */ 124 ATH11K_FIRMWARE_MODE_NORMAL, 125 126 /* factory tests etc */ 127 ATH11K_FIRMWARE_MODE_FTM, 128 129 /* Cold boot calibration */ 130 ATH11K_FIRMWARE_MODE_COLD_BOOT = 7, 131 }; 132 133 extern bool ath11k_cold_boot_cal; 134 135 #define ATH11K_IRQ_NUM_MAX 52 136 #define ATH11K_EXT_IRQ_NUM_MAX 16 137 138 struct ath11k_ext_irq_grp { 139 struct ath11k_base *ab; 140 u32 irqs[ATH11K_EXT_IRQ_NUM_MAX]; 141 u32 num_irq; 142 u32 grp_id; 143 u64 timestamp; 144 struct napi_struct napi; 145 struct net_device napi_ndev; 146 }; 147 148 #define HEHANDLE_CAP_PHYINFO_SIZE 3 149 #define HECAP_PHYINFO_SIZE 9 150 #define HECAP_MACINFO_SIZE 5 151 #define HECAP_TXRX_MCS_NSS_SIZE 2 152 #define HECAP_PPET16_PPET8_MAX_SIZE 25 153 154 #define HE_PPET16_PPET8_SIZE 8 155 156 /* 802.11ax PPE (PPDU packet Extension) threshold */ 157 struct he_ppe_threshold { 158 u32 numss_m1; 159 u32 ru_mask; 160 u32 ppet16_ppet8_ru3_ru0[HE_PPET16_PPET8_SIZE]; 161 }; 162 163 struct ath11k_he { 164 u8 hecap_macinfo[HECAP_MACINFO_SIZE]; 165 u32 hecap_rxmcsnssmap; 166 u32 hecap_txmcsnssmap; 167 u32 hecap_phyinfo[HEHANDLE_CAP_PHYINFO_SIZE]; 168 struct he_ppe_threshold hecap_ppet; 169 u32 heop_param; 170 }; 171 172 #define MAX_RADIOS 3 173 174 enum { 175 WMI_HOST_TP_SCALE_MAX = 0, 176 WMI_HOST_TP_SCALE_50 = 1, 177 WMI_HOST_TP_SCALE_25 = 2, 178 WMI_HOST_TP_SCALE_12 = 3, 179 WMI_HOST_TP_SCALE_MIN = 4, 180 WMI_HOST_TP_SCALE_SIZE = 5, 181 }; 182 183 enum ath11k_scan_state { 184 ATH11K_SCAN_IDLE, 185 ATH11K_SCAN_STARTING, 186 ATH11K_SCAN_RUNNING, 187 ATH11K_SCAN_ABORTING, 188 }; 189 190 enum ath11k_dev_flags { 191 ATH11K_CAC_RUNNING, 192 ATH11K_FLAG_CORE_REGISTERED, 193 ATH11K_FLAG_CRASH_FLUSH, 194 ATH11K_FLAG_RAW_MODE, 195 ATH11K_FLAG_HW_CRYPTO_DISABLED, 196 ATH11K_FLAG_BTCOEX, 197 ATH11K_FLAG_RECOVERY, 198 ATH11K_FLAG_UNREGISTERING, 199 ATH11K_FLAG_REGISTERED, 200 ATH11K_FLAG_QMI_FAIL, 201 ATH11K_FLAG_HTC_SUSPEND_COMPLETE, 202 }; 203 204 enum ath11k_monitor_flags { 205 ATH11K_FLAG_MONITOR_CONF_ENABLED, 206 ATH11K_FLAG_MONITOR_STARTED, 207 ATH11K_FLAG_MONITOR_VDEV_CREATED, 208 }; 209 210 struct ath11k_vif { 211 u32 vdev_id; 212 enum wmi_vdev_type vdev_type; 213 enum wmi_vdev_subtype vdev_subtype; 214 u32 beacon_interval; 215 u32 dtim_period; 216 u16 ast_hash; 217 u16 ast_idx; 218 u16 tcl_metadata; 219 u8 hal_addr_search_flags; 220 u8 search_type; 221 222 struct ath11k *ar; 223 struct ieee80211_vif *vif; 224 225 u16 tx_seq_no; 226 struct wmi_wmm_params_all_arg wmm_params; 227 struct list_head list; 228 union { 229 struct { 230 u32 uapsd; 231 } sta; 232 struct { 233 /* 127 stations; wmi limit */ 234 u8 tim_bitmap[16]; 235 u8 tim_len; 236 u32 ssid_len; 237 u8 ssid[IEEE80211_MAX_SSID_LEN]; 238 bool hidden_ssid; 239 /* P2P_IE with NoA attribute for P2P_GO case */ 240 u32 noa_len; 241 u8 *noa_data; 242 } ap; 243 } u; 244 245 bool is_started; 246 bool is_up; 247 bool spectral_enabled; 248 bool ps; 249 u32 aid; 250 u8 bssid[ETH_ALEN]; 251 struct cfg80211_bitrate_mask bitrate_mask; 252 struct delayed_work connection_loss_work; 253 int num_legacy_stations; 254 int rtscts_prot_mode; 255 int txpower; 256 bool rsnie_present; 257 bool wpaie_present; 258 bool bcca_zero_sent; 259 bool do_not_send_tmpl; 260 struct ieee80211_chanctx_conf chanctx; 261 }; 262 263 struct ath11k_vif_iter { 264 u32 vdev_id; 265 struct ath11k_vif *arvif; 266 }; 267 268 struct ath11k_rx_peer_stats { 269 u64 num_msdu; 270 u64 num_mpdu_fcs_ok; 271 u64 num_mpdu_fcs_err; 272 u64 tcp_msdu_count; 273 u64 udp_msdu_count; 274 u64 other_msdu_count; 275 u64 ampdu_msdu_count; 276 u64 non_ampdu_msdu_count; 277 u64 stbc_count; 278 u64 beamformed_count; 279 u64 mcs_count[HAL_RX_MAX_MCS + 1]; 280 u64 nss_count[HAL_RX_MAX_NSS]; 281 u64 bw_count[HAL_RX_BW_MAX]; 282 u64 gi_count[HAL_RX_GI_MAX]; 283 u64 coding_count[HAL_RX_SU_MU_CODING_MAX]; 284 u64 tid_count[IEEE80211_NUM_TIDS + 1]; 285 u64 pream_cnt[HAL_RX_PREAMBLE_MAX]; 286 u64 reception_type[HAL_RX_RECEPTION_TYPE_MAX]; 287 u64 rx_duration; 288 u64 dcm_count; 289 u64 ru_alloc_cnt[HAL_RX_RU_ALLOC_TYPE_MAX]; 290 }; 291 292 #define ATH11K_HE_MCS_NUM 12 293 #define ATH11K_VHT_MCS_NUM 10 294 #define ATH11K_BW_NUM 4 295 #define ATH11K_NSS_NUM 4 296 #define ATH11K_LEGACY_NUM 12 297 #define ATH11K_GI_NUM 4 298 #define ATH11K_HT_MCS_NUM 32 299 300 enum ath11k_pkt_rx_err { 301 ATH11K_PKT_RX_ERR_FCS, 302 ATH11K_PKT_RX_ERR_TKIP, 303 ATH11K_PKT_RX_ERR_CRYPT, 304 ATH11K_PKT_RX_ERR_PEER_IDX_INVAL, 305 ATH11K_PKT_RX_ERR_MAX, 306 }; 307 308 enum ath11k_ampdu_subfrm_num { 309 ATH11K_AMPDU_SUBFRM_NUM_10, 310 ATH11K_AMPDU_SUBFRM_NUM_20, 311 ATH11K_AMPDU_SUBFRM_NUM_30, 312 ATH11K_AMPDU_SUBFRM_NUM_40, 313 ATH11K_AMPDU_SUBFRM_NUM_50, 314 ATH11K_AMPDU_SUBFRM_NUM_60, 315 ATH11K_AMPDU_SUBFRM_NUM_MORE, 316 ATH11K_AMPDU_SUBFRM_NUM_MAX, 317 }; 318 319 enum ath11k_amsdu_subfrm_num { 320 ATH11K_AMSDU_SUBFRM_NUM_1, 321 ATH11K_AMSDU_SUBFRM_NUM_2, 322 ATH11K_AMSDU_SUBFRM_NUM_3, 323 ATH11K_AMSDU_SUBFRM_NUM_4, 324 ATH11K_AMSDU_SUBFRM_NUM_MORE, 325 ATH11K_AMSDU_SUBFRM_NUM_MAX, 326 }; 327 328 enum ath11k_counter_type { 329 ATH11K_COUNTER_TYPE_BYTES, 330 ATH11K_COUNTER_TYPE_PKTS, 331 ATH11K_COUNTER_TYPE_MAX, 332 }; 333 334 enum ath11k_stats_type { 335 ATH11K_STATS_TYPE_SUCC, 336 ATH11K_STATS_TYPE_FAIL, 337 ATH11K_STATS_TYPE_RETRY, 338 ATH11K_STATS_TYPE_AMPDU, 339 ATH11K_STATS_TYPE_MAX, 340 }; 341 342 struct ath11k_htt_data_stats { 343 u64 legacy[ATH11K_COUNTER_TYPE_MAX][ATH11K_LEGACY_NUM]; 344 u64 ht[ATH11K_COUNTER_TYPE_MAX][ATH11K_HT_MCS_NUM]; 345 u64 vht[ATH11K_COUNTER_TYPE_MAX][ATH11K_VHT_MCS_NUM]; 346 u64 he[ATH11K_COUNTER_TYPE_MAX][ATH11K_HE_MCS_NUM]; 347 u64 bw[ATH11K_COUNTER_TYPE_MAX][ATH11K_BW_NUM]; 348 u64 nss[ATH11K_COUNTER_TYPE_MAX][ATH11K_NSS_NUM]; 349 u64 gi[ATH11K_COUNTER_TYPE_MAX][ATH11K_GI_NUM]; 350 }; 351 352 struct ath11k_htt_tx_stats { 353 struct ath11k_htt_data_stats stats[ATH11K_STATS_TYPE_MAX]; 354 u64 tx_duration; 355 u64 ba_fails; 356 u64 ack_fails; 357 }; 358 359 struct ath11k_per_ppdu_tx_stats { 360 u16 succ_pkts; 361 u16 failed_pkts; 362 u16 retry_pkts; 363 u32 succ_bytes; 364 u32 failed_bytes; 365 u32 retry_bytes; 366 }; 367 368 struct ath11k_sta { 369 struct ath11k_vif *arvif; 370 371 /* the following are protected by ar->data_lock */ 372 u32 changed; /* IEEE80211_RC_* */ 373 u32 bw; 374 u32 nss; 375 u32 smps; 376 enum hal_pn_type pn_type; 377 378 struct work_struct update_wk; 379 struct work_struct set_4addr_wk; 380 struct rate_info txrate; 381 struct rate_info last_txrate; 382 u64 rx_duration; 383 u64 tx_duration; 384 u8 rssi_comb; 385 struct ath11k_htt_tx_stats *tx_stats; 386 struct ath11k_rx_peer_stats *rx_stats; 387 388 #ifdef CONFIG_MAC80211_DEBUGFS 389 /* protected by conf_mutex */ 390 bool aggr_mode; 391 #endif 392 393 bool use_4addr_set; 394 u16 tcl_metadata; 395 }; 396 397 #define ATH11K_MIN_5G_FREQ 4150 398 #define ATH11K_MIN_6G_FREQ 5925 399 #define ATH11K_MAX_6G_FREQ 7115 400 #define ATH11K_NUM_CHANS 101 401 #define ATH11K_MAX_5G_CHAN 173 402 403 enum ath11k_state { 404 ATH11K_STATE_OFF, 405 ATH11K_STATE_ON, 406 ATH11K_STATE_RESTARTING, 407 ATH11K_STATE_RESTARTED, 408 ATH11K_STATE_WEDGED, 409 /* Add other states as required */ 410 }; 411 412 /* Antenna noise floor */ 413 #define ATH11K_DEFAULT_NOISE_FLOOR -95 414 415 struct ath11k_fw_stats { 416 struct dentry *debugfs_fwstats; 417 u32 pdev_id; 418 u32 stats_id; 419 struct list_head pdevs; 420 struct list_head vdevs; 421 struct list_head bcn; 422 }; 423 424 struct ath11k_dbg_htt_stats { 425 u8 type; 426 u8 reset; 427 struct debug_htt_stats_req *stats_req; 428 /* protects shared stats req buffer */ 429 spinlock_t lock; 430 }; 431 432 struct ath11k_debug { 433 struct dentry *debugfs_pdev; 434 struct ath11k_dbg_htt_stats htt_stats; 435 u32 extd_tx_stats; 436 struct ath11k_fw_stats fw_stats; 437 struct completion fw_stats_complete; 438 bool fw_stats_done; 439 u32 extd_rx_stats; 440 u32 pktlog_filter; 441 u32 pktlog_mode; 442 u32 pktlog_peer_valid; 443 u8 pktlog_peer_addr[ETH_ALEN]; 444 u32 rx_filter; 445 }; 446 447 struct ath11k_per_peer_tx_stats { 448 u32 succ_bytes; 449 u32 retry_bytes; 450 u32 failed_bytes; 451 u16 succ_pkts; 452 u16 retry_pkts; 453 u16 failed_pkts; 454 u32 duration; 455 u8 ba_fails; 456 bool is_ampdu; 457 }; 458 459 #define ATH11K_FLUSH_TIMEOUT (5 * HZ) 460 #define ATH11K_VDEV_DELETE_TIMEOUT_HZ (5 * HZ) 461 462 struct ath11k { 463 struct ath11k_base *ab; 464 struct ath11k_pdev *pdev; 465 struct ieee80211_hw *hw; 466 struct ieee80211_ops *ops; 467 struct ath11k_pdev_wmi *wmi; 468 struct ath11k_pdev_dp dp; 469 u8 mac_addr[ETH_ALEN]; 470 u32 ht_cap_info; 471 u32 vht_cap_info; 472 struct ath11k_he ar_he; 473 enum ath11k_state state; 474 bool supports_6ghz; 475 struct { 476 struct completion started; 477 struct completion completed; 478 struct completion on_channel; 479 struct delayed_work timeout; 480 enum ath11k_scan_state state; 481 bool is_roc; 482 int vdev_id; 483 int roc_freq; 484 bool roc_notify; 485 } scan; 486 487 struct { 488 struct ieee80211_supported_band sbands[NUM_NL80211_BANDS]; 489 struct ieee80211_sband_iftype_data 490 iftype[NUM_NL80211_BANDS][NUM_NL80211_IFTYPES]; 491 } mac; 492 493 unsigned long dev_flags; 494 unsigned int filter_flags; 495 unsigned long monitor_flags; 496 u32 min_tx_power; 497 u32 max_tx_power; 498 u32 txpower_limit_2g; 499 u32 txpower_limit_5g; 500 u32 txpower_scale; 501 u32 power_scale; 502 u32 chan_tx_pwr; 503 u32 num_stations; 504 u32 max_num_stations; 505 /* To synchronize concurrent synchronous mac80211 callback operations, 506 * concurrent debugfs configuration and concurrent FW statistics events. 507 */ 508 struct mutex conf_mutex; 509 /* protects the radio specific data like debug stats, ppdu_stats_info stats, 510 * vdev_stop_status info, scan data, ath11k_sta info, ath11k_vif info, 511 * channel context data, survey info, test mode data. 512 */ 513 spinlock_t data_lock; 514 515 struct list_head arvifs; 516 /* should never be NULL; needed for regular htt rx */ 517 struct ieee80211_channel *rx_channel; 518 519 /* valid during scan; needed for mgmt rx during scan */ 520 struct ieee80211_channel *scan_channel; 521 522 u8 cfg_tx_chainmask; 523 u8 cfg_rx_chainmask; 524 u8 num_rx_chains; 525 u8 num_tx_chains; 526 /* pdev_idx starts from 0 whereas pdev->pdev_id starts with 1 */ 527 u8 pdev_idx; 528 u8 lmac_id; 529 530 struct completion peer_assoc_done; 531 struct completion peer_delete_done; 532 533 int install_key_status; 534 struct completion install_key_done; 535 536 int last_wmi_vdev_start_status; 537 struct completion vdev_setup_done; 538 struct completion vdev_delete_done; 539 540 int num_peers; 541 int max_num_peers; 542 u32 num_started_vdevs; 543 u32 num_created_vdevs; 544 unsigned long long allocated_vdev_map; 545 546 struct idr txmgmt_idr; 547 /* protects txmgmt_idr data */ 548 spinlock_t txmgmt_idr_lock; 549 atomic_t num_pending_mgmt_tx; 550 551 /* cycle count is reported twice for each visited channel during scan. 552 * access protected by data_lock 553 */ 554 u32 survey_last_rx_clear_count; 555 u32 survey_last_cycle_count; 556 557 /* Channel info events are expected to come in pairs without and with 558 * COMPLETE flag set respectively for each channel visit during scan. 559 * 560 * However there are deviations from this rule. This flag is used to 561 * avoid reporting garbage data. 562 */ 563 bool ch_info_can_report_survey; 564 struct survey_info survey[ATH11K_NUM_CHANS]; 565 struct completion bss_survey_done; 566 567 struct work_struct regd_update_work; 568 569 struct work_struct wmi_mgmt_tx_work; 570 struct sk_buff_head wmi_mgmt_tx_queue; 571 572 struct ath11k_per_peer_tx_stats peer_tx_stats; 573 struct list_head ppdu_stats_info; 574 u32 ppdu_stat_list_depth; 575 576 struct ath11k_per_peer_tx_stats cached_stats; 577 u32 last_ppdu_id; 578 u32 cached_ppdu_id; 579 int monitor_vdev_id; 580 #ifdef CONFIG_ATH11K_DEBUGFS 581 struct ath11k_debug debug; 582 #endif 583 #ifdef CONFIG_ATH11K_SPECTRAL 584 struct ath11k_spectral spectral; 585 #endif 586 bool dfs_block_radar_events; 587 struct ath11k_thermal thermal; 588 }; 589 590 struct ath11k_band_cap { 591 u32 phy_id; 592 u32 max_bw_supported; 593 u32 ht_cap_info; 594 u32 he_cap_info[2]; 595 u32 he_mcs; 596 u32 he_cap_phy_info[PSOC_HOST_MAX_PHY_SIZE]; 597 struct ath11k_ppe_threshold he_ppet; 598 u16 he_6ghz_capa; 599 }; 600 601 struct ath11k_pdev_cap { 602 u32 supported_bands; 603 u32 ampdu_density; 604 u32 vht_cap; 605 u32 vht_mcs; 606 u32 he_mcs; 607 u32 tx_chain_mask; 608 u32 rx_chain_mask; 609 u32 tx_chain_mask_shift; 610 u32 rx_chain_mask_shift; 611 struct ath11k_band_cap band[NUM_NL80211_BANDS]; 612 bool nss_ratio_enabled; 613 u8 nss_ratio_info; 614 }; 615 616 struct ath11k_pdev { 617 struct ath11k *ar; 618 u32 pdev_id; 619 struct ath11k_pdev_cap cap; 620 u8 mac_addr[ETH_ALEN]; 621 }; 622 623 struct ath11k_board_data { 624 const struct firmware *fw; 625 const void *data; 626 size_t len; 627 }; 628 629 struct ath11k_bus_params { 630 bool mhi_support; 631 bool m3_fw_support; 632 bool fixed_bdf_addr; 633 bool fixed_mem_region; 634 bool static_window_map; 635 }; 636 637 /* IPQ8074 HW channel counters frequency value in hertz */ 638 #define IPQ8074_CC_FREQ_HERTZ 320000 639 640 struct ath11k_bp_stats { 641 /* Head Pointer reported by the last HTT Backpressure event for the ring */ 642 u16 hp; 643 644 /* Tail Pointer reported by the last HTT Backpressure event for the ring */ 645 u16 tp; 646 647 /* Number of Backpressure events received for the ring */ 648 u32 count; 649 650 /* Last recorded event timestamp */ 651 unsigned long jiffies; 652 }; 653 654 struct ath11k_dp_ring_bp_stats { 655 struct ath11k_bp_stats umac_ring_bp_stats[HTT_SW_UMAC_RING_IDX_MAX]; 656 struct ath11k_bp_stats lmac_ring_bp_stats[HTT_SW_LMAC_RING_IDX_MAX][MAX_RADIOS]; 657 }; 658 659 struct ath11k_soc_dp_tx_err_stats { 660 /* TCL Ring Descriptor unavailable */ 661 u32 desc_na[DP_TCL_NUM_RING_MAX]; 662 /* Other failures during dp_tx due to mem allocation failure 663 * idr unavailable etc. 664 */ 665 atomic_t misc_fail; 666 }; 667 668 struct ath11k_soc_dp_stats { 669 u32 err_ring_pkts; 670 u32 invalid_rbm; 671 u32 rxdma_error[HAL_REO_ENTR_RING_RXDMA_ECODE_MAX]; 672 u32 reo_error[HAL_REO_DEST_RING_ERROR_CODE_MAX]; 673 u32 hal_reo_error[DP_REO_DST_RING_MAX]; 674 struct ath11k_soc_dp_tx_err_stats tx_err; 675 struct ath11k_dp_ring_bp_stats bp_stats; 676 }; 677 678 /* Master structure to hold the hw data which may be used in core module */ 679 struct ath11k_base { 680 enum ath11k_hw_rev hw_rev; 681 struct platform_device *pdev; 682 struct device *dev; 683 struct ath11k_qmi qmi; 684 struct ath11k_wmi_base wmi_ab; 685 struct completion fw_ready; 686 int num_radios; 687 /* HW channel counters frequency value in hertz common to all MACs */ 688 u32 cc_freq_hz; 689 690 struct ath11k_htc htc; 691 692 struct ath11k_dp dp; 693 694 void __iomem *mem; 695 unsigned long mem_len; 696 697 struct { 698 enum ath11k_bus bus; 699 const struct ath11k_hif_ops *ops; 700 } hif; 701 702 struct { 703 struct completion wakeup_completed; 704 } wow; 705 706 struct ath11k_ce ce; 707 struct timer_list rx_replenish_retry; 708 struct ath11k_hal hal; 709 /* To synchronize core_start/core_stop */ 710 struct mutex core_lock; 711 /* Protects data like peers */ 712 spinlock_t base_lock; 713 struct ath11k_pdev pdevs[MAX_RADIOS]; 714 struct ath11k_pdev __rcu *pdevs_active[MAX_RADIOS]; 715 struct ath11k_hal_reg_capabilities_ext hal_reg_cap[MAX_RADIOS]; 716 unsigned long long free_vdev_map; 717 struct list_head peers; 718 wait_queue_head_t peer_mapping_wq; 719 u8 mac_addr[ETH_ALEN]; 720 bool wmi_ready; 721 u32 wlan_init_status; 722 int irq_num[ATH11K_IRQ_NUM_MAX]; 723 struct ath11k_ext_irq_grp ext_irq_grp[ATH11K_EXT_IRQ_GRP_NUM_MAX]; 724 struct napi_struct *napi; 725 struct ath11k_targ_cap target_caps; 726 u32 ext_service_bitmap[WMI_SERVICE_EXT_BM_SIZE]; 727 bool pdevs_macaddr_valid; 728 int bd_api; 729 730 struct ath11k_hw_params hw_params; 731 struct ath11k_bus_params bus_params; 732 733 const struct firmware *cal_file; 734 735 /* Below regd's are protected by ab->data_lock */ 736 /* This is the regd set for every radio 737 * by the firmware during initializatin 738 */ 739 struct ieee80211_regdomain *default_regd[MAX_RADIOS]; 740 /* This regd is set during dynamic country setting 741 * This may or may not be used during the runtime 742 */ 743 struct ieee80211_regdomain *new_regd[MAX_RADIOS]; 744 745 /* Current DFS Regulatory */ 746 enum ath11k_dfs_region dfs_region; 747 #ifdef CONFIG_ATH11K_DEBUGFS 748 struct dentry *debugfs_soc; 749 struct dentry *debugfs_ath11k; 750 #endif 751 struct ath11k_soc_dp_stats soc_stats; 752 753 unsigned long dev_flags; 754 struct completion driver_recovery; 755 struct workqueue_struct *workqueue; 756 struct work_struct restart_work; 757 struct { 758 /* protected by data_lock */ 759 u32 fw_crash_counter; 760 } stats; 761 u32 pktlog_defs_checksum; 762 763 struct ath11k_dbring_cap *db_caps; 764 u32 num_db_cap; 765 766 struct timer_list mon_reap_timer; 767 768 struct completion htc_suspend; 769 770 struct { 771 enum ath11k_bdf_search bdf_search; 772 u32 vendor; 773 u32 device; 774 u32 subsystem_vendor; 775 u32 subsystem_device; 776 } id; 777 778 /* must be last */ 779 u8 drv_priv[0] __aligned(sizeof(void *)); 780 }; 781 782 struct ath11k_fw_stats_pdev { 783 struct list_head list; 784 785 /* PDEV stats */ 786 s32 ch_noise_floor; 787 /* Cycles spent transmitting frames */ 788 u32 tx_frame_count; 789 /* Cycles spent receiving frames */ 790 u32 rx_frame_count; 791 /* Total channel busy time, evidently */ 792 u32 rx_clear_count; 793 /* Total on-channel time */ 794 u32 cycle_count; 795 u32 phy_err_count; 796 u32 chan_tx_power; 797 u32 ack_rx_bad; 798 u32 rts_bad; 799 u32 rts_good; 800 u32 fcs_bad; 801 u32 no_beacons; 802 u32 mib_int_count; 803 804 /* PDEV TX stats */ 805 /* Num HTT cookies queued to dispatch list */ 806 s32 comp_queued; 807 /* Num HTT cookies dispatched */ 808 s32 comp_delivered; 809 /* Num MSDU queued to WAL */ 810 s32 msdu_enqued; 811 /* Num MPDU queue to WAL */ 812 s32 mpdu_enqued; 813 /* Num MSDUs dropped by WMM limit */ 814 s32 wmm_drop; 815 /* Num Local frames queued */ 816 s32 local_enqued; 817 /* Num Local frames done */ 818 s32 local_freed; 819 /* Num queued to HW */ 820 s32 hw_queued; 821 /* Num PPDU reaped from HW */ 822 s32 hw_reaped; 823 /* Num underruns */ 824 s32 underrun; 825 /* Num hw paused */ 826 u32 hw_paused; 827 /* Num PPDUs cleaned up in TX abort */ 828 s32 tx_abort; 829 /* Num MPDUs requeued by SW */ 830 s32 mpdus_requeued; 831 /* excessive retries */ 832 u32 tx_ko; 833 u32 tx_xretry; 834 /* data hw rate code */ 835 u32 data_rc; 836 /* Scheduler self triggers */ 837 u32 self_triggers; 838 /* frames dropped due to excessive sw retries */ 839 u32 sw_retry_failure; 840 /* illegal rate phy errors */ 841 u32 illgl_rate_phy_err; 842 /* wal pdev continuous xretry */ 843 u32 pdev_cont_xretry; 844 /* wal pdev tx timeouts */ 845 u32 pdev_tx_timeout; 846 /* wal pdev resets */ 847 u32 pdev_resets; 848 /* frames dropped due to non-availability of stateless TIDs */ 849 u32 stateless_tid_alloc_failure; 850 /* PhY/BB underrun */ 851 u32 phy_underrun; 852 /* MPDU is more than txop limit */ 853 u32 txop_ovf; 854 /* Num sequences posted */ 855 u32 seq_posted; 856 /* Num sequences failed in queueing */ 857 u32 seq_failed_queueing; 858 /* Num sequences completed */ 859 u32 seq_completed; 860 /* Num sequences restarted */ 861 u32 seq_restarted; 862 /* Num of MU sequences posted */ 863 u32 mu_seq_posted; 864 /* Num MPDUs flushed by SW, HWPAUSED, SW TXABORT 865 * (Reset,channel change) 866 */ 867 s32 mpdus_sw_flush; 868 /* Num MPDUs filtered by HW, all filter condition (TTL expired) */ 869 s32 mpdus_hw_filter; 870 /* Num MPDUs truncated by PDG (TXOP, TBTT, 871 * PPDU_duration based on rate, dyn_bw) 872 */ 873 s32 mpdus_truncated; 874 /* Num MPDUs that was tried but didn't receive ACK or BA */ 875 s32 mpdus_ack_failed; 876 /* Num MPDUs that was dropped du to expiry. */ 877 s32 mpdus_expired; 878 879 /* PDEV RX stats */ 880 /* Cnts any change in ring routing mid-ppdu */ 881 s32 mid_ppdu_route_change; 882 /* Total number of statuses processed */ 883 s32 status_rcvd; 884 /* Extra frags on rings 0-3 */ 885 s32 r0_frags; 886 s32 r1_frags; 887 s32 r2_frags; 888 s32 r3_frags; 889 /* MSDUs / MPDUs delivered to HTT */ 890 s32 htt_msdus; 891 s32 htt_mpdus; 892 /* MSDUs / MPDUs delivered to local stack */ 893 s32 loc_msdus; 894 s32 loc_mpdus; 895 /* AMSDUs that have more MSDUs than the status ring size */ 896 s32 oversize_amsdu; 897 /* Number of PHY errors */ 898 s32 phy_errs; 899 /* Number of PHY errors drops */ 900 s32 phy_err_drop; 901 /* Number of mpdu errors - FCS, MIC, ENC etc. */ 902 s32 mpdu_errs; 903 /* Num overflow errors */ 904 s32 rx_ovfl_errs; 905 }; 906 907 struct ath11k_fw_stats_vdev { 908 struct list_head list; 909 910 u32 vdev_id; 911 u32 beacon_snr; 912 u32 data_snr; 913 u32 num_tx_frames[WLAN_MAX_AC]; 914 u32 num_rx_frames; 915 u32 num_tx_frames_retries[WLAN_MAX_AC]; 916 u32 num_tx_frames_failures[WLAN_MAX_AC]; 917 u32 num_rts_fail; 918 u32 num_rts_success; 919 u32 num_rx_err; 920 u32 num_rx_discard; 921 u32 num_tx_not_acked; 922 u32 tx_rate_history[MAX_TX_RATE_VALUES]; 923 u32 beacon_rssi_history[MAX_TX_RATE_VALUES]; 924 }; 925 926 struct ath11k_fw_stats_bcn { 927 struct list_head list; 928 929 u32 vdev_id; 930 u32 tx_bcn_succ_cnt; 931 u32 tx_bcn_outage_cnt; 932 }; 933 934 extern const struct ce_pipe_config ath11k_target_ce_config_wlan_ipq8074[]; 935 extern const struct service_to_pipe ath11k_target_service_to_ce_map_wlan_ipq8074[]; 936 extern const struct service_to_pipe ath11k_target_service_to_ce_map_wlan_ipq6018[]; 937 938 extern const struct ce_pipe_config ath11k_target_ce_config_wlan_qca6390[]; 939 extern const struct service_to_pipe ath11k_target_service_to_ce_map_wlan_qca6390[]; 940 941 extern const struct ce_pipe_config ath11k_target_ce_config_wlan_qcn9074[]; 942 extern const struct service_to_pipe ath11k_target_service_to_ce_map_wlan_qcn9074[]; 943 int ath11k_core_qmi_firmware_ready(struct ath11k_base *ab); 944 int ath11k_core_pre_init(struct ath11k_base *ab); 945 int ath11k_core_init(struct ath11k_base *ath11k); 946 void ath11k_core_deinit(struct ath11k_base *ath11k); 947 struct ath11k_base *ath11k_core_alloc(struct device *dev, size_t priv_size, 948 enum ath11k_bus bus, 949 const struct ath11k_bus_params *bus_params); 950 void ath11k_core_free(struct ath11k_base *ath11k); 951 int ath11k_core_fetch_bdf(struct ath11k_base *ath11k, 952 struct ath11k_board_data *bd); 953 void ath11k_core_free_bdf(struct ath11k_base *ab, struct ath11k_board_data *bd); 954 int ath11k_core_check_dt(struct ath11k_base *ath11k); 955 956 void ath11k_core_halt(struct ath11k *ar); 957 int ath11k_core_resume(struct ath11k_base *ab); 958 int ath11k_core_suspend(struct ath11k_base *ab); 959 960 const struct firmware *ath11k_core_firmware_request(struct ath11k_base *ab, 961 const char *filename); 962 963 static inline const char *ath11k_scan_state_str(enum ath11k_scan_state state) 964 { 965 switch (state) { 966 case ATH11K_SCAN_IDLE: 967 return "idle"; 968 case ATH11K_SCAN_STARTING: 969 return "starting"; 970 case ATH11K_SCAN_RUNNING: 971 return "running"; 972 case ATH11K_SCAN_ABORTING: 973 return "aborting"; 974 } 975 976 return "unknown"; 977 } 978 979 static inline struct ath11k_skb_cb *ATH11K_SKB_CB(struct sk_buff *skb) 980 { 981 BUILD_BUG_ON(sizeof(struct ath11k_skb_cb) > 982 IEEE80211_TX_INFO_DRIVER_DATA_SIZE); 983 return (struct ath11k_skb_cb *)&IEEE80211_SKB_CB(skb)->driver_data; 984 } 985 986 static inline struct ath11k_skb_rxcb *ATH11K_SKB_RXCB(struct sk_buff *skb) 987 { 988 BUILD_BUG_ON(sizeof(struct ath11k_skb_rxcb) > sizeof(skb->cb)); 989 return (struct ath11k_skb_rxcb *)skb->cb; 990 } 991 992 static inline struct ath11k_vif *ath11k_vif_to_arvif(struct ieee80211_vif *vif) 993 { 994 return (struct ath11k_vif *)vif->drv_priv; 995 } 996 997 static inline struct ath11k *ath11k_ab_to_ar(struct ath11k_base *ab, 998 int mac_id) 999 { 1000 return ab->pdevs[ath11k_hw_mac_id_to_pdev_id(&ab->hw_params, mac_id)].ar; 1001 } 1002 1003 static inline void ath11k_core_create_firmware_path(struct ath11k_base *ab, 1004 const char *filename, 1005 void *buf, size_t buf_len) 1006 { 1007 snprintf(buf, buf_len, "%s/%s/%s", ATH11K_FW_DIR, 1008 ab->hw_params.fw.dir, filename); 1009 } 1010 1011 static inline const char *ath11k_bus_str(enum ath11k_bus bus) 1012 { 1013 switch (bus) { 1014 case ATH11K_BUS_PCI: 1015 return "pci"; 1016 case ATH11K_BUS_AHB: 1017 return "ahb"; 1018 } 1019 1020 return "unknown"; 1021 } 1022 1023 #endif /* _CORE_H_ */ 1024