GNU Linux-libre 4.14.290-gnu1
[releases.git] / drivers / net / wireless / intel / iwlwifi / fw / api / mac.h
1 /******************************************************************************
2  *
3  * This file is provided under a dual BSD/GPLv2 license.  When using or
4  * redistributing this file, you may do so under either license.
5  *
6  * GPL LICENSE SUMMARY
7  *
8  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
9  * Copyright(c) 2017        Intel Deutschland GmbH
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of version 2 of the GNU General Public License as
13  * published by the Free Software Foundation.
14  *
15  * This program is distributed in the hope that it will be useful, but
16  * WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * General Public License for more details.
19  *
20  * The full GNU General Public License is included in this distribution
21  * in the file called COPYING.
22  *
23  * Contact Information:
24  *  Intel Linux Wireless <linuxwifi@intel.com>
25  * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26  *
27  * BSD LICENSE
28  *
29  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
30  * Copyright(c) 2017        Intel Deutschland GmbH
31  * All rights reserved.
32  *
33  * Redistribution and use in source and binary forms, with or without
34  * modification, are permitted provided that the following conditions
35  * are met:
36  *
37  *  * Redistributions of source code must retain the above copyright
38  *    notice, this list of conditions and the following disclaimer.
39  *  * Redistributions in binary form must reproduce the above copyright
40  *    notice, this list of conditions and the following disclaimer in
41  *    the documentation and/or other materials provided with the
42  *    distribution.
43  *  * Neither the name Intel Corporation nor the names of its
44  *    contributors may be used to endorse or promote products derived
45  *    from this software without specific prior written permission.
46  *
47  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
48  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
49  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
50  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
51  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
52  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
53  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
54  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
55  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
56  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
57  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
58  *****************************************************************************/
59
60 #ifndef __iwl_fw_api_mac_h__
61 #define __iwl_fw_api_mac_h__
62
63 /*
64  * The first MAC indices (starting from 0) are available to the driver,
65  * AUX indices follows - 1 for non-CDB, 2 for CDB.
66  */
67 #define MAC_INDEX_AUX           4
68 #define MAC_INDEX_MIN_DRIVER    0
69 #define NUM_MAC_INDEX_DRIVER    MAC_INDEX_AUX
70 #define NUM_MAC_INDEX           (NUM_MAC_INDEX_DRIVER + 1)
71 #define NUM_MAC_INDEX_CDB       (NUM_MAC_INDEX_DRIVER + 2)
72
73 #define IWL_MVM_STATION_COUNT           16
74 #define IWL_MVM_INVALID_STA             0xFF
75
76 enum iwl_ac {
77         AC_BK,
78         AC_BE,
79         AC_VI,
80         AC_VO,
81         AC_NUM,
82 };
83
84 /**
85  * enum iwl_mac_protection_flags - MAC context flags
86  * @MAC_PROT_FLG_TGG_PROTECT: 11g protection when transmitting OFDM frames,
87  *      this will require CCK RTS/CTS2self.
88  *      RTS/CTS will protect full burst time.
89  * @MAC_PROT_FLG_HT_PROT: enable HT protection
90  * @MAC_PROT_FLG_FAT_PROT: protect 40 MHz transmissions
91  * @MAC_PROT_FLG_SELF_CTS_EN: allow CTS2self
92  */
93 enum iwl_mac_protection_flags {
94         MAC_PROT_FLG_TGG_PROTECT        = BIT(3),
95         MAC_PROT_FLG_HT_PROT            = BIT(23),
96         MAC_PROT_FLG_FAT_PROT           = BIT(24),
97         MAC_PROT_FLG_SELF_CTS_EN        = BIT(30),
98 };
99
100 #define MAC_FLG_SHORT_SLOT              BIT(4)
101 #define MAC_FLG_SHORT_PREAMBLE          BIT(5)
102
103 /**
104  * enum iwl_mac_types - Supported MAC types
105  * @FW_MAC_TYPE_FIRST: lowest supported MAC type
106  * @FW_MAC_TYPE_AUX: Auxiliary MAC (internal)
107  * @FW_MAC_TYPE_LISTENER: monitor MAC type (?)
108  * @FW_MAC_TYPE_PIBSS: Pseudo-IBSS
109  * @FW_MAC_TYPE_IBSS: IBSS
110  * @FW_MAC_TYPE_BSS_STA: BSS (managed) station
111  * @FW_MAC_TYPE_P2P_DEVICE: P2P Device
112  * @FW_MAC_TYPE_P2P_STA: P2P client
113  * @FW_MAC_TYPE_GO: P2P GO
114  * @FW_MAC_TYPE_TEST: ?
115  * @FW_MAC_TYPE_MAX: highest support MAC type
116  */
117 enum iwl_mac_types {
118         FW_MAC_TYPE_FIRST = 1,
119         FW_MAC_TYPE_AUX = FW_MAC_TYPE_FIRST,
120         FW_MAC_TYPE_LISTENER,
121         FW_MAC_TYPE_PIBSS,
122         FW_MAC_TYPE_IBSS,
123         FW_MAC_TYPE_BSS_STA,
124         FW_MAC_TYPE_P2P_DEVICE,
125         FW_MAC_TYPE_P2P_STA,
126         FW_MAC_TYPE_GO,
127         FW_MAC_TYPE_TEST,
128         FW_MAC_TYPE_MAX = FW_MAC_TYPE_TEST
129 }; /* MAC_CONTEXT_TYPE_API_E_VER_1 */
130
131 /**
132  * enum iwl_tsf_id - TSF hw timer ID
133  * @TSF_ID_A: use TSF A
134  * @TSF_ID_B: use TSF B
135  * @TSF_ID_C: use TSF C
136  * @TSF_ID_D: use TSF D
137  * @NUM_TSF_IDS: number of TSF timers available
138  */
139 enum iwl_tsf_id {
140         TSF_ID_A = 0,
141         TSF_ID_B = 1,
142         TSF_ID_C = 2,
143         TSF_ID_D = 3,
144         NUM_TSF_IDS = 4,
145 }; /* TSF_ID_API_E_VER_1 */
146
147 /**
148  * struct iwl_mac_data_ap - configuration data for AP MAC context
149  * @beacon_time: beacon transmit time in system time
150  * @beacon_tsf: beacon transmit time in TSF
151  * @bi: beacon interval in TU
152  * @bi_reciprocal: 2^32 / bi
153  * @dtim_interval: dtim transmit time in TU
154  * @dtim_reciprocal: 2^32 / dtim_interval
155  * @mcast_qid: queue ID for multicast traffic.
156  *      NOTE: obsolete from VER2 and on
157  * @beacon_template: beacon template ID
158  */
159 struct iwl_mac_data_ap {
160         __le32 beacon_time;
161         __le64 beacon_tsf;
162         __le32 bi;
163         __le32 bi_reciprocal;
164         __le32 dtim_interval;
165         __le32 dtim_reciprocal;
166         __le32 mcast_qid;
167         __le32 beacon_template;
168 } __packed; /* AP_MAC_DATA_API_S_VER_2 */
169
170 /**
171  * struct iwl_mac_data_ibss - configuration data for IBSS MAC context
172  * @beacon_time: beacon transmit time in system time
173  * @beacon_tsf: beacon transmit time in TSF
174  * @bi: beacon interval in TU
175  * @bi_reciprocal: 2^32 / bi
176  * @beacon_template: beacon template ID
177  */
178 struct iwl_mac_data_ibss {
179         __le32 beacon_time;
180         __le64 beacon_tsf;
181         __le32 bi;
182         __le32 bi_reciprocal;
183         __le32 beacon_template;
184 } __packed; /* IBSS_MAC_DATA_API_S_VER_1 */
185
186 /**
187  * struct iwl_mac_data_sta - configuration data for station MAC context
188  * @is_assoc: 1 for associated state, 0 otherwise
189  * @dtim_time: DTIM arrival time in system time
190  * @dtim_tsf: DTIM arrival time in TSF
191  * @bi: beacon interval in TU, applicable only when associated
192  * @bi_reciprocal: 2^32 / bi , applicable only when associated
193  * @dtim_interval: DTIM interval in TU, applicable only when associated
194  * @dtim_reciprocal: 2^32 / dtim_interval , applicable only when associated
195  * @listen_interval: in beacon intervals, applicable only when associated
196  * @assoc_id: unique ID assigned by the AP during association
197  * @assoc_beacon_arrive_time: TSF of first beacon after association
198  */
199 struct iwl_mac_data_sta {
200         __le32 is_assoc;
201         __le32 dtim_time;
202         __le64 dtim_tsf;
203         __le32 bi;
204         __le32 bi_reciprocal;
205         __le32 dtim_interval;
206         __le32 dtim_reciprocal;
207         __le32 listen_interval;
208         __le32 assoc_id;
209         __le32 assoc_beacon_arrive_time;
210 } __packed; /* STA_MAC_DATA_API_S_VER_1 */
211
212 /**
213  * struct iwl_mac_data_go - configuration data for P2P GO MAC context
214  * @ap: iwl_mac_data_ap struct with most config data
215  * @ctwin: client traffic window in TU (period after TBTT when GO is present).
216  *      0 indicates that there is no CT window.
217  * @opp_ps_enabled: indicate that opportunistic PS allowed
218  */
219 struct iwl_mac_data_go {
220         struct iwl_mac_data_ap ap;
221         __le32 ctwin;
222         __le32 opp_ps_enabled;
223 } __packed; /* GO_MAC_DATA_API_S_VER_1 */
224
225 /**
226  * struct iwl_mac_data_p2p_sta - configuration data for P2P client MAC context
227  * @sta: iwl_mac_data_sta struct with most config data
228  * @ctwin: client traffic window in TU (period after TBTT when GO is present).
229  *      0 indicates that there is no CT window.
230  */
231 struct iwl_mac_data_p2p_sta {
232         struct iwl_mac_data_sta sta;
233         __le32 ctwin;
234 } __packed; /* P2P_STA_MAC_DATA_API_S_VER_1 */
235
236 /**
237  * struct iwl_mac_data_pibss - Pseudo IBSS config data
238  * @stats_interval: interval in TU between statistics notifications to host.
239  */
240 struct iwl_mac_data_pibss {
241         __le32 stats_interval;
242 } __packed; /* PIBSS_MAC_DATA_API_S_VER_1 */
243
244 /*
245  * struct iwl_mac_data_p2p_dev - configuration data for the P2P Device MAC
246  * context.
247  * @is_disc_extended: if set to true, P2P Device discoverability is enabled on
248  *      other channels as well. This should be to true only in case that the
249  *      device is discoverable and there is an active GO. Note that setting this
250  *      field when not needed, will increase the number of interrupts and have
251  *      effect on the platform power, as this setting opens the Rx filters on
252  *      all macs.
253  */
254 struct iwl_mac_data_p2p_dev {
255         __le32 is_disc_extended;
256 } __packed; /* _P2P_DEV_MAC_DATA_API_S_VER_1 */
257
258 /**
259  * enum iwl_mac_filter_flags - MAC context filter flags
260  * @MAC_FILTER_IN_PROMISC: accept all data frames
261  * @MAC_FILTER_IN_CONTROL_AND_MGMT: pass all management and
262  *      control frames to the host
263  * @MAC_FILTER_ACCEPT_GRP: accept multicast frames
264  * @MAC_FILTER_DIS_DECRYPT: don't decrypt unicast frames
265  * @MAC_FILTER_DIS_GRP_DECRYPT: don't decrypt multicast frames
266  * @MAC_FILTER_IN_BEACON: transfer foreign BSS's beacons to host
267  *      (in station mode when associated)
268  * @MAC_FILTER_OUT_BCAST: filter out all broadcast frames
269  * @MAC_FILTER_IN_CRC32: extract FCS and append it to frames
270  * @MAC_FILTER_IN_PROBE_REQUEST: pass probe requests to host
271  */
272 enum iwl_mac_filter_flags {
273         MAC_FILTER_IN_PROMISC           = BIT(0),
274         MAC_FILTER_IN_CONTROL_AND_MGMT  = BIT(1),
275         MAC_FILTER_ACCEPT_GRP           = BIT(2),
276         MAC_FILTER_DIS_DECRYPT          = BIT(3),
277         MAC_FILTER_DIS_GRP_DECRYPT      = BIT(4),
278         MAC_FILTER_IN_BEACON            = BIT(6),
279         MAC_FILTER_OUT_BCAST            = BIT(8),
280         MAC_FILTER_IN_CRC32             = BIT(11),
281         MAC_FILTER_IN_PROBE_REQUEST     = BIT(12),
282 };
283
284 /**
285  * enum iwl_mac_qos_flags - QoS flags
286  * @MAC_QOS_FLG_UPDATE_EDCA: ?
287  * @MAC_QOS_FLG_TGN: HT is enabled
288  * @MAC_QOS_FLG_TXOP_TYPE: ?
289  *
290  */
291 enum iwl_mac_qos_flags {
292         MAC_QOS_FLG_UPDATE_EDCA = BIT(0),
293         MAC_QOS_FLG_TGN         = BIT(1),
294         MAC_QOS_FLG_TXOP_TYPE   = BIT(4),
295 };
296
297 /**
298  * struct iwl_ac_qos - QOS timing params for MAC_CONTEXT_CMD
299  * @cw_min: Contention window, start value in numbers of slots.
300  *      Should be a power-of-2, minus 1.  Device's default is 0x0f.
301  * @cw_max: Contention window, max value in numbers of slots.
302  *      Should be a power-of-2, minus 1.  Device's default is 0x3f.
303  * @aifsn:  Number of slots in Arbitration Interframe Space (before
304  *      performing random backoff timing prior to Tx).  Device default 1.
305  * @fifos_mask: FIFOs used by this MAC for this AC
306  * @edca_txop:  Length of Tx opportunity, in uSecs.  Device default is 0.
307  *
308  * One instance of this config struct for each of 4 EDCA access categories
309  * in struct iwl_qosparam_cmd.
310  *
311  * Device will automatically increase contention window by (2*CW) + 1 for each
312  * transmission retry.  Device uses cw_max as a bit mask, ANDed with new CW
313  * value, to cap the CW value.
314  */
315 struct iwl_ac_qos {
316         __le16 cw_min;
317         __le16 cw_max;
318         u8 aifsn;
319         u8 fifos_mask;
320         __le16 edca_txop;
321 } __packed; /* AC_QOS_API_S_VER_2 */
322
323 /**
324  * struct iwl_mac_ctx_cmd - command structure to configure MAC contexts
325  * ( MAC_CONTEXT_CMD = 0x28 )
326  * @id_and_color: ID and color of the MAC
327  * @action: action to perform, one of FW_CTXT_ACTION_*
328  * @mac_type: one of &enum iwl_mac_types
329  * @tsf_id: TSF HW timer, one of &enum iwl_tsf_id
330  * @node_addr: MAC address
331  * @reserved_for_node_addr: reserved
332  * @bssid_addr: BSSID
333  * @reserved_for_bssid_addr: reserved
334  * @cck_rates: basic rates available for CCK
335  * @ofdm_rates: basic rates available for OFDM
336  * @protection_flags: combination of &enum iwl_mac_protection_flags
337  * @cck_short_preamble: 0x20 for enabling short preamble, 0 otherwise
338  * @short_slot: 0x10 for enabling short slots, 0 otherwise
339  * @filter_flags: combination of &enum iwl_mac_filter_flags
340  * @qos_flags: from &enum iwl_mac_qos_flags
341  * @ac: one iwl_mac_qos configuration for each AC
342  */
343 struct iwl_mac_ctx_cmd {
344         /* COMMON_INDEX_HDR_API_S_VER_1 */
345         __le32 id_and_color;
346         __le32 action;
347         /* MAC_CONTEXT_COMMON_DATA_API_S_VER_1 */
348         __le32 mac_type;
349         __le32 tsf_id;
350         u8 node_addr[6];
351         __le16 reserved_for_node_addr;
352         u8 bssid_addr[6];
353         __le16 reserved_for_bssid_addr;
354         __le32 cck_rates;
355         __le32 ofdm_rates;
356         __le32 protection_flags;
357         __le32 cck_short_preamble;
358         __le32 short_slot;
359         __le32 filter_flags;
360         /* MAC_QOS_PARAM_API_S_VER_1 */
361         __le32 qos_flags;
362         struct iwl_ac_qos ac[AC_NUM+1];
363         /* MAC_CONTEXT_COMMON_DATA_API_S */
364         union {
365                 struct iwl_mac_data_ap ap;
366                 struct iwl_mac_data_go go;
367                 struct iwl_mac_data_sta sta;
368                 struct iwl_mac_data_p2p_sta p2p_sta;
369                 struct iwl_mac_data_p2p_dev p2p_dev;
370                 struct iwl_mac_data_pibss pibss;
371                 struct iwl_mac_data_ibss ibss;
372         };
373 } __packed; /* MAC_CONTEXT_CMD_API_S_VER_1 */
374
375 static inline u32 iwl_mvm_reciprocal(u32 v)
376 {
377         if (!v)
378                 return 0;
379         return 0xFFFFFFFF / v;
380 }
381
382 #define IWL_NONQOS_SEQ_GET      0x1
383 #define IWL_NONQOS_SEQ_SET      0x2
384 struct iwl_nonqos_seq_query_cmd {
385         __le32 get_set_flag;
386         __le32 mac_id_n_color;
387         __le16 value;
388         __le16 reserved;
389 } __packed; /* NON_QOS_TX_COUNTER_GET_SET_API_S_VER_1 */
390
391 /**
392  * struct iwl_missed_beacons_notif - information on missed beacons
393  * ( MISSED_BEACONS_NOTIFICATION = 0xa2 )
394  * @mac_id: interface ID
395  * @consec_missed_beacons_since_last_rx: number of consecutive missed
396  *      beacons since last RX.
397  * @consec_missed_beacons: number of consecutive missed beacons
398  * @num_expected_beacons: number of expected beacons
399  * @num_recvd_beacons: number of received beacons
400  */
401 struct iwl_missed_beacons_notif {
402         __le32 mac_id;
403         __le32 consec_missed_beacons_since_last_rx;
404         __le32 consec_missed_beacons;
405         __le32 num_expected_beacons;
406         __le32 num_recvd_beacons;
407 } __packed; /* MISSED_BEACON_NTFY_API_S_VER_3 */
408
409 #endif /* __iwl_fw_api_mac_h__ */