mac.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /* SPDX-License-Identifier: BSD-3-Clause-Clear */
  2. /*
  3. * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2021-2023, 2025 Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef ATH11K_MAC_H
  7. #define ATH11K_MAC_H
  8. #include <net/mac80211.h>
  9. #include <net/cfg80211.h>
  10. #include "wmi.h"
  11. struct ath11k;
  12. struct ath11k_base;
  13. struct ath11k_generic_iter {
  14. struct ath11k *ar;
  15. int ret;
  16. };
  17. /* number of failed packets (20 packets with 16 sw reties each) */
  18. #define ATH11K_KICKOUT_THRESHOLD (20 * 16)
  19. /* Use insanely high numbers to make sure that the firmware implementation
  20. * won't start, we have the same functionality already in hostapd. Unit
  21. * is seconds.
  22. */
  23. #define ATH11K_KEEPALIVE_MIN_IDLE 3747
  24. #define ATH11K_KEEPALIVE_MAX_IDLE 3895
  25. #define ATH11K_KEEPALIVE_MAX_UNRESPONSIVE 3900
  26. #define WMI_HOST_RC_DS_FLAG 0x01
  27. #define WMI_HOST_RC_CW40_FLAG 0x02
  28. #define WMI_HOST_RC_SGI_FLAG 0x04
  29. #define WMI_HOST_RC_HT_FLAG 0x08
  30. #define WMI_HOST_RC_RTSCTS_FLAG 0x10
  31. #define WMI_HOST_RC_TX_STBC_FLAG 0x20
  32. #define WMI_HOST_RC_RX_STBC_FLAG 0xC0
  33. #define WMI_HOST_RC_RX_STBC_FLAG_S 6
  34. #define WMI_HOST_RC_WEP_TKIP_FLAG 0x100
  35. #define WMI_HOST_RC_TS_FLAG 0x200
  36. #define WMI_HOST_RC_UAPSD_FLAG 0x400
  37. #define WMI_HT_CAP_ENABLED 0x0001
  38. #define WMI_HT_CAP_HT20_SGI 0x0002
  39. #define WMI_HT_CAP_DYNAMIC_SMPS 0x0004
  40. #define WMI_HT_CAP_TX_STBC 0x0008
  41. #define WMI_HT_CAP_TX_STBC_MASK_SHIFT 3
  42. #define WMI_HT_CAP_RX_STBC 0x0030
  43. #define WMI_HT_CAP_RX_STBC_MASK_SHIFT 4
  44. #define WMI_HT_CAP_LDPC 0x0040
  45. #define WMI_HT_CAP_L_SIG_TXOP_PROT 0x0080
  46. #define WMI_HT_CAP_MPDU_DENSITY 0x0700
  47. #define WMI_HT_CAP_MPDU_DENSITY_MASK_SHIFT 8
  48. #define WMI_HT_CAP_HT40_SGI 0x0800
  49. #define WMI_HT_CAP_RX_LDPC 0x1000
  50. #define WMI_HT_CAP_TX_LDPC 0x2000
  51. #define WMI_HT_CAP_IBF_BFER 0x4000
  52. /* These macros should be used when we wish to advertise STBC support for
  53. * only 1SS or 2SS or 3SS.
  54. */
  55. #define WMI_HT_CAP_RX_STBC_1SS 0x0010
  56. #define WMI_HT_CAP_RX_STBC_2SS 0x0020
  57. #define WMI_HT_CAP_RX_STBC_3SS 0x0030
  58. #define WMI_HT_CAP_DEFAULT_ALL (WMI_HT_CAP_ENABLED | \
  59. WMI_HT_CAP_HT20_SGI | \
  60. WMI_HT_CAP_HT40_SGI | \
  61. WMI_HT_CAP_TX_STBC | \
  62. WMI_HT_CAP_RX_STBC | \
  63. WMI_HT_CAP_LDPC)
  64. #define WMI_VHT_CAP_MAX_MPDU_LEN_MASK 0x00000003
  65. #define WMI_VHT_CAP_RX_LDPC 0x00000010
  66. #define WMI_VHT_CAP_SGI_80MHZ 0x00000020
  67. #define WMI_VHT_CAP_SGI_160MHZ 0x00000040
  68. #define WMI_VHT_CAP_TX_STBC 0x00000080
  69. #define WMI_VHT_CAP_RX_STBC_MASK 0x00000300
  70. #define WMI_VHT_CAP_RX_STBC_MASK_SHIFT 8
  71. #define WMI_VHT_CAP_SU_BFER 0x00000800
  72. #define WMI_VHT_CAP_SU_BFEE 0x00001000
  73. #define WMI_VHT_CAP_MAX_CS_ANT_MASK 0x0000E000
  74. #define WMI_VHT_CAP_MAX_CS_ANT_MASK_SHIFT 13
  75. #define WMI_VHT_CAP_MAX_SND_DIM_MASK 0x00070000
  76. #define WMI_VHT_CAP_MAX_SND_DIM_MASK_SHIFT 16
  77. #define WMI_VHT_CAP_MU_BFER 0x00080000
  78. #define WMI_VHT_CAP_MU_BFEE 0x00100000
  79. #define WMI_VHT_CAP_MAX_AMPDU_LEN_EXP 0x03800000
  80. #define WMI_VHT_CAP_MAX_AMPDU_LEN_EXP_SHIT 23
  81. #define WMI_VHT_CAP_RX_FIXED_ANT 0x10000000
  82. #define WMI_VHT_CAP_TX_FIXED_ANT 0x20000000
  83. #define WMI_VHT_CAP_MAX_MPDU_LEN_11454 0x00000002
  84. /* These macros should be used when we wish to advertise STBC support for
  85. * only 1SS or 2SS or 3SS.
  86. */
  87. #define WMI_VHT_CAP_RX_STBC_1SS 0x00000100
  88. #define WMI_VHT_CAP_RX_STBC_2SS 0x00000200
  89. #define WMI_VHT_CAP_RX_STBC_3SS 0x00000300
  90. #define WMI_VHT_CAP_DEFAULT_ALL (WMI_VHT_CAP_MAX_MPDU_LEN_11454 | \
  91. WMI_VHT_CAP_SGI_80MHZ | \
  92. WMI_VHT_CAP_TX_STBC | \
  93. WMI_VHT_CAP_RX_STBC_MASK | \
  94. WMI_VHT_CAP_RX_LDPC | \
  95. WMI_VHT_CAP_MAX_AMPDU_LEN_EXP | \
  96. WMI_VHT_CAP_RX_FIXED_ANT | \
  97. WMI_VHT_CAP_TX_FIXED_ANT)
  98. /* FIXME: should these be in ieee80211.h? */
  99. #define IEEE80211_VHT_MCS_SUPPORT_0_11_MASK GENMASK(23, 16)
  100. #define IEEE80211_DISABLE_VHT_MCS_SUPPORT_0_11 BIT(24)
  101. #define WMI_MAX_SPATIAL_STREAM 3
  102. #define ATH11K_CHAN_WIDTH_NUM 8
  103. #define ATH11K_BW_NSS_MAP_ENABLE BIT(31)
  104. #define ATH11K_PEER_RX_NSS_160MHZ GENMASK(2, 0)
  105. #define ATH11K_PEER_RX_NSS_80_80MHZ GENMASK(5, 3)
  106. #define ATH11K_OBSS_PD_MAX_THRESHOLD -82
  107. #define ATH11K_OBSS_PD_NON_SRG_MAX_THRESHOLD -62
  108. #define ATH11K_OBSS_PD_THRESHOLD_IN_DBM BIT(29)
  109. #define ATH11K_OBSS_PD_SRG_EN BIT(30)
  110. #define ATH11K_OBSS_PD_NON_SRG_EN BIT(31)
  111. extern const struct htt_rx_ring_tlv_filter ath11k_mac_mon_status_filter_default;
  112. #define ATH11K_SCAN_11D_INTERVAL 600000
  113. #define ATH11K_11D_INVALID_VDEV_ID 0xFFFF
  114. void ath11k_mac_11d_scan_start(struct ath11k *ar, u32 vdev_id);
  115. void ath11k_mac_11d_scan_stop(struct ath11k *ar);
  116. void ath11k_mac_11d_scan_stop_all(struct ath11k_base *ab);
  117. void ath11k_mac_destroy(struct ath11k_base *ab);
  118. void ath11k_mac_unregister(struct ath11k_base *ab);
  119. int ath11k_mac_register(struct ath11k_base *ab);
  120. int ath11k_mac_allocate(struct ath11k_base *ab);
  121. int ath11k_mac_hw_ratecode_to_legacy_rate(u8 hw_rc, u8 preamble, u8 *rateidx,
  122. u16 *rate);
  123. u8 ath11k_mac_bitrate_to_idx(const struct ieee80211_supported_band *sband,
  124. u32 bitrate);
  125. u8 ath11k_mac_hw_rate_to_idx(const struct ieee80211_supported_band *sband,
  126. u8 hw_rate, bool cck);
  127. void __ath11k_mac_scan_finish(struct ath11k *ar);
  128. void ath11k_mac_scan_finish(struct ath11k *ar);
  129. struct ath11k_vif *ath11k_mac_get_arvif(struct ath11k *ar, u32 vdev_id);
  130. struct ath11k_vif *ath11k_mac_get_arvif_by_vdev_id(struct ath11k_base *ab,
  131. u32 vdev_id);
  132. u8 ath11k_mac_get_target_pdev_id(struct ath11k *ar);
  133. u8 ath11k_mac_get_target_pdev_id_from_vif(struct ath11k_vif *arvif);
  134. struct ath11k_vif *ath11k_mac_get_vif_up(struct ath11k_base *ab);
  135. struct ath11k *ath11k_mac_get_ar_by_vdev_id(struct ath11k_base *ab, u32 vdev_id);
  136. struct ath11k *ath11k_mac_get_ar_by_pdev_id(struct ath11k_base *ab, u32 pdev_id);
  137. void ath11k_mac_drain_tx(struct ath11k *ar);
  138. void ath11k_mac_peer_cleanup_all(struct ath11k *ar);
  139. int ath11k_mac_tx_mgmt_pending_free(int buf_id, void *skb, void *ctx);
  140. u8 ath11k_mac_bw_to_mac80211_bw(u8 bw);
  141. enum nl80211_he_gi ath11k_mac_he_gi_to_nl80211_he_gi(u8 sgi);
  142. enum nl80211_he_ru_alloc ath11k_mac_phy_he_ru_to_nl80211_he_ru_alloc(u16 ru_phy);
  143. enum nl80211_he_ru_alloc ath11k_mac_he_ru_tones_to_nl80211_he_ru_alloc(u16 ru_tones);
  144. enum ath11k_supported_bw ath11k_mac_mac80211_bw_to_ath11k_bw(enum rate_info_bw bw);
  145. enum hal_encrypt_type ath11k_dp_tx_get_encrypt_type(u32 cipher);
  146. void ath11k_mac_handle_beacon(struct ath11k *ar, struct sk_buff *skb);
  147. void ath11k_mac_handle_beacon_miss(struct ath11k *ar, u32 vdev_id);
  148. void ath11k_mac_bcn_tx_event(struct ath11k_vif *arvif);
  149. int ath11k_mac_wait_tx_complete(struct ath11k *ar);
  150. int ath11k_mac_vif_set_keepalive(struct ath11k_vif *arvif,
  151. enum wmi_sta_keepalive_method method,
  152. u32 interval);
  153. void ath11k_mac_fill_reg_tpc_info(struct ath11k *ar,
  154. struct ieee80211_vif *vif,
  155. struct ieee80211_chanctx_conf *ctx);
  156. int ath11k_mac_fw_stats_request(struct ath11k *ar,
  157. struct stats_request_params *req_param);
  158. #endif