1 /* SPDX-License-Identifier: BSD-3-Clause-Clear */ 2 /* 3 * Copyright (c) 2018-2021 The Linux Foundation. All rights reserved. 4 * Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved. 5 */ 6 7 #ifndef ATH12K_MAC_H 8 #define ATH12K_MAC_H 9 10 #include <net/mac80211.h> 11 #include <net/cfg80211.h> 12 #include "wmi.h" 13 14 struct ath12k; 15 struct ath12k_base; 16 struct ath12k_hw; 17 struct ath12k_hw_group; 18 struct ath12k_pdev_map; 19 20 struct ath12k_generic_iter { 21 struct ath12k *ar; 22 int ret; 23 }; 24 25 /* number of failed packets (20 packets with 16 sw reties each) */ 26 #define ATH12K_KICKOUT_THRESHOLD (20 * 16) 27 28 /* Use insanely high numbers to make sure that the firmware implementation 29 * won't start, we have the same functionality already in hostapd. Unit 30 * is seconds. 31 */ 32 #define ATH12K_KEEPALIVE_MIN_IDLE 3747 33 #define ATH12K_KEEPALIVE_MAX_IDLE 3895 34 #define ATH12K_KEEPALIVE_MAX_UNRESPONSIVE 3900 35 36 /* FIXME: should these be in ieee80211.h? */ 37 #define IEEE80211_VHT_MCS_SUPPORT_0_11_MASK GENMASK(23, 16) 38 #define IEEE80211_DISABLE_VHT_MCS_SUPPORT_0_11 BIT(24) 39 40 #define ATH12K_CHAN_WIDTH_NUM 14 41 42 #define ATH12K_TX_POWER_MAX_VAL 70 43 #define ATH12K_TX_POWER_MIN_VAL 0 44 45 #define ATH12K_DEFAULT_LINK_ID 0 46 #define ATH12K_INVALID_LINK_ID 255 47 48 /* Default link after the IEEE802.11 defined Max link id limit 49 * for driver usage purpose. 50 */ 51 #define ATH12K_DEFAULT_SCAN_LINK IEEE80211_MLD_MAX_NUM_LINKS 52 #define ATH12K_NUM_MAX_LINKS (IEEE80211_MLD_MAX_NUM_LINKS + 1) 53 54 enum ath12k_supported_bw { 55 ATH12K_BW_20 = 0, 56 ATH12K_BW_40 = 1, 57 ATH12K_BW_80 = 2, 58 ATH12K_BW_160 = 3, 59 ATH12K_BW_320 = 4, 60 }; 61 62 struct ath12k_mac_get_any_chanctx_conf_arg { 63 struct ath12k *ar; 64 struct ieee80211_chanctx_conf *chanctx_conf; 65 }; 66 67 extern const struct htt_rx_ring_tlv_filter ath12k_mac_mon_status_filter_default; 68 69 void ath12k_mac_destroy(struct ath12k_hw_group *ag); 70 void ath12k_mac_unregister(struct ath12k_hw_group *ag); 71 int ath12k_mac_register(struct ath12k_hw_group *ag); 72 int ath12k_mac_allocate(struct ath12k_hw_group *ag); 73 int ath12k_mac_hw_ratecode_to_legacy_rate(u8 hw_rc, u8 preamble, u8 *rateidx, 74 u16 *rate); 75 u8 ath12k_mac_bitrate_to_idx(const struct ieee80211_supported_band *sband, 76 u32 bitrate); 77 u8 ath12k_mac_hw_rate_to_idx(const struct ieee80211_supported_band *sband, 78 u8 hw_rate, bool cck); 79 80 void __ath12k_mac_scan_finish(struct ath12k *ar); 81 void ath12k_mac_scan_finish(struct ath12k *ar); 82 83 struct ath12k_link_vif *ath12k_mac_get_arvif(struct ath12k *ar, u32 vdev_id); 84 struct ath12k_link_vif *ath12k_mac_get_arvif_by_vdev_id(struct ath12k_base *ab, 85 u32 vdev_id); 86 struct ath12k *ath12k_mac_get_ar_by_vdev_id(struct ath12k_base *ab, u32 vdev_id); 87 struct ath12k *ath12k_mac_get_ar_by_pdev_id(struct ath12k_base *ab, u32 pdev_id); 88 89 void ath12k_mac_drain_tx(struct ath12k *ar); 90 void ath12k_mac_peer_cleanup_all(struct ath12k *ar); 91 int ath12k_mac_tx_mgmt_pending_free(int buf_id, void *skb, void *ctx); 92 enum rate_info_bw ath12k_mac_bw_to_mac80211_bw(enum ath12k_supported_bw bw); 93 enum ath12k_supported_bw ath12k_mac_mac80211_bw_to_ath12k_bw(enum rate_info_bw bw); 94 enum hal_encrypt_type ath12k_dp_tx_get_encrypt_type(u32 cipher); 95 int ath12k_mac_rfkill_enable_radio(struct ath12k *ar, bool enable); 96 int ath12k_mac_rfkill_config(struct ath12k *ar); 97 int ath12k_mac_wait_tx_complete(struct ath12k *ar); 98 void ath12k_mac_handle_beacon(struct ath12k *ar, struct sk_buff *skb); 99 void ath12k_mac_handle_beacon_miss(struct ath12k *ar, u32 vdev_id); 100 int ath12k_mac_vif_set_keepalive(struct ath12k_link_vif *arvif, 101 enum wmi_sta_keepalive_method method, 102 u32 interval); 103 u8 ath12k_mac_get_target_pdev_id(struct ath12k *ar); 104 int ath12k_mac_mlo_setup(struct ath12k_hw_group *ag); 105 int ath12k_mac_mlo_ready(struct ath12k_hw_group *ag); 106 void ath12k_mac_mlo_teardown(struct ath12k_hw_group *ag); 107 int ath12k_mac_vdev_stop(struct ath12k_link_vif *arvif); 108 void ath12k_mac_get_any_chanctx_conf_iter(struct ieee80211_hw *hw, 109 struct ieee80211_chanctx_conf *conf, 110 void *data); 111 112 #endif 113