162306a36Sopenharmony_ci/* SPDX-License-Identifier: BSD-3-Clause-Clear */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
462306a36Sopenharmony_ci * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
562306a36Sopenharmony_ci */
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci#ifndef ATH12K_MAC_H
862306a36Sopenharmony_ci#define ATH12K_MAC_H
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci#include <net/mac80211.h>
1162306a36Sopenharmony_ci#include <net/cfg80211.h>
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_cistruct ath12k;
1462306a36Sopenharmony_cistruct ath12k_base;
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_cistruct ath12k_generic_iter {
1762306a36Sopenharmony_ci	struct ath12k *ar;
1862306a36Sopenharmony_ci	int ret;
1962306a36Sopenharmony_ci};
2062306a36Sopenharmony_ci
2162306a36Sopenharmony_ci/* number of failed packets (20 packets with 16 sw reties each) */
2262306a36Sopenharmony_ci#define ATH12K_KICKOUT_THRESHOLD		(20 * 16)
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci/* Use insanely high numbers to make sure that the firmware implementation
2562306a36Sopenharmony_ci * won't start, we have the same functionality already in hostapd. Unit
2662306a36Sopenharmony_ci * is seconds.
2762306a36Sopenharmony_ci */
2862306a36Sopenharmony_ci#define ATH12K_KEEPALIVE_MIN_IDLE		3747
2962306a36Sopenharmony_ci#define ATH12K_KEEPALIVE_MAX_IDLE		3895
3062306a36Sopenharmony_ci#define ATH12K_KEEPALIVE_MAX_UNRESPONSIVE	3900
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_ci/* FIXME: should these be in ieee80211.h? */
3362306a36Sopenharmony_ci#define IEEE80211_VHT_MCS_SUPPORT_0_11_MASK	GENMASK(23, 16)
3462306a36Sopenharmony_ci#define IEEE80211_DISABLE_VHT_MCS_SUPPORT_0_11	BIT(24)
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ci#define ATH12K_CHAN_WIDTH_NUM			14
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ci#define ATH12K_TX_POWER_MAX_VAL	70
3962306a36Sopenharmony_ci#define ATH12K_TX_POWER_MIN_VAL	0
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_cienum ath12k_supported_bw {
4262306a36Sopenharmony_ci	ATH12K_BW_20    = 0,
4362306a36Sopenharmony_ci	ATH12K_BW_40    = 1,
4462306a36Sopenharmony_ci	ATH12K_BW_80    = 2,
4562306a36Sopenharmony_ci	ATH12K_BW_160   = 3,
4662306a36Sopenharmony_ci};
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ciextern const struct htt_rx_ring_tlv_filter ath12k_mac_mon_status_filter_default;
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_civoid ath12k_mac_destroy(struct ath12k_base *ab);
5162306a36Sopenharmony_civoid ath12k_mac_unregister(struct ath12k_base *ab);
5262306a36Sopenharmony_ciint ath12k_mac_register(struct ath12k_base *ab);
5362306a36Sopenharmony_ciint ath12k_mac_allocate(struct ath12k_base *ab);
5462306a36Sopenharmony_ciint ath12k_mac_hw_ratecode_to_legacy_rate(u8 hw_rc, u8 preamble, u8 *rateidx,
5562306a36Sopenharmony_ci					  u16 *rate);
5662306a36Sopenharmony_ciu8 ath12k_mac_bitrate_to_idx(const struct ieee80211_supported_band *sband,
5762306a36Sopenharmony_ci			     u32 bitrate);
5862306a36Sopenharmony_ciu8 ath12k_mac_hw_rate_to_idx(const struct ieee80211_supported_band *sband,
5962306a36Sopenharmony_ci			     u8 hw_rate, bool cck);
6062306a36Sopenharmony_ci
6162306a36Sopenharmony_civoid __ath12k_mac_scan_finish(struct ath12k *ar);
6262306a36Sopenharmony_civoid ath12k_mac_scan_finish(struct ath12k *ar);
6362306a36Sopenharmony_ci
6462306a36Sopenharmony_cistruct ath12k_vif *ath12k_mac_get_arvif(struct ath12k *ar, u32 vdev_id);
6562306a36Sopenharmony_cistruct ath12k_vif *ath12k_mac_get_arvif_by_vdev_id(struct ath12k_base *ab,
6662306a36Sopenharmony_ci						   u32 vdev_id);
6762306a36Sopenharmony_cistruct ath12k *ath12k_mac_get_ar_by_vdev_id(struct ath12k_base *ab, u32 vdev_id);
6862306a36Sopenharmony_cistruct ath12k *ath12k_mac_get_ar_by_pdev_id(struct ath12k_base *ab, u32 pdev_id);
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_civoid ath12k_mac_drain_tx(struct ath12k *ar);
7162306a36Sopenharmony_civoid ath12k_mac_peer_cleanup_all(struct ath12k *ar);
7262306a36Sopenharmony_ciint ath12k_mac_tx_mgmt_pending_free(int buf_id, void *skb, void *ctx);
7362306a36Sopenharmony_cienum rate_info_bw ath12k_mac_bw_to_mac80211_bw(enum ath12k_supported_bw bw);
7462306a36Sopenharmony_cienum ath12k_supported_bw ath12k_mac_mac80211_bw_to_ath12k_bw(enum rate_info_bw bw);
7562306a36Sopenharmony_cienum hal_encrypt_type ath12k_dp_tx_get_encrypt_type(u32 cipher);
7662306a36Sopenharmony_ci#endif
77