162306a36Sopenharmony_ci/* SPDX-License-Identifier: ISC */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright (c) 2005-2011 Atheros Communications Inc.
462306a36Sopenharmony_ci * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.
562306a36Sopenharmony_ci */
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci#ifndef _MAC_H_
862306a36Sopenharmony_ci#define _MAC_H_
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci#include <net/mac80211.h>
1162306a36Sopenharmony_ci#include "core.h"
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci#define WEP_KEYID_SHIFT 6
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_cienum wmi_tlv_tx_pause_id;
1662306a36Sopenharmony_cienum wmi_tlv_tx_pause_action;
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_cistruct ath10k_generic_iter {
1962306a36Sopenharmony_ci	struct ath10k *ar;
2062306a36Sopenharmony_ci	int ret;
2162306a36Sopenharmony_ci};
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_cistruct rfc1042_hdr {
2462306a36Sopenharmony_ci	u8 llc_dsap;
2562306a36Sopenharmony_ci	u8 llc_ssap;
2662306a36Sopenharmony_ci	u8 llc_ctrl;
2762306a36Sopenharmony_ci	u8 snap_oui[3];
2862306a36Sopenharmony_ci	__be16 snap_type;
2962306a36Sopenharmony_ci} __packed;
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_cistruct ath10k *ath10k_mac_create(size_t priv_size);
3262306a36Sopenharmony_civoid ath10k_mac_destroy(struct ath10k *ar);
3362306a36Sopenharmony_ciint ath10k_mac_register(struct ath10k *ar);
3462306a36Sopenharmony_civoid ath10k_mac_unregister(struct ath10k *ar);
3562306a36Sopenharmony_cistruct ath10k_vif *ath10k_get_arvif(struct ath10k *ar, u32 vdev_id);
3662306a36Sopenharmony_civoid __ath10k_scan_finish(struct ath10k *ar);
3762306a36Sopenharmony_civoid ath10k_scan_finish(struct ath10k *ar);
3862306a36Sopenharmony_civoid ath10k_scan_timeout_work(struct work_struct *work);
3962306a36Sopenharmony_civoid ath10k_offchan_tx_purge(struct ath10k *ar);
4062306a36Sopenharmony_civoid ath10k_offchan_tx_work(struct work_struct *work);
4162306a36Sopenharmony_civoid ath10k_mgmt_over_wmi_tx_purge(struct ath10k *ar);
4262306a36Sopenharmony_civoid ath10k_mgmt_over_wmi_tx_work(struct work_struct *work);
4362306a36Sopenharmony_civoid ath10k_halt(struct ath10k *ar);
4462306a36Sopenharmony_civoid ath10k_mac_vif_beacon_free(struct ath10k_vif *arvif);
4562306a36Sopenharmony_civoid ath10k_drain_tx(struct ath10k *ar);
4662306a36Sopenharmony_cibool ath10k_mac_is_peer_wep_key_set(struct ath10k *ar, const u8 *addr,
4762306a36Sopenharmony_ci				    u8 keyidx);
4862306a36Sopenharmony_ciint ath10k_mac_vif_chan(struct ieee80211_vif *vif,
4962306a36Sopenharmony_ci			struct cfg80211_chan_def *def);
5062306a36Sopenharmony_ci
5162306a36Sopenharmony_civoid ath10k_mac_handle_beacon(struct ath10k *ar, struct sk_buff *skb);
5262306a36Sopenharmony_civoid ath10k_mac_handle_beacon_miss(struct ath10k *ar, u32 vdev_id);
5362306a36Sopenharmony_civoid ath10k_mac_handle_tx_pause_vdev(struct ath10k *ar, u32 vdev_id,
5462306a36Sopenharmony_ci				     enum wmi_tlv_tx_pause_id pause_id,
5562306a36Sopenharmony_ci				     enum wmi_tlv_tx_pause_action action);
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ciu8 ath10k_mac_hw_rate_to_idx(const struct ieee80211_supported_band *sband,
5862306a36Sopenharmony_ci			     u8 hw_rate, bool cck);
5962306a36Sopenharmony_ciu8 ath10k_mac_bitrate_to_idx(const struct ieee80211_supported_band *sband,
6062306a36Sopenharmony_ci			     u32 bitrate);
6162306a36Sopenharmony_ci
6262306a36Sopenharmony_civoid ath10k_mac_tx_lock(struct ath10k *ar, int reason);
6362306a36Sopenharmony_civoid ath10k_mac_tx_unlock(struct ath10k *ar, int reason);
6462306a36Sopenharmony_civoid ath10k_mac_vif_tx_lock(struct ath10k_vif *arvif, int reason);
6562306a36Sopenharmony_civoid ath10k_mac_vif_tx_unlock(struct ath10k_vif *arvif, int reason);
6662306a36Sopenharmony_cibool ath10k_mac_tx_frm_has_freq(struct ath10k *ar);
6762306a36Sopenharmony_civoid ath10k_mac_tx_push_pending(struct ath10k *ar);
6862306a36Sopenharmony_ciint ath10k_mac_tx_push_txq(struct ieee80211_hw *hw,
6962306a36Sopenharmony_ci			   struct ieee80211_txq *txq);
7062306a36Sopenharmony_cistruct ieee80211_txq *ath10k_mac_txq_lookup(struct ath10k *ar,
7162306a36Sopenharmony_ci					    u16 peer_id,
7262306a36Sopenharmony_ci					    u8 tid);
7362306a36Sopenharmony_ciint ath10k_mac_ext_resource_config(struct ath10k *ar, u32 val);
7462306a36Sopenharmony_civoid ath10k_mac_wait_tx_complete(struct ath10k *ar);
7562306a36Sopenharmony_ciint ath10k_mac_rfkill_enable_radio(struct ath10k *ar, bool enable);
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_cistatic inline void ath10k_tx_h_seq_no(struct ieee80211_vif *vif,
7862306a36Sopenharmony_ci				      struct sk_buff *skb)
7962306a36Sopenharmony_ci{
8062306a36Sopenharmony_ci	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
8162306a36Sopenharmony_ci	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
8262306a36Sopenharmony_ci	struct ath10k_vif *arvif = (void *)vif->drv_priv;
8362306a36Sopenharmony_ci
8462306a36Sopenharmony_ci	if (info->flags  & IEEE80211_TX_CTL_ASSIGN_SEQ) {
8562306a36Sopenharmony_ci		if (arvif->tx_seq_no == 0)
8662306a36Sopenharmony_ci			arvif->tx_seq_no = 0x1000;
8762306a36Sopenharmony_ci
8862306a36Sopenharmony_ci		if (info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT)
8962306a36Sopenharmony_ci			arvif->tx_seq_no += 0x10;
9062306a36Sopenharmony_ci		hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
9162306a36Sopenharmony_ci		hdr->seq_ctrl |= cpu_to_le16(arvif->tx_seq_no);
9262306a36Sopenharmony_ci	}
9362306a36Sopenharmony_ci}
9462306a36Sopenharmony_ci
9562306a36Sopenharmony_ci#endif /* _MAC_H_ */
96