xref: /freebsd/sys/contrib/dev/athk/ath10k/mac.h (revision da8fa4e37a0c048a67d7baa3b5a9bed637d02564)
1*da8fa4e3SBjoern A. Zeeb /* SPDX-License-Identifier: ISC */
2*da8fa4e3SBjoern A. Zeeb /*
3*da8fa4e3SBjoern A. Zeeb  * Copyright (c) 2005-2011 Atheros Communications Inc.
4*da8fa4e3SBjoern A. Zeeb  * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.
5*da8fa4e3SBjoern A. Zeeb  */
6*da8fa4e3SBjoern A. Zeeb 
7*da8fa4e3SBjoern A. Zeeb #ifndef _MAC_H_
8*da8fa4e3SBjoern A. Zeeb #define _MAC_H_
9*da8fa4e3SBjoern A. Zeeb 
10*da8fa4e3SBjoern A. Zeeb #include <net/mac80211.h>
11*da8fa4e3SBjoern A. Zeeb #include "core.h"
12*da8fa4e3SBjoern A. Zeeb 
13*da8fa4e3SBjoern A. Zeeb #define WEP_KEYID_SHIFT 6
14*da8fa4e3SBjoern A. Zeeb 
15*da8fa4e3SBjoern A. Zeeb enum wmi_tlv_tx_pause_id;
16*da8fa4e3SBjoern A. Zeeb enum wmi_tlv_tx_pause_action;
17*da8fa4e3SBjoern A. Zeeb 
18*da8fa4e3SBjoern A. Zeeb struct ath10k_generic_iter {
19*da8fa4e3SBjoern A. Zeeb 	struct ath10k *ar;
20*da8fa4e3SBjoern A. Zeeb 	int ret;
21*da8fa4e3SBjoern A. Zeeb };
22*da8fa4e3SBjoern A. Zeeb 
23*da8fa4e3SBjoern A. Zeeb struct rfc1042_hdr {
24*da8fa4e3SBjoern A. Zeeb 	u8 llc_dsap;
25*da8fa4e3SBjoern A. Zeeb 	u8 llc_ssap;
26*da8fa4e3SBjoern A. Zeeb 	u8 llc_ctrl;
27*da8fa4e3SBjoern A. Zeeb 	u8 snap_oui[3];
28*da8fa4e3SBjoern A. Zeeb 	__be16 snap_type;
29*da8fa4e3SBjoern A. Zeeb } __packed;
30*da8fa4e3SBjoern A. Zeeb 
31*da8fa4e3SBjoern A. Zeeb struct ath10k *ath10k_mac_create(size_t priv_size);
32*da8fa4e3SBjoern A. Zeeb void ath10k_mac_destroy(struct ath10k *ar);
33*da8fa4e3SBjoern A. Zeeb int ath10k_mac_register(struct ath10k *ar);
34*da8fa4e3SBjoern A. Zeeb void ath10k_mac_unregister(struct ath10k *ar);
35*da8fa4e3SBjoern A. Zeeb struct ath10k_vif *ath10k_get_arvif(struct ath10k *ar, u32 vdev_id);
36*da8fa4e3SBjoern A. Zeeb void __ath10k_scan_finish(struct ath10k *ar);
37*da8fa4e3SBjoern A. Zeeb void ath10k_scan_finish(struct ath10k *ar);
38*da8fa4e3SBjoern A. Zeeb void ath10k_scan_timeout_work(struct work_struct *work);
39*da8fa4e3SBjoern A. Zeeb void ath10k_offchan_tx_purge(struct ath10k *ar);
40*da8fa4e3SBjoern A. Zeeb void ath10k_offchan_tx_work(struct work_struct *work);
41*da8fa4e3SBjoern A. Zeeb void ath10k_mgmt_over_wmi_tx_purge(struct ath10k *ar);
42*da8fa4e3SBjoern A. Zeeb void ath10k_mgmt_over_wmi_tx_work(struct work_struct *work);
43*da8fa4e3SBjoern A. Zeeb void ath10k_halt(struct ath10k *ar);
44*da8fa4e3SBjoern A. Zeeb void ath10k_mac_vif_beacon_free(struct ath10k_vif *arvif);
45*da8fa4e3SBjoern A. Zeeb void ath10k_drain_tx(struct ath10k *ar);
46*da8fa4e3SBjoern A. Zeeb bool ath10k_mac_is_peer_wep_key_set(struct ath10k *ar, const u8 *addr,
47*da8fa4e3SBjoern A. Zeeb 				    u8 keyidx);
48*da8fa4e3SBjoern A. Zeeb int ath10k_mac_vif_chan(struct ieee80211_vif *vif,
49*da8fa4e3SBjoern A. Zeeb 			struct cfg80211_chan_def *def);
50*da8fa4e3SBjoern A. Zeeb 
51*da8fa4e3SBjoern A. Zeeb void ath10k_mac_handle_beacon(struct ath10k *ar, struct sk_buff *skb);
52*da8fa4e3SBjoern A. Zeeb void ath10k_mac_handle_beacon_miss(struct ath10k *ar, u32 vdev_id);
53*da8fa4e3SBjoern A. Zeeb void ath10k_mac_handle_tx_pause_vdev(struct ath10k *ar, u32 vdev_id,
54*da8fa4e3SBjoern A. Zeeb 				     enum wmi_tlv_tx_pause_id pause_id,
55*da8fa4e3SBjoern A. Zeeb 				     enum wmi_tlv_tx_pause_action action);
56*da8fa4e3SBjoern A. Zeeb 
57*da8fa4e3SBjoern A. Zeeb u8 ath10k_mac_hw_rate_to_idx(const struct ieee80211_supported_band *sband,
58*da8fa4e3SBjoern A. Zeeb 			     u8 hw_rate, bool cck);
59*da8fa4e3SBjoern A. Zeeb u8 ath10k_mac_bitrate_to_idx(const struct ieee80211_supported_band *sband,
60*da8fa4e3SBjoern A. Zeeb 			     u32 bitrate);
61*da8fa4e3SBjoern A. Zeeb 
62*da8fa4e3SBjoern A. Zeeb void ath10k_mac_tx_lock(struct ath10k *ar, int reason);
63*da8fa4e3SBjoern A. Zeeb void ath10k_mac_tx_unlock(struct ath10k *ar, int reason);
64*da8fa4e3SBjoern A. Zeeb void ath10k_mac_vif_tx_lock(struct ath10k_vif *arvif, int reason);
65*da8fa4e3SBjoern A. Zeeb void ath10k_mac_vif_tx_unlock(struct ath10k_vif *arvif, int reason);
66*da8fa4e3SBjoern A. Zeeb bool ath10k_mac_tx_frm_has_freq(struct ath10k *ar);
67*da8fa4e3SBjoern A. Zeeb void ath10k_mac_tx_push_pending(struct ath10k *ar);
68*da8fa4e3SBjoern A. Zeeb int ath10k_mac_tx_push_txq(struct ieee80211_hw *hw,
69*da8fa4e3SBjoern A. Zeeb 			   struct ieee80211_txq *txq);
70*da8fa4e3SBjoern A. Zeeb struct ieee80211_txq *ath10k_mac_txq_lookup(struct ath10k *ar,
71*da8fa4e3SBjoern A. Zeeb 					    u16 peer_id,
72*da8fa4e3SBjoern A. Zeeb 					    u8 tid);
73*da8fa4e3SBjoern A. Zeeb int ath10k_mac_ext_resource_config(struct ath10k *ar, u32 val);
74*da8fa4e3SBjoern A. Zeeb void ath10k_mac_wait_tx_complete(struct ath10k *ar);
75*da8fa4e3SBjoern A. Zeeb int ath10k_mac_rfkill_enable_radio(struct ath10k *ar, bool enable);
76*da8fa4e3SBjoern A. Zeeb 
ath10k_tx_h_seq_no(struct ieee80211_vif * vif,struct sk_buff * skb)77*da8fa4e3SBjoern A. Zeeb static inline void ath10k_tx_h_seq_no(struct ieee80211_vif *vif,
78*da8fa4e3SBjoern A. Zeeb 				      struct sk_buff *skb)
79*da8fa4e3SBjoern A. Zeeb {
80*da8fa4e3SBjoern A. Zeeb 	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
81*da8fa4e3SBjoern A. Zeeb 	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
82*da8fa4e3SBjoern A. Zeeb 	struct ath10k_vif *arvif = (void *)vif->drv_priv;
83*da8fa4e3SBjoern A. Zeeb 
84*da8fa4e3SBjoern A. Zeeb 	if (info->flags  & IEEE80211_TX_CTL_ASSIGN_SEQ) {
85*da8fa4e3SBjoern A. Zeeb 		if (arvif->tx_seq_no == 0)
86*da8fa4e3SBjoern A. Zeeb 			arvif->tx_seq_no = 0x1000;
87*da8fa4e3SBjoern A. Zeeb 
88*da8fa4e3SBjoern A. Zeeb 		if (info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT)
89*da8fa4e3SBjoern A. Zeeb 			arvif->tx_seq_no += 0x10;
90*da8fa4e3SBjoern A. Zeeb 		hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
91*da8fa4e3SBjoern A. Zeeb 		hdr->seq_ctrl |= cpu_to_le16(arvif->tx_seq_no);
92*da8fa4e3SBjoern A. Zeeb 	}
93*da8fa4e3SBjoern A. Zeeb }
94*da8fa4e3SBjoern A. Zeeb 
95*da8fa4e3SBjoern A. Zeeb #endif /* _MAC_H_ */
96