xref: /OK3568_Linux_fs/kernel/include/net/mac80211.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-only */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * mac80211 <-> driver interface
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * Copyright 2002-2005, Devicescape Software, Inc.
6*4882a593Smuzhiyun  * Copyright 2006-2007	Jiri Benc <jbenc@suse.cz>
7*4882a593Smuzhiyun  * Copyright 2007-2010	Johannes Berg <johannes@sipsolutions.net>
8*4882a593Smuzhiyun  * Copyright 2013-2014  Intel Mobile Communications GmbH
9*4882a593Smuzhiyun  * Copyright (C) 2015 - 2017 Intel Deutschland GmbH
10*4882a593Smuzhiyun  * Copyright (C) 2018 - 2020 Intel Corporation
11*4882a593Smuzhiyun  */
12*4882a593Smuzhiyun 
13*4882a593Smuzhiyun #ifndef MAC80211_H
14*4882a593Smuzhiyun #define MAC80211_H
15*4882a593Smuzhiyun 
16*4882a593Smuzhiyun #include <linux/bug.h>
17*4882a593Smuzhiyun #include <linux/kernel.h>
18*4882a593Smuzhiyun #include <linux/if_ether.h>
19*4882a593Smuzhiyun #include <linux/skbuff.h>
20*4882a593Smuzhiyun #include <linux/ieee80211.h>
21*4882a593Smuzhiyun #include <linux/android_kabi.h>
22*4882a593Smuzhiyun #include <net/cfg80211.h>
23*4882a593Smuzhiyun #include <net/codel.h>
24*4882a593Smuzhiyun #include <net/ieee80211_radiotap.h>
25*4882a593Smuzhiyun #include <asm/unaligned.h>
26*4882a593Smuzhiyun 
27*4882a593Smuzhiyun /**
28*4882a593Smuzhiyun  * DOC: Introduction
29*4882a593Smuzhiyun  *
30*4882a593Smuzhiyun  * mac80211 is the Linux stack for 802.11 hardware that implements
31*4882a593Smuzhiyun  * only partial functionality in hard- or firmware. This document
32*4882a593Smuzhiyun  * defines the interface between mac80211 and low-level hardware
33*4882a593Smuzhiyun  * drivers.
34*4882a593Smuzhiyun  */
35*4882a593Smuzhiyun 
36*4882a593Smuzhiyun /**
37*4882a593Smuzhiyun  * DOC: Calling mac80211 from interrupts
38*4882a593Smuzhiyun  *
39*4882a593Smuzhiyun  * Only ieee80211_tx_status_irqsafe() and ieee80211_rx_irqsafe() can be
40*4882a593Smuzhiyun  * called in hardware interrupt context. The low-level driver must not call any
41*4882a593Smuzhiyun  * other functions in hardware interrupt context. If there is a need for such
42*4882a593Smuzhiyun  * call, the low-level driver should first ACK the interrupt and perform the
43*4882a593Smuzhiyun  * IEEE 802.11 code call after this, e.g. from a scheduled workqueue or even
44*4882a593Smuzhiyun  * tasklet function.
45*4882a593Smuzhiyun  *
46*4882a593Smuzhiyun  * NOTE: If the driver opts to use the _irqsafe() functions, it may not also
47*4882a593Smuzhiyun  *	 use the non-IRQ-safe functions!
48*4882a593Smuzhiyun  */
49*4882a593Smuzhiyun 
50*4882a593Smuzhiyun /**
51*4882a593Smuzhiyun  * DOC: Warning
52*4882a593Smuzhiyun  *
53*4882a593Smuzhiyun  * If you're reading this document and not the header file itself, it will
54*4882a593Smuzhiyun  * be incomplete because not all documentation has been converted yet.
55*4882a593Smuzhiyun  */
56*4882a593Smuzhiyun 
57*4882a593Smuzhiyun /**
58*4882a593Smuzhiyun  * DOC: Frame format
59*4882a593Smuzhiyun  *
60*4882a593Smuzhiyun  * As a general rule, when frames are passed between mac80211 and the driver,
61*4882a593Smuzhiyun  * they start with the IEEE 802.11 header and include the same octets that are
62*4882a593Smuzhiyun  * sent over the air except for the FCS which should be calculated by the
63*4882a593Smuzhiyun  * hardware.
64*4882a593Smuzhiyun  *
65*4882a593Smuzhiyun  * There are, however, various exceptions to this rule for advanced features:
66*4882a593Smuzhiyun  *
67*4882a593Smuzhiyun  * The first exception is for hardware encryption and decryption offload
68*4882a593Smuzhiyun  * where the IV/ICV may or may not be generated in hardware.
69*4882a593Smuzhiyun  *
70*4882a593Smuzhiyun  * Secondly, when the hardware handles fragmentation, the frame handed to
71*4882a593Smuzhiyun  * the driver from mac80211 is the MSDU, not the MPDU.
72*4882a593Smuzhiyun  */
73*4882a593Smuzhiyun 
74*4882a593Smuzhiyun /**
75*4882a593Smuzhiyun  * DOC: mac80211 workqueue
76*4882a593Smuzhiyun  *
77*4882a593Smuzhiyun  * mac80211 provides its own workqueue for drivers and internal mac80211 use.
78*4882a593Smuzhiyun  * The workqueue is a single threaded workqueue and can only be accessed by
79*4882a593Smuzhiyun  * helpers for sanity checking. Drivers must ensure all work added onto the
80*4882a593Smuzhiyun  * mac80211 workqueue should be cancelled on the driver stop() callback.
81*4882a593Smuzhiyun  *
82*4882a593Smuzhiyun  * mac80211 will flushed the workqueue upon interface removal and during
83*4882a593Smuzhiyun  * suspend.
84*4882a593Smuzhiyun  *
85*4882a593Smuzhiyun  * All work performed on the mac80211 workqueue must not acquire the RTNL lock.
86*4882a593Smuzhiyun  *
87*4882a593Smuzhiyun  */
88*4882a593Smuzhiyun 
89*4882a593Smuzhiyun /**
90*4882a593Smuzhiyun  * DOC: mac80211 software tx queueing
91*4882a593Smuzhiyun  *
92*4882a593Smuzhiyun  * mac80211 provides an optional intermediate queueing implementation designed
93*4882a593Smuzhiyun  * to allow the driver to keep hardware queues short and provide some fairness
94*4882a593Smuzhiyun  * between different stations/interfaces.
95*4882a593Smuzhiyun  * In this model, the driver pulls data frames from the mac80211 queue instead
96*4882a593Smuzhiyun  * of letting mac80211 push them via drv_tx().
97*4882a593Smuzhiyun  * Other frames (e.g. control or management) are still pushed using drv_tx().
98*4882a593Smuzhiyun  *
99*4882a593Smuzhiyun  * Drivers indicate that they use this model by implementing the .wake_tx_queue
100*4882a593Smuzhiyun  * driver operation.
101*4882a593Smuzhiyun  *
102*4882a593Smuzhiyun  * Intermediate queues (struct ieee80211_txq) are kept per-sta per-tid, with
103*4882a593Smuzhiyun  * another per-sta for non-data/non-mgmt and bufferable management frames, and
104*4882a593Smuzhiyun  * a single per-vif queue for multicast data frames.
105*4882a593Smuzhiyun  *
106*4882a593Smuzhiyun  * The driver is expected to initialize its private per-queue data for stations
107*4882a593Smuzhiyun  * and interfaces in the .add_interface and .sta_add ops.
108*4882a593Smuzhiyun  *
109*4882a593Smuzhiyun  * The driver can't access the queue directly. To dequeue a frame from a
110*4882a593Smuzhiyun  * txq, it calls ieee80211_tx_dequeue(). Whenever mac80211 adds a new frame to a
111*4882a593Smuzhiyun  * queue, it calls the .wake_tx_queue driver op.
112*4882a593Smuzhiyun  *
113*4882a593Smuzhiyun  * Drivers can optionally delegate responsibility for scheduling queues to
114*4882a593Smuzhiyun  * mac80211, to take advantage of airtime fairness accounting. In this case, to
115*4882a593Smuzhiyun  * obtain the next queue to pull frames from, the driver calls
116*4882a593Smuzhiyun  * ieee80211_next_txq(). The driver is then expected to return the txq using
117*4882a593Smuzhiyun  * ieee80211_return_txq().
118*4882a593Smuzhiyun  *
119*4882a593Smuzhiyun  * For AP powersave TIM handling, the driver only needs to indicate if it has
120*4882a593Smuzhiyun  * buffered packets in the driver specific data structures by calling
121*4882a593Smuzhiyun  * ieee80211_sta_set_buffered(). For frames buffered in the ieee80211_txq
122*4882a593Smuzhiyun  * struct, mac80211 sets the appropriate TIM PVB bits and calls
123*4882a593Smuzhiyun  * .release_buffered_frames().
124*4882a593Smuzhiyun  * In that callback the driver is therefore expected to release its own
125*4882a593Smuzhiyun  * buffered frames and afterwards also frames from the ieee80211_txq (obtained
126*4882a593Smuzhiyun  * via the usual ieee80211_tx_dequeue).
127*4882a593Smuzhiyun  */
128*4882a593Smuzhiyun 
129*4882a593Smuzhiyun struct device;
130*4882a593Smuzhiyun 
131*4882a593Smuzhiyun /**
132*4882a593Smuzhiyun  * enum ieee80211_max_queues - maximum number of queues
133*4882a593Smuzhiyun  *
134*4882a593Smuzhiyun  * @IEEE80211_MAX_QUEUES: Maximum number of regular device queues.
135*4882a593Smuzhiyun  * @IEEE80211_MAX_QUEUE_MAP: bitmap with maximum queues set
136*4882a593Smuzhiyun  */
137*4882a593Smuzhiyun enum ieee80211_max_queues {
138*4882a593Smuzhiyun 	IEEE80211_MAX_QUEUES =		16,
139*4882a593Smuzhiyun 	IEEE80211_MAX_QUEUE_MAP =	BIT(IEEE80211_MAX_QUEUES) - 1,
140*4882a593Smuzhiyun };
141*4882a593Smuzhiyun 
142*4882a593Smuzhiyun #define IEEE80211_INVAL_HW_QUEUE	0xff
143*4882a593Smuzhiyun 
144*4882a593Smuzhiyun /**
145*4882a593Smuzhiyun  * enum ieee80211_ac_numbers - AC numbers as used in mac80211
146*4882a593Smuzhiyun  * @IEEE80211_AC_VO: voice
147*4882a593Smuzhiyun  * @IEEE80211_AC_VI: video
148*4882a593Smuzhiyun  * @IEEE80211_AC_BE: best effort
149*4882a593Smuzhiyun  * @IEEE80211_AC_BK: background
150*4882a593Smuzhiyun  */
151*4882a593Smuzhiyun enum ieee80211_ac_numbers {
152*4882a593Smuzhiyun 	IEEE80211_AC_VO		= 0,
153*4882a593Smuzhiyun 	IEEE80211_AC_VI		= 1,
154*4882a593Smuzhiyun 	IEEE80211_AC_BE		= 2,
155*4882a593Smuzhiyun 	IEEE80211_AC_BK		= 3,
156*4882a593Smuzhiyun };
157*4882a593Smuzhiyun 
158*4882a593Smuzhiyun /**
159*4882a593Smuzhiyun  * struct ieee80211_tx_queue_params - transmit queue configuration
160*4882a593Smuzhiyun  *
161*4882a593Smuzhiyun  * The information provided in this structure is required for QoS
162*4882a593Smuzhiyun  * transmit queue configuration. Cf. IEEE 802.11 7.3.2.29.
163*4882a593Smuzhiyun  *
164*4882a593Smuzhiyun  * @aifs: arbitration interframe space [0..255]
165*4882a593Smuzhiyun  * @cw_min: minimum contention window [a value of the form
166*4882a593Smuzhiyun  *	2^n-1 in the range 1..32767]
167*4882a593Smuzhiyun  * @cw_max: maximum contention window [like @cw_min]
168*4882a593Smuzhiyun  * @txop: maximum burst time in units of 32 usecs, 0 meaning disabled
169*4882a593Smuzhiyun  * @acm: is mandatory admission control required for the access category
170*4882a593Smuzhiyun  * @uapsd: is U-APSD mode enabled for the queue
171*4882a593Smuzhiyun  * @mu_edca: is the MU EDCA configured
172*4882a593Smuzhiyun  * @mu_edca_param_rec: MU EDCA Parameter Record for HE
173*4882a593Smuzhiyun  */
174*4882a593Smuzhiyun struct ieee80211_tx_queue_params {
175*4882a593Smuzhiyun 	u16 txop;
176*4882a593Smuzhiyun 	u16 cw_min;
177*4882a593Smuzhiyun 	u16 cw_max;
178*4882a593Smuzhiyun 	u8 aifs;
179*4882a593Smuzhiyun 	bool acm;
180*4882a593Smuzhiyun 	bool uapsd;
181*4882a593Smuzhiyun 	bool mu_edca;
182*4882a593Smuzhiyun 	struct ieee80211_he_mu_edca_param_ac_rec mu_edca_param_rec;
183*4882a593Smuzhiyun };
184*4882a593Smuzhiyun 
185*4882a593Smuzhiyun struct ieee80211_low_level_stats {
186*4882a593Smuzhiyun 	unsigned int dot11ACKFailureCount;
187*4882a593Smuzhiyun 	unsigned int dot11RTSFailureCount;
188*4882a593Smuzhiyun 	unsigned int dot11FCSErrorCount;
189*4882a593Smuzhiyun 	unsigned int dot11RTSSuccessCount;
190*4882a593Smuzhiyun };
191*4882a593Smuzhiyun 
192*4882a593Smuzhiyun /**
193*4882a593Smuzhiyun  * enum ieee80211_chanctx_change - change flag for channel context
194*4882a593Smuzhiyun  * @IEEE80211_CHANCTX_CHANGE_WIDTH: The channel width changed
195*4882a593Smuzhiyun  * @IEEE80211_CHANCTX_CHANGE_RX_CHAINS: The number of RX chains changed
196*4882a593Smuzhiyun  * @IEEE80211_CHANCTX_CHANGE_RADAR: radar detection flag changed
197*4882a593Smuzhiyun  * @IEEE80211_CHANCTX_CHANGE_CHANNEL: switched to another operating channel,
198*4882a593Smuzhiyun  *	this is used only with channel switching with CSA
199*4882a593Smuzhiyun  * @IEEE80211_CHANCTX_CHANGE_MIN_WIDTH: The min required channel width changed
200*4882a593Smuzhiyun  */
201*4882a593Smuzhiyun enum ieee80211_chanctx_change {
202*4882a593Smuzhiyun 	IEEE80211_CHANCTX_CHANGE_WIDTH		= BIT(0),
203*4882a593Smuzhiyun 	IEEE80211_CHANCTX_CHANGE_RX_CHAINS	= BIT(1),
204*4882a593Smuzhiyun 	IEEE80211_CHANCTX_CHANGE_RADAR		= BIT(2),
205*4882a593Smuzhiyun 	IEEE80211_CHANCTX_CHANGE_CHANNEL	= BIT(3),
206*4882a593Smuzhiyun 	IEEE80211_CHANCTX_CHANGE_MIN_WIDTH	= BIT(4),
207*4882a593Smuzhiyun };
208*4882a593Smuzhiyun 
209*4882a593Smuzhiyun /**
210*4882a593Smuzhiyun  * struct ieee80211_chanctx_conf - channel context that vifs may be tuned to
211*4882a593Smuzhiyun  *
212*4882a593Smuzhiyun  * This is the driver-visible part. The ieee80211_chanctx
213*4882a593Smuzhiyun  * that contains it is visible in mac80211 only.
214*4882a593Smuzhiyun  *
215*4882a593Smuzhiyun  * @def: the channel definition
216*4882a593Smuzhiyun  * @min_def: the minimum channel definition currently required.
217*4882a593Smuzhiyun  * @rx_chains_static: The number of RX chains that must always be
218*4882a593Smuzhiyun  *	active on the channel to receive MIMO transmissions
219*4882a593Smuzhiyun  * @rx_chains_dynamic: The number of RX chains that must be enabled
220*4882a593Smuzhiyun  *	after RTS/CTS handshake to receive SMPS MIMO transmissions;
221*4882a593Smuzhiyun  *	this will always be >= @rx_chains_static.
222*4882a593Smuzhiyun  * @radar_enabled: whether radar detection is enabled on this channel.
223*4882a593Smuzhiyun  * @drv_priv: data area for driver use, will always be aligned to
224*4882a593Smuzhiyun  *	sizeof(void *), size is determined in hw information.
225*4882a593Smuzhiyun  */
226*4882a593Smuzhiyun struct ieee80211_chanctx_conf {
227*4882a593Smuzhiyun 	struct cfg80211_chan_def def;
228*4882a593Smuzhiyun 	struct cfg80211_chan_def min_def;
229*4882a593Smuzhiyun 
230*4882a593Smuzhiyun 	u8 rx_chains_static, rx_chains_dynamic;
231*4882a593Smuzhiyun 
232*4882a593Smuzhiyun 	bool radar_enabled;
233*4882a593Smuzhiyun 
234*4882a593Smuzhiyun 	u8 drv_priv[] __aligned(sizeof(void *));
235*4882a593Smuzhiyun };
236*4882a593Smuzhiyun 
237*4882a593Smuzhiyun /**
238*4882a593Smuzhiyun  * enum ieee80211_chanctx_switch_mode - channel context switch mode
239*4882a593Smuzhiyun  * @CHANCTX_SWMODE_REASSIGN_VIF: Both old and new contexts already
240*4882a593Smuzhiyun  *	exist (and will continue to exist), but the virtual interface
241*4882a593Smuzhiyun  *	needs to be switched from one to the other.
242*4882a593Smuzhiyun  * @CHANCTX_SWMODE_SWAP_CONTEXTS: The old context exists but will stop
243*4882a593Smuzhiyun  *      to exist with this call, the new context doesn't exist but
244*4882a593Smuzhiyun  *      will be active after this call, the virtual interface switches
245*4882a593Smuzhiyun  *      from the old to the new (note that the driver may of course
246*4882a593Smuzhiyun  *      implement this as an on-the-fly chandef switch of the existing
247*4882a593Smuzhiyun  *      hardware context, but the mac80211 pointer for the old context
248*4882a593Smuzhiyun  *      will cease to exist and only the new one will later be used
249*4882a593Smuzhiyun  *      for changes/removal.)
250*4882a593Smuzhiyun  */
251*4882a593Smuzhiyun enum ieee80211_chanctx_switch_mode {
252*4882a593Smuzhiyun 	CHANCTX_SWMODE_REASSIGN_VIF,
253*4882a593Smuzhiyun 	CHANCTX_SWMODE_SWAP_CONTEXTS,
254*4882a593Smuzhiyun };
255*4882a593Smuzhiyun 
256*4882a593Smuzhiyun /**
257*4882a593Smuzhiyun  * struct ieee80211_vif_chanctx_switch - vif chanctx switch information
258*4882a593Smuzhiyun  *
259*4882a593Smuzhiyun  * This is structure is used to pass information about a vif that
260*4882a593Smuzhiyun  * needs to switch from one chanctx to another.  The
261*4882a593Smuzhiyun  * &ieee80211_chanctx_switch_mode defines how the switch should be
262*4882a593Smuzhiyun  * done.
263*4882a593Smuzhiyun  *
264*4882a593Smuzhiyun  * @vif: the vif that should be switched from old_ctx to new_ctx
265*4882a593Smuzhiyun  * @old_ctx: the old context to which the vif was assigned
266*4882a593Smuzhiyun  * @new_ctx: the new context to which the vif must be assigned
267*4882a593Smuzhiyun  */
268*4882a593Smuzhiyun struct ieee80211_vif_chanctx_switch {
269*4882a593Smuzhiyun 	struct ieee80211_vif *vif;
270*4882a593Smuzhiyun 	struct ieee80211_chanctx_conf *old_ctx;
271*4882a593Smuzhiyun 	struct ieee80211_chanctx_conf *new_ctx;
272*4882a593Smuzhiyun };
273*4882a593Smuzhiyun 
274*4882a593Smuzhiyun /**
275*4882a593Smuzhiyun  * enum ieee80211_bss_change - BSS change notification flags
276*4882a593Smuzhiyun  *
277*4882a593Smuzhiyun  * These flags are used with the bss_info_changed() callback
278*4882a593Smuzhiyun  * to indicate which BSS parameter changed.
279*4882a593Smuzhiyun  *
280*4882a593Smuzhiyun  * @BSS_CHANGED_ASSOC: association status changed (associated/disassociated),
281*4882a593Smuzhiyun  *	also implies a change in the AID.
282*4882a593Smuzhiyun  * @BSS_CHANGED_ERP_CTS_PROT: CTS protection changed
283*4882a593Smuzhiyun  * @BSS_CHANGED_ERP_PREAMBLE: preamble changed
284*4882a593Smuzhiyun  * @BSS_CHANGED_ERP_SLOT: slot timing changed
285*4882a593Smuzhiyun  * @BSS_CHANGED_HT: 802.11n parameters changed
286*4882a593Smuzhiyun  * @BSS_CHANGED_BASIC_RATES: Basic rateset changed
287*4882a593Smuzhiyun  * @BSS_CHANGED_BEACON_INT: Beacon interval changed
288*4882a593Smuzhiyun  * @BSS_CHANGED_BSSID: BSSID changed, for whatever
289*4882a593Smuzhiyun  *	reason (IBSS and managed mode)
290*4882a593Smuzhiyun  * @BSS_CHANGED_BEACON: Beacon data changed, retrieve
291*4882a593Smuzhiyun  *	new beacon (beaconing modes)
292*4882a593Smuzhiyun  * @BSS_CHANGED_BEACON_ENABLED: Beaconing should be
293*4882a593Smuzhiyun  *	enabled/disabled (beaconing modes)
294*4882a593Smuzhiyun  * @BSS_CHANGED_CQM: Connection quality monitor config changed
295*4882a593Smuzhiyun  * @BSS_CHANGED_IBSS: IBSS join status changed
296*4882a593Smuzhiyun  * @BSS_CHANGED_ARP_FILTER: Hardware ARP filter address list or state changed.
297*4882a593Smuzhiyun  * @BSS_CHANGED_QOS: QoS for this association was enabled/disabled. Note
298*4882a593Smuzhiyun  *	that it is only ever disabled for station mode.
299*4882a593Smuzhiyun  * @BSS_CHANGED_IDLE: Idle changed for this BSS/interface.
300*4882a593Smuzhiyun  * @BSS_CHANGED_SSID: SSID changed for this BSS (AP and IBSS mode)
301*4882a593Smuzhiyun  * @BSS_CHANGED_AP_PROBE_RESP: Probe Response changed for this BSS (AP mode)
302*4882a593Smuzhiyun  * @BSS_CHANGED_PS: PS changed for this BSS (STA mode)
303*4882a593Smuzhiyun  * @BSS_CHANGED_TXPOWER: TX power setting changed for this interface
304*4882a593Smuzhiyun  * @BSS_CHANGED_P2P_PS: P2P powersave settings (CTWindow, opportunistic PS)
305*4882a593Smuzhiyun  *	changed
306*4882a593Smuzhiyun  * @BSS_CHANGED_BEACON_INFO: Data from the AP's beacon became available:
307*4882a593Smuzhiyun  *	currently dtim_period only is under consideration.
308*4882a593Smuzhiyun  * @BSS_CHANGED_BANDWIDTH: The bandwidth used by this interface changed,
309*4882a593Smuzhiyun  *	note that this is only called when it changes after the channel
310*4882a593Smuzhiyun  *	context had been assigned.
311*4882a593Smuzhiyun  * @BSS_CHANGED_OCB: OCB join status changed
312*4882a593Smuzhiyun  * @BSS_CHANGED_MU_GROUPS: VHT MU-MIMO group id or user position changed
313*4882a593Smuzhiyun  * @BSS_CHANGED_KEEP_ALIVE: keep alive options (idle period or protected
314*4882a593Smuzhiyun  *	keep alive) changed.
315*4882a593Smuzhiyun  * @BSS_CHANGED_MCAST_RATE: Multicast Rate setting changed for this interface
316*4882a593Smuzhiyun  * @BSS_CHANGED_FTM_RESPONDER: fine timing measurement request responder
317*4882a593Smuzhiyun  *	functionality changed for this BSS (AP mode).
318*4882a593Smuzhiyun  * @BSS_CHANGED_TWT: TWT status changed
319*4882a593Smuzhiyun  * @BSS_CHANGED_HE_OBSS_PD: OBSS Packet Detection status changed.
320*4882a593Smuzhiyun  * @BSS_CHANGED_HE_BSS_COLOR: BSS Color has changed
321*4882a593Smuzhiyun  * @BSS_CHANGED_FILS_DISCOVERY: FILS discovery status changed.
322*4882a593Smuzhiyun  * @BSS_CHANGED_UNSOL_BCAST_PROBE_RESP: Unsolicited broadcast probe response
323*4882a593Smuzhiyun  *	status changed.
324*4882a593Smuzhiyun  *
325*4882a593Smuzhiyun  */
326*4882a593Smuzhiyun enum ieee80211_bss_change {
327*4882a593Smuzhiyun 	BSS_CHANGED_ASSOC		= 1<<0,
328*4882a593Smuzhiyun 	BSS_CHANGED_ERP_CTS_PROT	= 1<<1,
329*4882a593Smuzhiyun 	BSS_CHANGED_ERP_PREAMBLE	= 1<<2,
330*4882a593Smuzhiyun 	BSS_CHANGED_ERP_SLOT		= 1<<3,
331*4882a593Smuzhiyun 	BSS_CHANGED_HT			= 1<<4,
332*4882a593Smuzhiyun 	BSS_CHANGED_BASIC_RATES		= 1<<5,
333*4882a593Smuzhiyun 	BSS_CHANGED_BEACON_INT		= 1<<6,
334*4882a593Smuzhiyun 	BSS_CHANGED_BSSID		= 1<<7,
335*4882a593Smuzhiyun 	BSS_CHANGED_BEACON		= 1<<8,
336*4882a593Smuzhiyun 	BSS_CHANGED_BEACON_ENABLED	= 1<<9,
337*4882a593Smuzhiyun 	BSS_CHANGED_CQM			= 1<<10,
338*4882a593Smuzhiyun 	BSS_CHANGED_IBSS		= 1<<11,
339*4882a593Smuzhiyun 	BSS_CHANGED_ARP_FILTER		= 1<<12,
340*4882a593Smuzhiyun 	BSS_CHANGED_QOS			= 1<<13,
341*4882a593Smuzhiyun 	BSS_CHANGED_IDLE		= 1<<14,
342*4882a593Smuzhiyun 	BSS_CHANGED_SSID		= 1<<15,
343*4882a593Smuzhiyun 	BSS_CHANGED_AP_PROBE_RESP	= 1<<16,
344*4882a593Smuzhiyun 	BSS_CHANGED_PS			= 1<<17,
345*4882a593Smuzhiyun 	BSS_CHANGED_TXPOWER		= 1<<18,
346*4882a593Smuzhiyun 	BSS_CHANGED_P2P_PS		= 1<<19,
347*4882a593Smuzhiyun 	BSS_CHANGED_BEACON_INFO		= 1<<20,
348*4882a593Smuzhiyun 	BSS_CHANGED_BANDWIDTH		= 1<<21,
349*4882a593Smuzhiyun 	BSS_CHANGED_OCB                 = 1<<22,
350*4882a593Smuzhiyun 	BSS_CHANGED_MU_GROUPS		= 1<<23,
351*4882a593Smuzhiyun 	BSS_CHANGED_KEEP_ALIVE		= 1<<24,
352*4882a593Smuzhiyun 	BSS_CHANGED_MCAST_RATE		= 1<<25,
353*4882a593Smuzhiyun 	BSS_CHANGED_FTM_RESPONDER	= 1<<26,
354*4882a593Smuzhiyun 	BSS_CHANGED_TWT			= 1<<27,
355*4882a593Smuzhiyun 	BSS_CHANGED_HE_OBSS_PD		= 1<<28,
356*4882a593Smuzhiyun 	BSS_CHANGED_HE_BSS_COLOR	= 1<<29,
357*4882a593Smuzhiyun 	BSS_CHANGED_FILS_DISCOVERY      = 1<<30,
358*4882a593Smuzhiyun 	BSS_CHANGED_UNSOL_BCAST_PROBE_RESP = 1<<31,
359*4882a593Smuzhiyun 
360*4882a593Smuzhiyun 	/* when adding here, make sure to change ieee80211_reconfig */
361*4882a593Smuzhiyun };
362*4882a593Smuzhiyun 
363*4882a593Smuzhiyun /*
364*4882a593Smuzhiyun  * The maximum number of IPv4 addresses listed for ARP filtering. If the number
365*4882a593Smuzhiyun  * of addresses for an interface increase beyond this value, hardware ARP
366*4882a593Smuzhiyun  * filtering will be disabled.
367*4882a593Smuzhiyun  */
368*4882a593Smuzhiyun #define IEEE80211_BSS_ARP_ADDR_LIST_LEN 4
369*4882a593Smuzhiyun 
370*4882a593Smuzhiyun /**
371*4882a593Smuzhiyun  * enum ieee80211_event_type - event to be notified to the low level driver
372*4882a593Smuzhiyun  * @RSSI_EVENT: AP's rssi crossed the a threshold set by the driver.
373*4882a593Smuzhiyun  * @MLME_EVENT: event related to MLME
374*4882a593Smuzhiyun  * @BAR_RX_EVENT: a BAR was received
375*4882a593Smuzhiyun  * @BA_FRAME_TIMEOUT: Frames were released from the reordering buffer because
376*4882a593Smuzhiyun  *	they timed out. This won't be called for each frame released, but only
377*4882a593Smuzhiyun  *	once each time the timeout triggers.
378*4882a593Smuzhiyun  */
379*4882a593Smuzhiyun enum ieee80211_event_type {
380*4882a593Smuzhiyun 	RSSI_EVENT,
381*4882a593Smuzhiyun 	MLME_EVENT,
382*4882a593Smuzhiyun 	BAR_RX_EVENT,
383*4882a593Smuzhiyun 	BA_FRAME_TIMEOUT,
384*4882a593Smuzhiyun };
385*4882a593Smuzhiyun 
386*4882a593Smuzhiyun /**
387*4882a593Smuzhiyun  * enum ieee80211_rssi_event_data - relevant when event type is %RSSI_EVENT
388*4882a593Smuzhiyun  * @RSSI_EVENT_HIGH: AP's rssi went below the threshold set by the driver.
389*4882a593Smuzhiyun  * @RSSI_EVENT_LOW: AP's rssi went above the threshold set by the driver.
390*4882a593Smuzhiyun  */
391*4882a593Smuzhiyun enum ieee80211_rssi_event_data {
392*4882a593Smuzhiyun 	RSSI_EVENT_HIGH,
393*4882a593Smuzhiyun 	RSSI_EVENT_LOW,
394*4882a593Smuzhiyun };
395*4882a593Smuzhiyun 
396*4882a593Smuzhiyun /**
397*4882a593Smuzhiyun  * struct ieee80211_rssi_event - data attached to an %RSSI_EVENT
398*4882a593Smuzhiyun  * @data: See &enum ieee80211_rssi_event_data
399*4882a593Smuzhiyun  */
400*4882a593Smuzhiyun struct ieee80211_rssi_event {
401*4882a593Smuzhiyun 	enum ieee80211_rssi_event_data data;
402*4882a593Smuzhiyun };
403*4882a593Smuzhiyun 
404*4882a593Smuzhiyun /**
405*4882a593Smuzhiyun  * enum ieee80211_mlme_event_data - relevant when event type is %MLME_EVENT
406*4882a593Smuzhiyun  * @AUTH_EVENT: the MLME operation is authentication
407*4882a593Smuzhiyun  * @ASSOC_EVENT: the MLME operation is association
408*4882a593Smuzhiyun  * @DEAUTH_RX_EVENT: deauth received..
409*4882a593Smuzhiyun  * @DEAUTH_TX_EVENT: deauth sent.
410*4882a593Smuzhiyun  */
411*4882a593Smuzhiyun enum ieee80211_mlme_event_data {
412*4882a593Smuzhiyun 	AUTH_EVENT,
413*4882a593Smuzhiyun 	ASSOC_EVENT,
414*4882a593Smuzhiyun 	DEAUTH_RX_EVENT,
415*4882a593Smuzhiyun 	DEAUTH_TX_EVENT,
416*4882a593Smuzhiyun };
417*4882a593Smuzhiyun 
418*4882a593Smuzhiyun /**
419*4882a593Smuzhiyun  * enum ieee80211_mlme_event_status - relevant when event type is %MLME_EVENT
420*4882a593Smuzhiyun  * @MLME_SUCCESS: the MLME operation completed successfully.
421*4882a593Smuzhiyun  * @MLME_DENIED: the MLME operation was denied by the peer.
422*4882a593Smuzhiyun  * @MLME_TIMEOUT: the MLME operation timed out.
423*4882a593Smuzhiyun  */
424*4882a593Smuzhiyun enum ieee80211_mlme_event_status {
425*4882a593Smuzhiyun 	MLME_SUCCESS,
426*4882a593Smuzhiyun 	MLME_DENIED,
427*4882a593Smuzhiyun 	MLME_TIMEOUT,
428*4882a593Smuzhiyun };
429*4882a593Smuzhiyun 
430*4882a593Smuzhiyun /**
431*4882a593Smuzhiyun  * struct ieee80211_mlme_event - data attached to an %MLME_EVENT
432*4882a593Smuzhiyun  * @data: See &enum ieee80211_mlme_event_data
433*4882a593Smuzhiyun  * @status: See &enum ieee80211_mlme_event_status
434*4882a593Smuzhiyun  * @reason: the reason code if applicable
435*4882a593Smuzhiyun  */
436*4882a593Smuzhiyun struct ieee80211_mlme_event {
437*4882a593Smuzhiyun 	enum ieee80211_mlme_event_data data;
438*4882a593Smuzhiyun 	enum ieee80211_mlme_event_status status;
439*4882a593Smuzhiyun 	u16 reason;
440*4882a593Smuzhiyun };
441*4882a593Smuzhiyun 
442*4882a593Smuzhiyun /**
443*4882a593Smuzhiyun  * struct ieee80211_ba_event - data attached for BlockAck related events
444*4882a593Smuzhiyun  * @sta: pointer to the &ieee80211_sta to which this event relates
445*4882a593Smuzhiyun  * @tid: the tid
446*4882a593Smuzhiyun  * @ssn: the starting sequence number (for %BAR_RX_EVENT)
447*4882a593Smuzhiyun  */
448*4882a593Smuzhiyun struct ieee80211_ba_event {
449*4882a593Smuzhiyun 	struct ieee80211_sta *sta;
450*4882a593Smuzhiyun 	u16 tid;
451*4882a593Smuzhiyun 	u16 ssn;
452*4882a593Smuzhiyun };
453*4882a593Smuzhiyun 
454*4882a593Smuzhiyun /**
455*4882a593Smuzhiyun  * struct ieee80211_event - event to be sent to the driver
456*4882a593Smuzhiyun  * @type: The event itself. See &enum ieee80211_event_type.
457*4882a593Smuzhiyun  * @rssi: relevant if &type is %RSSI_EVENT
458*4882a593Smuzhiyun  * @mlme: relevant if &type is %AUTH_EVENT
459*4882a593Smuzhiyun  * @ba: relevant if &type is %BAR_RX_EVENT or %BA_FRAME_TIMEOUT
460*4882a593Smuzhiyun  * @u:union holding the fields above
461*4882a593Smuzhiyun  */
462*4882a593Smuzhiyun struct ieee80211_event {
463*4882a593Smuzhiyun 	enum ieee80211_event_type type;
464*4882a593Smuzhiyun 	union {
465*4882a593Smuzhiyun 		struct ieee80211_rssi_event rssi;
466*4882a593Smuzhiyun 		struct ieee80211_mlme_event mlme;
467*4882a593Smuzhiyun 		struct ieee80211_ba_event ba;
468*4882a593Smuzhiyun 	} u;
469*4882a593Smuzhiyun };
470*4882a593Smuzhiyun 
471*4882a593Smuzhiyun /**
472*4882a593Smuzhiyun  * struct ieee80211_mu_group_data - STA's VHT MU-MIMO group data
473*4882a593Smuzhiyun  *
474*4882a593Smuzhiyun  * This structure describes the group id data of VHT MU-MIMO
475*4882a593Smuzhiyun  *
476*4882a593Smuzhiyun  * @membership: 64 bits array - a bit is set if station is member of the group
477*4882a593Smuzhiyun  * @position: 2 bits per group id indicating the position in the group
478*4882a593Smuzhiyun  */
479*4882a593Smuzhiyun struct ieee80211_mu_group_data {
480*4882a593Smuzhiyun 	u8 membership[WLAN_MEMBERSHIP_LEN];
481*4882a593Smuzhiyun 	u8 position[WLAN_USER_POSITION_LEN];
482*4882a593Smuzhiyun };
483*4882a593Smuzhiyun 
484*4882a593Smuzhiyun /**
485*4882a593Smuzhiyun  * struct ieee80211_ftm_responder_params - FTM responder parameters
486*4882a593Smuzhiyun  *
487*4882a593Smuzhiyun  * @lci: LCI subelement content
488*4882a593Smuzhiyun  * @civicloc: CIVIC location subelement content
489*4882a593Smuzhiyun  * @lci_len: LCI data length
490*4882a593Smuzhiyun  * @civicloc_len: Civic data length
491*4882a593Smuzhiyun  */
492*4882a593Smuzhiyun struct ieee80211_ftm_responder_params {
493*4882a593Smuzhiyun 	const u8 *lci;
494*4882a593Smuzhiyun 	const u8 *civicloc;
495*4882a593Smuzhiyun 	size_t lci_len;
496*4882a593Smuzhiyun 	size_t civicloc_len;
497*4882a593Smuzhiyun };
498*4882a593Smuzhiyun 
499*4882a593Smuzhiyun /**
500*4882a593Smuzhiyun  * struct ieee80211_fils_discovery - FILS discovery parameters from
501*4882a593Smuzhiyun  * IEEE Std 802.11ai-2016, Annex C.3 MIB detail.
502*4882a593Smuzhiyun  *
503*4882a593Smuzhiyun  * @min_interval: Minimum packet interval in TUs (0 - 10000)
504*4882a593Smuzhiyun  * @max_interval: Maximum packet interval in TUs (0 - 10000)
505*4882a593Smuzhiyun  */
506*4882a593Smuzhiyun struct ieee80211_fils_discovery {
507*4882a593Smuzhiyun 	u32 min_interval;
508*4882a593Smuzhiyun 	u32 max_interval;
509*4882a593Smuzhiyun };
510*4882a593Smuzhiyun 
511*4882a593Smuzhiyun /**
512*4882a593Smuzhiyun  * struct ieee80211_bss_conf - holds the BSS's changing parameters
513*4882a593Smuzhiyun  *
514*4882a593Smuzhiyun  * This structure keeps information about a BSS (and an association
515*4882a593Smuzhiyun  * to that BSS) that can change during the lifetime of the BSS.
516*4882a593Smuzhiyun  *
517*4882a593Smuzhiyun  * @htc_trig_based_pkt_ext: default PE in 4us units, if BSS supports HE
518*4882a593Smuzhiyun  * @multi_sta_back_32bit: supports BA bitmap of 32-bits in Multi-STA BACK
519*4882a593Smuzhiyun  * @uora_exists: is the UORA element advertised by AP
520*4882a593Smuzhiyun  * @ack_enabled: indicates support to receive a multi-TID that solicits either
521*4882a593Smuzhiyun  *	ACK, BACK or both
522*4882a593Smuzhiyun  * @uora_ocw_range: UORA element's OCW Range field
523*4882a593Smuzhiyun  * @frame_time_rts_th: HE duration RTS threshold, in units of 32us
524*4882a593Smuzhiyun  * @he_support: does this BSS support HE
525*4882a593Smuzhiyun  * @twt_requester: does this BSS support TWT requester (relevant for managed
526*4882a593Smuzhiyun  *	mode only, set if the AP advertises TWT responder role)
527*4882a593Smuzhiyun  * @twt_responder: does this BSS support TWT requester (relevant for managed
528*4882a593Smuzhiyun  *	mode only, set if the AP advertises TWT responder role)
529*4882a593Smuzhiyun  * @twt_protected: does this BSS support protected TWT frames
530*4882a593Smuzhiyun  * @assoc: association status
531*4882a593Smuzhiyun  * @ibss_joined: indicates whether this station is part of an IBSS
532*4882a593Smuzhiyun  *	or not
533*4882a593Smuzhiyun  * @ibss_creator: indicates if a new IBSS network is being created
534*4882a593Smuzhiyun  * @aid: association ID number, valid only when @assoc is true
535*4882a593Smuzhiyun  * @use_cts_prot: use CTS protection
536*4882a593Smuzhiyun  * @use_short_preamble: use 802.11b short preamble
537*4882a593Smuzhiyun  * @use_short_slot: use short slot time (only relevant for ERP)
538*4882a593Smuzhiyun  * @dtim_period: num of beacons before the next DTIM, for beaconing,
539*4882a593Smuzhiyun  *	valid in station mode only if after the driver was notified
540*4882a593Smuzhiyun  *	with the %BSS_CHANGED_BEACON_INFO flag, will be non-zero then.
541*4882a593Smuzhiyun  * @sync_tsf: last beacon's/probe response's TSF timestamp (could be old
542*4882a593Smuzhiyun  *	as it may have been received during scanning long ago). If the
543*4882a593Smuzhiyun  *	HW flag %IEEE80211_HW_TIMING_BEACON_ONLY is set, then this can
544*4882a593Smuzhiyun  *	only come from a beacon, but might not become valid until after
545*4882a593Smuzhiyun  *	association when a beacon is received (which is notified with the
546*4882a593Smuzhiyun  *	%BSS_CHANGED_DTIM flag.). See also sync_dtim_count important notice.
547*4882a593Smuzhiyun  * @sync_device_ts: the device timestamp corresponding to the sync_tsf,
548*4882a593Smuzhiyun  *	the driver/device can use this to calculate synchronisation
549*4882a593Smuzhiyun  *	(see @sync_tsf). See also sync_dtim_count important notice.
550*4882a593Smuzhiyun  * @sync_dtim_count: Only valid when %IEEE80211_HW_TIMING_BEACON_ONLY
551*4882a593Smuzhiyun  *	is requested, see @sync_tsf/@sync_device_ts.
552*4882a593Smuzhiyun  *	IMPORTANT: These three sync_* parameters would possibly be out of sync
553*4882a593Smuzhiyun  *	by the time the driver will use them. The synchronized view is currently
554*4882a593Smuzhiyun  *	guaranteed only in certain callbacks.
555*4882a593Smuzhiyun  * @beacon_int: beacon interval
556*4882a593Smuzhiyun  * @assoc_capability: capabilities taken from assoc resp
557*4882a593Smuzhiyun  * @basic_rates: bitmap of basic rates, each bit stands for an
558*4882a593Smuzhiyun  *	index into the rate table configured by the driver in
559*4882a593Smuzhiyun  *	the current band.
560*4882a593Smuzhiyun  * @beacon_rate: associated AP's beacon TX rate
561*4882a593Smuzhiyun  * @mcast_rate: per-band multicast rate index + 1 (0: disabled)
562*4882a593Smuzhiyun  * @bssid: The BSSID for this BSS
563*4882a593Smuzhiyun  * @enable_beacon: whether beaconing should be enabled or not
564*4882a593Smuzhiyun  * @chandef: Channel definition for this BSS -- the hardware might be
565*4882a593Smuzhiyun  *	configured a higher bandwidth than this BSS uses, for example.
566*4882a593Smuzhiyun  * @mu_group: VHT MU-MIMO group membership data
567*4882a593Smuzhiyun  * @ht_operation_mode: HT operation mode like in &struct ieee80211_ht_operation.
568*4882a593Smuzhiyun  *	This field is only valid when the channel is a wide HT/VHT channel.
569*4882a593Smuzhiyun  *	Note that with TDLS this can be the case (channel is HT, protection must
570*4882a593Smuzhiyun  *	be used from this field) even when the BSS association isn't using HT.
571*4882a593Smuzhiyun  * @cqm_rssi_thold: Connection quality monitor RSSI threshold, a zero value
572*4882a593Smuzhiyun  *	implies disabled. As with the cfg80211 callback, a change here should
573*4882a593Smuzhiyun  *	cause an event to be sent indicating where the current value is in
574*4882a593Smuzhiyun  *	relation to the newly configured threshold.
575*4882a593Smuzhiyun  * @cqm_rssi_low: Connection quality monitor RSSI lower threshold, a zero value
576*4882a593Smuzhiyun  *	implies disabled.  This is an alternative mechanism to the single
577*4882a593Smuzhiyun  *	threshold event and can't be enabled simultaneously with it.
578*4882a593Smuzhiyun  * @cqm_rssi_high: Connection quality monitor RSSI upper threshold.
579*4882a593Smuzhiyun  * @cqm_rssi_hyst: Connection quality monitor RSSI hysteresis
580*4882a593Smuzhiyun  * @arp_addr_list: List of IPv4 addresses for hardware ARP filtering. The
581*4882a593Smuzhiyun  *	may filter ARP queries targeted for other addresses than listed here.
582*4882a593Smuzhiyun  *	The driver must allow ARP queries targeted for all address listed here
583*4882a593Smuzhiyun  *	to pass through. An empty list implies no ARP queries need to pass.
584*4882a593Smuzhiyun  * @arp_addr_cnt: Number of addresses currently on the list. Note that this
585*4882a593Smuzhiyun  *	may be larger than %IEEE80211_BSS_ARP_ADDR_LIST_LEN (the arp_addr_list
586*4882a593Smuzhiyun  *	array size), it's up to the driver what to do in that case.
587*4882a593Smuzhiyun  * @qos: This is a QoS-enabled BSS.
588*4882a593Smuzhiyun  * @idle: This interface is idle. There's also a global idle flag in the
589*4882a593Smuzhiyun  *	hardware config which may be more appropriate depending on what
590*4882a593Smuzhiyun  *	your driver/device needs to do.
591*4882a593Smuzhiyun  * @ps: power-save mode (STA only). This flag is NOT affected by
592*4882a593Smuzhiyun  *	offchannel/dynamic_ps operations.
593*4882a593Smuzhiyun  * @ssid: The SSID of the current vif. Valid in AP and IBSS mode.
594*4882a593Smuzhiyun  * @ssid_len: Length of SSID given in @ssid.
595*4882a593Smuzhiyun  * @hidden_ssid: The SSID of the current vif is hidden. Only valid in AP-mode.
596*4882a593Smuzhiyun  * @txpower: TX power in dBm.  INT_MIN means not configured.
597*4882a593Smuzhiyun  * @txpower_type: TX power adjustment used to control per packet Transmit
598*4882a593Smuzhiyun  *	Power Control (TPC) in lower driver for the current vif. In particular
599*4882a593Smuzhiyun  *	TPC is enabled if value passed in %txpower_type is
600*4882a593Smuzhiyun  *	NL80211_TX_POWER_LIMITED (allow using less than specified from
601*4882a593Smuzhiyun  *	userspace), whereas TPC is disabled if %txpower_type is set to
602*4882a593Smuzhiyun  *	NL80211_TX_POWER_FIXED (use value configured from userspace)
603*4882a593Smuzhiyun  * @p2p_noa_attr: P2P NoA attribute for P2P powersave
604*4882a593Smuzhiyun  * @allow_p2p_go_ps: indication for AP or P2P GO interface, whether it's allowed
605*4882a593Smuzhiyun  *	to use P2P PS mechanism or not. AP/P2P GO is not allowed to use P2P PS
606*4882a593Smuzhiyun  *	if it has associated clients without P2P PS support.
607*4882a593Smuzhiyun  * @max_idle_period: the time period during which the station can refrain from
608*4882a593Smuzhiyun  *	transmitting frames to its associated AP without being disassociated.
609*4882a593Smuzhiyun  *	In units of 1000 TUs. Zero value indicates that the AP did not include
610*4882a593Smuzhiyun  *	a (valid) BSS Max Idle Period Element.
611*4882a593Smuzhiyun  * @protected_keep_alive: if set, indicates that the station should send an RSN
612*4882a593Smuzhiyun  *	protected frame to the AP to reset the idle timer at the AP for the
613*4882a593Smuzhiyun  *	station.
614*4882a593Smuzhiyun  * @ftm_responder: whether to enable or disable fine timing measurement FTM
615*4882a593Smuzhiyun  *	responder functionality.
616*4882a593Smuzhiyun  * @ftmr_params: configurable lci/civic parameter when enabling FTM responder.
617*4882a593Smuzhiyun  * @nontransmitted: this BSS is a nontransmitted BSS profile
618*4882a593Smuzhiyun  * @transmitter_bssid: the address of transmitter AP
619*4882a593Smuzhiyun  * @bssid_index: index inside the multiple BSSID set
620*4882a593Smuzhiyun  * @bssid_indicator: 2^bssid_indicator is the maximum number of APs in set
621*4882a593Smuzhiyun  * @ema_ap: AP supports enhancements of discovery and advertisement of
622*4882a593Smuzhiyun  *	nontransmitted BSSIDs
623*4882a593Smuzhiyun  * @profile_periodicity: the least number of beacon frames need to be received
624*4882a593Smuzhiyun  *	in order to discover all the nontransmitted BSSIDs in the set.
625*4882a593Smuzhiyun  * @he_oper: HE operation information of the AP we are connected to
626*4882a593Smuzhiyun  * @he_obss_pd: OBSS Packet Detection parameters.
627*4882a593Smuzhiyun  * @he_bss_color: BSS coloring settings, if BSS supports HE
628*4882a593Smuzhiyun  * @fils_discovery: FILS discovery configuration
629*4882a593Smuzhiyun  * @unsol_bcast_probe_resp_interval: Unsolicited broadcast probe response
630*4882a593Smuzhiyun  *	interval.
631*4882a593Smuzhiyun  * @s1g: BSS is S1G BSS (affects Association Request format).
632*4882a593Smuzhiyun  * @beacon_tx_rate: The configured beacon transmit rate that needs to be passed
633*4882a593Smuzhiyun  *	to driver when rate control is offloaded to firmware.
634*4882a593Smuzhiyun  */
635*4882a593Smuzhiyun struct ieee80211_bss_conf {
636*4882a593Smuzhiyun 	const u8 *bssid;
637*4882a593Smuzhiyun 	u8 htc_trig_based_pkt_ext;
638*4882a593Smuzhiyun 	bool multi_sta_back_32bit;
639*4882a593Smuzhiyun 	bool uora_exists;
640*4882a593Smuzhiyun 	bool ack_enabled;
641*4882a593Smuzhiyun 	u8 uora_ocw_range;
642*4882a593Smuzhiyun 	u16 frame_time_rts_th;
643*4882a593Smuzhiyun 	bool he_support;
644*4882a593Smuzhiyun 	bool twt_requester;
645*4882a593Smuzhiyun 	bool twt_responder;
646*4882a593Smuzhiyun 	bool twt_protected;
647*4882a593Smuzhiyun 	/* association related data */
648*4882a593Smuzhiyun 	bool assoc, ibss_joined;
649*4882a593Smuzhiyun 	bool ibss_creator;
650*4882a593Smuzhiyun 	u16 aid;
651*4882a593Smuzhiyun 	/* erp related data */
652*4882a593Smuzhiyun 	bool use_cts_prot;
653*4882a593Smuzhiyun 	bool use_short_preamble;
654*4882a593Smuzhiyun 	bool use_short_slot;
655*4882a593Smuzhiyun 	bool enable_beacon;
656*4882a593Smuzhiyun 	u8 dtim_period;
657*4882a593Smuzhiyun 	u16 beacon_int;
658*4882a593Smuzhiyun 	u16 assoc_capability;
659*4882a593Smuzhiyun 	u64 sync_tsf;
660*4882a593Smuzhiyun 	u32 sync_device_ts;
661*4882a593Smuzhiyun 	u8 sync_dtim_count;
662*4882a593Smuzhiyun 	u32 basic_rates;
663*4882a593Smuzhiyun 	struct ieee80211_rate *beacon_rate;
664*4882a593Smuzhiyun 	int mcast_rate[NUM_NL80211_BANDS];
665*4882a593Smuzhiyun 	u16 ht_operation_mode;
666*4882a593Smuzhiyun 	s32 cqm_rssi_thold;
667*4882a593Smuzhiyun 	u32 cqm_rssi_hyst;
668*4882a593Smuzhiyun 	s32 cqm_rssi_low;
669*4882a593Smuzhiyun 	s32 cqm_rssi_high;
670*4882a593Smuzhiyun 	struct cfg80211_chan_def chandef;
671*4882a593Smuzhiyun 	struct ieee80211_mu_group_data mu_group;
672*4882a593Smuzhiyun 	__be32 arp_addr_list[IEEE80211_BSS_ARP_ADDR_LIST_LEN];
673*4882a593Smuzhiyun 	int arp_addr_cnt;
674*4882a593Smuzhiyun 	bool qos;
675*4882a593Smuzhiyun 	bool idle;
676*4882a593Smuzhiyun 	bool ps;
677*4882a593Smuzhiyun 	u8 ssid[IEEE80211_MAX_SSID_LEN];
678*4882a593Smuzhiyun 	size_t ssid_len;
679*4882a593Smuzhiyun 	bool hidden_ssid;
680*4882a593Smuzhiyun 	int txpower;
681*4882a593Smuzhiyun 	enum nl80211_tx_power_setting txpower_type;
682*4882a593Smuzhiyun 	struct ieee80211_p2p_noa_attr p2p_noa_attr;
683*4882a593Smuzhiyun 	bool allow_p2p_go_ps;
684*4882a593Smuzhiyun 	u16 max_idle_period;
685*4882a593Smuzhiyun 	bool protected_keep_alive;
686*4882a593Smuzhiyun 	bool ftm_responder;
687*4882a593Smuzhiyun 	struct ieee80211_ftm_responder_params *ftmr_params;
688*4882a593Smuzhiyun 	/* Multiple BSSID data */
689*4882a593Smuzhiyun 	bool nontransmitted;
690*4882a593Smuzhiyun 	u8 transmitter_bssid[ETH_ALEN];
691*4882a593Smuzhiyun 	u8 bssid_index;
692*4882a593Smuzhiyun 	u8 bssid_indicator;
693*4882a593Smuzhiyun 	bool ema_ap;
694*4882a593Smuzhiyun 	u8 profile_periodicity;
695*4882a593Smuzhiyun 	struct {
696*4882a593Smuzhiyun 		u32 params;
697*4882a593Smuzhiyun 		u16 nss_set;
698*4882a593Smuzhiyun 	} he_oper;
699*4882a593Smuzhiyun 	struct ieee80211_he_obss_pd he_obss_pd;
700*4882a593Smuzhiyun 	struct cfg80211_he_bss_color he_bss_color;
701*4882a593Smuzhiyun 	struct ieee80211_fils_discovery fils_discovery;
702*4882a593Smuzhiyun 	u32 unsol_bcast_probe_resp_interval;
703*4882a593Smuzhiyun 	bool s1g;
704*4882a593Smuzhiyun 	struct cfg80211_bitrate_mask beacon_tx_rate;
705*4882a593Smuzhiyun 
706*4882a593Smuzhiyun 	ANDROID_KABI_RESERVE(1);
707*4882a593Smuzhiyun };
708*4882a593Smuzhiyun 
709*4882a593Smuzhiyun /**
710*4882a593Smuzhiyun  * enum mac80211_tx_info_flags - flags to describe transmission information/status
711*4882a593Smuzhiyun  *
712*4882a593Smuzhiyun  * These flags are used with the @flags member of &ieee80211_tx_info.
713*4882a593Smuzhiyun  *
714*4882a593Smuzhiyun  * @IEEE80211_TX_CTL_REQ_TX_STATUS: require TX status callback for this frame.
715*4882a593Smuzhiyun  * @IEEE80211_TX_CTL_ASSIGN_SEQ: The driver has to assign a sequence
716*4882a593Smuzhiyun  *	number to this frame, taking care of not overwriting the fragment
717*4882a593Smuzhiyun  *	number and increasing the sequence number only when the
718*4882a593Smuzhiyun  *	IEEE80211_TX_CTL_FIRST_FRAGMENT flag is set. mac80211 will properly
719*4882a593Smuzhiyun  *	assign sequence numbers to QoS-data frames but cannot do so correctly
720*4882a593Smuzhiyun  *	for non-QoS-data and management frames because beacons need them from
721*4882a593Smuzhiyun  *	that counter as well and mac80211 cannot guarantee proper sequencing.
722*4882a593Smuzhiyun  *	If this flag is set, the driver should instruct the hardware to
723*4882a593Smuzhiyun  *	assign a sequence number to the frame or assign one itself. Cf. IEEE
724*4882a593Smuzhiyun  *	802.11-2007 7.1.3.4.1 paragraph 3. This flag will always be set for
725*4882a593Smuzhiyun  *	beacons and always be clear for frames without a sequence number field.
726*4882a593Smuzhiyun  * @IEEE80211_TX_CTL_NO_ACK: tell the low level not to wait for an ack
727*4882a593Smuzhiyun  * @IEEE80211_TX_CTL_CLEAR_PS_FILT: clear powersave filter for destination
728*4882a593Smuzhiyun  *	station
729*4882a593Smuzhiyun  * @IEEE80211_TX_CTL_FIRST_FRAGMENT: this is a first fragment of the frame
730*4882a593Smuzhiyun  * @IEEE80211_TX_CTL_SEND_AFTER_DTIM: send this frame after DTIM beacon
731*4882a593Smuzhiyun  * @IEEE80211_TX_CTL_AMPDU: this frame should be sent as part of an A-MPDU
732*4882a593Smuzhiyun  * @IEEE80211_TX_CTL_INJECTED: Frame was injected, internal to mac80211.
733*4882a593Smuzhiyun  * @IEEE80211_TX_STAT_TX_FILTERED: The frame was not transmitted
734*4882a593Smuzhiyun  *	because the destination STA was in powersave mode. Note that to
735*4882a593Smuzhiyun  *	avoid race conditions, the filter must be set by the hardware or
736*4882a593Smuzhiyun  *	firmware upon receiving a frame that indicates that the station
737*4882a593Smuzhiyun  *	went to sleep (must be done on device to filter frames already on
738*4882a593Smuzhiyun  *	the queue) and may only be unset after mac80211 gives the OK for
739*4882a593Smuzhiyun  *	that by setting the IEEE80211_TX_CTL_CLEAR_PS_FILT (see above),
740*4882a593Smuzhiyun  *	since only then is it guaranteed that no more frames are in the
741*4882a593Smuzhiyun  *	hardware queue.
742*4882a593Smuzhiyun  * @IEEE80211_TX_STAT_ACK: Frame was acknowledged
743*4882a593Smuzhiyun  * @IEEE80211_TX_STAT_AMPDU: The frame was aggregated, so status
744*4882a593Smuzhiyun  * 	is for the whole aggregation.
745*4882a593Smuzhiyun  * @IEEE80211_TX_STAT_AMPDU_NO_BACK: no block ack was returned,
746*4882a593Smuzhiyun  * 	so consider using block ack request (BAR).
747*4882a593Smuzhiyun  * @IEEE80211_TX_CTL_RATE_CTRL_PROBE: internal to mac80211, can be
748*4882a593Smuzhiyun  *	set by rate control algorithms to indicate probe rate, will
749*4882a593Smuzhiyun  *	be cleared for fragmented frames (except on the last fragment)
750*4882a593Smuzhiyun  * @IEEE80211_TX_INTFL_OFFCHAN_TX_OK: Internal to mac80211. Used to indicate
751*4882a593Smuzhiyun  *	that a frame can be transmitted while the queues are stopped for
752*4882a593Smuzhiyun  *	off-channel operation.
753*4882a593Smuzhiyun  * @IEEE80211_TX_CTL_HW_80211_ENCAP: This frame uses hardware encapsulation
754*4882a593Smuzhiyun  *	(header conversion)
755*4882a593Smuzhiyun  * @IEEE80211_TX_INTFL_RETRIED: completely internal to mac80211,
756*4882a593Smuzhiyun  *	used to indicate that a frame was already retried due to PS
757*4882a593Smuzhiyun  * @IEEE80211_TX_INTFL_DONT_ENCRYPT: completely internal to mac80211,
758*4882a593Smuzhiyun  *	used to indicate frame should not be encrypted
759*4882a593Smuzhiyun  * @IEEE80211_TX_CTL_NO_PS_BUFFER: This frame is a response to a poll
760*4882a593Smuzhiyun  *	frame (PS-Poll or uAPSD) or a non-bufferable MMPDU and must
761*4882a593Smuzhiyun  *	be sent although the station is in powersave mode.
762*4882a593Smuzhiyun  * @IEEE80211_TX_CTL_MORE_FRAMES: More frames will be passed to the
763*4882a593Smuzhiyun  *	transmit function after the current frame, this can be used
764*4882a593Smuzhiyun  *	by drivers to kick the DMA queue only if unset or when the
765*4882a593Smuzhiyun  *	queue gets full.
766*4882a593Smuzhiyun  * @IEEE80211_TX_INTFL_RETRANSMISSION: This frame is being retransmitted
767*4882a593Smuzhiyun  *	after TX status because the destination was asleep, it must not
768*4882a593Smuzhiyun  *	be modified again (no seqno assignment, crypto, etc.)
769*4882a593Smuzhiyun  * @IEEE80211_TX_INTFL_MLME_CONN_TX: This frame was transmitted by the MLME
770*4882a593Smuzhiyun  *	code for connection establishment, this indicates that its status
771*4882a593Smuzhiyun  *	should kick the MLME state machine.
772*4882a593Smuzhiyun  * @IEEE80211_TX_INTFL_NL80211_FRAME_TX: Frame was requested through nl80211
773*4882a593Smuzhiyun  *	MLME command (internal to mac80211 to figure out whether to send TX
774*4882a593Smuzhiyun  *	status to user space)
775*4882a593Smuzhiyun  * @IEEE80211_TX_CTL_LDPC: tells the driver to use LDPC for this frame
776*4882a593Smuzhiyun  * @IEEE80211_TX_CTL_STBC: Enables Space-Time Block Coding (STBC) for this
777*4882a593Smuzhiyun  *	frame and selects the maximum number of streams that it can use.
778*4882a593Smuzhiyun  * @IEEE80211_TX_CTL_TX_OFFCHAN: Marks this packet to be transmitted on
779*4882a593Smuzhiyun  *	the off-channel channel when a remain-on-channel offload is done
780*4882a593Smuzhiyun  *	in hardware -- normal packets still flow and are expected to be
781*4882a593Smuzhiyun  *	handled properly by the device.
782*4882a593Smuzhiyun  * @IEEE80211_TX_INTFL_TKIP_MIC_FAILURE: Marks this packet to be used for TKIP
783*4882a593Smuzhiyun  *	testing. It will be sent out with incorrect Michael MIC key to allow
784*4882a593Smuzhiyun  *	TKIP countermeasures to be tested.
785*4882a593Smuzhiyun  * @IEEE80211_TX_CTL_NO_CCK_RATE: This frame will be sent at non CCK rate.
786*4882a593Smuzhiyun  *	This flag is actually used for management frame especially for P2P
787*4882a593Smuzhiyun  *	frames not being sent at CCK rate in 2GHz band.
788*4882a593Smuzhiyun  * @IEEE80211_TX_STATUS_EOSP: This packet marks the end of service period,
789*4882a593Smuzhiyun  *	when its status is reported the service period ends. For frames in
790*4882a593Smuzhiyun  *	an SP that mac80211 transmits, it is already set; for driver frames
791*4882a593Smuzhiyun  *	the driver may set this flag. It is also used to do the same for
792*4882a593Smuzhiyun  *	PS-Poll responses.
793*4882a593Smuzhiyun  * @IEEE80211_TX_CTL_USE_MINRATE: This frame will be sent at lowest rate.
794*4882a593Smuzhiyun  *	This flag is used to send nullfunc frame at minimum rate when
795*4882a593Smuzhiyun  *	the nullfunc is used for connection monitoring purpose.
796*4882a593Smuzhiyun  * @IEEE80211_TX_CTL_DONTFRAG: Don't fragment this packet even if it
797*4882a593Smuzhiyun  *	would be fragmented by size (this is optional, only used for
798*4882a593Smuzhiyun  *	monitor injection).
799*4882a593Smuzhiyun  * @IEEE80211_TX_STAT_NOACK_TRANSMITTED: A frame that was marked with
800*4882a593Smuzhiyun  *	IEEE80211_TX_CTL_NO_ACK has been successfully transmitted without
801*4882a593Smuzhiyun  *	any errors (like issues specific to the driver/HW).
802*4882a593Smuzhiyun  *	This flag must not be set for frames that don't request no-ack
803*4882a593Smuzhiyun  *	behaviour with IEEE80211_TX_CTL_NO_ACK.
804*4882a593Smuzhiyun  *
805*4882a593Smuzhiyun  * Note: If you have to add new flags to the enumeration, then don't
806*4882a593Smuzhiyun  *	 forget to update %IEEE80211_TX_TEMPORARY_FLAGS when necessary.
807*4882a593Smuzhiyun  */
808*4882a593Smuzhiyun enum mac80211_tx_info_flags {
809*4882a593Smuzhiyun 	IEEE80211_TX_CTL_REQ_TX_STATUS		= BIT(0),
810*4882a593Smuzhiyun 	IEEE80211_TX_CTL_ASSIGN_SEQ		= BIT(1),
811*4882a593Smuzhiyun 	IEEE80211_TX_CTL_NO_ACK			= BIT(2),
812*4882a593Smuzhiyun 	IEEE80211_TX_CTL_CLEAR_PS_FILT		= BIT(3),
813*4882a593Smuzhiyun 	IEEE80211_TX_CTL_FIRST_FRAGMENT		= BIT(4),
814*4882a593Smuzhiyun 	IEEE80211_TX_CTL_SEND_AFTER_DTIM	= BIT(5),
815*4882a593Smuzhiyun 	IEEE80211_TX_CTL_AMPDU			= BIT(6),
816*4882a593Smuzhiyun 	IEEE80211_TX_CTL_INJECTED		= BIT(7),
817*4882a593Smuzhiyun 	IEEE80211_TX_STAT_TX_FILTERED		= BIT(8),
818*4882a593Smuzhiyun 	IEEE80211_TX_STAT_ACK			= BIT(9),
819*4882a593Smuzhiyun 	IEEE80211_TX_STAT_AMPDU			= BIT(10),
820*4882a593Smuzhiyun 	IEEE80211_TX_STAT_AMPDU_NO_BACK		= BIT(11),
821*4882a593Smuzhiyun 	IEEE80211_TX_CTL_RATE_CTRL_PROBE	= BIT(12),
822*4882a593Smuzhiyun 	IEEE80211_TX_INTFL_OFFCHAN_TX_OK	= BIT(13),
823*4882a593Smuzhiyun 	IEEE80211_TX_CTL_HW_80211_ENCAP		= BIT(14),
824*4882a593Smuzhiyun 	IEEE80211_TX_INTFL_RETRIED		= BIT(15),
825*4882a593Smuzhiyun 	IEEE80211_TX_INTFL_DONT_ENCRYPT		= BIT(16),
826*4882a593Smuzhiyun 	IEEE80211_TX_CTL_NO_PS_BUFFER		= BIT(17),
827*4882a593Smuzhiyun 	IEEE80211_TX_CTL_MORE_FRAMES		= BIT(18),
828*4882a593Smuzhiyun 	IEEE80211_TX_INTFL_RETRANSMISSION	= BIT(19),
829*4882a593Smuzhiyun 	IEEE80211_TX_INTFL_MLME_CONN_TX		= BIT(20),
830*4882a593Smuzhiyun 	IEEE80211_TX_INTFL_NL80211_FRAME_TX	= BIT(21),
831*4882a593Smuzhiyun 	IEEE80211_TX_CTL_LDPC			= BIT(22),
832*4882a593Smuzhiyun 	IEEE80211_TX_CTL_STBC			= BIT(23) | BIT(24),
833*4882a593Smuzhiyun 	IEEE80211_TX_CTL_TX_OFFCHAN		= BIT(25),
834*4882a593Smuzhiyun 	IEEE80211_TX_INTFL_TKIP_MIC_FAILURE	= BIT(26),
835*4882a593Smuzhiyun 	IEEE80211_TX_CTL_NO_CCK_RATE		= BIT(27),
836*4882a593Smuzhiyun 	IEEE80211_TX_STATUS_EOSP		= BIT(28),
837*4882a593Smuzhiyun 	IEEE80211_TX_CTL_USE_MINRATE		= BIT(29),
838*4882a593Smuzhiyun 	IEEE80211_TX_CTL_DONTFRAG		= BIT(30),
839*4882a593Smuzhiyun 	IEEE80211_TX_STAT_NOACK_TRANSMITTED	= BIT(31),
840*4882a593Smuzhiyun };
841*4882a593Smuzhiyun 
842*4882a593Smuzhiyun #define IEEE80211_TX_CTL_STBC_SHIFT		23
843*4882a593Smuzhiyun 
844*4882a593Smuzhiyun #define IEEE80211_TX_RC_S1G_MCS IEEE80211_TX_RC_VHT_MCS
845*4882a593Smuzhiyun 
846*4882a593Smuzhiyun /**
847*4882a593Smuzhiyun  * enum mac80211_tx_control_flags - flags to describe transmit control
848*4882a593Smuzhiyun  *
849*4882a593Smuzhiyun  * @IEEE80211_TX_CTRL_PORT_CTRL_PROTO: this frame is a port control
850*4882a593Smuzhiyun  *	protocol frame (e.g. EAP)
851*4882a593Smuzhiyun  * @IEEE80211_TX_CTRL_PS_RESPONSE: This frame is a response to a poll
852*4882a593Smuzhiyun  *	frame (PS-Poll or uAPSD).
853*4882a593Smuzhiyun  * @IEEE80211_TX_CTRL_RATE_INJECT: This frame is injected with rate information
854*4882a593Smuzhiyun  * @IEEE80211_TX_CTRL_AMSDU: This frame is an A-MSDU frame
855*4882a593Smuzhiyun  * @IEEE80211_TX_CTRL_FAST_XMIT: This frame is going through the fast_xmit path
856*4882a593Smuzhiyun  * @IEEE80211_TX_CTRL_SKIP_MPATH_LOOKUP: This frame skips mesh path lookup
857*4882a593Smuzhiyun  * @IEEE80211_TX_INTCFL_NEED_TXPROCESSING: completely internal to mac80211,
858*4882a593Smuzhiyun  *	used to indicate that a pending frame requires TX processing before
859*4882a593Smuzhiyun  *	it can be sent out.
860*4882a593Smuzhiyun  * @IEEE80211_TX_CTRL_NO_SEQNO: Do not overwrite the sequence number that
861*4882a593Smuzhiyun  *	has already been assigned to this frame.
862*4882a593Smuzhiyun  *
863*4882a593Smuzhiyun  * These flags are used in tx_info->control.flags.
864*4882a593Smuzhiyun  */
865*4882a593Smuzhiyun enum mac80211_tx_control_flags {
866*4882a593Smuzhiyun 	IEEE80211_TX_CTRL_PORT_CTRL_PROTO	= BIT(0),
867*4882a593Smuzhiyun 	IEEE80211_TX_CTRL_PS_RESPONSE		= BIT(1),
868*4882a593Smuzhiyun 	IEEE80211_TX_CTRL_RATE_INJECT		= BIT(2),
869*4882a593Smuzhiyun 	IEEE80211_TX_CTRL_AMSDU			= BIT(3),
870*4882a593Smuzhiyun 	IEEE80211_TX_CTRL_FAST_XMIT		= BIT(4),
871*4882a593Smuzhiyun 	IEEE80211_TX_CTRL_SKIP_MPATH_LOOKUP	= BIT(5),
872*4882a593Smuzhiyun 	IEEE80211_TX_INTCFL_NEED_TXPROCESSING	= BIT(6),
873*4882a593Smuzhiyun 	IEEE80211_TX_CTRL_NO_SEQNO		= BIT(7),
874*4882a593Smuzhiyun };
875*4882a593Smuzhiyun 
876*4882a593Smuzhiyun /*
877*4882a593Smuzhiyun  * This definition is used as a mask to clear all temporary flags, which are
878*4882a593Smuzhiyun  * set by the tx handlers for each transmission attempt by the mac80211 stack.
879*4882a593Smuzhiyun  */
880*4882a593Smuzhiyun #define IEEE80211_TX_TEMPORARY_FLAGS (IEEE80211_TX_CTL_NO_ACK |		      \
881*4882a593Smuzhiyun 	IEEE80211_TX_CTL_CLEAR_PS_FILT | IEEE80211_TX_CTL_FIRST_FRAGMENT |    \
882*4882a593Smuzhiyun 	IEEE80211_TX_CTL_SEND_AFTER_DTIM | IEEE80211_TX_CTL_AMPDU |	      \
883*4882a593Smuzhiyun 	IEEE80211_TX_STAT_TX_FILTERED |	IEEE80211_TX_STAT_ACK |		      \
884*4882a593Smuzhiyun 	IEEE80211_TX_STAT_AMPDU | IEEE80211_TX_STAT_AMPDU_NO_BACK |	      \
885*4882a593Smuzhiyun 	IEEE80211_TX_CTL_RATE_CTRL_PROBE | IEEE80211_TX_CTL_NO_PS_BUFFER |    \
886*4882a593Smuzhiyun 	IEEE80211_TX_CTL_MORE_FRAMES | IEEE80211_TX_CTL_LDPC |		      \
887*4882a593Smuzhiyun 	IEEE80211_TX_CTL_STBC | IEEE80211_TX_STATUS_EOSP)
888*4882a593Smuzhiyun 
889*4882a593Smuzhiyun /**
890*4882a593Smuzhiyun  * enum mac80211_rate_control_flags - per-rate flags set by the
891*4882a593Smuzhiyun  *	Rate Control algorithm.
892*4882a593Smuzhiyun  *
893*4882a593Smuzhiyun  * These flags are set by the Rate control algorithm for each rate during tx,
894*4882a593Smuzhiyun  * in the @flags member of struct ieee80211_tx_rate.
895*4882a593Smuzhiyun  *
896*4882a593Smuzhiyun  * @IEEE80211_TX_RC_USE_RTS_CTS: Use RTS/CTS exchange for this rate.
897*4882a593Smuzhiyun  * @IEEE80211_TX_RC_USE_CTS_PROTECT: CTS-to-self protection is required.
898*4882a593Smuzhiyun  *	This is set if the current BSS requires ERP protection.
899*4882a593Smuzhiyun  * @IEEE80211_TX_RC_USE_SHORT_PREAMBLE: Use short preamble.
900*4882a593Smuzhiyun  * @IEEE80211_TX_RC_MCS: HT rate.
901*4882a593Smuzhiyun  * @IEEE80211_TX_RC_VHT_MCS: VHT MCS rate, in this case the idx field is split
902*4882a593Smuzhiyun  *	into a higher 4 bits (Nss) and lower 4 bits (MCS number)
903*4882a593Smuzhiyun  * @IEEE80211_TX_RC_GREEN_FIELD: Indicates whether this rate should be used in
904*4882a593Smuzhiyun  *	Greenfield mode.
905*4882a593Smuzhiyun  * @IEEE80211_TX_RC_40_MHZ_WIDTH: Indicates if the Channel Width should be 40 MHz.
906*4882a593Smuzhiyun  * @IEEE80211_TX_RC_80_MHZ_WIDTH: Indicates 80 MHz transmission
907*4882a593Smuzhiyun  * @IEEE80211_TX_RC_160_MHZ_WIDTH: Indicates 160 MHz transmission
908*4882a593Smuzhiyun  *	(80+80 isn't supported yet)
909*4882a593Smuzhiyun  * @IEEE80211_TX_RC_DUP_DATA: The frame should be transmitted on both of the
910*4882a593Smuzhiyun  *	adjacent 20 MHz channels, if the current channel type is
911*4882a593Smuzhiyun  *	NL80211_CHAN_HT40MINUS or NL80211_CHAN_HT40PLUS.
912*4882a593Smuzhiyun  * @IEEE80211_TX_RC_SHORT_GI: Short Guard interval should be used for this rate.
913*4882a593Smuzhiyun  */
914*4882a593Smuzhiyun enum mac80211_rate_control_flags {
915*4882a593Smuzhiyun 	IEEE80211_TX_RC_USE_RTS_CTS		= BIT(0),
916*4882a593Smuzhiyun 	IEEE80211_TX_RC_USE_CTS_PROTECT		= BIT(1),
917*4882a593Smuzhiyun 	IEEE80211_TX_RC_USE_SHORT_PREAMBLE	= BIT(2),
918*4882a593Smuzhiyun 
919*4882a593Smuzhiyun 	/* rate index is an HT/VHT MCS instead of an index */
920*4882a593Smuzhiyun 	IEEE80211_TX_RC_MCS			= BIT(3),
921*4882a593Smuzhiyun 	IEEE80211_TX_RC_GREEN_FIELD		= BIT(4),
922*4882a593Smuzhiyun 	IEEE80211_TX_RC_40_MHZ_WIDTH		= BIT(5),
923*4882a593Smuzhiyun 	IEEE80211_TX_RC_DUP_DATA		= BIT(6),
924*4882a593Smuzhiyun 	IEEE80211_TX_RC_SHORT_GI		= BIT(7),
925*4882a593Smuzhiyun 	IEEE80211_TX_RC_VHT_MCS			= BIT(8),
926*4882a593Smuzhiyun 	IEEE80211_TX_RC_80_MHZ_WIDTH		= BIT(9),
927*4882a593Smuzhiyun 	IEEE80211_TX_RC_160_MHZ_WIDTH		= BIT(10),
928*4882a593Smuzhiyun };
929*4882a593Smuzhiyun 
930*4882a593Smuzhiyun 
931*4882a593Smuzhiyun /* there are 40 bytes if you don't need the rateset to be kept */
932*4882a593Smuzhiyun #define IEEE80211_TX_INFO_DRIVER_DATA_SIZE 40
933*4882a593Smuzhiyun 
934*4882a593Smuzhiyun /* if you do need the rateset, then you have less space */
935*4882a593Smuzhiyun #define IEEE80211_TX_INFO_RATE_DRIVER_DATA_SIZE 24
936*4882a593Smuzhiyun 
937*4882a593Smuzhiyun /* maximum number of rate stages */
938*4882a593Smuzhiyun #define IEEE80211_TX_MAX_RATES	4
939*4882a593Smuzhiyun 
940*4882a593Smuzhiyun /* maximum number of rate table entries */
941*4882a593Smuzhiyun #define IEEE80211_TX_RATE_TABLE_SIZE	4
942*4882a593Smuzhiyun 
943*4882a593Smuzhiyun /**
944*4882a593Smuzhiyun  * struct ieee80211_tx_rate - rate selection/status
945*4882a593Smuzhiyun  *
946*4882a593Smuzhiyun  * @idx: rate index to attempt to send with
947*4882a593Smuzhiyun  * @flags: rate control flags (&enum mac80211_rate_control_flags)
948*4882a593Smuzhiyun  * @count: number of tries in this rate before going to the next rate
949*4882a593Smuzhiyun  *
950*4882a593Smuzhiyun  * A value of -1 for @idx indicates an invalid rate and, if used
951*4882a593Smuzhiyun  * in an array of retry rates, that no more rates should be tried.
952*4882a593Smuzhiyun  *
953*4882a593Smuzhiyun  * When used for transmit status reporting, the driver should
954*4882a593Smuzhiyun  * always report the rate along with the flags it used.
955*4882a593Smuzhiyun  *
956*4882a593Smuzhiyun  * &struct ieee80211_tx_info contains an array of these structs
957*4882a593Smuzhiyun  * in the control information, and it will be filled by the rate
958*4882a593Smuzhiyun  * control algorithm according to what should be sent. For example,
959*4882a593Smuzhiyun  * if this array contains, in the format { <idx>, <count> } the
960*4882a593Smuzhiyun  * information::
961*4882a593Smuzhiyun  *
962*4882a593Smuzhiyun  *    { 3, 2 }, { 2, 2 }, { 1, 4 }, { -1, 0 }, { -1, 0 }
963*4882a593Smuzhiyun  *
964*4882a593Smuzhiyun  * then this means that the frame should be transmitted
965*4882a593Smuzhiyun  * up to twice at rate 3, up to twice at rate 2, and up to four
966*4882a593Smuzhiyun  * times at rate 1 if it doesn't get acknowledged. Say it gets
967*4882a593Smuzhiyun  * acknowledged by the peer after the fifth attempt, the status
968*4882a593Smuzhiyun  * information should then contain::
969*4882a593Smuzhiyun  *
970*4882a593Smuzhiyun  *   { 3, 2 }, { 2, 2 }, { 1, 1 }, { -1, 0 } ...
971*4882a593Smuzhiyun  *
972*4882a593Smuzhiyun  * since it was transmitted twice at rate 3, twice at rate 2
973*4882a593Smuzhiyun  * and once at rate 1 after which we received an acknowledgement.
974*4882a593Smuzhiyun  */
975*4882a593Smuzhiyun struct ieee80211_tx_rate {
976*4882a593Smuzhiyun 	s8 idx;
977*4882a593Smuzhiyun 	u16 count:5,
978*4882a593Smuzhiyun 	    flags:11;
979*4882a593Smuzhiyun } __packed;
980*4882a593Smuzhiyun 
981*4882a593Smuzhiyun #define IEEE80211_MAX_TX_RETRY		31
982*4882a593Smuzhiyun 
ieee80211_rate_set_vht(struct ieee80211_tx_rate * rate,u8 mcs,u8 nss)983*4882a593Smuzhiyun static inline void ieee80211_rate_set_vht(struct ieee80211_tx_rate *rate,
984*4882a593Smuzhiyun 					  u8 mcs, u8 nss)
985*4882a593Smuzhiyun {
986*4882a593Smuzhiyun 	WARN_ON(mcs & ~0xF);
987*4882a593Smuzhiyun 	WARN_ON((nss - 1) & ~0x7);
988*4882a593Smuzhiyun 	rate->idx = ((nss - 1) << 4) | mcs;
989*4882a593Smuzhiyun }
990*4882a593Smuzhiyun 
991*4882a593Smuzhiyun static inline u8
ieee80211_rate_get_vht_mcs(const struct ieee80211_tx_rate * rate)992*4882a593Smuzhiyun ieee80211_rate_get_vht_mcs(const struct ieee80211_tx_rate *rate)
993*4882a593Smuzhiyun {
994*4882a593Smuzhiyun 	return rate->idx & 0xF;
995*4882a593Smuzhiyun }
996*4882a593Smuzhiyun 
997*4882a593Smuzhiyun static inline u8
ieee80211_rate_get_vht_nss(const struct ieee80211_tx_rate * rate)998*4882a593Smuzhiyun ieee80211_rate_get_vht_nss(const struct ieee80211_tx_rate *rate)
999*4882a593Smuzhiyun {
1000*4882a593Smuzhiyun 	return (rate->idx >> 4) + 1;
1001*4882a593Smuzhiyun }
1002*4882a593Smuzhiyun 
1003*4882a593Smuzhiyun /**
1004*4882a593Smuzhiyun  * struct ieee80211_tx_info - skb transmit information
1005*4882a593Smuzhiyun  *
1006*4882a593Smuzhiyun  * This structure is placed in skb->cb for three uses:
1007*4882a593Smuzhiyun  *  (1) mac80211 TX control - mac80211 tells the driver what to do
1008*4882a593Smuzhiyun  *  (2) driver internal use (if applicable)
1009*4882a593Smuzhiyun  *  (3) TX status information - driver tells mac80211 what happened
1010*4882a593Smuzhiyun  *
1011*4882a593Smuzhiyun  * @flags: transmit info flags, defined above
1012*4882a593Smuzhiyun  * @band: the band to transmit on (use for checking for races)
1013*4882a593Smuzhiyun  * @hw_queue: HW queue to put the frame on, skb_get_queue_mapping() gives the AC
1014*4882a593Smuzhiyun  * @ack_frame_id: internal frame ID for TX status, used internally
1015*4882a593Smuzhiyun  * @tx_time_est: TX time estimate in units of 4us, used internally
1016*4882a593Smuzhiyun  * @control: union part for control data
1017*4882a593Smuzhiyun  * @control.rates: TX rates array to try
1018*4882a593Smuzhiyun  * @control.rts_cts_rate_idx: rate for RTS or CTS
1019*4882a593Smuzhiyun  * @control.use_rts: use RTS
1020*4882a593Smuzhiyun  * @control.use_cts_prot: use RTS/CTS
1021*4882a593Smuzhiyun  * @control.short_preamble: use short preamble (CCK only)
1022*4882a593Smuzhiyun  * @control.skip_table: skip externally configured rate table
1023*4882a593Smuzhiyun  * @control.jiffies: timestamp for expiry on powersave clients
1024*4882a593Smuzhiyun  * @control.vif: virtual interface (may be NULL)
1025*4882a593Smuzhiyun  * @control.hw_key: key to encrypt with (may be NULL)
1026*4882a593Smuzhiyun  * @control.flags: control flags, see &enum mac80211_tx_control_flags
1027*4882a593Smuzhiyun  * @control.enqueue_time: enqueue time (for iTXQs)
1028*4882a593Smuzhiyun  * @driver_rates: alias to @control.rates to reserve space
1029*4882a593Smuzhiyun  * @pad: padding
1030*4882a593Smuzhiyun  * @rate_driver_data: driver use area if driver needs @control.rates
1031*4882a593Smuzhiyun  * @status: union part for status data
1032*4882a593Smuzhiyun  * @status.rates: attempted rates
1033*4882a593Smuzhiyun  * @status.ack_signal: ACK signal
1034*4882a593Smuzhiyun  * @status.ampdu_ack_len: AMPDU ack length
1035*4882a593Smuzhiyun  * @status.ampdu_len: AMPDU length
1036*4882a593Smuzhiyun  * @status.antenna: (legacy, kept only for iwlegacy)
1037*4882a593Smuzhiyun  * @status.tx_time: airtime consumed for transmission; note this is only
1038*4882a593Smuzhiyun  *	used for WMM AC, not for airtime fairness
1039*4882a593Smuzhiyun  * @status.is_valid_ack_signal: ACK signal is valid
1040*4882a593Smuzhiyun  * @status.status_driver_data: driver use area
1041*4882a593Smuzhiyun  * @ack: union part for pure ACK data
1042*4882a593Smuzhiyun  * @ack.cookie: cookie for the ACK
1043*4882a593Smuzhiyun  * @driver_data: array of driver_data pointers
1044*4882a593Smuzhiyun  * @ampdu_ack_len: number of acked aggregated frames.
1045*4882a593Smuzhiyun  * 	relevant only if IEEE80211_TX_STAT_AMPDU was set.
1046*4882a593Smuzhiyun  * @ampdu_len: number of aggregated frames.
1047*4882a593Smuzhiyun  * 	relevant only if IEEE80211_TX_STAT_AMPDU was set.
1048*4882a593Smuzhiyun  * @ack_signal: signal strength of the ACK frame
1049*4882a593Smuzhiyun  */
1050*4882a593Smuzhiyun struct ieee80211_tx_info {
1051*4882a593Smuzhiyun 	/* common information */
1052*4882a593Smuzhiyun 	u32 flags;
1053*4882a593Smuzhiyun 	u32 band:3,
1054*4882a593Smuzhiyun 	    ack_frame_id:13,
1055*4882a593Smuzhiyun 	    hw_queue:4,
1056*4882a593Smuzhiyun 	    tx_time_est:10;
1057*4882a593Smuzhiyun 	/* 2 free bits */
1058*4882a593Smuzhiyun 
1059*4882a593Smuzhiyun 	union {
1060*4882a593Smuzhiyun 		struct {
1061*4882a593Smuzhiyun 			union {
1062*4882a593Smuzhiyun 				/* rate control */
1063*4882a593Smuzhiyun 				struct {
1064*4882a593Smuzhiyun 					struct ieee80211_tx_rate rates[
1065*4882a593Smuzhiyun 						IEEE80211_TX_MAX_RATES];
1066*4882a593Smuzhiyun 					s8 rts_cts_rate_idx;
1067*4882a593Smuzhiyun 					u8 use_rts:1;
1068*4882a593Smuzhiyun 					u8 use_cts_prot:1;
1069*4882a593Smuzhiyun 					u8 short_preamble:1;
1070*4882a593Smuzhiyun 					u8 skip_table:1;
1071*4882a593Smuzhiyun 					/* 2 bytes free */
1072*4882a593Smuzhiyun 				};
1073*4882a593Smuzhiyun 				/* only needed before rate control */
1074*4882a593Smuzhiyun 				unsigned long jiffies;
1075*4882a593Smuzhiyun 			};
1076*4882a593Smuzhiyun 			/* NB: vif can be NULL for injected frames */
1077*4882a593Smuzhiyun 			struct ieee80211_vif *vif;
1078*4882a593Smuzhiyun 			struct ieee80211_key_conf *hw_key;
1079*4882a593Smuzhiyun 			u32 flags;
1080*4882a593Smuzhiyun 			codel_time_t enqueue_time;
1081*4882a593Smuzhiyun 		} control;
1082*4882a593Smuzhiyun 		struct {
1083*4882a593Smuzhiyun 			u64 cookie;
1084*4882a593Smuzhiyun 		} ack;
1085*4882a593Smuzhiyun 		struct {
1086*4882a593Smuzhiyun 			struct ieee80211_tx_rate rates[IEEE80211_TX_MAX_RATES];
1087*4882a593Smuzhiyun 			s32 ack_signal;
1088*4882a593Smuzhiyun 			u8 ampdu_ack_len;
1089*4882a593Smuzhiyun 			u8 ampdu_len;
1090*4882a593Smuzhiyun 			u8 antenna;
1091*4882a593Smuzhiyun 			u16 tx_time;
1092*4882a593Smuzhiyun 			bool is_valid_ack_signal;
1093*4882a593Smuzhiyun 			void *status_driver_data[19 / sizeof(void *)];
1094*4882a593Smuzhiyun 		} status;
1095*4882a593Smuzhiyun 		struct {
1096*4882a593Smuzhiyun 			struct ieee80211_tx_rate driver_rates[
1097*4882a593Smuzhiyun 				IEEE80211_TX_MAX_RATES];
1098*4882a593Smuzhiyun 			u8 pad[4];
1099*4882a593Smuzhiyun 
1100*4882a593Smuzhiyun 			void *rate_driver_data[
1101*4882a593Smuzhiyun 				IEEE80211_TX_INFO_RATE_DRIVER_DATA_SIZE / sizeof(void *)];
1102*4882a593Smuzhiyun 		};
1103*4882a593Smuzhiyun 
1104*4882a593Smuzhiyun 		ANDROID_KABI_RESERVE(1);
1105*4882a593Smuzhiyun 
1106*4882a593Smuzhiyun 		void *driver_data[
1107*4882a593Smuzhiyun 			IEEE80211_TX_INFO_DRIVER_DATA_SIZE / sizeof(void *)];
1108*4882a593Smuzhiyun 	};
1109*4882a593Smuzhiyun };
1110*4882a593Smuzhiyun 
1111*4882a593Smuzhiyun static inline u16
ieee80211_info_set_tx_time_est(struct ieee80211_tx_info * info,u16 tx_time_est)1112*4882a593Smuzhiyun ieee80211_info_set_tx_time_est(struct ieee80211_tx_info *info, u16 tx_time_est)
1113*4882a593Smuzhiyun {
1114*4882a593Smuzhiyun 	/* We only have 10 bits in tx_time_est, so store airtime
1115*4882a593Smuzhiyun 	 * in increments of 4us and clamp the maximum to 2**12-1
1116*4882a593Smuzhiyun 	 */
1117*4882a593Smuzhiyun 	info->tx_time_est = min_t(u16, tx_time_est, 4095) >> 2;
1118*4882a593Smuzhiyun 	return info->tx_time_est << 2;
1119*4882a593Smuzhiyun }
1120*4882a593Smuzhiyun 
1121*4882a593Smuzhiyun static inline u16
ieee80211_info_get_tx_time_est(struct ieee80211_tx_info * info)1122*4882a593Smuzhiyun ieee80211_info_get_tx_time_est(struct ieee80211_tx_info *info)
1123*4882a593Smuzhiyun {
1124*4882a593Smuzhiyun 	return info->tx_time_est << 2;
1125*4882a593Smuzhiyun }
1126*4882a593Smuzhiyun 
1127*4882a593Smuzhiyun /**
1128*4882a593Smuzhiyun  * struct ieee80211_tx_status - extended tx status info for rate control
1129*4882a593Smuzhiyun  *
1130*4882a593Smuzhiyun  * @sta: Station that the packet was transmitted for
1131*4882a593Smuzhiyun  * @info: Basic tx status information
1132*4882a593Smuzhiyun  * @skb: Packet skb (can be NULL if not provided by the driver)
1133*4882a593Smuzhiyun  * @rate: The TX rate that was used when sending the packet
1134*4882a593Smuzhiyun  * @free_list: list where processed skbs are stored to be free'd by the driver
1135*4882a593Smuzhiyun  */
1136*4882a593Smuzhiyun struct ieee80211_tx_status {
1137*4882a593Smuzhiyun 	struct ieee80211_sta *sta;
1138*4882a593Smuzhiyun 	struct ieee80211_tx_info *info;
1139*4882a593Smuzhiyun 	struct sk_buff *skb;
1140*4882a593Smuzhiyun 	struct rate_info *rate;
1141*4882a593Smuzhiyun 	struct list_head *free_list;
1142*4882a593Smuzhiyun };
1143*4882a593Smuzhiyun 
1144*4882a593Smuzhiyun /**
1145*4882a593Smuzhiyun  * struct ieee80211_scan_ies - descriptors for different blocks of IEs
1146*4882a593Smuzhiyun  *
1147*4882a593Smuzhiyun  * This structure is used to point to different blocks of IEs in HW scan
1148*4882a593Smuzhiyun  * and scheduled scan. These blocks contain the IEs passed by userspace
1149*4882a593Smuzhiyun  * and the ones generated by mac80211.
1150*4882a593Smuzhiyun  *
1151*4882a593Smuzhiyun  * @ies: pointers to band specific IEs.
1152*4882a593Smuzhiyun  * @len: lengths of band_specific IEs.
1153*4882a593Smuzhiyun  * @common_ies: IEs for all bands (especially vendor specific ones)
1154*4882a593Smuzhiyun  * @common_ie_len: length of the common_ies
1155*4882a593Smuzhiyun  */
1156*4882a593Smuzhiyun struct ieee80211_scan_ies {
1157*4882a593Smuzhiyun 	const u8 *ies[NUM_NL80211_BANDS];
1158*4882a593Smuzhiyun 	size_t len[NUM_NL80211_BANDS];
1159*4882a593Smuzhiyun 	const u8 *common_ies;
1160*4882a593Smuzhiyun 	size_t common_ie_len;
1161*4882a593Smuzhiyun };
1162*4882a593Smuzhiyun 
1163*4882a593Smuzhiyun 
IEEE80211_SKB_CB(struct sk_buff * skb)1164*4882a593Smuzhiyun static inline struct ieee80211_tx_info *IEEE80211_SKB_CB(struct sk_buff *skb)
1165*4882a593Smuzhiyun {
1166*4882a593Smuzhiyun 	return (struct ieee80211_tx_info *)skb->cb;
1167*4882a593Smuzhiyun }
1168*4882a593Smuzhiyun 
IEEE80211_SKB_RXCB(struct sk_buff * skb)1169*4882a593Smuzhiyun static inline struct ieee80211_rx_status *IEEE80211_SKB_RXCB(struct sk_buff *skb)
1170*4882a593Smuzhiyun {
1171*4882a593Smuzhiyun 	return (struct ieee80211_rx_status *)skb->cb;
1172*4882a593Smuzhiyun }
1173*4882a593Smuzhiyun 
1174*4882a593Smuzhiyun /**
1175*4882a593Smuzhiyun  * ieee80211_tx_info_clear_status - clear TX status
1176*4882a593Smuzhiyun  *
1177*4882a593Smuzhiyun  * @info: The &struct ieee80211_tx_info to be cleared.
1178*4882a593Smuzhiyun  *
1179*4882a593Smuzhiyun  * When the driver passes an skb back to mac80211, it must report
1180*4882a593Smuzhiyun  * a number of things in TX status. This function clears everything
1181*4882a593Smuzhiyun  * in the TX status but the rate control information (it does clear
1182*4882a593Smuzhiyun  * the count since you need to fill that in anyway).
1183*4882a593Smuzhiyun  *
1184*4882a593Smuzhiyun  * NOTE: You can only use this function if you do NOT use
1185*4882a593Smuzhiyun  *	 info->driver_data! Use info->rate_driver_data
1186*4882a593Smuzhiyun  *	 instead if you need only the less space that allows.
1187*4882a593Smuzhiyun  */
1188*4882a593Smuzhiyun static inline void
ieee80211_tx_info_clear_status(struct ieee80211_tx_info * info)1189*4882a593Smuzhiyun ieee80211_tx_info_clear_status(struct ieee80211_tx_info *info)
1190*4882a593Smuzhiyun {
1191*4882a593Smuzhiyun 	int i;
1192*4882a593Smuzhiyun 
1193*4882a593Smuzhiyun 	BUILD_BUG_ON(offsetof(struct ieee80211_tx_info, status.rates) !=
1194*4882a593Smuzhiyun 		     offsetof(struct ieee80211_tx_info, control.rates));
1195*4882a593Smuzhiyun 	BUILD_BUG_ON(offsetof(struct ieee80211_tx_info, status.rates) !=
1196*4882a593Smuzhiyun 		     offsetof(struct ieee80211_tx_info, driver_rates));
1197*4882a593Smuzhiyun 	BUILD_BUG_ON(offsetof(struct ieee80211_tx_info, status.rates) != 8);
1198*4882a593Smuzhiyun 	/* clear the rate counts */
1199*4882a593Smuzhiyun 	for (i = 0; i < IEEE80211_TX_MAX_RATES; i++)
1200*4882a593Smuzhiyun 		info->status.rates[i].count = 0;
1201*4882a593Smuzhiyun 
1202*4882a593Smuzhiyun 	BUILD_BUG_ON(
1203*4882a593Smuzhiyun 	    offsetof(struct ieee80211_tx_info, status.ack_signal) != 20);
1204*4882a593Smuzhiyun 	memset(&info->status.ampdu_ack_len, 0,
1205*4882a593Smuzhiyun 	       sizeof(struct ieee80211_tx_info) -
1206*4882a593Smuzhiyun 	       offsetof(struct ieee80211_tx_info, status.ampdu_ack_len));
1207*4882a593Smuzhiyun }
1208*4882a593Smuzhiyun 
1209*4882a593Smuzhiyun 
1210*4882a593Smuzhiyun /**
1211*4882a593Smuzhiyun  * enum mac80211_rx_flags - receive flags
1212*4882a593Smuzhiyun  *
1213*4882a593Smuzhiyun  * These flags are used with the @flag member of &struct ieee80211_rx_status.
1214*4882a593Smuzhiyun  * @RX_FLAG_MMIC_ERROR: Michael MIC error was reported on this frame.
1215*4882a593Smuzhiyun  *	Use together with %RX_FLAG_MMIC_STRIPPED.
1216*4882a593Smuzhiyun  * @RX_FLAG_DECRYPTED: This frame was decrypted in hardware.
1217*4882a593Smuzhiyun  * @RX_FLAG_MMIC_STRIPPED: the Michael MIC is stripped off this frame,
1218*4882a593Smuzhiyun  *	verification has been done by the hardware.
1219*4882a593Smuzhiyun  * @RX_FLAG_IV_STRIPPED: The IV and ICV are stripped from this frame.
1220*4882a593Smuzhiyun  *	If this flag is set, the stack cannot do any replay detection
1221*4882a593Smuzhiyun  *	hence the driver or hardware will have to do that.
1222*4882a593Smuzhiyun  * @RX_FLAG_PN_VALIDATED: Currently only valid for CCMP/GCMP frames, this
1223*4882a593Smuzhiyun  *	flag indicates that the PN was verified for replay protection.
1224*4882a593Smuzhiyun  *	Note that this flag is also currently only supported when a frame
1225*4882a593Smuzhiyun  *	is also decrypted (ie. @RX_FLAG_DECRYPTED must be set)
1226*4882a593Smuzhiyun  * @RX_FLAG_DUP_VALIDATED: The driver should set this flag if it did
1227*4882a593Smuzhiyun  *	de-duplication by itself.
1228*4882a593Smuzhiyun  * @RX_FLAG_FAILED_FCS_CRC: Set this flag if the FCS check failed on
1229*4882a593Smuzhiyun  *	the frame.
1230*4882a593Smuzhiyun  * @RX_FLAG_FAILED_PLCP_CRC: Set this flag if the PCLP check failed on
1231*4882a593Smuzhiyun  *	the frame.
1232*4882a593Smuzhiyun  * @RX_FLAG_MACTIME_START: The timestamp passed in the RX status (@mactime
1233*4882a593Smuzhiyun  *	field) is valid and contains the time the first symbol of the MPDU
1234*4882a593Smuzhiyun  *	was received. This is useful in monitor mode and for proper IBSS
1235*4882a593Smuzhiyun  *	merging.
1236*4882a593Smuzhiyun  * @RX_FLAG_MACTIME_END: The timestamp passed in the RX status (@mactime
1237*4882a593Smuzhiyun  *	field) is valid and contains the time the last symbol of the MPDU
1238*4882a593Smuzhiyun  *	(including FCS) was received.
1239*4882a593Smuzhiyun  * @RX_FLAG_MACTIME_PLCP_START: The timestamp passed in the RX status (@mactime
1240*4882a593Smuzhiyun  *	field) is valid and contains the time the SYNC preamble was received.
1241*4882a593Smuzhiyun  * @RX_FLAG_NO_SIGNAL_VAL: The signal strength value is not present.
1242*4882a593Smuzhiyun  *	Valid only for data frames (mainly A-MPDU)
1243*4882a593Smuzhiyun  * @RX_FLAG_AMPDU_DETAILS: A-MPDU details are known, in particular the reference
1244*4882a593Smuzhiyun  *	number (@ampdu_reference) must be populated and be a distinct number for
1245*4882a593Smuzhiyun  *	each A-MPDU
1246*4882a593Smuzhiyun  * @RX_FLAG_AMPDU_LAST_KNOWN: last subframe is known, should be set on all
1247*4882a593Smuzhiyun  *	subframes of a single A-MPDU
1248*4882a593Smuzhiyun  * @RX_FLAG_AMPDU_IS_LAST: this subframe is the last subframe of the A-MPDU
1249*4882a593Smuzhiyun  * @RX_FLAG_AMPDU_DELIM_CRC_ERROR: A delimiter CRC error has been detected
1250*4882a593Smuzhiyun  *	on this subframe
1251*4882a593Smuzhiyun  * @RX_FLAG_AMPDU_DELIM_CRC_KNOWN: The delimiter CRC field is known (the CRC
1252*4882a593Smuzhiyun  *	is stored in the @ampdu_delimiter_crc field)
1253*4882a593Smuzhiyun  * @RX_FLAG_MIC_STRIPPED: The mic was stripped of this packet. Decryption was
1254*4882a593Smuzhiyun  *	done by the hardware
1255*4882a593Smuzhiyun  * @RX_FLAG_ONLY_MONITOR: Report frame only to monitor interfaces without
1256*4882a593Smuzhiyun  *	processing it in any regular way.
1257*4882a593Smuzhiyun  *	This is useful if drivers offload some frames but still want to report
1258*4882a593Smuzhiyun  *	them for sniffing purposes.
1259*4882a593Smuzhiyun  * @RX_FLAG_SKIP_MONITOR: Process and report frame to all interfaces except
1260*4882a593Smuzhiyun  *	monitor interfaces.
1261*4882a593Smuzhiyun  *	This is useful if drivers offload some frames but still want to report
1262*4882a593Smuzhiyun  *	them for sniffing purposes.
1263*4882a593Smuzhiyun  * @RX_FLAG_AMSDU_MORE: Some drivers may prefer to report separate A-MSDU
1264*4882a593Smuzhiyun  *	subframes instead of a one huge frame for performance reasons.
1265*4882a593Smuzhiyun  *	All, but the last MSDU from an A-MSDU should have this flag set. E.g.
1266*4882a593Smuzhiyun  *	if an A-MSDU has 3 frames, the first 2 must have the flag set, while
1267*4882a593Smuzhiyun  *	the 3rd (last) one must not have this flag set. The flag is used to
1268*4882a593Smuzhiyun  *	deal with retransmission/duplication recovery properly since A-MSDU
1269*4882a593Smuzhiyun  *	subframes share the same sequence number. Reported subframes can be
1270*4882a593Smuzhiyun  *	either regular MSDU or singly A-MSDUs. Subframes must not be
1271*4882a593Smuzhiyun  *	interleaved with other frames.
1272*4882a593Smuzhiyun  * @RX_FLAG_RADIOTAP_VENDOR_DATA: This frame contains vendor-specific
1273*4882a593Smuzhiyun  *	radiotap data in the skb->data (before the frame) as described by
1274*4882a593Smuzhiyun  *	the &struct ieee80211_vendor_radiotap.
1275*4882a593Smuzhiyun  * @RX_FLAG_ALLOW_SAME_PN: Allow the same PN as same packet before.
1276*4882a593Smuzhiyun  *	This is used for AMSDU subframes which can have the same PN as
1277*4882a593Smuzhiyun  *	the first subframe.
1278*4882a593Smuzhiyun  * @RX_FLAG_ICV_STRIPPED: The ICV is stripped from this frame. CRC checking must
1279*4882a593Smuzhiyun  *	be done in the hardware.
1280*4882a593Smuzhiyun  * @RX_FLAG_AMPDU_EOF_BIT: Value of the EOF bit in the A-MPDU delimiter for this
1281*4882a593Smuzhiyun  *	frame
1282*4882a593Smuzhiyun  * @RX_FLAG_AMPDU_EOF_BIT_KNOWN: The EOF value is known
1283*4882a593Smuzhiyun  * @RX_FLAG_RADIOTAP_HE: HE radiotap data is present
1284*4882a593Smuzhiyun  *	(&struct ieee80211_radiotap_he, mac80211 will fill in
1285*4882a593Smuzhiyun  *
1286*4882a593Smuzhiyun  *	 - DATA3_DATA_MCS
1287*4882a593Smuzhiyun  *	 - DATA3_DATA_DCM
1288*4882a593Smuzhiyun  *	 - DATA3_CODING
1289*4882a593Smuzhiyun  *	 - DATA5_GI
1290*4882a593Smuzhiyun  *	 - DATA5_DATA_BW_RU_ALLOC
1291*4882a593Smuzhiyun  *	 - DATA6_NSTS
1292*4882a593Smuzhiyun  *	 - DATA3_STBC
1293*4882a593Smuzhiyun  *
1294*4882a593Smuzhiyun  *	from the RX info data, so leave those zeroed when building this data)
1295*4882a593Smuzhiyun  * @RX_FLAG_RADIOTAP_HE_MU: HE MU radiotap data is present
1296*4882a593Smuzhiyun  *	(&struct ieee80211_radiotap_he_mu)
1297*4882a593Smuzhiyun  * @RX_FLAG_RADIOTAP_LSIG: L-SIG radiotap data is present
1298*4882a593Smuzhiyun  * @RX_FLAG_NO_PSDU: use the frame only for radiotap reporting, with
1299*4882a593Smuzhiyun  *	the "0-length PSDU" field included there.  The value for it is
1300*4882a593Smuzhiyun  *	in &struct ieee80211_rx_status.  Note that if this value isn't
1301*4882a593Smuzhiyun  *	known the frame shouldn't be reported.
1302*4882a593Smuzhiyun  */
1303*4882a593Smuzhiyun enum mac80211_rx_flags {
1304*4882a593Smuzhiyun 	RX_FLAG_MMIC_ERROR		= BIT(0),
1305*4882a593Smuzhiyun 	RX_FLAG_DECRYPTED		= BIT(1),
1306*4882a593Smuzhiyun 	RX_FLAG_MACTIME_PLCP_START	= BIT(2),
1307*4882a593Smuzhiyun 	RX_FLAG_MMIC_STRIPPED		= BIT(3),
1308*4882a593Smuzhiyun 	RX_FLAG_IV_STRIPPED		= BIT(4),
1309*4882a593Smuzhiyun 	RX_FLAG_FAILED_FCS_CRC		= BIT(5),
1310*4882a593Smuzhiyun 	RX_FLAG_FAILED_PLCP_CRC 	= BIT(6),
1311*4882a593Smuzhiyun 	RX_FLAG_MACTIME_START		= BIT(7),
1312*4882a593Smuzhiyun 	RX_FLAG_NO_SIGNAL_VAL		= BIT(8),
1313*4882a593Smuzhiyun 	RX_FLAG_AMPDU_DETAILS		= BIT(9),
1314*4882a593Smuzhiyun 	RX_FLAG_PN_VALIDATED		= BIT(10),
1315*4882a593Smuzhiyun 	RX_FLAG_DUP_VALIDATED		= BIT(11),
1316*4882a593Smuzhiyun 	RX_FLAG_AMPDU_LAST_KNOWN	= BIT(12),
1317*4882a593Smuzhiyun 	RX_FLAG_AMPDU_IS_LAST		= BIT(13),
1318*4882a593Smuzhiyun 	RX_FLAG_AMPDU_DELIM_CRC_ERROR	= BIT(14),
1319*4882a593Smuzhiyun 	RX_FLAG_AMPDU_DELIM_CRC_KNOWN	= BIT(15),
1320*4882a593Smuzhiyun 	RX_FLAG_MACTIME_END		= BIT(16),
1321*4882a593Smuzhiyun 	RX_FLAG_ONLY_MONITOR		= BIT(17),
1322*4882a593Smuzhiyun 	RX_FLAG_SKIP_MONITOR		= BIT(18),
1323*4882a593Smuzhiyun 	RX_FLAG_AMSDU_MORE		= BIT(19),
1324*4882a593Smuzhiyun 	RX_FLAG_RADIOTAP_VENDOR_DATA	= BIT(20),
1325*4882a593Smuzhiyun 	RX_FLAG_MIC_STRIPPED		= BIT(21),
1326*4882a593Smuzhiyun 	RX_FLAG_ALLOW_SAME_PN		= BIT(22),
1327*4882a593Smuzhiyun 	RX_FLAG_ICV_STRIPPED		= BIT(23),
1328*4882a593Smuzhiyun 	RX_FLAG_AMPDU_EOF_BIT		= BIT(24),
1329*4882a593Smuzhiyun 	RX_FLAG_AMPDU_EOF_BIT_KNOWN	= BIT(25),
1330*4882a593Smuzhiyun 	RX_FLAG_RADIOTAP_HE		= BIT(26),
1331*4882a593Smuzhiyun 	RX_FLAG_RADIOTAP_HE_MU		= BIT(27),
1332*4882a593Smuzhiyun 	RX_FLAG_RADIOTAP_LSIG		= BIT(28),
1333*4882a593Smuzhiyun 	RX_FLAG_NO_PSDU			= BIT(29),
1334*4882a593Smuzhiyun };
1335*4882a593Smuzhiyun 
1336*4882a593Smuzhiyun /**
1337*4882a593Smuzhiyun  * enum mac80211_rx_encoding_flags - MCS & bandwidth flags
1338*4882a593Smuzhiyun  *
1339*4882a593Smuzhiyun  * @RX_ENC_FLAG_SHORTPRE: Short preamble was used for this frame
1340*4882a593Smuzhiyun  * @RX_ENC_FLAG_SHORT_GI: Short guard interval was used
1341*4882a593Smuzhiyun  * @RX_ENC_FLAG_HT_GF: This frame was received in a HT-greenfield transmission,
1342*4882a593Smuzhiyun  *	if the driver fills this value it should add
1343*4882a593Smuzhiyun  *	%IEEE80211_RADIOTAP_MCS_HAVE_FMT
1344*4882a593Smuzhiyun  *	to @hw.radiotap_mcs_details to advertise that fact.
1345*4882a593Smuzhiyun  * @RX_ENC_FLAG_LDPC: LDPC was used
1346*4882a593Smuzhiyun  * @RX_ENC_FLAG_STBC_MASK: STBC 2 bit bitmask. 1 - Nss=1, 2 - Nss=2, 3 - Nss=3
1347*4882a593Smuzhiyun  * @RX_ENC_FLAG_BF: packet was beamformed
1348*4882a593Smuzhiyun  */
1349*4882a593Smuzhiyun enum mac80211_rx_encoding_flags {
1350*4882a593Smuzhiyun 	RX_ENC_FLAG_SHORTPRE		= BIT(0),
1351*4882a593Smuzhiyun 	RX_ENC_FLAG_SHORT_GI		= BIT(2),
1352*4882a593Smuzhiyun 	RX_ENC_FLAG_HT_GF		= BIT(3),
1353*4882a593Smuzhiyun 	RX_ENC_FLAG_STBC_MASK		= BIT(4) | BIT(5),
1354*4882a593Smuzhiyun 	RX_ENC_FLAG_LDPC		= BIT(6),
1355*4882a593Smuzhiyun 	RX_ENC_FLAG_BF			= BIT(7),
1356*4882a593Smuzhiyun };
1357*4882a593Smuzhiyun 
1358*4882a593Smuzhiyun #define RX_ENC_FLAG_STBC_SHIFT		4
1359*4882a593Smuzhiyun 
1360*4882a593Smuzhiyun enum mac80211_rx_encoding {
1361*4882a593Smuzhiyun 	RX_ENC_LEGACY = 0,
1362*4882a593Smuzhiyun 	RX_ENC_HT,
1363*4882a593Smuzhiyun 	RX_ENC_VHT,
1364*4882a593Smuzhiyun 	RX_ENC_HE,
1365*4882a593Smuzhiyun };
1366*4882a593Smuzhiyun 
1367*4882a593Smuzhiyun /**
1368*4882a593Smuzhiyun  * struct ieee80211_rx_status - receive status
1369*4882a593Smuzhiyun  *
1370*4882a593Smuzhiyun  * The low-level driver should provide this information (the subset
1371*4882a593Smuzhiyun  * supported by hardware) to the 802.11 code with each received
1372*4882a593Smuzhiyun  * frame, in the skb's control buffer (cb).
1373*4882a593Smuzhiyun  *
1374*4882a593Smuzhiyun  * @mactime: value in microseconds of the 64-bit Time Synchronization Function
1375*4882a593Smuzhiyun  * 	(TSF) timer when the first data symbol (MPDU) arrived at the hardware.
1376*4882a593Smuzhiyun  * @boottime_ns: CLOCK_BOOTTIME timestamp the frame was received at, this is
1377*4882a593Smuzhiyun  *	needed only for beacons and probe responses that update the scan cache.
1378*4882a593Smuzhiyun  * @device_timestamp: arbitrary timestamp for the device, mac80211 doesn't use
1379*4882a593Smuzhiyun  *	it but can store it and pass it back to the driver for synchronisation
1380*4882a593Smuzhiyun  * @band: the active band when this frame was received
1381*4882a593Smuzhiyun  * @freq: frequency the radio was tuned to when receiving this frame, in MHz
1382*4882a593Smuzhiyun  *	This field must be set for management frames, but isn't strictly needed
1383*4882a593Smuzhiyun  *	for data (other) frames - for those it only affects radiotap reporting.
1384*4882a593Smuzhiyun  * @freq_offset: @freq has a positive offset of 500Khz.
1385*4882a593Smuzhiyun  * @signal: signal strength when receiving this frame, either in dBm, in dB or
1386*4882a593Smuzhiyun  *	unspecified depending on the hardware capabilities flags
1387*4882a593Smuzhiyun  *	@IEEE80211_HW_SIGNAL_*
1388*4882a593Smuzhiyun  * @chains: bitmask of receive chains for which separate signal strength
1389*4882a593Smuzhiyun  *	values were filled.
1390*4882a593Smuzhiyun  * @chain_signal: per-chain signal strength, in dBm (unlike @signal, doesn't
1391*4882a593Smuzhiyun  *	support dB or unspecified units)
1392*4882a593Smuzhiyun  * @antenna: antenna used
1393*4882a593Smuzhiyun  * @rate_idx: index of data rate into band's supported rates or MCS index if
1394*4882a593Smuzhiyun  *	HT or VHT is used (%RX_FLAG_HT/%RX_FLAG_VHT)
1395*4882a593Smuzhiyun  * @nss: number of streams (VHT and HE only)
1396*4882a593Smuzhiyun  * @flag: %RX_FLAG_\*
1397*4882a593Smuzhiyun  * @encoding: &enum mac80211_rx_encoding
1398*4882a593Smuzhiyun  * @bw: &enum rate_info_bw
1399*4882a593Smuzhiyun  * @enc_flags: uses bits from &enum mac80211_rx_encoding_flags
1400*4882a593Smuzhiyun  * @he_ru: HE RU, from &enum nl80211_he_ru_alloc
1401*4882a593Smuzhiyun  * @he_gi: HE GI, from &enum nl80211_he_gi
1402*4882a593Smuzhiyun  * @he_dcm: HE DCM value
1403*4882a593Smuzhiyun  * @rx_flags: internal RX flags for mac80211
1404*4882a593Smuzhiyun  * @ampdu_reference: A-MPDU reference number, must be a different value for
1405*4882a593Smuzhiyun  *	each A-MPDU but the same for each subframe within one A-MPDU
1406*4882a593Smuzhiyun  * @ampdu_delimiter_crc: A-MPDU delimiter CRC
1407*4882a593Smuzhiyun  * @zero_length_psdu_type: radiotap type of the 0-length PSDU
1408*4882a593Smuzhiyun  */
1409*4882a593Smuzhiyun struct ieee80211_rx_status {
1410*4882a593Smuzhiyun 	u64 mactime;
1411*4882a593Smuzhiyun 	u64 boottime_ns;
1412*4882a593Smuzhiyun 	u32 device_timestamp;
1413*4882a593Smuzhiyun 	u32 ampdu_reference;
1414*4882a593Smuzhiyun 	u32 flag;
1415*4882a593Smuzhiyun 	u16 freq: 13, freq_offset: 1;
1416*4882a593Smuzhiyun 	u8 enc_flags;
1417*4882a593Smuzhiyun 	u8 encoding:2, bw:3, he_ru:3;
1418*4882a593Smuzhiyun 	u8 he_gi:2, he_dcm:1;
1419*4882a593Smuzhiyun 	u8 rate_idx;
1420*4882a593Smuzhiyun 	u8 nss;
1421*4882a593Smuzhiyun 	u8 rx_flags;
1422*4882a593Smuzhiyun 	u8 band;
1423*4882a593Smuzhiyun 	u8 antenna;
1424*4882a593Smuzhiyun 	s8 signal;
1425*4882a593Smuzhiyun 	u8 chains;
1426*4882a593Smuzhiyun 	s8 chain_signal[IEEE80211_MAX_CHAINS];
1427*4882a593Smuzhiyun 	u8 ampdu_delimiter_crc;
1428*4882a593Smuzhiyun 	u8 zero_length_psdu_type;
1429*4882a593Smuzhiyun };
1430*4882a593Smuzhiyun 
1431*4882a593Smuzhiyun static inline u32
ieee80211_rx_status_to_khz(struct ieee80211_rx_status * rx_status)1432*4882a593Smuzhiyun ieee80211_rx_status_to_khz(struct ieee80211_rx_status *rx_status)
1433*4882a593Smuzhiyun {
1434*4882a593Smuzhiyun 	return MHZ_TO_KHZ(rx_status->freq) +
1435*4882a593Smuzhiyun 	       (rx_status->freq_offset ? 500 : 0);
1436*4882a593Smuzhiyun }
1437*4882a593Smuzhiyun 
1438*4882a593Smuzhiyun /**
1439*4882a593Smuzhiyun  * struct ieee80211_vendor_radiotap - vendor radiotap data information
1440*4882a593Smuzhiyun  * @present: presence bitmap for this vendor namespace
1441*4882a593Smuzhiyun  *	(this could be extended in the future if any vendor needs more
1442*4882a593Smuzhiyun  *	 bits, the radiotap spec does allow for that)
1443*4882a593Smuzhiyun  * @align: radiotap vendor namespace alignment. This defines the needed
1444*4882a593Smuzhiyun  *	alignment for the @data field below, not for the vendor namespace
1445*4882a593Smuzhiyun  *	description itself (which has a fixed 2-byte alignment)
1446*4882a593Smuzhiyun  *	Must be a power of two, and be set to at least 1!
1447*4882a593Smuzhiyun  * @oui: radiotap vendor namespace OUI
1448*4882a593Smuzhiyun  * @subns: radiotap vendor sub namespace
1449*4882a593Smuzhiyun  * @len: radiotap vendor sub namespace skip length, if alignment is done
1450*4882a593Smuzhiyun  *	then that's added to this, i.e. this is only the length of the
1451*4882a593Smuzhiyun  *	@data field.
1452*4882a593Smuzhiyun  * @pad: number of bytes of padding after the @data, this exists so that
1453*4882a593Smuzhiyun  *	the skb data alignment can be preserved even if the data has odd
1454*4882a593Smuzhiyun  *	length
1455*4882a593Smuzhiyun  * @data: the actual vendor namespace data
1456*4882a593Smuzhiyun  *
1457*4882a593Smuzhiyun  * This struct, including the vendor data, goes into the skb->data before
1458*4882a593Smuzhiyun  * the 802.11 header. It's split up in mac80211 using the align/oui/subns
1459*4882a593Smuzhiyun  * data.
1460*4882a593Smuzhiyun  */
1461*4882a593Smuzhiyun struct ieee80211_vendor_radiotap {
1462*4882a593Smuzhiyun 	u32 present;
1463*4882a593Smuzhiyun 	u8 align;
1464*4882a593Smuzhiyun 	u8 oui[3];
1465*4882a593Smuzhiyun 	u8 subns;
1466*4882a593Smuzhiyun 	u8 pad;
1467*4882a593Smuzhiyun 	u16 len;
1468*4882a593Smuzhiyun 	u8 data[];
1469*4882a593Smuzhiyun } __packed;
1470*4882a593Smuzhiyun 
1471*4882a593Smuzhiyun /**
1472*4882a593Smuzhiyun  * enum ieee80211_conf_flags - configuration flags
1473*4882a593Smuzhiyun  *
1474*4882a593Smuzhiyun  * Flags to define PHY configuration options
1475*4882a593Smuzhiyun  *
1476*4882a593Smuzhiyun  * @IEEE80211_CONF_MONITOR: there's a monitor interface present -- use this
1477*4882a593Smuzhiyun  *	to determine for example whether to calculate timestamps for packets
1478*4882a593Smuzhiyun  *	or not, do not use instead of filter flags!
1479*4882a593Smuzhiyun  * @IEEE80211_CONF_PS: Enable 802.11 power save mode (managed mode only).
1480*4882a593Smuzhiyun  *	This is the power save mode defined by IEEE 802.11-2007 section 11.2,
1481*4882a593Smuzhiyun  *	meaning that the hardware still wakes up for beacons, is able to
1482*4882a593Smuzhiyun  *	transmit frames and receive the possible acknowledgment frames.
1483*4882a593Smuzhiyun  *	Not to be confused with hardware specific wakeup/sleep states,
1484*4882a593Smuzhiyun  *	driver is responsible for that. See the section "Powersave support"
1485*4882a593Smuzhiyun  *	for more.
1486*4882a593Smuzhiyun  * @IEEE80211_CONF_IDLE: The device is running, but idle; if the flag is set
1487*4882a593Smuzhiyun  *	the driver should be prepared to handle configuration requests but
1488*4882a593Smuzhiyun  *	may turn the device off as much as possible. Typically, this flag will
1489*4882a593Smuzhiyun  *	be set when an interface is set UP but not associated or scanning, but
1490*4882a593Smuzhiyun  *	it can also be unset in that case when monitor interfaces are active.
1491*4882a593Smuzhiyun  * @IEEE80211_CONF_OFFCHANNEL: The device is currently not on its main
1492*4882a593Smuzhiyun  *	operating channel.
1493*4882a593Smuzhiyun  */
1494*4882a593Smuzhiyun enum ieee80211_conf_flags {
1495*4882a593Smuzhiyun 	IEEE80211_CONF_MONITOR		= (1<<0),
1496*4882a593Smuzhiyun 	IEEE80211_CONF_PS		= (1<<1),
1497*4882a593Smuzhiyun 	IEEE80211_CONF_IDLE		= (1<<2),
1498*4882a593Smuzhiyun 	IEEE80211_CONF_OFFCHANNEL	= (1<<3),
1499*4882a593Smuzhiyun };
1500*4882a593Smuzhiyun 
1501*4882a593Smuzhiyun 
1502*4882a593Smuzhiyun /**
1503*4882a593Smuzhiyun  * enum ieee80211_conf_changed - denotes which configuration changed
1504*4882a593Smuzhiyun  *
1505*4882a593Smuzhiyun  * @IEEE80211_CONF_CHANGE_LISTEN_INTERVAL: the listen interval changed
1506*4882a593Smuzhiyun  * @IEEE80211_CONF_CHANGE_MONITOR: the monitor flag changed
1507*4882a593Smuzhiyun  * @IEEE80211_CONF_CHANGE_PS: the PS flag or dynamic PS timeout changed
1508*4882a593Smuzhiyun  * @IEEE80211_CONF_CHANGE_POWER: the TX power changed
1509*4882a593Smuzhiyun  * @IEEE80211_CONF_CHANGE_CHANNEL: the channel/channel_type changed
1510*4882a593Smuzhiyun  * @IEEE80211_CONF_CHANGE_RETRY_LIMITS: retry limits changed
1511*4882a593Smuzhiyun  * @IEEE80211_CONF_CHANGE_IDLE: Idle flag changed
1512*4882a593Smuzhiyun  * @IEEE80211_CONF_CHANGE_SMPS: Spatial multiplexing powersave mode changed
1513*4882a593Smuzhiyun  *	Note that this is only valid if channel contexts are not used,
1514*4882a593Smuzhiyun  *	otherwise each channel context has the number of chains listed.
1515*4882a593Smuzhiyun  */
1516*4882a593Smuzhiyun enum ieee80211_conf_changed {
1517*4882a593Smuzhiyun 	IEEE80211_CONF_CHANGE_SMPS		= BIT(1),
1518*4882a593Smuzhiyun 	IEEE80211_CONF_CHANGE_LISTEN_INTERVAL	= BIT(2),
1519*4882a593Smuzhiyun 	IEEE80211_CONF_CHANGE_MONITOR		= BIT(3),
1520*4882a593Smuzhiyun 	IEEE80211_CONF_CHANGE_PS		= BIT(4),
1521*4882a593Smuzhiyun 	IEEE80211_CONF_CHANGE_POWER		= BIT(5),
1522*4882a593Smuzhiyun 	IEEE80211_CONF_CHANGE_CHANNEL		= BIT(6),
1523*4882a593Smuzhiyun 	IEEE80211_CONF_CHANGE_RETRY_LIMITS	= BIT(7),
1524*4882a593Smuzhiyun 	IEEE80211_CONF_CHANGE_IDLE		= BIT(8),
1525*4882a593Smuzhiyun };
1526*4882a593Smuzhiyun 
1527*4882a593Smuzhiyun /**
1528*4882a593Smuzhiyun  * enum ieee80211_smps_mode - spatial multiplexing power save mode
1529*4882a593Smuzhiyun  *
1530*4882a593Smuzhiyun  * @IEEE80211_SMPS_AUTOMATIC: automatic
1531*4882a593Smuzhiyun  * @IEEE80211_SMPS_OFF: off
1532*4882a593Smuzhiyun  * @IEEE80211_SMPS_STATIC: static
1533*4882a593Smuzhiyun  * @IEEE80211_SMPS_DYNAMIC: dynamic
1534*4882a593Smuzhiyun  * @IEEE80211_SMPS_NUM_MODES: internal, don't use
1535*4882a593Smuzhiyun  */
1536*4882a593Smuzhiyun enum ieee80211_smps_mode {
1537*4882a593Smuzhiyun 	IEEE80211_SMPS_AUTOMATIC,
1538*4882a593Smuzhiyun 	IEEE80211_SMPS_OFF,
1539*4882a593Smuzhiyun 	IEEE80211_SMPS_STATIC,
1540*4882a593Smuzhiyun 	IEEE80211_SMPS_DYNAMIC,
1541*4882a593Smuzhiyun 
1542*4882a593Smuzhiyun 	/* keep last */
1543*4882a593Smuzhiyun 	IEEE80211_SMPS_NUM_MODES,
1544*4882a593Smuzhiyun };
1545*4882a593Smuzhiyun 
1546*4882a593Smuzhiyun /**
1547*4882a593Smuzhiyun  * struct ieee80211_conf - configuration of the device
1548*4882a593Smuzhiyun  *
1549*4882a593Smuzhiyun  * This struct indicates how the driver shall configure the hardware.
1550*4882a593Smuzhiyun  *
1551*4882a593Smuzhiyun  * @flags: configuration flags defined above
1552*4882a593Smuzhiyun  *
1553*4882a593Smuzhiyun  * @listen_interval: listen interval in units of beacon interval
1554*4882a593Smuzhiyun  * @ps_dtim_period: The DTIM period of the AP we're connected to, for use
1555*4882a593Smuzhiyun  *	in power saving. Power saving will not be enabled until a beacon
1556*4882a593Smuzhiyun  *	has been received and the DTIM period is known.
1557*4882a593Smuzhiyun  * @dynamic_ps_timeout: The dynamic powersave timeout (in ms), see the
1558*4882a593Smuzhiyun  *	powersave documentation below. This variable is valid only when
1559*4882a593Smuzhiyun  *	the CONF_PS flag is set.
1560*4882a593Smuzhiyun  *
1561*4882a593Smuzhiyun  * @power_level: requested transmit power (in dBm), backward compatibility
1562*4882a593Smuzhiyun  *	value only that is set to the minimum of all interfaces
1563*4882a593Smuzhiyun  *
1564*4882a593Smuzhiyun  * @chandef: the channel definition to tune to
1565*4882a593Smuzhiyun  * @radar_enabled: whether radar detection is enabled
1566*4882a593Smuzhiyun  *
1567*4882a593Smuzhiyun  * @long_frame_max_tx_count: Maximum number of transmissions for a "long" frame
1568*4882a593Smuzhiyun  *	(a frame not RTS protected), called "dot11LongRetryLimit" in 802.11,
1569*4882a593Smuzhiyun  *	but actually means the number of transmissions not the number of retries
1570*4882a593Smuzhiyun  * @short_frame_max_tx_count: Maximum number of transmissions for a "short"
1571*4882a593Smuzhiyun  *	frame, called "dot11ShortRetryLimit" in 802.11, but actually means the
1572*4882a593Smuzhiyun  *	number of transmissions not the number of retries
1573*4882a593Smuzhiyun  *
1574*4882a593Smuzhiyun  * @smps_mode: spatial multiplexing powersave mode; note that
1575*4882a593Smuzhiyun  *	%IEEE80211_SMPS_STATIC is used when the device is not
1576*4882a593Smuzhiyun  *	configured for an HT channel.
1577*4882a593Smuzhiyun  *	Note that this is only valid if channel contexts are not used,
1578*4882a593Smuzhiyun  *	otherwise each channel context has the number of chains listed.
1579*4882a593Smuzhiyun  */
1580*4882a593Smuzhiyun struct ieee80211_conf {
1581*4882a593Smuzhiyun 	u32 flags;
1582*4882a593Smuzhiyun 	int power_level, dynamic_ps_timeout;
1583*4882a593Smuzhiyun 
1584*4882a593Smuzhiyun 	u16 listen_interval;
1585*4882a593Smuzhiyun 	u8 ps_dtim_period;
1586*4882a593Smuzhiyun 
1587*4882a593Smuzhiyun 	u8 long_frame_max_tx_count, short_frame_max_tx_count;
1588*4882a593Smuzhiyun 
1589*4882a593Smuzhiyun 	struct cfg80211_chan_def chandef;
1590*4882a593Smuzhiyun 	bool radar_enabled;
1591*4882a593Smuzhiyun 	enum ieee80211_smps_mode smps_mode;
1592*4882a593Smuzhiyun 
1593*4882a593Smuzhiyun 	ANDROID_KABI_RESERVE(1);
1594*4882a593Smuzhiyun };
1595*4882a593Smuzhiyun 
1596*4882a593Smuzhiyun /**
1597*4882a593Smuzhiyun  * struct ieee80211_channel_switch - holds the channel switch data
1598*4882a593Smuzhiyun  *
1599*4882a593Smuzhiyun  * The information provided in this structure is required for channel switch
1600*4882a593Smuzhiyun  * operation.
1601*4882a593Smuzhiyun  *
1602*4882a593Smuzhiyun  * @timestamp: value in microseconds of the 64-bit Time Synchronization
1603*4882a593Smuzhiyun  *	Function (TSF) timer when the frame containing the channel switch
1604*4882a593Smuzhiyun  *	announcement was received. This is simply the rx.mactime parameter
1605*4882a593Smuzhiyun  *	the driver passed into mac80211.
1606*4882a593Smuzhiyun  * @device_timestamp: arbitrary timestamp for the device, this is the
1607*4882a593Smuzhiyun  *	rx.device_timestamp parameter the driver passed to mac80211.
1608*4882a593Smuzhiyun  * @block_tx: Indicates whether transmission must be blocked before the
1609*4882a593Smuzhiyun  *	scheduled channel switch, as indicated by the AP.
1610*4882a593Smuzhiyun  * @chandef: the new channel to switch to
1611*4882a593Smuzhiyun  * @count: the number of TBTT's until the channel switch event
1612*4882a593Smuzhiyun  * @delay: maximum delay between the time the AP transmitted the last beacon in
1613*4882a593Smuzhiyun   *	current channel and the expected time of the first beacon in the new
1614*4882a593Smuzhiyun   *	channel, expressed in TU.
1615*4882a593Smuzhiyun  */
1616*4882a593Smuzhiyun struct ieee80211_channel_switch {
1617*4882a593Smuzhiyun 	u64 timestamp;
1618*4882a593Smuzhiyun 	u32 device_timestamp;
1619*4882a593Smuzhiyun 	bool block_tx;
1620*4882a593Smuzhiyun 	struct cfg80211_chan_def chandef;
1621*4882a593Smuzhiyun 	u8 count;
1622*4882a593Smuzhiyun 	u32 delay;
1623*4882a593Smuzhiyun };
1624*4882a593Smuzhiyun 
1625*4882a593Smuzhiyun /**
1626*4882a593Smuzhiyun  * enum ieee80211_vif_flags - virtual interface flags
1627*4882a593Smuzhiyun  *
1628*4882a593Smuzhiyun  * @IEEE80211_VIF_BEACON_FILTER: the device performs beacon filtering
1629*4882a593Smuzhiyun  *	on this virtual interface to avoid unnecessary CPU wakeups
1630*4882a593Smuzhiyun  * @IEEE80211_VIF_SUPPORTS_CQM_RSSI: the device can do connection quality
1631*4882a593Smuzhiyun  *	monitoring on this virtual interface -- i.e. it can monitor
1632*4882a593Smuzhiyun  *	connection quality related parameters, such as the RSSI level and
1633*4882a593Smuzhiyun  *	provide notifications if configured trigger levels are reached.
1634*4882a593Smuzhiyun  * @IEEE80211_VIF_SUPPORTS_UAPSD: The device can do U-APSD for this
1635*4882a593Smuzhiyun  *	interface. This flag should be set during interface addition,
1636*4882a593Smuzhiyun  *	but may be set/cleared as late as authentication to an AP. It is
1637*4882a593Smuzhiyun  *	only valid for managed/station mode interfaces.
1638*4882a593Smuzhiyun  * @IEEE80211_VIF_GET_NOA_UPDATE: request to handle NOA attributes
1639*4882a593Smuzhiyun  *	and send P2P_PS notification to the driver if NOA changed, even
1640*4882a593Smuzhiyun  *	this is not pure P2P vif.
1641*4882a593Smuzhiyun  */
1642*4882a593Smuzhiyun enum ieee80211_vif_flags {
1643*4882a593Smuzhiyun 	IEEE80211_VIF_BEACON_FILTER		= BIT(0),
1644*4882a593Smuzhiyun 	IEEE80211_VIF_SUPPORTS_CQM_RSSI		= BIT(1),
1645*4882a593Smuzhiyun 	IEEE80211_VIF_SUPPORTS_UAPSD		= BIT(2),
1646*4882a593Smuzhiyun 	IEEE80211_VIF_GET_NOA_UPDATE		= BIT(3),
1647*4882a593Smuzhiyun };
1648*4882a593Smuzhiyun 
1649*4882a593Smuzhiyun 
1650*4882a593Smuzhiyun /**
1651*4882a593Smuzhiyun  * enum ieee80211_offload_flags - virtual interface offload flags
1652*4882a593Smuzhiyun  *
1653*4882a593Smuzhiyun  * @IEEE80211_OFFLOAD_ENCAP_ENABLED: tx encapsulation offload is enabled
1654*4882a593Smuzhiyun  *	The driver supports sending frames passed as 802.3 frames by mac80211.
1655*4882a593Smuzhiyun  *	It must also support sending 802.11 packets for the same interface.
1656*4882a593Smuzhiyun  * @IEEE80211_OFFLOAD_ENCAP_4ADDR: support 4-address mode encapsulation offload
1657*4882a593Smuzhiyun  */
1658*4882a593Smuzhiyun 
1659*4882a593Smuzhiyun enum ieee80211_offload_flags {
1660*4882a593Smuzhiyun 	IEEE80211_OFFLOAD_ENCAP_ENABLED		= BIT(0),
1661*4882a593Smuzhiyun 	IEEE80211_OFFLOAD_ENCAP_4ADDR		= BIT(1),
1662*4882a593Smuzhiyun };
1663*4882a593Smuzhiyun 
1664*4882a593Smuzhiyun /**
1665*4882a593Smuzhiyun  * struct ieee80211_vif - per-interface data
1666*4882a593Smuzhiyun  *
1667*4882a593Smuzhiyun  * Data in this structure is continually present for driver
1668*4882a593Smuzhiyun  * use during the life of a virtual interface.
1669*4882a593Smuzhiyun  *
1670*4882a593Smuzhiyun  * @type: type of this virtual interface
1671*4882a593Smuzhiyun  * @bss_conf: BSS configuration for this interface, either our own
1672*4882a593Smuzhiyun  *	or the BSS we're associated to
1673*4882a593Smuzhiyun  * @addr: address of this interface
1674*4882a593Smuzhiyun  * @p2p: indicates whether this AP or STA interface is a p2p
1675*4882a593Smuzhiyun  *	interface, i.e. a GO or p2p-sta respectively
1676*4882a593Smuzhiyun  * @csa_active: marks whether a channel switch is going on. Internally it is
1677*4882a593Smuzhiyun  *	write-protected by sdata_lock and local->mtx so holding either is fine
1678*4882a593Smuzhiyun  *	for read access.
1679*4882a593Smuzhiyun  * @mu_mimo_owner: indicates interface owns MU-MIMO capability
1680*4882a593Smuzhiyun  * @driver_flags: flags/capabilities the driver has for this interface,
1681*4882a593Smuzhiyun  *	these need to be set (or cleared) when the interface is added
1682*4882a593Smuzhiyun  *	or, if supported by the driver, the interface type is changed
1683*4882a593Smuzhiyun  *	at runtime, mac80211 will never touch this field
1684*4882a593Smuzhiyun  * @offloaad_flags: hardware offload capabilities/flags for this interface.
1685*4882a593Smuzhiyun  *	These are initialized by mac80211 before calling .add_interface,
1686*4882a593Smuzhiyun  *	.change_interface or .update_vif_offload and updated by the driver
1687*4882a593Smuzhiyun  *	within these ops, based on supported features or runtime change
1688*4882a593Smuzhiyun  *	restrictions.
1689*4882a593Smuzhiyun  * @hw_queue: hardware queue for each AC
1690*4882a593Smuzhiyun  * @cab_queue: content-after-beacon (DTIM beacon really) queue, AP mode only
1691*4882a593Smuzhiyun  * @chanctx_conf: The channel context this interface is assigned to, or %NULL
1692*4882a593Smuzhiyun  *	when it is not assigned. This pointer is RCU-protected due to the TX
1693*4882a593Smuzhiyun  *	path needing to access it; even though the netdev carrier will always
1694*4882a593Smuzhiyun  *	be off when it is %NULL there can still be races and packets could be
1695*4882a593Smuzhiyun  *	processed after it switches back to %NULL.
1696*4882a593Smuzhiyun  * @debugfs_dir: debugfs dentry, can be used by drivers to create own per
1697*4882a593Smuzhiyun  *	interface debug files. Note that it will be NULL for the virtual
1698*4882a593Smuzhiyun  *	monitor interface (if that is requested.)
1699*4882a593Smuzhiyun  * @probe_req_reg: probe requests should be reported to mac80211 for this
1700*4882a593Smuzhiyun  *	interface.
1701*4882a593Smuzhiyun  * @rx_mcast_action_reg: multicast Action frames should be reported to mac80211
1702*4882a593Smuzhiyun  *	for this interface.
1703*4882a593Smuzhiyun  * @drv_priv: data area for driver use, will always be aligned to
1704*4882a593Smuzhiyun  *	sizeof(void \*).
1705*4882a593Smuzhiyun  * @txq: the multicast data TX queue (if driver uses the TXQ abstraction)
1706*4882a593Smuzhiyun  * @txqs_stopped: per AC flag to indicate that intermediate TXQs are stopped,
1707*4882a593Smuzhiyun  *	protected by fq->lock.
1708*4882a593Smuzhiyun  * @offload_flags: 802.3 -> 802.11 enapsulation offload flags, see
1709*4882a593Smuzhiyun  *	&enum ieee80211_offload_flags.
1710*4882a593Smuzhiyun  */
1711*4882a593Smuzhiyun struct ieee80211_vif {
1712*4882a593Smuzhiyun 	enum nl80211_iftype type;
1713*4882a593Smuzhiyun 	struct ieee80211_bss_conf bss_conf;
1714*4882a593Smuzhiyun 	u8 addr[ETH_ALEN] __aligned(2);
1715*4882a593Smuzhiyun 	bool p2p;
1716*4882a593Smuzhiyun 	bool csa_active;
1717*4882a593Smuzhiyun 	bool mu_mimo_owner;
1718*4882a593Smuzhiyun 
1719*4882a593Smuzhiyun 	u8 cab_queue;
1720*4882a593Smuzhiyun 	u8 hw_queue[IEEE80211_NUM_ACS];
1721*4882a593Smuzhiyun 
1722*4882a593Smuzhiyun 	struct ieee80211_txq *txq;
1723*4882a593Smuzhiyun 
1724*4882a593Smuzhiyun 	struct ieee80211_chanctx_conf __rcu *chanctx_conf;
1725*4882a593Smuzhiyun 
1726*4882a593Smuzhiyun 	u32 driver_flags;
1727*4882a593Smuzhiyun 	u32 offload_flags;
1728*4882a593Smuzhiyun 
1729*4882a593Smuzhiyun #ifdef CONFIG_MAC80211_DEBUGFS
1730*4882a593Smuzhiyun 	struct dentry *debugfs_dir;
1731*4882a593Smuzhiyun #endif
1732*4882a593Smuzhiyun 
1733*4882a593Smuzhiyun 	bool probe_req_reg;
1734*4882a593Smuzhiyun 	bool rx_mcast_action_reg;
1735*4882a593Smuzhiyun 
1736*4882a593Smuzhiyun 	bool txqs_stopped[IEEE80211_NUM_ACS];
1737*4882a593Smuzhiyun 
1738*4882a593Smuzhiyun 	ANDROID_KABI_RESERVE(1);
1739*4882a593Smuzhiyun 
1740*4882a593Smuzhiyun 	/* must be last */
1741*4882a593Smuzhiyun 	u8 drv_priv[] __aligned(sizeof(void *));
1742*4882a593Smuzhiyun };
1743*4882a593Smuzhiyun 
ieee80211_vif_is_mesh(struct ieee80211_vif * vif)1744*4882a593Smuzhiyun static inline bool ieee80211_vif_is_mesh(struct ieee80211_vif *vif)
1745*4882a593Smuzhiyun {
1746*4882a593Smuzhiyun #ifdef CONFIG_MAC80211_MESH
1747*4882a593Smuzhiyun 	return vif->type == NL80211_IFTYPE_MESH_POINT;
1748*4882a593Smuzhiyun #endif
1749*4882a593Smuzhiyun 	return false;
1750*4882a593Smuzhiyun }
1751*4882a593Smuzhiyun 
1752*4882a593Smuzhiyun /**
1753*4882a593Smuzhiyun  * wdev_to_ieee80211_vif - return a vif struct from a wdev
1754*4882a593Smuzhiyun  * @wdev: the wdev to get the vif for
1755*4882a593Smuzhiyun  *
1756*4882a593Smuzhiyun  * This can be used by mac80211 drivers with direct cfg80211 APIs
1757*4882a593Smuzhiyun  * (like the vendor commands) that get a wdev.
1758*4882a593Smuzhiyun  *
1759*4882a593Smuzhiyun  * Note that this function may return %NULL if the given wdev isn't
1760*4882a593Smuzhiyun  * associated with a vif that the driver knows about (e.g. monitor
1761*4882a593Smuzhiyun  * or AP_VLAN interfaces.)
1762*4882a593Smuzhiyun  */
1763*4882a593Smuzhiyun struct ieee80211_vif *wdev_to_ieee80211_vif(struct wireless_dev *wdev);
1764*4882a593Smuzhiyun 
1765*4882a593Smuzhiyun /**
1766*4882a593Smuzhiyun  * ieee80211_vif_to_wdev - return a wdev struct from a vif
1767*4882a593Smuzhiyun  * @vif: the vif to get the wdev for
1768*4882a593Smuzhiyun  *
1769*4882a593Smuzhiyun  * This can be used by mac80211 drivers with direct cfg80211 APIs
1770*4882a593Smuzhiyun  * (like the vendor commands) that needs to get the wdev for a vif.
1771*4882a593Smuzhiyun  *
1772*4882a593Smuzhiyun  * Note that this function may return %NULL if the given wdev isn't
1773*4882a593Smuzhiyun  * associated with a vif that the driver knows about (e.g. monitor
1774*4882a593Smuzhiyun  * or AP_VLAN interfaces.)
1775*4882a593Smuzhiyun  */
1776*4882a593Smuzhiyun struct wireless_dev *ieee80211_vif_to_wdev(struct ieee80211_vif *vif);
1777*4882a593Smuzhiyun 
1778*4882a593Smuzhiyun /**
1779*4882a593Smuzhiyun  * enum ieee80211_key_flags - key flags
1780*4882a593Smuzhiyun  *
1781*4882a593Smuzhiyun  * These flags are used for communication about keys between the driver
1782*4882a593Smuzhiyun  * and mac80211, with the @flags parameter of &struct ieee80211_key_conf.
1783*4882a593Smuzhiyun  *
1784*4882a593Smuzhiyun  * @IEEE80211_KEY_FLAG_GENERATE_IV: This flag should be set by the
1785*4882a593Smuzhiyun  *	driver to indicate that it requires IV generation for this
1786*4882a593Smuzhiyun  *	particular key. Setting this flag does not necessarily mean that SKBs
1787*4882a593Smuzhiyun  *	will have sufficient tailroom for ICV or MIC.
1788*4882a593Smuzhiyun  * @IEEE80211_KEY_FLAG_GENERATE_MMIC: This flag should be set by
1789*4882a593Smuzhiyun  *	the driver for a TKIP key if it requires Michael MIC
1790*4882a593Smuzhiyun  *	generation in software.
1791*4882a593Smuzhiyun  * @IEEE80211_KEY_FLAG_PAIRWISE: Set by mac80211, this flag indicates
1792*4882a593Smuzhiyun  *	that the key is pairwise rather then a shared key.
1793*4882a593Smuzhiyun  * @IEEE80211_KEY_FLAG_SW_MGMT_TX: This flag should be set by the driver for a
1794*4882a593Smuzhiyun  *	CCMP/GCMP key if it requires CCMP/GCMP encryption of management frames
1795*4882a593Smuzhiyun  *	(MFP) to be done in software.
1796*4882a593Smuzhiyun  * @IEEE80211_KEY_FLAG_PUT_IV_SPACE: This flag should be set by the driver
1797*4882a593Smuzhiyun  *	if space should be prepared for the IV, but the IV
1798*4882a593Smuzhiyun  *	itself should not be generated. Do not set together with
1799*4882a593Smuzhiyun  *	@IEEE80211_KEY_FLAG_GENERATE_IV on the same key. Setting this flag does
1800*4882a593Smuzhiyun  *	not necessarily mean that SKBs will have sufficient tailroom for ICV or
1801*4882a593Smuzhiyun  *	MIC.
1802*4882a593Smuzhiyun  * @IEEE80211_KEY_FLAG_RX_MGMT: This key will be used to decrypt received
1803*4882a593Smuzhiyun  *	management frames. The flag can help drivers that have a hardware
1804*4882a593Smuzhiyun  *	crypto implementation that doesn't deal with management frames
1805*4882a593Smuzhiyun  *	properly by allowing them to not upload the keys to hardware and
1806*4882a593Smuzhiyun  *	fall back to software crypto. Note that this flag deals only with
1807*4882a593Smuzhiyun  *	RX, if your crypto engine can't deal with TX you can also set the
1808*4882a593Smuzhiyun  *	%IEEE80211_KEY_FLAG_SW_MGMT_TX flag to encrypt such frames in SW.
1809*4882a593Smuzhiyun  * @IEEE80211_KEY_FLAG_GENERATE_IV_MGMT: This flag should be set by the
1810*4882a593Smuzhiyun  *	driver for a CCMP/GCMP key to indicate that is requires IV generation
1811*4882a593Smuzhiyun  *	only for management frames (MFP).
1812*4882a593Smuzhiyun  * @IEEE80211_KEY_FLAG_RESERVE_TAILROOM: This flag should be set by the
1813*4882a593Smuzhiyun  *	driver for a key to indicate that sufficient tailroom must always
1814*4882a593Smuzhiyun  *	be reserved for ICV or MIC, even when HW encryption is enabled.
1815*4882a593Smuzhiyun  * @IEEE80211_KEY_FLAG_PUT_MIC_SPACE: This flag should be set by the driver for
1816*4882a593Smuzhiyun  *	a TKIP key if it only requires MIC space. Do not set together with
1817*4882a593Smuzhiyun  *	@IEEE80211_KEY_FLAG_GENERATE_MMIC on the same key.
1818*4882a593Smuzhiyun  * @IEEE80211_KEY_FLAG_NO_AUTO_TX: Key needs explicit Tx activation.
1819*4882a593Smuzhiyun  * @IEEE80211_KEY_FLAG_GENERATE_MMIE: This flag should be set by the driver
1820*4882a593Smuzhiyun  *	for a AES_CMAC key to indicate that it requires sequence number
1821*4882a593Smuzhiyun  *	generation only
1822*4882a593Smuzhiyun  */
1823*4882a593Smuzhiyun enum ieee80211_key_flags {
1824*4882a593Smuzhiyun 	IEEE80211_KEY_FLAG_GENERATE_IV_MGMT	= BIT(0),
1825*4882a593Smuzhiyun 	IEEE80211_KEY_FLAG_GENERATE_IV		= BIT(1),
1826*4882a593Smuzhiyun 	IEEE80211_KEY_FLAG_GENERATE_MMIC	= BIT(2),
1827*4882a593Smuzhiyun 	IEEE80211_KEY_FLAG_PAIRWISE		= BIT(3),
1828*4882a593Smuzhiyun 	IEEE80211_KEY_FLAG_SW_MGMT_TX		= BIT(4),
1829*4882a593Smuzhiyun 	IEEE80211_KEY_FLAG_PUT_IV_SPACE		= BIT(5),
1830*4882a593Smuzhiyun 	IEEE80211_KEY_FLAG_RX_MGMT		= BIT(6),
1831*4882a593Smuzhiyun 	IEEE80211_KEY_FLAG_RESERVE_TAILROOM	= BIT(7),
1832*4882a593Smuzhiyun 	IEEE80211_KEY_FLAG_PUT_MIC_SPACE	= BIT(8),
1833*4882a593Smuzhiyun 	IEEE80211_KEY_FLAG_NO_AUTO_TX		= BIT(9),
1834*4882a593Smuzhiyun 	IEEE80211_KEY_FLAG_GENERATE_MMIE	= BIT(10),
1835*4882a593Smuzhiyun };
1836*4882a593Smuzhiyun 
1837*4882a593Smuzhiyun /**
1838*4882a593Smuzhiyun  * struct ieee80211_key_conf - key information
1839*4882a593Smuzhiyun  *
1840*4882a593Smuzhiyun  * This key information is given by mac80211 to the driver by
1841*4882a593Smuzhiyun  * the set_key() callback in &struct ieee80211_ops.
1842*4882a593Smuzhiyun  *
1843*4882a593Smuzhiyun  * @hw_key_idx: To be set by the driver, this is the key index the driver
1844*4882a593Smuzhiyun  *	wants to be given when a frame is transmitted and needs to be
1845*4882a593Smuzhiyun  *	encrypted in hardware.
1846*4882a593Smuzhiyun  * @cipher: The key's cipher suite selector.
1847*4882a593Smuzhiyun  * @tx_pn: PN used for TX keys, may be used by the driver as well if it
1848*4882a593Smuzhiyun  *	needs to do software PN assignment by itself (e.g. due to TSO)
1849*4882a593Smuzhiyun  * @flags: key flags, see &enum ieee80211_key_flags.
1850*4882a593Smuzhiyun  * @keyidx: the key index (0-3)
1851*4882a593Smuzhiyun  * @keylen: key material length
1852*4882a593Smuzhiyun  * @key: key material. For ALG_TKIP the key is encoded as a 256-bit (32 byte)
1853*4882a593Smuzhiyun  * 	data block:
1854*4882a593Smuzhiyun  * 	- Temporal Encryption Key (128 bits)
1855*4882a593Smuzhiyun  * 	- Temporal Authenticator Tx MIC Key (64 bits)
1856*4882a593Smuzhiyun  * 	- Temporal Authenticator Rx MIC Key (64 bits)
1857*4882a593Smuzhiyun  * @icv_len: The ICV length for this key type
1858*4882a593Smuzhiyun  * @iv_len: The IV length for this key type
1859*4882a593Smuzhiyun  */
1860*4882a593Smuzhiyun struct ieee80211_key_conf {
1861*4882a593Smuzhiyun 	atomic64_t tx_pn;
1862*4882a593Smuzhiyun 	u32 cipher;
1863*4882a593Smuzhiyun 	u8 icv_len;
1864*4882a593Smuzhiyun 	u8 iv_len;
1865*4882a593Smuzhiyun 	u8 hw_key_idx;
1866*4882a593Smuzhiyun 	s8 keyidx;
1867*4882a593Smuzhiyun 	u16 flags;
1868*4882a593Smuzhiyun 	u8 keylen;
1869*4882a593Smuzhiyun 	u8 key[];
1870*4882a593Smuzhiyun };
1871*4882a593Smuzhiyun 
1872*4882a593Smuzhiyun #define IEEE80211_MAX_PN_LEN	16
1873*4882a593Smuzhiyun 
1874*4882a593Smuzhiyun #define TKIP_PN_TO_IV16(pn) ((u16)(pn & 0xffff))
1875*4882a593Smuzhiyun #define TKIP_PN_TO_IV32(pn) ((u32)((pn >> 16) & 0xffffffff))
1876*4882a593Smuzhiyun 
1877*4882a593Smuzhiyun /**
1878*4882a593Smuzhiyun  * struct ieee80211_key_seq - key sequence counter
1879*4882a593Smuzhiyun  *
1880*4882a593Smuzhiyun  * @tkip: TKIP data, containing IV32 and IV16 in host byte order
1881*4882a593Smuzhiyun  * @ccmp: PN data, most significant byte first (big endian,
1882*4882a593Smuzhiyun  *	reverse order than in packet)
1883*4882a593Smuzhiyun  * @aes_cmac: PN data, most significant byte first (big endian,
1884*4882a593Smuzhiyun  *	reverse order than in packet)
1885*4882a593Smuzhiyun  * @aes_gmac: PN data, most significant byte first (big endian,
1886*4882a593Smuzhiyun  *	reverse order than in packet)
1887*4882a593Smuzhiyun  * @gcmp: PN data, most significant byte first (big endian,
1888*4882a593Smuzhiyun  *	reverse order than in packet)
1889*4882a593Smuzhiyun  * @hw: data for HW-only (e.g. cipher scheme) keys
1890*4882a593Smuzhiyun  */
1891*4882a593Smuzhiyun struct ieee80211_key_seq {
1892*4882a593Smuzhiyun 	union {
1893*4882a593Smuzhiyun 		struct {
1894*4882a593Smuzhiyun 			u32 iv32;
1895*4882a593Smuzhiyun 			u16 iv16;
1896*4882a593Smuzhiyun 		} tkip;
1897*4882a593Smuzhiyun 		struct {
1898*4882a593Smuzhiyun 			u8 pn[6];
1899*4882a593Smuzhiyun 		} ccmp;
1900*4882a593Smuzhiyun 		struct {
1901*4882a593Smuzhiyun 			u8 pn[6];
1902*4882a593Smuzhiyun 		} aes_cmac;
1903*4882a593Smuzhiyun 		struct {
1904*4882a593Smuzhiyun 			u8 pn[6];
1905*4882a593Smuzhiyun 		} aes_gmac;
1906*4882a593Smuzhiyun 		struct {
1907*4882a593Smuzhiyun 			u8 pn[6];
1908*4882a593Smuzhiyun 		} gcmp;
1909*4882a593Smuzhiyun 		struct {
1910*4882a593Smuzhiyun 			u8 seq[IEEE80211_MAX_PN_LEN];
1911*4882a593Smuzhiyun 			u8 seq_len;
1912*4882a593Smuzhiyun 		} hw;
1913*4882a593Smuzhiyun 	};
1914*4882a593Smuzhiyun };
1915*4882a593Smuzhiyun 
1916*4882a593Smuzhiyun /**
1917*4882a593Smuzhiyun  * struct ieee80211_cipher_scheme - cipher scheme
1918*4882a593Smuzhiyun  *
1919*4882a593Smuzhiyun  * This structure contains a cipher scheme information defining
1920*4882a593Smuzhiyun  * the secure packet crypto handling.
1921*4882a593Smuzhiyun  *
1922*4882a593Smuzhiyun  * @cipher: a cipher suite selector
1923*4882a593Smuzhiyun  * @iftype: a cipher iftype bit mask indicating an allowed cipher usage
1924*4882a593Smuzhiyun  * @hdr_len: a length of a security header used the cipher
1925*4882a593Smuzhiyun  * @pn_len: a length of a packet number in the security header
1926*4882a593Smuzhiyun  * @pn_off: an offset of pn from the beginning of the security header
1927*4882a593Smuzhiyun  * @key_idx_off: an offset of key index byte in the security header
1928*4882a593Smuzhiyun  * @key_idx_mask: a bit mask of key_idx bits
1929*4882a593Smuzhiyun  * @key_idx_shift: a bit shift needed to get key_idx
1930*4882a593Smuzhiyun  *     key_idx value calculation:
1931*4882a593Smuzhiyun  *      (sec_header_base[key_idx_off] & key_idx_mask) >> key_idx_shift
1932*4882a593Smuzhiyun  * @mic_len: a mic length in bytes
1933*4882a593Smuzhiyun  */
1934*4882a593Smuzhiyun struct ieee80211_cipher_scheme {
1935*4882a593Smuzhiyun 	u32 cipher;
1936*4882a593Smuzhiyun 	u16 iftype;
1937*4882a593Smuzhiyun 	u8 hdr_len;
1938*4882a593Smuzhiyun 	u8 pn_len;
1939*4882a593Smuzhiyun 	u8 pn_off;
1940*4882a593Smuzhiyun 	u8 key_idx_off;
1941*4882a593Smuzhiyun 	u8 key_idx_mask;
1942*4882a593Smuzhiyun 	u8 key_idx_shift;
1943*4882a593Smuzhiyun 	u8 mic_len;
1944*4882a593Smuzhiyun };
1945*4882a593Smuzhiyun 
1946*4882a593Smuzhiyun /**
1947*4882a593Smuzhiyun  * enum set_key_cmd - key command
1948*4882a593Smuzhiyun  *
1949*4882a593Smuzhiyun  * Used with the set_key() callback in &struct ieee80211_ops, this
1950*4882a593Smuzhiyun  * indicates whether a key is being removed or added.
1951*4882a593Smuzhiyun  *
1952*4882a593Smuzhiyun  * @SET_KEY: a key is set
1953*4882a593Smuzhiyun  * @DISABLE_KEY: a key must be disabled
1954*4882a593Smuzhiyun  */
1955*4882a593Smuzhiyun enum set_key_cmd {
1956*4882a593Smuzhiyun 	SET_KEY, DISABLE_KEY,
1957*4882a593Smuzhiyun };
1958*4882a593Smuzhiyun 
1959*4882a593Smuzhiyun /**
1960*4882a593Smuzhiyun  * enum ieee80211_sta_state - station state
1961*4882a593Smuzhiyun  *
1962*4882a593Smuzhiyun  * @IEEE80211_STA_NOTEXIST: station doesn't exist at all,
1963*4882a593Smuzhiyun  *	this is a special state for add/remove transitions
1964*4882a593Smuzhiyun  * @IEEE80211_STA_NONE: station exists without special state
1965*4882a593Smuzhiyun  * @IEEE80211_STA_AUTH: station is authenticated
1966*4882a593Smuzhiyun  * @IEEE80211_STA_ASSOC: station is associated
1967*4882a593Smuzhiyun  * @IEEE80211_STA_AUTHORIZED: station is authorized (802.1X)
1968*4882a593Smuzhiyun  */
1969*4882a593Smuzhiyun enum ieee80211_sta_state {
1970*4882a593Smuzhiyun 	/* NOTE: These need to be ordered correctly! */
1971*4882a593Smuzhiyun 	IEEE80211_STA_NOTEXIST,
1972*4882a593Smuzhiyun 	IEEE80211_STA_NONE,
1973*4882a593Smuzhiyun 	IEEE80211_STA_AUTH,
1974*4882a593Smuzhiyun 	IEEE80211_STA_ASSOC,
1975*4882a593Smuzhiyun 	IEEE80211_STA_AUTHORIZED,
1976*4882a593Smuzhiyun };
1977*4882a593Smuzhiyun 
1978*4882a593Smuzhiyun /**
1979*4882a593Smuzhiyun  * enum ieee80211_sta_rx_bandwidth - station RX bandwidth
1980*4882a593Smuzhiyun  * @IEEE80211_STA_RX_BW_20: station can only receive 20 MHz
1981*4882a593Smuzhiyun  * @IEEE80211_STA_RX_BW_40: station can receive up to 40 MHz
1982*4882a593Smuzhiyun  * @IEEE80211_STA_RX_BW_80: station can receive up to 80 MHz
1983*4882a593Smuzhiyun  * @IEEE80211_STA_RX_BW_160: station can receive up to 160 MHz
1984*4882a593Smuzhiyun  *	(including 80+80 MHz)
1985*4882a593Smuzhiyun  *
1986*4882a593Smuzhiyun  * Implementation note: 20 must be zero to be initialized
1987*4882a593Smuzhiyun  *	correctly, the values must be sorted.
1988*4882a593Smuzhiyun  */
1989*4882a593Smuzhiyun enum ieee80211_sta_rx_bandwidth {
1990*4882a593Smuzhiyun 	IEEE80211_STA_RX_BW_20 = 0,
1991*4882a593Smuzhiyun 	IEEE80211_STA_RX_BW_40,
1992*4882a593Smuzhiyun 	IEEE80211_STA_RX_BW_80,
1993*4882a593Smuzhiyun 	IEEE80211_STA_RX_BW_160,
1994*4882a593Smuzhiyun };
1995*4882a593Smuzhiyun 
1996*4882a593Smuzhiyun /**
1997*4882a593Smuzhiyun  * struct ieee80211_sta_rates - station rate selection table
1998*4882a593Smuzhiyun  *
1999*4882a593Smuzhiyun  * @rcu_head: RCU head used for freeing the table on update
2000*4882a593Smuzhiyun  * @rate: transmit rates/flags to be used by default.
2001*4882a593Smuzhiyun  *	Overriding entries per-packet is possible by using cb tx control.
2002*4882a593Smuzhiyun  */
2003*4882a593Smuzhiyun struct ieee80211_sta_rates {
2004*4882a593Smuzhiyun 	struct rcu_head rcu_head;
2005*4882a593Smuzhiyun 	struct {
2006*4882a593Smuzhiyun 		s8 idx;
2007*4882a593Smuzhiyun 		u8 count;
2008*4882a593Smuzhiyun 		u8 count_cts;
2009*4882a593Smuzhiyun 		u8 count_rts;
2010*4882a593Smuzhiyun 		u16 flags;
2011*4882a593Smuzhiyun 	} rate[IEEE80211_TX_RATE_TABLE_SIZE];
2012*4882a593Smuzhiyun };
2013*4882a593Smuzhiyun 
2014*4882a593Smuzhiyun /**
2015*4882a593Smuzhiyun  * struct ieee80211_sta_txpwr - station txpower configuration
2016*4882a593Smuzhiyun  *
2017*4882a593Smuzhiyun  * Used to configure txpower for station.
2018*4882a593Smuzhiyun  *
2019*4882a593Smuzhiyun  * @power: indicates the tx power, in dBm, to be used when sending data frames
2020*4882a593Smuzhiyun  *	to the STA.
2021*4882a593Smuzhiyun  * @type: In particular if TPC %type is NL80211_TX_POWER_LIMITED then tx power
2022*4882a593Smuzhiyun  *	will be less than or equal to specified from userspace, whereas if TPC
2023*4882a593Smuzhiyun  *	%type is NL80211_TX_POWER_AUTOMATIC then it indicates default tx power.
2024*4882a593Smuzhiyun  *	NL80211_TX_POWER_FIXED is not a valid configuration option for
2025*4882a593Smuzhiyun  *	per peer TPC.
2026*4882a593Smuzhiyun  */
2027*4882a593Smuzhiyun struct ieee80211_sta_txpwr {
2028*4882a593Smuzhiyun 	s16 power;
2029*4882a593Smuzhiyun 	enum nl80211_tx_power_setting type;
2030*4882a593Smuzhiyun };
2031*4882a593Smuzhiyun 
2032*4882a593Smuzhiyun /**
2033*4882a593Smuzhiyun  * struct ieee80211_sta - station table entry
2034*4882a593Smuzhiyun  *
2035*4882a593Smuzhiyun  * A station table entry represents a station we are possibly
2036*4882a593Smuzhiyun  * communicating with. Since stations are RCU-managed in
2037*4882a593Smuzhiyun  * mac80211, any ieee80211_sta pointer you get access to must
2038*4882a593Smuzhiyun  * either be protected by rcu_read_lock() explicitly or implicitly,
2039*4882a593Smuzhiyun  * or you must take good care to not use such a pointer after a
2040*4882a593Smuzhiyun  * call to your sta_remove callback that removed it.
2041*4882a593Smuzhiyun  *
2042*4882a593Smuzhiyun  * @addr: MAC address
2043*4882a593Smuzhiyun  * @aid: AID we assigned to the station if we're an AP
2044*4882a593Smuzhiyun  * @supp_rates: Bitmap of supported rates (per band)
2045*4882a593Smuzhiyun  * @ht_cap: HT capabilities of this STA; restricted to our own capabilities
2046*4882a593Smuzhiyun  * @vht_cap: VHT capabilities of this STA; restricted to our own capabilities
2047*4882a593Smuzhiyun  * @he_cap: HE capabilities of this STA
2048*4882a593Smuzhiyun  * @he_6ghz_capa: on 6 GHz, holds the HE 6 GHz band capabilities
2049*4882a593Smuzhiyun  * @max_rx_aggregation_subframes: maximal amount of frames in a single AMPDU
2050*4882a593Smuzhiyun  *	that this station is allowed to transmit to us.
2051*4882a593Smuzhiyun  *	Can be modified by driver.
2052*4882a593Smuzhiyun  * @wme: indicates whether the STA supports QoS/WME (if local devices does,
2053*4882a593Smuzhiyun  *	otherwise always false)
2054*4882a593Smuzhiyun  * @drv_priv: data area for driver use, will always be aligned to
2055*4882a593Smuzhiyun  *	sizeof(void \*), size is determined in hw information.
2056*4882a593Smuzhiyun  * @uapsd_queues: bitmap of queues configured for uapsd. Only valid
2057*4882a593Smuzhiyun  *	if wme is supported. The bits order is like in
2058*4882a593Smuzhiyun  *	IEEE80211_WMM_IE_STA_QOSINFO_AC_*.
2059*4882a593Smuzhiyun  * @max_sp: max Service Period. Only valid if wme is supported.
2060*4882a593Smuzhiyun  * @bandwidth: current bandwidth the station can receive with
2061*4882a593Smuzhiyun  * @rx_nss: in HT/VHT, the maximum number of spatial streams the
2062*4882a593Smuzhiyun  *	station can receive at the moment, changed by operating mode
2063*4882a593Smuzhiyun  *	notifications and capabilities. The value is only valid after
2064*4882a593Smuzhiyun  *	the station moves to associated state.
2065*4882a593Smuzhiyun  * @smps_mode: current SMPS mode (off, static or dynamic)
2066*4882a593Smuzhiyun  * @rates: rate control selection table
2067*4882a593Smuzhiyun  * @tdls: indicates whether the STA is a TDLS peer
2068*4882a593Smuzhiyun  * @tdls_initiator: indicates the STA is an initiator of the TDLS link. Only
2069*4882a593Smuzhiyun  *	valid if the STA is a TDLS peer in the first place.
2070*4882a593Smuzhiyun  * @mfp: indicates whether the STA uses management frame protection or not.
2071*4882a593Smuzhiyun  * @max_amsdu_subframes: indicates the maximal number of MSDUs in a single
2072*4882a593Smuzhiyun  *	A-MSDU. Taken from the Extended Capabilities element. 0 means
2073*4882a593Smuzhiyun  *	unlimited.
2074*4882a593Smuzhiyun  * @support_p2p_ps: indicates whether the STA supports P2P PS mechanism or not.
2075*4882a593Smuzhiyun  * @max_rc_amsdu_len: Maximum A-MSDU size in bytes recommended by rate control.
2076*4882a593Smuzhiyun  * @max_tid_amsdu_len: Maximum A-MSDU size in bytes for this TID
2077*4882a593Smuzhiyun  * @txpwr: the station tx power configuration
2078*4882a593Smuzhiyun  * @txq: per-TID data TX queues (if driver uses the TXQ abstraction); note that
2079*4882a593Smuzhiyun  *	the last entry (%IEEE80211_NUM_TIDS) is used for non-data frames
2080*4882a593Smuzhiyun  */
2081*4882a593Smuzhiyun struct ieee80211_sta {
2082*4882a593Smuzhiyun 	u32 supp_rates[NUM_NL80211_BANDS];
2083*4882a593Smuzhiyun 	u8 addr[ETH_ALEN];
2084*4882a593Smuzhiyun 	u16 aid;
2085*4882a593Smuzhiyun 	struct ieee80211_sta_ht_cap ht_cap;
2086*4882a593Smuzhiyun 	struct ieee80211_sta_vht_cap vht_cap;
2087*4882a593Smuzhiyun 	struct ieee80211_sta_he_cap he_cap;
2088*4882a593Smuzhiyun 	struct ieee80211_he_6ghz_capa he_6ghz_capa;
2089*4882a593Smuzhiyun 	u16 max_rx_aggregation_subframes;
2090*4882a593Smuzhiyun 	bool wme;
2091*4882a593Smuzhiyun 	u8 uapsd_queues;
2092*4882a593Smuzhiyun 	u8 max_sp;
2093*4882a593Smuzhiyun 	u8 rx_nss;
2094*4882a593Smuzhiyun 	enum ieee80211_sta_rx_bandwidth bandwidth;
2095*4882a593Smuzhiyun 	enum ieee80211_smps_mode smps_mode;
2096*4882a593Smuzhiyun 	struct ieee80211_sta_rates __rcu *rates;
2097*4882a593Smuzhiyun 	bool tdls;
2098*4882a593Smuzhiyun 	bool tdls_initiator;
2099*4882a593Smuzhiyun 	bool mfp;
2100*4882a593Smuzhiyun 	u8 max_amsdu_subframes;
2101*4882a593Smuzhiyun 
2102*4882a593Smuzhiyun 	/**
2103*4882a593Smuzhiyun 	 * @max_amsdu_len:
2104*4882a593Smuzhiyun 	 * indicates the maximal length of an A-MSDU in bytes.
2105*4882a593Smuzhiyun 	 * This field is always valid for packets with a VHT preamble.
2106*4882a593Smuzhiyun 	 * For packets with a HT preamble, additional limits apply:
2107*4882a593Smuzhiyun 	 *
2108*4882a593Smuzhiyun 	 * * If the skb is transmitted as part of a BA agreement, the
2109*4882a593Smuzhiyun 	 *   A-MSDU maximal size is min(max_amsdu_len, 4065) bytes.
2110*4882a593Smuzhiyun 	 * * If the skb is not part of a BA agreement, the A-MSDU maximal
2111*4882a593Smuzhiyun 	 *   size is min(max_amsdu_len, 7935) bytes.
2112*4882a593Smuzhiyun 	 *
2113*4882a593Smuzhiyun 	 * Both additional HT limits must be enforced by the low level
2114*4882a593Smuzhiyun 	 * driver. This is defined by the spec (IEEE 802.11-2012 section
2115*4882a593Smuzhiyun 	 * 8.3.2.2 NOTE 2).
2116*4882a593Smuzhiyun 	 */
2117*4882a593Smuzhiyun 	u16 max_amsdu_len;
2118*4882a593Smuzhiyun 	bool support_p2p_ps;
2119*4882a593Smuzhiyun 	u16 max_rc_amsdu_len;
2120*4882a593Smuzhiyun 	u16 max_tid_amsdu_len[IEEE80211_NUM_TIDS];
2121*4882a593Smuzhiyun 	struct ieee80211_sta_txpwr txpwr;
2122*4882a593Smuzhiyun 
2123*4882a593Smuzhiyun 	struct ieee80211_txq *txq[IEEE80211_NUM_TIDS + 1];
2124*4882a593Smuzhiyun 
2125*4882a593Smuzhiyun 	ANDROID_KABI_RESERVE(1);
2126*4882a593Smuzhiyun 
2127*4882a593Smuzhiyun 	/* must be last */
2128*4882a593Smuzhiyun 	u8 drv_priv[] __aligned(sizeof(void *));
2129*4882a593Smuzhiyun };
2130*4882a593Smuzhiyun 
2131*4882a593Smuzhiyun /**
2132*4882a593Smuzhiyun  * enum sta_notify_cmd - sta notify command
2133*4882a593Smuzhiyun  *
2134*4882a593Smuzhiyun  * Used with the sta_notify() callback in &struct ieee80211_ops, this
2135*4882a593Smuzhiyun  * indicates if an associated station made a power state transition.
2136*4882a593Smuzhiyun  *
2137*4882a593Smuzhiyun  * @STA_NOTIFY_SLEEP: a station is now sleeping
2138*4882a593Smuzhiyun  * @STA_NOTIFY_AWAKE: a sleeping station woke up
2139*4882a593Smuzhiyun  */
2140*4882a593Smuzhiyun enum sta_notify_cmd {
2141*4882a593Smuzhiyun 	STA_NOTIFY_SLEEP, STA_NOTIFY_AWAKE,
2142*4882a593Smuzhiyun };
2143*4882a593Smuzhiyun 
2144*4882a593Smuzhiyun /**
2145*4882a593Smuzhiyun  * struct ieee80211_tx_control - TX control data
2146*4882a593Smuzhiyun  *
2147*4882a593Smuzhiyun  * @sta: station table entry, this sta pointer may be NULL and
2148*4882a593Smuzhiyun  * 	it is not allowed to copy the pointer, due to RCU.
2149*4882a593Smuzhiyun  */
2150*4882a593Smuzhiyun struct ieee80211_tx_control {
2151*4882a593Smuzhiyun 	struct ieee80211_sta *sta;
2152*4882a593Smuzhiyun };
2153*4882a593Smuzhiyun 
2154*4882a593Smuzhiyun /**
2155*4882a593Smuzhiyun  * struct ieee80211_txq - Software intermediate tx queue
2156*4882a593Smuzhiyun  *
2157*4882a593Smuzhiyun  * @vif: &struct ieee80211_vif pointer from the add_interface callback.
2158*4882a593Smuzhiyun  * @sta: station table entry, %NULL for per-vif queue
2159*4882a593Smuzhiyun  * @tid: the TID for this queue (unused for per-vif queue),
2160*4882a593Smuzhiyun  *	%IEEE80211_NUM_TIDS for non-data (if enabled)
2161*4882a593Smuzhiyun  * @ac: the AC for this queue
2162*4882a593Smuzhiyun  * @drv_priv: driver private area, sized by hw->txq_data_size
2163*4882a593Smuzhiyun  *
2164*4882a593Smuzhiyun  * The driver can obtain packets from this queue by calling
2165*4882a593Smuzhiyun  * ieee80211_tx_dequeue().
2166*4882a593Smuzhiyun  */
2167*4882a593Smuzhiyun struct ieee80211_txq {
2168*4882a593Smuzhiyun 	struct ieee80211_vif *vif;
2169*4882a593Smuzhiyun 	struct ieee80211_sta *sta;
2170*4882a593Smuzhiyun 	u8 tid;
2171*4882a593Smuzhiyun 	u8 ac;
2172*4882a593Smuzhiyun 
2173*4882a593Smuzhiyun 	/* must be last */
2174*4882a593Smuzhiyun 	u8 drv_priv[] __aligned(sizeof(void *));
2175*4882a593Smuzhiyun };
2176*4882a593Smuzhiyun 
2177*4882a593Smuzhiyun /**
2178*4882a593Smuzhiyun  * enum ieee80211_hw_flags - hardware flags
2179*4882a593Smuzhiyun  *
2180*4882a593Smuzhiyun  * These flags are used to indicate hardware capabilities to
2181*4882a593Smuzhiyun  * the stack. Generally, flags here should have their meaning
2182*4882a593Smuzhiyun  * done in a way that the simplest hardware doesn't need setting
2183*4882a593Smuzhiyun  * any particular flags. There are some exceptions to this rule,
2184*4882a593Smuzhiyun  * however, so you are advised to review these flags carefully.
2185*4882a593Smuzhiyun  *
2186*4882a593Smuzhiyun  * @IEEE80211_HW_HAS_RATE_CONTROL:
2187*4882a593Smuzhiyun  *	The hardware or firmware includes rate control, and cannot be
2188*4882a593Smuzhiyun  *	controlled by the stack. As such, no rate control algorithm
2189*4882a593Smuzhiyun  *	should be instantiated, and the TX rate reported to userspace
2190*4882a593Smuzhiyun  *	will be taken from the TX status instead of the rate control
2191*4882a593Smuzhiyun  *	algorithm.
2192*4882a593Smuzhiyun  *	Note that this requires that the driver implement a number of
2193*4882a593Smuzhiyun  *	callbacks so it has the correct information, it needs to have
2194*4882a593Smuzhiyun  *	the @set_rts_threshold callback and must look at the BSS config
2195*4882a593Smuzhiyun  *	@use_cts_prot for G/N protection, @use_short_slot for slot
2196*4882a593Smuzhiyun  *	timing in 2.4 GHz and @use_short_preamble for preambles for
2197*4882a593Smuzhiyun  *	CCK frames.
2198*4882a593Smuzhiyun  *
2199*4882a593Smuzhiyun  * @IEEE80211_HW_RX_INCLUDES_FCS:
2200*4882a593Smuzhiyun  *	Indicates that received frames passed to the stack include
2201*4882a593Smuzhiyun  *	the FCS at the end.
2202*4882a593Smuzhiyun  *
2203*4882a593Smuzhiyun  * @IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING:
2204*4882a593Smuzhiyun  *	Some wireless LAN chipsets buffer broadcast/multicast frames
2205*4882a593Smuzhiyun  *	for power saving stations in the hardware/firmware and others
2206*4882a593Smuzhiyun  *	rely on the host system for such buffering. This option is used
2207*4882a593Smuzhiyun  *	to configure the IEEE 802.11 upper layer to buffer broadcast and
2208*4882a593Smuzhiyun  *	multicast frames when there are power saving stations so that
2209*4882a593Smuzhiyun  *	the driver can fetch them with ieee80211_get_buffered_bc().
2210*4882a593Smuzhiyun  *
2211*4882a593Smuzhiyun  * @IEEE80211_HW_SIGNAL_UNSPEC:
2212*4882a593Smuzhiyun  *	Hardware can provide signal values but we don't know its units. We
2213*4882a593Smuzhiyun  *	expect values between 0 and @max_signal.
2214*4882a593Smuzhiyun  *	If possible please provide dB or dBm instead.
2215*4882a593Smuzhiyun  *
2216*4882a593Smuzhiyun  * @IEEE80211_HW_SIGNAL_DBM:
2217*4882a593Smuzhiyun  *	Hardware gives signal values in dBm, decibel difference from
2218*4882a593Smuzhiyun  *	one milliwatt. This is the preferred method since it is standardized
2219*4882a593Smuzhiyun  *	between different devices. @max_signal does not need to be set.
2220*4882a593Smuzhiyun  *
2221*4882a593Smuzhiyun  * @IEEE80211_HW_SPECTRUM_MGMT:
2222*4882a593Smuzhiyun  * 	Hardware supports spectrum management defined in 802.11h
2223*4882a593Smuzhiyun  * 	Measurement, Channel Switch, Quieting, TPC
2224*4882a593Smuzhiyun  *
2225*4882a593Smuzhiyun  * @IEEE80211_HW_AMPDU_AGGREGATION:
2226*4882a593Smuzhiyun  *	Hardware supports 11n A-MPDU aggregation.
2227*4882a593Smuzhiyun  *
2228*4882a593Smuzhiyun  * @IEEE80211_HW_SUPPORTS_PS:
2229*4882a593Smuzhiyun  *	Hardware has power save support (i.e. can go to sleep).
2230*4882a593Smuzhiyun  *
2231*4882a593Smuzhiyun  * @IEEE80211_HW_PS_NULLFUNC_STACK:
2232*4882a593Smuzhiyun  *	Hardware requires nullfunc frame handling in stack, implies
2233*4882a593Smuzhiyun  *	stack support for dynamic PS.
2234*4882a593Smuzhiyun  *
2235*4882a593Smuzhiyun  * @IEEE80211_HW_SUPPORTS_DYNAMIC_PS:
2236*4882a593Smuzhiyun  *	Hardware has support for dynamic PS.
2237*4882a593Smuzhiyun  *
2238*4882a593Smuzhiyun  * @IEEE80211_HW_MFP_CAPABLE:
2239*4882a593Smuzhiyun  *	Hardware supports management frame protection (MFP, IEEE 802.11w).
2240*4882a593Smuzhiyun  *
2241*4882a593Smuzhiyun  * @IEEE80211_HW_REPORTS_TX_ACK_STATUS:
2242*4882a593Smuzhiyun  *	Hardware can provide ack status reports of Tx frames to
2243*4882a593Smuzhiyun  *	the stack.
2244*4882a593Smuzhiyun  *
2245*4882a593Smuzhiyun  * @IEEE80211_HW_CONNECTION_MONITOR:
2246*4882a593Smuzhiyun  *	The hardware performs its own connection monitoring, including
2247*4882a593Smuzhiyun  *	periodic keep-alives to the AP and probing the AP on beacon loss.
2248*4882a593Smuzhiyun  *
2249*4882a593Smuzhiyun  * @IEEE80211_HW_NEED_DTIM_BEFORE_ASSOC:
2250*4882a593Smuzhiyun  *	This device needs to get data from beacon before association (i.e.
2251*4882a593Smuzhiyun  *	dtim_period).
2252*4882a593Smuzhiyun  *
2253*4882a593Smuzhiyun  * @IEEE80211_HW_SUPPORTS_PER_STA_GTK: The device's crypto engine supports
2254*4882a593Smuzhiyun  *	per-station GTKs as used by IBSS RSN or during fast transition. If
2255*4882a593Smuzhiyun  *	the device doesn't support per-station GTKs, but can be asked not
2256*4882a593Smuzhiyun  *	to decrypt group addressed frames, then IBSS RSN support is still
2257*4882a593Smuzhiyun  *	possible but software crypto will be used. Advertise the wiphy flag
2258*4882a593Smuzhiyun  *	only in that case.
2259*4882a593Smuzhiyun  *
2260*4882a593Smuzhiyun  * @IEEE80211_HW_AP_LINK_PS: When operating in AP mode the device
2261*4882a593Smuzhiyun  *	autonomously manages the PS status of connected stations. When
2262*4882a593Smuzhiyun  *	this flag is set mac80211 will not trigger PS mode for connected
2263*4882a593Smuzhiyun  *	stations based on the PM bit of incoming frames.
2264*4882a593Smuzhiyun  *	Use ieee80211_start_ps()/ieee8021_end_ps() to manually configure
2265*4882a593Smuzhiyun  *	the PS mode of connected stations.
2266*4882a593Smuzhiyun  *
2267*4882a593Smuzhiyun  * @IEEE80211_HW_TX_AMPDU_SETUP_IN_HW: The device handles TX A-MPDU session
2268*4882a593Smuzhiyun  *	setup strictly in HW. mac80211 should not attempt to do this in
2269*4882a593Smuzhiyun  *	software.
2270*4882a593Smuzhiyun  *
2271*4882a593Smuzhiyun  * @IEEE80211_HW_WANT_MONITOR_VIF: The driver would like to be informed of
2272*4882a593Smuzhiyun  *	a virtual monitor interface when monitor interfaces are the only
2273*4882a593Smuzhiyun  *	active interfaces.
2274*4882a593Smuzhiyun  *
2275*4882a593Smuzhiyun  * @IEEE80211_HW_NO_AUTO_VIF: The driver would like for no wlanX to
2276*4882a593Smuzhiyun  *	be created.  It is expected user-space will create vifs as
2277*4882a593Smuzhiyun  *	desired (and thus have them named as desired).
2278*4882a593Smuzhiyun  *
2279*4882a593Smuzhiyun  * @IEEE80211_HW_SW_CRYPTO_CONTROL: The driver wants to control which of the
2280*4882a593Smuzhiyun  *	crypto algorithms can be done in software - so don't automatically
2281*4882a593Smuzhiyun  *	try to fall back to it if hardware crypto fails, but do so only if
2282*4882a593Smuzhiyun  *	the driver returns 1. This also forces the driver to advertise its
2283*4882a593Smuzhiyun  *	supported cipher suites.
2284*4882a593Smuzhiyun  *
2285*4882a593Smuzhiyun  * @IEEE80211_HW_SUPPORT_FAST_XMIT: The driver/hardware supports fast-xmit,
2286*4882a593Smuzhiyun  *	this currently requires only the ability to calculate the duration
2287*4882a593Smuzhiyun  *	for frames.
2288*4882a593Smuzhiyun  *
2289*4882a593Smuzhiyun  * @IEEE80211_HW_QUEUE_CONTROL: The driver wants to control per-interface
2290*4882a593Smuzhiyun  *	queue mapping in order to use different queues (not just one per AC)
2291*4882a593Smuzhiyun  *	for different virtual interfaces. See the doc section on HW queue
2292*4882a593Smuzhiyun  *	control for more details.
2293*4882a593Smuzhiyun  *
2294*4882a593Smuzhiyun  * @IEEE80211_HW_SUPPORTS_RC_TABLE: The driver supports using a rate
2295*4882a593Smuzhiyun  *	selection table provided by the rate control algorithm.
2296*4882a593Smuzhiyun  *
2297*4882a593Smuzhiyun  * @IEEE80211_HW_P2P_DEV_ADDR_FOR_INTF: Use the P2P Device address for any
2298*4882a593Smuzhiyun  *	P2P Interface. This will be honoured even if more than one interface
2299*4882a593Smuzhiyun  *	is supported.
2300*4882a593Smuzhiyun  *
2301*4882a593Smuzhiyun  * @IEEE80211_HW_TIMING_BEACON_ONLY: Use sync timing from beacon frames
2302*4882a593Smuzhiyun  *	only, to allow getting TBTT of a DTIM beacon.
2303*4882a593Smuzhiyun  *
2304*4882a593Smuzhiyun  * @IEEE80211_HW_SUPPORTS_HT_CCK_RATES: Hardware supports mixing HT/CCK rates
2305*4882a593Smuzhiyun  *	and can cope with CCK rates in an aggregation session (e.g. by not
2306*4882a593Smuzhiyun  *	using aggregation for such frames.)
2307*4882a593Smuzhiyun  *
2308*4882a593Smuzhiyun  * @IEEE80211_HW_CHANCTX_STA_CSA: Support 802.11h based channel-switch (CSA)
2309*4882a593Smuzhiyun  *	for a single active channel while using channel contexts. When support
2310*4882a593Smuzhiyun  *	is not enabled the default action is to disconnect when getting the
2311*4882a593Smuzhiyun  *	CSA frame.
2312*4882a593Smuzhiyun  *
2313*4882a593Smuzhiyun  * @IEEE80211_HW_SUPPORTS_CLONED_SKBS: The driver will never modify the payload
2314*4882a593Smuzhiyun  *	or tailroom of TX skbs without copying them first.
2315*4882a593Smuzhiyun  *
2316*4882a593Smuzhiyun  * @IEEE80211_HW_SINGLE_SCAN_ON_ALL_BANDS: The HW supports scanning on all bands
2317*4882a593Smuzhiyun  *	in one command, mac80211 doesn't have to run separate scans per band.
2318*4882a593Smuzhiyun  *
2319*4882a593Smuzhiyun  * @IEEE80211_HW_TDLS_WIDER_BW: The device/driver supports wider bandwidth
2320*4882a593Smuzhiyun  *	than then BSS bandwidth for a TDLS link on the base channel.
2321*4882a593Smuzhiyun  *
2322*4882a593Smuzhiyun  * @IEEE80211_HW_SUPPORTS_AMSDU_IN_AMPDU: The driver supports receiving A-MSDUs
2323*4882a593Smuzhiyun  *	within A-MPDU.
2324*4882a593Smuzhiyun  *
2325*4882a593Smuzhiyun  * @IEEE80211_HW_BEACON_TX_STATUS: The device/driver provides TX status
2326*4882a593Smuzhiyun  *	for sent beacons.
2327*4882a593Smuzhiyun  *
2328*4882a593Smuzhiyun  * @IEEE80211_HW_NEEDS_UNIQUE_STA_ADDR: Hardware (or driver) requires that each
2329*4882a593Smuzhiyun  *	station has a unique address, i.e. each station entry can be identified
2330*4882a593Smuzhiyun  *	by just its MAC address; this prevents, for example, the same station
2331*4882a593Smuzhiyun  *	from connecting to two virtual AP interfaces at the same time.
2332*4882a593Smuzhiyun  *
2333*4882a593Smuzhiyun  * @IEEE80211_HW_SUPPORTS_REORDERING_BUFFER: Hardware (or driver) manages the
2334*4882a593Smuzhiyun  *	reordering buffer internally, guaranteeing mac80211 receives frames in
2335*4882a593Smuzhiyun  *	order and does not need to manage its own reorder buffer or BA session
2336*4882a593Smuzhiyun  *	timeout.
2337*4882a593Smuzhiyun  *
2338*4882a593Smuzhiyun  * @IEEE80211_HW_USES_RSS: The device uses RSS and thus requires parallel RX,
2339*4882a593Smuzhiyun  *	which implies using per-CPU station statistics.
2340*4882a593Smuzhiyun  *
2341*4882a593Smuzhiyun  * @IEEE80211_HW_TX_AMSDU: Hardware (or driver) supports software aggregated
2342*4882a593Smuzhiyun  *	A-MSDU frames. Requires software tx queueing and fast-xmit support.
2343*4882a593Smuzhiyun  *	When not using minstrel/minstrel_ht rate control, the driver must
2344*4882a593Smuzhiyun  *	limit the maximum A-MSDU size based on the current tx rate by setting
2345*4882a593Smuzhiyun  *	max_rc_amsdu_len in struct ieee80211_sta.
2346*4882a593Smuzhiyun  *
2347*4882a593Smuzhiyun  * @IEEE80211_HW_TX_FRAG_LIST: Hardware (or driver) supports sending frag_list
2348*4882a593Smuzhiyun  *	skbs, needed for zero-copy software A-MSDU.
2349*4882a593Smuzhiyun  *
2350*4882a593Smuzhiyun  * @IEEE80211_HW_REPORTS_LOW_ACK: The driver (or firmware) reports low ack event
2351*4882a593Smuzhiyun  *	by ieee80211_report_low_ack() based on its own algorithm. For such
2352*4882a593Smuzhiyun  *	drivers, mac80211 packet loss mechanism will not be triggered and driver
2353*4882a593Smuzhiyun  *	is completely depending on firmware event for station kickout.
2354*4882a593Smuzhiyun  *
2355*4882a593Smuzhiyun  * @IEEE80211_HW_SUPPORTS_TX_FRAG: Hardware does fragmentation by itself.
2356*4882a593Smuzhiyun  *	The stack will not do fragmentation.
2357*4882a593Smuzhiyun  *	The callback for @set_frag_threshold should be set as well.
2358*4882a593Smuzhiyun  *
2359*4882a593Smuzhiyun  * @IEEE80211_HW_SUPPORTS_TDLS_BUFFER_STA: Hardware supports buffer STA on
2360*4882a593Smuzhiyun  *	TDLS links.
2361*4882a593Smuzhiyun  *
2362*4882a593Smuzhiyun  * @IEEE80211_HW_DEAUTH_NEED_MGD_TX_PREP: The driver requires the
2363*4882a593Smuzhiyun  *	mgd_prepare_tx() callback to be called before transmission of a
2364*4882a593Smuzhiyun  *	deauthentication frame in case the association was completed but no
2365*4882a593Smuzhiyun  *	beacon was heard. This is required in multi-channel scenarios, where the
2366*4882a593Smuzhiyun  *	virtual interface might not be given air time for the transmission of
2367*4882a593Smuzhiyun  *	the frame, as it is not synced with the AP/P2P GO yet, and thus the
2368*4882a593Smuzhiyun  *	deauthentication frame might not be transmitted.
2369*4882a593Smuzhiyun  *
2370*4882a593Smuzhiyun  * @IEEE80211_HW_DOESNT_SUPPORT_QOS_NDP: The driver (or firmware) doesn't
2371*4882a593Smuzhiyun  *	support QoS NDP for AP probing - that's most likely a driver bug.
2372*4882a593Smuzhiyun  *
2373*4882a593Smuzhiyun  * @IEEE80211_HW_BUFF_MMPDU_TXQ: use the TXQ for bufferable MMPDUs, this of
2374*4882a593Smuzhiyun  *	course requires the driver to use TXQs to start with.
2375*4882a593Smuzhiyun  *
2376*4882a593Smuzhiyun  * @IEEE80211_HW_SUPPORTS_VHT_EXT_NSS_BW: (Hardware) rate control supports VHT
2377*4882a593Smuzhiyun  *	extended NSS BW (dot11VHTExtendedNSSBWCapable). This flag will be set if
2378*4882a593Smuzhiyun  *	the selected rate control algorithm sets %RATE_CTRL_CAPA_VHT_EXT_NSS_BW
2379*4882a593Smuzhiyun  *	but if the rate control is built-in then it must be set by the driver.
2380*4882a593Smuzhiyun  *	See also the documentation for that flag.
2381*4882a593Smuzhiyun  *
2382*4882a593Smuzhiyun  * @IEEE80211_HW_STA_MMPDU_TXQ: use the extra non-TID per-station TXQ for all
2383*4882a593Smuzhiyun  *	MMPDUs on station interfaces. This of course requires the driver to use
2384*4882a593Smuzhiyun  *	TXQs to start with.
2385*4882a593Smuzhiyun  *
2386*4882a593Smuzhiyun  * @IEEE80211_HW_TX_STATUS_NO_AMPDU_LEN: Driver does not report accurate A-MPDU
2387*4882a593Smuzhiyun  *	length in tx status information
2388*4882a593Smuzhiyun  *
2389*4882a593Smuzhiyun  * @IEEE80211_HW_SUPPORTS_MULTI_BSSID: Hardware supports multi BSSID
2390*4882a593Smuzhiyun  *
2391*4882a593Smuzhiyun  * @IEEE80211_HW_SUPPORTS_ONLY_HE_MULTI_BSSID: Hardware supports multi BSSID
2392*4882a593Smuzhiyun  *	only for HE APs. Applies if @IEEE80211_HW_SUPPORTS_MULTI_BSSID is set.
2393*4882a593Smuzhiyun  *
2394*4882a593Smuzhiyun  * @IEEE80211_HW_AMPDU_KEYBORDER_SUPPORT: The card and driver is only
2395*4882a593Smuzhiyun  *	aggregating MPDUs with the same keyid, allowing mac80211 to keep Tx
2396*4882a593Smuzhiyun  *	A-MPDU sessions active while rekeying with Extended Key ID.
2397*4882a593Smuzhiyun  *
2398*4882a593Smuzhiyun  * @IEEE80211_HW_SUPPORTS_TX_ENCAP_OFFLOAD: Hardware supports tx encapsulation
2399*4882a593Smuzhiyun  *	offload
2400*4882a593Smuzhiyun  *
2401*4882a593Smuzhiyun  * @NUM_IEEE80211_HW_FLAGS: number of hardware flags, used for sizing arrays
2402*4882a593Smuzhiyun  */
2403*4882a593Smuzhiyun enum ieee80211_hw_flags {
2404*4882a593Smuzhiyun 	IEEE80211_HW_HAS_RATE_CONTROL,
2405*4882a593Smuzhiyun 	IEEE80211_HW_RX_INCLUDES_FCS,
2406*4882a593Smuzhiyun 	IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING,
2407*4882a593Smuzhiyun 	IEEE80211_HW_SIGNAL_UNSPEC,
2408*4882a593Smuzhiyun 	IEEE80211_HW_SIGNAL_DBM,
2409*4882a593Smuzhiyun 	IEEE80211_HW_NEED_DTIM_BEFORE_ASSOC,
2410*4882a593Smuzhiyun 	IEEE80211_HW_SPECTRUM_MGMT,
2411*4882a593Smuzhiyun 	IEEE80211_HW_AMPDU_AGGREGATION,
2412*4882a593Smuzhiyun 	IEEE80211_HW_SUPPORTS_PS,
2413*4882a593Smuzhiyun 	IEEE80211_HW_PS_NULLFUNC_STACK,
2414*4882a593Smuzhiyun 	IEEE80211_HW_SUPPORTS_DYNAMIC_PS,
2415*4882a593Smuzhiyun 	IEEE80211_HW_MFP_CAPABLE,
2416*4882a593Smuzhiyun 	IEEE80211_HW_WANT_MONITOR_VIF,
2417*4882a593Smuzhiyun 	IEEE80211_HW_NO_AUTO_VIF,
2418*4882a593Smuzhiyun 	IEEE80211_HW_SW_CRYPTO_CONTROL,
2419*4882a593Smuzhiyun 	IEEE80211_HW_SUPPORT_FAST_XMIT,
2420*4882a593Smuzhiyun 	IEEE80211_HW_REPORTS_TX_ACK_STATUS,
2421*4882a593Smuzhiyun 	IEEE80211_HW_CONNECTION_MONITOR,
2422*4882a593Smuzhiyun 	IEEE80211_HW_QUEUE_CONTROL,
2423*4882a593Smuzhiyun 	IEEE80211_HW_SUPPORTS_PER_STA_GTK,
2424*4882a593Smuzhiyun 	IEEE80211_HW_AP_LINK_PS,
2425*4882a593Smuzhiyun 	IEEE80211_HW_TX_AMPDU_SETUP_IN_HW,
2426*4882a593Smuzhiyun 	IEEE80211_HW_SUPPORTS_RC_TABLE,
2427*4882a593Smuzhiyun 	IEEE80211_HW_P2P_DEV_ADDR_FOR_INTF,
2428*4882a593Smuzhiyun 	IEEE80211_HW_TIMING_BEACON_ONLY,
2429*4882a593Smuzhiyun 	IEEE80211_HW_SUPPORTS_HT_CCK_RATES,
2430*4882a593Smuzhiyun 	IEEE80211_HW_CHANCTX_STA_CSA,
2431*4882a593Smuzhiyun 	IEEE80211_HW_SUPPORTS_CLONED_SKBS,
2432*4882a593Smuzhiyun 	IEEE80211_HW_SINGLE_SCAN_ON_ALL_BANDS,
2433*4882a593Smuzhiyun 	IEEE80211_HW_TDLS_WIDER_BW,
2434*4882a593Smuzhiyun 	IEEE80211_HW_SUPPORTS_AMSDU_IN_AMPDU,
2435*4882a593Smuzhiyun 	IEEE80211_HW_BEACON_TX_STATUS,
2436*4882a593Smuzhiyun 	IEEE80211_HW_NEEDS_UNIQUE_STA_ADDR,
2437*4882a593Smuzhiyun 	IEEE80211_HW_SUPPORTS_REORDERING_BUFFER,
2438*4882a593Smuzhiyun 	IEEE80211_HW_USES_RSS,
2439*4882a593Smuzhiyun 	IEEE80211_HW_TX_AMSDU,
2440*4882a593Smuzhiyun 	IEEE80211_HW_TX_FRAG_LIST,
2441*4882a593Smuzhiyun 	IEEE80211_HW_REPORTS_LOW_ACK,
2442*4882a593Smuzhiyun 	IEEE80211_HW_SUPPORTS_TX_FRAG,
2443*4882a593Smuzhiyun 	IEEE80211_HW_SUPPORTS_TDLS_BUFFER_STA,
2444*4882a593Smuzhiyun 	IEEE80211_HW_DEAUTH_NEED_MGD_TX_PREP,
2445*4882a593Smuzhiyun 	IEEE80211_HW_DOESNT_SUPPORT_QOS_NDP,
2446*4882a593Smuzhiyun 	IEEE80211_HW_BUFF_MMPDU_TXQ,
2447*4882a593Smuzhiyun 	IEEE80211_HW_SUPPORTS_VHT_EXT_NSS_BW,
2448*4882a593Smuzhiyun 	IEEE80211_HW_STA_MMPDU_TXQ,
2449*4882a593Smuzhiyun 	IEEE80211_HW_TX_STATUS_NO_AMPDU_LEN,
2450*4882a593Smuzhiyun 	IEEE80211_HW_SUPPORTS_MULTI_BSSID,
2451*4882a593Smuzhiyun 	IEEE80211_HW_SUPPORTS_ONLY_HE_MULTI_BSSID,
2452*4882a593Smuzhiyun 	IEEE80211_HW_AMPDU_KEYBORDER_SUPPORT,
2453*4882a593Smuzhiyun 	IEEE80211_HW_SUPPORTS_TX_ENCAP_OFFLOAD,
2454*4882a593Smuzhiyun 
2455*4882a593Smuzhiyun 	/* keep last, obviously */
2456*4882a593Smuzhiyun 	NUM_IEEE80211_HW_FLAGS
2457*4882a593Smuzhiyun };
2458*4882a593Smuzhiyun 
2459*4882a593Smuzhiyun /**
2460*4882a593Smuzhiyun  * struct ieee80211_hw - hardware information and state
2461*4882a593Smuzhiyun  *
2462*4882a593Smuzhiyun  * This structure contains the configuration and hardware
2463*4882a593Smuzhiyun  * information for an 802.11 PHY.
2464*4882a593Smuzhiyun  *
2465*4882a593Smuzhiyun  * @wiphy: This points to the &struct wiphy allocated for this
2466*4882a593Smuzhiyun  *	802.11 PHY. You must fill in the @perm_addr and @dev
2467*4882a593Smuzhiyun  *	members of this structure using SET_IEEE80211_DEV()
2468*4882a593Smuzhiyun  *	and SET_IEEE80211_PERM_ADDR(). Additionally, all supported
2469*4882a593Smuzhiyun  *	bands (with channels, bitrates) are registered here.
2470*4882a593Smuzhiyun  *
2471*4882a593Smuzhiyun  * @conf: &struct ieee80211_conf, device configuration, don't use.
2472*4882a593Smuzhiyun  *
2473*4882a593Smuzhiyun  * @priv: pointer to private area that was allocated for driver use
2474*4882a593Smuzhiyun  *	along with this structure.
2475*4882a593Smuzhiyun  *
2476*4882a593Smuzhiyun  * @flags: hardware flags, see &enum ieee80211_hw_flags.
2477*4882a593Smuzhiyun  *
2478*4882a593Smuzhiyun  * @extra_tx_headroom: headroom to reserve in each transmit skb
2479*4882a593Smuzhiyun  *	for use by the driver (e.g. for transmit headers.)
2480*4882a593Smuzhiyun  *
2481*4882a593Smuzhiyun  * @extra_beacon_tailroom: tailroom to reserve in each beacon tx skb.
2482*4882a593Smuzhiyun  *	Can be used by drivers to add extra IEs.
2483*4882a593Smuzhiyun  *
2484*4882a593Smuzhiyun  * @max_signal: Maximum value for signal (rssi) in RX information, used
2485*4882a593Smuzhiyun  *	only when @IEEE80211_HW_SIGNAL_UNSPEC or @IEEE80211_HW_SIGNAL_DB
2486*4882a593Smuzhiyun  *
2487*4882a593Smuzhiyun  * @max_listen_interval: max listen interval in units of beacon interval
2488*4882a593Smuzhiyun  *	that HW supports
2489*4882a593Smuzhiyun  *
2490*4882a593Smuzhiyun  * @queues: number of available hardware transmit queues for
2491*4882a593Smuzhiyun  *	data packets. WMM/QoS requires at least four, these
2492*4882a593Smuzhiyun  *	queues need to have configurable access parameters.
2493*4882a593Smuzhiyun  *
2494*4882a593Smuzhiyun  * @rate_control_algorithm: rate control algorithm for this hardware.
2495*4882a593Smuzhiyun  *	If unset (NULL), the default algorithm will be used. Must be
2496*4882a593Smuzhiyun  *	set before calling ieee80211_register_hw().
2497*4882a593Smuzhiyun  *
2498*4882a593Smuzhiyun  * @vif_data_size: size (in bytes) of the drv_priv data area
2499*4882a593Smuzhiyun  *	within &struct ieee80211_vif.
2500*4882a593Smuzhiyun  * @sta_data_size: size (in bytes) of the drv_priv data area
2501*4882a593Smuzhiyun  *	within &struct ieee80211_sta.
2502*4882a593Smuzhiyun  * @chanctx_data_size: size (in bytes) of the drv_priv data area
2503*4882a593Smuzhiyun  *	within &struct ieee80211_chanctx_conf.
2504*4882a593Smuzhiyun  * @txq_data_size: size (in bytes) of the drv_priv data area
2505*4882a593Smuzhiyun  *	within @struct ieee80211_txq.
2506*4882a593Smuzhiyun  *
2507*4882a593Smuzhiyun  * @max_rates: maximum number of alternate rate retry stages the hw
2508*4882a593Smuzhiyun  *	can handle.
2509*4882a593Smuzhiyun  * @max_report_rates: maximum number of alternate rate retry stages
2510*4882a593Smuzhiyun  *	the hw can report back.
2511*4882a593Smuzhiyun  * @max_rate_tries: maximum number of tries for each stage
2512*4882a593Smuzhiyun  *
2513*4882a593Smuzhiyun  * @max_rx_aggregation_subframes: maximum buffer size (number of
2514*4882a593Smuzhiyun  *	sub-frames) to be used for A-MPDU block ack receiver
2515*4882a593Smuzhiyun  *	aggregation.
2516*4882a593Smuzhiyun  *	This is only relevant if the device has restrictions on the
2517*4882a593Smuzhiyun  *	number of subframes, if it relies on mac80211 to do reordering
2518*4882a593Smuzhiyun  *	it shouldn't be set.
2519*4882a593Smuzhiyun  *
2520*4882a593Smuzhiyun  * @max_tx_aggregation_subframes: maximum number of subframes in an
2521*4882a593Smuzhiyun  *	aggregate an HT/HE device will transmit. In HT AddBA we'll
2522*4882a593Smuzhiyun  *	advertise a constant value of 64 as some older APs crash if
2523*4882a593Smuzhiyun  *	the window size is smaller (an example is LinkSys WRT120N
2524*4882a593Smuzhiyun  *	with FW v1.0.07 build 002 Jun 18 2012).
2525*4882a593Smuzhiyun  *	For AddBA to HE capable peers this value will be used.
2526*4882a593Smuzhiyun  *
2527*4882a593Smuzhiyun  * @max_tx_fragments: maximum number of tx buffers per (A)-MSDU, sum
2528*4882a593Smuzhiyun  *	of 1 + skb_shinfo(skb)->nr_frags for each skb in the frag_list.
2529*4882a593Smuzhiyun  *
2530*4882a593Smuzhiyun  * @offchannel_tx_hw_queue: HW queue ID to use for offchannel TX
2531*4882a593Smuzhiyun  *	(if %IEEE80211_HW_QUEUE_CONTROL is set)
2532*4882a593Smuzhiyun  *
2533*4882a593Smuzhiyun  * @radiotap_mcs_details: lists which MCS information can the HW
2534*4882a593Smuzhiyun  *	reports, by default it is set to _MCS, _GI and _BW but doesn't
2535*4882a593Smuzhiyun  *	include _FMT. Use %IEEE80211_RADIOTAP_MCS_HAVE_\* values, only
2536*4882a593Smuzhiyun  *	adding _BW is supported today.
2537*4882a593Smuzhiyun  *
2538*4882a593Smuzhiyun  * @radiotap_vht_details: lists which VHT MCS information the HW reports,
2539*4882a593Smuzhiyun  *	the default is _GI | _BANDWIDTH.
2540*4882a593Smuzhiyun  *	Use the %IEEE80211_RADIOTAP_VHT_KNOWN_\* values.
2541*4882a593Smuzhiyun  *
2542*4882a593Smuzhiyun  * @radiotap_he: HE radiotap validity flags
2543*4882a593Smuzhiyun  *
2544*4882a593Smuzhiyun  * @radiotap_timestamp: Information for the radiotap timestamp field; if the
2545*4882a593Smuzhiyun  *	@units_pos member is set to a non-negative value then the timestamp
2546*4882a593Smuzhiyun  *	field will be added and populated from the &struct ieee80211_rx_status
2547*4882a593Smuzhiyun  *	device_timestamp.
2548*4882a593Smuzhiyun  * @radiotap_timestamp.units_pos: Must be set to a combination of a
2549*4882a593Smuzhiyun  *	IEEE80211_RADIOTAP_TIMESTAMP_UNIT_* and a
2550*4882a593Smuzhiyun  *	IEEE80211_RADIOTAP_TIMESTAMP_SPOS_* value.
2551*4882a593Smuzhiyun  * @radiotap_timestamp.accuracy: If non-negative, fills the accuracy in the
2552*4882a593Smuzhiyun  *	radiotap field and the accuracy known flag will be set.
2553*4882a593Smuzhiyun  *
2554*4882a593Smuzhiyun  * @netdev_features: netdev features to be set in each netdev created
2555*4882a593Smuzhiyun  *	from this HW. Note that not all features are usable with mac80211,
2556*4882a593Smuzhiyun  *	other features will be rejected during HW registration.
2557*4882a593Smuzhiyun  *
2558*4882a593Smuzhiyun  * @uapsd_queues: This bitmap is included in (re)association frame to indicate
2559*4882a593Smuzhiyun  *	for each access category if it is uAPSD trigger-enabled and delivery-
2560*4882a593Smuzhiyun  *	enabled. Use IEEE80211_WMM_IE_STA_QOSINFO_AC_* to set this bitmap.
2561*4882a593Smuzhiyun  *	Each bit corresponds to different AC. Value '1' in specific bit means
2562*4882a593Smuzhiyun  *	that corresponding AC is both trigger- and delivery-enabled. '0' means
2563*4882a593Smuzhiyun  *	neither enabled.
2564*4882a593Smuzhiyun  *
2565*4882a593Smuzhiyun  * @uapsd_max_sp_len: maximum number of total buffered frames the WMM AP may
2566*4882a593Smuzhiyun  *	deliver to a WMM STA during any Service Period triggered by the WMM STA.
2567*4882a593Smuzhiyun  *	Use IEEE80211_WMM_IE_STA_QOSINFO_SP_* for correct values.
2568*4882a593Smuzhiyun  *
2569*4882a593Smuzhiyun  * @n_cipher_schemes: a size of an array of cipher schemes definitions.
2570*4882a593Smuzhiyun  * @cipher_schemes: a pointer to an array of cipher scheme definitions
2571*4882a593Smuzhiyun  *	supported by HW.
2572*4882a593Smuzhiyun  * @max_nan_de_entries: maximum number of NAN DE functions supported by the
2573*4882a593Smuzhiyun  *	device.
2574*4882a593Smuzhiyun  *
2575*4882a593Smuzhiyun  * @tx_sk_pacing_shift: Pacing shift to set on TCP sockets when frames from
2576*4882a593Smuzhiyun  *	them are encountered. The default should typically not be changed,
2577*4882a593Smuzhiyun  *	unless the driver has good reasons for needing more buffers.
2578*4882a593Smuzhiyun  *
2579*4882a593Smuzhiyun  * @weight_multiplier: Driver specific airtime weight multiplier used while
2580*4882a593Smuzhiyun  *	refilling deficit of each TXQ.
2581*4882a593Smuzhiyun  *
2582*4882a593Smuzhiyun  * @max_mtu: the max mtu could be set.
2583*4882a593Smuzhiyun  */
2584*4882a593Smuzhiyun struct ieee80211_hw {
2585*4882a593Smuzhiyun 	struct ieee80211_conf conf;
2586*4882a593Smuzhiyun 	struct wiphy *wiphy;
2587*4882a593Smuzhiyun 	const char *rate_control_algorithm;
2588*4882a593Smuzhiyun 	void *priv;
2589*4882a593Smuzhiyun 	unsigned long flags[BITS_TO_LONGS(NUM_IEEE80211_HW_FLAGS)];
2590*4882a593Smuzhiyun 	unsigned int extra_tx_headroom;
2591*4882a593Smuzhiyun 	unsigned int extra_beacon_tailroom;
2592*4882a593Smuzhiyun 	int vif_data_size;
2593*4882a593Smuzhiyun 	int sta_data_size;
2594*4882a593Smuzhiyun 	int chanctx_data_size;
2595*4882a593Smuzhiyun 	int txq_data_size;
2596*4882a593Smuzhiyun 	u16 queues;
2597*4882a593Smuzhiyun 	u16 max_listen_interval;
2598*4882a593Smuzhiyun 	s8 max_signal;
2599*4882a593Smuzhiyun 	u8 max_rates;
2600*4882a593Smuzhiyun 	u8 max_report_rates;
2601*4882a593Smuzhiyun 	u8 max_rate_tries;
2602*4882a593Smuzhiyun 	u16 max_rx_aggregation_subframes;
2603*4882a593Smuzhiyun 	u16 max_tx_aggregation_subframes;
2604*4882a593Smuzhiyun 	u8 max_tx_fragments;
2605*4882a593Smuzhiyun 	u8 offchannel_tx_hw_queue;
2606*4882a593Smuzhiyun 	u8 radiotap_mcs_details;
2607*4882a593Smuzhiyun 	u16 radiotap_vht_details;
2608*4882a593Smuzhiyun 	struct {
2609*4882a593Smuzhiyun 		int units_pos;
2610*4882a593Smuzhiyun 		s16 accuracy;
2611*4882a593Smuzhiyun 	} radiotap_timestamp;
2612*4882a593Smuzhiyun 	netdev_features_t netdev_features;
2613*4882a593Smuzhiyun 	u8 uapsd_queues;
2614*4882a593Smuzhiyun 	u8 uapsd_max_sp_len;
2615*4882a593Smuzhiyun 	u8 n_cipher_schemes;
2616*4882a593Smuzhiyun 	const struct ieee80211_cipher_scheme *cipher_schemes;
2617*4882a593Smuzhiyun 	u8 max_nan_de_entries;
2618*4882a593Smuzhiyun 	u8 tx_sk_pacing_shift;
2619*4882a593Smuzhiyun 	u8 weight_multiplier;
2620*4882a593Smuzhiyun 	u32 max_mtu;
2621*4882a593Smuzhiyun 
2622*4882a593Smuzhiyun 	ANDROID_KABI_RESERVE(1);
2623*4882a593Smuzhiyun };
2624*4882a593Smuzhiyun 
_ieee80211_hw_check(struct ieee80211_hw * hw,enum ieee80211_hw_flags flg)2625*4882a593Smuzhiyun static inline bool _ieee80211_hw_check(struct ieee80211_hw *hw,
2626*4882a593Smuzhiyun 				       enum ieee80211_hw_flags flg)
2627*4882a593Smuzhiyun {
2628*4882a593Smuzhiyun 	return test_bit(flg, hw->flags);
2629*4882a593Smuzhiyun }
2630*4882a593Smuzhiyun #define ieee80211_hw_check(hw, flg)	_ieee80211_hw_check(hw, IEEE80211_HW_##flg)
2631*4882a593Smuzhiyun 
_ieee80211_hw_set(struct ieee80211_hw * hw,enum ieee80211_hw_flags flg)2632*4882a593Smuzhiyun static inline void _ieee80211_hw_set(struct ieee80211_hw *hw,
2633*4882a593Smuzhiyun 				     enum ieee80211_hw_flags flg)
2634*4882a593Smuzhiyun {
2635*4882a593Smuzhiyun 	return __set_bit(flg, hw->flags);
2636*4882a593Smuzhiyun }
2637*4882a593Smuzhiyun #define ieee80211_hw_set(hw, flg)	_ieee80211_hw_set(hw, IEEE80211_HW_##flg)
2638*4882a593Smuzhiyun 
2639*4882a593Smuzhiyun /**
2640*4882a593Smuzhiyun  * struct ieee80211_scan_request - hw scan request
2641*4882a593Smuzhiyun  *
2642*4882a593Smuzhiyun  * @ies: pointers different parts of IEs (in req.ie)
2643*4882a593Smuzhiyun  * @req: cfg80211 request.
2644*4882a593Smuzhiyun  */
2645*4882a593Smuzhiyun struct ieee80211_scan_request {
2646*4882a593Smuzhiyun 	struct ieee80211_scan_ies ies;
2647*4882a593Smuzhiyun 
2648*4882a593Smuzhiyun 	/* Keep last */
2649*4882a593Smuzhiyun 	struct cfg80211_scan_request req;
2650*4882a593Smuzhiyun };
2651*4882a593Smuzhiyun 
2652*4882a593Smuzhiyun /**
2653*4882a593Smuzhiyun  * struct ieee80211_tdls_ch_sw_params - TDLS channel switch parameters
2654*4882a593Smuzhiyun  *
2655*4882a593Smuzhiyun  * @sta: peer this TDLS channel-switch request/response came from
2656*4882a593Smuzhiyun  * @chandef: channel referenced in a TDLS channel-switch request
2657*4882a593Smuzhiyun  * @action_code: see &enum ieee80211_tdls_actioncode
2658*4882a593Smuzhiyun  * @status: channel-switch response status
2659*4882a593Smuzhiyun  * @timestamp: time at which the frame was received
2660*4882a593Smuzhiyun  * @switch_time: switch-timing parameter received in the frame
2661*4882a593Smuzhiyun  * @switch_timeout: switch-timing parameter received in the frame
2662*4882a593Smuzhiyun  * @tmpl_skb: TDLS switch-channel response template
2663*4882a593Smuzhiyun  * @ch_sw_tm_ie: offset of the channel-switch timing IE inside @tmpl_skb
2664*4882a593Smuzhiyun  */
2665*4882a593Smuzhiyun struct ieee80211_tdls_ch_sw_params {
2666*4882a593Smuzhiyun 	struct ieee80211_sta *sta;
2667*4882a593Smuzhiyun 	struct cfg80211_chan_def *chandef;
2668*4882a593Smuzhiyun 	u8 action_code;
2669*4882a593Smuzhiyun 	u32 status;
2670*4882a593Smuzhiyun 	u32 timestamp;
2671*4882a593Smuzhiyun 	u16 switch_time;
2672*4882a593Smuzhiyun 	u16 switch_timeout;
2673*4882a593Smuzhiyun 	struct sk_buff *tmpl_skb;
2674*4882a593Smuzhiyun 	u32 ch_sw_tm_ie;
2675*4882a593Smuzhiyun };
2676*4882a593Smuzhiyun 
2677*4882a593Smuzhiyun /**
2678*4882a593Smuzhiyun  * wiphy_to_ieee80211_hw - return a mac80211 driver hw struct from a wiphy
2679*4882a593Smuzhiyun  *
2680*4882a593Smuzhiyun  * @wiphy: the &struct wiphy which we want to query
2681*4882a593Smuzhiyun  *
2682*4882a593Smuzhiyun  * mac80211 drivers can use this to get to their respective
2683*4882a593Smuzhiyun  * &struct ieee80211_hw. Drivers wishing to get to their own private
2684*4882a593Smuzhiyun  * structure can then access it via hw->priv. Note that mac802111 drivers should
2685*4882a593Smuzhiyun  * not use wiphy_priv() to try to get their private driver structure as this
2686*4882a593Smuzhiyun  * is already used internally by mac80211.
2687*4882a593Smuzhiyun  *
2688*4882a593Smuzhiyun  * Return: The mac80211 driver hw struct of @wiphy.
2689*4882a593Smuzhiyun  */
2690*4882a593Smuzhiyun struct ieee80211_hw *wiphy_to_ieee80211_hw(struct wiphy *wiphy);
2691*4882a593Smuzhiyun 
2692*4882a593Smuzhiyun /**
2693*4882a593Smuzhiyun  * SET_IEEE80211_DEV - set device for 802.11 hardware
2694*4882a593Smuzhiyun  *
2695*4882a593Smuzhiyun  * @hw: the &struct ieee80211_hw to set the device for
2696*4882a593Smuzhiyun  * @dev: the &struct device of this 802.11 device
2697*4882a593Smuzhiyun  */
SET_IEEE80211_DEV(struct ieee80211_hw * hw,struct device * dev)2698*4882a593Smuzhiyun static inline void SET_IEEE80211_DEV(struct ieee80211_hw *hw, struct device *dev)
2699*4882a593Smuzhiyun {
2700*4882a593Smuzhiyun 	set_wiphy_dev(hw->wiphy, dev);
2701*4882a593Smuzhiyun }
2702*4882a593Smuzhiyun 
2703*4882a593Smuzhiyun /**
2704*4882a593Smuzhiyun  * SET_IEEE80211_PERM_ADDR - set the permanent MAC address for 802.11 hardware
2705*4882a593Smuzhiyun  *
2706*4882a593Smuzhiyun  * @hw: the &struct ieee80211_hw to set the MAC address for
2707*4882a593Smuzhiyun  * @addr: the address to set
2708*4882a593Smuzhiyun  */
SET_IEEE80211_PERM_ADDR(struct ieee80211_hw * hw,const u8 * addr)2709*4882a593Smuzhiyun static inline void SET_IEEE80211_PERM_ADDR(struct ieee80211_hw *hw, const u8 *addr)
2710*4882a593Smuzhiyun {
2711*4882a593Smuzhiyun 	memcpy(hw->wiphy->perm_addr, addr, ETH_ALEN);
2712*4882a593Smuzhiyun }
2713*4882a593Smuzhiyun 
2714*4882a593Smuzhiyun static inline struct ieee80211_rate *
ieee80211_get_tx_rate(const struct ieee80211_hw * hw,const struct ieee80211_tx_info * c)2715*4882a593Smuzhiyun ieee80211_get_tx_rate(const struct ieee80211_hw *hw,
2716*4882a593Smuzhiyun 		      const struct ieee80211_tx_info *c)
2717*4882a593Smuzhiyun {
2718*4882a593Smuzhiyun 	if (WARN_ON_ONCE(c->control.rates[0].idx < 0))
2719*4882a593Smuzhiyun 		return NULL;
2720*4882a593Smuzhiyun 	return &hw->wiphy->bands[c->band]->bitrates[c->control.rates[0].idx];
2721*4882a593Smuzhiyun }
2722*4882a593Smuzhiyun 
2723*4882a593Smuzhiyun static inline struct ieee80211_rate *
ieee80211_get_rts_cts_rate(const struct ieee80211_hw * hw,const struct ieee80211_tx_info * c)2724*4882a593Smuzhiyun ieee80211_get_rts_cts_rate(const struct ieee80211_hw *hw,
2725*4882a593Smuzhiyun 			   const struct ieee80211_tx_info *c)
2726*4882a593Smuzhiyun {
2727*4882a593Smuzhiyun 	if (c->control.rts_cts_rate_idx < 0)
2728*4882a593Smuzhiyun 		return NULL;
2729*4882a593Smuzhiyun 	return &hw->wiphy->bands[c->band]->bitrates[c->control.rts_cts_rate_idx];
2730*4882a593Smuzhiyun }
2731*4882a593Smuzhiyun 
2732*4882a593Smuzhiyun static inline struct ieee80211_rate *
ieee80211_get_alt_retry_rate(const struct ieee80211_hw * hw,const struct ieee80211_tx_info * c,int idx)2733*4882a593Smuzhiyun ieee80211_get_alt_retry_rate(const struct ieee80211_hw *hw,
2734*4882a593Smuzhiyun 			     const struct ieee80211_tx_info *c, int idx)
2735*4882a593Smuzhiyun {
2736*4882a593Smuzhiyun 	if (c->control.rates[idx + 1].idx < 0)
2737*4882a593Smuzhiyun 		return NULL;
2738*4882a593Smuzhiyun 	return &hw->wiphy->bands[c->band]->bitrates[c->control.rates[idx + 1].idx];
2739*4882a593Smuzhiyun }
2740*4882a593Smuzhiyun 
2741*4882a593Smuzhiyun /**
2742*4882a593Smuzhiyun  * ieee80211_free_txskb - free TX skb
2743*4882a593Smuzhiyun  * @hw: the hardware
2744*4882a593Smuzhiyun  * @skb: the skb
2745*4882a593Smuzhiyun  *
2746*4882a593Smuzhiyun  * Free a transmit skb. Use this function when some failure
2747*4882a593Smuzhiyun  * to transmit happened and thus status cannot be reported.
2748*4882a593Smuzhiyun  */
2749*4882a593Smuzhiyun void ieee80211_free_txskb(struct ieee80211_hw *hw, struct sk_buff *skb);
2750*4882a593Smuzhiyun 
2751*4882a593Smuzhiyun /**
2752*4882a593Smuzhiyun  * DOC: Hardware crypto acceleration
2753*4882a593Smuzhiyun  *
2754*4882a593Smuzhiyun  * mac80211 is capable of taking advantage of many hardware
2755*4882a593Smuzhiyun  * acceleration designs for encryption and decryption operations.
2756*4882a593Smuzhiyun  *
2757*4882a593Smuzhiyun  * The set_key() callback in the &struct ieee80211_ops for a given
2758*4882a593Smuzhiyun  * device is called to enable hardware acceleration of encryption and
2759*4882a593Smuzhiyun  * decryption. The callback takes a @sta parameter that will be NULL
2760*4882a593Smuzhiyun  * for default keys or keys used for transmission only, or point to
2761*4882a593Smuzhiyun  * the station information for the peer for individual keys.
2762*4882a593Smuzhiyun  * Multiple transmission keys with the same key index may be used when
2763*4882a593Smuzhiyun  * VLANs are configured for an access point.
2764*4882a593Smuzhiyun  *
2765*4882a593Smuzhiyun  * When transmitting, the TX control data will use the @hw_key_idx
2766*4882a593Smuzhiyun  * selected by the driver by modifying the &struct ieee80211_key_conf
2767*4882a593Smuzhiyun  * pointed to by the @key parameter to the set_key() function.
2768*4882a593Smuzhiyun  *
2769*4882a593Smuzhiyun  * The set_key() call for the %SET_KEY command should return 0 if
2770*4882a593Smuzhiyun  * the key is now in use, -%EOPNOTSUPP or -%ENOSPC if it couldn't be
2771*4882a593Smuzhiyun  * added; if you return 0 then hw_key_idx must be assigned to the
2772*4882a593Smuzhiyun  * hardware key index, you are free to use the full u8 range.
2773*4882a593Smuzhiyun  *
2774*4882a593Smuzhiyun  * Note that in the case that the @IEEE80211_HW_SW_CRYPTO_CONTROL flag is
2775*4882a593Smuzhiyun  * set, mac80211 will not automatically fall back to software crypto if
2776*4882a593Smuzhiyun  * enabling hardware crypto failed. The set_key() call may also return the
2777*4882a593Smuzhiyun  * value 1 to permit this specific key/algorithm to be done in software.
2778*4882a593Smuzhiyun  *
2779*4882a593Smuzhiyun  * When the cmd is %DISABLE_KEY then it must succeed.
2780*4882a593Smuzhiyun  *
2781*4882a593Smuzhiyun  * Note that it is permissible to not decrypt a frame even if a key
2782*4882a593Smuzhiyun  * for it has been uploaded to hardware, the stack will not make any
2783*4882a593Smuzhiyun  * decision based on whether a key has been uploaded or not but rather
2784*4882a593Smuzhiyun  * based on the receive flags.
2785*4882a593Smuzhiyun  *
2786*4882a593Smuzhiyun  * The &struct ieee80211_key_conf structure pointed to by the @key
2787*4882a593Smuzhiyun  * parameter is guaranteed to be valid until another call to set_key()
2788*4882a593Smuzhiyun  * removes it, but it can only be used as a cookie to differentiate
2789*4882a593Smuzhiyun  * keys.
2790*4882a593Smuzhiyun  *
2791*4882a593Smuzhiyun  * In TKIP some HW need to be provided a phase 1 key, for RX decryption
2792*4882a593Smuzhiyun  * acceleration (i.e. iwlwifi). Those drivers should provide update_tkip_key
2793*4882a593Smuzhiyun  * handler.
2794*4882a593Smuzhiyun  * The update_tkip_key() call updates the driver with the new phase 1 key.
2795*4882a593Smuzhiyun  * This happens every time the iv16 wraps around (every 65536 packets). The
2796*4882a593Smuzhiyun  * set_key() call will happen only once for each key (unless the AP did
2797*4882a593Smuzhiyun  * rekeying), it will not include a valid phase 1 key. The valid phase 1 key is
2798*4882a593Smuzhiyun  * provided by update_tkip_key only. The trigger that makes mac80211 call this
2799*4882a593Smuzhiyun  * handler is software decryption with wrap around of iv16.
2800*4882a593Smuzhiyun  *
2801*4882a593Smuzhiyun  * The set_default_unicast_key() call updates the default WEP key index
2802*4882a593Smuzhiyun  * configured to the hardware for WEP encryption type. This is required
2803*4882a593Smuzhiyun  * for devices that support offload of data packets (e.g. ARP responses).
2804*4882a593Smuzhiyun  *
2805*4882a593Smuzhiyun  * Mac80211 drivers should set the @NL80211_EXT_FEATURE_CAN_REPLACE_PTK0 flag
2806*4882a593Smuzhiyun  * when they are able to replace in-use PTK keys according to the following
2807*4882a593Smuzhiyun  * requirements:
2808*4882a593Smuzhiyun  * 1) They do not hand over frames decrypted with the old key to
2809*4882a593Smuzhiyun       mac80211 once the call to set_key() with command %DISABLE_KEY has been
2810*4882a593Smuzhiyun       completed when also setting @IEEE80211_KEY_FLAG_GENERATE_IV for any key,
2811*4882a593Smuzhiyun    2) either drop or continue to use the old key for any outgoing frames queued
2812*4882a593Smuzhiyun       at the time of the key deletion (including re-transmits),
2813*4882a593Smuzhiyun    3) never send out a frame queued prior to the set_key() %SET_KEY command
2814*4882a593Smuzhiyun       encrypted with the new key and
2815*4882a593Smuzhiyun    4) never send out a frame unencrypted when it should be encrypted.
2816*4882a593Smuzhiyun    Mac80211 will not queue any new frames for a deleted key to the driver.
2817*4882a593Smuzhiyun  */
2818*4882a593Smuzhiyun 
2819*4882a593Smuzhiyun /**
2820*4882a593Smuzhiyun  * DOC: Powersave support
2821*4882a593Smuzhiyun  *
2822*4882a593Smuzhiyun  * mac80211 has support for various powersave implementations.
2823*4882a593Smuzhiyun  *
2824*4882a593Smuzhiyun  * First, it can support hardware that handles all powersaving by itself,
2825*4882a593Smuzhiyun  * such hardware should simply set the %IEEE80211_HW_SUPPORTS_PS hardware
2826*4882a593Smuzhiyun  * flag. In that case, it will be told about the desired powersave mode
2827*4882a593Smuzhiyun  * with the %IEEE80211_CONF_PS flag depending on the association status.
2828*4882a593Smuzhiyun  * The hardware must take care of sending nullfunc frames when necessary,
2829*4882a593Smuzhiyun  * i.e. when entering and leaving powersave mode. The hardware is required
2830*4882a593Smuzhiyun  * to look at the AID in beacons and signal to the AP that it woke up when
2831*4882a593Smuzhiyun  * it finds traffic directed to it.
2832*4882a593Smuzhiyun  *
2833*4882a593Smuzhiyun  * %IEEE80211_CONF_PS flag enabled means that the powersave mode defined in
2834*4882a593Smuzhiyun  * IEEE 802.11-2007 section 11.2 is enabled. This is not to be confused
2835*4882a593Smuzhiyun  * with hardware wakeup and sleep states. Driver is responsible for waking
2836*4882a593Smuzhiyun  * up the hardware before issuing commands to the hardware and putting it
2837*4882a593Smuzhiyun  * back to sleep at appropriate times.
2838*4882a593Smuzhiyun  *
2839*4882a593Smuzhiyun  * When PS is enabled, hardware needs to wakeup for beacons and receive the
2840*4882a593Smuzhiyun  * buffered multicast/broadcast frames after the beacon. Also it must be
2841*4882a593Smuzhiyun  * possible to send frames and receive the acknowledment frame.
2842*4882a593Smuzhiyun  *
2843*4882a593Smuzhiyun  * Other hardware designs cannot send nullfunc frames by themselves and also
2844*4882a593Smuzhiyun  * need software support for parsing the TIM bitmap. This is also supported
2845*4882a593Smuzhiyun  * by mac80211 by combining the %IEEE80211_HW_SUPPORTS_PS and
2846*4882a593Smuzhiyun  * %IEEE80211_HW_PS_NULLFUNC_STACK flags. The hardware is of course still
2847*4882a593Smuzhiyun  * required to pass up beacons. The hardware is still required to handle
2848*4882a593Smuzhiyun  * waking up for multicast traffic; if it cannot the driver must handle that
2849*4882a593Smuzhiyun  * as best as it can, mac80211 is too slow to do that.
2850*4882a593Smuzhiyun  *
2851*4882a593Smuzhiyun  * Dynamic powersave is an extension to normal powersave in which the
2852*4882a593Smuzhiyun  * hardware stays awake for a user-specified period of time after sending a
2853*4882a593Smuzhiyun  * frame so that reply frames need not be buffered and therefore delayed to
2854*4882a593Smuzhiyun  * the next wakeup. It's compromise of getting good enough latency when
2855*4882a593Smuzhiyun  * there's data traffic and still saving significantly power in idle
2856*4882a593Smuzhiyun  * periods.
2857*4882a593Smuzhiyun  *
2858*4882a593Smuzhiyun  * Dynamic powersave is simply supported by mac80211 enabling and disabling
2859*4882a593Smuzhiyun  * PS based on traffic. Driver needs to only set %IEEE80211_HW_SUPPORTS_PS
2860*4882a593Smuzhiyun  * flag and mac80211 will handle everything automatically. Additionally,
2861*4882a593Smuzhiyun  * hardware having support for the dynamic PS feature may set the
2862*4882a593Smuzhiyun  * %IEEE80211_HW_SUPPORTS_DYNAMIC_PS flag to indicate that it can support
2863*4882a593Smuzhiyun  * dynamic PS mode itself. The driver needs to look at the
2864*4882a593Smuzhiyun  * @dynamic_ps_timeout hardware configuration value and use it that value
2865*4882a593Smuzhiyun  * whenever %IEEE80211_CONF_PS is set. In this case mac80211 will disable
2866*4882a593Smuzhiyun  * dynamic PS feature in stack and will just keep %IEEE80211_CONF_PS
2867*4882a593Smuzhiyun  * enabled whenever user has enabled powersave.
2868*4882a593Smuzhiyun  *
2869*4882a593Smuzhiyun  * Driver informs U-APSD client support by enabling
2870*4882a593Smuzhiyun  * %IEEE80211_VIF_SUPPORTS_UAPSD flag. The mode is configured through the
2871*4882a593Smuzhiyun  * uapsd parameter in conf_tx() operation. Hardware needs to send the QoS
2872*4882a593Smuzhiyun  * Nullfunc frames and stay awake until the service period has ended. To
2873*4882a593Smuzhiyun  * utilize U-APSD, dynamic powersave is disabled for voip AC and all frames
2874*4882a593Smuzhiyun  * from that AC are transmitted with powersave enabled.
2875*4882a593Smuzhiyun  *
2876*4882a593Smuzhiyun  * Note: U-APSD client mode is not yet supported with
2877*4882a593Smuzhiyun  * %IEEE80211_HW_PS_NULLFUNC_STACK.
2878*4882a593Smuzhiyun  */
2879*4882a593Smuzhiyun 
2880*4882a593Smuzhiyun /**
2881*4882a593Smuzhiyun  * DOC: Beacon filter support
2882*4882a593Smuzhiyun  *
2883*4882a593Smuzhiyun  * Some hardware have beacon filter support to reduce host cpu wakeups
2884*4882a593Smuzhiyun  * which will reduce system power consumption. It usually works so that
2885*4882a593Smuzhiyun  * the firmware creates a checksum of the beacon but omits all constantly
2886*4882a593Smuzhiyun  * changing elements (TSF, TIM etc). Whenever the checksum changes the
2887*4882a593Smuzhiyun  * beacon is forwarded to the host, otherwise it will be just dropped. That
2888*4882a593Smuzhiyun  * way the host will only receive beacons where some relevant information
2889*4882a593Smuzhiyun  * (for example ERP protection or WMM settings) have changed.
2890*4882a593Smuzhiyun  *
2891*4882a593Smuzhiyun  * Beacon filter support is advertised with the %IEEE80211_VIF_BEACON_FILTER
2892*4882a593Smuzhiyun  * interface capability. The driver needs to enable beacon filter support
2893*4882a593Smuzhiyun  * whenever power save is enabled, that is %IEEE80211_CONF_PS is set. When
2894*4882a593Smuzhiyun  * power save is enabled, the stack will not check for beacon loss and the
2895*4882a593Smuzhiyun  * driver needs to notify about loss of beacons with ieee80211_beacon_loss().
2896*4882a593Smuzhiyun  *
2897*4882a593Smuzhiyun  * The time (or number of beacons missed) until the firmware notifies the
2898*4882a593Smuzhiyun  * driver of a beacon loss event (which in turn causes the driver to call
2899*4882a593Smuzhiyun  * ieee80211_beacon_loss()) should be configurable and will be controlled
2900*4882a593Smuzhiyun  * by mac80211 and the roaming algorithm in the future.
2901*4882a593Smuzhiyun  *
2902*4882a593Smuzhiyun  * Since there may be constantly changing information elements that nothing
2903*4882a593Smuzhiyun  * in the software stack cares about, we will, in the future, have mac80211
2904*4882a593Smuzhiyun  * tell the driver which information elements are interesting in the sense
2905*4882a593Smuzhiyun  * that we want to see changes in them. This will include
2906*4882a593Smuzhiyun  *
2907*4882a593Smuzhiyun  *  - a list of information element IDs
2908*4882a593Smuzhiyun  *  - a list of OUIs for the vendor information element
2909*4882a593Smuzhiyun  *
2910*4882a593Smuzhiyun  * Ideally, the hardware would filter out any beacons without changes in the
2911*4882a593Smuzhiyun  * requested elements, but if it cannot support that it may, at the expense
2912*4882a593Smuzhiyun  * of some efficiency, filter out only a subset. For example, if the device
2913*4882a593Smuzhiyun  * doesn't support checking for OUIs it should pass up all changes in all
2914*4882a593Smuzhiyun  * vendor information elements.
2915*4882a593Smuzhiyun  *
2916*4882a593Smuzhiyun  * Note that change, for the sake of simplification, also includes information
2917*4882a593Smuzhiyun  * elements appearing or disappearing from the beacon.
2918*4882a593Smuzhiyun  *
2919*4882a593Smuzhiyun  * Some hardware supports an "ignore list" instead, just make sure nothing
2920*4882a593Smuzhiyun  * that was requested is on the ignore list, and include commonly changing
2921*4882a593Smuzhiyun  * information element IDs in the ignore list, for example 11 (BSS load) and
2922*4882a593Smuzhiyun  * the various vendor-assigned IEs with unknown contents (128, 129, 133-136,
2923*4882a593Smuzhiyun  * 149, 150, 155, 156, 173, 176, 178, 179, 219); for forward compatibility
2924*4882a593Smuzhiyun  * it could also include some currently unused IDs.
2925*4882a593Smuzhiyun  *
2926*4882a593Smuzhiyun  *
2927*4882a593Smuzhiyun  * In addition to these capabilities, hardware should support notifying the
2928*4882a593Smuzhiyun  * host of changes in the beacon RSSI. This is relevant to implement roaming
2929*4882a593Smuzhiyun  * when no traffic is flowing (when traffic is flowing we see the RSSI of
2930*4882a593Smuzhiyun  * the received data packets). This can consist in notifying the host when
2931*4882a593Smuzhiyun  * the RSSI changes significantly or when it drops below or rises above
2932*4882a593Smuzhiyun  * configurable thresholds. In the future these thresholds will also be
2933*4882a593Smuzhiyun  * configured by mac80211 (which gets them from userspace) to implement
2934*4882a593Smuzhiyun  * them as the roaming algorithm requires.
2935*4882a593Smuzhiyun  *
2936*4882a593Smuzhiyun  * If the hardware cannot implement this, the driver should ask it to
2937*4882a593Smuzhiyun  * periodically pass beacon frames to the host so that software can do the
2938*4882a593Smuzhiyun  * signal strength threshold checking.
2939*4882a593Smuzhiyun  */
2940*4882a593Smuzhiyun 
2941*4882a593Smuzhiyun /**
2942*4882a593Smuzhiyun  * DOC: Spatial multiplexing power save
2943*4882a593Smuzhiyun  *
2944*4882a593Smuzhiyun  * SMPS (Spatial multiplexing power save) is a mechanism to conserve
2945*4882a593Smuzhiyun  * power in an 802.11n implementation. For details on the mechanism
2946*4882a593Smuzhiyun  * and rationale, please refer to 802.11 (as amended by 802.11n-2009)
2947*4882a593Smuzhiyun  * "11.2.3 SM power save".
2948*4882a593Smuzhiyun  *
2949*4882a593Smuzhiyun  * The mac80211 implementation is capable of sending action frames
2950*4882a593Smuzhiyun  * to update the AP about the station's SMPS mode, and will instruct
2951*4882a593Smuzhiyun  * the driver to enter the specific mode. It will also announce the
2952*4882a593Smuzhiyun  * requested SMPS mode during the association handshake. Hardware
2953*4882a593Smuzhiyun  * support for this feature is required, and can be indicated by
2954*4882a593Smuzhiyun  * hardware flags.
2955*4882a593Smuzhiyun  *
2956*4882a593Smuzhiyun  * The default mode will be "automatic", which nl80211/cfg80211
2957*4882a593Smuzhiyun  * defines to be dynamic SMPS in (regular) powersave, and SMPS
2958*4882a593Smuzhiyun  * turned off otherwise.
2959*4882a593Smuzhiyun  *
2960*4882a593Smuzhiyun  * To support this feature, the driver must set the appropriate
2961*4882a593Smuzhiyun  * hardware support flags, and handle the SMPS flag to the config()
2962*4882a593Smuzhiyun  * operation. It will then with this mechanism be instructed to
2963*4882a593Smuzhiyun  * enter the requested SMPS mode while associated to an HT AP.
2964*4882a593Smuzhiyun  */
2965*4882a593Smuzhiyun 
2966*4882a593Smuzhiyun /**
2967*4882a593Smuzhiyun  * DOC: Frame filtering
2968*4882a593Smuzhiyun  *
2969*4882a593Smuzhiyun  * mac80211 requires to see many management frames for proper
2970*4882a593Smuzhiyun  * operation, and users may want to see many more frames when
2971*4882a593Smuzhiyun  * in monitor mode. However, for best CPU usage and power consumption,
2972*4882a593Smuzhiyun  * having as few frames as possible percolate through the stack is
2973*4882a593Smuzhiyun  * desirable. Hence, the hardware should filter as much as possible.
2974*4882a593Smuzhiyun  *
2975*4882a593Smuzhiyun  * To achieve this, mac80211 uses filter flags (see below) to tell
2976*4882a593Smuzhiyun  * the driver's configure_filter() function which frames should be
2977*4882a593Smuzhiyun  * passed to mac80211 and which should be filtered out.
2978*4882a593Smuzhiyun  *
2979*4882a593Smuzhiyun  * Before configure_filter() is invoked, the prepare_multicast()
2980*4882a593Smuzhiyun  * callback is invoked with the parameters @mc_count and @mc_list
2981*4882a593Smuzhiyun  * for the combined multicast address list of all virtual interfaces.
2982*4882a593Smuzhiyun  * It's use is optional, and it returns a u64 that is passed to
2983*4882a593Smuzhiyun  * configure_filter(). Additionally, configure_filter() has the
2984*4882a593Smuzhiyun  * arguments @changed_flags telling which flags were changed and
2985*4882a593Smuzhiyun  * @total_flags with the new flag states.
2986*4882a593Smuzhiyun  *
2987*4882a593Smuzhiyun  * If your device has no multicast address filters your driver will
2988*4882a593Smuzhiyun  * need to check both the %FIF_ALLMULTI flag and the @mc_count
2989*4882a593Smuzhiyun  * parameter to see whether multicast frames should be accepted
2990*4882a593Smuzhiyun  * or dropped.
2991*4882a593Smuzhiyun  *
2992*4882a593Smuzhiyun  * All unsupported flags in @total_flags must be cleared.
2993*4882a593Smuzhiyun  * Hardware does not support a flag if it is incapable of _passing_
2994*4882a593Smuzhiyun  * the frame to the stack. Otherwise the driver must ignore
2995*4882a593Smuzhiyun  * the flag, but not clear it.
2996*4882a593Smuzhiyun  * You must _only_ clear the flag (announce no support for the
2997*4882a593Smuzhiyun  * flag to mac80211) if you are not able to pass the packet type
2998*4882a593Smuzhiyun  * to the stack (so the hardware always filters it).
2999*4882a593Smuzhiyun  * So for example, you should clear @FIF_CONTROL, if your hardware
3000*4882a593Smuzhiyun  * always filters control frames. If your hardware always passes
3001*4882a593Smuzhiyun  * control frames to the kernel and is incapable of filtering them,
3002*4882a593Smuzhiyun  * you do _not_ clear the @FIF_CONTROL flag.
3003*4882a593Smuzhiyun  * This rule applies to all other FIF flags as well.
3004*4882a593Smuzhiyun  */
3005*4882a593Smuzhiyun 
3006*4882a593Smuzhiyun /**
3007*4882a593Smuzhiyun  * DOC: AP support for powersaving clients
3008*4882a593Smuzhiyun  *
3009*4882a593Smuzhiyun  * In order to implement AP and P2P GO modes, mac80211 has support for
3010*4882a593Smuzhiyun  * client powersaving, both "legacy" PS (PS-Poll/null data) and uAPSD.
3011*4882a593Smuzhiyun  * There currently is no support for sAPSD.
3012*4882a593Smuzhiyun  *
3013*4882a593Smuzhiyun  * There is one assumption that mac80211 makes, namely that a client
3014*4882a593Smuzhiyun  * will not poll with PS-Poll and trigger with uAPSD at the same time.
3015*4882a593Smuzhiyun  * Both are supported, and both can be used by the same client, but
3016*4882a593Smuzhiyun  * they can't be used concurrently by the same client. This simplifies
3017*4882a593Smuzhiyun  * the driver code.
3018*4882a593Smuzhiyun  *
3019*4882a593Smuzhiyun  * The first thing to keep in mind is that there is a flag for complete
3020*4882a593Smuzhiyun  * driver implementation: %IEEE80211_HW_AP_LINK_PS. If this flag is set,
3021*4882a593Smuzhiyun  * mac80211 expects the driver to handle most of the state machine for
3022*4882a593Smuzhiyun  * powersaving clients and will ignore the PM bit in incoming frames.
3023*4882a593Smuzhiyun  * Drivers then use ieee80211_sta_ps_transition() to inform mac80211 of
3024*4882a593Smuzhiyun  * stations' powersave transitions. In this mode, mac80211 also doesn't
3025*4882a593Smuzhiyun  * handle PS-Poll/uAPSD.
3026*4882a593Smuzhiyun  *
3027*4882a593Smuzhiyun  * In the mode without %IEEE80211_HW_AP_LINK_PS, mac80211 will check the
3028*4882a593Smuzhiyun  * PM bit in incoming frames for client powersave transitions. When a
3029*4882a593Smuzhiyun  * station goes to sleep, we will stop transmitting to it. There is,
3030*4882a593Smuzhiyun  * however, a race condition: a station might go to sleep while there is
3031*4882a593Smuzhiyun  * data buffered on hardware queues. If the device has support for this
3032*4882a593Smuzhiyun  * it will reject frames, and the driver should give the frames back to
3033*4882a593Smuzhiyun  * mac80211 with the %IEEE80211_TX_STAT_TX_FILTERED flag set which will
3034*4882a593Smuzhiyun  * cause mac80211 to retry the frame when the station wakes up. The
3035*4882a593Smuzhiyun  * driver is also notified of powersave transitions by calling its
3036*4882a593Smuzhiyun  * @sta_notify callback.
3037*4882a593Smuzhiyun  *
3038*4882a593Smuzhiyun  * When the station is asleep, it has three choices: it can wake up,
3039*4882a593Smuzhiyun  * it can PS-Poll, or it can possibly start a uAPSD service period.
3040*4882a593Smuzhiyun  * Waking up is implemented by simply transmitting all buffered (and
3041*4882a593Smuzhiyun  * filtered) frames to the station. This is the easiest case. When
3042*4882a593Smuzhiyun  * the station sends a PS-Poll or a uAPSD trigger frame, mac80211
3043*4882a593Smuzhiyun  * will inform the driver of this with the @allow_buffered_frames
3044*4882a593Smuzhiyun  * callback; this callback is optional. mac80211 will then transmit
3045*4882a593Smuzhiyun  * the frames as usual and set the %IEEE80211_TX_CTL_NO_PS_BUFFER
3046*4882a593Smuzhiyun  * on each frame. The last frame in the service period (or the only
3047*4882a593Smuzhiyun  * response to a PS-Poll) also has %IEEE80211_TX_STATUS_EOSP set to
3048*4882a593Smuzhiyun  * indicate that it ends the service period; as this frame must have
3049*4882a593Smuzhiyun  * TX status report it also sets %IEEE80211_TX_CTL_REQ_TX_STATUS.
3050*4882a593Smuzhiyun  * When TX status is reported for this frame, the service period is
3051*4882a593Smuzhiyun  * marked has having ended and a new one can be started by the peer.
3052*4882a593Smuzhiyun  *
3053*4882a593Smuzhiyun  * Additionally, non-bufferable MMPDUs can also be transmitted by
3054*4882a593Smuzhiyun  * mac80211 with the %IEEE80211_TX_CTL_NO_PS_BUFFER set in them.
3055*4882a593Smuzhiyun  *
3056*4882a593Smuzhiyun  * Another race condition can happen on some devices like iwlwifi
3057*4882a593Smuzhiyun  * when there are frames queued for the station and it wakes up
3058*4882a593Smuzhiyun  * or polls; the frames that are already queued could end up being
3059*4882a593Smuzhiyun  * transmitted first instead, causing reordering and/or wrong
3060*4882a593Smuzhiyun  * processing of the EOSP. The cause is that allowing frames to be
3061*4882a593Smuzhiyun  * transmitted to a certain station is out-of-band communication to
3062*4882a593Smuzhiyun  * the device. To allow this problem to be solved, the driver can
3063*4882a593Smuzhiyun  * call ieee80211_sta_block_awake() if frames are buffered when it
3064*4882a593Smuzhiyun  * is notified that the station went to sleep. When all these frames
3065*4882a593Smuzhiyun  * have been filtered (see above), it must call the function again
3066*4882a593Smuzhiyun  * to indicate that the station is no longer blocked.
3067*4882a593Smuzhiyun  *
3068*4882a593Smuzhiyun  * If the driver buffers frames in the driver for aggregation in any
3069*4882a593Smuzhiyun  * way, it must use the ieee80211_sta_set_buffered() call when it is
3070*4882a593Smuzhiyun  * notified of the station going to sleep to inform mac80211 of any
3071*4882a593Smuzhiyun  * TIDs that have frames buffered. Note that when a station wakes up
3072*4882a593Smuzhiyun  * this information is reset (hence the requirement to call it when
3073*4882a593Smuzhiyun  * informed of the station going to sleep). Then, when a service
3074*4882a593Smuzhiyun  * period starts for any reason, @release_buffered_frames is called
3075*4882a593Smuzhiyun  * with the number of frames to be released and which TIDs they are
3076*4882a593Smuzhiyun  * to come from. In this case, the driver is responsible for setting
3077*4882a593Smuzhiyun  * the EOSP (for uAPSD) and MORE_DATA bits in the released frames,
3078*4882a593Smuzhiyun  * to help the @more_data parameter is passed to tell the driver if
3079*4882a593Smuzhiyun  * there is more data on other TIDs -- the TIDs to release frames
3080*4882a593Smuzhiyun  * from are ignored since mac80211 doesn't know how many frames the
3081*4882a593Smuzhiyun  * buffers for those TIDs contain.
3082*4882a593Smuzhiyun  *
3083*4882a593Smuzhiyun  * If the driver also implement GO mode, where absence periods may
3084*4882a593Smuzhiyun  * shorten service periods (or abort PS-Poll responses), it must
3085*4882a593Smuzhiyun  * filter those response frames except in the case of frames that
3086*4882a593Smuzhiyun  * are buffered in the driver -- those must remain buffered to avoid
3087*4882a593Smuzhiyun  * reordering. Because it is possible that no frames are released
3088*4882a593Smuzhiyun  * in this case, the driver must call ieee80211_sta_eosp()
3089*4882a593Smuzhiyun  * to indicate to mac80211 that the service period ended anyway.
3090*4882a593Smuzhiyun  *
3091*4882a593Smuzhiyun  * Finally, if frames from multiple TIDs are released from mac80211
3092*4882a593Smuzhiyun  * but the driver might reorder them, it must clear & set the flags
3093*4882a593Smuzhiyun  * appropriately (only the last frame may have %IEEE80211_TX_STATUS_EOSP)
3094*4882a593Smuzhiyun  * and also take care of the EOSP and MORE_DATA bits in the frame.
3095*4882a593Smuzhiyun  * The driver may also use ieee80211_sta_eosp() in this case.
3096*4882a593Smuzhiyun  *
3097*4882a593Smuzhiyun  * Note that if the driver ever buffers frames other than QoS-data
3098*4882a593Smuzhiyun  * frames, it must take care to never send a non-QoS-data frame as
3099*4882a593Smuzhiyun  * the last frame in a service period, adding a QoS-nulldata frame
3100*4882a593Smuzhiyun  * after a non-QoS-data frame if needed.
3101*4882a593Smuzhiyun  */
3102*4882a593Smuzhiyun 
3103*4882a593Smuzhiyun /**
3104*4882a593Smuzhiyun  * DOC: HW queue control
3105*4882a593Smuzhiyun  *
3106*4882a593Smuzhiyun  * Before HW queue control was introduced, mac80211 only had a single static
3107*4882a593Smuzhiyun  * assignment of per-interface AC software queues to hardware queues. This
3108*4882a593Smuzhiyun  * was problematic for a few reasons:
3109*4882a593Smuzhiyun  * 1) off-channel transmissions might get stuck behind other frames
3110*4882a593Smuzhiyun  * 2) multiple virtual interfaces couldn't be handled correctly
3111*4882a593Smuzhiyun  * 3) after-DTIM frames could get stuck behind other frames
3112*4882a593Smuzhiyun  *
3113*4882a593Smuzhiyun  * To solve this, hardware typically uses multiple different queues for all
3114*4882a593Smuzhiyun  * the different usages, and this needs to be propagated into mac80211 so it
3115*4882a593Smuzhiyun  * won't have the same problem with the software queues.
3116*4882a593Smuzhiyun  *
3117*4882a593Smuzhiyun  * Therefore, mac80211 now offers the %IEEE80211_HW_QUEUE_CONTROL capability
3118*4882a593Smuzhiyun  * flag that tells it that the driver implements its own queue control. To do
3119*4882a593Smuzhiyun  * so, the driver will set up the various queues in each &struct ieee80211_vif
3120*4882a593Smuzhiyun  * and the offchannel queue in &struct ieee80211_hw. In response, mac80211 will
3121*4882a593Smuzhiyun  * use those queue IDs in the hw_queue field of &struct ieee80211_tx_info and
3122*4882a593Smuzhiyun  * if necessary will queue the frame on the right software queue that mirrors
3123*4882a593Smuzhiyun  * the hardware queue.
3124*4882a593Smuzhiyun  * Additionally, the driver has to then use these HW queue IDs for the queue
3125*4882a593Smuzhiyun  * management functions (ieee80211_stop_queue() et al.)
3126*4882a593Smuzhiyun  *
3127*4882a593Smuzhiyun  * The driver is free to set up the queue mappings as needed, multiple virtual
3128*4882a593Smuzhiyun  * interfaces may map to the same hardware queues if needed. The setup has to
3129*4882a593Smuzhiyun  * happen during add_interface or change_interface callbacks. For example, a
3130*4882a593Smuzhiyun  * driver supporting station+station and station+AP modes might decide to have
3131*4882a593Smuzhiyun  * 10 hardware queues to handle different scenarios:
3132*4882a593Smuzhiyun  *
3133*4882a593Smuzhiyun  * 4 AC HW queues for 1st vif: 0, 1, 2, 3
3134*4882a593Smuzhiyun  * 4 AC HW queues for 2nd vif: 4, 5, 6, 7
3135*4882a593Smuzhiyun  * after-DTIM queue for AP:   8
3136*4882a593Smuzhiyun  * off-channel queue:         9
3137*4882a593Smuzhiyun  *
3138*4882a593Smuzhiyun  * It would then set up the hardware like this:
3139*4882a593Smuzhiyun  *   hw.offchannel_tx_hw_queue = 9
3140*4882a593Smuzhiyun  *
3141*4882a593Smuzhiyun  * and the first virtual interface that is added as follows:
3142*4882a593Smuzhiyun  *   vif.hw_queue[IEEE80211_AC_VO] = 0
3143*4882a593Smuzhiyun  *   vif.hw_queue[IEEE80211_AC_VI] = 1
3144*4882a593Smuzhiyun  *   vif.hw_queue[IEEE80211_AC_BE] = 2
3145*4882a593Smuzhiyun  *   vif.hw_queue[IEEE80211_AC_BK] = 3
3146*4882a593Smuzhiyun  *   vif.cab_queue = 8 // if AP mode, otherwise %IEEE80211_INVAL_HW_QUEUE
3147*4882a593Smuzhiyun  * and the second virtual interface with 4-7.
3148*4882a593Smuzhiyun  *
3149*4882a593Smuzhiyun  * If queue 6 gets full, for example, mac80211 would only stop the second
3150*4882a593Smuzhiyun  * virtual interface's BE queue since virtual interface queues are per AC.
3151*4882a593Smuzhiyun  *
3152*4882a593Smuzhiyun  * Note that the vif.cab_queue value should be set to %IEEE80211_INVAL_HW_QUEUE
3153*4882a593Smuzhiyun  * whenever the queue is not used (i.e. the interface is not in AP mode) if the
3154*4882a593Smuzhiyun  * queue could potentially be shared since mac80211 will look at cab_queue when
3155*4882a593Smuzhiyun  * a queue is stopped/woken even if the interface is not in AP mode.
3156*4882a593Smuzhiyun  */
3157*4882a593Smuzhiyun 
3158*4882a593Smuzhiyun /**
3159*4882a593Smuzhiyun  * enum ieee80211_filter_flags - hardware filter flags
3160*4882a593Smuzhiyun  *
3161*4882a593Smuzhiyun  * These flags determine what the filter in hardware should be
3162*4882a593Smuzhiyun  * programmed to let through and what should not be passed to the
3163*4882a593Smuzhiyun  * stack. It is always safe to pass more frames than requested,
3164*4882a593Smuzhiyun  * but this has negative impact on power consumption.
3165*4882a593Smuzhiyun  *
3166*4882a593Smuzhiyun  * @FIF_ALLMULTI: pass all multicast frames, this is used if requested
3167*4882a593Smuzhiyun  *	by the user or if the hardware is not capable of filtering by
3168*4882a593Smuzhiyun  *	multicast address.
3169*4882a593Smuzhiyun  *
3170*4882a593Smuzhiyun  * @FIF_FCSFAIL: pass frames with failed FCS (but you need to set the
3171*4882a593Smuzhiyun  *	%RX_FLAG_FAILED_FCS_CRC for them)
3172*4882a593Smuzhiyun  *
3173*4882a593Smuzhiyun  * @FIF_PLCPFAIL: pass frames with failed PLCP CRC (but you need to set
3174*4882a593Smuzhiyun  *	the %RX_FLAG_FAILED_PLCP_CRC for them
3175*4882a593Smuzhiyun  *
3176*4882a593Smuzhiyun  * @FIF_BCN_PRBRESP_PROMISC: This flag is set during scanning to indicate
3177*4882a593Smuzhiyun  *	to the hardware that it should not filter beacons or probe responses
3178*4882a593Smuzhiyun  *	by BSSID. Filtering them can greatly reduce the amount of processing
3179*4882a593Smuzhiyun  *	mac80211 needs to do and the amount of CPU wakeups, so you should
3180*4882a593Smuzhiyun  *	honour this flag if possible.
3181*4882a593Smuzhiyun  *
3182*4882a593Smuzhiyun  * @FIF_CONTROL: pass control frames (except for PS Poll) addressed to this
3183*4882a593Smuzhiyun  *	station
3184*4882a593Smuzhiyun  *
3185*4882a593Smuzhiyun  * @FIF_OTHER_BSS: pass frames destined to other BSSes
3186*4882a593Smuzhiyun  *
3187*4882a593Smuzhiyun  * @FIF_PSPOLL: pass PS Poll frames
3188*4882a593Smuzhiyun  *
3189*4882a593Smuzhiyun  * @FIF_PROBE_REQ: pass probe request frames
3190*4882a593Smuzhiyun  *
3191*4882a593Smuzhiyun  * @FIF_MCAST_ACTION: pass multicast Action frames
3192*4882a593Smuzhiyun  */
3193*4882a593Smuzhiyun enum ieee80211_filter_flags {
3194*4882a593Smuzhiyun 	FIF_ALLMULTI		= 1<<1,
3195*4882a593Smuzhiyun 	FIF_FCSFAIL		= 1<<2,
3196*4882a593Smuzhiyun 	FIF_PLCPFAIL		= 1<<3,
3197*4882a593Smuzhiyun 	FIF_BCN_PRBRESP_PROMISC	= 1<<4,
3198*4882a593Smuzhiyun 	FIF_CONTROL		= 1<<5,
3199*4882a593Smuzhiyun 	FIF_OTHER_BSS		= 1<<6,
3200*4882a593Smuzhiyun 	FIF_PSPOLL		= 1<<7,
3201*4882a593Smuzhiyun 	FIF_PROBE_REQ		= 1<<8,
3202*4882a593Smuzhiyun 	FIF_MCAST_ACTION	= 1<<9,
3203*4882a593Smuzhiyun };
3204*4882a593Smuzhiyun 
3205*4882a593Smuzhiyun /**
3206*4882a593Smuzhiyun  * enum ieee80211_ampdu_mlme_action - A-MPDU actions
3207*4882a593Smuzhiyun  *
3208*4882a593Smuzhiyun  * These flags are used with the ampdu_action() callback in
3209*4882a593Smuzhiyun  * &struct ieee80211_ops to indicate which action is needed.
3210*4882a593Smuzhiyun  *
3211*4882a593Smuzhiyun  * Note that drivers MUST be able to deal with a TX aggregation
3212*4882a593Smuzhiyun  * session being stopped even before they OK'ed starting it by
3213*4882a593Smuzhiyun  * calling ieee80211_start_tx_ba_cb_irqsafe, because the peer
3214*4882a593Smuzhiyun  * might receive the addBA frame and send a delBA right away!
3215*4882a593Smuzhiyun  *
3216*4882a593Smuzhiyun  * @IEEE80211_AMPDU_RX_START: start RX aggregation
3217*4882a593Smuzhiyun  * @IEEE80211_AMPDU_RX_STOP: stop RX aggregation
3218*4882a593Smuzhiyun  * @IEEE80211_AMPDU_TX_START: start TX aggregation, the driver must either
3219*4882a593Smuzhiyun  *	call ieee80211_start_tx_ba_cb_irqsafe() or
3220*4882a593Smuzhiyun  *	call ieee80211_start_tx_ba_cb_irqsafe() with status
3221*4882a593Smuzhiyun  *	%IEEE80211_AMPDU_TX_START_DELAY_ADDBA to delay addba after
3222*4882a593Smuzhiyun  *	ieee80211_start_tx_ba_cb_irqsafe is called, or just return the special
3223*4882a593Smuzhiyun  *	status %IEEE80211_AMPDU_TX_START_IMMEDIATE.
3224*4882a593Smuzhiyun  * @IEEE80211_AMPDU_TX_OPERATIONAL: TX aggregation has become operational
3225*4882a593Smuzhiyun  * @IEEE80211_AMPDU_TX_STOP_CONT: stop TX aggregation but continue transmitting
3226*4882a593Smuzhiyun  *	queued packets, now unaggregated. After all packets are transmitted the
3227*4882a593Smuzhiyun  *	driver has to call ieee80211_stop_tx_ba_cb_irqsafe().
3228*4882a593Smuzhiyun  * @IEEE80211_AMPDU_TX_STOP_FLUSH: stop TX aggregation and flush all packets,
3229*4882a593Smuzhiyun  *	called when the station is removed. There's no need or reason to call
3230*4882a593Smuzhiyun  *	ieee80211_stop_tx_ba_cb_irqsafe() in this case as mac80211 assumes the
3231*4882a593Smuzhiyun  *	session is gone and removes the station.
3232*4882a593Smuzhiyun  * @IEEE80211_AMPDU_TX_STOP_FLUSH_CONT: called when TX aggregation is stopped
3233*4882a593Smuzhiyun  *	but the driver hasn't called ieee80211_stop_tx_ba_cb_irqsafe() yet and
3234*4882a593Smuzhiyun  *	now the connection is dropped and the station will be removed. Drivers
3235*4882a593Smuzhiyun  *	should clean up and drop remaining packets when this is called.
3236*4882a593Smuzhiyun  */
3237*4882a593Smuzhiyun enum ieee80211_ampdu_mlme_action {
3238*4882a593Smuzhiyun 	IEEE80211_AMPDU_RX_START,
3239*4882a593Smuzhiyun 	IEEE80211_AMPDU_RX_STOP,
3240*4882a593Smuzhiyun 	IEEE80211_AMPDU_TX_START,
3241*4882a593Smuzhiyun 	IEEE80211_AMPDU_TX_STOP_CONT,
3242*4882a593Smuzhiyun 	IEEE80211_AMPDU_TX_STOP_FLUSH,
3243*4882a593Smuzhiyun 	IEEE80211_AMPDU_TX_STOP_FLUSH_CONT,
3244*4882a593Smuzhiyun 	IEEE80211_AMPDU_TX_OPERATIONAL,
3245*4882a593Smuzhiyun };
3246*4882a593Smuzhiyun 
3247*4882a593Smuzhiyun #define IEEE80211_AMPDU_TX_START_IMMEDIATE 1
3248*4882a593Smuzhiyun #define IEEE80211_AMPDU_TX_START_DELAY_ADDBA 2
3249*4882a593Smuzhiyun 
3250*4882a593Smuzhiyun /**
3251*4882a593Smuzhiyun  * struct ieee80211_ampdu_params - AMPDU action parameters
3252*4882a593Smuzhiyun  *
3253*4882a593Smuzhiyun  * @action: the ampdu action, value from %ieee80211_ampdu_mlme_action.
3254*4882a593Smuzhiyun  * @sta: peer of this AMPDU session
3255*4882a593Smuzhiyun  * @tid: tid of the BA session
3256*4882a593Smuzhiyun  * @ssn: start sequence number of the session. TX/RX_STOP can pass 0. When
3257*4882a593Smuzhiyun  *	action is set to %IEEE80211_AMPDU_RX_START the driver passes back the
3258*4882a593Smuzhiyun  *	actual ssn value used to start the session and writes the value here.
3259*4882a593Smuzhiyun  * @buf_size: reorder buffer size  (number of subframes). Valid only when the
3260*4882a593Smuzhiyun  *	action is set to %IEEE80211_AMPDU_RX_START or
3261*4882a593Smuzhiyun  *	%IEEE80211_AMPDU_TX_OPERATIONAL
3262*4882a593Smuzhiyun  * @amsdu: indicates the peer's ability to receive A-MSDU within A-MPDU.
3263*4882a593Smuzhiyun  *	valid when the action is set to %IEEE80211_AMPDU_TX_OPERATIONAL
3264*4882a593Smuzhiyun  * @timeout: BA session timeout. Valid only when the action is set to
3265*4882a593Smuzhiyun  *	%IEEE80211_AMPDU_RX_START
3266*4882a593Smuzhiyun  */
3267*4882a593Smuzhiyun struct ieee80211_ampdu_params {
3268*4882a593Smuzhiyun 	enum ieee80211_ampdu_mlme_action action;
3269*4882a593Smuzhiyun 	struct ieee80211_sta *sta;
3270*4882a593Smuzhiyun 	u16 tid;
3271*4882a593Smuzhiyun 	u16 ssn;
3272*4882a593Smuzhiyun 	u16 buf_size;
3273*4882a593Smuzhiyun 	bool amsdu;
3274*4882a593Smuzhiyun 	u16 timeout;
3275*4882a593Smuzhiyun };
3276*4882a593Smuzhiyun 
3277*4882a593Smuzhiyun /**
3278*4882a593Smuzhiyun  * enum ieee80211_frame_release_type - frame release reason
3279*4882a593Smuzhiyun  * @IEEE80211_FRAME_RELEASE_PSPOLL: frame released for PS-Poll
3280*4882a593Smuzhiyun  * @IEEE80211_FRAME_RELEASE_UAPSD: frame(s) released due to
3281*4882a593Smuzhiyun  *	frame received on trigger-enabled AC
3282*4882a593Smuzhiyun  */
3283*4882a593Smuzhiyun enum ieee80211_frame_release_type {
3284*4882a593Smuzhiyun 	IEEE80211_FRAME_RELEASE_PSPOLL,
3285*4882a593Smuzhiyun 	IEEE80211_FRAME_RELEASE_UAPSD,
3286*4882a593Smuzhiyun };
3287*4882a593Smuzhiyun 
3288*4882a593Smuzhiyun /**
3289*4882a593Smuzhiyun  * enum ieee80211_rate_control_changed - flags to indicate what changed
3290*4882a593Smuzhiyun  *
3291*4882a593Smuzhiyun  * @IEEE80211_RC_BW_CHANGED: The bandwidth that can be used to transmit
3292*4882a593Smuzhiyun  *	to this station changed. The actual bandwidth is in the station
3293*4882a593Smuzhiyun  *	information -- for HT20/40 the IEEE80211_HT_CAP_SUP_WIDTH_20_40
3294*4882a593Smuzhiyun  *	flag changes, for HT and VHT the bandwidth field changes.
3295*4882a593Smuzhiyun  * @IEEE80211_RC_SMPS_CHANGED: The SMPS state of the station changed.
3296*4882a593Smuzhiyun  * @IEEE80211_RC_SUPP_RATES_CHANGED: The supported rate set of this peer
3297*4882a593Smuzhiyun  *	changed (in IBSS mode) due to discovering more information about
3298*4882a593Smuzhiyun  *	the peer.
3299*4882a593Smuzhiyun  * @IEEE80211_RC_NSS_CHANGED: N_SS (number of spatial streams) was changed
3300*4882a593Smuzhiyun  *	by the peer
3301*4882a593Smuzhiyun  */
3302*4882a593Smuzhiyun enum ieee80211_rate_control_changed {
3303*4882a593Smuzhiyun 	IEEE80211_RC_BW_CHANGED		= BIT(0),
3304*4882a593Smuzhiyun 	IEEE80211_RC_SMPS_CHANGED	= BIT(1),
3305*4882a593Smuzhiyun 	IEEE80211_RC_SUPP_RATES_CHANGED	= BIT(2),
3306*4882a593Smuzhiyun 	IEEE80211_RC_NSS_CHANGED	= BIT(3),
3307*4882a593Smuzhiyun };
3308*4882a593Smuzhiyun 
3309*4882a593Smuzhiyun /**
3310*4882a593Smuzhiyun  * enum ieee80211_roc_type - remain on channel type
3311*4882a593Smuzhiyun  *
3312*4882a593Smuzhiyun  * With the support for multi channel contexts and multi channel operations,
3313*4882a593Smuzhiyun  * remain on channel operations might be limited/deferred/aborted by other
3314*4882a593Smuzhiyun  * flows/operations which have higher priority (and vice versa).
3315*4882a593Smuzhiyun  * Specifying the ROC type can be used by devices to prioritize the ROC
3316*4882a593Smuzhiyun  * operations compared to other operations/flows.
3317*4882a593Smuzhiyun  *
3318*4882a593Smuzhiyun  * @IEEE80211_ROC_TYPE_NORMAL: There are no special requirements for this ROC.
3319*4882a593Smuzhiyun  * @IEEE80211_ROC_TYPE_MGMT_TX: The remain on channel request is required
3320*4882a593Smuzhiyun  *	for sending management frames offchannel.
3321*4882a593Smuzhiyun  */
3322*4882a593Smuzhiyun enum ieee80211_roc_type {
3323*4882a593Smuzhiyun 	IEEE80211_ROC_TYPE_NORMAL = 0,
3324*4882a593Smuzhiyun 	IEEE80211_ROC_TYPE_MGMT_TX,
3325*4882a593Smuzhiyun };
3326*4882a593Smuzhiyun 
3327*4882a593Smuzhiyun /**
3328*4882a593Smuzhiyun  * enum ieee80211_reconfig_type - reconfig type
3329*4882a593Smuzhiyun  *
3330*4882a593Smuzhiyun  * This enum is used by the reconfig_complete() callback to indicate what
3331*4882a593Smuzhiyun  * reconfiguration type was completed.
3332*4882a593Smuzhiyun  *
3333*4882a593Smuzhiyun  * @IEEE80211_RECONFIG_TYPE_RESTART: hw restart type
3334*4882a593Smuzhiyun  *	(also due to resume() callback returning 1)
3335*4882a593Smuzhiyun  * @IEEE80211_RECONFIG_TYPE_SUSPEND: suspend type (regardless
3336*4882a593Smuzhiyun  *	of wowlan configuration)
3337*4882a593Smuzhiyun  */
3338*4882a593Smuzhiyun enum ieee80211_reconfig_type {
3339*4882a593Smuzhiyun 	IEEE80211_RECONFIG_TYPE_RESTART,
3340*4882a593Smuzhiyun 	IEEE80211_RECONFIG_TYPE_SUSPEND,
3341*4882a593Smuzhiyun };
3342*4882a593Smuzhiyun 
3343*4882a593Smuzhiyun /**
3344*4882a593Smuzhiyun  * struct ieee80211_ops - callbacks from mac80211 to the driver
3345*4882a593Smuzhiyun  *
3346*4882a593Smuzhiyun  * This structure contains various callbacks that the driver may
3347*4882a593Smuzhiyun  * handle or, in some cases, must handle, for example to configure
3348*4882a593Smuzhiyun  * the hardware to a new channel or to transmit a frame.
3349*4882a593Smuzhiyun  *
3350*4882a593Smuzhiyun  * @tx: Handler that 802.11 module calls for each transmitted frame.
3351*4882a593Smuzhiyun  *	skb contains the buffer starting from the IEEE 802.11 header.
3352*4882a593Smuzhiyun  *	The low-level driver should send the frame out based on
3353*4882a593Smuzhiyun  *	configuration in the TX control data. This handler should,
3354*4882a593Smuzhiyun  *	preferably, never fail and stop queues appropriately.
3355*4882a593Smuzhiyun  *	Must be atomic.
3356*4882a593Smuzhiyun  *
3357*4882a593Smuzhiyun  * @start: Called before the first netdevice attached to the hardware
3358*4882a593Smuzhiyun  *	is enabled. This should turn on the hardware and must turn on
3359*4882a593Smuzhiyun  *	frame reception (for possibly enabled monitor interfaces.)
3360*4882a593Smuzhiyun  *	Returns negative error codes, these may be seen in userspace,
3361*4882a593Smuzhiyun  *	or zero.
3362*4882a593Smuzhiyun  *	When the device is started it should not have a MAC address
3363*4882a593Smuzhiyun  *	to avoid acknowledging frames before a non-monitor device
3364*4882a593Smuzhiyun  *	is added.
3365*4882a593Smuzhiyun  *	Must be implemented and can sleep.
3366*4882a593Smuzhiyun  *
3367*4882a593Smuzhiyun  * @stop: Called after last netdevice attached to the hardware
3368*4882a593Smuzhiyun  *	is disabled. This should turn off the hardware (at least
3369*4882a593Smuzhiyun  *	it must turn off frame reception.)
3370*4882a593Smuzhiyun  *	May be called right after add_interface if that rejects
3371*4882a593Smuzhiyun  *	an interface. If you added any work onto the mac80211 workqueue
3372*4882a593Smuzhiyun  *	you should ensure to cancel it on this callback.
3373*4882a593Smuzhiyun  *	Must be implemented and can sleep.
3374*4882a593Smuzhiyun  *
3375*4882a593Smuzhiyun  * @suspend: Suspend the device; mac80211 itself will quiesce before and
3376*4882a593Smuzhiyun  *	stop transmitting and doing any other configuration, and then
3377*4882a593Smuzhiyun  *	ask the device to suspend. This is only invoked when WoWLAN is
3378*4882a593Smuzhiyun  *	configured, otherwise the device is deconfigured completely and
3379*4882a593Smuzhiyun  *	reconfigured at resume time.
3380*4882a593Smuzhiyun  *	The driver may also impose special conditions under which it
3381*4882a593Smuzhiyun  *	wants to use the "normal" suspend (deconfigure), say if it only
3382*4882a593Smuzhiyun  *	supports WoWLAN when the device is associated. In this case, it
3383*4882a593Smuzhiyun  *	must return 1 from this function.
3384*4882a593Smuzhiyun  *
3385*4882a593Smuzhiyun  * @resume: If WoWLAN was configured, this indicates that mac80211 is
3386*4882a593Smuzhiyun  *	now resuming its operation, after this the device must be fully
3387*4882a593Smuzhiyun  *	functional again. If this returns an error, the only way out is
3388*4882a593Smuzhiyun  *	to also unregister the device. If it returns 1, then mac80211
3389*4882a593Smuzhiyun  *	will also go through the regular complete restart on resume.
3390*4882a593Smuzhiyun  *
3391*4882a593Smuzhiyun  * @set_wakeup: Enable or disable wakeup when WoWLAN configuration is
3392*4882a593Smuzhiyun  *	modified. The reason is that device_set_wakeup_enable() is
3393*4882a593Smuzhiyun  *	supposed to be called when the configuration changes, not only
3394*4882a593Smuzhiyun  *	in suspend().
3395*4882a593Smuzhiyun  *
3396*4882a593Smuzhiyun  * @add_interface: Called when a netdevice attached to the hardware is
3397*4882a593Smuzhiyun  *	enabled. Because it is not called for monitor mode devices, @start
3398*4882a593Smuzhiyun  *	and @stop must be implemented.
3399*4882a593Smuzhiyun  *	The driver should perform any initialization it needs before
3400*4882a593Smuzhiyun  *	the device can be enabled. The initial configuration for the
3401*4882a593Smuzhiyun  *	interface is given in the conf parameter.
3402*4882a593Smuzhiyun  *	The callback may refuse to add an interface by returning a
3403*4882a593Smuzhiyun  *	negative error code (which will be seen in userspace.)
3404*4882a593Smuzhiyun  *	Must be implemented and can sleep.
3405*4882a593Smuzhiyun  *
3406*4882a593Smuzhiyun  * @change_interface: Called when a netdevice changes type. This callback
3407*4882a593Smuzhiyun  *	is optional, but only if it is supported can interface types be
3408*4882a593Smuzhiyun  *	switched while the interface is UP. The callback may sleep.
3409*4882a593Smuzhiyun  *	Note that while an interface is being switched, it will not be
3410*4882a593Smuzhiyun  *	found by the interface iteration callbacks.
3411*4882a593Smuzhiyun  *
3412*4882a593Smuzhiyun  * @remove_interface: Notifies a driver that an interface is going down.
3413*4882a593Smuzhiyun  *	The @stop callback is called after this if it is the last interface
3414*4882a593Smuzhiyun  *	and no monitor interfaces are present.
3415*4882a593Smuzhiyun  *	When all interfaces are removed, the MAC address in the hardware
3416*4882a593Smuzhiyun  *	must be cleared so the device no longer acknowledges packets,
3417*4882a593Smuzhiyun  *	the mac_addr member of the conf structure is, however, set to the
3418*4882a593Smuzhiyun  *	MAC address of the device going away.
3419*4882a593Smuzhiyun  *	Hence, this callback must be implemented. It can sleep.
3420*4882a593Smuzhiyun  *
3421*4882a593Smuzhiyun  * @config: Handler for configuration requests. IEEE 802.11 code calls this
3422*4882a593Smuzhiyun  *	function to change hardware configuration, e.g., channel.
3423*4882a593Smuzhiyun  *	This function should never fail but returns a negative error code
3424*4882a593Smuzhiyun  *	if it does. The callback can sleep.
3425*4882a593Smuzhiyun  *
3426*4882a593Smuzhiyun  * @bss_info_changed: Handler for configuration requests related to BSS
3427*4882a593Smuzhiyun  *	parameters that may vary during BSS's lifespan, and may affect low
3428*4882a593Smuzhiyun  *	level driver (e.g. assoc/disassoc status, erp parameters).
3429*4882a593Smuzhiyun  *	This function should not be used if no BSS has been set, unless
3430*4882a593Smuzhiyun  *	for association indication. The @changed parameter indicates which
3431*4882a593Smuzhiyun  *	of the bss parameters has changed when a call is made. The callback
3432*4882a593Smuzhiyun  *	can sleep.
3433*4882a593Smuzhiyun  *
3434*4882a593Smuzhiyun  * @prepare_multicast: Prepare for multicast filter configuration.
3435*4882a593Smuzhiyun  *	This callback is optional, and its return value is passed
3436*4882a593Smuzhiyun  *	to configure_filter(). This callback must be atomic.
3437*4882a593Smuzhiyun  *
3438*4882a593Smuzhiyun  * @configure_filter: Configure the device's RX filter.
3439*4882a593Smuzhiyun  *	See the section "Frame filtering" for more information.
3440*4882a593Smuzhiyun  *	This callback must be implemented and can sleep.
3441*4882a593Smuzhiyun  *
3442*4882a593Smuzhiyun  * @config_iface_filter: Configure the interface's RX filter.
3443*4882a593Smuzhiyun  *	This callback is optional and is used to configure which frames
3444*4882a593Smuzhiyun  *	should be passed to mac80211. The filter_flags is the combination
3445*4882a593Smuzhiyun  *	of FIF_* flags. The changed_flags is a bit mask that indicates
3446*4882a593Smuzhiyun  *	which flags are changed.
3447*4882a593Smuzhiyun  *	This callback can sleep.
3448*4882a593Smuzhiyun  *
3449*4882a593Smuzhiyun  * @set_tim: Set TIM bit. mac80211 calls this function when a TIM bit
3450*4882a593Smuzhiyun  * 	must be set or cleared for a given STA. Must be atomic.
3451*4882a593Smuzhiyun  *
3452*4882a593Smuzhiyun  * @set_key: See the section "Hardware crypto acceleration"
3453*4882a593Smuzhiyun  *	This callback is only called between add_interface and
3454*4882a593Smuzhiyun  *	remove_interface calls, i.e. while the given virtual interface
3455*4882a593Smuzhiyun  *	is enabled.
3456*4882a593Smuzhiyun  *	Returns a negative error code if the key can't be added.
3457*4882a593Smuzhiyun  *	The callback can sleep.
3458*4882a593Smuzhiyun  *
3459*4882a593Smuzhiyun  * @update_tkip_key: See the section "Hardware crypto acceleration"
3460*4882a593Smuzhiyun  * 	This callback will be called in the context of Rx. Called for drivers
3461*4882a593Smuzhiyun  * 	which set IEEE80211_KEY_FLAG_TKIP_REQ_RX_P1_KEY.
3462*4882a593Smuzhiyun  *	The callback must be atomic.
3463*4882a593Smuzhiyun  *
3464*4882a593Smuzhiyun  * @set_rekey_data: If the device supports GTK rekeying, for example while the
3465*4882a593Smuzhiyun  *	host is suspended, it can assign this callback to retrieve the data
3466*4882a593Smuzhiyun  *	necessary to do GTK rekeying, this is the KEK, KCK and replay counter.
3467*4882a593Smuzhiyun  *	After rekeying was done it should (for example during resume) notify
3468*4882a593Smuzhiyun  *	userspace of the new replay counter using ieee80211_gtk_rekey_notify().
3469*4882a593Smuzhiyun  *
3470*4882a593Smuzhiyun  * @set_default_unicast_key: Set the default (unicast) key index, useful for
3471*4882a593Smuzhiyun  *	WEP when the device sends data packets autonomously, e.g. for ARP
3472*4882a593Smuzhiyun  *	offloading. The index can be 0-3, or -1 for unsetting it.
3473*4882a593Smuzhiyun  *
3474*4882a593Smuzhiyun  * @hw_scan: Ask the hardware to service the scan request, no need to start
3475*4882a593Smuzhiyun  *	the scan state machine in stack. The scan must honour the channel
3476*4882a593Smuzhiyun  *	configuration done by the regulatory agent in the wiphy's
3477*4882a593Smuzhiyun  *	registered bands. The hardware (or the driver) needs to make sure
3478*4882a593Smuzhiyun  *	that power save is disabled.
3479*4882a593Smuzhiyun  *	The @req ie/ie_len members are rewritten by mac80211 to contain the
3480*4882a593Smuzhiyun  *	entire IEs after the SSID, so that drivers need not look at these
3481*4882a593Smuzhiyun  *	at all but just send them after the SSID -- mac80211 includes the
3482*4882a593Smuzhiyun  *	(extended) supported rates and HT information (where applicable).
3483*4882a593Smuzhiyun  *	When the scan finishes, ieee80211_scan_completed() must be called;
3484*4882a593Smuzhiyun  *	note that it also must be called when the scan cannot finish due to
3485*4882a593Smuzhiyun  *	any error unless this callback returned a negative error code.
3486*4882a593Smuzhiyun  *	This callback is also allowed to return the special return value 1,
3487*4882a593Smuzhiyun  *	this indicates that hardware scan isn't desirable right now and a
3488*4882a593Smuzhiyun  *	software scan should be done instead. A driver wishing to use this
3489*4882a593Smuzhiyun  *	capability must ensure its (hardware) scan capabilities aren't
3490*4882a593Smuzhiyun  *	advertised as more capable than mac80211's software scan is.
3491*4882a593Smuzhiyun  *	The callback can sleep.
3492*4882a593Smuzhiyun  *
3493*4882a593Smuzhiyun  * @cancel_hw_scan: Ask the low-level tp cancel the active hw scan.
3494*4882a593Smuzhiyun  *	The driver should ask the hardware to cancel the scan (if possible),
3495*4882a593Smuzhiyun  *	but the scan will be completed only after the driver will call
3496*4882a593Smuzhiyun  *	ieee80211_scan_completed().
3497*4882a593Smuzhiyun  *	This callback is needed for wowlan, to prevent enqueueing a new
3498*4882a593Smuzhiyun  *	scan_work after the low-level driver was already suspended.
3499*4882a593Smuzhiyun  *	The callback can sleep.
3500*4882a593Smuzhiyun  *
3501*4882a593Smuzhiyun  * @sched_scan_start: Ask the hardware to start scanning repeatedly at
3502*4882a593Smuzhiyun  *	specific intervals.  The driver must call the
3503*4882a593Smuzhiyun  *	ieee80211_sched_scan_results() function whenever it finds results.
3504*4882a593Smuzhiyun  *	This process will continue until sched_scan_stop is called.
3505*4882a593Smuzhiyun  *
3506*4882a593Smuzhiyun  * @sched_scan_stop: Tell the hardware to stop an ongoing scheduled scan.
3507*4882a593Smuzhiyun  *	In this case, ieee80211_sched_scan_stopped() must not be called.
3508*4882a593Smuzhiyun  *
3509*4882a593Smuzhiyun  * @sw_scan_start: Notifier function that is called just before a software scan
3510*4882a593Smuzhiyun  *	is started. Can be NULL, if the driver doesn't need this notification.
3511*4882a593Smuzhiyun  *	The mac_addr parameter allows supporting NL80211_SCAN_FLAG_RANDOM_ADDR,
3512*4882a593Smuzhiyun  *	the driver may set the NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR flag if it
3513*4882a593Smuzhiyun  *	can use this parameter. The callback can sleep.
3514*4882a593Smuzhiyun  *
3515*4882a593Smuzhiyun  * @sw_scan_complete: Notifier function that is called just after a
3516*4882a593Smuzhiyun  *	software scan finished. Can be NULL, if the driver doesn't need
3517*4882a593Smuzhiyun  *	this notification.
3518*4882a593Smuzhiyun  *	The callback can sleep.
3519*4882a593Smuzhiyun  *
3520*4882a593Smuzhiyun  * @get_stats: Return low-level statistics.
3521*4882a593Smuzhiyun  * 	Returns zero if statistics are available.
3522*4882a593Smuzhiyun  *	The callback can sleep.
3523*4882a593Smuzhiyun  *
3524*4882a593Smuzhiyun  * @get_key_seq: If your device implements encryption in hardware and does
3525*4882a593Smuzhiyun  *	IV/PN assignment then this callback should be provided to read the
3526*4882a593Smuzhiyun  *	IV/PN for the given key from hardware.
3527*4882a593Smuzhiyun  *	The callback must be atomic.
3528*4882a593Smuzhiyun  *
3529*4882a593Smuzhiyun  * @set_frag_threshold: Configuration of fragmentation threshold. Assign this
3530*4882a593Smuzhiyun  *	if the device does fragmentation by itself. Note that to prevent the
3531*4882a593Smuzhiyun  *	stack from doing fragmentation IEEE80211_HW_SUPPORTS_TX_FRAG
3532*4882a593Smuzhiyun  *	should be set as well.
3533*4882a593Smuzhiyun  *	The callback can sleep.
3534*4882a593Smuzhiyun  *
3535*4882a593Smuzhiyun  * @set_rts_threshold: Configuration of RTS threshold (if device needs it)
3536*4882a593Smuzhiyun  *	The callback can sleep.
3537*4882a593Smuzhiyun  *
3538*4882a593Smuzhiyun  * @sta_add: Notifies low level driver about addition of an associated station,
3539*4882a593Smuzhiyun  *	AP, IBSS/WDS/mesh peer etc. This callback can sleep.
3540*4882a593Smuzhiyun  *
3541*4882a593Smuzhiyun  * @sta_remove: Notifies low level driver about removal of an associated
3542*4882a593Smuzhiyun  *	station, AP, IBSS/WDS/mesh peer etc. Note that after the callback
3543*4882a593Smuzhiyun  *	returns it isn't safe to use the pointer, not even RCU protected;
3544*4882a593Smuzhiyun  *	no RCU grace period is guaranteed between returning here and freeing
3545*4882a593Smuzhiyun  *	the station. See @sta_pre_rcu_remove if needed.
3546*4882a593Smuzhiyun  *	This callback can sleep.
3547*4882a593Smuzhiyun  *
3548*4882a593Smuzhiyun  * @sta_add_debugfs: Drivers can use this callback to add debugfs files
3549*4882a593Smuzhiyun  *	when a station is added to mac80211's station list. This callback
3550*4882a593Smuzhiyun  *	should be within a CONFIG_MAC80211_DEBUGFS conditional. This
3551*4882a593Smuzhiyun  *	callback can sleep.
3552*4882a593Smuzhiyun  *
3553*4882a593Smuzhiyun  * @sta_notify: Notifies low level driver about power state transition of an
3554*4882a593Smuzhiyun  *	associated station, AP,  IBSS/WDS/mesh peer etc. For a VIF operating
3555*4882a593Smuzhiyun  *	in AP mode, this callback will not be called when the flag
3556*4882a593Smuzhiyun  *	%IEEE80211_HW_AP_LINK_PS is set. Must be atomic.
3557*4882a593Smuzhiyun  *
3558*4882a593Smuzhiyun  * @sta_set_txpwr: Configure the station tx power. This callback set the tx
3559*4882a593Smuzhiyun  *	power for the station.
3560*4882a593Smuzhiyun  *	This callback can sleep.
3561*4882a593Smuzhiyun  *
3562*4882a593Smuzhiyun  * @sta_state: Notifies low level driver about state transition of a
3563*4882a593Smuzhiyun  *	station (which can be the AP, a client, IBSS/WDS/mesh peer etc.)
3564*4882a593Smuzhiyun  *	This callback is mutually exclusive with @sta_add/@sta_remove.
3565*4882a593Smuzhiyun  *	It must not fail for down transitions but may fail for transitions
3566*4882a593Smuzhiyun  *	up the list of states. Also note that after the callback returns it
3567*4882a593Smuzhiyun  *	isn't safe to use the pointer, not even RCU protected - no RCU grace
3568*4882a593Smuzhiyun  *	period is guaranteed between returning here and freeing the station.
3569*4882a593Smuzhiyun  *	See @sta_pre_rcu_remove if needed.
3570*4882a593Smuzhiyun  *	The callback can sleep.
3571*4882a593Smuzhiyun  *
3572*4882a593Smuzhiyun  * @sta_pre_rcu_remove: Notify driver about station removal before RCU
3573*4882a593Smuzhiyun  *	synchronisation. This is useful if a driver needs to have station
3574*4882a593Smuzhiyun  *	pointers protected using RCU, it can then use this call to clear
3575*4882a593Smuzhiyun  *	the pointers instead of waiting for an RCU grace period to elapse
3576*4882a593Smuzhiyun  *	in @sta_state.
3577*4882a593Smuzhiyun  *	The callback can sleep.
3578*4882a593Smuzhiyun  *
3579*4882a593Smuzhiyun  * @sta_rc_update: Notifies the driver of changes to the bitrates that can be
3580*4882a593Smuzhiyun  *	used to transmit to the station. The changes are advertised with bits
3581*4882a593Smuzhiyun  *	from &enum ieee80211_rate_control_changed and the values are reflected
3582*4882a593Smuzhiyun  *	in the station data. This callback should only be used when the driver
3583*4882a593Smuzhiyun  *	uses hardware rate control (%IEEE80211_HW_HAS_RATE_CONTROL) since
3584*4882a593Smuzhiyun  *	otherwise the rate control algorithm is notified directly.
3585*4882a593Smuzhiyun  *	Must be atomic.
3586*4882a593Smuzhiyun  * @sta_rate_tbl_update: Notifies the driver that the rate table changed. This
3587*4882a593Smuzhiyun  *	is only used if the configured rate control algorithm actually uses
3588*4882a593Smuzhiyun  *	the new rate table API, and is therefore optional. Must be atomic.
3589*4882a593Smuzhiyun  *
3590*4882a593Smuzhiyun  * @sta_statistics: Get statistics for this station. For example with beacon
3591*4882a593Smuzhiyun  *	filtering, the statistics kept by mac80211 might not be accurate, so
3592*4882a593Smuzhiyun  *	let the driver pre-fill the statistics. The driver can fill most of
3593*4882a593Smuzhiyun  *	the values (indicating which by setting the filled bitmap), but not
3594*4882a593Smuzhiyun  *	all of them make sense - see the source for which ones are possible.
3595*4882a593Smuzhiyun  *	Statistics that the driver doesn't fill will be filled by mac80211.
3596*4882a593Smuzhiyun  *	The callback can sleep.
3597*4882a593Smuzhiyun  *
3598*4882a593Smuzhiyun  * @conf_tx: Configure TX queue parameters (EDCF (aifs, cw_min, cw_max),
3599*4882a593Smuzhiyun  *	bursting) for a hardware TX queue.
3600*4882a593Smuzhiyun  *	Returns a negative error code on failure.
3601*4882a593Smuzhiyun  *	The callback can sleep.
3602*4882a593Smuzhiyun  *
3603*4882a593Smuzhiyun  * @get_tsf: Get the current TSF timer value from firmware/hardware. Currently,
3604*4882a593Smuzhiyun  *	this is only used for IBSS mode BSSID merging and debugging. Is not a
3605*4882a593Smuzhiyun  *	required function.
3606*4882a593Smuzhiyun  *	The callback can sleep.
3607*4882a593Smuzhiyun  *
3608*4882a593Smuzhiyun  * @set_tsf: Set the TSF timer to the specified value in the firmware/hardware.
3609*4882a593Smuzhiyun  *	Currently, this is only used for IBSS mode debugging. Is not a
3610*4882a593Smuzhiyun  *	required function.
3611*4882a593Smuzhiyun  *	The callback can sleep.
3612*4882a593Smuzhiyun  *
3613*4882a593Smuzhiyun  * @offset_tsf: Offset the TSF timer by the specified value in the
3614*4882a593Smuzhiyun  *	firmware/hardware.  Preferred to set_tsf as it avoids delay between
3615*4882a593Smuzhiyun  *	calling set_tsf() and hardware getting programmed, which will show up
3616*4882a593Smuzhiyun  *	as TSF delay. Is not a required function.
3617*4882a593Smuzhiyun  *	The callback can sleep.
3618*4882a593Smuzhiyun  *
3619*4882a593Smuzhiyun  * @reset_tsf: Reset the TSF timer and allow firmware/hardware to synchronize
3620*4882a593Smuzhiyun  *	with other STAs in the IBSS. This is only used in IBSS mode. This
3621*4882a593Smuzhiyun  *	function is optional if the firmware/hardware takes full care of
3622*4882a593Smuzhiyun  *	TSF synchronization.
3623*4882a593Smuzhiyun  *	The callback can sleep.
3624*4882a593Smuzhiyun  *
3625*4882a593Smuzhiyun  * @tx_last_beacon: Determine whether the last IBSS beacon was sent by us.
3626*4882a593Smuzhiyun  *	This is needed only for IBSS mode and the result of this function is
3627*4882a593Smuzhiyun  *	used to determine whether to reply to Probe Requests.
3628*4882a593Smuzhiyun  *	Returns non-zero if this device sent the last beacon.
3629*4882a593Smuzhiyun  *	The callback can sleep.
3630*4882a593Smuzhiyun  *
3631*4882a593Smuzhiyun  * @get_survey: Return per-channel survey information
3632*4882a593Smuzhiyun  *
3633*4882a593Smuzhiyun  * @rfkill_poll: Poll rfkill hardware state. If you need this, you also
3634*4882a593Smuzhiyun  *	need to set wiphy->rfkill_poll to %true before registration,
3635*4882a593Smuzhiyun  *	and need to call wiphy_rfkill_set_hw_state() in the callback.
3636*4882a593Smuzhiyun  *	The callback can sleep.
3637*4882a593Smuzhiyun  *
3638*4882a593Smuzhiyun  * @set_coverage_class: Set slot time for given coverage class as specified
3639*4882a593Smuzhiyun  *	in IEEE 802.11-2007 section 17.3.8.6 and modify ACK timeout
3640*4882a593Smuzhiyun  *	accordingly; coverage class equals to -1 to enable ACK timeout
3641*4882a593Smuzhiyun  *	estimation algorithm (dynack). To disable dynack set valid value for
3642*4882a593Smuzhiyun  *	coverage class. This callback is not required and may sleep.
3643*4882a593Smuzhiyun  *
3644*4882a593Smuzhiyun  * @testmode_cmd: Implement a cfg80211 test mode command. The passed @vif may
3645*4882a593Smuzhiyun  *	be %NULL. The callback can sleep.
3646*4882a593Smuzhiyun  * @testmode_dump: Implement a cfg80211 test mode dump. The callback can sleep.
3647*4882a593Smuzhiyun  *
3648*4882a593Smuzhiyun  * @flush: Flush all pending frames from the hardware queue, making sure
3649*4882a593Smuzhiyun  *	that the hardware queues are empty. The @queues parameter is a bitmap
3650*4882a593Smuzhiyun  *	of queues to flush, which is useful if different virtual interfaces
3651*4882a593Smuzhiyun  *	use different hardware queues; it may also indicate all queues.
3652*4882a593Smuzhiyun  *	If the parameter @drop is set to %true, pending frames may be dropped.
3653*4882a593Smuzhiyun  *	Note that vif can be NULL.
3654*4882a593Smuzhiyun  *	The callback can sleep.
3655*4882a593Smuzhiyun  *
3656*4882a593Smuzhiyun  * @channel_switch: Drivers that need (or want) to offload the channel
3657*4882a593Smuzhiyun  *	switch operation for CSAs received from the AP may implement this
3658*4882a593Smuzhiyun  *	callback. They must then call ieee80211_chswitch_done() to indicate
3659*4882a593Smuzhiyun  *	completion of the channel switch.
3660*4882a593Smuzhiyun  *
3661*4882a593Smuzhiyun  * @set_antenna: Set antenna configuration (tx_ant, rx_ant) on the device.
3662*4882a593Smuzhiyun  *	Parameters are bitmaps of allowed antennas to use for TX/RX. Drivers may
3663*4882a593Smuzhiyun  *	reject TX/RX mask combinations they cannot support by returning -EINVAL
3664*4882a593Smuzhiyun  *	(also see nl80211.h @NL80211_ATTR_WIPHY_ANTENNA_TX).
3665*4882a593Smuzhiyun  *
3666*4882a593Smuzhiyun  * @get_antenna: Get current antenna configuration from device (tx_ant, rx_ant).
3667*4882a593Smuzhiyun  *
3668*4882a593Smuzhiyun  * @remain_on_channel: Starts an off-channel period on the given channel, must
3669*4882a593Smuzhiyun  *	call back to ieee80211_ready_on_channel() when on that channel. Note
3670*4882a593Smuzhiyun  *	that normal channel traffic is not stopped as this is intended for hw
3671*4882a593Smuzhiyun  *	offload. Frames to transmit on the off-channel channel are transmitted
3672*4882a593Smuzhiyun  *	normally except for the %IEEE80211_TX_CTL_TX_OFFCHAN flag. When the
3673*4882a593Smuzhiyun  *	duration (which will always be non-zero) expires, the driver must call
3674*4882a593Smuzhiyun  *	ieee80211_remain_on_channel_expired().
3675*4882a593Smuzhiyun  *	Note that this callback may be called while the device is in IDLE and
3676*4882a593Smuzhiyun  *	must be accepted in this case.
3677*4882a593Smuzhiyun  *	This callback may sleep.
3678*4882a593Smuzhiyun  * @cancel_remain_on_channel: Requests that an ongoing off-channel period is
3679*4882a593Smuzhiyun  *	aborted before it expires. This callback may sleep.
3680*4882a593Smuzhiyun  *
3681*4882a593Smuzhiyun  * @set_ringparam: Set tx and rx ring sizes.
3682*4882a593Smuzhiyun  *
3683*4882a593Smuzhiyun  * @get_ringparam: Get tx and rx ring current and maximum sizes.
3684*4882a593Smuzhiyun  *
3685*4882a593Smuzhiyun  * @tx_frames_pending: Check if there is any pending frame in the hardware
3686*4882a593Smuzhiyun  *	queues before entering power save.
3687*4882a593Smuzhiyun  *
3688*4882a593Smuzhiyun  * @set_bitrate_mask: Set a mask of rates to be used for rate control selection
3689*4882a593Smuzhiyun  *	when transmitting a frame. Currently only legacy rates are handled.
3690*4882a593Smuzhiyun  *	The callback can sleep.
3691*4882a593Smuzhiyun  * @event_callback: Notify driver about any event in mac80211. See
3692*4882a593Smuzhiyun  *	&enum ieee80211_event_type for the different types.
3693*4882a593Smuzhiyun  *	The callback must be atomic.
3694*4882a593Smuzhiyun  *
3695*4882a593Smuzhiyun  * @release_buffered_frames: Release buffered frames according to the given
3696*4882a593Smuzhiyun  *	parameters. In the case where the driver buffers some frames for
3697*4882a593Smuzhiyun  *	sleeping stations mac80211 will use this callback to tell the driver
3698*4882a593Smuzhiyun  *	to release some frames, either for PS-poll or uAPSD.
3699*4882a593Smuzhiyun  *	Note that if the @more_data parameter is %false the driver must check
3700*4882a593Smuzhiyun  *	if there are more frames on the given TIDs, and if there are more than
3701*4882a593Smuzhiyun  *	the frames being released then it must still set the more-data bit in
3702*4882a593Smuzhiyun  *	the frame. If the @more_data parameter is %true, then of course the
3703*4882a593Smuzhiyun  *	more-data bit must always be set.
3704*4882a593Smuzhiyun  *	The @tids parameter tells the driver which TIDs to release frames
3705*4882a593Smuzhiyun  *	from, for PS-poll it will always have only a single bit set.
3706*4882a593Smuzhiyun  *	In the case this is used for a PS-poll initiated release, the
3707*4882a593Smuzhiyun  *	@num_frames parameter will always be 1 so code can be shared. In
3708*4882a593Smuzhiyun  *	this case the driver must also set %IEEE80211_TX_STATUS_EOSP flag
3709*4882a593Smuzhiyun  *	on the TX status (and must report TX status) so that the PS-poll
3710*4882a593Smuzhiyun  *	period is properly ended. This is used to avoid sending multiple
3711*4882a593Smuzhiyun  *	responses for a retried PS-poll frame.
3712*4882a593Smuzhiyun  *	In the case this is used for uAPSD, the @num_frames parameter may be
3713*4882a593Smuzhiyun  *	bigger than one, but the driver may send fewer frames (it must send
3714*4882a593Smuzhiyun  *	at least one, however). In this case it is also responsible for
3715*4882a593Smuzhiyun  *	setting the EOSP flag in the QoS header of the frames. Also, when the
3716*4882a593Smuzhiyun  *	service period ends, the driver must set %IEEE80211_TX_STATUS_EOSP
3717*4882a593Smuzhiyun  *	on the last frame in the SP. Alternatively, it may call the function
3718*4882a593Smuzhiyun  *	ieee80211_sta_eosp() to inform mac80211 of the end of the SP.
3719*4882a593Smuzhiyun  *	This callback must be atomic.
3720*4882a593Smuzhiyun  * @allow_buffered_frames: Prepare device to allow the given number of frames
3721*4882a593Smuzhiyun  *	to go out to the given station. The frames will be sent by mac80211
3722*4882a593Smuzhiyun  *	via the usual TX path after this call. The TX information for frames
3723*4882a593Smuzhiyun  *	released will also have the %IEEE80211_TX_CTL_NO_PS_BUFFER flag set
3724*4882a593Smuzhiyun  *	and the last one will also have %IEEE80211_TX_STATUS_EOSP set. In case
3725*4882a593Smuzhiyun  *	frames from multiple TIDs are released and the driver might reorder
3726*4882a593Smuzhiyun  *	them between the TIDs, it must set the %IEEE80211_TX_STATUS_EOSP flag
3727*4882a593Smuzhiyun  *	on the last frame and clear it on all others and also handle the EOSP
3728*4882a593Smuzhiyun  *	bit in the QoS header correctly. Alternatively, it can also call the
3729*4882a593Smuzhiyun  *	ieee80211_sta_eosp() function.
3730*4882a593Smuzhiyun  *	The @tids parameter is a bitmap and tells the driver which TIDs the
3731*4882a593Smuzhiyun  *	frames will be on; it will at most have two bits set.
3732*4882a593Smuzhiyun  *	This callback must be atomic.
3733*4882a593Smuzhiyun  *
3734*4882a593Smuzhiyun  * @get_et_sset_count:  Ethtool API to get string-set count.
3735*4882a593Smuzhiyun  *
3736*4882a593Smuzhiyun  * @get_et_stats:  Ethtool API to get a set of u64 stats.
3737*4882a593Smuzhiyun  *
3738*4882a593Smuzhiyun  * @get_et_strings:  Ethtool API to get a set of strings to describe stats
3739*4882a593Smuzhiyun  *	and perhaps other supported types of ethtool data-sets.
3740*4882a593Smuzhiyun  *
3741*4882a593Smuzhiyun  * @mgd_prepare_tx: Prepare for transmitting a management frame for association
3742*4882a593Smuzhiyun  *	before associated. In multi-channel scenarios, a virtual interface is
3743*4882a593Smuzhiyun  *	bound to a channel before it is associated, but as it isn't associated
3744*4882a593Smuzhiyun  *	yet it need not necessarily be given airtime, in particular since any
3745*4882a593Smuzhiyun  *	transmission to a P2P GO needs to be synchronized against the GO's
3746*4882a593Smuzhiyun  *	powersave state. mac80211 will call this function before transmitting a
3747*4882a593Smuzhiyun  *	management frame prior to having successfully associated to allow the
3748*4882a593Smuzhiyun  *	driver to give it channel time for the transmission, to get a response
3749*4882a593Smuzhiyun  *	and to be able to synchronize with the GO.
3750*4882a593Smuzhiyun  *	For drivers that set %IEEE80211_HW_DEAUTH_NEED_MGD_TX_PREP, mac80211
3751*4882a593Smuzhiyun  *	would also call this function before transmitting a deauthentication
3752*4882a593Smuzhiyun  *	frame in case that no beacon was heard from the AP/P2P GO.
3753*4882a593Smuzhiyun  *	The callback will be called before each transmission and upon return
3754*4882a593Smuzhiyun  *	mac80211 will transmit the frame right away.
3755*4882a593Smuzhiyun  *      If duration is greater than zero, mac80211 hints to the driver the
3756*4882a593Smuzhiyun  *      duration for which the operation is requested.
3757*4882a593Smuzhiyun  *	The callback is optional and can (should!) sleep.
3758*4882a593Smuzhiyun  *
3759*4882a593Smuzhiyun  * @mgd_protect_tdls_discover: Protect a TDLS discovery session. After sending
3760*4882a593Smuzhiyun  *	a TDLS discovery-request, we expect a reply to arrive on the AP's
3761*4882a593Smuzhiyun  *	channel. We must stay on the channel (no PSM, scan, etc.), since a TDLS
3762*4882a593Smuzhiyun  *	setup-response is a direct packet not buffered by the AP.
3763*4882a593Smuzhiyun  *	mac80211 will call this function just before the transmission of a TDLS
3764*4882a593Smuzhiyun  *	discovery-request. The recommended period of protection is at least
3765*4882a593Smuzhiyun  *	2 * (DTIM period).
3766*4882a593Smuzhiyun  *	The callback is optional and can sleep.
3767*4882a593Smuzhiyun  *
3768*4882a593Smuzhiyun  * @add_chanctx: Notifies device driver about new channel context creation.
3769*4882a593Smuzhiyun  *	This callback may sleep.
3770*4882a593Smuzhiyun  * @remove_chanctx: Notifies device driver about channel context destruction.
3771*4882a593Smuzhiyun  *	This callback may sleep.
3772*4882a593Smuzhiyun  * @change_chanctx: Notifies device driver about channel context changes that
3773*4882a593Smuzhiyun  *	may happen when combining different virtual interfaces on the same
3774*4882a593Smuzhiyun  *	channel context with different settings
3775*4882a593Smuzhiyun  *	This callback may sleep.
3776*4882a593Smuzhiyun  * @assign_vif_chanctx: Notifies device driver about channel context being bound
3777*4882a593Smuzhiyun  *	to vif. Possible use is for hw queue remapping.
3778*4882a593Smuzhiyun  *	This callback may sleep.
3779*4882a593Smuzhiyun  * @unassign_vif_chanctx: Notifies device driver about channel context being
3780*4882a593Smuzhiyun  *	unbound from vif.
3781*4882a593Smuzhiyun  *	This callback may sleep.
3782*4882a593Smuzhiyun  * @switch_vif_chanctx: switch a number of vifs from one chanctx to
3783*4882a593Smuzhiyun  *	another, as specified in the list of
3784*4882a593Smuzhiyun  *	@ieee80211_vif_chanctx_switch passed to the driver, according
3785*4882a593Smuzhiyun  *	to the mode defined in &ieee80211_chanctx_switch_mode.
3786*4882a593Smuzhiyun  *	This callback may sleep.
3787*4882a593Smuzhiyun  *
3788*4882a593Smuzhiyun  * @start_ap: Start operation on the AP interface, this is called after all the
3789*4882a593Smuzhiyun  *	information in bss_conf is set and beacon can be retrieved. A channel
3790*4882a593Smuzhiyun  *	context is bound before this is called. Note that if the driver uses
3791*4882a593Smuzhiyun  *	software scan or ROC, this (and @stop_ap) isn't called when the AP is
3792*4882a593Smuzhiyun  *	just "paused" for scanning/ROC, which is indicated by the beacon being
3793*4882a593Smuzhiyun  *	disabled/enabled via @bss_info_changed.
3794*4882a593Smuzhiyun  * @stop_ap: Stop operation on the AP interface.
3795*4882a593Smuzhiyun  *
3796*4882a593Smuzhiyun  * @reconfig_complete: Called after a call to ieee80211_restart_hw() and
3797*4882a593Smuzhiyun  *	during resume, when the reconfiguration has completed.
3798*4882a593Smuzhiyun  *	This can help the driver implement the reconfiguration step (and
3799*4882a593Smuzhiyun  *	indicate mac80211 is ready to receive frames).
3800*4882a593Smuzhiyun  *	This callback may sleep.
3801*4882a593Smuzhiyun  *
3802*4882a593Smuzhiyun  * @ipv6_addr_change: IPv6 address assignment on the given interface changed.
3803*4882a593Smuzhiyun  *	Currently, this is only called for managed or P2P client interfaces.
3804*4882a593Smuzhiyun  *	This callback is optional; it must not sleep.
3805*4882a593Smuzhiyun  *
3806*4882a593Smuzhiyun  * @channel_switch_beacon: Starts a channel switch to a new channel.
3807*4882a593Smuzhiyun  *	Beacons are modified to include CSA or ECSA IEs before calling this
3808*4882a593Smuzhiyun  *	function. The corresponding count fields in these IEs must be
3809*4882a593Smuzhiyun  *	decremented, and when they reach 1 the driver must call
3810*4882a593Smuzhiyun  *	ieee80211_csa_finish(). Drivers which use ieee80211_beacon_get()
3811*4882a593Smuzhiyun  *	get the csa counter decremented by mac80211, but must check if it is
3812*4882a593Smuzhiyun  *	1 using ieee80211_beacon_counter_is_complete() after the beacon has been
3813*4882a593Smuzhiyun  *	transmitted and then call ieee80211_csa_finish().
3814*4882a593Smuzhiyun  *	If the CSA count starts as zero or 1, this function will not be called,
3815*4882a593Smuzhiyun  *	since there won't be any time to beacon before the switch anyway.
3816*4882a593Smuzhiyun  * @pre_channel_switch: This is an optional callback that is called
3817*4882a593Smuzhiyun  *	before a channel switch procedure is started (ie. when a STA
3818*4882a593Smuzhiyun  *	gets a CSA or a userspace initiated channel-switch), allowing
3819*4882a593Smuzhiyun  *	the driver to prepare for the channel switch.
3820*4882a593Smuzhiyun  * @post_channel_switch: This is an optional callback that is called
3821*4882a593Smuzhiyun  *	after a channel switch procedure is completed, allowing the
3822*4882a593Smuzhiyun  *	driver to go back to a normal configuration.
3823*4882a593Smuzhiyun  * @abort_channel_switch: This is an optional callback that is called
3824*4882a593Smuzhiyun  *	when channel switch procedure was completed, allowing the
3825*4882a593Smuzhiyun  *	driver to go back to a normal configuration.
3826*4882a593Smuzhiyun  * @channel_switch_rx_beacon: This is an optional callback that is called
3827*4882a593Smuzhiyun  *	when channel switch procedure is in progress and additional beacon with
3828*4882a593Smuzhiyun  *	CSA IE was received, allowing driver to track changes in count.
3829*4882a593Smuzhiyun  * @join_ibss: Join an IBSS (on an IBSS interface); this is called after all
3830*4882a593Smuzhiyun  *	information in bss_conf is set up and the beacon can be retrieved. A
3831*4882a593Smuzhiyun  *	channel context is bound before this is called.
3832*4882a593Smuzhiyun  * @leave_ibss: Leave the IBSS again.
3833*4882a593Smuzhiyun  *
3834*4882a593Smuzhiyun  * @get_expected_throughput: extract the expected throughput towards the
3835*4882a593Smuzhiyun  *	specified station. The returned value is expressed in Kbps. It returns 0
3836*4882a593Smuzhiyun  *	if the RC algorithm does not have proper data to provide.
3837*4882a593Smuzhiyun  *
3838*4882a593Smuzhiyun  * @get_txpower: get current maximum tx power (in dBm) based on configuration
3839*4882a593Smuzhiyun  *	and hardware limits.
3840*4882a593Smuzhiyun  *
3841*4882a593Smuzhiyun  * @tdls_channel_switch: Start channel-switching with a TDLS peer. The driver
3842*4882a593Smuzhiyun  *	is responsible for continually initiating channel-switching operations
3843*4882a593Smuzhiyun  *	and returning to the base channel for communication with the AP. The
3844*4882a593Smuzhiyun  *	driver receives a channel-switch request template and the location of
3845*4882a593Smuzhiyun  *	the switch-timing IE within the template as part of the invocation.
3846*4882a593Smuzhiyun  *	The template is valid only within the call, and the driver can
3847*4882a593Smuzhiyun  *	optionally copy the skb for further re-use.
3848*4882a593Smuzhiyun  * @tdls_cancel_channel_switch: Stop channel-switching with a TDLS peer. Both
3849*4882a593Smuzhiyun  *	peers must be on the base channel when the call completes.
3850*4882a593Smuzhiyun  * @tdls_recv_channel_switch: a TDLS channel-switch related frame (request or
3851*4882a593Smuzhiyun  *	response) has been received from a remote peer. The driver gets
3852*4882a593Smuzhiyun  *	parameters parsed from the incoming frame and may use them to continue
3853*4882a593Smuzhiyun  *	an ongoing channel-switch operation. In addition, a channel-switch
3854*4882a593Smuzhiyun  *	response template is provided, together with the location of the
3855*4882a593Smuzhiyun  *	switch-timing IE within the template. The skb can only be used within
3856*4882a593Smuzhiyun  *	the function call.
3857*4882a593Smuzhiyun  *
3858*4882a593Smuzhiyun  * @wake_tx_queue: Called when new packets have been added to the queue.
3859*4882a593Smuzhiyun  * @sync_rx_queues: Process all pending frames in RSS queues. This is a
3860*4882a593Smuzhiyun  *	synchronization which is needed in case driver has in its RSS queues
3861*4882a593Smuzhiyun  *	pending frames that were received prior to the control path action
3862*4882a593Smuzhiyun  *	currently taken (e.g. disassociation) but are not processed yet.
3863*4882a593Smuzhiyun  *
3864*4882a593Smuzhiyun  * @start_nan: join an existing NAN cluster, or create a new one.
3865*4882a593Smuzhiyun  * @stop_nan: leave the NAN cluster.
3866*4882a593Smuzhiyun  * @nan_change_conf: change NAN configuration. The data in cfg80211_nan_conf
3867*4882a593Smuzhiyun  *	contains full new configuration and changes specify which parameters
3868*4882a593Smuzhiyun  *	are changed with respect to the last NAN config.
3869*4882a593Smuzhiyun  *	The driver gets both full configuration and the changed parameters since
3870*4882a593Smuzhiyun  *	some devices may need the full configuration while others need only the
3871*4882a593Smuzhiyun  *	changed parameters.
3872*4882a593Smuzhiyun  * @add_nan_func: Add a NAN function. Returns 0 on success. The data in
3873*4882a593Smuzhiyun  *	cfg80211_nan_func must not be referenced outside the scope of
3874*4882a593Smuzhiyun  *	this call.
3875*4882a593Smuzhiyun  * @del_nan_func: Remove a NAN function. The driver must call
3876*4882a593Smuzhiyun  *	ieee80211_nan_func_terminated() with
3877*4882a593Smuzhiyun  *	NL80211_NAN_FUNC_TERM_REASON_USER_REQUEST reason code upon removal.
3878*4882a593Smuzhiyun  * @can_aggregate_in_amsdu: Called in order to determine if HW supports
3879*4882a593Smuzhiyun  *	aggregating two specific frames in the same A-MSDU. The relation
3880*4882a593Smuzhiyun  *	between the skbs should be symmetric and transitive. Note that while
3881*4882a593Smuzhiyun  *	skb is always a real frame, head may or may not be an A-MSDU.
3882*4882a593Smuzhiyun  * @get_ftm_responder_stats: Retrieve FTM responder statistics, if available.
3883*4882a593Smuzhiyun  *	Statistics should be cumulative, currently no way to reset is provided.
3884*4882a593Smuzhiyun  *
3885*4882a593Smuzhiyun  * @start_pmsr: start peer measurement (e.g. FTM) (this call can sleep)
3886*4882a593Smuzhiyun  * @abort_pmsr: abort peer measurement (this call can sleep)
3887*4882a593Smuzhiyun  * @set_tid_config: Apply TID specific configurations. This callback may sleep.
3888*4882a593Smuzhiyun  * @reset_tid_config: Reset TID specific configuration for the peer.
3889*4882a593Smuzhiyun  *	This callback may sleep.
3890*4882a593Smuzhiyun  * @update_vif_offload: Update virtual interface offload flags
3891*4882a593Smuzhiyun  *	This callback may sleep.
3892*4882a593Smuzhiyun  * @sta_set_4addr: Called to notify the driver when a station starts/stops using
3893*4882a593Smuzhiyun  *	4-address mode
3894*4882a593Smuzhiyun  */
3895*4882a593Smuzhiyun struct ieee80211_ops {
3896*4882a593Smuzhiyun 	void (*tx)(struct ieee80211_hw *hw,
3897*4882a593Smuzhiyun 		   struct ieee80211_tx_control *control,
3898*4882a593Smuzhiyun 		   struct sk_buff *skb);
3899*4882a593Smuzhiyun 	int (*start)(struct ieee80211_hw *hw);
3900*4882a593Smuzhiyun 	void (*stop)(struct ieee80211_hw *hw);
3901*4882a593Smuzhiyun #ifdef CONFIG_PM
3902*4882a593Smuzhiyun 	int (*suspend)(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan);
3903*4882a593Smuzhiyun 	int (*resume)(struct ieee80211_hw *hw);
3904*4882a593Smuzhiyun 	void (*set_wakeup)(struct ieee80211_hw *hw, bool enabled);
3905*4882a593Smuzhiyun #endif
3906*4882a593Smuzhiyun 	int (*add_interface)(struct ieee80211_hw *hw,
3907*4882a593Smuzhiyun 			     struct ieee80211_vif *vif);
3908*4882a593Smuzhiyun 	int (*change_interface)(struct ieee80211_hw *hw,
3909*4882a593Smuzhiyun 				struct ieee80211_vif *vif,
3910*4882a593Smuzhiyun 				enum nl80211_iftype new_type, bool p2p);
3911*4882a593Smuzhiyun 	void (*remove_interface)(struct ieee80211_hw *hw,
3912*4882a593Smuzhiyun 				 struct ieee80211_vif *vif);
3913*4882a593Smuzhiyun 	int (*config)(struct ieee80211_hw *hw, u32 changed);
3914*4882a593Smuzhiyun 	void (*bss_info_changed)(struct ieee80211_hw *hw,
3915*4882a593Smuzhiyun 				 struct ieee80211_vif *vif,
3916*4882a593Smuzhiyun 				 struct ieee80211_bss_conf *info,
3917*4882a593Smuzhiyun 				 u32 changed);
3918*4882a593Smuzhiyun 
3919*4882a593Smuzhiyun 	int (*start_ap)(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
3920*4882a593Smuzhiyun 	void (*stop_ap)(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
3921*4882a593Smuzhiyun 
3922*4882a593Smuzhiyun 	u64 (*prepare_multicast)(struct ieee80211_hw *hw,
3923*4882a593Smuzhiyun 				 struct netdev_hw_addr_list *mc_list);
3924*4882a593Smuzhiyun 	void (*configure_filter)(struct ieee80211_hw *hw,
3925*4882a593Smuzhiyun 				 unsigned int changed_flags,
3926*4882a593Smuzhiyun 				 unsigned int *total_flags,
3927*4882a593Smuzhiyun 				 u64 multicast);
3928*4882a593Smuzhiyun 	void (*config_iface_filter)(struct ieee80211_hw *hw,
3929*4882a593Smuzhiyun 				    struct ieee80211_vif *vif,
3930*4882a593Smuzhiyun 				    unsigned int filter_flags,
3931*4882a593Smuzhiyun 				    unsigned int changed_flags);
3932*4882a593Smuzhiyun 	int (*set_tim)(struct ieee80211_hw *hw, struct ieee80211_sta *sta,
3933*4882a593Smuzhiyun 		       bool set);
3934*4882a593Smuzhiyun 	int (*set_key)(struct ieee80211_hw *hw, enum set_key_cmd cmd,
3935*4882a593Smuzhiyun 		       struct ieee80211_vif *vif, struct ieee80211_sta *sta,
3936*4882a593Smuzhiyun 		       struct ieee80211_key_conf *key);
3937*4882a593Smuzhiyun 	void (*update_tkip_key)(struct ieee80211_hw *hw,
3938*4882a593Smuzhiyun 				struct ieee80211_vif *vif,
3939*4882a593Smuzhiyun 				struct ieee80211_key_conf *conf,
3940*4882a593Smuzhiyun 				struct ieee80211_sta *sta,
3941*4882a593Smuzhiyun 				u32 iv32, u16 *phase1key);
3942*4882a593Smuzhiyun 	void (*set_rekey_data)(struct ieee80211_hw *hw,
3943*4882a593Smuzhiyun 			       struct ieee80211_vif *vif,
3944*4882a593Smuzhiyun 			       struct cfg80211_gtk_rekey_data *data);
3945*4882a593Smuzhiyun 	void (*set_default_unicast_key)(struct ieee80211_hw *hw,
3946*4882a593Smuzhiyun 					struct ieee80211_vif *vif, int idx);
3947*4882a593Smuzhiyun 	int (*hw_scan)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
3948*4882a593Smuzhiyun 		       struct ieee80211_scan_request *req);
3949*4882a593Smuzhiyun 	void (*cancel_hw_scan)(struct ieee80211_hw *hw,
3950*4882a593Smuzhiyun 			       struct ieee80211_vif *vif);
3951*4882a593Smuzhiyun 	int (*sched_scan_start)(struct ieee80211_hw *hw,
3952*4882a593Smuzhiyun 				struct ieee80211_vif *vif,
3953*4882a593Smuzhiyun 				struct cfg80211_sched_scan_request *req,
3954*4882a593Smuzhiyun 				struct ieee80211_scan_ies *ies);
3955*4882a593Smuzhiyun 	int (*sched_scan_stop)(struct ieee80211_hw *hw,
3956*4882a593Smuzhiyun 			       struct ieee80211_vif *vif);
3957*4882a593Smuzhiyun 	void (*sw_scan_start)(struct ieee80211_hw *hw,
3958*4882a593Smuzhiyun 			      struct ieee80211_vif *vif,
3959*4882a593Smuzhiyun 			      const u8 *mac_addr);
3960*4882a593Smuzhiyun 	void (*sw_scan_complete)(struct ieee80211_hw *hw,
3961*4882a593Smuzhiyun 				 struct ieee80211_vif *vif);
3962*4882a593Smuzhiyun 	int (*get_stats)(struct ieee80211_hw *hw,
3963*4882a593Smuzhiyun 			 struct ieee80211_low_level_stats *stats);
3964*4882a593Smuzhiyun 	void (*get_key_seq)(struct ieee80211_hw *hw,
3965*4882a593Smuzhiyun 			    struct ieee80211_key_conf *key,
3966*4882a593Smuzhiyun 			    struct ieee80211_key_seq *seq);
3967*4882a593Smuzhiyun 	int (*set_frag_threshold)(struct ieee80211_hw *hw, u32 value);
3968*4882a593Smuzhiyun 	int (*set_rts_threshold)(struct ieee80211_hw *hw, u32 value);
3969*4882a593Smuzhiyun 	int (*sta_add)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
3970*4882a593Smuzhiyun 		       struct ieee80211_sta *sta);
3971*4882a593Smuzhiyun 	int (*sta_remove)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
3972*4882a593Smuzhiyun 			  struct ieee80211_sta *sta);
3973*4882a593Smuzhiyun #ifdef CONFIG_MAC80211_DEBUGFS
3974*4882a593Smuzhiyun 	void (*sta_add_debugfs)(struct ieee80211_hw *hw,
3975*4882a593Smuzhiyun 				struct ieee80211_vif *vif,
3976*4882a593Smuzhiyun 				struct ieee80211_sta *sta,
3977*4882a593Smuzhiyun 				struct dentry *dir);
3978*4882a593Smuzhiyun #endif
3979*4882a593Smuzhiyun 	void (*sta_notify)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
3980*4882a593Smuzhiyun 			enum sta_notify_cmd, struct ieee80211_sta *sta);
3981*4882a593Smuzhiyun 	int (*sta_set_txpwr)(struct ieee80211_hw *hw,
3982*4882a593Smuzhiyun 			     struct ieee80211_vif *vif,
3983*4882a593Smuzhiyun 			     struct ieee80211_sta *sta);
3984*4882a593Smuzhiyun 	int (*sta_state)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
3985*4882a593Smuzhiyun 			 struct ieee80211_sta *sta,
3986*4882a593Smuzhiyun 			 enum ieee80211_sta_state old_state,
3987*4882a593Smuzhiyun 			 enum ieee80211_sta_state new_state);
3988*4882a593Smuzhiyun 	void (*sta_pre_rcu_remove)(struct ieee80211_hw *hw,
3989*4882a593Smuzhiyun 				   struct ieee80211_vif *vif,
3990*4882a593Smuzhiyun 				   struct ieee80211_sta *sta);
3991*4882a593Smuzhiyun 	void (*sta_rc_update)(struct ieee80211_hw *hw,
3992*4882a593Smuzhiyun 			      struct ieee80211_vif *vif,
3993*4882a593Smuzhiyun 			      struct ieee80211_sta *sta,
3994*4882a593Smuzhiyun 			      u32 changed);
3995*4882a593Smuzhiyun 	void (*sta_rate_tbl_update)(struct ieee80211_hw *hw,
3996*4882a593Smuzhiyun 				    struct ieee80211_vif *vif,
3997*4882a593Smuzhiyun 				    struct ieee80211_sta *sta);
3998*4882a593Smuzhiyun 	void (*sta_statistics)(struct ieee80211_hw *hw,
3999*4882a593Smuzhiyun 			       struct ieee80211_vif *vif,
4000*4882a593Smuzhiyun 			       struct ieee80211_sta *sta,
4001*4882a593Smuzhiyun 			       struct station_info *sinfo);
4002*4882a593Smuzhiyun 	int (*conf_tx)(struct ieee80211_hw *hw,
4003*4882a593Smuzhiyun 		       struct ieee80211_vif *vif, u16 ac,
4004*4882a593Smuzhiyun 		       const struct ieee80211_tx_queue_params *params);
4005*4882a593Smuzhiyun 	u64 (*get_tsf)(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
4006*4882a593Smuzhiyun 	void (*set_tsf)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
4007*4882a593Smuzhiyun 			u64 tsf);
4008*4882a593Smuzhiyun 	void (*offset_tsf)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
4009*4882a593Smuzhiyun 			   s64 offset);
4010*4882a593Smuzhiyun 	void (*reset_tsf)(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
4011*4882a593Smuzhiyun 	int (*tx_last_beacon)(struct ieee80211_hw *hw);
4012*4882a593Smuzhiyun 
4013*4882a593Smuzhiyun 	/**
4014*4882a593Smuzhiyun 	 * @ampdu_action:
4015*4882a593Smuzhiyun 	 * Perform a certain A-MPDU action.
4016*4882a593Smuzhiyun 	 * The RA/TID combination determines the destination and TID we want
4017*4882a593Smuzhiyun 	 * the ampdu action to be performed for. The action is defined through
4018*4882a593Smuzhiyun 	 * ieee80211_ampdu_mlme_action.
4019*4882a593Smuzhiyun 	 * When the action is set to %IEEE80211_AMPDU_TX_OPERATIONAL the driver
4020*4882a593Smuzhiyun 	 * may neither send aggregates containing more subframes than @buf_size
4021*4882a593Smuzhiyun 	 * nor send aggregates in a way that lost frames would exceed the
4022*4882a593Smuzhiyun 	 * buffer size. If just limiting the aggregate size, this would be
4023*4882a593Smuzhiyun 	 * possible with a buf_size of 8:
4024*4882a593Smuzhiyun 	 *
4025*4882a593Smuzhiyun 	 * - ``TX: 1.....7``
4026*4882a593Smuzhiyun 	 * - ``RX:  2....7`` (lost frame #1)
4027*4882a593Smuzhiyun 	 * - ``TX:        8..1...``
4028*4882a593Smuzhiyun 	 *
4029*4882a593Smuzhiyun 	 * which is invalid since #1 was now re-transmitted well past the
4030*4882a593Smuzhiyun 	 * buffer size of 8. Correct ways to retransmit #1 would be:
4031*4882a593Smuzhiyun 	 *
4032*4882a593Smuzhiyun 	 * - ``TX:        1   or``
4033*4882a593Smuzhiyun 	 * - ``TX:        18  or``
4034*4882a593Smuzhiyun 	 * - ``TX:        81``
4035*4882a593Smuzhiyun 	 *
4036*4882a593Smuzhiyun 	 * Even ``189`` would be wrong since 1 could be lost again.
4037*4882a593Smuzhiyun 	 *
4038*4882a593Smuzhiyun 	 * Returns a negative error code on failure. The driver may return
4039*4882a593Smuzhiyun 	 * %IEEE80211_AMPDU_TX_START_IMMEDIATE for %IEEE80211_AMPDU_TX_START
4040*4882a593Smuzhiyun 	 * if the session can start immediately.
4041*4882a593Smuzhiyun 	 *
4042*4882a593Smuzhiyun 	 * The callback can sleep.
4043*4882a593Smuzhiyun 	 */
4044*4882a593Smuzhiyun 	int (*ampdu_action)(struct ieee80211_hw *hw,
4045*4882a593Smuzhiyun 			    struct ieee80211_vif *vif,
4046*4882a593Smuzhiyun 			    struct ieee80211_ampdu_params *params);
4047*4882a593Smuzhiyun 	int (*get_survey)(struct ieee80211_hw *hw, int idx,
4048*4882a593Smuzhiyun 		struct survey_info *survey);
4049*4882a593Smuzhiyun 	void (*rfkill_poll)(struct ieee80211_hw *hw);
4050*4882a593Smuzhiyun 	void (*set_coverage_class)(struct ieee80211_hw *hw, s16 coverage_class);
4051*4882a593Smuzhiyun #ifdef CONFIG_NL80211_TESTMODE
4052*4882a593Smuzhiyun 	int (*testmode_cmd)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
4053*4882a593Smuzhiyun 			    void *data, int len);
4054*4882a593Smuzhiyun 	int (*testmode_dump)(struct ieee80211_hw *hw, struct sk_buff *skb,
4055*4882a593Smuzhiyun 			     struct netlink_callback *cb,
4056*4882a593Smuzhiyun 			     void *data, int len);
4057*4882a593Smuzhiyun #endif
4058*4882a593Smuzhiyun 	void (*flush)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
4059*4882a593Smuzhiyun 		      u32 queues, bool drop);
4060*4882a593Smuzhiyun 	void (*channel_switch)(struct ieee80211_hw *hw,
4061*4882a593Smuzhiyun 			       struct ieee80211_vif *vif,
4062*4882a593Smuzhiyun 			       struct ieee80211_channel_switch *ch_switch);
4063*4882a593Smuzhiyun 	int (*set_antenna)(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant);
4064*4882a593Smuzhiyun 	int (*get_antenna)(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant);
4065*4882a593Smuzhiyun 
4066*4882a593Smuzhiyun 	int (*remain_on_channel)(struct ieee80211_hw *hw,
4067*4882a593Smuzhiyun 				 struct ieee80211_vif *vif,
4068*4882a593Smuzhiyun 				 struct ieee80211_channel *chan,
4069*4882a593Smuzhiyun 				 int duration,
4070*4882a593Smuzhiyun 				 enum ieee80211_roc_type type);
4071*4882a593Smuzhiyun 	int (*cancel_remain_on_channel)(struct ieee80211_hw *hw,
4072*4882a593Smuzhiyun 					struct ieee80211_vif *vif);
4073*4882a593Smuzhiyun 	int (*set_ringparam)(struct ieee80211_hw *hw, u32 tx, u32 rx);
4074*4882a593Smuzhiyun 	void (*get_ringparam)(struct ieee80211_hw *hw,
4075*4882a593Smuzhiyun 			      u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max);
4076*4882a593Smuzhiyun 	bool (*tx_frames_pending)(struct ieee80211_hw *hw);
4077*4882a593Smuzhiyun 	int (*set_bitrate_mask)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
4078*4882a593Smuzhiyun 				const struct cfg80211_bitrate_mask *mask);
4079*4882a593Smuzhiyun 	void (*event_callback)(struct ieee80211_hw *hw,
4080*4882a593Smuzhiyun 			       struct ieee80211_vif *vif,
4081*4882a593Smuzhiyun 			       const struct ieee80211_event *event);
4082*4882a593Smuzhiyun 
4083*4882a593Smuzhiyun 	void (*allow_buffered_frames)(struct ieee80211_hw *hw,
4084*4882a593Smuzhiyun 				      struct ieee80211_sta *sta,
4085*4882a593Smuzhiyun 				      u16 tids, int num_frames,
4086*4882a593Smuzhiyun 				      enum ieee80211_frame_release_type reason,
4087*4882a593Smuzhiyun 				      bool more_data);
4088*4882a593Smuzhiyun 	void (*release_buffered_frames)(struct ieee80211_hw *hw,
4089*4882a593Smuzhiyun 					struct ieee80211_sta *sta,
4090*4882a593Smuzhiyun 					u16 tids, int num_frames,
4091*4882a593Smuzhiyun 					enum ieee80211_frame_release_type reason,
4092*4882a593Smuzhiyun 					bool more_data);
4093*4882a593Smuzhiyun 
4094*4882a593Smuzhiyun 	int	(*get_et_sset_count)(struct ieee80211_hw *hw,
4095*4882a593Smuzhiyun 				     struct ieee80211_vif *vif, int sset);
4096*4882a593Smuzhiyun 	void	(*get_et_stats)(struct ieee80211_hw *hw,
4097*4882a593Smuzhiyun 				struct ieee80211_vif *vif,
4098*4882a593Smuzhiyun 				struct ethtool_stats *stats, u64 *data);
4099*4882a593Smuzhiyun 	void	(*get_et_strings)(struct ieee80211_hw *hw,
4100*4882a593Smuzhiyun 				  struct ieee80211_vif *vif,
4101*4882a593Smuzhiyun 				  u32 sset, u8 *data);
4102*4882a593Smuzhiyun 
4103*4882a593Smuzhiyun 	void	(*mgd_prepare_tx)(struct ieee80211_hw *hw,
4104*4882a593Smuzhiyun 				  struct ieee80211_vif *vif,
4105*4882a593Smuzhiyun 				  u16 duration);
4106*4882a593Smuzhiyun 
4107*4882a593Smuzhiyun 	void	(*mgd_protect_tdls_discover)(struct ieee80211_hw *hw,
4108*4882a593Smuzhiyun 					     struct ieee80211_vif *vif);
4109*4882a593Smuzhiyun 
4110*4882a593Smuzhiyun 	int (*add_chanctx)(struct ieee80211_hw *hw,
4111*4882a593Smuzhiyun 			   struct ieee80211_chanctx_conf *ctx);
4112*4882a593Smuzhiyun 	void (*remove_chanctx)(struct ieee80211_hw *hw,
4113*4882a593Smuzhiyun 			       struct ieee80211_chanctx_conf *ctx);
4114*4882a593Smuzhiyun 	void (*change_chanctx)(struct ieee80211_hw *hw,
4115*4882a593Smuzhiyun 			       struct ieee80211_chanctx_conf *ctx,
4116*4882a593Smuzhiyun 			       u32 changed);
4117*4882a593Smuzhiyun 	int (*assign_vif_chanctx)(struct ieee80211_hw *hw,
4118*4882a593Smuzhiyun 				  struct ieee80211_vif *vif,
4119*4882a593Smuzhiyun 				  struct ieee80211_chanctx_conf *ctx);
4120*4882a593Smuzhiyun 	void (*unassign_vif_chanctx)(struct ieee80211_hw *hw,
4121*4882a593Smuzhiyun 				     struct ieee80211_vif *vif,
4122*4882a593Smuzhiyun 				     struct ieee80211_chanctx_conf *ctx);
4123*4882a593Smuzhiyun 	int (*switch_vif_chanctx)(struct ieee80211_hw *hw,
4124*4882a593Smuzhiyun 				  struct ieee80211_vif_chanctx_switch *vifs,
4125*4882a593Smuzhiyun 				  int n_vifs,
4126*4882a593Smuzhiyun 				  enum ieee80211_chanctx_switch_mode mode);
4127*4882a593Smuzhiyun 
4128*4882a593Smuzhiyun 	void (*reconfig_complete)(struct ieee80211_hw *hw,
4129*4882a593Smuzhiyun 				  enum ieee80211_reconfig_type reconfig_type);
4130*4882a593Smuzhiyun 
4131*4882a593Smuzhiyun #if IS_ENABLED(CONFIG_IPV6)
4132*4882a593Smuzhiyun 	void (*ipv6_addr_change)(struct ieee80211_hw *hw,
4133*4882a593Smuzhiyun 				 struct ieee80211_vif *vif,
4134*4882a593Smuzhiyun 				 struct inet6_dev *idev);
4135*4882a593Smuzhiyun #endif
4136*4882a593Smuzhiyun 	void (*channel_switch_beacon)(struct ieee80211_hw *hw,
4137*4882a593Smuzhiyun 				      struct ieee80211_vif *vif,
4138*4882a593Smuzhiyun 				      struct cfg80211_chan_def *chandef);
4139*4882a593Smuzhiyun 	int (*pre_channel_switch)(struct ieee80211_hw *hw,
4140*4882a593Smuzhiyun 				  struct ieee80211_vif *vif,
4141*4882a593Smuzhiyun 				  struct ieee80211_channel_switch *ch_switch);
4142*4882a593Smuzhiyun 
4143*4882a593Smuzhiyun 	int (*post_channel_switch)(struct ieee80211_hw *hw,
4144*4882a593Smuzhiyun 				   struct ieee80211_vif *vif);
4145*4882a593Smuzhiyun 	void (*abort_channel_switch)(struct ieee80211_hw *hw,
4146*4882a593Smuzhiyun 				     struct ieee80211_vif *vif);
4147*4882a593Smuzhiyun 	void (*channel_switch_rx_beacon)(struct ieee80211_hw *hw,
4148*4882a593Smuzhiyun 					 struct ieee80211_vif *vif,
4149*4882a593Smuzhiyun 					 struct ieee80211_channel_switch *ch_switch);
4150*4882a593Smuzhiyun 
4151*4882a593Smuzhiyun 	int (*join_ibss)(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
4152*4882a593Smuzhiyun 	void (*leave_ibss)(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
4153*4882a593Smuzhiyun 	u32 (*get_expected_throughput)(struct ieee80211_hw *hw,
4154*4882a593Smuzhiyun 				       struct ieee80211_sta *sta);
4155*4882a593Smuzhiyun 	int (*get_txpower)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
4156*4882a593Smuzhiyun 			   int *dbm);
4157*4882a593Smuzhiyun 
4158*4882a593Smuzhiyun 	int (*tdls_channel_switch)(struct ieee80211_hw *hw,
4159*4882a593Smuzhiyun 				   struct ieee80211_vif *vif,
4160*4882a593Smuzhiyun 				   struct ieee80211_sta *sta, u8 oper_class,
4161*4882a593Smuzhiyun 				   struct cfg80211_chan_def *chandef,
4162*4882a593Smuzhiyun 				   struct sk_buff *tmpl_skb, u32 ch_sw_tm_ie);
4163*4882a593Smuzhiyun 	void (*tdls_cancel_channel_switch)(struct ieee80211_hw *hw,
4164*4882a593Smuzhiyun 					   struct ieee80211_vif *vif,
4165*4882a593Smuzhiyun 					   struct ieee80211_sta *sta);
4166*4882a593Smuzhiyun 	void (*tdls_recv_channel_switch)(struct ieee80211_hw *hw,
4167*4882a593Smuzhiyun 					 struct ieee80211_vif *vif,
4168*4882a593Smuzhiyun 					 struct ieee80211_tdls_ch_sw_params *params);
4169*4882a593Smuzhiyun 
4170*4882a593Smuzhiyun 	void (*wake_tx_queue)(struct ieee80211_hw *hw,
4171*4882a593Smuzhiyun 			      struct ieee80211_txq *txq);
4172*4882a593Smuzhiyun 	void (*sync_rx_queues)(struct ieee80211_hw *hw);
4173*4882a593Smuzhiyun 
4174*4882a593Smuzhiyun 	int (*start_nan)(struct ieee80211_hw *hw,
4175*4882a593Smuzhiyun 			 struct ieee80211_vif *vif,
4176*4882a593Smuzhiyun 			 struct cfg80211_nan_conf *conf);
4177*4882a593Smuzhiyun 	int (*stop_nan)(struct ieee80211_hw *hw,
4178*4882a593Smuzhiyun 			struct ieee80211_vif *vif);
4179*4882a593Smuzhiyun 	int (*nan_change_conf)(struct ieee80211_hw *hw,
4180*4882a593Smuzhiyun 			       struct ieee80211_vif *vif,
4181*4882a593Smuzhiyun 			       struct cfg80211_nan_conf *conf, u32 changes);
4182*4882a593Smuzhiyun 	int (*add_nan_func)(struct ieee80211_hw *hw,
4183*4882a593Smuzhiyun 			    struct ieee80211_vif *vif,
4184*4882a593Smuzhiyun 			    const struct cfg80211_nan_func *nan_func);
4185*4882a593Smuzhiyun 	void (*del_nan_func)(struct ieee80211_hw *hw,
4186*4882a593Smuzhiyun 			    struct ieee80211_vif *vif,
4187*4882a593Smuzhiyun 			    u8 instance_id);
4188*4882a593Smuzhiyun 	bool (*can_aggregate_in_amsdu)(struct ieee80211_hw *hw,
4189*4882a593Smuzhiyun 				       struct sk_buff *head,
4190*4882a593Smuzhiyun 				       struct sk_buff *skb);
4191*4882a593Smuzhiyun 	int (*get_ftm_responder_stats)(struct ieee80211_hw *hw,
4192*4882a593Smuzhiyun 				       struct ieee80211_vif *vif,
4193*4882a593Smuzhiyun 				       struct cfg80211_ftm_responder_stats *ftm_stats);
4194*4882a593Smuzhiyun 	int (*start_pmsr)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
4195*4882a593Smuzhiyun 			  struct cfg80211_pmsr_request *request);
4196*4882a593Smuzhiyun 	void (*abort_pmsr)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
4197*4882a593Smuzhiyun 			   struct cfg80211_pmsr_request *request);
4198*4882a593Smuzhiyun 	int (*set_tid_config)(struct ieee80211_hw *hw,
4199*4882a593Smuzhiyun 			      struct ieee80211_vif *vif,
4200*4882a593Smuzhiyun 			      struct ieee80211_sta *sta,
4201*4882a593Smuzhiyun 			      struct cfg80211_tid_config *tid_conf);
4202*4882a593Smuzhiyun 	int (*reset_tid_config)(struct ieee80211_hw *hw,
4203*4882a593Smuzhiyun 				struct ieee80211_vif *vif,
4204*4882a593Smuzhiyun 				struct ieee80211_sta *sta, u8 tids);
4205*4882a593Smuzhiyun 	void (*update_vif_offload)(struct ieee80211_hw *hw,
4206*4882a593Smuzhiyun 				   struct ieee80211_vif *vif);
4207*4882a593Smuzhiyun 	void (*sta_set_4addr)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
4208*4882a593Smuzhiyun 			      struct ieee80211_sta *sta, bool enabled);
4209*4882a593Smuzhiyun 
4210*4882a593Smuzhiyun 	ANDROID_KABI_RESERVE(1);
4211*4882a593Smuzhiyun 	ANDROID_KABI_RESERVE(2);
4212*4882a593Smuzhiyun 	ANDROID_KABI_RESERVE(3);
4213*4882a593Smuzhiyun 	ANDROID_KABI_RESERVE(4);
4214*4882a593Smuzhiyun };
4215*4882a593Smuzhiyun 
4216*4882a593Smuzhiyun /**
4217*4882a593Smuzhiyun  * ieee80211_alloc_hw_nm - Allocate a new hardware device
4218*4882a593Smuzhiyun  *
4219*4882a593Smuzhiyun  * This must be called once for each hardware device. The returned pointer
4220*4882a593Smuzhiyun  * must be used to refer to this device when calling other functions.
4221*4882a593Smuzhiyun  * mac80211 allocates a private data area for the driver pointed to by
4222*4882a593Smuzhiyun  * @priv in &struct ieee80211_hw, the size of this area is given as
4223*4882a593Smuzhiyun  * @priv_data_len.
4224*4882a593Smuzhiyun  *
4225*4882a593Smuzhiyun  * @priv_data_len: length of private data
4226*4882a593Smuzhiyun  * @ops: callbacks for this device
4227*4882a593Smuzhiyun  * @requested_name: Requested name for this device.
4228*4882a593Smuzhiyun  *	NULL is valid value, and means use the default naming (phy%d)
4229*4882a593Smuzhiyun  *
4230*4882a593Smuzhiyun  * Return: A pointer to the new hardware device, or %NULL on error.
4231*4882a593Smuzhiyun  */
4232*4882a593Smuzhiyun struct ieee80211_hw *ieee80211_alloc_hw_nm(size_t priv_data_len,
4233*4882a593Smuzhiyun 					   const struct ieee80211_ops *ops,
4234*4882a593Smuzhiyun 					   const char *requested_name);
4235*4882a593Smuzhiyun 
4236*4882a593Smuzhiyun /**
4237*4882a593Smuzhiyun  * ieee80211_alloc_hw - Allocate a new hardware device
4238*4882a593Smuzhiyun  *
4239*4882a593Smuzhiyun  * This must be called once for each hardware device. The returned pointer
4240*4882a593Smuzhiyun  * must be used to refer to this device when calling other functions.
4241*4882a593Smuzhiyun  * mac80211 allocates a private data area for the driver pointed to by
4242*4882a593Smuzhiyun  * @priv in &struct ieee80211_hw, the size of this area is given as
4243*4882a593Smuzhiyun  * @priv_data_len.
4244*4882a593Smuzhiyun  *
4245*4882a593Smuzhiyun  * @priv_data_len: length of private data
4246*4882a593Smuzhiyun  * @ops: callbacks for this device
4247*4882a593Smuzhiyun  *
4248*4882a593Smuzhiyun  * Return: A pointer to the new hardware device, or %NULL on error.
4249*4882a593Smuzhiyun  */
4250*4882a593Smuzhiyun static inline
ieee80211_alloc_hw(size_t priv_data_len,const struct ieee80211_ops * ops)4251*4882a593Smuzhiyun struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
4252*4882a593Smuzhiyun 					const struct ieee80211_ops *ops)
4253*4882a593Smuzhiyun {
4254*4882a593Smuzhiyun 	return ieee80211_alloc_hw_nm(priv_data_len, ops, NULL);
4255*4882a593Smuzhiyun }
4256*4882a593Smuzhiyun 
4257*4882a593Smuzhiyun /**
4258*4882a593Smuzhiyun  * ieee80211_register_hw - Register hardware device
4259*4882a593Smuzhiyun  *
4260*4882a593Smuzhiyun  * You must call this function before any other functions in
4261*4882a593Smuzhiyun  * mac80211. Note that before a hardware can be registered, you
4262*4882a593Smuzhiyun  * need to fill the contained wiphy's information.
4263*4882a593Smuzhiyun  *
4264*4882a593Smuzhiyun  * @hw: the device to register as returned by ieee80211_alloc_hw()
4265*4882a593Smuzhiyun  *
4266*4882a593Smuzhiyun  * Return: 0 on success. An error code otherwise.
4267*4882a593Smuzhiyun  */
4268*4882a593Smuzhiyun int ieee80211_register_hw(struct ieee80211_hw *hw);
4269*4882a593Smuzhiyun 
4270*4882a593Smuzhiyun /**
4271*4882a593Smuzhiyun  * struct ieee80211_tpt_blink - throughput blink description
4272*4882a593Smuzhiyun  * @throughput: throughput in Kbit/sec
4273*4882a593Smuzhiyun  * @blink_time: blink time in milliseconds
4274*4882a593Smuzhiyun  *	(full cycle, ie. one off + one on period)
4275*4882a593Smuzhiyun  */
4276*4882a593Smuzhiyun struct ieee80211_tpt_blink {
4277*4882a593Smuzhiyun 	int throughput;
4278*4882a593Smuzhiyun 	int blink_time;
4279*4882a593Smuzhiyun };
4280*4882a593Smuzhiyun 
4281*4882a593Smuzhiyun /**
4282*4882a593Smuzhiyun  * enum ieee80211_tpt_led_trigger_flags - throughput trigger flags
4283*4882a593Smuzhiyun  * @IEEE80211_TPT_LEDTRIG_FL_RADIO: enable blinking with radio
4284*4882a593Smuzhiyun  * @IEEE80211_TPT_LEDTRIG_FL_WORK: enable blinking when working
4285*4882a593Smuzhiyun  * @IEEE80211_TPT_LEDTRIG_FL_CONNECTED: enable blinking when at least one
4286*4882a593Smuzhiyun  *	interface is connected in some way, including being an AP
4287*4882a593Smuzhiyun  */
4288*4882a593Smuzhiyun enum ieee80211_tpt_led_trigger_flags {
4289*4882a593Smuzhiyun 	IEEE80211_TPT_LEDTRIG_FL_RADIO		= BIT(0),
4290*4882a593Smuzhiyun 	IEEE80211_TPT_LEDTRIG_FL_WORK		= BIT(1),
4291*4882a593Smuzhiyun 	IEEE80211_TPT_LEDTRIG_FL_CONNECTED	= BIT(2),
4292*4882a593Smuzhiyun };
4293*4882a593Smuzhiyun 
4294*4882a593Smuzhiyun #ifdef CONFIG_MAC80211_LEDS
4295*4882a593Smuzhiyun const char *__ieee80211_get_tx_led_name(struct ieee80211_hw *hw);
4296*4882a593Smuzhiyun const char *__ieee80211_get_rx_led_name(struct ieee80211_hw *hw);
4297*4882a593Smuzhiyun const char *__ieee80211_get_assoc_led_name(struct ieee80211_hw *hw);
4298*4882a593Smuzhiyun const char *__ieee80211_get_radio_led_name(struct ieee80211_hw *hw);
4299*4882a593Smuzhiyun const char *
4300*4882a593Smuzhiyun __ieee80211_create_tpt_led_trigger(struct ieee80211_hw *hw,
4301*4882a593Smuzhiyun 				   unsigned int flags,
4302*4882a593Smuzhiyun 				   const struct ieee80211_tpt_blink *blink_table,
4303*4882a593Smuzhiyun 				   unsigned int blink_table_len);
4304*4882a593Smuzhiyun #endif
4305*4882a593Smuzhiyun /**
4306*4882a593Smuzhiyun  * ieee80211_get_tx_led_name - get name of TX LED
4307*4882a593Smuzhiyun  *
4308*4882a593Smuzhiyun  * mac80211 creates a transmit LED trigger for each wireless hardware
4309*4882a593Smuzhiyun  * that can be used to drive LEDs if your driver registers a LED device.
4310*4882a593Smuzhiyun  * This function returns the name (or %NULL if not configured for LEDs)
4311*4882a593Smuzhiyun  * of the trigger so you can automatically link the LED device.
4312*4882a593Smuzhiyun  *
4313*4882a593Smuzhiyun  * @hw: the hardware to get the LED trigger name for
4314*4882a593Smuzhiyun  *
4315*4882a593Smuzhiyun  * Return: The name of the LED trigger. %NULL if not configured for LEDs.
4316*4882a593Smuzhiyun  */
ieee80211_get_tx_led_name(struct ieee80211_hw * hw)4317*4882a593Smuzhiyun static inline const char *ieee80211_get_tx_led_name(struct ieee80211_hw *hw)
4318*4882a593Smuzhiyun {
4319*4882a593Smuzhiyun #ifdef CONFIG_MAC80211_LEDS
4320*4882a593Smuzhiyun 	return __ieee80211_get_tx_led_name(hw);
4321*4882a593Smuzhiyun #else
4322*4882a593Smuzhiyun 	return NULL;
4323*4882a593Smuzhiyun #endif
4324*4882a593Smuzhiyun }
4325*4882a593Smuzhiyun 
4326*4882a593Smuzhiyun /**
4327*4882a593Smuzhiyun  * ieee80211_get_rx_led_name - get name of RX LED
4328*4882a593Smuzhiyun  *
4329*4882a593Smuzhiyun  * mac80211 creates a receive LED trigger for each wireless hardware
4330*4882a593Smuzhiyun  * that can be used to drive LEDs if your driver registers a LED device.
4331*4882a593Smuzhiyun  * This function returns the name (or %NULL if not configured for LEDs)
4332*4882a593Smuzhiyun  * of the trigger so you can automatically link the LED device.
4333*4882a593Smuzhiyun  *
4334*4882a593Smuzhiyun  * @hw: the hardware to get the LED trigger name for
4335*4882a593Smuzhiyun  *
4336*4882a593Smuzhiyun  * Return: The name of the LED trigger. %NULL if not configured for LEDs.
4337*4882a593Smuzhiyun  */
ieee80211_get_rx_led_name(struct ieee80211_hw * hw)4338*4882a593Smuzhiyun static inline const char *ieee80211_get_rx_led_name(struct ieee80211_hw *hw)
4339*4882a593Smuzhiyun {
4340*4882a593Smuzhiyun #ifdef CONFIG_MAC80211_LEDS
4341*4882a593Smuzhiyun 	return __ieee80211_get_rx_led_name(hw);
4342*4882a593Smuzhiyun #else
4343*4882a593Smuzhiyun 	return NULL;
4344*4882a593Smuzhiyun #endif
4345*4882a593Smuzhiyun }
4346*4882a593Smuzhiyun 
4347*4882a593Smuzhiyun /**
4348*4882a593Smuzhiyun  * ieee80211_get_assoc_led_name - get name of association LED
4349*4882a593Smuzhiyun  *
4350*4882a593Smuzhiyun  * mac80211 creates a association LED trigger for each wireless hardware
4351*4882a593Smuzhiyun  * that can be used to drive LEDs if your driver registers a LED device.
4352*4882a593Smuzhiyun  * This function returns the name (or %NULL if not configured for LEDs)
4353*4882a593Smuzhiyun  * of the trigger so you can automatically link the LED device.
4354*4882a593Smuzhiyun  *
4355*4882a593Smuzhiyun  * @hw: the hardware to get the LED trigger name for
4356*4882a593Smuzhiyun  *
4357*4882a593Smuzhiyun  * Return: The name of the LED trigger. %NULL if not configured for LEDs.
4358*4882a593Smuzhiyun  */
ieee80211_get_assoc_led_name(struct ieee80211_hw * hw)4359*4882a593Smuzhiyun static inline const char *ieee80211_get_assoc_led_name(struct ieee80211_hw *hw)
4360*4882a593Smuzhiyun {
4361*4882a593Smuzhiyun #ifdef CONFIG_MAC80211_LEDS
4362*4882a593Smuzhiyun 	return __ieee80211_get_assoc_led_name(hw);
4363*4882a593Smuzhiyun #else
4364*4882a593Smuzhiyun 	return NULL;
4365*4882a593Smuzhiyun #endif
4366*4882a593Smuzhiyun }
4367*4882a593Smuzhiyun 
4368*4882a593Smuzhiyun /**
4369*4882a593Smuzhiyun  * ieee80211_get_radio_led_name - get name of radio LED
4370*4882a593Smuzhiyun  *
4371*4882a593Smuzhiyun  * mac80211 creates a radio change LED trigger for each wireless hardware
4372*4882a593Smuzhiyun  * that can be used to drive LEDs if your driver registers a LED device.
4373*4882a593Smuzhiyun  * This function returns the name (or %NULL if not configured for LEDs)
4374*4882a593Smuzhiyun  * of the trigger so you can automatically link the LED device.
4375*4882a593Smuzhiyun  *
4376*4882a593Smuzhiyun  * @hw: the hardware to get the LED trigger name for
4377*4882a593Smuzhiyun  *
4378*4882a593Smuzhiyun  * Return: The name of the LED trigger. %NULL if not configured for LEDs.
4379*4882a593Smuzhiyun  */
ieee80211_get_radio_led_name(struct ieee80211_hw * hw)4380*4882a593Smuzhiyun static inline const char *ieee80211_get_radio_led_name(struct ieee80211_hw *hw)
4381*4882a593Smuzhiyun {
4382*4882a593Smuzhiyun #ifdef CONFIG_MAC80211_LEDS
4383*4882a593Smuzhiyun 	return __ieee80211_get_radio_led_name(hw);
4384*4882a593Smuzhiyun #else
4385*4882a593Smuzhiyun 	return NULL;
4386*4882a593Smuzhiyun #endif
4387*4882a593Smuzhiyun }
4388*4882a593Smuzhiyun 
4389*4882a593Smuzhiyun /**
4390*4882a593Smuzhiyun  * ieee80211_create_tpt_led_trigger - create throughput LED trigger
4391*4882a593Smuzhiyun  * @hw: the hardware to create the trigger for
4392*4882a593Smuzhiyun  * @flags: trigger flags, see &enum ieee80211_tpt_led_trigger_flags
4393*4882a593Smuzhiyun  * @blink_table: the blink table -- needs to be ordered by throughput
4394*4882a593Smuzhiyun  * @blink_table_len: size of the blink table
4395*4882a593Smuzhiyun  *
4396*4882a593Smuzhiyun  * Return: %NULL (in case of error, or if no LED triggers are
4397*4882a593Smuzhiyun  * configured) or the name of the new trigger.
4398*4882a593Smuzhiyun  *
4399*4882a593Smuzhiyun  * Note: This function must be called before ieee80211_register_hw().
4400*4882a593Smuzhiyun  */
4401*4882a593Smuzhiyun static inline const char *
ieee80211_create_tpt_led_trigger(struct ieee80211_hw * hw,unsigned int flags,const struct ieee80211_tpt_blink * blink_table,unsigned int blink_table_len)4402*4882a593Smuzhiyun ieee80211_create_tpt_led_trigger(struct ieee80211_hw *hw, unsigned int flags,
4403*4882a593Smuzhiyun 				 const struct ieee80211_tpt_blink *blink_table,
4404*4882a593Smuzhiyun 				 unsigned int blink_table_len)
4405*4882a593Smuzhiyun {
4406*4882a593Smuzhiyun #ifdef CONFIG_MAC80211_LEDS
4407*4882a593Smuzhiyun 	return __ieee80211_create_tpt_led_trigger(hw, flags, blink_table,
4408*4882a593Smuzhiyun 						  blink_table_len);
4409*4882a593Smuzhiyun #else
4410*4882a593Smuzhiyun 	return NULL;
4411*4882a593Smuzhiyun #endif
4412*4882a593Smuzhiyun }
4413*4882a593Smuzhiyun 
4414*4882a593Smuzhiyun /**
4415*4882a593Smuzhiyun  * ieee80211_unregister_hw - Unregister a hardware device
4416*4882a593Smuzhiyun  *
4417*4882a593Smuzhiyun  * This function instructs mac80211 to free allocated resources
4418*4882a593Smuzhiyun  * and unregister netdevices from the networking subsystem.
4419*4882a593Smuzhiyun  *
4420*4882a593Smuzhiyun  * @hw: the hardware to unregister
4421*4882a593Smuzhiyun  */
4422*4882a593Smuzhiyun void ieee80211_unregister_hw(struct ieee80211_hw *hw);
4423*4882a593Smuzhiyun 
4424*4882a593Smuzhiyun /**
4425*4882a593Smuzhiyun  * ieee80211_free_hw - free hardware descriptor
4426*4882a593Smuzhiyun  *
4427*4882a593Smuzhiyun  * This function frees everything that was allocated, including the
4428*4882a593Smuzhiyun  * private data for the driver. You must call ieee80211_unregister_hw()
4429*4882a593Smuzhiyun  * before calling this function.
4430*4882a593Smuzhiyun  *
4431*4882a593Smuzhiyun  * @hw: the hardware to free
4432*4882a593Smuzhiyun  */
4433*4882a593Smuzhiyun void ieee80211_free_hw(struct ieee80211_hw *hw);
4434*4882a593Smuzhiyun 
4435*4882a593Smuzhiyun /**
4436*4882a593Smuzhiyun  * ieee80211_restart_hw - restart hardware completely
4437*4882a593Smuzhiyun  *
4438*4882a593Smuzhiyun  * Call this function when the hardware was restarted for some reason
4439*4882a593Smuzhiyun  * (hardware error, ...) and the driver is unable to restore its state
4440*4882a593Smuzhiyun  * by itself. mac80211 assumes that at this point the driver/hardware
4441*4882a593Smuzhiyun  * is completely uninitialised and stopped, it starts the process by
4442*4882a593Smuzhiyun  * calling the ->start() operation. The driver will need to reset all
4443*4882a593Smuzhiyun  * internal state that it has prior to calling this function.
4444*4882a593Smuzhiyun  *
4445*4882a593Smuzhiyun  * @hw: the hardware to restart
4446*4882a593Smuzhiyun  */
4447*4882a593Smuzhiyun void ieee80211_restart_hw(struct ieee80211_hw *hw);
4448*4882a593Smuzhiyun 
4449*4882a593Smuzhiyun /**
4450*4882a593Smuzhiyun  * ieee80211_rx_list - receive frame and store processed skbs in a list
4451*4882a593Smuzhiyun  *
4452*4882a593Smuzhiyun  * Use this function to hand received frames to mac80211. The receive
4453*4882a593Smuzhiyun  * buffer in @skb must start with an IEEE 802.11 header. In case of a
4454*4882a593Smuzhiyun  * paged @skb is used, the driver is recommended to put the ieee80211
4455*4882a593Smuzhiyun  * header of the frame on the linear part of the @skb to avoid memory
4456*4882a593Smuzhiyun  * allocation and/or memcpy by the stack.
4457*4882a593Smuzhiyun  *
4458*4882a593Smuzhiyun  * This function may not be called in IRQ context. Calls to this function
4459*4882a593Smuzhiyun  * for a single hardware must be synchronized against each other. Calls to
4460*4882a593Smuzhiyun  * this function, ieee80211_rx_ni() and ieee80211_rx_irqsafe() may not be
4461*4882a593Smuzhiyun  * mixed for a single hardware. Must not run concurrently with
4462*4882a593Smuzhiyun  * ieee80211_tx_status() or ieee80211_tx_status_ni().
4463*4882a593Smuzhiyun  *
4464*4882a593Smuzhiyun  * This function must be called with BHs disabled and RCU read lock
4465*4882a593Smuzhiyun  *
4466*4882a593Smuzhiyun  * @hw: the hardware this frame came in on
4467*4882a593Smuzhiyun  * @sta: the station the frame was received from, or %NULL
4468*4882a593Smuzhiyun  * @skb: the buffer to receive, owned by mac80211 after this call
4469*4882a593Smuzhiyun  * @list: the destination list
4470*4882a593Smuzhiyun  */
4471*4882a593Smuzhiyun void ieee80211_rx_list(struct ieee80211_hw *hw, struct ieee80211_sta *sta,
4472*4882a593Smuzhiyun 		       struct sk_buff *skb, struct list_head *list);
4473*4882a593Smuzhiyun 
4474*4882a593Smuzhiyun /**
4475*4882a593Smuzhiyun  * ieee80211_rx_napi - receive frame from NAPI context
4476*4882a593Smuzhiyun  *
4477*4882a593Smuzhiyun  * Use this function to hand received frames to mac80211. The receive
4478*4882a593Smuzhiyun  * buffer in @skb must start with an IEEE 802.11 header. In case of a
4479*4882a593Smuzhiyun  * paged @skb is used, the driver is recommended to put the ieee80211
4480*4882a593Smuzhiyun  * header of the frame on the linear part of the @skb to avoid memory
4481*4882a593Smuzhiyun  * allocation and/or memcpy by the stack.
4482*4882a593Smuzhiyun  *
4483*4882a593Smuzhiyun  * This function may not be called in IRQ context. Calls to this function
4484*4882a593Smuzhiyun  * for a single hardware must be synchronized against each other. Calls to
4485*4882a593Smuzhiyun  * this function, ieee80211_rx_ni() and ieee80211_rx_irqsafe() may not be
4486*4882a593Smuzhiyun  * mixed for a single hardware. Must not run concurrently with
4487*4882a593Smuzhiyun  * ieee80211_tx_status() or ieee80211_tx_status_ni().
4488*4882a593Smuzhiyun  *
4489*4882a593Smuzhiyun  * This function must be called with BHs disabled.
4490*4882a593Smuzhiyun  *
4491*4882a593Smuzhiyun  * @hw: the hardware this frame came in on
4492*4882a593Smuzhiyun  * @sta: the station the frame was received from, or %NULL
4493*4882a593Smuzhiyun  * @skb: the buffer to receive, owned by mac80211 after this call
4494*4882a593Smuzhiyun  * @napi: the NAPI context
4495*4882a593Smuzhiyun  */
4496*4882a593Smuzhiyun void ieee80211_rx_napi(struct ieee80211_hw *hw, struct ieee80211_sta *sta,
4497*4882a593Smuzhiyun 		       struct sk_buff *skb, struct napi_struct *napi);
4498*4882a593Smuzhiyun 
4499*4882a593Smuzhiyun /**
4500*4882a593Smuzhiyun  * ieee80211_rx - receive frame
4501*4882a593Smuzhiyun  *
4502*4882a593Smuzhiyun  * Use this function to hand received frames to mac80211. The receive
4503*4882a593Smuzhiyun  * buffer in @skb must start with an IEEE 802.11 header. In case of a
4504*4882a593Smuzhiyun  * paged @skb is used, the driver is recommended to put the ieee80211
4505*4882a593Smuzhiyun  * header of the frame on the linear part of the @skb to avoid memory
4506*4882a593Smuzhiyun  * allocation and/or memcpy by the stack.
4507*4882a593Smuzhiyun  *
4508*4882a593Smuzhiyun  * This function may not be called in IRQ context. Calls to this function
4509*4882a593Smuzhiyun  * for a single hardware must be synchronized against each other. Calls to
4510*4882a593Smuzhiyun  * this function, ieee80211_rx_ni() and ieee80211_rx_irqsafe() may not be
4511*4882a593Smuzhiyun  * mixed for a single hardware. Must not run concurrently with
4512*4882a593Smuzhiyun  * ieee80211_tx_status() or ieee80211_tx_status_ni().
4513*4882a593Smuzhiyun  *
4514*4882a593Smuzhiyun  * In process context use instead ieee80211_rx_ni().
4515*4882a593Smuzhiyun  *
4516*4882a593Smuzhiyun  * @hw: the hardware this frame came in on
4517*4882a593Smuzhiyun  * @skb: the buffer to receive, owned by mac80211 after this call
4518*4882a593Smuzhiyun  */
ieee80211_rx(struct ieee80211_hw * hw,struct sk_buff * skb)4519*4882a593Smuzhiyun static inline void ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb)
4520*4882a593Smuzhiyun {
4521*4882a593Smuzhiyun 	ieee80211_rx_napi(hw, NULL, skb, NULL);
4522*4882a593Smuzhiyun }
4523*4882a593Smuzhiyun 
4524*4882a593Smuzhiyun /**
4525*4882a593Smuzhiyun  * ieee80211_rx_irqsafe - receive frame
4526*4882a593Smuzhiyun  *
4527*4882a593Smuzhiyun  * Like ieee80211_rx() but can be called in IRQ context
4528*4882a593Smuzhiyun  * (internally defers to a tasklet.)
4529*4882a593Smuzhiyun  *
4530*4882a593Smuzhiyun  * Calls to this function, ieee80211_rx() or ieee80211_rx_ni() may not
4531*4882a593Smuzhiyun  * be mixed for a single hardware.Must not run concurrently with
4532*4882a593Smuzhiyun  * ieee80211_tx_status() or ieee80211_tx_status_ni().
4533*4882a593Smuzhiyun  *
4534*4882a593Smuzhiyun  * @hw: the hardware this frame came in on
4535*4882a593Smuzhiyun  * @skb: the buffer to receive, owned by mac80211 after this call
4536*4882a593Smuzhiyun  */
4537*4882a593Smuzhiyun void ieee80211_rx_irqsafe(struct ieee80211_hw *hw, struct sk_buff *skb);
4538*4882a593Smuzhiyun 
4539*4882a593Smuzhiyun /**
4540*4882a593Smuzhiyun  * ieee80211_rx_ni - receive frame (in process context)
4541*4882a593Smuzhiyun  *
4542*4882a593Smuzhiyun  * Like ieee80211_rx() but can be called in process context
4543*4882a593Smuzhiyun  * (internally disables bottom halves).
4544*4882a593Smuzhiyun  *
4545*4882a593Smuzhiyun  * Calls to this function, ieee80211_rx() and ieee80211_rx_irqsafe() may
4546*4882a593Smuzhiyun  * not be mixed for a single hardware. Must not run concurrently with
4547*4882a593Smuzhiyun  * ieee80211_tx_status() or ieee80211_tx_status_ni().
4548*4882a593Smuzhiyun  *
4549*4882a593Smuzhiyun  * @hw: the hardware this frame came in on
4550*4882a593Smuzhiyun  * @skb: the buffer to receive, owned by mac80211 after this call
4551*4882a593Smuzhiyun  */
ieee80211_rx_ni(struct ieee80211_hw * hw,struct sk_buff * skb)4552*4882a593Smuzhiyun static inline void ieee80211_rx_ni(struct ieee80211_hw *hw,
4553*4882a593Smuzhiyun 				   struct sk_buff *skb)
4554*4882a593Smuzhiyun {
4555*4882a593Smuzhiyun 	local_bh_disable();
4556*4882a593Smuzhiyun 	ieee80211_rx(hw, skb);
4557*4882a593Smuzhiyun 	local_bh_enable();
4558*4882a593Smuzhiyun }
4559*4882a593Smuzhiyun 
4560*4882a593Smuzhiyun /**
4561*4882a593Smuzhiyun  * ieee80211_sta_ps_transition - PS transition for connected sta
4562*4882a593Smuzhiyun  *
4563*4882a593Smuzhiyun  * When operating in AP mode with the %IEEE80211_HW_AP_LINK_PS
4564*4882a593Smuzhiyun  * flag set, use this function to inform mac80211 about a connected station
4565*4882a593Smuzhiyun  * entering/leaving PS mode.
4566*4882a593Smuzhiyun  *
4567*4882a593Smuzhiyun  * This function may not be called in IRQ context or with softirqs enabled.
4568*4882a593Smuzhiyun  *
4569*4882a593Smuzhiyun  * Calls to this function for a single hardware must be synchronized against
4570*4882a593Smuzhiyun  * each other.
4571*4882a593Smuzhiyun  *
4572*4882a593Smuzhiyun  * @sta: currently connected sta
4573*4882a593Smuzhiyun  * @start: start or stop PS
4574*4882a593Smuzhiyun  *
4575*4882a593Smuzhiyun  * Return: 0 on success. -EINVAL when the requested PS mode is already set.
4576*4882a593Smuzhiyun  */
4577*4882a593Smuzhiyun int ieee80211_sta_ps_transition(struct ieee80211_sta *sta, bool start);
4578*4882a593Smuzhiyun 
4579*4882a593Smuzhiyun /**
4580*4882a593Smuzhiyun  * ieee80211_sta_ps_transition_ni - PS transition for connected sta
4581*4882a593Smuzhiyun  *                                  (in process context)
4582*4882a593Smuzhiyun  *
4583*4882a593Smuzhiyun  * Like ieee80211_sta_ps_transition() but can be called in process context
4584*4882a593Smuzhiyun  * (internally disables bottom halves). Concurrent call restriction still
4585*4882a593Smuzhiyun  * applies.
4586*4882a593Smuzhiyun  *
4587*4882a593Smuzhiyun  * @sta: currently connected sta
4588*4882a593Smuzhiyun  * @start: start or stop PS
4589*4882a593Smuzhiyun  *
4590*4882a593Smuzhiyun  * Return: Like ieee80211_sta_ps_transition().
4591*4882a593Smuzhiyun  */
ieee80211_sta_ps_transition_ni(struct ieee80211_sta * sta,bool start)4592*4882a593Smuzhiyun static inline int ieee80211_sta_ps_transition_ni(struct ieee80211_sta *sta,
4593*4882a593Smuzhiyun 						  bool start)
4594*4882a593Smuzhiyun {
4595*4882a593Smuzhiyun 	int ret;
4596*4882a593Smuzhiyun 
4597*4882a593Smuzhiyun 	local_bh_disable();
4598*4882a593Smuzhiyun 	ret = ieee80211_sta_ps_transition(sta, start);
4599*4882a593Smuzhiyun 	local_bh_enable();
4600*4882a593Smuzhiyun 
4601*4882a593Smuzhiyun 	return ret;
4602*4882a593Smuzhiyun }
4603*4882a593Smuzhiyun 
4604*4882a593Smuzhiyun /**
4605*4882a593Smuzhiyun  * ieee80211_sta_pspoll - PS-Poll frame received
4606*4882a593Smuzhiyun  * @sta: currently connected station
4607*4882a593Smuzhiyun  *
4608*4882a593Smuzhiyun  * When operating in AP mode with the %IEEE80211_HW_AP_LINK_PS flag set,
4609*4882a593Smuzhiyun  * use this function to inform mac80211 that a PS-Poll frame from a
4610*4882a593Smuzhiyun  * connected station was received.
4611*4882a593Smuzhiyun  * This must be used in conjunction with ieee80211_sta_ps_transition()
4612*4882a593Smuzhiyun  * and possibly ieee80211_sta_uapsd_trigger(); calls to all three must
4613*4882a593Smuzhiyun  * be serialized.
4614*4882a593Smuzhiyun  */
4615*4882a593Smuzhiyun void ieee80211_sta_pspoll(struct ieee80211_sta *sta);
4616*4882a593Smuzhiyun 
4617*4882a593Smuzhiyun /**
4618*4882a593Smuzhiyun  * ieee80211_sta_uapsd_trigger - (potential) U-APSD trigger frame received
4619*4882a593Smuzhiyun  * @sta: currently connected station
4620*4882a593Smuzhiyun  * @tid: TID of the received (potential) trigger frame
4621*4882a593Smuzhiyun  *
4622*4882a593Smuzhiyun  * When operating in AP mode with the %IEEE80211_HW_AP_LINK_PS flag set,
4623*4882a593Smuzhiyun  * use this function to inform mac80211 that a (potential) trigger frame
4624*4882a593Smuzhiyun  * from a connected station was received.
4625*4882a593Smuzhiyun  * This must be used in conjunction with ieee80211_sta_ps_transition()
4626*4882a593Smuzhiyun  * and possibly ieee80211_sta_pspoll(); calls to all three must be
4627*4882a593Smuzhiyun  * serialized.
4628*4882a593Smuzhiyun  * %IEEE80211_NUM_TIDS can be passed as the tid if the tid is unknown.
4629*4882a593Smuzhiyun  * In this case, mac80211 will not check that this tid maps to an AC
4630*4882a593Smuzhiyun  * that is trigger enabled and assume that the caller did the proper
4631*4882a593Smuzhiyun  * checks.
4632*4882a593Smuzhiyun  */
4633*4882a593Smuzhiyun void ieee80211_sta_uapsd_trigger(struct ieee80211_sta *sta, u8 tid);
4634*4882a593Smuzhiyun 
4635*4882a593Smuzhiyun /*
4636*4882a593Smuzhiyun  * The TX headroom reserved by mac80211 for its own tx_status functions.
4637*4882a593Smuzhiyun  * This is enough for the radiotap header.
4638*4882a593Smuzhiyun  */
4639*4882a593Smuzhiyun #define IEEE80211_TX_STATUS_HEADROOM	ALIGN(14, 4)
4640*4882a593Smuzhiyun 
4641*4882a593Smuzhiyun /**
4642*4882a593Smuzhiyun  * ieee80211_sta_set_buffered - inform mac80211 about driver-buffered frames
4643*4882a593Smuzhiyun  * @sta: &struct ieee80211_sta pointer for the sleeping station
4644*4882a593Smuzhiyun  * @tid: the TID that has buffered frames
4645*4882a593Smuzhiyun  * @buffered: indicates whether or not frames are buffered for this TID
4646*4882a593Smuzhiyun  *
4647*4882a593Smuzhiyun  * If a driver buffers frames for a powersave station instead of passing
4648*4882a593Smuzhiyun  * them back to mac80211 for retransmission, the station may still need
4649*4882a593Smuzhiyun  * to be told that there are buffered frames via the TIM bit.
4650*4882a593Smuzhiyun  *
4651*4882a593Smuzhiyun  * This function informs mac80211 whether or not there are frames that are
4652*4882a593Smuzhiyun  * buffered in the driver for a given TID; mac80211 can then use this data
4653*4882a593Smuzhiyun  * to set the TIM bit (NOTE: This may call back into the driver's set_tim
4654*4882a593Smuzhiyun  * call! Beware of the locking!)
4655*4882a593Smuzhiyun  *
4656*4882a593Smuzhiyun  * If all frames are released to the station (due to PS-poll or uAPSD)
4657*4882a593Smuzhiyun  * then the driver needs to inform mac80211 that there no longer are
4658*4882a593Smuzhiyun  * frames buffered. However, when the station wakes up mac80211 assumes
4659*4882a593Smuzhiyun  * that all buffered frames will be transmitted and clears this data,
4660*4882a593Smuzhiyun  * drivers need to make sure they inform mac80211 about all buffered
4661*4882a593Smuzhiyun  * frames on the sleep transition (sta_notify() with %STA_NOTIFY_SLEEP).
4662*4882a593Smuzhiyun  *
4663*4882a593Smuzhiyun  * Note that technically mac80211 only needs to know this per AC, not per
4664*4882a593Smuzhiyun  * TID, but since driver buffering will inevitably happen per TID (since
4665*4882a593Smuzhiyun  * it is related to aggregation) it is easier to make mac80211 map the
4666*4882a593Smuzhiyun  * TID to the AC as required instead of keeping track in all drivers that
4667*4882a593Smuzhiyun  * use this API.
4668*4882a593Smuzhiyun  */
4669*4882a593Smuzhiyun void ieee80211_sta_set_buffered(struct ieee80211_sta *sta,
4670*4882a593Smuzhiyun 				u8 tid, bool buffered);
4671*4882a593Smuzhiyun 
4672*4882a593Smuzhiyun /**
4673*4882a593Smuzhiyun  * ieee80211_get_tx_rates - get the selected transmit rates for a packet
4674*4882a593Smuzhiyun  *
4675*4882a593Smuzhiyun  * Call this function in a driver with per-packet rate selection support
4676*4882a593Smuzhiyun  * to combine the rate info in the packet tx info with the most recent
4677*4882a593Smuzhiyun  * rate selection table for the station entry.
4678*4882a593Smuzhiyun  *
4679*4882a593Smuzhiyun  * @vif: &struct ieee80211_vif pointer from the add_interface callback.
4680*4882a593Smuzhiyun  * @sta: the receiver station to which this packet is sent.
4681*4882a593Smuzhiyun  * @skb: the frame to be transmitted.
4682*4882a593Smuzhiyun  * @dest: buffer for extracted rate/retry information
4683*4882a593Smuzhiyun  * @max_rates: maximum number of rates to fetch
4684*4882a593Smuzhiyun  */
4685*4882a593Smuzhiyun void ieee80211_get_tx_rates(struct ieee80211_vif *vif,
4686*4882a593Smuzhiyun 			    struct ieee80211_sta *sta,
4687*4882a593Smuzhiyun 			    struct sk_buff *skb,
4688*4882a593Smuzhiyun 			    struct ieee80211_tx_rate *dest,
4689*4882a593Smuzhiyun 			    int max_rates);
4690*4882a593Smuzhiyun 
4691*4882a593Smuzhiyun /**
4692*4882a593Smuzhiyun  * ieee80211_sta_set_expected_throughput - set the expected tpt for a station
4693*4882a593Smuzhiyun  *
4694*4882a593Smuzhiyun  * Call this function to notify mac80211 about a change in expected throughput
4695*4882a593Smuzhiyun  * to a station. A driver for a device that does rate control in firmware can
4696*4882a593Smuzhiyun  * call this function when the expected throughput estimate towards a station
4697*4882a593Smuzhiyun  * changes. The information is used to tune the CoDel AQM applied to traffic
4698*4882a593Smuzhiyun  * going towards that station (which can otherwise be too aggressive and cause
4699*4882a593Smuzhiyun  * slow stations to starve).
4700*4882a593Smuzhiyun  *
4701*4882a593Smuzhiyun  * @pubsta: the station to set throughput for.
4702*4882a593Smuzhiyun  * @thr: the current expected throughput in kbps.
4703*4882a593Smuzhiyun  */
4704*4882a593Smuzhiyun void ieee80211_sta_set_expected_throughput(struct ieee80211_sta *pubsta,
4705*4882a593Smuzhiyun 					   u32 thr);
4706*4882a593Smuzhiyun 
4707*4882a593Smuzhiyun /**
4708*4882a593Smuzhiyun  * ieee80211_tx_rate_update - transmit rate update callback
4709*4882a593Smuzhiyun  *
4710*4882a593Smuzhiyun  * Drivers should call this functions with a non-NULL pub sta
4711*4882a593Smuzhiyun  * This function can be used in drivers that does not have provision
4712*4882a593Smuzhiyun  * in updating the tx rate in data path.
4713*4882a593Smuzhiyun  *
4714*4882a593Smuzhiyun  * @hw: the hardware the frame was transmitted by
4715*4882a593Smuzhiyun  * @pubsta: the station to update the tx rate for.
4716*4882a593Smuzhiyun  * @info: tx status information
4717*4882a593Smuzhiyun  */
4718*4882a593Smuzhiyun void ieee80211_tx_rate_update(struct ieee80211_hw *hw,
4719*4882a593Smuzhiyun 			      struct ieee80211_sta *pubsta,
4720*4882a593Smuzhiyun 			      struct ieee80211_tx_info *info);
4721*4882a593Smuzhiyun 
4722*4882a593Smuzhiyun /**
4723*4882a593Smuzhiyun  * ieee80211_tx_status - transmit status callback
4724*4882a593Smuzhiyun  *
4725*4882a593Smuzhiyun  * Call this function for all transmitted frames after they have been
4726*4882a593Smuzhiyun  * transmitted. It is permissible to not call this function for
4727*4882a593Smuzhiyun  * multicast frames but this can affect statistics.
4728*4882a593Smuzhiyun  *
4729*4882a593Smuzhiyun  * This function may not be called in IRQ context. Calls to this function
4730*4882a593Smuzhiyun  * for a single hardware must be synchronized against each other. Calls
4731*4882a593Smuzhiyun  * to this function, ieee80211_tx_status_ni() and ieee80211_tx_status_irqsafe()
4732*4882a593Smuzhiyun  * may not be mixed for a single hardware. Must not run concurrently with
4733*4882a593Smuzhiyun  * ieee80211_rx() or ieee80211_rx_ni().
4734*4882a593Smuzhiyun  *
4735*4882a593Smuzhiyun  * @hw: the hardware the frame was transmitted by
4736*4882a593Smuzhiyun  * @skb: the frame that was transmitted, owned by mac80211 after this call
4737*4882a593Smuzhiyun  */
4738*4882a593Smuzhiyun void ieee80211_tx_status(struct ieee80211_hw *hw,
4739*4882a593Smuzhiyun 			 struct sk_buff *skb);
4740*4882a593Smuzhiyun 
4741*4882a593Smuzhiyun /**
4742*4882a593Smuzhiyun  * ieee80211_tx_status_ext - extended transmit status callback
4743*4882a593Smuzhiyun  *
4744*4882a593Smuzhiyun  * This function can be used as a replacement for ieee80211_tx_status
4745*4882a593Smuzhiyun  * in drivers that may want to provide extra information that does not
4746*4882a593Smuzhiyun  * fit into &struct ieee80211_tx_info.
4747*4882a593Smuzhiyun  *
4748*4882a593Smuzhiyun  * Calls to this function for a single hardware must be synchronized
4749*4882a593Smuzhiyun  * against each other. Calls to this function, ieee80211_tx_status_ni()
4750*4882a593Smuzhiyun  * and ieee80211_tx_status_irqsafe() may not be mixed for a single hardware.
4751*4882a593Smuzhiyun  *
4752*4882a593Smuzhiyun  * @hw: the hardware the frame was transmitted by
4753*4882a593Smuzhiyun  * @status: tx status information
4754*4882a593Smuzhiyun  */
4755*4882a593Smuzhiyun void ieee80211_tx_status_ext(struct ieee80211_hw *hw,
4756*4882a593Smuzhiyun 			     struct ieee80211_tx_status *status);
4757*4882a593Smuzhiyun 
4758*4882a593Smuzhiyun /**
4759*4882a593Smuzhiyun  * ieee80211_tx_status_noskb - transmit status callback without skb
4760*4882a593Smuzhiyun  *
4761*4882a593Smuzhiyun  * This function can be used as a replacement for ieee80211_tx_status
4762*4882a593Smuzhiyun  * in drivers that cannot reliably map tx status information back to
4763*4882a593Smuzhiyun  * specific skbs.
4764*4882a593Smuzhiyun  *
4765*4882a593Smuzhiyun  * Calls to this function for a single hardware must be synchronized
4766*4882a593Smuzhiyun  * against each other. Calls to this function, ieee80211_tx_status_ni()
4767*4882a593Smuzhiyun  * and ieee80211_tx_status_irqsafe() may not be mixed for a single hardware.
4768*4882a593Smuzhiyun  *
4769*4882a593Smuzhiyun  * @hw: the hardware the frame was transmitted by
4770*4882a593Smuzhiyun  * @sta: the receiver station to which this packet is sent
4771*4882a593Smuzhiyun  *	(NULL for multicast packets)
4772*4882a593Smuzhiyun  * @info: tx status information
4773*4882a593Smuzhiyun  */
ieee80211_tx_status_noskb(struct ieee80211_hw * hw,struct ieee80211_sta * sta,struct ieee80211_tx_info * info)4774*4882a593Smuzhiyun static inline void ieee80211_tx_status_noskb(struct ieee80211_hw *hw,
4775*4882a593Smuzhiyun 					     struct ieee80211_sta *sta,
4776*4882a593Smuzhiyun 					     struct ieee80211_tx_info *info)
4777*4882a593Smuzhiyun {
4778*4882a593Smuzhiyun 	struct ieee80211_tx_status status = {
4779*4882a593Smuzhiyun 		.sta = sta,
4780*4882a593Smuzhiyun 		.info = info,
4781*4882a593Smuzhiyun 	};
4782*4882a593Smuzhiyun 
4783*4882a593Smuzhiyun 	ieee80211_tx_status_ext(hw, &status);
4784*4882a593Smuzhiyun }
4785*4882a593Smuzhiyun 
4786*4882a593Smuzhiyun /**
4787*4882a593Smuzhiyun  * ieee80211_tx_status_ni - transmit status callback (in process context)
4788*4882a593Smuzhiyun  *
4789*4882a593Smuzhiyun  * Like ieee80211_tx_status() but can be called in process context.
4790*4882a593Smuzhiyun  *
4791*4882a593Smuzhiyun  * Calls to this function, ieee80211_tx_status() and
4792*4882a593Smuzhiyun  * ieee80211_tx_status_irqsafe() may not be mixed
4793*4882a593Smuzhiyun  * for a single hardware.
4794*4882a593Smuzhiyun  *
4795*4882a593Smuzhiyun  * @hw: the hardware the frame was transmitted by
4796*4882a593Smuzhiyun  * @skb: the frame that was transmitted, owned by mac80211 after this call
4797*4882a593Smuzhiyun  */
ieee80211_tx_status_ni(struct ieee80211_hw * hw,struct sk_buff * skb)4798*4882a593Smuzhiyun static inline void ieee80211_tx_status_ni(struct ieee80211_hw *hw,
4799*4882a593Smuzhiyun 					  struct sk_buff *skb)
4800*4882a593Smuzhiyun {
4801*4882a593Smuzhiyun 	local_bh_disable();
4802*4882a593Smuzhiyun 	ieee80211_tx_status(hw, skb);
4803*4882a593Smuzhiyun 	local_bh_enable();
4804*4882a593Smuzhiyun }
4805*4882a593Smuzhiyun 
4806*4882a593Smuzhiyun /**
4807*4882a593Smuzhiyun  * ieee80211_tx_status_irqsafe - IRQ-safe transmit status callback
4808*4882a593Smuzhiyun  *
4809*4882a593Smuzhiyun  * Like ieee80211_tx_status() but can be called in IRQ context
4810*4882a593Smuzhiyun  * (internally defers to a tasklet.)
4811*4882a593Smuzhiyun  *
4812*4882a593Smuzhiyun  * Calls to this function, ieee80211_tx_status() and
4813*4882a593Smuzhiyun  * ieee80211_tx_status_ni() may not be mixed for a single hardware.
4814*4882a593Smuzhiyun  *
4815*4882a593Smuzhiyun  * @hw: the hardware the frame was transmitted by
4816*4882a593Smuzhiyun  * @skb: the frame that was transmitted, owned by mac80211 after this call
4817*4882a593Smuzhiyun  */
4818*4882a593Smuzhiyun void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw,
4819*4882a593Smuzhiyun 				 struct sk_buff *skb);
4820*4882a593Smuzhiyun 
4821*4882a593Smuzhiyun /**
4822*4882a593Smuzhiyun  * ieee80211_tx_status_8023 - transmit status callback for 802.3 frame format
4823*4882a593Smuzhiyun  *
4824*4882a593Smuzhiyun  * Call this function for all transmitted data frames after their transmit
4825*4882a593Smuzhiyun  * completion. This callback should only be called for data frames which
4826*4882a593Smuzhiyun  * are using driver's (or hardware's) offload capability of encap/decap
4827*4882a593Smuzhiyun  * 802.11 frames.
4828*4882a593Smuzhiyun  *
4829*4882a593Smuzhiyun  * This function may not be called in IRQ context. Calls to this function
4830*4882a593Smuzhiyun  * for a single hardware must be synchronized against each other and all
4831*4882a593Smuzhiyun  * calls in the same tx status family.
4832*4882a593Smuzhiyun  *
4833*4882a593Smuzhiyun  * @hw: the hardware the frame was transmitted by
4834*4882a593Smuzhiyun  * @vif: the interface for which the frame was transmitted
4835*4882a593Smuzhiyun  * @skb: the frame that was transmitted, owned by mac80211 after this call
4836*4882a593Smuzhiyun  */
4837*4882a593Smuzhiyun void ieee80211_tx_status_8023(struct ieee80211_hw *hw,
4838*4882a593Smuzhiyun 			       struct ieee80211_vif *vif,
4839*4882a593Smuzhiyun 			       struct sk_buff *skb);
4840*4882a593Smuzhiyun 
4841*4882a593Smuzhiyun /**
4842*4882a593Smuzhiyun  * ieee80211_report_low_ack - report non-responding station
4843*4882a593Smuzhiyun  *
4844*4882a593Smuzhiyun  * When operating in AP-mode, call this function to report a non-responding
4845*4882a593Smuzhiyun  * connected STA.
4846*4882a593Smuzhiyun  *
4847*4882a593Smuzhiyun  * @sta: the non-responding connected sta
4848*4882a593Smuzhiyun  * @num_packets: number of packets sent to @sta without a response
4849*4882a593Smuzhiyun  */
4850*4882a593Smuzhiyun void ieee80211_report_low_ack(struct ieee80211_sta *sta, u32 num_packets);
4851*4882a593Smuzhiyun 
4852*4882a593Smuzhiyun #define IEEE80211_MAX_CNTDWN_COUNTERS_NUM 2
4853*4882a593Smuzhiyun 
4854*4882a593Smuzhiyun /**
4855*4882a593Smuzhiyun  * struct ieee80211_mutable_offsets - mutable beacon offsets
4856*4882a593Smuzhiyun  * @tim_offset: position of TIM element
4857*4882a593Smuzhiyun  * @tim_length: size of TIM element
4858*4882a593Smuzhiyun  * @cntdwn_counter_offs: array of IEEE80211_MAX_CNTDWN_COUNTERS_NUM offsets
4859*4882a593Smuzhiyun  *	to countdown counters.  This array can contain zero values which
4860*4882a593Smuzhiyun  *	should be ignored.
4861*4882a593Smuzhiyun  */
4862*4882a593Smuzhiyun struct ieee80211_mutable_offsets {
4863*4882a593Smuzhiyun 	u16 tim_offset;
4864*4882a593Smuzhiyun 	u16 tim_length;
4865*4882a593Smuzhiyun 
4866*4882a593Smuzhiyun 	u16 cntdwn_counter_offs[IEEE80211_MAX_CNTDWN_COUNTERS_NUM];
4867*4882a593Smuzhiyun };
4868*4882a593Smuzhiyun 
4869*4882a593Smuzhiyun /**
4870*4882a593Smuzhiyun  * ieee80211_beacon_get_template - beacon template generation function
4871*4882a593Smuzhiyun  * @hw: pointer obtained from ieee80211_alloc_hw().
4872*4882a593Smuzhiyun  * @vif: &struct ieee80211_vif pointer from the add_interface callback.
4873*4882a593Smuzhiyun  * @offs: &struct ieee80211_mutable_offsets pointer to struct that will
4874*4882a593Smuzhiyun  *	receive the offsets that may be updated by the driver.
4875*4882a593Smuzhiyun  *
4876*4882a593Smuzhiyun  * If the driver implements beaconing modes, it must use this function to
4877*4882a593Smuzhiyun  * obtain the beacon template.
4878*4882a593Smuzhiyun  *
4879*4882a593Smuzhiyun  * This function should be used if the beacon frames are generated by the
4880*4882a593Smuzhiyun  * device, and then the driver must use the returned beacon as the template
4881*4882a593Smuzhiyun  * The driver or the device are responsible to update the DTIM and, when
4882*4882a593Smuzhiyun  * applicable, the CSA count.
4883*4882a593Smuzhiyun  *
4884*4882a593Smuzhiyun  * The driver is responsible for freeing the returned skb.
4885*4882a593Smuzhiyun  *
4886*4882a593Smuzhiyun  * Return: The beacon template. %NULL on error.
4887*4882a593Smuzhiyun  */
4888*4882a593Smuzhiyun struct sk_buff *
4889*4882a593Smuzhiyun ieee80211_beacon_get_template(struct ieee80211_hw *hw,
4890*4882a593Smuzhiyun 			      struct ieee80211_vif *vif,
4891*4882a593Smuzhiyun 			      struct ieee80211_mutable_offsets *offs);
4892*4882a593Smuzhiyun 
4893*4882a593Smuzhiyun /**
4894*4882a593Smuzhiyun  * ieee80211_beacon_get_tim - beacon generation function
4895*4882a593Smuzhiyun  * @hw: pointer obtained from ieee80211_alloc_hw().
4896*4882a593Smuzhiyun  * @vif: &struct ieee80211_vif pointer from the add_interface callback.
4897*4882a593Smuzhiyun  * @tim_offset: pointer to variable that will receive the TIM IE offset.
4898*4882a593Smuzhiyun  *	Set to 0 if invalid (in non-AP modes).
4899*4882a593Smuzhiyun  * @tim_length: pointer to variable that will receive the TIM IE length,
4900*4882a593Smuzhiyun  *	(including the ID and length bytes!).
4901*4882a593Smuzhiyun  *	Set to 0 if invalid (in non-AP modes).
4902*4882a593Smuzhiyun  *
4903*4882a593Smuzhiyun  * If the driver implements beaconing modes, it must use this function to
4904*4882a593Smuzhiyun  * obtain the beacon frame.
4905*4882a593Smuzhiyun  *
4906*4882a593Smuzhiyun  * If the beacon frames are generated by the host system (i.e., not in
4907*4882a593Smuzhiyun  * hardware/firmware), the driver uses this function to get each beacon
4908*4882a593Smuzhiyun  * frame from mac80211 -- it is responsible for calling this function exactly
4909*4882a593Smuzhiyun  * once before the beacon is needed (e.g. based on hardware interrupt).
4910*4882a593Smuzhiyun  *
4911*4882a593Smuzhiyun  * The driver is responsible for freeing the returned skb.
4912*4882a593Smuzhiyun  *
4913*4882a593Smuzhiyun  * Return: The beacon template. %NULL on error.
4914*4882a593Smuzhiyun  */
4915*4882a593Smuzhiyun struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw,
4916*4882a593Smuzhiyun 					 struct ieee80211_vif *vif,
4917*4882a593Smuzhiyun 					 u16 *tim_offset, u16 *tim_length);
4918*4882a593Smuzhiyun 
4919*4882a593Smuzhiyun /**
4920*4882a593Smuzhiyun  * ieee80211_beacon_get - beacon generation function
4921*4882a593Smuzhiyun  * @hw: pointer obtained from ieee80211_alloc_hw().
4922*4882a593Smuzhiyun  * @vif: &struct ieee80211_vif pointer from the add_interface callback.
4923*4882a593Smuzhiyun  *
4924*4882a593Smuzhiyun  * See ieee80211_beacon_get_tim().
4925*4882a593Smuzhiyun  *
4926*4882a593Smuzhiyun  * Return: See ieee80211_beacon_get_tim().
4927*4882a593Smuzhiyun  */
ieee80211_beacon_get(struct ieee80211_hw * hw,struct ieee80211_vif * vif)4928*4882a593Smuzhiyun static inline struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
4929*4882a593Smuzhiyun 						   struct ieee80211_vif *vif)
4930*4882a593Smuzhiyun {
4931*4882a593Smuzhiyun 	return ieee80211_beacon_get_tim(hw, vif, NULL, NULL);
4932*4882a593Smuzhiyun }
4933*4882a593Smuzhiyun 
4934*4882a593Smuzhiyun /**
4935*4882a593Smuzhiyun  * ieee80211_beacon_update_cntdwn - request mac80211 to decrement the beacon countdown
4936*4882a593Smuzhiyun  * @vif: &struct ieee80211_vif pointer from the add_interface callback.
4937*4882a593Smuzhiyun  *
4938*4882a593Smuzhiyun  * The beacon counter should be updated after each beacon transmission.
4939*4882a593Smuzhiyun  * This function is called implicitly when
4940*4882a593Smuzhiyun  * ieee80211_beacon_get/ieee80211_beacon_get_tim are called, however if the
4941*4882a593Smuzhiyun  * beacon frames are generated by the device, the driver should call this
4942*4882a593Smuzhiyun  * function after each beacon transmission to sync mac80211's beacon countdown.
4943*4882a593Smuzhiyun  *
4944*4882a593Smuzhiyun  * Return: new countdown value
4945*4882a593Smuzhiyun  */
4946*4882a593Smuzhiyun u8 ieee80211_beacon_update_cntdwn(struct ieee80211_vif *vif);
4947*4882a593Smuzhiyun 
4948*4882a593Smuzhiyun /**
4949*4882a593Smuzhiyun  * ieee80211_beacon_set_cntdwn - request mac80211 to set beacon countdown
4950*4882a593Smuzhiyun  * @vif: &struct ieee80211_vif pointer from the add_interface callback.
4951*4882a593Smuzhiyun  * @counter: the new value for the counter
4952*4882a593Smuzhiyun  *
4953*4882a593Smuzhiyun  * The beacon countdown can be changed by the device, this API should be
4954*4882a593Smuzhiyun  * used by the device driver to update csa counter in mac80211.
4955*4882a593Smuzhiyun  *
4956*4882a593Smuzhiyun  * It should never be used together with ieee80211_beacon_update_cntdwn(),
4957*4882a593Smuzhiyun  * as it will cause a race condition around the counter value.
4958*4882a593Smuzhiyun  */
4959*4882a593Smuzhiyun void ieee80211_beacon_set_cntdwn(struct ieee80211_vif *vif, u8 counter);
4960*4882a593Smuzhiyun 
4961*4882a593Smuzhiyun /**
4962*4882a593Smuzhiyun  * ieee80211_csa_finish - notify mac80211 about channel switch
4963*4882a593Smuzhiyun  * @vif: &struct ieee80211_vif pointer from the add_interface callback.
4964*4882a593Smuzhiyun  *
4965*4882a593Smuzhiyun  * After a channel switch announcement was scheduled and the counter in this
4966*4882a593Smuzhiyun  * announcement hits 1, this function must be called by the driver to
4967*4882a593Smuzhiyun  * notify mac80211 that the channel can be changed.
4968*4882a593Smuzhiyun  */
4969*4882a593Smuzhiyun void ieee80211_csa_finish(struct ieee80211_vif *vif);
4970*4882a593Smuzhiyun 
4971*4882a593Smuzhiyun /**
4972*4882a593Smuzhiyun  * ieee80211_beacon_cntdwn_is_complete - find out if countdown reached 1
4973*4882a593Smuzhiyun  * @vif: &struct ieee80211_vif pointer from the add_interface callback.
4974*4882a593Smuzhiyun  *
4975*4882a593Smuzhiyun  * This function returns whether the countdown reached zero.
4976*4882a593Smuzhiyun  */
4977*4882a593Smuzhiyun bool ieee80211_beacon_cntdwn_is_complete(struct ieee80211_vif *vif);
4978*4882a593Smuzhiyun 
4979*4882a593Smuzhiyun /**
4980*4882a593Smuzhiyun  * ieee80211_proberesp_get - retrieve a Probe Response template
4981*4882a593Smuzhiyun  * @hw: pointer obtained from ieee80211_alloc_hw().
4982*4882a593Smuzhiyun  * @vif: &struct ieee80211_vif pointer from the add_interface callback.
4983*4882a593Smuzhiyun  *
4984*4882a593Smuzhiyun  * Creates a Probe Response template which can, for example, be uploaded to
4985*4882a593Smuzhiyun  * hardware. The destination address should be set by the caller.
4986*4882a593Smuzhiyun  *
4987*4882a593Smuzhiyun  * Can only be called in AP mode.
4988*4882a593Smuzhiyun  *
4989*4882a593Smuzhiyun  * Return: The Probe Response template. %NULL on error.
4990*4882a593Smuzhiyun  */
4991*4882a593Smuzhiyun struct sk_buff *ieee80211_proberesp_get(struct ieee80211_hw *hw,
4992*4882a593Smuzhiyun 					struct ieee80211_vif *vif);
4993*4882a593Smuzhiyun 
4994*4882a593Smuzhiyun /**
4995*4882a593Smuzhiyun  * ieee80211_pspoll_get - retrieve a PS Poll template
4996*4882a593Smuzhiyun  * @hw: pointer obtained from ieee80211_alloc_hw().
4997*4882a593Smuzhiyun  * @vif: &struct ieee80211_vif pointer from the add_interface callback.
4998*4882a593Smuzhiyun  *
4999*4882a593Smuzhiyun  * Creates a PS Poll a template which can, for example, uploaded to
5000*4882a593Smuzhiyun  * hardware. The template must be updated after association so that correct
5001*4882a593Smuzhiyun  * AID, BSSID and MAC address is used.
5002*4882a593Smuzhiyun  *
5003*4882a593Smuzhiyun  * Note: Caller (or hardware) is responsible for setting the
5004*4882a593Smuzhiyun  * &IEEE80211_FCTL_PM bit.
5005*4882a593Smuzhiyun  *
5006*4882a593Smuzhiyun  * Return: The PS Poll template. %NULL on error.
5007*4882a593Smuzhiyun  */
5008*4882a593Smuzhiyun struct sk_buff *ieee80211_pspoll_get(struct ieee80211_hw *hw,
5009*4882a593Smuzhiyun 				     struct ieee80211_vif *vif);
5010*4882a593Smuzhiyun 
5011*4882a593Smuzhiyun /**
5012*4882a593Smuzhiyun  * ieee80211_nullfunc_get - retrieve a nullfunc template
5013*4882a593Smuzhiyun  * @hw: pointer obtained from ieee80211_alloc_hw().
5014*4882a593Smuzhiyun  * @vif: &struct ieee80211_vif pointer from the add_interface callback.
5015*4882a593Smuzhiyun  * @qos_ok: QoS NDP is acceptable to the caller, this should be set
5016*4882a593Smuzhiyun  *	if at all possible
5017*4882a593Smuzhiyun  *
5018*4882a593Smuzhiyun  * Creates a Nullfunc template which can, for example, uploaded to
5019*4882a593Smuzhiyun  * hardware. The template must be updated after association so that correct
5020*4882a593Smuzhiyun  * BSSID and address is used.
5021*4882a593Smuzhiyun  *
5022*4882a593Smuzhiyun  * If @qos_ndp is set and the association is to an AP with QoS/WMM, the
5023*4882a593Smuzhiyun  * returned packet will be QoS NDP.
5024*4882a593Smuzhiyun  *
5025*4882a593Smuzhiyun  * Note: Caller (or hardware) is responsible for setting the
5026*4882a593Smuzhiyun  * &IEEE80211_FCTL_PM bit as well as Duration and Sequence Control fields.
5027*4882a593Smuzhiyun  *
5028*4882a593Smuzhiyun  * Return: The nullfunc template. %NULL on error.
5029*4882a593Smuzhiyun  */
5030*4882a593Smuzhiyun struct sk_buff *ieee80211_nullfunc_get(struct ieee80211_hw *hw,
5031*4882a593Smuzhiyun 				       struct ieee80211_vif *vif,
5032*4882a593Smuzhiyun 				       bool qos_ok);
5033*4882a593Smuzhiyun 
5034*4882a593Smuzhiyun /**
5035*4882a593Smuzhiyun  * ieee80211_probereq_get - retrieve a Probe Request template
5036*4882a593Smuzhiyun  * @hw: pointer obtained from ieee80211_alloc_hw().
5037*4882a593Smuzhiyun  * @src_addr: source MAC address
5038*4882a593Smuzhiyun  * @ssid: SSID buffer
5039*4882a593Smuzhiyun  * @ssid_len: length of SSID
5040*4882a593Smuzhiyun  * @tailroom: tailroom to reserve at end of SKB for IEs
5041*4882a593Smuzhiyun  *
5042*4882a593Smuzhiyun  * Creates a Probe Request template which can, for example, be uploaded to
5043*4882a593Smuzhiyun  * hardware.
5044*4882a593Smuzhiyun  *
5045*4882a593Smuzhiyun  * Return: The Probe Request template. %NULL on error.
5046*4882a593Smuzhiyun  */
5047*4882a593Smuzhiyun struct sk_buff *ieee80211_probereq_get(struct ieee80211_hw *hw,
5048*4882a593Smuzhiyun 				       const u8 *src_addr,
5049*4882a593Smuzhiyun 				       const u8 *ssid, size_t ssid_len,
5050*4882a593Smuzhiyun 				       size_t tailroom);
5051*4882a593Smuzhiyun 
5052*4882a593Smuzhiyun /**
5053*4882a593Smuzhiyun  * ieee80211_rts_get - RTS frame generation function
5054*4882a593Smuzhiyun  * @hw: pointer obtained from ieee80211_alloc_hw().
5055*4882a593Smuzhiyun  * @vif: &struct ieee80211_vif pointer from the add_interface callback.
5056*4882a593Smuzhiyun  * @frame: pointer to the frame that is going to be protected by the RTS.
5057*4882a593Smuzhiyun  * @frame_len: the frame length (in octets).
5058*4882a593Smuzhiyun  * @frame_txctl: &struct ieee80211_tx_info of the frame.
5059*4882a593Smuzhiyun  * @rts: The buffer where to store the RTS frame.
5060*4882a593Smuzhiyun  *
5061*4882a593Smuzhiyun  * If the RTS frames are generated by the host system (i.e., not in
5062*4882a593Smuzhiyun  * hardware/firmware), the low-level driver uses this function to receive
5063*4882a593Smuzhiyun  * the next RTS frame from the 802.11 code. The low-level is responsible
5064*4882a593Smuzhiyun  * for calling this function before and RTS frame is needed.
5065*4882a593Smuzhiyun  */
5066*4882a593Smuzhiyun void ieee80211_rts_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
5067*4882a593Smuzhiyun 		       const void *frame, size_t frame_len,
5068*4882a593Smuzhiyun 		       const struct ieee80211_tx_info *frame_txctl,
5069*4882a593Smuzhiyun 		       struct ieee80211_rts *rts);
5070*4882a593Smuzhiyun 
5071*4882a593Smuzhiyun /**
5072*4882a593Smuzhiyun  * ieee80211_rts_duration - Get the duration field for an RTS frame
5073*4882a593Smuzhiyun  * @hw: pointer obtained from ieee80211_alloc_hw().
5074*4882a593Smuzhiyun  * @vif: &struct ieee80211_vif pointer from the add_interface callback.
5075*4882a593Smuzhiyun  * @frame_len: the length of the frame that is going to be protected by the RTS.
5076*4882a593Smuzhiyun  * @frame_txctl: &struct ieee80211_tx_info of the frame.
5077*4882a593Smuzhiyun  *
5078*4882a593Smuzhiyun  * If the RTS is generated in firmware, but the host system must provide
5079*4882a593Smuzhiyun  * the duration field, the low-level driver uses this function to receive
5080*4882a593Smuzhiyun  * the duration field value in little-endian byteorder.
5081*4882a593Smuzhiyun  *
5082*4882a593Smuzhiyun  * Return: The duration.
5083*4882a593Smuzhiyun  */
5084*4882a593Smuzhiyun __le16 ieee80211_rts_duration(struct ieee80211_hw *hw,
5085*4882a593Smuzhiyun 			      struct ieee80211_vif *vif, size_t frame_len,
5086*4882a593Smuzhiyun 			      const struct ieee80211_tx_info *frame_txctl);
5087*4882a593Smuzhiyun 
5088*4882a593Smuzhiyun /**
5089*4882a593Smuzhiyun  * ieee80211_ctstoself_get - CTS-to-self frame generation function
5090*4882a593Smuzhiyun  * @hw: pointer obtained from ieee80211_alloc_hw().
5091*4882a593Smuzhiyun  * @vif: &struct ieee80211_vif pointer from the add_interface callback.
5092*4882a593Smuzhiyun  * @frame: pointer to the frame that is going to be protected by the CTS-to-self.
5093*4882a593Smuzhiyun  * @frame_len: the frame length (in octets).
5094*4882a593Smuzhiyun  * @frame_txctl: &struct ieee80211_tx_info of the frame.
5095*4882a593Smuzhiyun  * @cts: The buffer where to store the CTS-to-self frame.
5096*4882a593Smuzhiyun  *
5097*4882a593Smuzhiyun  * If the CTS-to-self frames are generated by the host system (i.e., not in
5098*4882a593Smuzhiyun  * hardware/firmware), the low-level driver uses this function to receive
5099*4882a593Smuzhiyun  * the next CTS-to-self frame from the 802.11 code. The low-level is responsible
5100*4882a593Smuzhiyun  * for calling this function before and CTS-to-self frame is needed.
5101*4882a593Smuzhiyun  */
5102*4882a593Smuzhiyun void ieee80211_ctstoself_get(struct ieee80211_hw *hw,
5103*4882a593Smuzhiyun 			     struct ieee80211_vif *vif,
5104*4882a593Smuzhiyun 			     const void *frame, size_t frame_len,
5105*4882a593Smuzhiyun 			     const struct ieee80211_tx_info *frame_txctl,
5106*4882a593Smuzhiyun 			     struct ieee80211_cts *cts);
5107*4882a593Smuzhiyun 
5108*4882a593Smuzhiyun /**
5109*4882a593Smuzhiyun  * ieee80211_ctstoself_duration - Get the duration field for a CTS-to-self frame
5110*4882a593Smuzhiyun  * @hw: pointer obtained from ieee80211_alloc_hw().
5111*4882a593Smuzhiyun  * @vif: &struct ieee80211_vif pointer from the add_interface callback.
5112*4882a593Smuzhiyun  * @frame_len: the length of the frame that is going to be protected by the CTS-to-self.
5113*4882a593Smuzhiyun  * @frame_txctl: &struct ieee80211_tx_info of the frame.
5114*4882a593Smuzhiyun  *
5115*4882a593Smuzhiyun  * If the CTS-to-self is generated in firmware, but the host system must provide
5116*4882a593Smuzhiyun  * the duration field, the low-level driver uses this function to receive
5117*4882a593Smuzhiyun  * the duration field value in little-endian byteorder.
5118*4882a593Smuzhiyun  *
5119*4882a593Smuzhiyun  * Return: The duration.
5120*4882a593Smuzhiyun  */
5121*4882a593Smuzhiyun __le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw,
5122*4882a593Smuzhiyun 				    struct ieee80211_vif *vif,
5123*4882a593Smuzhiyun 				    size_t frame_len,
5124*4882a593Smuzhiyun 				    const struct ieee80211_tx_info *frame_txctl);
5125*4882a593Smuzhiyun 
5126*4882a593Smuzhiyun /**
5127*4882a593Smuzhiyun  * ieee80211_generic_frame_duration - Calculate the duration field for a frame
5128*4882a593Smuzhiyun  * @hw: pointer obtained from ieee80211_alloc_hw().
5129*4882a593Smuzhiyun  * @vif: &struct ieee80211_vif pointer from the add_interface callback.
5130*4882a593Smuzhiyun  * @band: the band to calculate the frame duration on
5131*4882a593Smuzhiyun  * @frame_len: the length of the frame.
5132*4882a593Smuzhiyun  * @rate: the rate at which the frame is going to be transmitted.
5133*4882a593Smuzhiyun  *
5134*4882a593Smuzhiyun  * Calculate the duration field of some generic frame, given its
5135*4882a593Smuzhiyun  * length and transmission rate (in 100kbps).
5136*4882a593Smuzhiyun  *
5137*4882a593Smuzhiyun  * Return: The duration.
5138*4882a593Smuzhiyun  */
5139*4882a593Smuzhiyun __le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw,
5140*4882a593Smuzhiyun 					struct ieee80211_vif *vif,
5141*4882a593Smuzhiyun 					enum nl80211_band band,
5142*4882a593Smuzhiyun 					size_t frame_len,
5143*4882a593Smuzhiyun 					struct ieee80211_rate *rate);
5144*4882a593Smuzhiyun 
5145*4882a593Smuzhiyun /**
5146*4882a593Smuzhiyun  * ieee80211_get_buffered_bc - accessing buffered broadcast and multicast frames
5147*4882a593Smuzhiyun  * @hw: pointer as obtained from ieee80211_alloc_hw().
5148*4882a593Smuzhiyun  * @vif: &struct ieee80211_vif pointer from the add_interface callback.
5149*4882a593Smuzhiyun  *
5150*4882a593Smuzhiyun  * Function for accessing buffered broadcast and multicast frames. If
5151*4882a593Smuzhiyun  * hardware/firmware does not implement buffering of broadcast/multicast
5152*4882a593Smuzhiyun  * frames when power saving is used, 802.11 code buffers them in the host
5153*4882a593Smuzhiyun  * memory. The low-level driver uses this function to fetch next buffered
5154*4882a593Smuzhiyun  * frame. In most cases, this is used when generating beacon frame.
5155*4882a593Smuzhiyun  *
5156*4882a593Smuzhiyun  * Return: A pointer to the next buffered skb or NULL if no more buffered
5157*4882a593Smuzhiyun  * frames are available.
5158*4882a593Smuzhiyun  *
5159*4882a593Smuzhiyun  * Note: buffered frames are returned only after DTIM beacon frame was
5160*4882a593Smuzhiyun  * generated with ieee80211_beacon_get() and the low-level driver must thus
5161*4882a593Smuzhiyun  * call ieee80211_beacon_get() first. ieee80211_get_buffered_bc() returns
5162*4882a593Smuzhiyun  * NULL if the previous generated beacon was not DTIM, so the low-level driver
5163*4882a593Smuzhiyun  * does not need to check for DTIM beacons separately and should be able to
5164*4882a593Smuzhiyun  * use common code for all beacons.
5165*4882a593Smuzhiyun  */
5166*4882a593Smuzhiyun struct sk_buff *
5167*4882a593Smuzhiyun ieee80211_get_buffered_bc(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
5168*4882a593Smuzhiyun 
5169*4882a593Smuzhiyun /**
5170*4882a593Smuzhiyun  * ieee80211_get_tkip_p1k_iv - get a TKIP phase 1 key for IV32
5171*4882a593Smuzhiyun  *
5172*4882a593Smuzhiyun  * This function returns the TKIP phase 1 key for the given IV32.
5173*4882a593Smuzhiyun  *
5174*4882a593Smuzhiyun  * @keyconf: the parameter passed with the set key
5175*4882a593Smuzhiyun  * @iv32: IV32 to get the P1K for
5176*4882a593Smuzhiyun  * @p1k: a buffer to which the key will be written, as 5 u16 values
5177*4882a593Smuzhiyun  */
5178*4882a593Smuzhiyun void ieee80211_get_tkip_p1k_iv(struct ieee80211_key_conf *keyconf,
5179*4882a593Smuzhiyun 			       u32 iv32, u16 *p1k);
5180*4882a593Smuzhiyun 
5181*4882a593Smuzhiyun /**
5182*4882a593Smuzhiyun  * ieee80211_get_tkip_p1k - get a TKIP phase 1 key
5183*4882a593Smuzhiyun  *
5184*4882a593Smuzhiyun  * This function returns the TKIP phase 1 key for the IV32 taken
5185*4882a593Smuzhiyun  * from the given packet.
5186*4882a593Smuzhiyun  *
5187*4882a593Smuzhiyun  * @keyconf: the parameter passed with the set key
5188*4882a593Smuzhiyun  * @skb: the packet to take the IV32 value from that will be encrypted
5189*4882a593Smuzhiyun  *	with this P1K
5190*4882a593Smuzhiyun  * @p1k: a buffer to which the key will be written, as 5 u16 values
5191*4882a593Smuzhiyun  */
ieee80211_get_tkip_p1k(struct ieee80211_key_conf * keyconf,struct sk_buff * skb,u16 * p1k)5192*4882a593Smuzhiyun static inline void ieee80211_get_tkip_p1k(struct ieee80211_key_conf *keyconf,
5193*4882a593Smuzhiyun 					  struct sk_buff *skb, u16 *p1k)
5194*4882a593Smuzhiyun {
5195*4882a593Smuzhiyun 	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
5196*4882a593Smuzhiyun 	const u8 *data = (u8 *)hdr + ieee80211_hdrlen(hdr->frame_control);
5197*4882a593Smuzhiyun 	u32 iv32 = get_unaligned_le32(&data[4]);
5198*4882a593Smuzhiyun 
5199*4882a593Smuzhiyun 	ieee80211_get_tkip_p1k_iv(keyconf, iv32, p1k);
5200*4882a593Smuzhiyun }
5201*4882a593Smuzhiyun 
5202*4882a593Smuzhiyun /**
5203*4882a593Smuzhiyun  * ieee80211_get_tkip_rx_p1k - get a TKIP phase 1 key for RX
5204*4882a593Smuzhiyun  *
5205*4882a593Smuzhiyun  * This function returns the TKIP phase 1 key for the given IV32
5206*4882a593Smuzhiyun  * and transmitter address.
5207*4882a593Smuzhiyun  *
5208*4882a593Smuzhiyun  * @keyconf: the parameter passed with the set key
5209*4882a593Smuzhiyun  * @ta: TA that will be used with the key
5210*4882a593Smuzhiyun  * @iv32: IV32 to get the P1K for
5211*4882a593Smuzhiyun  * @p1k: a buffer to which the key will be written, as 5 u16 values
5212*4882a593Smuzhiyun  */
5213*4882a593Smuzhiyun void ieee80211_get_tkip_rx_p1k(struct ieee80211_key_conf *keyconf,
5214*4882a593Smuzhiyun 			       const u8 *ta, u32 iv32, u16 *p1k);
5215*4882a593Smuzhiyun 
5216*4882a593Smuzhiyun /**
5217*4882a593Smuzhiyun  * ieee80211_get_tkip_p2k - get a TKIP phase 2 key
5218*4882a593Smuzhiyun  *
5219*4882a593Smuzhiyun  * This function computes the TKIP RC4 key for the IV values
5220*4882a593Smuzhiyun  * in the packet.
5221*4882a593Smuzhiyun  *
5222*4882a593Smuzhiyun  * @keyconf: the parameter passed with the set key
5223*4882a593Smuzhiyun  * @skb: the packet to take the IV32/IV16 values from that will be
5224*4882a593Smuzhiyun  *	encrypted with this key
5225*4882a593Smuzhiyun  * @p2k: a buffer to which the key will be written, 16 bytes
5226*4882a593Smuzhiyun  */
5227*4882a593Smuzhiyun void ieee80211_get_tkip_p2k(struct ieee80211_key_conf *keyconf,
5228*4882a593Smuzhiyun 			    struct sk_buff *skb, u8 *p2k);
5229*4882a593Smuzhiyun 
5230*4882a593Smuzhiyun /**
5231*4882a593Smuzhiyun  * ieee80211_tkip_add_iv - write TKIP IV and Ext. IV to pos
5232*4882a593Smuzhiyun  *
5233*4882a593Smuzhiyun  * @pos: start of crypto header
5234*4882a593Smuzhiyun  * @keyconf: the parameter passed with the set key
5235*4882a593Smuzhiyun  * @pn: PN to add
5236*4882a593Smuzhiyun  *
5237*4882a593Smuzhiyun  * Returns: pointer to the octet following IVs (i.e. beginning of
5238*4882a593Smuzhiyun  * the packet payload)
5239*4882a593Smuzhiyun  *
5240*4882a593Smuzhiyun  * This function writes the tkip IV value to pos (which should
5241*4882a593Smuzhiyun  * point to the crypto header)
5242*4882a593Smuzhiyun  */
5243*4882a593Smuzhiyun u8 *ieee80211_tkip_add_iv(u8 *pos, struct ieee80211_key_conf *keyconf, u64 pn);
5244*4882a593Smuzhiyun 
5245*4882a593Smuzhiyun /**
5246*4882a593Smuzhiyun  * ieee80211_get_key_rx_seq - get key RX sequence counter
5247*4882a593Smuzhiyun  *
5248*4882a593Smuzhiyun  * @keyconf: the parameter passed with the set key
5249*4882a593Smuzhiyun  * @tid: The TID, or -1 for the management frame value (CCMP/GCMP only);
5250*4882a593Smuzhiyun  *	the value on TID 0 is also used for non-QoS frames. For
5251*4882a593Smuzhiyun  *	CMAC, only TID 0 is valid.
5252*4882a593Smuzhiyun  * @seq: buffer to receive the sequence data
5253*4882a593Smuzhiyun  *
5254*4882a593Smuzhiyun  * This function allows a driver to retrieve the current RX IV/PNs
5255*4882a593Smuzhiyun  * for the given key. It must not be called if IV checking is done
5256*4882a593Smuzhiyun  * by the device and not by mac80211.
5257*4882a593Smuzhiyun  *
5258*4882a593Smuzhiyun  * Note that this function may only be called when no RX processing
5259*4882a593Smuzhiyun  * can be done concurrently.
5260*4882a593Smuzhiyun  */
5261*4882a593Smuzhiyun void ieee80211_get_key_rx_seq(struct ieee80211_key_conf *keyconf,
5262*4882a593Smuzhiyun 			      int tid, struct ieee80211_key_seq *seq);
5263*4882a593Smuzhiyun 
5264*4882a593Smuzhiyun /**
5265*4882a593Smuzhiyun  * ieee80211_set_key_rx_seq - set key RX sequence counter
5266*4882a593Smuzhiyun  *
5267*4882a593Smuzhiyun  * @keyconf: the parameter passed with the set key
5268*4882a593Smuzhiyun  * @tid: The TID, or -1 for the management frame value (CCMP/GCMP only);
5269*4882a593Smuzhiyun  *	the value on TID 0 is also used for non-QoS frames. For
5270*4882a593Smuzhiyun  *	CMAC, only TID 0 is valid.
5271*4882a593Smuzhiyun  * @seq: new sequence data
5272*4882a593Smuzhiyun  *
5273*4882a593Smuzhiyun  * This function allows a driver to set the current RX IV/PNs for the
5274*4882a593Smuzhiyun  * given key. This is useful when resuming from WoWLAN sleep and GTK
5275*4882a593Smuzhiyun  * rekey may have been done while suspended. It should not be called
5276*4882a593Smuzhiyun  * if IV checking is done by the device and not by mac80211.
5277*4882a593Smuzhiyun  *
5278*4882a593Smuzhiyun  * Note that this function may only be called when no RX processing
5279*4882a593Smuzhiyun  * can be done concurrently.
5280*4882a593Smuzhiyun  */
5281*4882a593Smuzhiyun void ieee80211_set_key_rx_seq(struct ieee80211_key_conf *keyconf,
5282*4882a593Smuzhiyun 			      int tid, struct ieee80211_key_seq *seq);
5283*4882a593Smuzhiyun 
5284*4882a593Smuzhiyun /**
5285*4882a593Smuzhiyun  * ieee80211_remove_key - remove the given key
5286*4882a593Smuzhiyun  * @keyconf: the parameter passed with the set key
5287*4882a593Smuzhiyun  *
5288*4882a593Smuzhiyun  * Remove the given key. If the key was uploaded to the hardware at the
5289*4882a593Smuzhiyun  * time this function is called, it is not deleted in the hardware but
5290*4882a593Smuzhiyun  * instead assumed to have been removed already.
5291*4882a593Smuzhiyun  *
5292*4882a593Smuzhiyun  * Note that due to locking considerations this function can (currently)
5293*4882a593Smuzhiyun  * only be called during key iteration (ieee80211_iter_keys().)
5294*4882a593Smuzhiyun  */
5295*4882a593Smuzhiyun void ieee80211_remove_key(struct ieee80211_key_conf *keyconf);
5296*4882a593Smuzhiyun 
5297*4882a593Smuzhiyun /**
5298*4882a593Smuzhiyun  * ieee80211_gtk_rekey_add - add a GTK key from rekeying during WoWLAN
5299*4882a593Smuzhiyun  * @vif: the virtual interface to add the key on
5300*4882a593Smuzhiyun  * @keyconf: new key data
5301*4882a593Smuzhiyun  *
5302*4882a593Smuzhiyun  * When GTK rekeying was done while the system was suspended, (a) new
5303*4882a593Smuzhiyun  * key(s) will be available. These will be needed by mac80211 for proper
5304*4882a593Smuzhiyun  * RX processing, so this function allows setting them.
5305*4882a593Smuzhiyun  *
5306*4882a593Smuzhiyun  * The function returns the newly allocated key structure, which will
5307*4882a593Smuzhiyun  * have similar contents to the passed key configuration but point to
5308*4882a593Smuzhiyun  * mac80211-owned memory. In case of errors, the function returns an
5309*4882a593Smuzhiyun  * ERR_PTR(), use IS_ERR() etc.
5310*4882a593Smuzhiyun  *
5311*4882a593Smuzhiyun  * Note that this function assumes the key isn't added to hardware
5312*4882a593Smuzhiyun  * acceleration, so no TX will be done with the key. Since it's a GTK
5313*4882a593Smuzhiyun  * on managed (station) networks, this is true anyway. If the driver
5314*4882a593Smuzhiyun  * calls this function from the resume callback and subsequently uses
5315*4882a593Smuzhiyun  * the return code 1 to reconfigure the device, this key will be part
5316*4882a593Smuzhiyun  * of the reconfiguration.
5317*4882a593Smuzhiyun  *
5318*4882a593Smuzhiyun  * Note that the driver should also call ieee80211_set_key_rx_seq()
5319*4882a593Smuzhiyun  * for the new key for each TID to set up sequence counters properly.
5320*4882a593Smuzhiyun  *
5321*4882a593Smuzhiyun  * IMPORTANT: If this replaces a key that is present in the hardware,
5322*4882a593Smuzhiyun  * then it will attempt to remove it during this call. In many cases
5323*4882a593Smuzhiyun  * this isn't what you want, so call ieee80211_remove_key() first for
5324*4882a593Smuzhiyun  * the key that's being replaced.
5325*4882a593Smuzhiyun  */
5326*4882a593Smuzhiyun struct ieee80211_key_conf *
5327*4882a593Smuzhiyun ieee80211_gtk_rekey_add(struct ieee80211_vif *vif,
5328*4882a593Smuzhiyun 			struct ieee80211_key_conf *keyconf);
5329*4882a593Smuzhiyun 
5330*4882a593Smuzhiyun /**
5331*4882a593Smuzhiyun  * ieee80211_gtk_rekey_notify - notify userspace supplicant of rekeying
5332*4882a593Smuzhiyun  * @vif: virtual interface the rekeying was done on
5333*4882a593Smuzhiyun  * @bssid: The BSSID of the AP, for checking association
5334*4882a593Smuzhiyun  * @replay_ctr: the new replay counter after GTK rekeying
5335*4882a593Smuzhiyun  * @gfp: allocation flags
5336*4882a593Smuzhiyun  */
5337*4882a593Smuzhiyun void ieee80211_gtk_rekey_notify(struct ieee80211_vif *vif, const u8 *bssid,
5338*4882a593Smuzhiyun 				const u8 *replay_ctr, gfp_t gfp);
5339*4882a593Smuzhiyun 
5340*4882a593Smuzhiyun /**
5341*4882a593Smuzhiyun  * ieee80211_wake_queue - wake specific queue
5342*4882a593Smuzhiyun  * @hw: pointer as obtained from ieee80211_alloc_hw().
5343*4882a593Smuzhiyun  * @queue: queue number (counted from zero).
5344*4882a593Smuzhiyun  *
5345*4882a593Smuzhiyun  * Drivers should use this function instead of netif_wake_queue.
5346*4882a593Smuzhiyun  */
5347*4882a593Smuzhiyun void ieee80211_wake_queue(struct ieee80211_hw *hw, int queue);
5348*4882a593Smuzhiyun 
5349*4882a593Smuzhiyun /**
5350*4882a593Smuzhiyun  * ieee80211_stop_queue - stop specific queue
5351*4882a593Smuzhiyun  * @hw: pointer as obtained from ieee80211_alloc_hw().
5352*4882a593Smuzhiyun  * @queue: queue number (counted from zero).
5353*4882a593Smuzhiyun  *
5354*4882a593Smuzhiyun  * Drivers should use this function instead of netif_stop_queue.
5355*4882a593Smuzhiyun  */
5356*4882a593Smuzhiyun void ieee80211_stop_queue(struct ieee80211_hw *hw, int queue);
5357*4882a593Smuzhiyun 
5358*4882a593Smuzhiyun /**
5359*4882a593Smuzhiyun  * ieee80211_queue_stopped - test status of the queue
5360*4882a593Smuzhiyun  * @hw: pointer as obtained from ieee80211_alloc_hw().
5361*4882a593Smuzhiyun  * @queue: queue number (counted from zero).
5362*4882a593Smuzhiyun  *
5363*4882a593Smuzhiyun  * Drivers should use this function instead of netif_stop_queue.
5364*4882a593Smuzhiyun  *
5365*4882a593Smuzhiyun  * Return: %true if the queue is stopped. %false otherwise.
5366*4882a593Smuzhiyun  */
5367*4882a593Smuzhiyun 
5368*4882a593Smuzhiyun int ieee80211_queue_stopped(struct ieee80211_hw *hw, int queue);
5369*4882a593Smuzhiyun 
5370*4882a593Smuzhiyun /**
5371*4882a593Smuzhiyun  * ieee80211_stop_queues - stop all queues
5372*4882a593Smuzhiyun  * @hw: pointer as obtained from ieee80211_alloc_hw().
5373*4882a593Smuzhiyun  *
5374*4882a593Smuzhiyun  * Drivers should use this function instead of netif_stop_queue.
5375*4882a593Smuzhiyun  */
5376*4882a593Smuzhiyun void ieee80211_stop_queues(struct ieee80211_hw *hw);
5377*4882a593Smuzhiyun 
5378*4882a593Smuzhiyun /**
5379*4882a593Smuzhiyun  * ieee80211_wake_queues - wake all queues
5380*4882a593Smuzhiyun  * @hw: pointer as obtained from ieee80211_alloc_hw().
5381*4882a593Smuzhiyun  *
5382*4882a593Smuzhiyun  * Drivers should use this function instead of netif_wake_queue.
5383*4882a593Smuzhiyun  */
5384*4882a593Smuzhiyun void ieee80211_wake_queues(struct ieee80211_hw *hw);
5385*4882a593Smuzhiyun 
5386*4882a593Smuzhiyun /**
5387*4882a593Smuzhiyun  * ieee80211_scan_completed - completed hardware scan
5388*4882a593Smuzhiyun  *
5389*4882a593Smuzhiyun  * When hardware scan offload is used (i.e. the hw_scan() callback is
5390*4882a593Smuzhiyun  * assigned) this function needs to be called by the driver to notify
5391*4882a593Smuzhiyun  * mac80211 that the scan finished. This function can be called from
5392*4882a593Smuzhiyun  * any context, including hardirq context.
5393*4882a593Smuzhiyun  *
5394*4882a593Smuzhiyun  * @hw: the hardware that finished the scan
5395*4882a593Smuzhiyun  * @info: information about the completed scan
5396*4882a593Smuzhiyun  */
5397*4882a593Smuzhiyun void ieee80211_scan_completed(struct ieee80211_hw *hw,
5398*4882a593Smuzhiyun 			      struct cfg80211_scan_info *info);
5399*4882a593Smuzhiyun 
5400*4882a593Smuzhiyun /**
5401*4882a593Smuzhiyun  * ieee80211_sched_scan_results - got results from scheduled scan
5402*4882a593Smuzhiyun  *
5403*4882a593Smuzhiyun  * When a scheduled scan is running, this function needs to be called by the
5404*4882a593Smuzhiyun  * driver whenever there are new scan results available.
5405*4882a593Smuzhiyun  *
5406*4882a593Smuzhiyun  * @hw: the hardware that is performing scheduled scans
5407*4882a593Smuzhiyun  */
5408*4882a593Smuzhiyun void ieee80211_sched_scan_results(struct ieee80211_hw *hw);
5409*4882a593Smuzhiyun 
5410*4882a593Smuzhiyun /**
5411*4882a593Smuzhiyun  * ieee80211_sched_scan_stopped - inform that the scheduled scan has stopped
5412*4882a593Smuzhiyun  *
5413*4882a593Smuzhiyun  * When a scheduled scan is running, this function can be called by
5414*4882a593Smuzhiyun  * the driver if it needs to stop the scan to perform another task.
5415*4882a593Smuzhiyun  * Usual scenarios are drivers that cannot continue the scheduled scan
5416*4882a593Smuzhiyun  * while associating, for instance.
5417*4882a593Smuzhiyun  *
5418*4882a593Smuzhiyun  * @hw: the hardware that is performing scheduled scans
5419*4882a593Smuzhiyun  */
5420*4882a593Smuzhiyun void ieee80211_sched_scan_stopped(struct ieee80211_hw *hw);
5421*4882a593Smuzhiyun 
5422*4882a593Smuzhiyun /**
5423*4882a593Smuzhiyun  * enum ieee80211_interface_iteration_flags - interface iteration flags
5424*4882a593Smuzhiyun  * @IEEE80211_IFACE_ITER_NORMAL: Iterate over all interfaces that have
5425*4882a593Smuzhiyun  *	been added to the driver; However, note that during hardware
5426*4882a593Smuzhiyun  *	reconfiguration (after restart_hw) it will iterate over a new
5427*4882a593Smuzhiyun  *	interface and over all the existing interfaces even if they
5428*4882a593Smuzhiyun  *	haven't been re-added to the driver yet.
5429*4882a593Smuzhiyun  * @IEEE80211_IFACE_ITER_RESUME_ALL: During resume, iterate over all
5430*4882a593Smuzhiyun  *	interfaces, even if they haven't been re-added to the driver yet.
5431*4882a593Smuzhiyun  * @IEEE80211_IFACE_ITER_ACTIVE: Iterate only active interfaces (netdev is up).
5432*4882a593Smuzhiyun  * @IEEE80211_IFACE_SKIP_SDATA_NOT_IN_DRIVER: Skip any interfaces where SDATA
5433*4882a593Smuzhiyun  *	is not in the driver.  This may fix crashes during firmware recovery
5434*4882a593Smuzhiyun  *	for instance.
5435*4882a593Smuzhiyun  */
5436*4882a593Smuzhiyun enum ieee80211_interface_iteration_flags {
5437*4882a593Smuzhiyun 	IEEE80211_IFACE_ITER_NORMAL	= 0,
5438*4882a593Smuzhiyun 	IEEE80211_IFACE_ITER_RESUME_ALL	= BIT(0),
5439*4882a593Smuzhiyun 	IEEE80211_IFACE_ITER_ACTIVE	= BIT(1),
5440*4882a593Smuzhiyun 	IEEE80211_IFACE_SKIP_SDATA_NOT_IN_DRIVER	= BIT(2),
5441*4882a593Smuzhiyun };
5442*4882a593Smuzhiyun 
5443*4882a593Smuzhiyun /**
5444*4882a593Smuzhiyun  * ieee80211_iterate_interfaces - iterate interfaces
5445*4882a593Smuzhiyun  *
5446*4882a593Smuzhiyun  * This function iterates over the interfaces associated with a given
5447*4882a593Smuzhiyun  * hardware and calls the callback for them. This includes active as well as
5448*4882a593Smuzhiyun  * inactive interfaces. This function allows the iterator function to sleep.
5449*4882a593Smuzhiyun  * Will iterate over a new interface during add_interface().
5450*4882a593Smuzhiyun  *
5451*4882a593Smuzhiyun  * @hw: the hardware struct of which the interfaces should be iterated over
5452*4882a593Smuzhiyun  * @iter_flags: iteration flags, see &enum ieee80211_interface_iteration_flags
5453*4882a593Smuzhiyun  * @iterator: the iterator function to call
5454*4882a593Smuzhiyun  * @data: first argument of the iterator function
5455*4882a593Smuzhiyun  */
5456*4882a593Smuzhiyun void ieee80211_iterate_interfaces(struct ieee80211_hw *hw, u32 iter_flags,
5457*4882a593Smuzhiyun 				  void (*iterator)(void *data, u8 *mac,
5458*4882a593Smuzhiyun 						   struct ieee80211_vif *vif),
5459*4882a593Smuzhiyun 				  void *data);
5460*4882a593Smuzhiyun 
5461*4882a593Smuzhiyun /**
5462*4882a593Smuzhiyun  * ieee80211_iterate_active_interfaces - iterate active interfaces
5463*4882a593Smuzhiyun  *
5464*4882a593Smuzhiyun  * This function iterates over the interfaces associated with a given
5465*4882a593Smuzhiyun  * hardware that are currently active and calls the callback for them.
5466*4882a593Smuzhiyun  * This function allows the iterator function to sleep, when the iterator
5467*4882a593Smuzhiyun  * function is atomic @ieee80211_iterate_active_interfaces_atomic can
5468*4882a593Smuzhiyun  * be used.
5469*4882a593Smuzhiyun  * Does not iterate over a new interface during add_interface().
5470*4882a593Smuzhiyun  *
5471*4882a593Smuzhiyun  * @hw: the hardware struct of which the interfaces should be iterated over
5472*4882a593Smuzhiyun  * @iter_flags: iteration flags, see &enum ieee80211_interface_iteration_flags
5473*4882a593Smuzhiyun  * @iterator: the iterator function to call
5474*4882a593Smuzhiyun  * @data: first argument of the iterator function
5475*4882a593Smuzhiyun  */
5476*4882a593Smuzhiyun static inline void
ieee80211_iterate_active_interfaces(struct ieee80211_hw * hw,u32 iter_flags,void (* iterator)(void * data,u8 * mac,struct ieee80211_vif * vif),void * data)5477*4882a593Smuzhiyun ieee80211_iterate_active_interfaces(struct ieee80211_hw *hw, u32 iter_flags,
5478*4882a593Smuzhiyun 				    void (*iterator)(void *data, u8 *mac,
5479*4882a593Smuzhiyun 						     struct ieee80211_vif *vif),
5480*4882a593Smuzhiyun 				    void *data)
5481*4882a593Smuzhiyun {
5482*4882a593Smuzhiyun 	ieee80211_iterate_interfaces(hw,
5483*4882a593Smuzhiyun 				     iter_flags | IEEE80211_IFACE_ITER_ACTIVE,
5484*4882a593Smuzhiyun 				     iterator, data);
5485*4882a593Smuzhiyun }
5486*4882a593Smuzhiyun 
5487*4882a593Smuzhiyun /**
5488*4882a593Smuzhiyun  * ieee80211_iterate_active_interfaces_atomic - iterate active interfaces
5489*4882a593Smuzhiyun  *
5490*4882a593Smuzhiyun  * This function iterates over the interfaces associated with a given
5491*4882a593Smuzhiyun  * hardware that are currently active and calls the callback for them.
5492*4882a593Smuzhiyun  * This function requires the iterator callback function to be atomic,
5493*4882a593Smuzhiyun  * if that is not desired, use @ieee80211_iterate_active_interfaces instead.
5494*4882a593Smuzhiyun  * Does not iterate over a new interface during add_interface().
5495*4882a593Smuzhiyun  *
5496*4882a593Smuzhiyun  * @hw: the hardware struct of which the interfaces should be iterated over
5497*4882a593Smuzhiyun  * @iter_flags: iteration flags, see &enum ieee80211_interface_iteration_flags
5498*4882a593Smuzhiyun  * @iterator: the iterator function to call, cannot sleep
5499*4882a593Smuzhiyun  * @data: first argument of the iterator function
5500*4882a593Smuzhiyun  */
5501*4882a593Smuzhiyun void ieee80211_iterate_active_interfaces_atomic(struct ieee80211_hw *hw,
5502*4882a593Smuzhiyun 						u32 iter_flags,
5503*4882a593Smuzhiyun 						void (*iterator)(void *data,
5504*4882a593Smuzhiyun 						    u8 *mac,
5505*4882a593Smuzhiyun 						    struct ieee80211_vif *vif),
5506*4882a593Smuzhiyun 						void *data);
5507*4882a593Smuzhiyun 
5508*4882a593Smuzhiyun /**
5509*4882a593Smuzhiyun  * ieee80211_iterate_active_interfaces_rtnl - iterate active interfaces
5510*4882a593Smuzhiyun  *
5511*4882a593Smuzhiyun  * This function iterates over the interfaces associated with a given
5512*4882a593Smuzhiyun  * hardware that are currently active and calls the callback for them.
5513*4882a593Smuzhiyun  * This version can only be used while holding the RTNL.
5514*4882a593Smuzhiyun  *
5515*4882a593Smuzhiyun  * @hw: the hardware struct of which the interfaces should be iterated over
5516*4882a593Smuzhiyun  * @iter_flags: iteration flags, see &enum ieee80211_interface_iteration_flags
5517*4882a593Smuzhiyun  * @iterator: the iterator function to call, cannot sleep
5518*4882a593Smuzhiyun  * @data: first argument of the iterator function
5519*4882a593Smuzhiyun  */
5520*4882a593Smuzhiyun void ieee80211_iterate_active_interfaces_rtnl(struct ieee80211_hw *hw,
5521*4882a593Smuzhiyun 					      u32 iter_flags,
5522*4882a593Smuzhiyun 					      void (*iterator)(void *data,
5523*4882a593Smuzhiyun 						u8 *mac,
5524*4882a593Smuzhiyun 						struct ieee80211_vif *vif),
5525*4882a593Smuzhiyun 					      void *data);
5526*4882a593Smuzhiyun 
5527*4882a593Smuzhiyun /**
5528*4882a593Smuzhiyun  * ieee80211_iterate_stations_atomic - iterate stations
5529*4882a593Smuzhiyun  *
5530*4882a593Smuzhiyun  * This function iterates over all stations associated with a given
5531*4882a593Smuzhiyun  * hardware that are currently uploaded to the driver and calls the callback
5532*4882a593Smuzhiyun  * function for them.
5533*4882a593Smuzhiyun  * This function requires the iterator callback function to be atomic,
5534*4882a593Smuzhiyun  *
5535*4882a593Smuzhiyun  * @hw: the hardware struct of which the interfaces should be iterated over
5536*4882a593Smuzhiyun  * @iterator: the iterator function to call, cannot sleep
5537*4882a593Smuzhiyun  * @data: first argument of the iterator function
5538*4882a593Smuzhiyun  */
5539*4882a593Smuzhiyun void ieee80211_iterate_stations_atomic(struct ieee80211_hw *hw,
5540*4882a593Smuzhiyun 				       void (*iterator)(void *data,
5541*4882a593Smuzhiyun 						struct ieee80211_sta *sta),
5542*4882a593Smuzhiyun 				       void *data);
5543*4882a593Smuzhiyun /**
5544*4882a593Smuzhiyun  * ieee80211_queue_work - add work onto the mac80211 workqueue
5545*4882a593Smuzhiyun  *
5546*4882a593Smuzhiyun  * Drivers and mac80211 use this to add work onto the mac80211 workqueue.
5547*4882a593Smuzhiyun  * This helper ensures drivers are not queueing work when they should not be.
5548*4882a593Smuzhiyun  *
5549*4882a593Smuzhiyun  * @hw: the hardware struct for the interface we are adding work for
5550*4882a593Smuzhiyun  * @work: the work we want to add onto the mac80211 workqueue
5551*4882a593Smuzhiyun  */
5552*4882a593Smuzhiyun void ieee80211_queue_work(struct ieee80211_hw *hw, struct work_struct *work);
5553*4882a593Smuzhiyun 
5554*4882a593Smuzhiyun /**
5555*4882a593Smuzhiyun  * ieee80211_queue_delayed_work - add work onto the mac80211 workqueue
5556*4882a593Smuzhiyun  *
5557*4882a593Smuzhiyun  * Drivers and mac80211 use this to queue delayed work onto the mac80211
5558*4882a593Smuzhiyun  * workqueue.
5559*4882a593Smuzhiyun  *
5560*4882a593Smuzhiyun  * @hw: the hardware struct for the interface we are adding work for
5561*4882a593Smuzhiyun  * @dwork: delayable work to queue onto the mac80211 workqueue
5562*4882a593Smuzhiyun  * @delay: number of jiffies to wait before queueing
5563*4882a593Smuzhiyun  */
5564*4882a593Smuzhiyun void ieee80211_queue_delayed_work(struct ieee80211_hw *hw,
5565*4882a593Smuzhiyun 				  struct delayed_work *dwork,
5566*4882a593Smuzhiyun 				  unsigned long delay);
5567*4882a593Smuzhiyun 
5568*4882a593Smuzhiyun /**
5569*4882a593Smuzhiyun  * ieee80211_start_tx_ba_session - Start a tx Block Ack session.
5570*4882a593Smuzhiyun  * @sta: the station for which to start a BA session
5571*4882a593Smuzhiyun  * @tid: the TID to BA on.
5572*4882a593Smuzhiyun  * @timeout: session timeout value (in TUs)
5573*4882a593Smuzhiyun  *
5574*4882a593Smuzhiyun  * Return: success if addBA request was sent, failure otherwise
5575*4882a593Smuzhiyun  *
5576*4882a593Smuzhiyun  * Although mac80211/low level driver/user space application can estimate
5577*4882a593Smuzhiyun  * the need to start aggregation on a certain RA/TID, the session level
5578*4882a593Smuzhiyun  * will be managed by the mac80211.
5579*4882a593Smuzhiyun  */
5580*4882a593Smuzhiyun int ieee80211_start_tx_ba_session(struct ieee80211_sta *sta, u16 tid,
5581*4882a593Smuzhiyun 				  u16 timeout);
5582*4882a593Smuzhiyun 
5583*4882a593Smuzhiyun /**
5584*4882a593Smuzhiyun  * ieee80211_start_tx_ba_cb_irqsafe - low level driver ready to aggregate.
5585*4882a593Smuzhiyun  * @vif: &struct ieee80211_vif pointer from the add_interface callback
5586*4882a593Smuzhiyun  * @ra: receiver address of the BA session recipient.
5587*4882a593Smuzhiyun  * @tid: the TID to BA on.
5588*4882a593Smuzhiyun  *
5589*4882a593Smuzhiyun  * This function must be called by low level driver once it has
5590*4882a593Smuzhiyun  * finished with preparations for the BA session. It can be called
5591*4882a593Smuzhiyun  * from any context.
5592*4882a593Smuzhiyun  */
5593*4882a593Smuzhiyun void ieee80211_start_tx_ba_cb_irqsafe(struct ieee80211_vif *vif, const u8 *ra,
5594*4882a593Smuzhiyun 				      u16 tid);
5595*4882a593Smuzhiyun 
5596*4882a593Smuzhiyun /**
5597*4882a593Smuzhiyun  * ieee80211_stop_tx_ba_session - Stop a Block Ack session.
5598*4882a593Smuzhiyun  * @sta: the station whose BA session to stop
5599*4882a593Smuzhiyun  * @tid: the TID to stop BA.
5600*4882a593Smuzhiyun  *
5601*4882a593Smuzhiyun  * Return: negative error if the TID is invalid, or no aggregation active
5602*4882a593Smuzhiyun  *
5603*4882a593Smuzhiyun  * Although mac80211/low level driver/user space application can estimate
5604*4882a593Smuzhiyun  * the need to stop aggregation on a certain RA/TID, the session level
5605*4882a593Smuzhiyun  * will be managed by the mac80211.
5606*4882a593Smuzhiyun  */
5607*4882a593Smuzhiyun int ieee80211_stop_tx_ba_session(struct ieee80211_sta *sta, u16 tid);
5608*4882a593Smuzhiyun 
5609*4882a593Smuzhiyun /**
5610*4882a593Smuzhiyun  * ieee80211_stop_tx_ba_cb_irqsafe - low level driver ready to stop aggregate.
5611*4882a593Smuzhiyun  * @vif: &struct ieee80211_vif pointer from the add_interface callback
5612*4882a593Smuzhiyun  * @ra: receiver address of the BA session recipient.
5613*4882a593Smuzhiyun  * @tid: the desired TID to BA on.
5614*4882a593Smuzhiyun  *
5615*4882a593Smuzhiyun  * This function must be called by low level driver once it has
5616*4882a593Smuzhiyun  * finished with preparations for the BA session tear down. It
5617*4882a593Smuzhiyun  * can be called from any context.
5618*4882a593Smuzhiyun  */
5619*4882a593Smuzhiyun void ieee80211_stop_tx_ba_cb_irqsafe(struct ieee80211_vif *vif, const u8 *ra,
5620*4882a593Smuzhiyun 				     u16 tid);
5621*4882a593Smuzhiyun 
5622*4882a593Smuzhiyun /**
5623*4882a593Smuzhiyun  * ieee80211_find_sta - find a station
5624*4882a593Smuzhiyun  *
5625*4882a593Smuzhiyun  * @vif: virtual interface to look for station on
5626*4882a593Smuzhiyun  * @addr: station's address
5627*4882a593Smuzhiyun  *
5628*4882a593Smuzhiyun  * Return: The station, if found. %NULL otherwise.
5629*4882a593Smuzhiyun  *
5630*4882a593Smuzhiyun  * Note: This function must be called under RCU lock and the
5631*4882a593Smuzhiyun  * resulting pointer is only valid under RCU lock as well.
5632*4882a593Smuzhiyun  */
5633*4882a593Smuzhiyun struct ieee80211_sta *ieee80211_find_sta(struct ieee80211_vif *vif,
5634*4882a593Smuzhiyun 					 const u8 *addr);
5635*4882a593Smuzhiyun 
5636*4882a593Smuzhiyun /**
5637*4882a593Smuzhiyun  * ieee80211_find_sta_by_ifaddr - find a station on hardware
5638*4882a593Smuzhiyun  *
5639*4882a593Smuzhiyun  * @hw: pointer as obtained from ieee80211_alloc_hw()
5640*4882a593Smuzhiyun  * @addr: remote station's address
5641*4882a593Smuzhiyun  * @localaddr: local address (vif->sdata->vif.addr). Use NULL for 'any'.
5642*4882a593Smuzhiyun  *
5643*4882a593Smuzhiyun  * Return: The station, if found. %NULL otherwise.
5644*4882a593Smuzhiyun  *
5645*4882a593Smuzhiyun  * Note: This function must be called under RCU lock and the
5646*4882a593Smuzhiyun  * resulting pointer is only valid under RCU lock as well.
5647*4882a593Smuzhiyun  *
5648*4882a593Smuzhiyun  * NOTE: You may pass NULL for localaddr, but then you will just get
5649*4882a593Smuzhiyun  *      the first STA that matches the remote address 'addr'.
5650*4882a593Smuzhiyun  *      We can have multiple STA associated with multiple
5651*4882a593Smuzhiyun  *      logical stations (e.g. consider a station connecting to another
5652*4882a593Smuzhiyun  *      BSSID on the same AP hardware without disconnecting first).
5653*4882a593Smuzhiyun  *      In this case, the result of this method with localaddr NULL
5654*4882a593Smuzhiyun  *      is not reliable.
5655*4882a593Smuzhiyun  *
5656*4882a593Smuzhiyun  * DO NOT USE THIS FUNCTION with localaddr NULL if at all possible.
5657*4882a593Smuzhiyun  */
5658*4882a593Smuzhiyun struct ieee80211_sta *ieee80211_find_sta_by_ifaddr(struct ieee80211_hw *hw,
5659*4882a593Smuzhiyun 					       const u8 *addr,
5660*4882a593Smuzhiyun 					       const u8 *localaddr);
5661*4882a593Smuzhiyun 
5662*4882a593Smuzhiyun /**
5663*4882a593Smuzhiyun  * ieee80211_sta_block_awake - block station from waking up
5664*4882a593Smuzhiyun  * @hw: the hardware
5665*4882a593Smuzhiyun  * @pubsta: the station
5666*4882a593Smuzhiyun  * @block: whether to block or unblock
5667*4882a593Smuzhiyun  *
5668*4882a593Smuzhiyun  * Some devices require that all frames that are on the queues
5669*4882a593Smuzhiyun  * for a specific station that went to sleep are flushed before
5670*4882a593Smuzhiyun  * a poll response or frames after the station woke up can be
5671*4882a593Smuzhiyun  * delivered to that it. Note that such frames must be rejected
5672*4882a593Smuzhiyun  * by the driver as filtered, with the appropriate status flag.
5673*4882a593Smuzhiyun  *
5674*4882a593Smuzhiyun  * This function allows implementing this mode in a race-free
5675*4882a593Smuzhiyun  * manner.
5676*4882a593Smuzhiyun  *
5677*4882a593Smuzhiyun  * To do this, a driver must keep track of the number of frames
5678*4882a593Smuzhiyun  * still enqueued for a specific station. If this number is not
5679*4882a593Smuzhiyun  * zero when the station goes to sleep, the driver must call
5680*4882a593Smuzhiyun  * this function to force mac80211 to consider the station to
5681*4882a593Smuzhiyun  * be asleep regardless of the station's actual state. Once the
5682*4882a593Smuzhiyun  * number of outstanding frames reaches zero, the driver must
5683*4882a593Smuzhiyun  * call this function again to unblock the station. That will
5684*4882a593Smuzhiyun  * cause mac80211 to be able to send ps-poll responses, and if
5685*4882a593Smuzhiyun  * the station queried in the meantime then frames will also
5686*4882a593Smuzhiyun  * be sent out as a result of this. Additionally, the driver
5687*4882a593Smuzhiyun  * will be notified that the station woke up some time after
5688*4882a593Smuzhiyun  * it is unblocked, regardless of whether the station actually
5689*4882a593Smuzhiyun  * woke up while blocked or not.
5690*4882a593Smuzhiyun  */
5691*4882a593Smuzhiyun void ieee80211_sta_block_awake(struct ieee80211_hw *hw,
5692*4882a593Smuzhiyun 			       struct ieee80211_sta *pubsta, bool block);
5693*4882a593Smuzhiyun 
5694*4882a593Smuzhiyun /**
5695*4882a593Smuzhiyun  * ieee80211_sta_eosp - notify mac80211 about end of SP
5696*4882a593Smuzhiyun  * @pubsta: the station
5697*4882a593Smuzhiyun  *
5698*4882a593Smuzhiyun  * When a device transmits frames in a way that it can't tell
5699*4882a593Smuzhiyun  * mac80211 in the TX status about the EOSP, it must clear the
5700*4882a593Smuzhiyun  * %IEEE80211_TX_STATUS_EOSP bit and call this function instead.
5701*4882a593Smuzhiyun  * This applies for PS-Poll as well as uAPSD.
5702*4882a593Smuzhiyun  *
5703*4882a593Smuzhiyun  * Note that just like with _tx_status() and _rx() drivers must
5704*4882a593Smuzhiyun  * not mix calls to irqsafe/non-irqsafe versions, this function
5705*4882a593Smuzhiyun  * must not be mixed with those either. Use the all irqsafe, or
5706*4882a593Smuzhiyun  * all non-irqsafe, don't mix!
5707*4882a593Smuzhiyun  *
5708*4882a593Smuzhiyun  * NB: the _irqsafe version of this function doesn't exist, no
5709*4882a593Smuzhiyun  *     driver needs it right now. Don't call this function if
5710*4882a593Smuzhiyun  *     you'd need the _irqsafe version, look at the git history
5711*4882a593Smuzhiyun  *     and restore the _irqsafe version!
5712*4882a593Smuzhiyun  */
5713*4882a593Smuzhiyun void ieee80211_sta_eosp(struct ieee80211_sta *pubsta);
5714*4882a593Smuzhiyun 
5715*4882a593Smuzhiyun /**
5716*4882a593Smuzhiyun  * ieee80211_send_eosp_nullfunc - ask mac80211 to send NDP with EOSP
5717*4882a593Smuzhiyun  * @pubsta: the station
5718*4882a593Smuzhiyun  * @tid: the tid of the NDP
5719*4882a593Smuzhiyun  *
5720*4882a593Smuzhiyun  * Sometimes the device understands that it needs to close
5721*4882a593Smuzhiyun  * the Service Period unexpectedly. This can happen when
5722*4882a593Smuzhiyun  * sending frames that are filling holes in the BA window.
5723*4882a593Smuzhiyun  * In this case, the device can ask mac80211 to send a
5724*4882a593Smuzhiyun  * Nullfunc frame with EOSP set. When that happens, the
5725*4882a593Smuzhiyun  * driver must have called ieee80211_sta_set_buffered() to
5726*4882a593Smuzhiyun  * let mac80211 know that there are no buffered frames any
5727*4882a593Smuzhiyun  * more, otherwise mac80211 will get the more_data bit wrong.
5728*4882a593Smuzhiyun  * The low level driver must have made sure that the frame
5729*4882a593Smuzhiyun  * will be sent despite the station being in power-save.
5730*4882a593Smuzhiyun  * Mac80211 won't call allow_buffered_frames().
5731*4882a593Smuzhiyun  * Note that calling this function, doesn't exempt the driver
5732*4882a593Smuzhiyun  * from closing the EOSP properly, it will still have to call
5733*4882a593Smuzhiyun  * ieee80211_sta_eosp when the NDP is sent.
5734*4882a593Smuzhiyun  */
5735*4882a593Smuzhiyun void ieee80211_send_eosp_nullfunc(struct ieee80211_sta *pubsta, int tid);
5736*4882a593Smuzhiyun 
5737*4882a593Smuzhiyun /**
5738*4882a593Smuzhiyun  * ieee80211_sta_register_airtime - register airtime usage for a sta/tid
5739*4882a593Smuzhiyun  *
5740*4882a593Smuzhiyun  * Register airtime usage for a given sta on a given tid. The driver must call
5741*4882a593Smuzhiyun  * this function to notify mac80211 that a station used a certain amount of
5742*4882a593Smuzhiyun  * airtime. This information will be used by the TXQ scheduler to schedule
5743*4882a593Smuzhiyun  * stations in a way that ensures airtime fairness.
5744*4882a593Smuzhiyun  *
5745*4882a593Smuzhiyun  * The reported airtime should as a minimum include all time that is spent
5746*4882a593Smuzhiyun  * transmitting to the remote station, including overhead and padding, but not
5747*4882a593Smuzhiyun  * including time spent waiting for a TXOP. If the time is not reported by the
5748*4882a593Smuzhiyun  * hardware it can in some cases be calculated from the rate and known frame
5749*4882a593Smuzhiyun  * composition. When possible, the time should include any failed transmission
5750*4882a593Smuzhiyun  * attempts.
5751*4882a593Smuzhiyun  *
5752*4882a593Smuzhiyun  * The driver can either call this function synchronously for every packet or
5753*4882a593Smuzhiyun  * aggregate, or asynchronously as airtime usage information becomes available.
5754*4882a593Smuzhiyun  * TX and RX airtime can be reported together, or separately by setting one of
5755*4882a593Smuzhiyun  * them to 0.
5756*4882a593Smuzhiyun  *
5757*4882a593Smuzhiyun  * @pubsta: the station
5758*4882a593Smuzhiyun  * @tid: the TID to register airtime for
5759*4882a593Smuzhiyun  * @tx_airtime: airtime used during TX (in usec)
5760*4882a593Smuzhiyun  * @rx_airtime: airtime used during RX (in usec)
5761*4882a593Smuzhiyun  */
5762*4882a593Smuzhiyun void ieee80211_sta_register_airtime(struct ieee80211_sta *pubsta, u8 tid,
5763*4882a593Smuzhiyun 				    u32 tx_airtime, u32 rx_airtime);
5764*4882a593Smuzhiyun 
5765*4882a593Smuzhiyun /**
5766*4882a593Smuzhiyun  * ieee80211_txq_airtime_check - check if a txq can send frame to device
5767*4882a593Smuzhiyun  *
5768*4882a593Smuzhiyun  * @hw: pointer obtained from ieee80211_alloc_hw()
5769*4882a593Smuzhiyun  * @txq: pointer obtained from station or virtual interface
5770*4882a593Smuzhiyun  *
5771*4882a593Smuzhiyun  * Return true if the AQL's airtime limit has not been reached and the txq can
5772*4882a593Smuzhiyun  * continue to send more packets to the device. Otherwise return false.
5773*4882a593Smuzhiyun  */
5774*4882a593Smuzhiyun bool
5775*4882a593Smuzhiyun ieee80211_txq_airtime_check(struct ieee80211_hw *hw, struct ieee80211_txq *txq);
5776*4882a593Smuzhiyun 
5777*4882a593Smuzhiyun /**
5778*4882a593Smuzhiyun  * ieee80211_iter_keys - iterate keys programmed into the device
5779*4882a593Smuzhiyun  * @hw: pointer obtained from ieee80211_alloc_hw()
5780*4882a593Smuzhiyun  * @vif: virtual interface to iterate, may be %NULL for all
5781*4882a593Smuzhiyun  * @iter: iterator function that will be called for each key
5782*4882a593Smuzhiyun  * @iter_data: custom data to pass to the iterator function
5783*4882a593Smuzhiyun  *
5784*4882a593Smuzhiyun  * This function can be used to iterate all the keys known to
5785*4882a593Smuzhiyun  * mac80211, even those that weren't previously programmed into
5786*4882a593Smuzhiyun  * the device. This is intended for use in WoWLAN if the device
5787*4882a593Smuzhiyun  * needs reprogramming of the keys during suspend. Note that due
5788*4882a593Smuzhiyun  * to locking reasons, it is also only safe to call this at few
5789*4882a593Smuzhiyun  * spots since it must hold the RTNL and be able to sleep.
5790*4882a593Smuzhiyun  *
5791*4882a593Smuzhiyun  * The order in which the keys are iterated matches the order
5792*4882a593Smuzhiyun  * in which they were originally installed and handed to the
5793*4882a593Smuzhiyun  * set_key callback.
5794*4882a593Smuzhiyun  */
5795*4882a593Smuzhiyun void ieee80211_iter_keys(struct ieee80211_hw *hw,
5796*4882a593Smuzhiyun 			 struct ieee80211_vif *vif,
5797*4882a593Smuzhiyun 			 void (*iter)(struct ieee80211_hw *hw,
5798*4882a593Smuzhiyun 				      struct ieee80211_vif *vif,
5799*4882a593Smuzhiyun 				      struct ieee80211_sta *sta,
5800*4882a593Smuzhiyun 				      struct ieee80211_key_conf *key,
5801*4882a593Smuzhiyun 				      void *data),
5802*4882a593Smuzhiyun 			 void *iter_data);
5803*4882a593Smuzhiyun 
5804*4882a593Smuzhiyun /**
5805*4882a593Smuzhiyun  * ieee80211_iter_keys_rcu - iterate keys programmed into the device
5806*4882a593Smuzhiyun  * @hw: pointer obtained from ieee80211_alloc_hw()
5807*4882a593Smuzhiyun  * @vif: virtual interface to iterate, may be %NULL for all
5808*4882a593Smuzhiyun  * @iter: iterator function that will be called for each key
5809*4882a593Smuzhiyun  * @iter_data: custom data to pass to the iterator function
5810*4882a593Smuzhiyun  *
5811*4882a593Smuzhiyun  * This function can be used to iterate all the keys known to
5812*4882a593Smuzhiyun  * mac80211, even those that weren't previously programmed into
5813*4882a593Smuzhiyun  * the device. Note that due to locking reasons, keys of station
5814*4882a593Smuzhiyun  * in removal process will be skipped.
5815*4882a593Smuzhiyun  *
5816*4882a593Smuzhiyun  * This function requires being called in an RCU critical section,
5817*4882a593Smuzhiyun  * and thus iter must be atomic.
5818*4882a593Smuzhiyun  */
5819*4882a593Smuzhiyun void ieee80211_iter_keys_rcu(struct ieee80211_hw *hw,
5820*4882a593Smuzhiyun 			     struct ieee80211_vif *vif,
5821*4882a593Smuzhiyun 			     void (*iter)(struct ieee80211_hw *hw,
5822*4882a593Smuzhiyun 					  struct ieee80211_vif *vif,
5823*4882a593Smuzhiyun 					  struct ieee80211_sta *sta,
5824*4882a593Smuzhiyun 					  struct ieee80211_key_conf *key,
5825*4882a593Smuzhiyun 					  void *data),
5826*4882a593Smuzhiyun 			     void *iter_data);
5827*4882a593Smuzhiyun 
5828*4882a593Smuzhiyun /**
5829*4882a593Smuzhiyun  * ieee80211_iter_chan_contexts_atomic - iterate channel contexts
5830*4882a593Smuzhiyun  * @hw: pointer obtained from ieee80211_alloc_hw().
5831*4882a593Smuzhiyun  * @iter: iterator function
5832*4882a593Smuzhiyun  * @iter_data: data passed to iterator function
5833*4882a593Smuzhiyun  *
5834*4882a593Smuzhiyun  * Iterate all active channel contexts. This function is atomic and
5835*4882a593Smuzhiyun  * doesn't acquire any locks internally that might be held in other
5836*4882a593Smuzhiyun  * places while calling into the driver.
5837*4882a593Smuzhiyun  *
5838*4882a593Smuzhiyun  * The iterator will not find a context that's being added (during
5839*4882a593Smuzhiyun  * the driver callback to add it) but will find it while it's being
5840*4882a593Smuzhiyun  * removed.
5841*4882a593Smuzhiyun  *
5842*4882a593Smuzhiyun  * Note that during hardware restart, all contexts that existed
5843*4882a593Smuzhiyun  * before the restart are considered already present so will be
5844*4882a593Smuzhiyun  * found while iterating, whether they've been re-added already
5845*4882a593Smuzhiyun  * or not.
5846*4882a593Smuzhiyun  */
5847*4882a593Smuzhiyun void ieee80211_iter_chan_contexts_atomic(
5848*4882a593Smuzhiyun 	struct ieee80211_hw *hw,
5849*4882a593Smuzhiyun 	void (*iter)(struct ieee80211_hw *hw,
5850*4882a593Smuzhiyun 		     struct ieee80211_chanctx_conf *chanctx_conf,
5851*4882a593Smuzhiyun 		     void *data),
5852*4882a593Smuzhiyun 	void *iter_data);
5853*4882a593Smuzhiyun 
5854*4882a593Smuzhiyun /**
5855*4882a593Smuzhiyun  * ieee80211_ap_probereq_get - retrieve a Probe Request template
5856*4882a593Smuzhiyun  * @hw: pointer obtained from ieee80211_alloc_hw().
5857*4882a593Smuzhiyun  * @vif: &struct ieee80211_vif pointer from the add_interface callback.
5858*4882a593Smuzhiyun  *
5859*4882a593Smuzhiyun  * Creates a Probe Request template which can, for example, be uploaded to
5860*4882a593Smuzhiyun  * hardware. The template is filled with bssid, ssid and supported rate
5861*4882a593Smuzhiyun  * information. This function must only be called from within the
5862*4882a593Smuzhiyun  * .bss_info_changed callback function and only in managed mode. The function
5863*4882a593Smuzhiyun  * is only useful when the interface is associated, otherwise it will return
5864*4882a593Smuzhiyun  * %NULL.
5865*4882a593Smuzhiyun  *
5866*4882a593Smuzhiyun  * Return: The Probe Request template. %NULL on error.
5867*4882a593Smuzhiyun  */
5868*4882a593Smuzhiyun struct sk_buff *ieee80211_ap_probereq_get(struct ieee80211_hw *hw,
5869*4882a593Smuzhiyun 					  struct ieee80211_vif *vif);
5870*4882a593Smuzhiyun 
5871*4882a593Smuzhiyun /**
5872*4882a593Smuzhiyun  * ieee80211_beacon_loss - inform hardware does not receive beacons
5873*4882a593Smuzhiyun  *
5874*4882a593Smuzhiyun  * @vif: &struct ieee80211_vif pointer from the add_interface callback.
5875*4882a593Smuzhiyun  *
5876*4882a593Smuzhiyun  * When beacon filtering is enabled with %IEEE80211_VIF_BEACON_FILTER and
5877*4882a593Smuzhiyun  * %IEEE80211_CONF_PS is set, the driver needs to inform whenever the
5878*4882a593Smuzhiyun  * hardware is not receiving beacons with this function.
5879*4882a593Smuzhiyun  */
5880*4882a593Smuzhiyun void ieee80211_beacon_loss(struct ieee80211_vif *vif);
5881*4882a593Smuzhiyun 
5882*4882a593Smuzhiyun /**
5883*4882a593Smuzhiyun  * ieee80211_connection_loss - inform hardware has lost connection to the AP
5884*4882a593Smuzhiyun  *
5885*4882a593Smuzhiyun  * @vif: &struct ieee80211_vif pointer from the add_interface callback.
5886*4882a593Smuzhiyun  *
5887*4882a593Smuzhiyun  * When beacon filtering is enabled with %IEEE80211_VIF_BEACON_FILTER, and
5888*4882a593Smuzhiyun  * %IEEE80211_CONF_PS and %IEEE80211_HW_CONNECTION_MONITOR are set, the driver
5889*4882a593Smuzhiyun  * needs to inform if the connection to the AP has been lost.
5890*4882a593Smuzhiyun  * The function may also be called if the connection needs to be terminated
5891*4882a593Smuzhiyun  * for some other reason, even if %IEEE80211_HW_CONNECTION_MONITOR isn't set.
5892*4882a593Smuzhiyun  *
5893*4882a593Smuzhiyun  * This function will cause immediate change to disassociated state,
5894*4882a593Smuzhiyun  * without connection recovery attempts.
5895*4882a593Smuzhiyun  */
5896*4882a593Smuzhiyun void ieee80211_connection_loss(struct ieee80211_vif *vif);
5897*4882a593Smuzhiyun 
5898*4882a593Smuzhiyun /**
5899*4882a593Smuzhiyun  * ieee80211_resume_disconnect - disconnect from AP after resume
5900*4882a593Smuzhiyun  *
5901*4882a593Smuzhiyun  * @vif: &struct ieee80211_vif pointer from the add_interface callback.
5902*4882a593Smuzhiyun  *
5903*4882a593Smuzhiyun  * Instructs mac80211 to disconnect from the AP after resume.
5904*4882a593Smuzhiyun  * Drivers can use this after WoWLAN if they know that the
5905*4882a593Smuzhiyun  * connection cannot be kept up, for example because keys were
5906*4882a593Smuzhiyun  * used while the device was asleep but the replay counters or
5907*4882a593Smuzhiyun  * similar cannot be retrieved from the device during resume.
5908*4882a593Smuzhiyun  *
5909*4882a593Smuzhiyun  * Note that due to implementation issues, if the driver uses
5910*4882a593Smuzhiyun  * the reconfiguration functionality during resume the interface
5911*4882a593Smuzhiyun  * will still be added as associated first during resume and then
5912*4882a593Smuzhiyun  * disconnect normally later.
5913*4882a593Smuzhiyun  *
5914*4882a593Smuzhiyun  * This function can only be called from the resume callback and
5915*4882a593Smuzhiyun  * the driver must not be holding any of its own locks while it
5916*4882a593Smuzhiyun  * calls this function, or at least not any locks it needs in the
5917*4882a593Smuzhiyun  * key configuration paths (if it supports HW crypto).
5918*4882a593Smuzhiyun  */
5919*4882a593Smuzhiyun void ieee80211_resume_disconnect(struct ieee80211_vif *vif);
5920*4882a593Smuzhiyun 
5921*4882a593Smuzhiyun /**
5922*4882a593Smuzhiyun  * ieee80211_cqm_rssi_notify - inform a configured connection quality monitoring
5923*4882a593Smuzhiyun  *	rssi threshold triggered
5924*4882a593Smuzhiyun  *
5925*4882a593Smuzhiyun  * @vif: &struct ieee80211_vif pointer from the add_interface callback.
5926*4882a593Smuzhiyun  * @rssi_event: the RSSI trigger event type
5927*4882a593Smuzhiyun  * @rssi_level: new RSSI level value or 0 if not available
5928*4882a593Smuzhiyun  * @gfp: context flags
5929*4882a593Smuzhiyun  *
5930*4882a593Smuzhiyun  * When the %IEEE80211_VIF_SUPPORTS_CQM_RSSI is set, and a connection quality
5931*4882a593Smuzhiyun  * monitoring is configured with an rssi threshold, the driver will inform
5932*4882a593Smuzhiyun  * whenever the rssi level reaches the threshold.
5933*4882a593Smuzhiyun  */
5934*4882a593Smuzhiyun void ieee80211_cqm_rssi_notify(struct ieee80211_vif *vif,
5935*4882a593Smuzhiyun 			       enum nl80211_cqm_rssi_threshold_event rssi_event,
5936*4882a593Smuzhiyun 			       s32 rssi_level,
5937*4882a593Smuzhiyun 			       gfp_t gfp);
5938*4882a593Smuzhiyun 
5939*4882a593Smuzhiyun /**
5940*4882a593Smuzhiyun  * ieee80211_cqm_beacon_loss_notify - inform CQM of beacon loss
5941*4882a593Smuzhiyun  *
5942*4882a593Smuzhiyun  * @vif: &struct ieee80211_vif pointer from the add_interface callback.
5943*4882a593Smuzhiyun  * @gfp: context flags
5944*4882a593Smuzhiyun  */
5945*4882a593Smuzhiyun void ieee80211_cqm_beacon_loss_notify(struct ieee80211_vif *vif, gfp_t gfp);
5946*4882a593Smuzhiyun 
5947*4882a593Smuzhiyun /**
5948*4882a593Smuzhiyun  * ieee80211_radar_detected - inform that a radar was detected
5949*4882a593Smuzhiyun  *
5950*4882a593Smuzhiyun  * @hw: pointer as obtained from ieee80211_alloc_hw()
5951*4882a593Smuzhiyun  */
5952*4882a593Smuzhiyun void ieee80211_radar_detected(struct ieee80211_hw *hw);
5953*4882a593Smuzhiyun 
5954*4882a593Smuzhiyun /**
5955*4882a593Smuzhiyun  * ieee80211_chswitch_done - Complete channel switch process
5956*4882a593Smuzhiyun  * @vif: &struct ieee80211_vif pointer from the add_interface callback.
5957*4882a593Smuzhiyun  * @success: make the channel switch successful or not
5958*4882a593Smuzhiyun  *
5959*4882a593Smuzhiyun  * Complete the channel switch post-process: set the new operational channel
5960*4882a593Smuzhiyun  * and wake up the suspended queues.
5961*4882a593Smuzhiyun  */
5962*4882a593Smuzhiyun void ieee80211_chswitch_done(struct ieee80211_vif *vif, bool success);
5963*4882a593Smuzhiyun 
5964*4882a593Smuzhiyun /**
5965*4882a593Smuzhiyun  * ieee80211_request_smps - request SM PS transition
5966*4882a593Smuzhiyun  * @vif: &struct ieee80211_vif pointer from the add_interface callback.
5967*4882a593Smuzhiyun  * @smps_mode: new SM PS mode
5968*4882a593Smuzhiyun  *
5969*4882a593Smuzhiyun  * This allows the driver to request an SM PS transition in managed
5970*4882a593Smuzhiyun  * mode. This is useful when the driver has more information than
5971*4882a593Smuzhiyun  * the stack about possible interference, for example by bluetooth.
5972*4882a593Smuzhiyun  */
5973*4882a593Smuzhiyun void ieee80211_request_smps(struct ieee80211_vif *vif,
5974*4882a593Smuzhiyun 			    enum ieee80211_smps_mode smps_mode);
5975*4882a593Smuzhiyun 
5976*4882a593Smuzhiyun /**
5977*4882a593Smuzhiyun  * ieee80211_ready_on_channel - notification of remain-on-channel start
5978*4882a593Smuzhiyun  * @hw: pointer as obtained from ieee80211_alloc_hw()
5979*4882a593Smuzhiyun  */
5980*4882a593Smuzhiyun void ieee80211_ready_on_channel(struct ieee80211_hw *hw);
5981*4882a593Smuzhiyun 
5982*4882a593Smuzhiyun /**
5983*4882a593Smuzhiyun  * ieee80211_remain_on_channel_expired - remain_on_channel duration expired
5984*4882a593Smuzhiyun  * @hw: pointer as obtained from ieee80211_alloc_hw()
5985*4882a593Smuzhiyun  */
5986*4882a593Smuzhiyun void ieee80211_remain_on_channel_expired(struct ieee80211_hw *hw);
5987*4882a593Smuzhiyun 
5988*4882a593Smuzhiyun /**
5989*4882a593Smuzhiyun  * ieee80211_stop_rx_ba_session - callback to stop existing BA sessions
5990*4882a593Smuzhiyun  *
5991*4882a593Smuzhiyun  * in order not to harm the system performance and user experience, the device
5992*4882a593Smuzhiyun  * may request not to allow any rx ba session and tear down existing rx ba
5993*4882a593Smuzhiyun  * sessions based on system constraints such as periodic BT activity that needs
5994*4882a593Smuzhiyun  * to limit wlan activity (eg.sco or a2dp)."
5995*4882a593Smuzhiyun  * in such cases, the intention is to limit the duration of the rx ppdu and
5996*4882a593Smuzhiyun  * therefore prevent the peer device to use a-mpdu aggregation.
5997*4882a593Smuzhiyun  *
5998*4882a593Smuzhiyun  * @vif: &struct ieee80211_vif pointer from the add_interface callback.
5999*4882a593Smuzhiyun  * @ba_rx_bitmap: Bit map of open rx ba per tid
6000*4882a593Smuzhiyun  * @addr: & to bssid mac address
6001*4882a593Smuzhiyun  */
6002*4882a593Smuzhiyun void ieee80211_stop_rx_ba_session(struct ieee80211_vif *vif, u16 ba_rx_bitmap,
6003*4882a593Smuzhiyun 				  const u8 *addr);
6004*4882a593Smuzhiyun 
6005*4882a593Smuzhiyun /**
6006*4882a593Smuzhiyun  * ieee80211_mark_rx_ba_filtered_frames - move RX BA window and mark filtered
6007*4882a593Smuzhiyun  * @pubsta: station struct
6008*4882a593Smuzhiyun  * @tid: the session's TID
6009*4882a593Smuzhiyun  * @ssn: starting sequence number of the bitmap, all frames before this are
6010*4882a593Smuzhiyun  *	assumed to be out of the window after the call
6011*4882a593Smuzhiyun  * @filtered: bitmap of filtered frames, BIT(0) is the @ssn entry etc.
6012*4882a593Smuzhiyun  * @received_mpdus: number of received mpdus in firmware
6013*4882a593Smuzhiyun  *
6014*4882a593Smuzhiyun  * This function moves the BA window and releases all frames before @ssn, and
6015*4882a593Smuzhiyun  * marks frames marked in the bitmap as having been filtered. Afterwards, it
6016*4882a593Smuzhiyun  * checks if any frames in the window starting from @ssn can now be released
6017*4882a593Smuzhiyun  * (in case they were only waiting for frames that were filtered.)
6018*4882a593Smuzhiyun  */
6019*4882a593Smuzhiyun void ieee80211_mark_rx_ba_filtered_frames(struct ieee80211_sta *pubsta, u8 tid,
6020*4882a593Smuzhiyun 					  u16 ssn, u64 filtered,
6021*4882a593Smuzhiyun 					  u16 received_mpdus);
6022*4882a593Smuzhiyun 
6023*4882a593Smuzhiyun /**
6024*4882a593Smuzhiyun  * ieee80211_send_bar - send a BlockAckReq frame
6025*4882a593Smuzhiyun  *
6026*4882a593Smuzhiyun  * can be used to flush pending frames from the peer's aggregation reorder
6027*4882a593Smuzhiyun  * buffer.
6028*4882a593Smuzhiyun  *
6029*4882a593Smuzhiyun  * @vif: &struct ieee80211_vif pointer from the add_interface callback.
6030*4882a593Smuzhiyun  * @ra: the peer's destination address
6031*4882a593Smuzhiyun  * @tid: the TID of the aggregation session
6032*4882a593Smuzhiyun  * @ssn: the new starting sequence number for the receiver
6033*4882a593Smuzhiyun  */
6034*4882a593Smuzhiyun void ieee80211_send_bar(struct ieee80211_vif *vif, u8 *ra, u16 tid, u16 ssn);
6035*4882a593Smuzhiyun 
6036*4882a593Smuzhiyun /**
6037*4882a593Smuzhiyun  * ieee80211_manage_rx_ba_offl - helper to queue an RX BA work
6038*4882a593Smuzhiyun  * @vif: &struct ieee80211_vif pointer from the add_interface callback
6039*4882a593Smuzhiyun  * @addr: station mac address
6040*4882a593Smuzhiyun  * @tid: the rx tid
6041*4882a593Smuzhiyun  */
6042*4882a593Smuzhiyun void ieee80211_manage_rx_ba_offl(struct ieee80211_vif *vif, const u8 *addr,
6043*4882a593Smuzhiyun 				 unsigned int tid);
6044*4882a593Smuzhiyun 
6045*4882a593Smuzhiyun /**
6046*4882a593Smuzhiyun  * ieee80211_start_rx_ba_session_offl - start a Rx BA session
6047*4882a593Smuzhiyun  *
6048*4882a593Smuzhiyun  * Some device drivers may offload part of the Rx aggregation flow including
6049*4882a593Smuzhiyun  * AddBa/DelBa negotiation but may otherwise be incapable of full Rx
6050*4882a593Smuzhiyun  * reordering.
6051*4882a593Smuzhiyun  *
6052*4882a593Smuzhiyun  * Create structures responsible for reordering so device drivers may call here
6053*4882a593Smuzhiyun  * when they complete AddBa negotiation.
6054*4882a593Smuzhiyun  *
6055*4882a593Smuzhiyun  * @vif: &struct ieee80211_vif pointer from the add_interface callback
6056*4882a593Smuzhiyun  * @addr: station mac address
6057*4882a593Smuzhiyun  * @tid: the rx tid
6058*4882a593Smuzhiyun  */
ieee80211_start_rx_ba_session_offl(struct ieee80211_vif * vif,const u8 * addr,u16 tid)6059*4882a593Smuzhiyun static inline void ieee80211_start_rx_ba_session_offl(struct ieee80211_vif *vif,
6060*4882a593Smuzhiyun 						      const u8 *addr, u16 tid)
6061*4882a593Smuzhiyun {
6062*4882a593Smuzhiyun 	if (WARN_ON(tid >= IEEE80211_NUM_TIDS))
6063*4882a593Smuzhiyun 		return;
6064*4882a593Smuzhiyun 	ieee80211_manage_rx_ba_offl(vif, addr, tid);
6065*4882a593Smuzhiyun }
6066*4882a593Smuzhiyun 
6067*4882a593Smuzhiyun /**
6068*4882a593Smuzhiyun  * ieee80211_stop_rx_ba_session_offl - stop a Rx BA session
6069*4882a593Smuzhiyun  *
6070*4882a593Smuzhiyun  * Some device drivers may offload part of the Rx aggregation flow including
6071*4882a593Smuzhiyun  * AddBa/DelBa negotiation but may otherwise be incapable of full Rx
6072*4882a593Smuzhiyun  * reordering.
6073*4882a593Smuzhiyun  *
6074*4882a593Smuzhiyun  * Destroy structures responsible for reordering so device drivers may call here
6075*4882a593Smuzhiyun  * when they complete DelBa negotiation.
6076*4882a593Smuzhiyun  *
6077*4882a593Smuzhiyun  * @vif: &struct ieee80211_vif pointer from the add_interface callback
6078*4882a593Smuzhiyun  * @addr: station mac address
6079*4882a593Smuzhiyun  * @tid: the rx tid
6080*4882a593Smuzhiyun  */
ieee80211_stop_rx_ba_session_offl(struct ieee80211_vif * vif,const u8 * addr,u16 tid)6081*4882a593Smuzhiyun static inline void ieee80211_stop_rx_ba_session_offl(struct ieee80211_vif *vif,
6082*4882a593Smuzhiyun 						     const u8 *addr, u16 tid)
6083*4882a593Smuzhiyun {
6084*4882a593Smuzhiyun 	if (WARN_ON(tid >= IEEE80211_NUM_TIDS))
6085*4882a593Smuzhiyun 		return;
6086*4882a593Smuzhiyun 	ieee80211_manage_rx_ba_offl(vif, addr, tid + IEEE80211_NUM_TIDS);
6087*4882a593Smuzhiyun }
6088*4882a593Smuzhiyun 
6089*4882a593Smuzhiyun /**
6090*4882a593Smuzhiyun  * ieee80211_rx_ba_timer_expired - stop a Rx BA session due to timeout
6091*4882a593Smuzhiyun  *
6092*4882a593Smuzhiyun  * Some device drivers do not offload AddBa/DelBa negotiation, but handle rx
6093*4882a593Smuzhiyun  * buffer reording internally, and therefore also handle the session timer.
6094*4882a593Smuzhiyun  *
6095*4882a593Smuzhiyun  * Trigger the timeout flow, which sends a DelBa.
6096*4882a593Smuzhiyun  *
6097*4882a593Smuzhiyun  * @vif: &struct ieee80211_vif pointer from the add_interface callback
6098*4882a593Smuzhiyun  * @addr: station mac address
6099*4882a593Smuzhiyun  * @tid: the rx tid
6100*4882a593Smuzhiyun  */
6101*4882a593Smuzhiyun void ieee80211_rx_ba_timer_expired(struct ieee80211_vif *vif,
6102*4882a593Smuzhiyun 				   const u8 *addr, unsigned int tid);
6103*4882a593Smuzhiyun 
6104*4882a593Smuzhiyun /* Rate control API */
6105*4882a593Smuzhiyun 
6106*4882a593Smuzhiyun /**
6107*4882a593Smuzhiyun  * struct ieee80211_tx_rate_control - rate control information for/from RC algo
6108*4882a593Smuzhiyun  *
6109*4882a593Smuzhiyun  * @hw: The hardware the algorithm is invoked for.
6110*4882a593Smuzhiyun  * @sband: The band this frame is being transmitted on.
6111*4882a593Smuzhiyun  * @bss_conf: the current BSS configuration
6112*4882a593Smuzhiyun  * @skb: the skb that will be transmitted, the control information in it needs
6113*4882a593Smuzhiyun  *	to be filled in
6114*4882a593Smuzhiyun  * @reported_rate: The rate control algorithm can fill this in to indicate
6115*4882a593Smuzhiyun  *	which rate should be reported to userspace as the current rate and
6116*4882a593Smuzhiyun  *	used for rate calculations in the mesh network.
6117*4882a593Smuzhiyun  * @rts: whether RTS will be used for this frame because it is longer than the
6118*4882a593Smuzhiyun  *	RTS threshold
6119*4882a593Smuzhiyun  * @short_preamble: whether mac80211 will request short-preamble transmission
6120*4882a593Smuzhiyun  *	if the selected rate supports it
6121*4882a593Smuzhiyun  * @rate_idx_mask: user-requested (legacy) rate mask
6122*4882a593Smuzhiyun  * @rate_idx_mcs_mask: user-requested MCS rate mask (NULL if not in use)
6123*4882a593Smuzhiyun  * @bss: whether this frame is sent out in AP or IBSS mode
6124*4882a593Smuzhiyun  */
6125*4882a593Smuzhiyun struct ieee80211_tx_rate_control {
6126*4882a593Smuzhiyun 	struct ieee80211_hw *hw;
6127*4882a593Smuzhiyun 	struct ieee80211_supported_band *sband;
6128*4882a593Smuzhiyun 	struct ieee80211_bss_conf *bss_conf;
6129*4882a593Smuzhiyun 	struct sk_buff *skb;
6130*4882a593Smuzhiyun 	struct ieee80211_tx_rate reported_rate;
6131*4882a593Smuzhiyun 	bool rts, short_preamble;
6132*4882a593Smuzhiyun 	u32 rate_idx_mask;
6133*4882a593Smuzhiyun 	u8 *rate_idx_mcs_mask;
6134*4882a593Smuzhiyun 	bool bss;
6135*4882a593Smuzhiyun };
6136*4882a593Smuzhiyun 
6137*4882a593Smuzhiyun /**
6138*4882a593Smuzhiyun  * enum rate_control_capabilities - rate control capabilities
6139*4882a593Smuzhiyun  */
6140*4882a593Smuzhiyun enum rate_control_capabilities {
6141*4882a593Smuzhiyun 	/**
6142*4882a593Smuzhiyun 	 * @RATE_CTRL_CAPA_VHT_EXT_NSS_BW:
6143*4882a593Smuzhiyun 	 * Support for extended NSS BW support (dot11VHTExtendedNSSCapable)
6144*4882a593Smuzhiyun 	 * Note that this is only looked at if the minimum number of chains
6145*4882a593Smuzhiyun 	 * that the AP uses is < the number of TX chains the hardware has,
6146*4882a593Smuzhiyun 	 * otherwise the NSS difference doesn't bother us.
6147*4882a593Smuzhiyun 	 */
6148*4882a593Smuzhiyun 	RATE_CTRL_CAPA_VHT_EXT_NSS_BW = BIT(0),
6149*4882a593Smuzhiyun };
6150*4882a593Smuzhiyun 
6151*4882a593Smuzhiyun struct rate_control_ops {
6152*4882a593Smuzhiyun 	unsigned long capa;
6153*4882a593Smuzhiyun 	const char *name;
6154*4882a593Smuzhiyun 	void *(*alloc)(struct ieee80211_hw *hw);
6155*4882a593Smuzhiyun 	void (*add_debugfs)(struct ieee80211_hw *hw, void *priv,
6156*4882a593Smuzhiyun 			    struct dentry *debugfsdir);
6157*4882a593Smuzhiyun 	void (*free)(void *priv);
6158*4882a593Smuzhiyun 
6159*4882a593Smuzhiyun 	void *(*alloc_sta)(void *priv, struct ieee80211_sta *sta, gfp_t gfp);
6160*4882a593Smuzhiyun 	void (*rate_init)(void *priv, struct ieee80211_supported_band *sband,
6161*4882a593Smuzhiyun 			  struct cfg80211_chan_def *chandef,
6162*4882a593Smuzhiyun 			  struct ieee80211_sta *sta, void *priv_sta);
6163*4882a593Smuzhiyun 	void (*rate_update)(void *priv, struct ieee80211_supported_band *sband,
6164*4882a593Smuzhiyun 			    struct cfg80211_chan_def *chandef,
6165*4882a593Smuzhiyun 			    struct ieee80211_sta *sta, void *priv_sta,
6166*4882a593Smuzhiyun 			    u32 changed);
6167*4882a593Smuzhiyun 	void (*free_sta)(void *priv, struct ieee80211_sta *sta,
6168*4882a593Smuzhiyun 			 void *priv_sta);
6169*4882a593Smuzhiyun 
6170*4882a593Smuzhiyun 	void (*tx_status_ext)(void *priv,
6171*4882a593Smuzhiyun 			      struct ieee80211_supported_band *sband,
6172*4882a593Smuzhiyun 			      void *priv_sta, struct ieee80211_tx_status *st);
6173*4882a593Smuzhiyun 	void (*tx_status)(void *priv, struct ieee80211_supported_band *sband,
6174*4882a593Smuzhiyun 			  struct ieee80211_sta *sta, void *priv_sta,
6175*4882a593Smuzhiyun 			  struct sk_buff *skb);
6176*4882a593Smuzhiyun 	void (*get_rate)(void *priv, struct ieee80211_sta *sta, void *priv_sta,
6177*4882a593Smuzhiyun 			 struct ieee80211_tx_rate_control *txrc);
6178*4882a593Smuzhiyun 
6179*4882a593Smuzhiyun 	void (*add_sta_debugfs)(void *priv, void *priv_sta,
6180*4882a593Smuzhiyun 				struct dentry *dir);
6181*4882a593Smuzhiyun 
6182*4882a593Smuzhiyun 	u32 (*get_expected_throughput)(void *priv_sta);
6183*4882a593Smuzhiyun 
6184*4882a593Smuzhiyun 	ANDROID_KABI_RESERVE(1);
6185*4882a593Smuzhiyun 	ANDROID_KABI_RESERVE(2);
6186*4882a593Smuzhiyun 	ANDROID_KABI_RESERVE(3);
6187*4882a593Smuzhiyun 	ANDROID_KABI_RESERVE(4);
6188*4882a593Smuzhiyun };
6189*4882a593Smuzhiyun 
rate_supported(struct ieee80211_sta * sta,enum nl80211_band band,int index)6190*4882a593Smuzhiyun static inline int rate_supported(struct ieee80211_sta *sta,
6191*4882a593Smuzhiyun 				 enum nl80211_band band,
6192*4882a593Smuzhiyun 				 int index)
6193*4882a593Smuzhiyun {
6194*4882a593Smuzhiyun 	return (sta == NULL || sta->supp_rates[band] & BIT(index));
6195*4882a593Smuzhiyun }
6196*4882a593Smuzhiyun 
6197*4882a593Smuzhiyun static inline s8
rate_lowest_index(struct ieee80211_supported_band * sband,struct ieee80211_sta * sta)6198*4882a593Smuzhiyun rate_lowest_index(struct ieee80211_supported_band *sband,
6199*4882a593Smuzhiyun 		  struct ieee80211_sta *sta)
6200*4882a593Smuzhiyun {
6201*4882a593Smuzhiyun 	int i;
6202*4882a593Smuzhiyun 
6203*4882a593Smuzhiyun 	for (i = 0; i < sband->n_bitrates; i++)
6204*4882a593Smuzhiyun 		if (rate_supported(sta, sband->band, i))
6205*4882a593Smuzhiyun 			return i;
6206*4882a593Smuzhiyun 
6207*4882a593Smuzhiyun 	/* warn when we cannot find a rate. */
6208*4882a593Smuzhiyun 	WARN_ON_ONCE(1);
6209*4882a593Smuzhiyun 
6210*4882a593Smuzhiyun 	/* and return 0 (the lowest index) */
6211*4882a593Smuzhiyun 	return 0;
6212*4882a593Smuzhiyun }
6213*4882a593Smuzhiyun 
6214*4882a593Smuzhiyun static inline
rate_usable_index_exists(struct ieee80211_supported_band * sband,struct ieee80211_sta * sta)6215*4882a593Smuzhiyun bool rate_usable_index_exists(struct ieee80211_supported_band *sband,
6216*4882a593Smuzhiyun 			      struct ieee80211_sta *sta)
6217*4882a593Smuzhiyun {
6218*4882a593Smuzhiyun 	unsigned int i;
6219*4882a593Smuzhiyun 
6220*4882a593Smuzhiyun 	for (i = 0; i < sband->n_bitrates; i++)
6221*4882a593Smuzhiyun 		if (rate_supported(sta, sband->band, i))
6222*4882a593Smuzhiyun 			return true;
6223*4882a593Smuzhiyun 	return false;
6224*4882a593Smuzhiyun }
6225*4882a593Smuzhiyun 
6226*4882a593Smuzhiyun /**
6227*4882a593Smuzhiyun  * rate_control_set_rates - pass the sta rate selection to mac80211/driver
6228*4882a593Smuzhiyun  *
6229*4882a593Smuzhiyun  * When not doing a rate control probe to test rates, rate control should pass
6230*4882a593Smuzhiyun  * its rate selection to mac80211. If the driver supports receiving a station
6231*4882a593Smuzhiyun  * rate table, it will use it to ensure that frames are always sent based on
6232*4882a593Smuzhiyun  * the most recent rate control module decision.
6233*4882a593Smuzhiyun  *
6234*4882a593Smuzhiyun  * @hw: pointer as obtained from ieee80211_alloc_hw()
6235*4882a593Smuzhiyun  * @pubsta: &struct ieee80211_sta pointer to the target destination.
6236*4882a593Smuzhiyun  * @rates: new tx rate set to be used for this station.
6237*4882a593Smuzhiyun  */
6238*4882a593Smuzhiyun int rate_control_set_rates(struct ieee80211_hw *hw,
6239*4882a593Smuzhiyun 			   struct ieee80211_sta *pubsta,
6240*4882a593Smuzhiyun 			   struct ieee80211_sta_rates *rates);
6241*4882a593Smuzhiyun 
6242*4882a593Smuzhiyun int ieee80211_rate_control_register(const struct rate_control_ops *ops);
6243*4882a593Smuzhiyun void ieee80211_rate_control_unregister(const struct rate_control_ops *ops);
6244*4882a593Smuzhiyun 
6245*4882a593Smuzhiyun static inline bool
conf_is_ht20(struct ieee80211_conf * conf)6246*4882a593Smuzhiyun conf_is_ht20(struct ieee80211_conf *conf)
6247*4882a593Smuzhiyun {
6248*4882a593Smuzhiyun 	return conf->chandef.width == NL80211_CHAN_WIDTH_20;
6249*4882a593Smuzhiyun }
6250*4882a593Smuzhiyun 
6251*4882a593Smuzhiyun static inline bool
conf_is_ht40_minus(struct ieee80211_conf * conf)6252*4882a593Smuzhiyun conf_is_ht40_minus(struct ieee80211_conf *conf)
6253*4882a593Smuzhiyun {
6254*4882a593Smuzhiyun 	return conf->chandef.width == NL80211_CHAN_WIDTH_40 &&
6255*4882a593Smuzhiyun 	       conf->chandef.center_freq1 < conf->chandef.chan->center_freq;
6256*4882a593Smuzhiyun }
6257*4882a593Smuzhiyun 
6258*4882a593Smuzhiyun static inline bool
conf_is_ht40_plus(struct ieee80211_conf * conf)6259*4882a593Smuzhiyun conf_is_ht40_plus(struct ieee80211_conf *conf)
6260*4882a593Smuzhiyun {
6261*4882a593Smuzhiyun 	return conf->chandef.width == NL80211_CHAN_WIDTH_40 &&
6262*4882a593Smuzhiyun 	       conf->chandef.center_freq1 > conf->chandef.chan->center_freq;
6263*4882a593Smuzhiyun }
6264*4882a593Smuzhiyun 
6265*4882a593Smuzhiyun static inline bool
conf_is_ht40(struct ieee80211_conf * conf)6266*4882a593Smuzhiyun conf_is_ht40(struct ieee80211_conf *conf)
6267*4882a593Smuzhiyun {
6268*4882a593Smuzhiyun 	return conf->chandef.width == NL80211_CHAN_WIDTH_40;
6269*4882a593Smuzhiyun }
6270*4882a593Smuzhiyun 
6271*4882a593Smuzhiyun static inline bool
conf_is_ht(struct ieee80211_conf * conf)6272*4882a593Smuzhiyun conf_is_ht(struct ieee80211_conf *conf)
6273*4882a593Smuzhiyun {
6274*4882a593Smuzhiyun 	return (conf->chandef.width != NL80211_CHAN_WIDTH_5) &&
6275*4882a593Smuzhiyun 		(conf->chandef.width != NL80211_CHAN_WIDTH_10) &&
6276*4882a593Smuzhiyun 		(conf->chandef.width != NL80211_CHAN_WIDTH_20_NOHT);
6277*4882a593Smuzhiyun }
6278*4882a593Smuzhiyun 
6279*4882a593Smuzhiyun static inline enum nl80211_iftype
ieee80211_iftype_p2p(enum nl80211_iftype type,bool p2p)6280*4882a593Smuzhiyun ieee80211_iftype_p2p(enum nl80211_iftype type, bool p2p)
6281*4882a593Smuzhiyun {
6282*4882a593Smuzhiyun 	if (p2p) {
6283*4882a593Smuzhiyun 		switch (type) {
6284*4882a593Smuzhiyun 		case NL80211_IFTYPE_STATION:
6285*4882a593Smuzhiyun 			return NL80211_IFTYPE_P2P_CLIENT;
6286*4882a593Smuzhiyun 		case NL80211_IFTYPE_AP:
6287*4882a593Smuzhiyun 			return NL80211_IFTYPE_P2P_GO;
6288*4882a593Smuzhiyun 		default:
6289*4882a593Smuzhiyun 			break;
6290*4882a593Smuzhiyun 		}
6291*4882a593Smuzhiyun 	}
6292*4882a593Smuzhiyun 	return type;
6293*4882a593Smuzhiyun }
6294*4882a593Smuzhiyun 
6295*4882a593Smuzhiyun static inline enum nl80211_iftype
ieee80211_vif_type_p2p(struct ieee80211_vif * vif)6296*4882a593Smuzhiyun ieee80211_vif_type_p2p(struct ieee80211_vif *vif)
6297*4882a593Smuzhiyun {
6298*4882a593Smuzhiyun 	return ieee80211_iftype_p2p(vif->type, vif->p2p);
6299*4882a593Smuzhiyun }
6300*4882a593Smuzhiyun 
6301*4882a593Smuzhiyun /**
6302*4882a593Smuzhiyun  * ieee80211_update_mu_groups - set the VHT MU-MIMO groud data
6303*4882a593Smuzhiyun  *
6304*4882a593Smuzhiyun  * @vif: the specified virtual interface
6305*4882a593Smuzhiyun  * @membership: 64 bits array - a bit is set if station is member of the group
6306*4882a593Smuzhiyun  * @position: 2 bits per group id indicating the position in the group
6307*4882a593Smuzhiyun  *
6308*4882a593Smuzhiyun  * Note: This function assumes that the given vif is valid and the position and
6309*4882a593Smuzhiyun  * membership data is of the correct size and are in the same byte order as the
6310*4882a593Smuzhiyun  * matching GroupId management frame.
6311*4882a593Smuzhiyun  * Calls to this function need to be serialized with RX path.
6312*4882a593Smuzhiyun  */
6313*4882a593Smuzhiyun void ieee80211_update_mu_groups(struct ieee80211_vif *vif,
6314*4882a593Smuzhiyun 				const u8 *membership, const u8 *position);
6315*4882a593Smuzhiyun 
6316*4882a593Smuzhiyun void ieee80211_enable_rssi_reports(struct ieee80211_vif *vif,
6317*4882a593Smuzhiyun 				   int rssi_min_thold,
6318*4882a593Smuzhiyun 				   int rssi_max_thold);
6319*4882a593Smuzhiyun 
6320*4882a593Smuzhiyun void ieee80211_disable_rssi_reports(struct ieee80211_vif *vif);
6321*4882a593Smuzhiyun 
6322*4882a593Smuzhiyun /**
6323*4882a593Smuzhiyun  * ieee80211_ave_rssi - report the average RSSI for the specified interface
6324*4882a593Smuzhiyun  *
6325*4882a593Smuzhiyun  * @vif: the specified virtual interface
6326*4882a593Smuzhiyun  *
6327*4882a593Smuzhiyun  * Note: This function assumes that the given vif is valid.
6328*4882a593Smuzhiyun  *
6329*4882a593Smuzhiyun  * Return: The average RSSI value for the requested interface, or 0 if not
6330*4882a593Smuzhiyun  * applicable.
6331*4882a593Smuzhiyun  */
6332*4882a593Smuzhiyun int ieee80211_ave_rssi(struct ieee80211_vif *vif);
6333*4882a593Smuzhiyun 
6334*4882a593Smuzhiyun /**
6335*4882a593Smuzhiyun  * ieee80211_report_wowlan_wakeup - report WoWLAN wakeup
6336*4882a593Smuzhiyun  * @vif: virtual interface
6337*4882a593Smuzhiyun  * @wakeup: wakeup reason(s)
6338*4882a593Smuzhiyun  * @gfp: allocation flags
6339*4882a593Smuzhiyun  *
6340*4882a593Smuzhiyun  * See cfg80211_report_wowlan_wakeup().
6341*4882a593Smuzhiyun  */
6342*4882a593Smuzhiyun void ieee80211_report_wowlan_wakeup(struct ieee80211_vif *vif,
6343*4882a593Smuzhiyun 				    struct cfg80211_wowlan_wakeup *wakeup,
6344*4882a593Smuzhiyun 				    gfp_t gfp);
6345*4882a593Smuzhiyun 
6346*4882a593Smuzhiyun /**
6347*4882a593Smuzhiyun  * ieee80211_tx_prepare_skb - prepare an 802.11 skb for transmission
6348*4882a593Smuzhiyun  * @hw: pointer as obtained from ieee80211_alloc_hw()
6349*4882a593Smuzhiyun  * @vif: virtual interface
6350*4882a593Smuzhiyun  * @skb: frame to be sent from within the driver
6351*4882a593Smuzhiyun  * @band: the band to transmit on
6352*4882a593Smuzhiyun  * @sta: optional pointer to get the station to send the frame to
6353*4882a593Smuzhiyun  *
6354*4882a593Smuzhiyun  * Note: must be called under RCU lock
6355*4882a593Smuzhiyun  */
6356*4882a593Smuzhiyun bool ieee80211_tx_prepare_skb(struct ieee80211_hw *hw,
6357*4882a593Smuzhiyun 			      struct ieee80211_vif *vif, struct sk_buff *skb,
6358*4882a593Smuzhiyun 			      int band, struct ieee80211_sta **sta);
6359*4882a593Smuzhiyun 
6360*4882a593Smuzhiyun /**
6361*4882a593Smuzhiyun  * ieee80211_parse_tx_radiotap - Sanity-check and parse the radiotap header
6362*4882a593Smuzhiyun  *				 of injected frames.
6363*4882a593Smuzhiyun  *
6364*4882a593Smuzhiyun  * To accurately parse and take into account rate and retransmission fields,
6365*4882a593Smuzhiyun  * you must initialize the chandef field in the ieee80211_tx_info structure
6366*4882a593Smuzhiyun  * of the skb before calling this function.
6367*4882a593Smuzhiyun  *
6368*4882a593Smuzhiyun  * @skb: packet injected by userspace
6369*4882a593Smuzhiyun  * @dev: the &struct device of this 802.11 device
6370*4882a593Smuzhiyun  */
6371*4882a593Smuzhiyun bool ieee80211_parse_tx_radiotap(struct sk_buff *skb,
6372*4882a593Smuzhiyun 				 struct net_device *dev);
6373*4882a593Smuzhiyun 
6374*4882a593Smuzhiyun /**
6375*4882a593Smuzhiyun  * struct ieee80211_noa_data - holds temporary data for tracking P2P NoA state
6376*4882a593Smuzhiyun  *
6377*4882a593Smuzhiyun  * @next_tsf: TSF timestamp of the next absent state change
6378*4882a593Smuzhiyun  * @has_next_tsf: next absent state change event pending
6379*4882a593Smuzhiyun  *
6380*4882a593Smuzhiyun  * @absent: descriptor bitmask, set if GO is currently absent
6381*4882a593Smuzhiyun  *
6382*4882a593Smuzhiyun  * private:
6383*4882a593Smuzhiyun  *
6384*4882a593Smuzhiyun  * @count: count fields from the NoA descriptors
6385*4882a593Smuzhiyun  * @desc: adjusted data from the NoA
6386*4882a593Smuzhiyun  */
6387*4882a593Smuzhiyun struct ieee80211_noa_data {
6388*4882a593Smuzhiyun 	u32 next_tsf;
6389*4882a593Smuzhiyun 	bool has_next_tsf;
6390*4882a593Smuzhiyun 
6391*4882a593Smuzhiyun 	u8 absent;
6392*4882a593Smuzhiyun 
6393*4882a593Smuzhiyun 	u8 count[IEEE80211_P2P_NOA_DESC_MAX];
6394*4882a593Smuzhiyun 	struct {
6395*4882a593Smuzhiyun 		u32 start;
6396*4882a593Smuzhiyun 		u32 duration;
6397*4882a593Smuzhiyun 		u32 interval;
6398*4882a593Smuzhiyun 	} desc[IEEE80211_P2P_NOA_DESC_MAX];
6399*4882a593Smuzhiyun };
6400*4882a593Smuzhiyun 
6401*4882a593Smuzhiyun /**
6402*4882a593Smuzhiyun  * ieee80211_parse_p2p_noa - initialize NoA tracking data from P2P IE
6403*4882a593Smuzhiyun  *
6404*4882a593Smuzhiyun  * @attr: P2P NoA IE
6405*4882a593Smuzhiyun  * @data: NoA tracking data
6406*4882a593Smuzhiyun  * @tsf: current TSF timestamp
6407*4882a593Smuzhiyun  *
6408*4882a593Smuzhiyun  * Return: number of successfully parsed descriptors
6409*4882a593Smuzhiyun  */
6410*4882a593Smuzhiyun int ieee80211_parse_p2p_noa(const struct ieee80211_p2p_noa_attr *attr,
6411*4882a593Smuzhiyun 			    struct ieee80211_noa_data *data, u32 tsf);
6412*4882a593Smuzhiyun 
6413*4882a593Smuzhiyun /**
6414*4882a593Smuzhiyun  * ieee80211_update_p2p_noa - get next pending P2P GO absent state change
6415*4882a593Smuzhiyun  *
6416*4882a593Smuzhiyun  * @data: NoA tracking data
6417*4882a593Smuzhiyun  * @tsf: current TSF timestamp
6418*4882a593Smuzhiyun  */
6419*4882a593Smuzhiyun void ieee80211_update_p2p_noa(struct ieee80211_noa_data *data, u32 tsf);
6420*4882a593Smuzhiyun 
6421*4882a593Smuzhiyun /**
6422*4882a593Smuzhiyun  * ieee80211_tdls_oper_request - request userspace to perform a TDLS operation
6423*4882a593Smuzhiyun  * @vif: virtual interface
6424*4882a593Smuzhiyun  * @peer: the peer's destination address
6425*4882a593Smuzhiyun  * @oper: the requested TDLS operation
6426*4882a593Smuzhiyun  * @reason_code: reason code for the operation, valid for TDLS teardown
6427*4882a593Smuzhiyun  * @gfp: allocation flags
6428*4882a593Smuzhiyun  *
6429*4882a593Smuzhiyun  * See cfg80211_tdls_oper_request().
6430*4882a593Smuzhiyun  */
6431*4882a593Smuzhiyun void ieee80211_tdls_oper_request(struct ieee80211_vif *vif, const u8 *peer,
6432*4882a593Smuzhiyun 				 enum nl80211_tdls_operation oper,
6433*4882a593Smuzhiyun 				 u16 reason_code, gfp_t gfp);
6434*4882a593Smuzhiyun 
6435*4882a593Smuzhiyun /**
6436*4882a593Smuzhiyun  * ieee80211_reserve_tid - request to reserve a specific TID
6437*4882a593Smuzhiyun  *
6438*4882a593Smuzhiyun  * There is sometimes a need (such as in TDLS) for blocking the driver from
6439*4882a593Smuzhiyun  * using a specific TID so that the FW can use it for certain operations such
6440*4882a593Smuzhiyun  * as sending PTI requests. To make sure that the driver doesn't use that TID,
6441*4882a593Smuzhiyun  * this function must be called as it flushes out packets on this TID and marks
6442*4882a593Smuzhiyun  * it as blocked, so that any transmit for the station on this TID will be
6443*4882a593Smuzhiyun  * redirected to the alternative TID in the same AC.
6444*4882a593Smuzhiyun  *
6445*4882a593Smuzhiyun  * Note that this function blocks and may call back into the driver, so it
6446*4882a593Smuzhiyun  * should be called without driver locks held. Also note this function should
6447*4882a593Smuzhiyun  * only be called from the driver's @sta_state callback.
6448*4882a593Smuzhiyun  *
6449*4882a593Smuzhiyun  * @sta: the station to reserve the TID for
6450*4882a593Smuzhiyun  * @tid: the TID to reserve
6451*4882a593Smuzhiyun  *
6452*4882a593Smuzhiyun  * Returns: 0 on success, else on failure
6453*4882a593Smuzhiyun  */
6454*4882a593Smuzhiyun int ieee80211_reserve_tid(struct ieee80211_sta *sta, u8 tid);
6455*4882a593Smuzhiyun 
6456*4882a593Smuzhiyun /**
6457*4882a593Smuzhiyun  * ieee80211_unreserve_tid - request to unreserve a specific TID
6458*4882a593Smuzhiyun  *
6459*4882a593Smuzhiyun  * Once there is no longer any need for reserving a certain TID, this function
6460*4882a593Smuzhiyun  * should be called, and no longer will packets have their TID modified for
6461*4882a593Smuzhiyun  * preventing use of this TID in the driver.
6462*4882a593Smuzhiyun  *
6463*4882a593Smuzhiyun  * Note that this function blocks and acquires a lock, so it should be called
6464*4882a593Smuzhiyun  * without driver locks held. Also note this function should only be called
6465*4882a593Smuzhiyun  * from the driver's @sta_state callback.
6466*4882a593Smuzhiyun  *
6467*4882a593Smuzhiyun  * @sta: the station
6468*4882a593Smuzhiyun  * @tid: the TID to unreserve
6469*4882a593Smuzhiyun  */
6470*4882a593Smuzhiyun void ieee80211_unreserve_tid(struct ieee80211_sta *sta, u8 tid);
6471*4882a593Smuzhiyun 
6472*4882a593Smuzhiyun /**
6473*4882a593Smuzhiyun  * ieee80211_tx_dequeue - dequeue a packet from a software tx queue
6474*4882a593Smuzhiyun  *
6475*4882a593Smuzhiyun  * @hw: pointer as obtained from ieee80211_alloc_hw()
6476*4882a593Smuzhiyun  * @txq: pointer obtained from station or virtual interface, or from
6477*4882a593Smuzhiyun  *	ieee80211_next_txq()
6478*4882a593Smuzhiyun  *
6479*4882a593Smuzhiyun  * Returns the skb if successful, %NULL if no frame was available.
6480*4882a593Smuzhiyun  *
6481*4882a593Smuzhiyun  * Note that this must be called in an rcu_read_lock() critical section,
6482*4882a593Smuzhiyun  * which can only be released after the SKB was handled. Some pointers in
6483*4882a593Smuzhiyun  * skb->cb, e.g. the key pointer, are protected by RCU and thus the
6484*4882a593Smuzhiyun  * critical section must persist not just for the duration of this call
6485*4882a593Smuzhiyun  * but for the duration of the frame handling.
6486*4882a593Smuzhiyun  * However, also note that while in the wake_tx_queue() method,
6487*4882a593Smuzhiyun  * rcu_read_lock() is already held.
6488*4882a593Smuzhiyun  *
6489*4882a593Smuzhiyun  * softirqs must also be disabled when this function is called.
6490*4882a593Smuzhiyun  * In process context, use ieee80211_tx_dequeue_ni() instead.
6491*4882a593Smuzhiyun  */
6492*4882a593Smuzhiyun struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw,
6493*4882a593Smuzhiyun 				     struct ieee80211_txq *txq);
6494*4882a593Smuzhiyun 
6495*4882a593Smuzhiyun /**
6496*4882a593Smuzhiyun  * ieee80211_tx_dequeue_ni - dequeue a packet from a software tx queue
6497*4882a593Smuzhiyun  * (in process context)
6498*4882a593Smuzhiyun  *
6499*4882a593Smuzhiyun  * Like ieee80211_tx_dequeue() but can be called in process context
6500*4882a593Smuzhiyun  * (internally disables bottom halves).
6501*4882a593Smuzhiyun  *
6502*4882a593Smuzhiyun  * @hw: pointer as obtained from ieee80211_alloc_hw()
6503*4882a593Smuzhiyun  * @txq: pointer obtained from station or virtual interface, or from
6504*4882a593Smuzhiyun  *	ieee80211_next_txq()
6505*4882a593Smuzhiyun  */
ieee80211_tx_dequeue_ni(struct ieee80211_hw * hw,struct ieee80211_txq * txq)6506*4882a593Smuzhiyun static inline struct sk_buff *ieee80211_tx_dequeue_ni(struct ieee80211_hw *hw,
6507*4882a593Smuzhiyun 						      struct ieee80211_txq *txq)
6508*4882a593Smuzhiyun {
6509*4882a593Smuzhiyun 	struct sk_buff *skb;
6510*4882a593Smuzhiyun 
6511*4882a593Smuzhiyun 	local_bh_disable();
6512*4882a593Smuzhiyun 	skb = ieee80211_tx_dequeue(hw, txq);
6513*4882a593Smuzhiyun 	local_bh_enable();
6514*4882a593Smuzhiyun 
6515*4882a593Smuzhiyun 	return skb;
6516*4882a593Smuzhiyun }
6517*4882a593Smuzhiyun 
6518*4882a593Smuzhiyun /**
6519*4882a593Smuzhiyun  * ieee80211_next_txq - get next tx queue to pull packets from
6520*4882a593Smuzhiyun  *
6521*4882a593Smuzhiyun  * @hw: pointer as obtained from ieee80211_alloc_hw()
6522*4882a593Smuzhiyun  * @ac: AC number to return packets from.
6523*4882a593Smuzhiyun  *
6524*4882a593Smuzhiyun  * Returns the next txq if successful, %NULL if no queue is eligible. If a txq
6525*4882a593Smuzhiyun  * is returned, it should be returned with ieee80211_return_txq() after the
6526*4882a593Smuzhiyun  * driver has finished scheduling it.
6527*4882a593Smuzhiyun  */
6528*4882a593Smuzhiyun struct ieee80211_txq *ieee80211_next_txq(struct ieee80211_hw *hw, u8 ac);
6529*4882a593Smuzhiyun 
6530*4882a593Smuzhiyun /**
6531*4882a593Smuzhiyun  * ieee80211_txq_schedule_start - start new scheduling round for TXQs
6532*4882a593Smuzhiyun  *
6533*4882a593Smuzhiyun  * @hw: pointer as obtained from ieee80211_alloc_hw()
6534*4882a593Smuzhiyun  * @ac: AC number to acquire locks for
6535*4882a593Smuzhiyun  *
6536*4882a593Smuzhiyun  * Should be called before ieee80211_next_txq() or ieee80211_return_txq().
6537*4882a593Smuzhiyun  * The driver must not call multiple TXQ scheduling rounds concurrently.
6538*4882a593Smuzhiyun  */
6539*4882a593Smuzhiyun void ieee80211_txq_schedule_start(struct ieee80211_hw *hw, u8 ac);
6540*4882a593Smuzhiyun 
6541*4882a593Smuzhiyun /* (deprecated) */
ieee80211_txq_schedule_end(struct ieee80211_hw * hw,u8 ac)6542*4882a593Smuzhiyun static inline void ieee80211_txq_schedule_end(struct ieee80211_hw *hw, u8 ac)
6543*4882a593Smuzhiyun {
6544*4882a593Smuzhiyun }
6545*4882a593Smuzhiyun 
6546*4882a593Smuzhiyun void __ieee80211_schedule_txq(struct ieee80211_hw *hw,
6547*4882a593Smuzhiyun 			      struct ieee80211_txq *txq, bool force);
6548*4882a593Smuzhiyun 
6549*4882a593Smuzhiyun /**
6550*4882a593Smuzhiyun  * ieee80211_schedule_txq - schedule a TXQ for transmission
6551*4882a593Smuzhiyun  *
6552*4882a593Smuzhiyun  * @hw: pointer as obtained from ieee80211_alloc_hw()
6553*4882a593Smuzhiyun  * @txq: pointer obtained from station or virtual interface
6554*4882a593Smuzhiyun  *
6555*4882a593Smuzhiyun  * Schedules a TXQ for transmission if it is not already scheduled,
6556*4882a593Smuzhiyun  * even if mac80211 does not have any packets buffered.
6557*4882a593Smuzhiyun  *
6558*4882a593Smuzhiyun  * The driver may call this function if it has buffered packets for
6559*4882a593Smuzhiyun  * this TXQ internally.
6560*4882a593Smuzhiyun  */
6561*4882a593Smuzhiyun static inline void
ieee80211_schedule_txq(struct ieee80211_hw * hw,struct ieee80211_txq * txq)6562*4882a593Smuzhiyun ieee80211_schedule_txq(struct ieee80211_hw *hw, struct ieee80211_txq *txq)
6563*4882a593Smuzhiyun {
6564*4882a593Smuzhiyun 	__ieee80211_schedule_txq(hw, txq, true);
6565*4882a593Smuzhiyun }
6566*4882a593Smuzhiyun 
6567*4882a593Smuzhiyun /**
6568*4882a593Smuzhiyun  * ieee80211_return_txq - return a TXQ previously acquired by ieee80211_next_txq()
6569*4882a593Smuzhiyun  *
6570*4882a593Smuzhiyun  * @hw: pointer as obtained from ieee80211_alloc_hw()
6571*4882a593Smuzhiyun  * @txq: pointer obtained from station or virtual interface
6572*4882a593Smuzhiyun  * @force: schedule txq even if mac80211 does not have any buffered packets.
6573*4882a593Smuzhiyun  *
6574*4882a593Smuzhiyun  * The driver may set force=true if it has buffered packets for this TXQ
6575*4882a593Smuzhiyun  * internally.
6576*4882a593Smuzhiyun  */
6577*4882a593Smuzhiyun static inline void
ieee80211_return_txq(struct ieee80211_hw * hw,struct ieee80211_txq * txq,bool force)6578*4882a593Smuzhiyun ieee80211_return_txq(struct ieee80211_hw *hw, struct ieee80211_txq *txq,
6579*4882a593Smuzhiyun 		     bool force)
6580*4882a593Smuzhiyun {
6581*4882a593Smuzhiyun 	__ieee80211_schedule_txq(hw, txq, force);
6582*4882a593Smuzhiyun }
6583*4882a593Smuzhiyun 
6584*4882a593Smuzhiyun /**
6585*4882a593Smuzhiyun  * ieee80211_txq_may_transmit - check whether TXQ is allowed to transmit
6586*4882a593Smuzhiyun  *
6587*4882a593Smuzhiyun  * This function is used to check whether given txq is allowed to transmit by
6588*4882a593Smuzhiyun  * the airtime scheduler, and can be used by drivers to access the airtime
6589*4882a593Smuzhiyun  * fairness accounting without going using the scheduling order enfored by
6590*4882a593Smuzhiyun  * next_txq().
6591*4882a593Smuzhiyun  *
6592*4882a593Smuzhiyun  * Returns %true if the airtime scheduler thinks the TXQ should be allowed to
6593*4882a593Smuzhiyun  * transmit, and %false if it should be throttled. This function can also have
6594*4882a593Smuzhiyun  * the side effect of rotating the TXQ in the scheduler rotation, which will
6595*4882a593Smuzhiyun  * eventually bring the deficit to positive and allow the station to transmit
6596*4882a593Smuzhiyun  * again.
6597*4882a593Smuzhiyun  *
6598*4882a593Smuzhiyun  * The API ieee80211_txq_may_transmit() also ensures that TXQ list will be
6599*4882a593Smuzhiyun  * aligned against driver's own round-robin scheduler list. i.e it rotates
6600*4882a593Smuzhiyun  * the TXQ list till it makes the requested node becomes the first entry
6601*4882a593Smuzhiyun  * in TXQ list. Thus both the TXQ list and driver's list are in sync. If this
6602*4882a593Smuzhiyun  * function returns %true, the driver is expected to schedule packets
6603*4882a593Smuzhiyun  * for transmission, and then return the TXQ through ieee80211_return_txq().
6604*4882a593Smuzhiyun  *
6605*4882a593Smuzhiyun  * @hw: pointer as obtained from ieee80211_alloc_hw()
6606*4882a593Smuzhiyun  * @txq: pointer obtained from station or virtual interface
6607*4882a593Smuzhiyun  */
6608*4882a593Smuzhiyun bool ieee80211_txq_may_transmit(struct ieee80211_hw *hw,
6609*4882a593Smuzhiyun 				struct ieee80211_txq *txq);
6610*4882a593Smuzhiyun 
6611*4882a593Smuzhiyun /**
6612*4882a593Smuzhiyun  * ieee80211_txq_get_depth - get pending frame/byte count of given txq
6613*4882a593Smuzhiyun  *
6614*4882a593Smuzhiyun  * The values are not guaranteed to be coherent with regard to each other, i.e.
6615*4882a593Smuzhiyun  * txq state can change half-way of this function and the caller may end up
6616*4882a593Smuzhiyun  * with "new" frame_cnt and "old" byte_cnt or vice-versa.
6617*4882a593Smuzhiyun  *
6618*4882a593Smuzhiyun  * @txq: pointer obtained from station or virtual interface
6619*4882a593Smuzhiyun  * @frame_cnt: pointer to store frame count
6620*4882a593Smuzhiyun  * @byte_cnt: pointer to store byte count
6621*4882a593Smuzhiyun  */
6622*4882a593Smuzhiyun void ieee80211_txq_get_depth(struct ieee80211_txq *txq,
6623*4882a593Smuzhiyun 			     unsigned long *frame_cnt,
6624*4882a593Smuzhiyun 			     unsigned long *byte_cnt);
6625*4882a593Smuzhiyun 
6626*4882a593Smuzhiyun /**
6627*4882a593Smuzhiyun  * ieee80211_nan_func_terminated - notify about NAN function termination.
6628*4882a593Smuzhiyun  *
6629*4882a593Smuzhiyun  * This function is used to notify mac80211 about NAN function termination.
6630*4882a593Smuzhiyun  * Note that this function can't be called from hard irq.
6631*4882a593Smuzhiyun  *
6632*4882a593Smuzhiyun  * @vif: &struct ieee80211_vif pointer from the add_interface callback.
6633*4882a593Smuzhiyun  * @inst_id: the local instance id
6634*4882a593Smuzhiyun  * @reason: termination reason (one of the NL80211_NAN_FUNC_TERM_REASON_*)
6635*4882a593Smuzhiyun  * @gfp: allocation flags
6636*4882a593Smuzhiyun  */
6637*4882a593Smuzhiyun void ieee80211_nan_func_terminated(struct ieee80211_vif *vif,
6638*4882a593Smuzhiyun 				   u8 inst_id,
6639*4882a593Smuzhiyun 				   enum nl80211_nan_func_term_reason reason,
6640*4882a593Smuzhiyun 				   gfp_t gfp);
6641*4882a593Smuzhiyun 
6642*4882a593Smuzhiyun /**
6643*4882a593Smuzhiyun  * ieee80211_nan_func_match - notify about NAN function match event.
6644*4882a593Smuzhiyun  *
6645*4882a593Smuzhiyun  * This function is used to notify mac80211 about NAN function match. The
6646*4882a593Smuzhiyun  * cookie inside the match struct will be assigned by mac80211.
6647*4882a593Smuzhiyun  * Note that this function can't be called from hard irq.
6648*4882a593Smuzhiyun  *
6649*4882a593Smuzhiyun  * @vif: &struct ieee80211_vif pointer from the add_interface callback.
6650*4882a593Smuzhiyun  * @match: match event information
6651*4882a593Smuzhiyun  * @gfp: allocation flags
6652*4882a593Smuzhiyun  */
6653*4882a593Smuzhiyun void ieee80211_nan_func_match(struct ieee80211_vif *vif,
6654*4882a593Smuzhiyun 			      struct cfg80211_nan_match_params *match,
6655*4882a593Smuzhiyun 			      gfp_t gfp);
6656*4882a593Smuzhiyun 
6657*4882a593Smuzhiyun /**
6658*4882a593Smuzhiyun  * ieee80211_calc_rx_airtime - calculate estimated transmission airtime for RX.
6659*4882a593Smuzhiyun  *
6660*4882a593Smuzhiyun  * This function calculates the estimated airtime usage of a frame based on the
6661*4882a593Smuzhiyun  * rate information in the RX status struct and the frame length.
6662*4882a593Smuzhiyun  *
6663*4882a593Smuzhiyun  * @hw: pointer as obtained from ieee80211_alloc_hw()
6664*4882a593Smuzhiyun  * @status: &struct ieee80211_rx_status containing the transmission rate
6665*4882a593Smuzhiyun  *          information.
6666*4882a593Smuzhiyun  * @len: frame length in bytes
6667*4882a593Smuzhiyun  */
6668*4882a593Smuzhiyun u32 ieee80211_calc_rx_airtime(struct ieee80211_hw *hw,
6669*4882a593Smuzhiyun 			      struct ieee80211_rx_status *status,
6670*4882a593Smuzhiyun 			      int len);
6671*4882a593Smuzhiyun 
6672*4882a593Smuzhiyun /**
6673*4882a593Smuzhiyun  * ieee80211_calc_tx_airtime - calculate estimated transmission airtime for TX.
6674*4882a593Smuzhiyun  *
6675*4882a593Smuzhiyun  * This function calculates the estimated airtime usage of a frame based on the
6676*4882a593Smuzhiyun  * rate information in the TX info struct and the frame length.
6677*4882a593Smuzhiyun  *
6678*4882a593Smuzhiyun  * @hw: pointer as obtained from ieee80211_alloc_hw()
6679*4882a593Smuzhiyun  * @info: &struct ieee80211_tx_info of the frame.
6680*4882a593Smuzhiyun  * @len: frame length in bytes
6681*4882a593Smuzhiyun  */
6682*4882a593Smuzhiyun u32 ieee80211_calc_tx_airtime(struct ieee80211_hw *hw,
6683*4882a593Smuzhiyun 			      struct ieee80211_tx_info *info,
6684*4882a593Smuzhiyun 			      int len);
6685*4882a593Smuzhiyun /**
6686*4882a593Smuzhiyun  * ieee80211_set_hw_80211_encap - enable hardware encapsulation offloading.
6687*4882a593Smuzhiyun  *
6688*4882a593Smuzhiyun  * This function is used to notify mac80211 that a vif can be passed raw 802.3
6689*4882a593Smuzhiyun  * frames. The driver needs to then handle the 802.11 encapsulation inside the
6690*4882a593Smuzhiyun  * hardware or firmware.
6691*4882a593Smuzhiyun  *
6692*4882a593Smuzhiyun  * @vif: &struct ieee80211_vif pointer from the add_interface callback.
6693*4882a593Smuzhiyun  * @enable: indicate if the feature should be turned on or off
6694*4882a593Smuzhiyun  */
6695*4882a593Smuzhiyun bool ieee80211_set_hw_80211_encap(struct ieee80211_vif *vif, bool enable);
6696*4882a593Smuzhiyun 
6697*4882a593Smuzhiyun /**
6698*4882a593Smuzhiyun  * ieee80211_get_fils_discovery_tmpl - Get FILS discovery template.
6699*4882a593Smuzhiyun  * @hw: pointer obtained from ieee80211_alloc_hw().
6700*4882a593Smuzhiyun  * @vif: &struct ieee80211_vif pointer from the add_interface callback.
6701*4882a593Smuzhiyun  *
6702*4882a593Smuzhiyun  * The driver is responsible for freeing the returned skb.
6703*4882a593Smuzhiyun  *
6704*4882a593Smuzhiyun  * Return: FILS discovery template. %NULL on error.
6705*4882a593Smuzhiyun  */
6706*4882a593Smuzhiyun struct sk_buff *ieee80211_get_fils_discovery_tmpl(struct ieee80211_hw *hw,
6707*4882a593Smuzhiyun 						  struct ieee80211_vif *vif);
6708*4882a593Smuzhiyun 
6709*4882a593Smuzhiyun /**
6710*4882a593Smuzhiyun  * ieee80211_get_unsol_bcast_probe_resp_tmpl - Get unsolicited broadcast
6711*4882a593Smuzhiyun  *	probe response template.
6712*4882a593Smuzhiyun  * @hw: pointer obtained from ieee80211_alloc_hw().
6713*4882a593Smuzhiyun  * @vif: &struct ieee80211_vif pointer from the add_interface callback.
6714*4882a593Smuzhiyun  *
6715*4882a593Smuzhiyun  * The driver is responsible for freeing the returned skb.
6716*4882a593Smuzhiyun  *
6717*4882a593Smuzhiyun  * Return: Unsolicited broadcast probe response template. %NULL on error.
6718*4882a593Smuzhiyun  */
6719*4882a593Smuzhiyun struct sk_buff *
6720*4882a593Smuzhiyun ieee80211_get_unsol_bcast_probe_resp_tmpl(struct ieee80211_hw *hw,
6721*4882a593Smuzhiyun 					  struct ieee80211_vif *vif);
6722*4882a593Smuzhiyun #endif /* MAC80211_H */
6723