7128379fb6218cc0fdf7843524fd860b88b44774
[pandora-kernel.git] / drivers / net / wireless / iwlwifi / mvm / fw-api.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) 2013 - 2015 Intel Mobile Communications 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  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
23  * USA
24  *
25  * The full GNU General Public License is included in this distribution
26  * in the file called COPYING.
27  *
28  * Contact Information:
29  *  Intel Linux Wireless <ilw@linux.intel.com>
30  * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
31  *
32  * BSD LICENSE
33  *
34  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
35  * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
36  * All rights reserved.
37  *
38  * Redistribution and use in source and binary forms, with or without
39  * modification, are permitted provided that the following conditions
40  * are met:
41  *
42  *  * Redistributions of source code must retain the above copyright
43  *    notice, this list of conditions and the following disclaimer.
44  *  * Redistributions in binary form must reproduce the above copyright
45  *    notice, this list of conditions and the following disclaimer in
46  *    the documentation and/or other materials provided with the
47  *    distribution.
48  *  * Neither the name Intel Corporation nor the names of its
49  *    contributors may be used to endorse or promote products derived
50  *    from this software without specific prior written permission.
51  *
52  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
53  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
54  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
55  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
56  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
57  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
58  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
59  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
60  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
61  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
62  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
63  *
64  *****************************************************************************/
65
66 #ifndef __fw_api_h__
67 #define __fw_api_h__
68
69 #include "fw-api-rs.h"
70 #include "fw-api-tx.h"
71 #include "fw-api-sta.h"
72 #include "fw-api-mac.h"
73 #include "fw-api-power.h"
74 #include "fw-api-d3.h"
75 #include "fw-api-coex.h"
76 #include "fw-api-scan.h"
77 #include "fw-api-stats.h"
78
79 /* Tx queue numbers */
80 enum {
81         IWL_MVM_OFFCHANNEL_QUEUE = 8,
82         IWL_MVM_CMD_QUEUE = 9,
83 };
84
85 enum iwl_mvm_tx_fifo {
86         IWL_MVM_TX_FIFO_BK = 0,
87         IWL_MVM_TX_FIFO_BE,
88         IWL_MVM_TX_FIFO_VI,
89         IWL_MVM_TX_FIFO_VO,
90         IWL_MVM_TX_FIFO_MCAST = 5,
91         IWL_MVM_TX_FIFO_CMD = 7,
92 };
93
94 #define IWL_MVM_STATION_COUNT   16
95
96 #define IWL_MVM_TDLS_STA_COUNT  4
97
98 /* commands */
99 enum {
100         MVM_ALIVE = 0x1,
101         REPLY_ERROR = 0x2,
102
103         INIT_COMPLETE_NOTIF = 0x4,
104
105         /* PHY context commands */
106         PHY_CONTEXT_CMD = 0x8,
107         DBG_CFG = 0x9,
108         ANTENNA_COUPLING_NOTIFICATION = 0xa,
109
110         /* UMAC scan commands */
111         SCAN_ITERATION_COMPLETE_UMAC = 0xb5,
112         SCAN_CFG_CMD = 0xc,
113         SCAN_REQ_UMAC = 0xd,
114         SCAN_ABORT_UMAC = 0xe,
115         SCAN_COMPLETE_UMAC = 0xf,
116
117         /* station table */
118         ADD_STA_KEY = 0x17,
119         ADD_STA = 0x18,
120         REMOVE_STA = 0x19,
121
122         /* TX */
123         TX_CMD = 0x1c,
124         TXPATH_FLUSH = 0x1e,
125         MGMT_MCAST_KEY = 0x1f,
126
127         /* scheduler config */
128         SCD_QUEUE_CFG = 0x1d,
129
130         /* global key */
131         WEP_KEY = 0x20,
132
133         /* Memory */
134         SHARED_MEM_CFG = 0x25,
135
136         /* TDLS */
137         TDLS_CHANNEL_SWITCH_CMD = 0x27,
138         TDLS_CHANNEL_SWITCH_NOTIFICATION = 0xaa,
139         TDLS_CONFIG_CMD = 0xa7,
140
141         /* MAC and Binding commands */
142         MAC_CONTEXT_CMD = 0x28,
143         TIME_EVENT_CMD = 0x29, /* both CMD and response */
144         TIME_EVENT_NOTIFICATION = 0x2a,
145         BINDING_CONTEXT_CMD = 0x2b,
146         TIME_QUOTA_CMD = 0x2c,
147         NON_QOS_TX_COUNTER_CMD = 0x2d,
148
149         LQ_CMD = 0x4e,
150
151         /* Scan offload */
152         SCAN_OFFLOAD_REQUEST_CMD = 0x51,
153         SCAN_OFFLOAD_ABORT_CMD = 0x52,
154         HOT_SPOT_CMD = 0x53,
155         SCAN_OFFLOAD_COMPLETE = 0x6D,
156         SCAN_OFFLOAD_UPDATE_PROFILES_CMD = 0x6E,
157         SCAN_OFFLOAD_CONFIG_CMD = 0x6f,
158         MATCH_FOUND_NOTIFICATION = 0xd9,
159         SCAN_ITERATION_COMPLETE = 0xe7,
160
161         /* Phy */
162         PHY_CONFIGURATION_CMD = 0x6a,
163         CALIB_RES_NOTIF_PHY_DB = 0x6b,
164         /* PHY_DB_CMD = 0x6c, */
165
166         /* Power - legacy power table command */
167         POWER_TABLE_CMD = 0x77,
168         PSM_UAPSD_AP_MISBEHAVING_NOTIFICATION = 0x78,
169         LTR_CONFIG = 0xee,
170
171         /* Thermal Throttling*/
172         REPLY_THERMAL_MNG_BACKOFF = 0x7e,
173
174         /* NVM */
175         NVM_ACCESS_CMD = 0x88,
176
177         SET_CALIB_DEFAULT_CMD = 0x8e,
178
179         BEACON_NOTIFICATION = 0x90,
180         BEACON_TEMPLATE_CMD = 0x91,
181         TX_ANT_CONFIGURATION_CMD = 0x98,
182         STATISTICS_CMD = 0x9c,
183         STATISTICS_NOTIFICATION = 0x9d,
184         EOSP_NOTIFICATION = 0x9e,
185         REDUCE_TX_POWER_CMD = 0x9f,
186
187         /* RF-KILL commands and notifications */
188         CARD_STATE_CMD = 0xa0,
189         CARD_STATE_NOTIFICATION = 0xa1,
190
191         MISSED_BEACONS_NOTIFICATION = 0xa2,
192
193         /* Power - new power table command */
194         MAC_PM_POWER_TABLE = 0xa9,
195
196         MFUART_LOAD_NOTIFICATION = 0xb1,
197
198         REPLY_RX_PHY_CMD = 0xc0,
199         REPLY_RX_MPDU_CMD = 0xc1,
200         BA_NOTIF = 0xc5,
201
202         /* Location Aware Regulatory */
203         MCC_UPDATE_CMD = 0xc8,
204         MCC_CHUB_UPDATE_CMD = 0xc9,
205
206         MARKER_CMD = 0xcb,
207
208         /* BT Coex */
209         BT_COEX_PRIO_TABLE = 0xcc,
210         BT_COEX_PROT_ENV = 0xcd,
211         BT_PROFILE_NOTIFICATION = 0xce,
212         BT_CONFIG = 0x9b,
213         BT_COEX_UPDATE_SW_BOOST = 0x5a,
214         BT_COEX_UPDATE_CORUN_LUT = 0x5b,
215         BT_COEX_UPDATE_REDUCED_TXP = 0x5c,
216         BT_COEX_CI = 0x5d,
217
218         REPLY_SF_CFG_CMD = 0xd1,
219         REPLY_BEACON_FILTERING_CMD = 0xd2,
220
221         /* DTS measurements */
222         CMD_DTS_MEASUREMENT_TRIGGER = 0xdc,
223         DTS_MEASUREMENT_NOTIFICATION = 0xdd,
224
225         REPLY_DEBUG_CMD = 0xf0,
226         DEBUG_LOG_MSG = 0xf7,
227
228         BCAST_FILTER_CMD = 0xcf,
229         MCAST_FILTER_CMD = 0xd0,
230
231         /* D3 commands/notifications */
232         D3_CONFIG_CMD = 0xd3,
233         PROT_OFFLOAD_CONFIG_CMD = 0xd4,
234         OFFLOADS_QUERY_CMD = 0xd5,
235         REMOTE_WAKE_CONFIG_CMD = 0xd6,
236         D0I3_END_CMD = 0xed,
237
238         /* for WoWLAN in particular */
239         WOWLAN_PATTERNS = 0xe0,
240         WOWLAN_CONFIGURATION = 0xe1,
241         WOWLAN_TSC_RSC_PARAM = 0xe2,
242         WOWLAN_TKIP_PARAM = 0xe3,
243         WOWLAN_KEK_KCK_MATERIAL = 0xe4,
244         WOWLAN_GET_STATUSES = 0xe5,
245         WOWLAN_TX_POWER_PER_DB = 0xe6,
246
247         /* and for NetDetect */
248         SCAN_OFFLOAD_PROFILES_QUERY_CMD = 0x56,
249         SCAN_OFFLOAD_HOTSPOTS_CONFIG_CMD = 0x58,
250         SCAN_OFFLOAD_HOTSPOTS_QUERY_CMD = 0x59,
251
252         REPLY_MAX = 0xff,
253 };
254
255 /**
256  * struct iwl_cmd_response - generic response struct for most commands
257  * @status: status of the command asked, changes for each one
258  */
259 struct iwl_cmd_response {
260         __le32 status;
261 };
262
263 /*
264  * struct iwl_tx_ant_cfg_cmd
265  * @valid: valid antenna configuration
266  */
267 struct iwl_tx_ant_cfg_cmd {
268         __le32 valid;
269 } __packed;
270
271 /*
272  * Calibration control struct.
273  * Sent as part of the phy configuration command.
274  * @flow_trigger: bitmap for which calibrations to perform according to
275  *              flow triggers.
276  * @event_trigger: bitmap for which calibrations to perform according to
277  *              event triggers.
278  */
279 struct iwl_calib_ctrl {
280         __le32 flow_trigger;
281         __le32 event_trigger;
282 } __packed;
283
284 /* This enum defines the bitmap of various calibrations to enable in both
285  * init ucode and runtime ucode through CALIBRATION_CFG_CMD.
286  */
287 enum iwl_calib_cfg {
288         IWL_CALIB_CFG_XTAL_IDX                  = BIT(0),
289         IWL_CALIB_CFG_TEMPERATURE_IDX           = BIT(1),
290         IWL_CALIB_CFG_VOLTAGE_READ_IDX          = BIT(2),
291         IWL_CALIB_CFG_PAPD_IDX                  = BIT(3),
292         IWL_CALIB_CFG_TX_PWR_IDX                = BIT(4),
293         IWL_CALIB_CFG_DC_IDX                    = BIT(5),
294         IWL_CALIB_CFG_BB_FILTER_IDX             = BIT(6),
295         IWL_CALIB_CFG_LO_LEAKAGE_IDX            = BIT(7),
296         IWL_CALIB_CFG_TX_IQ_IDX                 = BIT(8),
297         IWL_CALIB_CFG_TX_IQ_SKEW_IDX            = BIT(9),
298         IWL_CALIB_CFG_RX_IQ_IDX                 = BIT(10),
299         IWL_CALIB_CFG_RX_IQ_SKEW_IDX            = BIT(11),
300         IWL_CALIB_CFG_SENSITIVITY_IDX           = BIT(12),
301         IWL_CALIB_CFG_CHAIN_NOISE_IDX           = BIT(13),
302         IWL_CALIB_CFG_DISCONNECTED_ANT_IDX      = BIT(14),
303         IWL_CALIB_CFG_ANT_COUPLING_IDX          = BIT(15),
304         IWL_CALIB_CFG_DAC_IDX                   = BIT(16),
305         IWL_CALIB_CFG_ABS_IDX                   = BIT(17),
306         IWL_CALIB_CFG_AGC_IDX                   = BIT(18),
307 };
308
309 /*
310  * Phy configuration command.
311  */
312 struct iwl_phy_cfg_cmd {
313         __le32  phy_cfg;
314         struct iwl_calib_ctrl calib_control;
315 } __packed;
316
317 #define PHY_CFG_RADIO_TYPE      (BIT(0) | BIT(1))
318 #define PHY_CFG_RADIO_STEP      (BIT(2) | BIT(3))
319 #define PHY_CFG_RADIO_DASH      (BIT(4) | BIT(5))
320 #define PHY_CFG_PRODUCT_NUMBER  (BIT(6) | BIT(7))
321 #define PHY_CFG_TX_CHAIN_A      BIT(8)
322 #define PHY_CFG_TX_CHAIN_B      BIT(9)
323 #define PHY_CFG_TX_CHAIN_C      BIT(10)
324 #define PHY_CFG_RX_CHAIN_A      BIT(12)
325 #define PHY_CFG_RX_CHAIN_B      BIT(13)
326 #define PHY_CFG_RX_CHAIN_C      BIT(14)
327
328
329 /* Target of the NVM_ACCESS_CMD */
330 enum {
331         NVM_ACCESS_TARGET_CACHE = 0,
332         NVM_ACCESS_TARGET_OTP = 1,
333         NVM_ACCESS_TARGET_EEPROM = 2,
334 };
335
336 /* Section types for NVM_ACCESS_CMD */
337 enum {
338         NVM_SECTION_TYPE_SW = 1,
339         NVM_SECTION_TYPE_REGULATORY = 3,
340         NVM_SECTION_TYPE_CALIBRATION = 4,
341         NVM_SECTION_TYPE_PRODUCTION = 5,
342         NVM_SECTION_TYPE_MAC_OVERRIDE = 11,
343         NVM_SECTION_TYPE_PHY_SKU = 12,
344         NVM_MAX_NUM_SECTIONS = 13,
345 };
346
347 /**
348  * struct iwl_nvm_access_cmd_ver2 - Request the device to send an NVM section
349  * @op_code: 0 - read, 1 - write
350  * @target: NVM_ACCESS_TARGET_*
351  * @type: NVM_SECTION_TYPE_*
352  * @offset: offset in bytes into the section
353  * @length: in bytes, to read/write
354  * @data: if write operation, the data to write. On read its empty
355  */
356 struct iwl_nvm_access_cmd {
357         u8 op_code;
358         u8 target;
359         __le16 type;
360         __le16 offset;
361         __le16 length;
362         u8 data[];
363 } __packed; /* NVM_ACCESS_CMD_API_S_VER_2 */
364
365 /**
366  * struct iwl_nvm_access_resp_ver2 - response to NVM_ACCESS_CMD
367  * @offset: offset in bytes into the section
368  * @length: in bytes, either how much was written or read
369  * @type: NVM_SECTION_TYPE_*
370  * @status: 0 for success, fail otherwise
371  * @data: if read operation, the data returned. Empty on write.
372  */
373 struct iwl_nvm_access_resp {
374         __le16 offset;
375         __le16 length;
376         __le16 type;
377         __le16 status;
378         u8 data[];
379 } __packed; /* NVM_ACCESS_CMD_RESP_API_S_VER_2 */
380
381 /* MVM_ALIVE 0x1 */
382
383 /* alive response is_valid values */
384 #define ALIVE_RESP_UCODE_OK     BIT(0)
385 #define ALIVE_RESP_RFKILL       BIT(1)
386
387 /* alive response ver_type values */
388 enum {
389         FW_TYPE_HW = 0,
390         FW_TYPE_PROT = 1,
391         FW_TYPE_AP = 2,
392         FW_TYPE_WOWLAN = 3,
393         FW_TYPE_TIMING = 4,
394         FW_TYPE_WIPAN = 5
395 };
396
397 /* alive response ver_subtype values */
398 enum {
399         FW_SUBTYPE_FULL_FEATURE = 0,
400         FW_SUBTYPE_BOOTSRAP = 1, /* Not valid */
401         FW_SUBTYPE_REDUCED = 2,
402         FW_SUBTYPE_ALIVE_ONLY = 3,
403         FW_SUBTYPE_WOWLAN = 4,
404         FW_SUBTYPE_AP_SUBTYPE = 5,
405         FW_SUBTYPE_WIPAN = 6,
406         FW_SUBTYPE_INITIALIZE = 9
407 };
408
409 #define IWL_ALIVE_STATUS_ERR 0xDEAD
410 #define IWL_ALIVE_STATUS_OK 0xCAFE
411
412 #define IWL_ALIVE_FLG_RFKILL    BIT(0)
413
414 struct mvm_alive_resp_ver1 {
415         __le16 status;
416         __le16 flags;
417         u8 ucode_minor;
418         u8 ucode_major;
419         __le16 id;
420         u8 api_minor;
421         u8 api_major;
422         u8 ver_subtype;
423         u8 ver_type;
424         u8 mac;
425         u8 opt;
426         __le16 reserved2;
427         __le32 timestamp;
428         __le32 error_event_table_ptr;   /* SRAM address for error log */
429         __le32 log_event_table_ptr;     /* SRAM address for event log */
430         __le32 cpu_register_ptr;
431         __le32 dbgm_config_ptr;
432         __le32 alive_counter_ptr;
433         __le32 scd_base_ptr;            /* SRAM address for SCD */
434 } __packed; /* ALIVE_RES_API_S_VER_1 */
435
436 struct mvm_alive_resp_ver2 {
437         __le16 status;
438         __le16 flags;
439         u8 ucode_minor;
440         u8 ucode_major;
441         __le16 id;
442         u8 api_minor;
443         u8 api_major;
444         u8 ver_subtype;
445         u8 ver_type;
446         u8 mac;
447         u8 opt;
448         __le16 reserved2;
449         __le32 timestamp;
450         __le32 error_event_table_ptr;   /* SRAM address for error log */
451         __le32 log_event_table_ptr;     /* SRAM address for LMAC event log */
452         __le32 cpu_register_ptr;
453         __le32 dbgm_config_ptr;
454         __le32 alive_counter_ptr;
455         __le32 scd_base_ptr;            /* SRAM address for SCD */
456         __le32 st_fwrd_addr;            /* pointer to Store and forward */
457         __le32 st_fwrd_size;
458         u8 umac_minor;                  /* UMAC version: minor */
459         u8 umac_major;                  /* UMAC version: major */
460         __le16 umac_id;                 /* UMAC version: id */
461         __le32 error_info_addr;         /* SRAM address for UMAC error log */
462         __le32 dbg_print_buff_addr;
463 } __packed; /* ALIVE_RES_API_S_VER_2 */
464
465 struct mvm_alive_resp {
466         __le16 status;
467         __le16 flags;
468         __le32 ucode_minor;
469         __le32 ucode_major;
470         u8 ver_subtype;
471         u8 ver_type;
472         u8 mac;
473         u8 opt;
474         __le32 timestamp;
475         __le32 error_event_table_ptr;   /* SRAM address for error log */
476         __le32 log_event_table_ptr;     /* SRAM address for LMAC event log */
477         __le32 cpu_register_ptr;
478         __le32 dbgm_config_ptr;
479         __le32 alive_counter_ptr;
480         __le32 scd_base_ptr;            /* SRAM address for SCD */
481         __le32 st_fwrd_addr;            /* pointer to Store and forward */
482         __le32 st_fwrd_size;
483         __le32 umac_minor;              /* UMAC version: minor */
484         __le32 umac_major;              /* UMAC version: major */
485         __le32 error_info_addr;         /* SRAM address for UMAC error log */
486         __le32 dbg_print_buff_addr;
487 } __packed; /* ALIVE_RES_API_S_VER_3 */
488
489 /* Error response/notification */
490 enum {
491         FW_ERR_UNKNOWN_CMD = 0x0,
492         FW_ERR_INVALID_CMD_PARAM = 0x1,
493         FW_ERR_SERVICE = 0x2,
494         FW_ERR_ARC_MEMORY = 0x3,
495         FW_ERR_ARC_CODE = 0x4,
496         FW_ERR_WATCH_DOG = 0x5,
497         FW_ERR_WEP_GRP_KEY_INDX = 0x10,
498         FW_ERR_WEP_KEY_SIZE = 0x11,
499         FW_ERR_OBSOLETE_FUNC = 0x12,
500         FW_ERR_UNEXPECTED = 0xFE,
501         FW_ERR_FATAL = 0xFF
502 };
503
504 /**
505  * struct iwl_error_resp - FW error indication
506  * ( REPLY_ERROR = 0x2 )
507  * @error_type: one of FW_ERR_*
508  * @cmd_id: the command ID for which the error occured
509  * @bad_cmd_seq_num: sequence number of the erroneous command
510  * @error_service: which service created the error, applicable only if
511  *      error_type = 2, otherwise 0
512  * @timestamp: TSF in usecs.
513  */
514 struct iwl_error_resp {
515         __le32 error_type;
516         u8 cmd_id;
517         u8 reserved1;
518         __le16 bad_cmd_seq_num;
519         __le32 error_service;
520         __le64 timestamp;
521 } __packed;
522
523
524 /* Common PHY, MAC and Bindings definitions */
525
526 #define MAX_MACS_IN_BINDING     (3)
527 #define MAX_BINDINGS            (4)
528 #define AUX_BINDING_INDEX       (3)
529 #define MAX_PHYS                (4)
530
531 /* Used to extract ID and color from the context dword */
532 #define FW_CTXT_ID_POS    (0)
533 #define FW_CTXT_ID_MSK    (0xff << FW_CTXT_ID_POS)
534 #define FW_CTXT_COLOR_POS (8)
535 #define FW_CTXT_COLOR_MSK (0xff << FW_CTXT_COLOR_POS)
536 #define FW_CTXT_INVALID   (0xffffffff)
537
538 #define FW_CMD_ID_AND_COLOR(_id, _color) ((_id << FW_CTXT_ID_POS) |\
539                                           (_color << FW_CTXT_COLOR_POS))
540
541 /* Possible actions on PHYs, MACs and Bindings */
542 enum {
543         FW_CTXT_ACTION_STUB = 0,
544         FW_CTXT_ACTION_ADD,
545         FW_CTXT_ACTION_MODIFY,
546         FW_CTXT_ACTION_REMOVE,
547         FW_CTXT_ACTION_NUM
548 }; /* COMMON_CONTEXT_ACTION_API_E_VER_1 */
549
550 /* Time Events */
551
552 /* Time Event types, according to MAC type */
553 enum iwl_time_event_type {
554         /* BSS Station Events */
555         TE_BSS_STA_AGGRESSIVE_ASSOC,
556         TE_BSS_STA_ASSOC,
557         TE_BSS_EAP_DHCP_PROT,
558         TE_BSS_QUIET_PERIOD,
559
560         /* P2P Device Events */
561         TE_P2P_DEVICE_DISCOVERABLE,
562         TE_P2P_DEVICE_LISTEN,
563         TE_P2P_DEVICE_ACTION_SCAN,
564         TE_P2P_DEVICE_FULL_SCAN,
565
566         /* P2P Client Events */
567         TE_P2P_CLIENT_AGGRESSIVE_ASSOC,
568         TE_P2P_CLIENT_ASSOC,
569         TE_P2P_CLIENT_QUIET_PERIOD,
570
571         /* P2P GO Events */
572         TE_P2P_GO_ASSOC_PROT,
573         TE_P2P_GO_REPETITIVE_NOA,
574         TE_P2P_GO_CT_WINDOW,
575
576         /* WiDi Sync Events */
577         TE_WIDI_TX_SYNC,
578
579         /* Channel Switch NoA */
580         TE_CHANNEL_SWITCH_PERIOD,
581
582         TE_MAX
583 }; /* MAC_EVENT_TYPE_API_E_VER_1 */
584
585
586
587 /* Time event - defines for command API v1 */
588
589 /*
590  * @TE_V1_FRAG_NONE: fragmentation of the time event is NOT allowed.
591  * @TE_V1_FRAG_SINGLE: fragmentation of the time event is allowed, but only
592  *      the first fragment is scheduled.
593  * @TE_V1_FRAG_DUAL: fragmentation of the time event is allowed, but only
594  *      the first 2 fragments are scheduled.
595  * @TE_V1_FRAG_ENDLESS: fragmentation of the time event is allowed, and any
596  *      number of fragments are valid.
597  *
598  * Other than the constant defined above, specifying a fragmentation value 'x'
599  * means that the event can be fragmented but only the first 'x' will be
600  * scheduled.
601  */
602 enum {
603         TE_V1_FRAG_NONE = 0,
604         TE_V1_FRAG_SINGLE = 1,
605         TE_V1_FRAG_DUAL = 2,
606         TE_V1_FRAG_ENDLESS = 0xffffffff
607 };
608
609 /* If a Time Event can be fragmented, this is the max number of fragments */
610 #define TE_V1_FRAG_MAX_MSK      0x0fffffff
611 /* Repeat the time event endlessly (until removed) */
612 #define TE_V1_REPEAT_ENDLESS    0xffffffff
613 /* If a Time Event has bounded repetitions, this is the maximal value */
614 #define TE_V1_REPEAT_MAX_MSK_V1 0x0fffffff
615
616 /* Time Event dependencies: none, on another TE, or in a specific time */
617 enum {
618         TE_V1_INDEPENDENT               = 0,
619         TE_V1_DEP_OTHER                 = BIT(0),
620         TE_V1_DEP_TSF                   = BIT(1),
621         TE_V1_EVENT_SOCIOPATHIC         = BIT(2),
622 }; /* MAC_EVENT_DEPENDENCY_POLICY_API_E_VER_2 */
623
624 /*
625  * @TE_V1_NOTIF_NONE: no notifications
626  * @TE_V1_NOTIF_HOST_EVENT_START: request/receive notification on event start
627  * @TE_V1_NOTIF_HOST_EVENT_END:request/receive notification on event end
628  * @TE_V1_NOTIF_INTERNAL_EVENT_START: internal FW use
629  * @TE_V1_NOTIF_INTERNAL_EVENT_END: internal FW use.
630  * @TE_V1_NOTIF_HOST_FRAG_START: request/receive notification on frag start
631  * @TE_V1_NOTIF_HOST_FRAG_END:request/receive notification on frag end
632  * @TE_V1_NOTIF_INTERNAL_FRAG_START: internal FW use.
633  * @TE_V1_NOTIF_INTERNAL_FRAG_END: internal FW use.
634  *
635  * Supported Time event notifications configuration.
636  * A notification (both event and fragment) includes a status indicating weather
637  * the FW was able to schedule the event or not. For fragment start/end
638  * notification the status is always success. There is no start/end fragment
639  * notification for monolithic events.
640  */
641 enum {
642         TE_V1_NOTIF_NONE = 0,
643         TE_V1_NOTIF_HOST_EVENT_START = BIT(0),
644         TE_V1_NOTIF_HOST_EVENT_END = BIT(1),
645         TE_V1_NOTIF_INTERNAL_EVENT_START = BIT(2),
646         TE_V1_NOTIF_INTERNAL_EVENT_END = BIT(3),
647         TE_V1_NOTIF_HOST_FRAG_START = BIT(4),
648         TE_V1_NOTIF_HOST_FRAG_END = BIT(5),
649         TE_V1_NOTIF_INTERNAL_FRAG_START = BIT(6),
650         TE_V1_NOTIF_INTERNAL_FRAG_END = BIT(7),
651 }; /* MAC_EVENT_ACTION_API_E_VER_2 */
652
653 /* Time event - defines for command API */
654
655 /*
656  * @TE_V2_FRAG_NONE: fragmentation of the time event is NOT allowed.
657  * @TE_V2_FRAG_SINGLE: fragmentation of the time event is allowed, but only
658  *  the first fragment is scheduled.
659  * @TE_V2_FRAG_DUAL: fragmentation of the time event is allowed, but only
660  *  the first 2 fragments are scheduled.
661  * @TE_V2_FRAG_ENDLESS: fragmentation of the time event is allowed, and any
662  *  number of fragments are valid.
663  *
664  * Other than the constant defined above, specifying a fragmentation value 'x'
665  * means that the event can be fragmented but only the first 'x' will be
666  * scheduled.
667  */
668 enum {
669         TE_V2_FRAG_NONE = 0,
670         TE_V2_FRAG_SINGLE = 1,
671         TE_V2_FRAG_DUAL = 2,
672         TE_V2_FRAG_MAX = 0xfe,
673         TE_V2_FRAG_ENDLESS = 0xff
674 };
675
676 /* Repeat the time event endlessly (until removed) */
677 #define TE_V2_REPEAT_ENDLESS    0xff
678 /* If a Time Event has bounded repetitions, this is the maximal value */
679 #define TE_V2_REPEAT_MAX        0xfe
680
681 #define TE_V2_PLACEMENT_POS     12
682 #define TE_V2_ABSENCE_POS       15
683
684 /* Time event policy values
685  * A notification (both event and fragment) includes a status indicating weather
686  * the FW was able to schedule the event or not. For fragment start/end
687  * notification the status is always success. There is no start/end fragment
688  * notification for monolithic events.
689  *
690  * @TE_V2_DEFAULT_POLICY: independent, social, present, unoticable
691  * @TE_V2_NOTIF_HOST_EVENT_START: request/receive notification on event start
692  * @TE_V2_NOTIF_HOST_EVENT_END:request/receive notification on event end
693  * @TE_V2_NOTIF_INTERNAL_EVENT_START: internal FW use
694  * @TE_V2_NOTIF_INTERNAL_EVENT_END: internal FW use.
695  * @TE_V2_NOTIF_HOST_FRAG_START: request/receive notification on frag start
696  * @TE_V2_NOTIF_HOST_FRAG_END:request/receive notification on frag end
697  * @TE_V2_NOTIF_INTERNAL_FRAG_START: internal FW use.
698  * @TE_V2_NOTIF_INTERNAL_FRAG_END: internal FW use.
699  * @TE_V2_DEP_OTHER: depends on another time event
700  * @TE_V2_DEP_TSF: depends on a specific time
701  * @TE_V2_EVENT_SOCIOPATHIC: can't co-exist with other events of tha same MAC
702  * @TE_V2_ABSENCE: are we present or absent during the Time Event.
703  */
704 enum {
705         TE_V2_DEFAULT_POLICY = 0x0,
706
707         /* notifications (event start/stop, fragment start/stop) */
708         TE_V2_NOTIF_HOST_EVENT_START = BIT(0),
709         TE_V2_NOTIF_HOST_EVENT_END = BIT(1),
710         TE_V2_NOTIF_INTERNAL_EVENT_START = BIT(2),
711         TE_V2_NOTIF_INTERNAL_EVENT_END = BIT(3),
712
713         TE_V2_NOTIF_HOST_FRAG_START = BIT(4),
714         TE_V2_NOTIF_HOST_FRAG_END = BIT(5),
715         TE_V2_NOTIF_INTERNAL_FRAG_START = BIT(6),
716         TE_V2_NOTIF_INTERNAL_FRAG_END = BIT(7),
717         T2_V2_START_IMMEDIATELY = BIT(11),
718
719         TE_V2_NOTIF_MSK = 0xff,
720
721         /* placement characteristics */
722         TE_V2_DEP_OTHER = BIT(TE_V2_PLACEMENT_POS),
723         TE_V2_DEP_TSF = BIT(TE_V2_PLACEMENT_POS + 1),
724         TE_V2_EVENT_SOCIOPATHIC = BIT(TE_V2_PLACEMENT_POS + 2),
725
726         /* are we present or absent during the Time Event. */
727         TE_V2_ABSENCE = BIT(TE_V2_ABSENCE_POS),
728 };
729
730 /**
731  * struct iwl_time_event_cmd_api - configuring Time Events
732  * with struct MAC_TIME_EVENT_DATA_API_S_VER_2 (see also
733  * with version 1. determined by IWL_UCODE_TLV_FLAGS)
734  * ( TIME_EVENT_CMD = 0x29 )
735  * @id_and_color: ID and color of the relevant MAC
736  * @action: action to perform, one of FW_CTXT_ACTION_*
737  * @id: this field has two meanings, depending on the action:
738  *      If the action is ADD, then it means the type of event to add.
739  *      For all other actions it is the unique event ID assigned when the
740  *      event was added by the FW.
741  * @apply_time: When to start the Time Event (in GP2)
742  * @max_delay: maximum delay to event's start (apply time), in TU
743  * @depends_on: the unique ID of the event we depend on (if any)
744  * @interval: interval between repetitions, in TU
745  * @duration: duration of event in TU
746  * @repeat: how many repetitions to do, can be TE_REPEAT_ENDLESS
747  * @max_frags: maximal number of fragments the Time Event can be divided to
748  * @policy: defines whether uCode shall notify the host or other uCode modules
749  *      on event and/or fragment start and/or end
750  *      using one of TE_INDEPENDENT, TE_DEP_OTHER, TE_DEP_TSF
751  *      TE_EVENT_SOCIOPATHIC
752  *      using TE_ABSENCE and using TE_NOTIF_*
753  */
754 struct iwl_time_event_cmd {
755         /* COMMON_INDEX_HDR_API_S_VER_1 */
756         __le32 id_and_color;
757         __le32 action;
758         __le32 id;
759         /* MAC_TIME_EVENT_DATA_API_S_VER_2 */
760         __le32 apply_time;
761         __le32 max_delay;
762         __le32 depends_on;
763         __le32 interval;
764         __le32 duration;
765         u8 repeat;
766         u8 max_frags;
767         __le16 policy;
768 } __packed; /* MAC_TIME_EVENT_CMD_API_S_VER_2 */
769
770 /**
771  * struct iwl_time_event_resp - response structure to iwl_time_event_cmd
772  * @status: bit 0 indicates success, all others specify errors
773  * @id: the Time Event type
774  * @unique_id: the unique ID assigned (in ADD) or given (others) to the TE
775  * @id_and_color: ID and color of the relevant MAC
776  */
777 struct iwl_time_event_resp {
778         __le32 status;
779         __le32 id;
780         __le32 unique_id;
781         __le32 id_and_color;
782 } __packed; /* MAC_TIME_EVENT_RSP_API_S_VER_1 */
783
784 /**
785  * struct iwl_time_event_notif - notifications of time event start/stop
786  * ( TIME_EVENT_NOTIFICATION = 0x2a )
787  * @timestamp: action timestamp in GP2
788  * @session_id: session's unique id
789  * @unique_id: unique id of the Time Event itself
790  * @id_and_color: ID and color of the relevant MAC
791  * @action: one of TE_NOTIF_START or TE_NOTIF_END
792  * @status: true if scheduled, false otherwise (not executed)
793  */
794 struct iwl_time_event_notif {
795         __le32 timestamp;
796         __le32 session_id;
797         __le32 unique_id;
798         __le32 id_and_color;
799         __le32 action;
800         __le32 status;
801 } __packed; /* MAC_TIME_EVENT_NTFY_API_S_VER_1 */
802
803
804 /* Bindings and Time Quota */
805
806 /**
807  * struct iwl_binding_cmd - configuring bindings
808  * ( BINDING_CONTEXT_CMD = 0x2b )
809  * @id_and_color: ID and color of the relevant Binding
810  * @action: action to perform, one of FW_CTXT_ACTION_*
811  * @macs: array of MAC id and colors which belong to the binding
812  * @phy: PHY id and color which belongs to the binding
813  */
814 struct iwl_binding_cmd {
815         /* COMMON_INDEX_HDR_API_S_VER_1 */
816         __le32 id_and_color;
817         __le32 action;
818         /* BINDING_DATA_API_S_VER_1 */
819         __le32 macs[MAX_MACS_IN_BINDING];
820         __le32 phy;
821 } __packed; /* BINDING_CMD_API_S_VER_1 */
822
823 /* The maximal number of fragments in the FW's schedule session */
824 #define IWL_MVM_MAX_QUOTA 128
825
826 /**
827  * struct iwl_time_quota_data - configuration of time quota per binding
828  * @id_and_color: ID and color of the relevant Binding
829  * @quota: absolute time quota in TU. The scheduler will try to divide the
830  *      remainig quota (after Time Events) according to this quota.
831  * @max_duration: max uninterrupted context duration in TU
832  */
833 struct iwl_time_quota_data {
834         __le32 id_and_color;
835         __le32 quota;
836         __le32 max_duration;
837 } __packed; /* TIME_QUOTA_DATA_API_S_VER_1 */
838
839 /**
840  * struct iwl_time_quota_cmd - configuration of time quota between bindings
841  * ( TIME_QUOTA_CMD = 0x2c )
842  * @quotas: allocations per binding
843  */
844 struct iwl_time_quota_cmd {
845         struct iwl_time_quota_data quotas[MAX_BINDINGS];
846 } __packed; /* TIME_QUOTA_ALLOCATION_CMD_API_S_VER_1 */
847
848
849 /* PHY context */
850
851 /* Supported bands */
852 #define PHY_BAND_5  (0)
853 #define PHY_BAND_24 (1)
854
855 /* Supported channel width, vary if there is VHT support */
856 #define PHY_VHT_CHANNEL_MODE20  (0x0)
857 #define PHY_VHT_CHANNEL_MODE40  (0x1)
858 #define PHY_VHT_CHANNEL_MODE80  (0x2)
859 #define PHY_VHT_CHANNEL_MODE160 (0x3)
860
861 /*
862  * Control channel position:
863  * For legacy set bit means upper channel, otherwise lower.
864  * For VHT - bit-2 marks if the control is lower/upper relative to center-freq
865  *   bits-1:0 mark the distance from the center freq. for 20Mhz, offset is 0.
866  *                                   center_freq
867  *                                        |
868  * 40Mhz                          |_______|_______|
869  * 80Mhz                  |_______|_______|_______|_______|
870  * 160Mhz |_______|_______|_______|_______|_______|_______|_______|_______|
871  * code      011     010     001     000  |  100     101     110    111
872  */
873 #define PHY_VHT_CTRL_POS_1_BELOW  (0x0)
874 #define PHY_VHT_CTRL_POS_2_BELOW  (0x1)
875 #define PHY_VHT_CTRL_POS_3_BELOW  (0x2)
876 #define PHY_VHT_CTRL_POS_4_BELOW  (0x3)
877 #define PHY_VHT_CTRL_POS_1_ABOVE  (0x4)
878 #define PHY_VHT_CTRL_POS_2_ABOVE  (0x5)
879 #define PHY_VHT_CTRL_POS_3_ABOVE  (0x6)
880 #define PHY_VHT_CTRL_POS_4_ABOVE  (0x7)
881
882 /*
883  * @band: PHY_BAND_*
884  * @channel: channel number
885  * @width: PHY_[VHT|LEGACY]_CHANNEL_*
886  * @ctrl channel: PHY_[VHT|LEGACY]_CTRL_*
887  */
888 struct iwl_fw_channel_info {
889         u8 band;
890         u8 channel;
891         u8 width;
892         u8 ctrl_pos;
893 } __packed;
894
895 #define PHY_RX_CHAIN_DRIVER_FORCE_POS   (0)
896 #define PHY_RX_CHAIN_DRIVER_FORCE_MSK \
897         (0x1 << PHY_RX_CHAIN_DRIVER_FORCE_POS)
898 #define PHY_RX_CHAIN_VALID_POS          (1)
899 #define PHY_RX_CHAIN_VALID_MSK \
900         (0x7 << PHY_RX_CHAIN_VALID_POS)
901 #define PHY_RX_CHAIN_FORCE_SEL_POS      (4)
902 #define PHY_RX_CHAIN_FORCE_SEL_MSK \
903         (0x7 << PHY_RX_CHAIN_FORCE_SEL_POS)
904 #define PHY_RX_CHAIN_FORCE_MIMO_SEL_POS (7)
905 #define PHY_RX_CHAIN_FORCE_MIMO_SEL_MSK \
906         (0x7 << PHY_RX_CHAIN_FORCE_MIMO_SEL_POS)
907 #define PHY_RX_CHAIN_CNT_POS            (10)
908 #define PHY_RX_CHAIN_CNT_MSK \
909         (0x3 << PHY_RX_CHAIN_CNT_POS)
910 #define PHY_RX_CHAIN_MIMO_CNT_POS       (12)
911 #define PHY_RX_CHAIN_MIMO_CNT_MSK \
912         (0x3 << PHY_RX_CHAIN_MIMO_CNT_POS)
913 #define PHY_RX_CHAIN_MIMO_FORCE_POS     (14)
914 #define PHY_RX_CHAIN_MIMO_FORCE_MSK \
915         (0x1 << PHY_RX_CHAIN_MIMO_FORCE_POS)
916
917 /* TODO: fix the value, make it depend on firmware at runtime? */
918 #define NUM_PHY_CTX     3
919
920 /* TODO: complete missing documentation */
921 /**
922  * struct iwl_phy_context_cmd - config of the PHY context
923  * ( PHY_CONTEXT_CMD = 0x8 )
924  * @id_and_color: ID and color of the relevant Binding
925  * @action: action to perform, one of FW_CTXT_ACTION_*
926  * @apply_time: 0 means immediate apply and context switch.
927  *      other value means apply new params after X usecs
928  * @tx_param_color: ???
929  * @channel_info:
930  * @txchain_info: ???
931  * @rxchain_info: ???
932  * @acquisition_data: ???
933  * @dsp_cfg_flags: set to 0
934  */
935 struct iwl_phy_context_cmd {
936         /* COMMON_INDEX_HDR_API_S_VER_1 */
937         __le32 id_and_color;
938         __le32 action;
939         /* PHY_CONTEXT_DATA_API_S_VER_1 */
940         __le32 apply_time;
941         __le32 tx_param_color;
942         struct iwl_fw_channel_info ci;
943         __le32 txchain_info;
944         __le32 rxchain_info;
945         __le32 acquisition_data;
946         __le32 dsp_cfg_flags;
947 } __packed; /* PHY_CONTEXT_CMD_API_VER_1 */
948
949 /*
950  * Aux ROC command
951  *
952  * Command requests the firmware to create a time event for a certain duration
953  * and remain on the given channel. This is done by using the Aux framework in
954  * the FW.
955  * The command was first used for Hot Spot issues - but can be used regardless
956  * to Hot Spot.
957  *
958  * ( HOT_SPOT_CMD 0x53 )
959  *
960  * @id_and_color: ID and color of the MAC
961  * @action: action to perform, one of FW_CTXT_ACTION_*
962  * @event_unique_id: If the action FW_CTXT_ACTION_REMOVE then the
963  *      event_unique_id should be the id of the time event assigned by ucode.
964  *      Otherwise ignore the event_unique_id.
965  * @sta_id_and_color: station id and color, resumed during "Remain On Channel"
966  *      activity.
967  * @channel_info: channel info
968  * @node_addr: Our MAC Address
969  * @reserved: reserved for alignment
970  * @apply_time: GP2 value to start (should always be the current GP2 value)
971  * @apply_time_max_delay: Maximum apply time delay value in TU. Defines max
972  *      time by which start of the event is allowed to be postponed.
973  * @duration: event duration in TU To calculate event duration:
974  *      timeEventDuration = min(duration, remainingQuota)
975  */
976 struct iwl_hs20_roc_req {
977         /* COMMON_INDEX_HDR_API_S_VER_1 hdr */
978         __le32 id_and_color;
979         __le32 action;
980         __le32 event_unique_id;
981         __le32 sta_id_and_color;
982         struct iwl_fw_channel_info channel_info;
983         u8 node_addr[ETH_ALEN];
984         __le16 reserved;
985         __le32 apply_time;
986         __le32 apply_time_max_delay;
987         __le32 duration;
988 } __packed; /* HOT_SPOT_CMD_API_S_VER_1 */
989
990 /*
991  * values for AUX ROC result values
992  */
993 enum iwl_mvm_hot_spot {
994         HOT_SPOT_RSP_STATUS_OK,
995         HOT_SPOT_RSP_STATUS_TOO_MANY_EVENTS,
996         HOT_SPOT_MAX_NUM_OF_SESSIONS,
997 };
998
999 /*
1000  * Aux ROC command response
1001  *
1002  * In response to iwl_hs20_roc_req the FW sends this command to notify the
1003  * driver the uid of the timevent.
1004  *
1005  * ( HOT_SPOT_CMD 0x53 )
1006  *
1007  * @event_unique_id: Unique ID of time event assigned by ucode
1008  * @status: Return status 0 is success, all the rest used for specific errors
1009  */
1010 struct iwl_hs20_roc_res {
1011         __le32 event_unique_id;
1012         __le32 status;
1013 } __packed; /* HOT_SPOT_RSP_API_S_VER_1 */
1014
1015 #define IWL_RX_INFO_PHY_CNT 8
1016 #define IWL_RX_INFO_ENERGY_ANT_ABC_IDX 1
1017 #define IWL_RX_INFO_ENERGY_ANT_A_MSK 0x000000ff
1018 #define IWL_RX_INFO_ENERGY_ANT_B_MSK 0x0000ff00
1019 #define IWL_RX_INFO_ENERGY_ANT_C_MSK 0x00ff0000
1020 #define IWL_RX_INFO_ENERGY_ANT_A_POS 0
1021 #define IWL_RX_INFO_ENERGY_ANT_B_POS 8
1022 #define IWL_RX_INFO_ENERGY_ANT_C_POS 16
1023
1024 #define IWL_RX_INFO_AGC_IDX 1
1025 #define IWL_RX_INFO_RSSI_AB_IDX 2
1026 #define IWL_OFDM_AGC_A_MSK 0x0000007f
1027 #define IWL_OFDM_AGC_A_POS 0
1028 #define IWL_OFDM_AGC_B_MSK 0x00003f80
1029 #define IWL_OFDM_AGC_B_POS 7
1030 #define IWL_OFDM_AGC_CODE_MSK 0x3fe00000
1031 #define IWL_OFDM_AGC_CODE_POS 20
1032 #define IWL_OFDM_RSSI_INBAND_A_MSK 0x00ff
1033 #define IWL_OFDM_RSSI_A_POS 0
1034 #define IWL_OFDM_RSSI_ALLBAND_A_MSK 0xff00
1035 #define IWL_OFDM_RSSI_ALLBAND_A_POS 8
1036 #define IWL_OFDM_RSSI_INBAND_B_MSK 0xff0000
1037 #define IWL_OFDM_RSSI_B_POS 16
1038 #define IWL_OFDM_RSSI_ALLBAND_B_MSK 0xff000000
1039 #define IWL_OFDM_RSSI_ALLBAND_B_POS 24
1040
1041 /**
1042  * struct iwl_rx_phy_info - phy info
1043  * (REPLY_RX_PHY_CMD = 0xc0)
1044  * @non_cfg_phy_cnt: non configurable DSP phy data byte count
1045  * @cfg_phy_cnt: configurable DSP phy data byte count
1046  * @stat_id: configurable DSP phy data set ID
1047  * @reserved1:
1048  * @system_timestamp: GP2  at on air rise
1049  * @timestamp: TSF at on air rise
1050  * @beacon_time_stamp: beacon at on-air rise
1051  * @phy_flags: general phy flags: band, modulation, ...
1052  * @channel: channel number
1053  * @non_cfg_phy_buf: for various implementations of non_cfg_phy
1054  * @rate_n_flags: RATE_MCS_*
1055  * @byte_count: frame's byte-count
1056  * @frame_time: frame's time on the air, based on byte count and frame rate
1057  *      calculation
1058  * @mac_active_msk: what MACs were active when the frame was received
1059  *
1060  * Before each Rx, the device sends this data. It contains PHY information
1061  * about the reception of the packet.
1062  */
1063 struct iwl_rx_phy_info {
1064         u8 non_cfg_phy_cnt;
1065         u8 cfg_phy_cnt;
1066         u8 stat_id;
1067         u8 reserved1;
1068         __le32 system_timestamp;
1069         __le64 timestamp;
1070         __le32 beacon_time_stamp;
1071         __le16 phy_flags;
1072         __le16 channel;
1073         __le32 non_cfg_phy[IWL_RX_INFO_PHY_CNT];
1074         __le32 rate_n_flags;
1075         __le32 byte_count;
1076         __le16 mac_active_msk;
1077         __le16 frame_time;
1078 } __packed;
1079
1080 struct iwl_rx_mpdu_res_start {
1081         __le16 byte_count;
1082         __le16 reserved;
1083 } __packed;
1084
1085 /**
1086  * enum iwl_rx_phy_flags - to parse %iwl_rx_phy_info phy_flags
1087  * @RX_RES_PHY_FLAGS_BAND_24: true if the packet was received on 2.4 band
1088  * @RX_RES_PHY_FLAGS_MOD_CCK:
1089  * @RX_RES_PHY_FLAGS_SHORT_PREAMBLE: true if packet's preamble was short
1090  * @RX_RES_PHY_FLAGS_NARROW_BAND:
1091  * @RX_RES_PHY_FLAGS_ANTENNA: antenna on which the packet was received
1092  * @RX_RES_PHY_FLAGS_AGG: set if the packet was part of an A-MPDU
1093  * @RX_RES_PHY_FLAGS_OFDM_HT: The frame was an HT frame
1094  * @RX_RES_PHY_FLAGS_OFDM_GF: The frame used GF preamble
1095  * @RX_RES_PHY_FLAGS_OFDM_VHT: The frame was a VHT frame
1096  */
1097 enum iwl_rx_phy_flags {
1098         RX_RES_PHY_FLAGS_BAND_24        = BIT(0),
1099         RX_RES_PHY_FLAGS_MOD_CCK        = BIT(1),
1100         RX_RES_PHY_FLAGS_SHORT_PREAMBLE = BIT(2),
1101         RX_RES_PHY_FLAGS_NARROW_BAND    = BIT(3),
1102         RX_RES_PHY_FLAGS_ANTENNA        = (0x7 << 4),
1103         RX_RES_PHY_FLAGS_ANTENNA_POS    = 4,
1104         RX_RES_PHY_FLAGS_AGG            = BIT(7),
1105         RX_RES_PHY_FLAGS_OFDM_HT        = BIT(8),
1106         RX_RES_PHY_FLAGS_OFDM_GF        = BIT(9),
1107         RX_RES_PHY_FLAGS_OFDM_VHT       = BIT(10),
1108 };
1109
1110 /**
1111  * enum iwl_mvm_rx_status - written by fw for each Rx packet
1112  * @RX_MPDU_RES_STATUS_CRC_OK: CRC is fine
1113  * @RX_MPDU_RES_STATUS_OVERRUN_OK: there was no RXE overflow
1114  * @RX_MPDU_RES_STATUS_SRC_STA_FOUND:
1115  * @RX_MPDU_RES_STATUS_KEY_VALID:
1116  * @RX_MPDU_RES_STATUS_KEY_PARAM_OK:
1117  * @RX_MPDU_RES_STATUS_ICV_OK: ICV is fine, if not, the packet is destroyed
1118  * @RX_MPDU_RES_STATUS_MIC_OK: used for CCM alg only. TKIP MIC is checked
1119  *      in the driver.
1120  * @RX_MPDU_RES_STATUS_TTAK_OK: TTAK is fine
1121  * @RX_MPDU_RES_STATUS_MNG_FRAME_REPLAY_ERR:  valid for alg = CCM_CMAC or
1122  *      alg = CCM only. Checks replay attack for 11w frames. Relevant only if
1123  *      %RX_MPDU_RES_STATUS_ROBUST_MNG_FRAME is set.
1124  * @RX_MPDU_RES_STATUS_SEC_NO_ENC: this frame is not encrypted
1125  * @RX_MPDU_RES_STATUS_SEC_WEP_ENC: this frame is encrypted using WEP
1126  * @RX_MPDU_RES_STATUS_SEC_CCM_ENC: this frame is encrypted using CCM
1127  * @RX_MPDU_RES_STATUS_SEC_TKIP_ENC: this frame is encrypted using TKIP
1128  * @RX_MPDU_RES_STATUS_SEC_CCM_CMAC_ENC: this frame is encrypted using CCM_CMAC
1129  * @RX_MPDU_RES_STATUS_SEC_ENC_ERR: this frame couldn't be decrypted
1130  * @RX_MPDU_RES_STATUS_SEC_ENC_MSK: bitmask of the encryption algorithm
1131  * @RX_MPDU_RES_STATUS_DEC_DONE: this frame has been successfully decrypted
1132  * @RX_MPDU_RES_STATUS_PROTECT_FRAME_BIT_CMP:
1133  * @RX_MPDU_RES_STATUS_EXT_IV_BIT_CMP:
1134  * @RX_MPDU_RES_STATUS_KEY_ID_CMP_BIT:
1135  * @RX_MPDU_RES_STATUS_ROBUST_MNG_FRAME: this frame is an 11w management frame
1136  * @RX_MPDU_RES_STATUS_HASH_INDEX_MSK:
1137  * @RX_MPDU_RES_STATUS_STA_ID_MSK:
1138  * @RX_MPDU_RES_STATUS_RRF_KILL:
1139  * @RX_MPDU_RES_STATUS_FILTERING_MSK:
1140  * @RX_MPDU_RES_STATUS2_FILTERING_MSK:
1141  */
1142 enum iwl_mvm_rx_status {
1143         RX_MPDU_RES_STATUS_CRC_OK                       = BIT(0),
1144         RX_MPDU_RES_STATUS_OVERRUN_OK                   = BIT(1),
1145         RX_MPDU_RES_STATUS_SRC_STA_FOUND                = BIT(2),
1146         RX_MPDU_RES_STATUS_KEY_VALID                    = BIT(3),
1147         RX_MPDU_RES_STATUS_KEY_PARAM_OK                 = BIT(4),
1148         RX_MPDU_RES_STATUS_ICV_OK                       = BIT(5),
1149         RX_MPDU_RES_STATUS_MIC_OK                       = BIT(6),
1150         RX_MPDU_RES_STATUS_TTAK_OK                      = BIT(7),
1151         RX_MPDU_RES_STATUS_MNG_FRAME_REPLAY_ERR         = BIT(7),
1152         RX_MPDU_RES_STATUS_SEC_NO_ENC                   = (0 << 8),
1153         RX_MPDU_RES_STATUS_SEC_WEP_ENC                  = (1 << 8),
1154         RX_MPDU_RES_STATUS_SEC_CCM_ENC                  = (2 << 8),
1155         RX_MPDU_RES_STATUS_SEC_TKIP_ENC                 = (3 << 8),
1156         RX_MPDU_RES_STATUS_SEC_EXT_ENC                  = (4 << 8),
1157         RX_MPDU_RES_STATUS_SEC_CCM_CMAC_ENC             = (6 << 8),
1158         RX_MPDU_RES_STATUS_SEC_ENC_ERR                  = (7 << 8),
1159         RX_MPDU_RES_STATUS_SEC_ENC_MSK                  = (7 << 8),
1160         RX_MPDU_RES_STATUS_DEC_DONE                     = BIT(11),
1161         RX_MPDU_RES_STATUS_PROTECT_FRAME_BIT_CMP        = BIT(12),
1162         RX_MPDU_RES_STATUS_EXT_IV_BIT_CMP               = BIT(13),
1163         RX_MPDU_RES_STATUS_KEY_ID_CMP_BIT               = BIT(14),
1164         RX_MPDU_RES_STATUS_ROBUST_MNG_FRAME             = BIT(15),
1165         RX_MPDU_RES_STATUS_HASH_INDEX_MSK               = (0x3F0000),
1166         RX_MPDU_RES_STATUS_STA_ID_MSK                   = (0x1f000000),
1167         RX_MPDU_RES_STATUS_RRF_KILL                     = BIT(29),
1168         RX_MPDU_RES_STATUS_FILTERING_MSK                = (0xc00000),
1169         RX_MPDU_RES_STATUS2_FILTERING_MSK               = (0xc0000000),
1170 };
1171
1172 /**
1173  * struct iwl_radio_version_notif - information on the radio version
1174  * ( RADIO_VERSION_NOTIFICATION = 0x68 )
1175  * @radio_flavor:
1176  * @radio_step:
1177  * @radio_dash:
1178  */
1179 struct iwl_radio_version_notif {
1180         __le32 radio_flavor;
1181         __le32 radio_step;
1182         __le32 radio_dash;
1183 } __packed; /* RADIO_VERSION_NOTOFICATION_S_VER_1 */
1184
1185 enum iwl_card_state_flags {
1186         CARD_ENABLED            = 0x00,
1187         HW_CARD_DISABLED        = 0x01,
1188         SW_CARD_DISABLED        = 0x02,
1189         CT_KILL_CARD_DISABLED   = 0x04,
1190         HALT_CARD_DISABLED      = 0x08,
1191         CARD_DISABLED_MSK       = 0x0f,
1192         CARD_IS_RX_ON           = 0x10,
1193 };
1194
1195 /**
1196  * struct iwl_radio_version_notif - information on the radio version
1197  * ( CARD_STATE_NOTIFICATION = 0xa1 )
1198  * @flags: %iwl_card_state_flags
1199  */
1200 struct iwl_card_state_notif {
1201         __le32 flags;
1202 } __packed; /* CARD_STATE_NTFY_API_S_VER_1 */
1203
1204 /**
1205  * struct iwl_missed_beacons_notif - information on missed beacons
1206  * ( MISSED_BEACONS_NOTIFICATION = 0xa2 )
1207  * @mac_id: interface ID
1208  * @consec_missed_beacons_since_last_rx: number of consecutive missed
1209  *      beacons since last RX.
1210  * @consec_missed_beacons: number of consecutive missed beacons
1211  * @num_expected_beacons:
1212  * @num_recvd_beacons:
1213  */
1214 struct iwl_missed_beacons_notif {
1215         __le32 mac_id;
1216         __le32 consec_missed_beacons_since_last_rx;
1217         __le32 consec_missed_beacons;
1218         __le32 num_expected_beacons;
1219         __le32 num_recvd_beacons;
1220 } __packed; /* MISSED_BEACON_NTFY_API_S_VER_3 */
1221
1222 /**
1223  * struct iwl_mfuart_load_notif - mfuart image version & status
1224  * ( MFUART_LOAD_NOTIFICATION = 0xb1 )
1225  * @installed_ver: installed image version
1226  * @external_ver: external image version
1227  * @status: MFUART loading status
1228  * @duration: MFUART loading time
1229 */
1230 struct iwl_mfuart_load_notif {
1231         __le32 installed_ver;
1232         __le32 external_ver;
1233         __le32 status;
1234         __le32 duration;
1235 } __packed; /*MFU_LOADER_NTFY_API_S_VER_1*/
1236
1237 /**
1238  * struct iwl_set_calib_default_cmd - set default value for calibration.
1239  * ( SET_CALIB_DEFAULT_CMD = 0x8e )
1240  * @calib_index: the calibration to set value for
1241  * @length: of data
1242  * @data: the value to set for the calibration result
1243  */
1244 struct iwl_set_calib_default_cmd {
1245         __le16 calib_index;
1246         __le16 length;
1247         u8 data[0];
1248 } __packed; /* PHY_CALIB_OVERRIDE_VALUES_S */
1249
1250 #define MAX_PORT_ID_NUM 2
1251 #define MAX_MCAST_FILTERING_ADDRESSES 256
1252
1253 /**
1254  * struct iwl_mcast_filter_cmd - configure multicast filter.
1255  * @filter_own: Set 1 to filter out multicast packets sent by station itself
1256  * @port_id:    Multicast MAC addresses array specifier. This is a strange way
1257  *              to identify network interface adopted in host-device IF.
1258  *              It is used by FW as index in array of addresses. This array has
1259  *              MAX_PORT_ID_NUM members.
1260  * @count:      Number of MAC addresses in the array
1261  * @pass_all:   Set 1 to pass all multicast packets.
1262  * @bssid:      current association BSSID.
1263  * @addr_list:  Place holder for array of MAC addresses.
1264  *              IMPORTANT: add padding if necessary to ensure DWORD alignment.
1265  */
1266 struct iwl_mcast_filter_cmd {
1267         u8 filter_own;
1268         u8 port_id;
1269         u8 count;
1270         u8 pass_all;
1271         u8 bssid[6];
1272         u8 reserved[2];
1273         u8 addr_list[0];
1274 } __packed; /* MCAST_FILTERING_CMD_API_S_VER_1 */
1275
1276 #define MAX_BCAST_FILTERS 8
1277 #define MAX_BCAST_FILTER_ATTRS 2
1278
1279 /**
1280  * enum iwl_mvm_bcast_filter_attr_offset - written by fw for each Rx packet
1281  * @BCAST_FILTER_OFFSET_PAYLOAD_START: offset is from payload start.
1282  * @BCAST_FILTER_OFFSET_IP_END: offset is from ip header end (i.e.
1283  *      start of ip payload).
1284  */
1285 enum iwl_mvm_bcast_filter_attr_offset {
1286         BCAST_FILTER_OFFSET_PAYLOAD_START = 0,
1287         BCAST_FILTER_OFFSET_IP_END = 1,
1288 };
1289
1290 /**
1291  * struct iwl_fw_bcast_filter_attr - broadcast filter attribute
1292  * @offset_type:        &enum iwl_mvm_bcast_filter_attr_offset.
1293  * @offset:     starting offset of this pattern.
1294  * @val:                value to match - big endian (MSB is the first
1295  *              byte to match from offset pos).
1296  * @mask:       mask to match (big endian).
1297  */
1298 struct iwl_fw_bcast_filter_attr {
1299         u8 offset_type;
1300         u8 offset;
1301         __le16 reserved1;
1302         __be32 val;
1303         __be32 mask;
1304 } __packed; /* BCAST_FILTER_ATT_S_VER_1 */
1305
1306 /**
1307  * enum iwl_mvm_bcast_filter_frame_type - filter frame type
1308  * @BCAST_FILTER_FRAME_TYPE_ALL: consider all frames.
1309  * @BCAST_FILTER_FRAME_TYPE_IPV4: consider only ipv4 frames
1310  */
1311 enum iwl_mvm_bcast_filter_frame_type {
1312         BCAST_FILTER_FRAME_TYPE_ALL = 0,
1313         BCAST_FILTER_FRAME_TYPE_IPV4 = 1,
1314 };
1315
1316 /**
1317  * struct iwl_fw_bcast_filter - broadcast filter
1318  * @discard: discard frame (1) or let it pass (0).
1319  * @frame_type: &enum iwl_mvm_bcast_filter_frame_type.
1320  * @num_attrs: number of valid attributes in this filter.
1321  * @attrs: attributes of this filter. a filter is considered matched
1322  *      only when all its attributes are matched (i.e. AND relationship)
1323  */
1324 struct iwl_fw_bcast_filter {
1325         u8 discard;
1326         u8 frame_type;
1327         u8 num_attrs;
1328         u8 reserved1;
1329         struct iwl_fw_bcast_filter_attr attrs[MAX_BCAST_FILTER_ATTRS];
1330 } __packed; /* BCAST_FILTER_S_VER_1 */
1331
1332 /**
1333  * struct iwl_fw_bcast_mac - per-mac broadcast filtering configuration.
1334  * @default_discard: default action for this mac (discard (1) / pass (0)).
1335  * @attached_filters: bitmap of relevant filters for this mac.
1336  */
1337 struct iwl_fw_bcast_mac {
1338         u8 default_discard;
1339         u8 reserved1;
1340         __le16 attached_filters;
1341 } __packed; /* BCAST_MAC_CONTEXT_S_VER_1 */
1342
1343 /**
1344  * struct iwl_bcast_filter_cmd - broadcast filtering configuration
1345  * @disable: enable (0) / disable (1)
1346  * @max_bcast_filters: max number of filters (MAX_BCAST_FILTERS)
1347  * @max_macs: max number of macs (NUM_MAC_INDEX_DRIVER)
1348  * @filters: broadcast filters
1349  * @macs: broadcast filtering configuration per-mac
1350  */
1351 struct iwl_bcast_filter_cmd {
1352         u8 disable;
1353         u8 max_bcast_filters;
1354         u8 max_macs;
1355         u8 reserved1;
1356         struct iwl_fw_bcast_filter filters[MAX_BCAST_FILTERS];
1357         struct iwl_fw_bcast_mac macs[NUM_MAC_INDEX_DRIVER];
1358 } __packed; /* BCAST_FILTERING_HCMD_API_S_VER_1 */
1359
1360 /*
1361  * enum iwl_mvm_marker_id - maker ids
1362  *
1363  * The ids for different type of markers to insert into the usniffer logs
1364  */
1365 enum iwl_mvm_marker_id {
1366         MARKER_ID_TX_FRAME_LATENCY = 1,
1367 }; /* MARKER_ID_API_E_VER_1 */
1368
1369 /**
1370  * struct iwl_mvm_marker - mark info into the usniffer logs
1371  *
1372  * (MARKER_CMD = 0xcb)
1373  *
1374  * Mark the UTC time stamp into the usniffer logs together with additional
1375  * metadata, so the usniffer output can be parsed.
1376  * In the command response the ucode will return the GP2 time.
1377  *
1378  * @dw_len: The amount of dwords following this byte including this byte.
1379  * @marker_id: A unique marker id (iwl_mvm_marker_id).
1380  * @reserved: reserved.
1381  * @timestamp: in milliseconds since 1970-01-01 00:00:00 UTC
1382  * @metadata: additional meta data that will be written to the unsiffer log
1383  */
1384 struct iwl_mvm_marker {
1385         u8 dwLen;
1386         u8 markerId;
1387         __le16 reserved;
1388         __le64 timestamp;
1389         __le32 metadata[0];
1390 } __packed; /* MARKER_API_S_VER_1 */
1391
1392 /***********************************
1393  * Smart Fifo API
1394  ***********************************/
1395 /* Smart Fifo state */
1396 enum iwl_sf_state {
1397         SF_LONG_DELAY_ON = 0, /* should never be called by driver */
1398         SF_FULL_ON,
1399         SF_UNINIT,
1400         SF_INIT_OFF,
1401         SF_HW_NUM_STATES
1402 };
1403
1404 /* Smart Fifo possible scenario */
1405 enum iwl_sf_scenario {
1406         SF_SCENARIO_SINGLE_UNICAST,
1407         SF_SCENARIO_AGG_UNICAST,
1408         SF_SCENARIO_MULTICAST,
1409         SF_SCENARIO_BA_RESP,
1410         SF_SCENARIO_TX_RESP,
1411         SF_NUM_SCENARIO
1412 };
1413
1414 #define SF_TRANSIENT_STATES_NUMBER 2    /* SF_LONG_DELAY_ON and SF_FULL_ON */
1415 #define SF_NUM_TIMEOUT_TYPES 2          /* Aging timer and Idle timer */
1416
1417 /* smart FIFO default values */
1418 #define SF_W_MARK_SISO 6144
1419 #define SF_W_MARK_MIMO2 8192
1420 #define SF_W_MARK_MIMO3 6144
1421 #define SF_W_MARK_LEGACY 4096
1422 #define SF_W_MARK_SCAN 4096
1423
1424 /* SF Scenarios timers for default configuration (aligned to 32 uSec) */
1425 #define SF_SINGLE_UNICAST_IDLE_TIMER_DEF 160    /* 150 uSec  */
1426 #define SF_SINGLE_UNICAST_AGING_TIMER_DEF 400   /* 0.4 mSec */
1427 #define SF_AGG_UNICAST_IDLE_TIMER_DEF 160               /* 150 uSec */
1428 #define SF_AGG_UNICAST_AGING_TIMER_DEF 400              /* 0.4 mSec */
1429 #define SF_MCAST_IDLE_TIMER_DEF 160             /* 150 mSec */
1430 #define SF_MCAST_AGING_TIMER_DEF 400            /* 0.4 mSec */
1431 #define SF_BA_IDLE_TIMER_DEF 160                        /* 150 uSec */
1432 #define SF_BA_AGING_TIMER_DEF 400                       /* 0.4 mSec */
1433 #define SF_TX_RE_IDLE_TIMER_DEF 160                     /* 150 uSec */
1434 #define SF_TX_RE_AGING_TIMER_DEF 400            /* 0.4 mSec */
1435
1436 /* SF Scenarios timers for BSS MAC configuration (aligned to 32 uSec) */
1437 #define SF_SINGLE_UNICAST_IDLE_TIMER 320        /* 300 uSec  */
1438 #define SF_SINGLE_UNICAST_AGING_TIMER 2016      /* 2 mSec */
1439 #define SF_AGG_UNICAST_IDLE_TIMER 320           /* 300 uSec */
1440 #define SF_AGG_UNICAST_AGING_TIMER 2016         /* 2 mSec */
1441 #define SF_MCAST_IDLE_TIMER 2016                /* 2 mSec */
1442 #define SF_MCAST_AGING_TIMER 10016              /* 10 mSec */
1443 #define SF_BA_IDLE_TIMER 320                    /* 300 uSec */
1444 #define SF_BA_AGING_TIMER 2016                  /* 2 mSec */
1445 #define SF_TX_RE_IDLE_TIMER 320                 /* 300 uSec */
1446 #define SF_TX_RE_AGING_TIMER 2016               /* 2 mSec */
1447
1448 #define SF_LONG_DELAY_AGING_TIMER 1000000       /* 1 Sec */
1449
1450 #define SF_CFG_DUMMY_NOTIF_OFF  BIT(16)
1451
1452 /**
1453  * Smart Fifo configuration command.
1454  * @state: smart fifo state, types listed in enum %iwl_sf_sate.
1455  * @watermark: Minimum allowed availabe free space in RXF for transient state.
1456  * @long_delay_timeouts: aging and idle timer values for each scenario
1457  * in long delay state.
1458  * @full_on_timeouts: timer values for each scenario in full on state.
1459  */
1460 struct iwl_sf_cfg_cmd {
1461         __le32 state;
1462         __le32 watermark[SF_TRANSIENT_STATES_NUMBER];
1463         __le32 long_delay_timeouts[SF_NUM_SCENARIO][SF_NUM_TIMEOUT_TYPES];
1464         __le32 full_on_timeouts[SF_NUM_SCENARIO][SF_NUM_TIMEOUT_TYPES];
1465 } __packed; /* SF_CFG_API_S_VER_2 */
1466
1467 /***********************************
1468  * Location Aware Regulatory (LAR) API - MCC updates
1469  ***********************************/
1470
1471 /**
1472  * struct iwl_mcc_update_cmd - Request the device to update geographic
1473  * regulatory profile according to the given MCC (Mobile Country Code).
1474  * The MCC is two letter-code, ascii upper case[A-Z] or '00' for world domain.
1475  * 'ZZ' MCC will be used to switch to NVM default profile; in this case, the
1476  * MCC in the cmd response will be the relevant MCC in the NVM.
1477  * @mcc: given mobile country code
1478  * @source_id: the source from where we got the MCC, see iwl_mcc_source
1479  * @reserved: reserved for alignment
1480  */
1481 struct iwl_mcc_update_cmd {
1482         __le16 mcc;
1483         u8 source_id;
1484         u8 reserved;
1485 } __packed; /* LAR_UPDATE_MCC_CMD_API_S */
1486
1487 /**
1488  * iwl_mcc_update_resp - response to MCC_UPDATE_CMD.
1489  * Contains the new channel control profile map, if changed, and the new MCC
1490  * (mobile country code).
1491  * The new MCC may be different than what was requested in MCC_UPDATE_CMD.
1492  * @status: see &enum iwl_mcc_update_status
1493  * @mcc: the new applied MCC
1494  * @cap: capabilities for all channels which matches the MCC
1495  * @source_id: the MCC source, see iwl_mcc_source
1496  * @n_channels: number of channels in @channels_data (may be 14, 39, 50 or 51
1497  *              channels, depending on platform)
1498  * @channels: channel control data map, DWORD for each channel. Only the first
1499  *      16bits are used.
1500  */
1501 struct iwl_mcc_update_resp {
1502         __le32 status;
1503         __le16 mcc;
1504         u8 cap;
1505         u8 source_id;
1506         __le32 n_channels;
1507         __le32 channels[0];
1508 } __packed; /* LAR_UPDATE_MCC_CMD_RESP_S */
1509
1510 /**
1511  * struct iwl_mcc_chub_notif - chub notifies of mcc change
1512  * (MCC_CHUB_UPDATE_CMD = 0xc9)
1513  * The Chub (Communication Hub, CommsHUB) is a HW component that connects to
1514  * the cellular and connectivity cores that gets updates of the mcc, and
1515  * notifies the ucode directly of any mcc change.
1516  * The ucode requests the driver to request the device to update geographic
1517  * regulatory  profile according to the given MCC (Mobile Country Code).
1518  * The MCC is two letter-code, ascii upper case[A-Z] or '00' for world domain.
1519  * 'ZZ' MCC will be used to switch to NVM default profile; in this case, the
1520  * MCC in the cmd response will be the relevant MCC in the NVM.
1521  * @mcc: given mobile country code
1522  * @source_id: identity of the change originator, see iwl_mcc_source
1523  * @reserved1: reserved for alignment
1524  */
1525 struct iwl_mcc_chub_notif {
1526         u16 mcc;
1527         u8 source_id;
1528         u8 reserved1;
1529 } __packed; /* LAR_MCC_NOTIFY_S */
1530
1531 enum iwl_mcc_update_status {
1532         MCC_RESP_NEW_CHAN_PROFILE,
1533         MCC_RESP_SAME_CHAN_PROFILE,
1534         MCC_RESP_INVALID,
1535         MCC_RESP_NVM_DISABLED,
1536         MCC_RESP_ILLEGAL,
1537         MCC_RESP_LOW_PRIORITY,
1538 };
1539
1540 enum iwl_mcc_source {
1541         MCC_SOURCE_OLD_FW = 0,
1542         MCC_SOURCE_ME = 1,
1543         MCC_SOURCE_BIOS = 2,
1544         MCC_SOURCE_3G_LTE_HOST = 3,
1545         MCC_SOURCE_3G_LTE_DEVICE = 4,
1546         MCC_SOURCE_WIFI = 5,
1547         MCC_SOURCE_RESERVED = 6,
1548         MCC_SOURCE_DEFAULT = 7,
1549         MCC_SOURCE_UNINITIALIZED = 8,
1550         MCC_SOURCE_GET_CURRENT = 0x10
1551 };
1552
1553 /* DTS measurements */
1554
1555 enum iwl_dts_measurement_flags {
1556         DTS_TRIGGER_CMD_FLAGS_TEMP      = BIT(0),
1557         DTS_TRIGGER_CMD_FLAGS_VOLT      = BIT(1),
1558 };
1559
1560 /**
1561  * iwl_dts_measurement_cmd - request DTS temperature and/or voltage measurements
1562  *
1563  * @flags: indicates which measurements we want as specified in &enum
1564  *         iwl_dts_measurement_flags
1565  */
1566 struct iwl_dts_measurement_cmd {
1567         __le32 flags;
1568 } __packed; /* TEMPERATURE_MEASUREMENT_TRIGGER_CMD_S */
1569
1570 /**
1571  * iwl_dts_measurement_notif - notification received with the measurements
1572  *
1573  * @temp: the measured temperature
1574  * @voltage: the measured voltage
1575  */
1576 struct iwl_dts_measurement_notif {
1577         __le32 temp;
1578         __le32 voltage;
1579 } __packed; /* TEMPERATURE_MEASUREMENT_TRIGGER_NTFY_S */
1580
1581 /***********************************
1582  * TDLS API
1583  ***********************************/
1584
1585 /* Type of TDLS request */
1586 enum iwl_tdls_channel_switch_type {
1587         TDLS_SEND_CHAN_SW_REQ = 0,
1588         TDLS_SEND_CHAN_SW_RESP_AND_MOVE_CH,
1589         TDLS_MOVE_CH,
1590 }; /* TDLS_STA_CHANNEL_SWITCH_CMD_TYPE_API_E_VER_1 */
1591
1592 /**
1593  * Switch timing sub-element in a TDLS channel-switch command
1594  * @frame_timestamp: GP2 timestamp of channel-switch request/response packet
1595  *      received from peer
1596  * @max_offchan_duration: What amount of microseconds out of a DTIM is given
1597  *      to the TDLS off-channel communication. For instance if the DTIM is
1598  *      200TU and the TDLS peer is to be given 25% of the time, the value
1599  *      given will be 50TU, or 50 * 1024 if translated into microseconds.
1600  * @switch_time: switch time the peer sent in its channel switch timing IE
1601  * @switch_timout: switch timeout the peer sent in its channel switch timing IE
1602  */
1603 struct iwl_tdls_channel_switch_timing {
1604         __le32 frame_timestamp; /* GP2 time of peer packet Rx */
1605         __le32 max_offchan_duration; /* given in micro-seconds */
1606         __le32 switch_time; /* given in micro-seconds */
1607         __le32 switch_timeout; /* given in micro-seconds */
1608 } __packed; /* TDLS_STA_CHANNEL_SWITCH_TIMING_DATA_API_S_VER_1 */
1609
1610 #define IWL_TDLS_CH_SW_FRAME_MAX_SIZE 200
1611
1612 /**
1613  * TDLS channel switch frame template
1614  *
1615  * A template representing a TDLS channel-switch request or response frame
1616  *
1617  * @switch_time_offset: offset to the channel switch timing IE in the template
1618  * @tx_cmd: Tx parameters for the frame
1619  * @data: frame data
1620  */
1621 struct iwl_tdls_channel_switch_frame {
1622         __le32 switch_time_offset;
1623         struct iwl_tx_cmd tx_cmd;
1624         u8 data[IWL_TDLS_CH_SW_FRAME_MAX_SIZE];
1625 } __packed; /* TDLS_STA_CHANNEL_SWITCH_FRAME_API_S_VER_1 */
1626
1627 /**
1628  * TDLS channel switch command
1629  *
1630  * The command is sent to initiate a channel switch and also in response to
1631  * incoming TDLS channel-switch request/response packets from remote peers.
1632  *
1633  * @switch_type: see &enum iwl_tdls_channel_switch_type
1634  * @peer_sta_id: station id of TDLS peer
1635  * @ci: channel we switch to
1636  * @timing: timing related data for command
1637  * @frame: channel-switch request/response template, depending to switch_type
1638  */
1639 struct iwl_tdls_channel_switch_cmd {
1640         u8 switch_type;
1641         __le32 peer_sta_id;
1642         struct iwl_fw_channel_info ci;
1643         struct iwl_tdls_channel_switch_timing timing;
1644         struct iwl_tdls_channel_switch_frame frame;
1645 } __packed; /* TDLS_STA_CHANNEL_SWITCH_CMD_API_S_VER_1 */
1646
1647 /**
1648  * TDLS channel switch start notification
1649  *
1650  * @status: non-zero on success
1651  * @offchannel_duration: duration given in microseconds
1652  * @sta_id: peer currently performing the channel-switch with
1653  */
1654 struct iwl_tdls_channel_switch_notif {
1655         __le32 status;
1656         __le32 offchannel_duration;
1657         __le32 sta_id;
1658 } __packed; /* TDLS_STA_CHANNEL_SWITCH_NTFY_API_S_VER_1 */
1659
1660 /**
1661  * TDLS station info
1662  *
1663  * @sta_id: station id of the TDLS peer
1664  * @tx_to_peer_tid: TID reserved vs. the peer for FW based Tx
1665  * @tx_to_peer_ssn: initial SSN the FW should use for Tx on its TID vs the peer
1666  * @is_initiator: 1 if the peer is the TDLS link initiator, 0 otherwise
1667  */
1668 struct iwl_tdls_sta_info {
1669         u8 sta_id;
1670         u8 tx_to_peer_tid;
1671         __le16 tx_to_peer_ssn;
1672         __le32 is_initiator;
1673 } __packed; /* TDLS_STA_INFO_VER_1 */
1674
1675 /**
1676  * TDLS basic config command
1677  *
1678  * @id_and_color: MAC id and color being configured
1679  * @tdls_peer_count: amount of currently connected TDLS peers
1680  * @tx_to_ap_tid: TID reverved vs. the AP for FW based Tx
1681  * @tx_to_ap_ssn: initial SSN the FW should use for Tx on its TID vs. the AP
1682  * @sta_info: per-station info. Only the first tdls_peer_count entries are set
1683  * @pti_req_data_offset: offset of network-level data for the PTI template
1684  * @pti_req_tx_cmd: Tx parameters for PTI request template
1685  * @pti_req_template: PTI request template data
1686  */
1687 struct iwl_tdls_config_cmd {
1688         __le32 id_and_color; /* mac id and color */
1689         u8 tdls_peer_count;
1690         u8 tx_to_ap_tid;
1691         __le16 tx_to_ap_ssn;
1692         struct iwl_tdls_sta_info sta_info[IWL_MVM_TDLS_STA_COUNT];
1693
1694         __le32 pti_req_data_offset;
1695         struct iwl_tx_cmd pti_req_tx_cmd;
1696         u8 pti_req_template[0];
1697 } __packed; /* TDLS_CONFIG_CMD_API_S_VER_1 */
1698
1699 /**
1700  * TDLS per-station config information from FW
1701  *
1702  * @sta_id: station id of the TDLS peer
1703  * @tx_to_peer_last_seq: last sequence number used by FW during FW-based Tx to
1704  *      the peer
1705  */
1706 struct iwl_tdls_config_sta_info_res {
1707         __le16 sta_id;
1708         __le16 tx_to_peer_last_seq;
1709 } __packed; /* TDLS_STA_INFO_RSP_VER_1 */
1710
1711 /**
1712  * TDLS config information from FW
1713  *
1714  * @tx_to_ap_last_seq: last sequence number used by FW during FW-based Tx to AP
1715  * @sta_info: per-station TDLS config information
1716  */
1717 struct iwl_tdls_config_res {
1718         __le32 tx_to_ap_last_seq;
1719         struct iwl_tdls_config_sta_info_res sta_info[IWL_MVM_TDLS_STA_COUNT];
1720 } __packed; /* TDLS_CONFIG_RSP_API_S_VER_1 */
1721
1722 #define TX_FIFO_MAX_NUM         8
1723 #define RX_FIFO_MAX_NUM         2
1724
1725 /**
1726  * Shared memory configuration information from the FW
1727  *
1728  * @shared_mem_addr: shared memory addr (pre 8000 HW set to 0x0 as MARBH is not
1729  *      accessible)
1730  * @shared_mem_size: shared memory size
1731  * @sample_buff_addr: internal sample (mon/adc) buff addr (pre 8000 HW set to
1732  *      0x0 as accessible only via DBGM RDAT)
1733  * @sample_buff_size: internal sample buff size
1734  * @txfifo_addr: start addr of TXF0 (excluding the context table 0.5KB), (pre
1735  *      8000 HW set to 0x0 as not accessible)
1736  * @txfifo_size: size of TXF0 ... TXF7
1737  * @rxfifo_size: RXF1, RXF2 sizes. If there is no RXF2, it'll have a value of 0
1738  * @page_buff_addr: used by UMAC and performance debug (page miss analysis),
1739  *      when paging is not supported this should be 0
1740  * @page_buff_size: size of %page_buff_addr
1741  */
1742 struct iwl_shared_mem_cfg {
1743         __le32 shared_mem_addr;
1744         __le32 shared_mem_size;
1745         __le32 sample_buff_addr;
1746         __le32 sample_buff_size;
1747         __le32 txfifo_addr;
1748         __le32 txfifo_size[TX_FIFO_MAX_NUM];
1749         __le32 rxfifo_size[RX_FIFO_MAX_NUM];
1750         __le32 page_buff_addr;
1751         __le32 page_buff_size;
1752 } __packed; /* SHARED_MEM_ALLOC_API_S_VER_1 */
1753
1754 #endif /* __fw_api_h__ */