Loading...
1/* SPDX-License-Identifier: ISC */
2/*
3 * Copyright (c) 2005-2011 Atheros Communications Inc.
4 * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.
5 */
6
7#ifndef _MAC_H_
8#define _MAC_H_
9
10#include <net/mac80211.h>
11#include "core.h"
12
13#define WEP_KEYID_SHIFT 6
14
15enum wmi_tlv_tx_pause_id;
16enum wmi_tlv_tx_pause_action;
17
18struct ath10k_generic_iter {
19 struct ath10k *ar;
20 int ret;
21};
22
23struct rfc1042_hdr {
24 u8 llc_dsap;
25 u8 llc_ssap;
26 u8 llc_ctrl;
27 u8 snap_oui[3];
28 __be16 snap_type;
29} __packed;
30
31struct ath10k *ath10k_mac_create(size_t priv_size);
32void ath10k_mac_destroy(struct ath10k *ar);
33int ath10k_mac_register(struct ath10k *ar);
34void ath10k_mac_unregister(struct ath10k *ar);
35struct ath10k_vif *ath10k_get_arvif(struct ath10k *ar, u32 vdev_id);
36void __ath10k_scan_finish(struct ath10k *ar);
37void ath10k_scan_finish(struct ath10k *ar);
38void ath10k_scan_timeout_work(struct work_struct *work);
39void ath10k_offchan_tx_purge(struct ath10k *ar);
40void ath10k_offchan_tx_work(struct work_struct *work);
41void ath10k_mgmt_over_wmi_tx_purge(struct ath10k *ar);
42void ath10k_mgmt_over_wmi_tx_work(struct work_struct *work);
43void ath10k_halt(struct ath10k *ar);
44void ath10k_mac_vif_beacon_free(struct ath10k_vif *arvif);
45void ath10k_drain_tx(struct ath10k *ar);
46bool ath10k_mac_is_peer_wep_key_set(struct ath10k *ar, const u8 *addr,
47 u8 keyidx);
48int ath10k_mac_vif_chan(struct ieee80211_vif *vif,
49 struct cfg80211_chan_def *def);
50
51void ath10k_mac_handle_beacon(struct ath10k *ar, struct sk_buff *skb);
52void ath10k_mac_handle_beacon_miss(struct ath10k *ar, u32 vdev_id);
53void ath10k_mac_handle_tx_pause_vdev(struct ath10k *ar, u32 vdev_id,
54 enum wmi_tlv_tx_pause_id pause_id,
55 enum wmi_tlv_tx_pause_action action);
56
57u8 ath10k_mac_hw_rate_to_idx(const struct ieee80211_supported_band *sband,
58 u8 hw_rate, bool cck);
59u8 ath10k_mac_bitrate_to_idx(const struct ieee80211_supported_band *sband,
60 u32 bitrate);
61
62void ath10k_mac_tx_lock(struct ath10k *ar, int reason);
63void ath10k_mac_tx_unlock(struct ath10k *ar, int reason);
64void ath10k_mac_vif_tx_lock(struct ath10k_vif *arvif, int reason);
65void ath10k_mac_vif_tx_unlock(struct ath10k_vif *arvif, int reason);
66bool ath10k_mac_tx_frm_has_freq(struct ath10k *ar);
67void ath10k_mac_tx_push_pending(struct ath10k *ar);
68int ath10k_mac_tx_push_txq(struct ieee80211_hw *hw,
69 struct ieee80211_txq *txq);
70struct ieee80211_txq *ath10k_mac_txq_lookup(struct ath10k *ar,
71 u16 peer_id,
72 u8 tid);
73int ath10k_mac_ext_resource_config(struct ath10k *ar, u32 val);
74void ath10k_mac_wait_tx_complete(struct ath10k *ar);
75int ath10k_mac_rfkill_enable_radio(struct ath10k *ar, bool enable);
76
77static inline void ath10k_tx_h_seq_no(struct ieee80211_vif *vif,
78 struct sk_buff *skb)
79{
80 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
81 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
82 struct ath10k_vif *arvif = (void *)vif->drv_priv;
83
84 if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) {
85 if (arvif->tx_seq_no == 0)
86 arvif->tx_seq_no = 0x1000;
87
88 if (info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT)
89 arvif->tx_seq_no += 0x10;
90 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
91 hdr->seq_ctrl |= cpu_to_le16(arvif->tx_seq_no);
92 }
93}
94
95#endif /* _MAC_H_ */
1/*
2 * Copyright (c) 2005-2011 Atheros Communications Inc.
3 * Copyright (c) 2011-2013 Qualcomm Atheros, Inc.
4 *
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18#ifndef _MAC_H_
19#define _MAC_H_
20
21#include <net/mac80211.h>
22#include "core.h"
23
24#define WEP_KEYID_SHIFT 6
25
26enum wmi_tlv_tx_pause_id;
27enum wmi_tlv_tx_pause_action;
28
29struct ath10k_generic_iter {
30 struct ath10k *ar;
31 int ret;
32};
33
34struct rfc1042_hdr {
35 u8 llc_dsap;
36 u8 llc_ssap;
37 u8 llc_ctrl;
38 u8 snap_oui[3];
39 __be16 snap_type;
40} __packed;
41
42struct ath10k *ath10k_mac_create(size_t priv_size);
43void ath10k_mac_destroy(struct ath10k *ar);
44int ath10k_mac_register(struct ath10k *ar);
45void ath10k_mac_unregister(struct ath10k *ar);
46struct ath10k_vif *ath10k_get_arvif(struct ath10k *ar, u32 vdev_id);
47void __ath10k_scan_finish(struct ath10k *ar);
48void ath10k_scan_finish(struct ath10k *ar);
49void ath10k_scan_timeout_work(struct work_struct *work);
50void ath10k_offchan_tx_purge(struct ath10k *ar);
51void ath10k_offchan_tx_work(struct work_struct *work);
52void ath10k_mgmt_over_wmi_tx_purge(struct ath10k *ar);
53void ath10k_mgmt_over_wmi_tx_work(struct work_struct *work);
54void ath10k_halt(struct ath10k *ar);
55void ath10k_mac_vif_beacon_free(struct ath10k_vif *arvif);
56void ath10k_drain_tx(struct ath10k *ar);
57bool ath10k_mac_is_peer_wep_key_set(struct ath10k *ar, const u8 *addr,
58 u8 keyidx);
59int ath10k_mac_vif_chan(struct ieee80211_vif *vif,
60 struct cfg80211_chan_def *def);
61
62void ath10k_mac_handle_beacon(struct ath10k *ar, struct sk_buff *skb);
63void ath10k_mac_handle_beacon_miss(struct ath10k *ar, u32 vdev_id);
64void ath10k_mac_handle_tx_pause_vdev(struct ath10k *ar, u32 vdev_id,
65 enum wmi_tlv_tx_pause_id pause_id,
66 enum wmi_tlv_tx_pause_action action);
67
68u8 ath10k_mac_hw_rate_to_idx(const struct ieee80211_supported_band *sband,
69 u8 hw_rate, bool cck);
70u8 ath10k_mac_bitrate_to_idx(const struct ieee80211_supported_band *sband,
71 u32 bitrate);
72
73void ath10k_mac_tx_lock(struct ath10k *ar, int reason);
74void ath10k_mac_tx_unlock(struct ath10k *ar, int reason);
75void ath10k_mac_vif_tx_lock(struct ath10k_vif *arvif, int reason);
76void ath10k_mac_vif_tx_unlock(struct ath10k_vif *arvif, int reason);
77bool ath10k_mac_tx_frm_has_freq(struct ath10k *ar);
78
79static inline struct ath10k_vif *ath10k_vif_to_arvif(struct ieee80211_vif *vif)
80{
81 return (struct ath10k_vif *)vif->drv_priv;
82}
83
84static inline void ath10k_tx_h_seq_no(struct ieee80211_vif *vif,
85 struct sk_buff *skb)
86{
87 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
88 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
89 struct ath10k_vif *arvif = ath10k_vif_to_arvif(vif);
90
91 if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) {
92 if (arvif->tx_seq_no == 0)
93 arvif->tx_seq_no = 0x1000;
94
95 if (info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT)
96 arvif->tx_seq_no += 0x10;
97 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
98 hdr->seq_ctrl |= cpu_to_le16(arvif->tx_seq_no);
99 }
100}
101
102#endif /* _MAC_H_ */