mac.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. /* SPDX-License-Identifier: BSD-3-Clause-Clear */
  2. /*
  3. * Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
  4. * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
  5. */
  6. #ifndef ATH12K_MAC_H
  7. #define ATH12K_MAC_H
  8. #include <net/mac80211.h>
  9. #include <net/cfg80211.h>
  10. #include "wmi.h"
  11. struct ath12k;
  12. struct ath12k_base;
  13. struct ath12k_hw;
  14. struct ath12k_hw_group;
  15. struct ath12k_pdev_map;
  16. struct ath12k_generic_iter {
  17. struct ath12k *ar;
  18. int ret;
  19. };
  20. /* number of failed packets (20 packets with 16 sw reties each) */
  21. #define ATH12K_KICKOUT_THRESHOLD (20 * 16)
  22. /* Use insanely high numbers to make sure that the firmware implementation
  23. * won't start, we have the same functionality already in hostapd. Unit
  24. * is seconds.
  25. */
  26. #define ATH12K_KEEPALIVE_MIN_IDLE 3747
  27. #define ATH12K_KEEPALIVE_MAX_IDLE 3895
  28. #define ATH12K_KEEPALIVE_MAX_UNRESPONSIVE 3900
  29. #define ATH12K_PDEV_TX_POWER_INVALID ((u32)-1)
  30. #define ATH12K_PDEV_TX_POWER_REFRESH_TIME_MSECS 5000 /* msecs */
  31. /* FIXME: should these be in ieee80211.h? */
  32. #define IEEE80211_VHT_MCS_SUPPORT_0_11_MASK GENMASK(23, 16)
  33. #define IEEE80211_DISABLE_VHT_MCS_SUPPORT_0_11 BIT(24)
  34. #define ATH12K_CHAN_WIDTH_NUM 14
  35. #define ATH12K_BW_NSS_MAP_ENABLE BIT(31)
  36. #define ATH12K_PEER_RX_NSS_160MHZ GENMASK(2, 0)
  37. #define ATH12K_TX_POWER_MAX_VAL 70
  38. #define ATH12K_TX_POWER_MIN_VAL 0
  39. #define ATH12K_DEFAULT_LINK_ID 0
  40. #define ATH12K_INVALID_LINK_ID 255
  41. /* Default link after the IEEE802.11 defined Max link id limit
  42. * for driver usage purpose.
  43. */
  44. #define ATH12K_FIRST_SCAN_LINK IEEE80211_MLD_MAX_NUM_LINKS
  45. #define ATH12K_SCAN_LINKS_MASK GENMASK(ATH12K_NUM_MAX_LINKS, IEEE80211_MLD_MAX_NUM_LINKS)
  46. #define ATH12K_NUM_MAX_ACTIVE_LINKS_PER_DEVICE 2
  47. #define HECAP_PHY_SUBFMR_GET(hecap_phy) \
  48. u8_get_bits(hecap_phy[3], IEEE80211_HE_PHY_CAP3_SU_BEAMFORMER)
  49. #define HECAP_PHY_SUBFME_GET(hecap_phy) \
  50. u8_get_bits(hecap_phy[4], IEEE80211_HE_PHY_CAP4_SU_BEAMFORMEE)
  51. #define HECAP_PHY_MUBFMR_GET(hecap_phy) \
  52. u8_get_bits(hecap_phy[4], IEEE80211_HE_PHY_CAP4_MU_BEAMFORMER)
  53. #define HECAP_PHY_ULMUMIMO_GET(hecap_phy) \
  54. u8_get_bits(hecap_phy[2], IEEE80211_HE_PHY_CAP2_UL_MU_FULL_MU_MIMO)
  55. #define HECAP_PHY_ULOFDMA_GET(hecap_phy) \
  56. u8_get_bits(hecap_phy[2], IEEE80211_HE_PHY_CAP2_UL_MU_PARTIAL_MU_MIMO)
  57. enum ath12k_supported_bw {
  58. ATH12K_BW_20 = 0,
  59. ATH12K_BW_40 = 1,
  60. ATH12K_BW_80 = 2,
  61. ATH12K_BW_160 = 3,
  62. ATH12K_BW_320 = 4,
  63. };
  64. enum ath12k_gi {
  65. ATH12K_RATE_INFO_GI_0_8,
  66. ATH12K_RATE_INFO_GI_1_6,
  67. ATH12K_RATE_INFO_GI_3_2,
  68. };
  69. enum ath12k_ltf {
  70. ATH12K_RATE_INFO_1XLTF,
  71. ATH12K_RATE_INFO_2XLTF,
  72. ATH12K_RATE_INFO_4XLTF,
  73. };
  74. struct ath12k_mac_get_any_chanctx_conf_arg {
  75. struct ath12k *ar;
  76. struct ieee80211_chanctx_conf *chanctx_conf;
  77. };
  78. /**
  79. * struct ath12k_chan_power_info - TPE containing power info per channel chunk
  80. * @chan_cfreq: channel center freq (MHz)
  81. * e.g.
  82. * channel 37/20 MHz, it is 6135
  83. * channel 37/40 MHz, it is 6125
  84. * channel 37/80 MHz, it is 6145
  85. * channel 37/160 MHz, it is 6185
  86. * @tx_power: transmit power (dBm)
  87. */
  88. struct ath12k_chan_power_info {
  89. u16 chan_cfreq;
  90. s8 tx_power;
  91. };
  92. /* ath12k only deals with 320 MHz, so 16 subchannels */
  93. #define ATH12K_NUM_PWR_LEVELS 16
  94. /**
  95. * struct ath12k_reg_tpc_power_info - regulatory TPC power info
  96. * @is_psd_power: is PSD power or not
  97. * @eirp_power: Maximum EIRP power (dBm), valid only if power is PSD
  98. * @ap_power_type: type of power (SP/LPI/VLP)
  99. * @num_pwr_levels: number of power levels
  100. * @reg_max: Array of maximum TX power (dBm) per PSD value
  101. * @ap_constraint_power: AP constraint power (dBm)
  102. * @tpe: TPE values processed from TPE IE
  103. * @chan_power_info: power info to send to firmware
  104. */
  105. struct ath12k_reg_tpc_power_info {
  106. bool is_psd_power;
  107. u8 eirp_power;
  108. enum wmi_reg_6g_ap_type ap_power_type;
  109. u8 num_pwr_levels;
  110. u8 reg_max[ATH12K_NUM_PWR_LEVELS];
  111. u8 ap_constraint_power;
  112. s8 tpe[ATH12K_NUM_PWR_LEVELS];
  113. struct ath12k_chan_power_info chan_power_info[ATH12K_NUM_PWR_LEVELS];
  114. };
  115. #define ATH12K_OBSS_PD_MAX_THRESHOLD -82
  116. #define ATH12K_OBSS_PD_NON_SRG_MAX_THRESHOLD -62
  117. extern const struct htt_rx_ring_tlv_filter ath12k_mac_mon_status_filter_default;
  118. #define ATH12K_SCAN_11D_INTERVAL 600000
  119. #define ATH12K_11D_INVALID_VDEV_ID 0xFFFF
  120. void ath12k_mac_11d_scan_start(struct ath12k *ar, u32 vdev_id);
  121. void ath12k_mac_11d_scan_stop(struct ath12k *ar);
  122. void ath12k_mac_11d_scan_stop_all(struct ath12k_base *ab);
  123. void ath12k_mac_destroy(struct ath12k_hw_group *ag);
  124. void ath12k_mac_unregister(struct ath12k_hw_group *ag);
  125. int ath12k_mac_register(struct ath12k_hw_group *ag);
  126. int ath12k_mac_allocate(struct ath12k_hw_group *ag);
  127. int ath12k_mac_hw_ratecode_to_legacy_rate(u8 hw_rc, u8 preamble, u8 *rateidx,
  128. u16 *rate);
  129. u8 ath12k_mac_bitrate_to_idx(const struct ieee80211_supported_band *sband,
  130. u32 bitrate);
  131. u8 ath12k_mac_hw_rate_to_idx(const struct ieee80211_supported_band *sband,
  132. u8 hw_rate, bool cck);
  133. void __ath12k_mac_scan_finish(struct ath12k *ar);
  134. void ath12k_mac_scan_finish(struct ath12k *ar);
  135. struct ath12k_link_vif *ath12k_mac_get_arvif(struct ath12k *ar, u32 vdev_id);
  136. struct ath12k_link_vif *ath12k_mac_get_arvif_by_vdev_id(struct ath12k_base *ab,
  137. u32 vdev_id);
  138. struct ath12k *ath12k_mac_get_ar_by_vdev_id(struct ath12k_base *ab, u32 vdev_id);
  139. struct ath12k *ath12k_mac_get_ar_by_pdev_id(struct ath12k_base *ab, u32 pdev_id);
  140. void ath12k_mac_drain_tx(struct ath12k *ar);
  141. void ath12k_mac_peer_cleanup_all(struct ath12k *ar);
  142. void ath12k_mac_dp_peer_cleanup(struct ath12k_hw *ah);
  143. int ath12k_mac_tx_mgmt_pending_free(int buf_id, void *skb, void *ctx);
  144. enum rate_info_bw ath12k_mac_bw_to_mac80211_bw(enum ath12k_supported_bw bw);
  145. enum ath12k_supported_bw ath12k_mac_mac80211_bw_to_ath12k_bw(enum rate_info_bw bw);
  146. enum hal_encrypt_type ath12k_dp_tx_get_encrypt_type(u32 cipher);
  147. int ath12k_mac_rfkill_enable_radio(struct ath12k *ar, bool enable);
  148. int ath12k_mac_rfkill_config(struct ath12k *ar);
  149. int ath12k_mac_wait_tx_complete(struct ath12k *ar);
  150. void ath12k_mac_handle_beacon(struct ath12k *ar, struct sk_buff *skb);
  151. void ath12k_mac_handle_beacon_miss(struct ath12k *ar,
  152. struct ath12k_link_vif *arvif);
  153. int ath12k_mac_vif_set_keepalive(struct ath12k_link_vif *arvif,
  154. enum wmi_sta_keepalive_method method,
  155. u32 interval);
  156. u8 ath12k_mac_get_target_pdev_id(struct ath12k *ar);
  157. int ath12k_mac_mlo_setup(struct ath12k_hw_group *ag);
  158. int ath12k_mac_mlo_ready(struct ath12k_hw_group *ag);
  159. void ath12k_mac_mlo_teardown(struct ath12k_hw_group *ag);
  160. int ath12k_mac_vdev_stop(struct ath12k_link_vif *arvif);
  161. void ath12k_mac_get_any_chanctx_conf_iter(struct ieee80211_hw *hw,
  162. struct ieee80211_chanctx_conf *conf,
  163. void *data);
  164. u16 ath12k_mac_he_convert_tones_to_ru_tones(u16 tones);
  165. enum nl80211_eht_ru_alloc ath12k_mac_eht_ru_tones_to_nl80211_eht_ru_alloc(u16 ru_tones);
  166. enum nl80211_eht_gi ath12k_mac_eht_gi_to_nl80211_eht_gi(u8 sgi);
  167. struct ieee80211_bss_conf *ath12k_mac_get_link_bss_conf(struct ath12k_link_vif *arvif);
  168. struct ath12k *ath12k_get_ar_by_vif(struct ieee80211_hw *hw,
  169. struct ieee80211_vif *vif,
  170. u8 link_id);
  171. int ath12k_mac_get_fw_stats(struct ath12k *ar, struct ath12k_fw_stats_req_params *param);
  172. void ath12k_mac_update_freq_range(struct ath12k *ar,
  173. u32 freq_low, u32 freq_high);
  174. void ath12k_mac_fill_reg_tpc_info(struct ath12k *ar,
  175. struct ath12k_link_vif *arvif,
  176. struct ieee80211_chanctx_conf *ctx);
  177. int ath12k_mac_op_start(struct ieee80211_hw *hw);
  178. void ath12k_mac_op_stop(struct ieee80211_hw *hw, bool suspend);
  179. void
  180. ath12k_mac_op_reconfig_complete(struct ieee80211_hw *hw,
  181. enum ieee80211_reconfig_type reconfig_type);
  182. int ath12k_mac_op_add_interface(struct ieee80211_hw *hw,
  183. struct ieee80211_vif *vif);
  184. void ath12k_mac_op_remove_interface(struct ieee80211_hw *hw,
  185. struct ieee80211_vif *vif);
  186. void ath12k_mac_op_update_vif_offload(struct ieee80211_hw *hw,
  187. struct ieee80211_vif *vif);
  188. int ath12k_mac_op_config(struct ieee80211_hw *hw, int radio_idx, u32 changed);
  189. void ath12k_mac_op_link_info_changed(struct ieee80211_hw *hw,
  190. struct ieee80211_vif *vif,
  191. struct ieee80211_bss_conf *info,
  192. u64 changed);
  193. void ath12k_mac_op_vif_cfg_changed(struct ieee80211_hw *hw,
  194. struct ieee80211_vif *vif,
  195. u64 changed);
  196. int
  197. ath12k_mac_op_change_vif_links
  198. (struct ieee80211_hw *hw,
  199. struct ieee80211_vif *vif,
  200. u16 old_links, u16 new_links,
  201. struct ieee80211_bss_conf *ol[IEEE80211_MLD_MAX_NUM_LINKS]);
  202. void ath12k_mac_op_configure_filter(struct ieee80211_hw *hw,
  203. unsigned int changed_flags,
  204. unsigned int *total_flags,
  205. u64 multicast);
  206. int ath12k_mac_op_hw_scan(struct ieee80211_hw *hw,
  207. struct ieee80211_vif *vif,
  208. struct ieee80211_scan_request *hw_req);
  209. void ath12k_mac_op_cancel_hw_scan(struct ieee80211_hw *hw,
  210. struct ieee80211_vif *vif);
  211. int ath12k_mac_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
  212. struct ieee80211_vif *vif, struct ieee80211_sta *sta,
  213. struct ieee80211_key_conf *key);
  214. void ath12k_mac_op_set_rekey_data(struct ieee80211_hw *hw,
  215. struct ieee80211_vif *vif,
  216. struct cfg80211_gtk_rekey_data *data);
  217. int ath12k_mac_op_sta_state(struct ieee80211_hw *hw,
  218. struct ieee80211_vif *vif,
  219. struct ieee80211_sta *sta,
  220. enum ieee80211_sta_state old_state,
  221. enum ieee80211_sta_state new_state);
  222. int ath12k_mac_op_sta_set_txpwr(struct ieee80211_hw *hw,
  223. struct ieee80211_vif *vif,
  224. struct ieee80211_sta *sta);
  225. void ath12k_mac_op_link_sta_rc_update(struct ieee80211_hw *hw,
  226. struct ieee80211_vif *vif,
  227. struct ieee80211_link_sta *link_sta,
  228. u32 changed);
  229. int ath12k_mac_op_conf_tx(struct ieee80211_hw *hw,
  230. struct ieee80211_vif *vif,
  231. unsigned int link_id, u16 ac,
  232. const struct ieee80211_tx_queue_params *params);
  233. int ath12k_mac_op_set_antenna(struct ieee80211_hw *hw, int radio_idx,
  234. u32 tx_ant, u32 rx_ant);
  235. int ath12k_mac_op_get_antenna(struct ieee80211_hw *hw, int radio_idx,
  236. u32 *tx_ant, u32 *rx_ant);
  237. int ath12k_mac_op_ampdu_action(struct ieee80211_hw *hw,
  238. struct ieee80211_vif *vif,
  239. struct ieee80211_ampdu_params *params);
  240. int ath12k_mac_op_add_chanctx(struct ieee80211_hw *hw,
  241. struct ieee80211_chanctx_conf *ctx);
  242. void ath12k_mac_op_remove_chanctx(struct ieee80211_hw *hw,
  243. struct ieee80211_chanctx_conf *ctx);
  244. void ath12k_mac_op_change_chanctx(struct ieee80211_hw *hw,
  245. struct ieee80211_chanctx_conf *ctx,
  246. u32 changed);
  247. int
  248. ath12k_mac_op_assign_vif_chanctx(struct ieee80211_hw *hw,
  249. struct ieee80211_vif *vif,
  250. struct ieee80211_bss_conf *link_conf,
  251. struct ieee80211_chanctx_conf *ctx);
  252. void
  253. ath12k_mac_op_unassign_vif_chanctx(struct ieee80211_hw *hw,
  254. struct ieee80211_vif *vif,
  255. struct ieee80211_bss_conf *link_conf,
  256. struct ieee80211_chanctx_conf *ctx);
  257. int
  258. ath12k_mac_op_switch_vif_chanctx(struct ieee80211_hw *hw,
  259. struct ieee80211_vif_chanctx_switch *vifs,
  260. int n_vifs,
  261. enum ieee80211_chanctx_switch_mode mode);
  262. int ath12k_mac_op_set_rts_threshold(struct ieee80211_hw *hw,
  263. int radio_idx, u32 value);
  264. int ath12k_mac_op_set_frag_threshold(struct ieee80211_hw *hw,
  265. int radio_idx, u32 value);
  266. int
  267. ath12k_mac_op_set_bitrate_mask(struct ieee80211_hw *hw,
  268. struct ieee80211_vif *vif,
  269. const struct cfg80211_bitrate_mask *mask);
  270. int ath12k_mac_op_get_survey(struct ieee80211_hw *hw, int idx,
  271. struct survey_info *survey);
  272. void ath12k_mac_op_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  273. u32 queues, bool drop);
  274. void ath12k_mac_op_sta_statistics(struct ieee80211_hw *hw,
  275. struct ieee80211_vif *vif,
  276. struct ieee80211_sta *sta,
  277. struct station_info *sinfo);
  278. void ath12k_mac_op_link_sta_statistics(struct ieee80211_hw *hw,
  279. struct ieee80211_vif *vif,
  280. struct ieee80211_link_sta *link_sta,
  281. struct link_station_info *link_sinfo);
  282. int ath12k_mac_op_remain_on_channel(struct ieee80211_hw *hw,
  283. struct ieee80211_vif *vif,
  284. struct ieee80211_channel *chan,
  285. int duration,
  286. enum ieee80211_roc_type type);
  287. int ath12k_mac_op_cancel_remain_on_channel(struct ieee80211_hw *hw,
  288. struct ieee80211_vif *vif);
  289. int ath12k_mac_op_change_sta_links(struct ieee80211_hw *hw,
  290. struct ieee80211_vif *vif,
  291. struct ieee80211_sta *sta,
  292. u16 old_links, u16 new_links);
  293. bool ath12k_mac_op_can_activate_links(struct ieee80211_hw *hw,
  294. struct ieee80211_vif *vif,
  295. u16 active_links);
  296. int ath12k_mac_op_get_txpower(struct ieee80211_hw *hw,
  297. struct ieee80211_vif *vif,
  298. unsigned int link_id,
  299. int *dbm);
  300. int ath12k_mac_mgmt_tx(struct ath12k *ar, struct sk_buff *skb,
  301. bool is_prb_rsp);
  302. void ath12k_mac_add_p2p_noa_ie(struct ath12k *ar,
  303. struct ieee80211_vif *vif,
  304. struct sk_buff *skb,
  305. bool is_prb_rsp);
  306. u8 ath12k_mac_get_tx_link(struct ieee80211_sta *sta, struct ieee80211_vif *vif,
  307. u8 link, struct sk_buff *skb, u32 info_flags);
  308. void ath12k_mlo_mcast_update_tx_link_address(struct ieee80211_vif *vif,
  309. u8 link_id, struct sk_buff *skb,
  310. u32 info_flags);
  311. #endif