iwl-commands.h revision bf3c7fddf9dffb0e5c76da3a94b8f5817a72f92c
1b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
2b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
3b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * This file is provided under a dual BSD/GPLv2 license.  When using or
4b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * redistributing this file, you may do so under either license.
5b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
6b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * GPL LICENSE SUMMARY
7b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
81f44780827c6bbbcd1f12d5c6b6ce84f49a96bc0Reinette Chatre * Copyright(c) 2005 - 2010 Intel Corporation. All rights reserved.
9b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
10b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * This program is free software; you can redistribute it and/or modify
1101ebd063e11bdcf1ddc605d968ea89aef48e34e0Ian Schram * it under the terms of version 2 of the GNU General Public License as
12b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * published by the Free Software Foundation.
13b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
14b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * This program is distributed in the hope that it will be useful, but
15b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * WITHOUT ANY WARRANTY; without even the implied warranty of
16b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * General Public License for more details.
18b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
19b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * You should have received a copy of the GNU General Public License
20b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * along with this program; if not, write to the Free Software
21b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
22b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * USA
23b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
24b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * The full GNU General Public License is included in this distribution
25b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * in the file called LICENSE.GPL.
26b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
27b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Contact Information:
28759ef89fb096c4a6ef078d3cfd5682ac037bd789Winkler, Tomas *  Intel Linux Wireless <ilw@linux.intel.com>
29b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
30b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
31b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * BSD LICENSE
32b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
331f44780827c6bbbcd1f12d5c6b6ce84f49a96bc0Reinette Chatre * Copyright(c) 2005 - 2010 Intel Corporation. All rights reserved.
34b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * All rights reserved.
35b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
36b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Redistribution and use in source and binary forms, with or without
37b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * modification, are permitted provided that the following conditions
38b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * are met:
39b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
40b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *  * Redistributions of source code must retain the above copyright
41b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *    notice, this list of conditions and the following disclaimer.
42b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *  * Redistributions in binary form must reproduce the above copyright
43b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *    notice, this list of conditions and the following disclaimer in
44b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *    the documentation and/or other materials provided with the
45b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *    distribution.
46b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *  * Neither the name Intel Corporation nor the names of its
47b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *    contributors may be used to endorse or promote products derived
48b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *    from this software without specific prior written permission.
49b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
50b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
51b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
52b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
53b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
54b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
56b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
57b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
58b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
59b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
60b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
61b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
62b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
63fcd427bbba10fc315d1c958b85bba74448db4eb4Ben M Cahill/*
645a36ba0e412a0e12a8bf2648a075226c1dd7870dTomas Winkler * Please use this file (iwl-commands.h) only for uCode API definitions.
65fcd427bbba10fc315d1c958b85bba74448db4eb4Ben M Cahill * Please use iwl-4965-hw.h for hardware-related definitions.
663e0d4cb12f6fd97193a455b49125398b2231c87cTomas Winkler * Please use iwl-dev.h for driver implementation definitions.
67fcd427bbba10fc315d1c958b85bba74448db4eb4Ben M Cahill */
68b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
696a63578ddf6148927a80c07a73b40ccc8f3ac8e2Emmanuel Grumbach#ifndef __iwl_commands_h__
706a63578ddf6148927a80c07a73b40ccc8f3ac8e2Emmanuel Grumbach#define __iwl_commands_h__
71b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
72a3139c5956702c9ff957ac9fe2d902de355b063eSamuel Ortizstruct iwl_priv;
73a3139c5956702c9ff957ac9fe2d902de355b063eSamuel Ortiz
74c02b3acd29766c6f79c2411cb5b85e1ee72c4c8fChatre, Reinette/* uCode version contains 4 values: Major/Minor/API/Serial */
75c02b3acd29766c6f79c2411cb5b85e1ee72c4c8fChatre, Reinette#define IWL_UCODE_MAJOR(ver)	(((ver) & 0xFF000000) >> 24)
76c02b3acd29766c6f79c2411cb5b85e1ee72c4c8fChatre, Reinette#define IWL_UCODE_MINOR(ver)	(((ver) & 0x00FF0000) >> 16)
77c02b3acd29766c6f79c2411cb5b85e1ee72c4c8fChatre, Reinette#define IWL_UCODE_API(ver)	(((ver) & 0x0000FF00) >> 8)
78c02b3acd29766c6f79c2411cb5b85e1ee72c4c8fChatre, Reinette#define IWL_UCODE_SERIAL(ver)	((ver) & 0x000000FF)
79c02b3acd29766c6f79c2411cb5b85e1ee72c4c8fChatre, Reinette
804c897253cc9ae1c6a2798b27b5fe8e6d94ab6185Tomas Winkler
814c897253cc9ae1c6a2798b27b5fe8e6d94ab6185Tomas Winkler/* Tx rates */
824c897253cc9ae1c6a2798b27b5fe8e6d94ab6185Tomas Winkler#define IWL_CCK_RATES	4
834c897253cc9ae1c6a2798b27b5fe8e6d94ab6185Tomas Winkler#define IWL_OFDM_RATES	8
844c897253cc9ae1c6a2798b27b5fe8e6d94ab6185Tomas Winkler#define IWL_MAX_RATES	(IWL_CCK_RATES + IWL_OFDM_RATES)
854c897253cc9ae1c6a2798b27b5fe8e6d94ab6185Tomas Winkler
86b481de9ca074528fe8c429604e2777db8b89806aZhu Yienum {
87b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_ALIVE = 0x1,
88b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_ERROR = 0x2,
89b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
90b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* RXON and QOS commands */
91b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_RXON = 0x10,
92b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_RXON_ASSOC = 0x11,
93b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_QOS_PARAM = 0x13,
94b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_RXON_TIMING = 0x14,
95b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
96b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* Multi-Station support */
97b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_ADD_STA = 0x18,
98b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_REMOVE_STA = 0x19,
99b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_REMOVE_ALL_STA = 0x1a,	/* not used */
100b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_TXFIFO_FLUSH = 0x1e,
1010a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach
1020a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach	/* Security */
1030a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach	REPLY_WEPKEY = 0x20,
104b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1052aa6ab86bc475a115f56645591d2413981846509Tomas Winkler	/* RX, TX, LEDs */
106b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_3945_RX = 0x1b,           /* 3945 only */
107b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_TX = 0x1c,
108b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_RATE_SCALE = 0x47,	/* 3945 only */
1094c8d1913ac1baab64080c1030cb94e24cbd9a0f8Wey-Yi Guy	REPLY_LEDS_CMD = 0x48,
110b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_TX_LINK_QUALITY_CMD = 0x4e, /* for 4965 and up */
1119636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky
112d23000cd8992823e06ca0745564f2c25fe923ce4Wey-Yi Guy	/* WiMAX coexistence */
1139636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_PRIORITY_TABLE_CMD = 0x5a,	/* for 5000 series and up */
1149636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_MEDIUM_NOTIFICATION = 0x5b,
1159636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_EVENT_CMD = 0x5c,
116be5d56ed885a2897ec813eab4a8055d495816e9aTomas Winkler
1171a5c3d61993f56daf15c35bea8d3943f4e835638Jay Sternberg	/* Calibration */
118be5d56ed885a2897ec813eab4a8055d495816e9aTomas Winkler	TEMPERATURE_NOTIFICATION = 0x62,
119be5d56ed885a2897ec813eab4a8055d495816e9aTomas Winkler	CALIBRATION_CFG_CMD = 0x65,
120be5d56ed885a2897ec813eab4a8055d495816e9aTomas Winkler	CALIBRATION_RES_NOTIFICATION = 0x66,
121be5d56ed885a2897ec813eab4a8055d495816e9aTomas Winkler	CALIBRATION_COMPLETE_NOTIFICATION = 0x67,
122b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
123b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* 802.11h related */
124b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_QUIET_CMD = 0x71,		/* not used */
125b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_CHANNEL_SWITCH = 0x72,
126b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	CHANNEL_SWITCH_NOTIFICATION = 0x73,
127b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74,
128b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	SPECTRUM_MEASURE_NOTIFICATION = 0x75,
129b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
130b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* Power Management */
131b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	POWER_TABLE_CMD = 0x77,
132b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	PM_SLEEP_NOTIFICATION = 0x7A,
133b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	PM_DEBUG_STATISTIC_NOTIFIC = 0x7B,
134b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
135b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* Scan commands and notifications */
136b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_SCAN_CMD = 0x80,
137b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_SCAN_ABORT_CMD = 0x81,
138b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	SCAN_START_NOTIFICATION = 0x82,
139b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	SCAN_RESULTS_NOTIFICATION = 0x83,
140b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	SCAN_COMPLETE_NOTIFICATION = 0x84,
141b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
142b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* IBSS/AP commands */
143b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	BEACON_NOTIFICATION = 0x90,
144b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_TX_BEACON = 0x91,
145b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	WHO_IS_AWAKE_NOTIFICATION = 0x94,	/* not used */
146b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
14776a2407a5b043d0950d5657184118e89860d545cJay Sternberg	/* Miscellaneous commands */
148b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_TX_POWER_DBM_CMD = 0x95,
149b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	QUIET_NOTIFICATION = 0x96,		/* not used */
15076a2407a5b043d0950d5657184118e89860d545cJay Sternberg	REPLY_TX_PWR_TABLE_CMD = 0x97,
1512f748deceee10bac563df0e859830cc628d1a841Wey-Yi Guy	REPLY_TX_POWER_DBM_CMD_V1 = 0x98,	/* old version of API */
152b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_ANT_CONFIGURATION_CMD = 0x98,
153b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	MEASURE_ABORT_NOTIFICATION = 0x99,	/* not used */
154a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler
155b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* Bluetooth device coexistence config command */
156b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_BT_CONFIG = 0x9b,
15780cc0c382db318de88577eff027d5c4097abef81Ben M Cahill
158b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* Statistics */
159b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_STATISTICS_CMD = 0x9c,
160b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	STATISTICS_NOTIFICATION = 0x9d,
161b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
162b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* RF-KILL commands and notifications */
163b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_CARD_STATE_CMD = 0xa0,
164b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	CARD_STATE_NOTIFICATION = 0xa1,
165b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
166b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* Missed beacons notification */
167b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	MISSED_BEACONS_NOTIFICATION = 0xa2,
168b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
169b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_CT_KILL_CONFIG_CMD = 0xa4,
170b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	SENSITIVITY_CMD = 0xa8,
171b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_PHY_CALIBRATION_CMD = 0xb0,
172b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_RX_PHY_CMD = 0xc0,
173857485c0c46ceee5c658c1761bba4d9a5ddf433fTomas Winkler	REPLY_RX_MPDU_CMD = 0xc1,
174b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_RX = 0xc3,
175b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_COMPRESSED_BA = 0xc5,
176b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_MAX = 0xff
177b481de9ca074528fe8c429604e2777db8b89806aZhu Yi};
178b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
179b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
180abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill * (0)
18180cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * Commonly used structures and definitions:
182b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Command header, rate_n_flags, txpower
183b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
184b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
185857485c0c46ceee5c658c1761bba4d9a5ddf433fTomas Winkler
186b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* iwl_cmd_header flags value */
187b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define IWL_CMD_FAILED_MSK 0x40
1889734cb23a02f8de5fa99225ca61c7019ca9f232fTomas Winkler
1899734cb23a02f8de5fa99225ca61c7019ca9f232fTomas Winkler#define SEQ_TO_QUEUE(s)	(((s) >> 8) & 0x1f)
1909734cb23a02f8de5fa99225ca61c7019ca9f232fTomas Winkler#define QUEUE_TO_SEQ(q)	(((q) & 0x1f) << 8)
1919734cb23a02f8de5fa99225ca61c7019ca9f232fTomas Winkler#define SEQ_TO_INDEX(s)	((s) & 0xff)
19251e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define INDEX_TO_SEQ(i)	((i) & 0xff)
19351e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define SEQ_HUGE_FRAME	cpu_to_le16(0x4000)
1949734cb23a02f8de5fa99225ca61c7019ca9f232fTomas Winkler#define SEQ_RX_FRAME	cpu_to_le16(0x8000)
195075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill
196857485c0c46ceee5c658c1761bba4d9a5ddf433fTomas Winkler/**
197075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * struct iwl_cmd_header
198075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *
199075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * This header format appears in the beginning of each command sent from the
200075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * driver, and each response/notification received from uCode.
201857485c0c46ceee5c658c1761bba4d9a5ddf433fTomas Winkler */
202075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahillstruct iwl_cmd_header {
2039734cb23a02f8de5fa99225ca61c7019ca9f232fTomas Winkler	u8 cmd;		/* Command ID:  REPLY_RXON, etc. */
204075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	u8 flags;	/* 0:5 reserved, 6 abort, 7 internal */
205a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler	/*
206075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	 * The driver sets up the sequence number to values of its choosing.
207075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	 * uCode does not use this value, but passes it back to the driver
208075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	 * when sending the response to each driver-originated command, so
209075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	 * the driver can match the response to the command.  Since the values
210b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * don't get used by uCode, the driver may set up an arbitrary format.
211075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	 *
212075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	 * There is one exception:  uCode sets bit 15 when it originates
213075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	 * the response/notification, i.e. when the response/notification
214075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	 * is not a direct response to a command sent by the driver.  For
215075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	 * example, uCode issues REPLY_3945_RX when it sends a received frame
216b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * to the driver; it is not a direct response to any driver command.
217075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	 *
218075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	 * The Linux driver uses the following format:
2199734cb23a02f8de5fa99225ca61c7019ca9f232fTomas Winkler	 *
2209734cb23a02f8de5fa99225ca61c7019ca9f232fTomas Winkler	 *  0:7		tfd index - position within TX queue
2219734cb23a02f8de5fa99225ca61c7019ca9f232fTomas Winkler	 *  8:12	TX queue id
2229734cb23a02f8de5fa99225ca61c7019ca9f232fTomas Winkler	 *  13		reserved
2239734cb23a02f8de5fa99225ca61c7019ca9f232fTomas Winkler	 *  14		huge - driver sets this to indicate command is in the
2249734cb23a02f8de5fa99225ca61c7019ca9f232fTomas Winkler	 *  		'huge' storage at the end of the command buffers
225b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 *  15		unsolicited RX or uCode-originated notification
226b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 */
227b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 sequence;
228075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill
229b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* command or response/notification data follows immediately */
230b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 data[0];
231b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2323d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
2333d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
2343d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler/**
2353d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * struct iwl3945_tx_power
2363d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler *
2373d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * Used in REPLY_TX_PWR_TABLE_CMD, REPLY_SCAN_CMD, REPLY_CHANNEL_SWITCH
2383d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler *
2393d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * Each entry contains two values:
2403d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * 1)  DSP gain (or sometimes called DSP attenuation).  This is a fine-grained
2413d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler *     linear value that multiplies the output of the digital signal processor,
2423d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler *     before being sent to the analog radio.
2433d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * 2)  Radio gain.  This sets the analog gain of the radio Tx path.
2443d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler *     It is a coarser setting, and behaves in a logarithmic (dB) fashion.
2453d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler *
2463d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * Driver obtains values from struct iwl3945_tx_power power_gain_table[][].
2473d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler */
2483d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_tx_power {
2493d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 tx_gain;		/* gain for analog radio */
2503d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 dsp_atten;		/* gain for DSP */
2513d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler} __attribute__ ((packed));
2523d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
2533d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler/**
2543d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * struct iwl3945_power_per_rate
2553d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler *
2563d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * Used in REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH
2573d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler */
2583d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_power_per_rate {
2593d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 rate;		/* plcp */
2603d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct iwl3945_tx_power tpc;
2613d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 reserved;
2623d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler} __attribute__ ((packed));
263abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill
2645c5aa3f13a50881b8f6e529e321bbefb5faec37bHalperin, Daniel C/**
265abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill * iwlagn rate_n_flags bit fields
2665c5aa3f13a50881b8f6e529e321bbefb5faec37bHalperin, Daniel C *
267857485c0c46ceee5c658c1761bba4d9a5ddf433fTomas Winkler * rate_n_flags format is used in following iwlagn commands:
2685c5aa3f13a50881b8f6e529e321bbefb5faec37bHalperin, Daniel C *  REPLY_RX (response only)
269abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *  REPLY_RX_MPDU (response only)
270abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *  REPLY_TX (both command and response)
271abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *  REPLY_TX_LINK_QUALITY_CMD
272abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *
273abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill * High-throughput (HT) rate format for bits 7:0 (bit 8 must be "1"):
274abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *  2-0:  0)   6 Mbps
275abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *        1)  12 Mbps
276abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *        2)  18 Mbps
277abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *        3)  24 Mbps
278abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *        4)  36 Mbps
279abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *        5)  48 Mbps
280abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *        6)  54 Mbps
281abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *        7)  60 Mbps
2825c5aa3f13a50881b8f6e529e321bbefb5faec37bHalperin, Daniel C *
283abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *  4-3:  0)  Single stream (SISO)
2845c5aa3f13a50881b8f6e529e321bbefb5faec37bHalperin, Daniel C *        1)  Dual stream (MIMO)
285abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *        2)  Triple stream (MIMO)
2867aafef1c6e2e24f9a10dc2972bf0ee70624ccc47Wey-Yi Guy *
287abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *    5:  Value of 0x20 in bits 7:0 indicates 6 Mbps HT40 duplicate data
288abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *
289abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill * Legacy OFDM rate format for bits 7:0 (bit 8 must be "0", bit 9 "0"):
290abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *  3-0:  0xD)   6 Mbps
291abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *        0xF)   9 Mbps
292abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *        0x5)  12 Mbps
293abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *        0x7)  18 Mbps
294abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *        0x9)  24 Mbps
295abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *        0xB)  36 Mbps
296abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *        0x1)  48 Mbps
297abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *        0x3)  54 Mbps
298abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *
2991061787967db03975dc02030d6815811f4eb9231Daniel Wu * Legacy CCK rate format for bits 7:0 (bit 8 must be "0", bit 9 "1"):
300abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *  6-0:   10)  1 Mbps
301abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *         20)  2 Mbps
302abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *         55)  5.5 Mbps
303abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *        110)  11 Mbps
304abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill */
3055c5aa3f13a50881b8f6e529e321bbefb5faec37bHalperin, Daniel C#define RATE_MCS_CODE_MSK 0x7
3065c5aa3f13a50881b8f6e529e321bbefb5faec37bHalperin, Daniel C#define RATE_MCS_SPATIAL_POS 3
307abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill#define RATE_MCS_SPATIAL_MSK 0x18
308abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill#define RATE_MCS_HT_DUP_POS 5
309abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill#define RATE_MCS_HT_DUP_MSK 0x20
310075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill
311abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill/* Bit 8: (1) HT format, (0) legacy format in bits 7:0 */
312abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill#define RATE_MCS_FLAGS_POS 8
313abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill#define RATE_MCS_HT_POS 8
314abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill#define RATE_MCS_HT_MSK 0x100
315075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill
316abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill/* Bit 9: (1) CCK, (0) OFDM.  HT (bit 8) must be "0" for this bit to be valid */
317abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill#define RATE_MCS_CCK_POS 9
318abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill#define RATE_MCS_CCK_MSK 0x200
319075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill
320abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill/* Bit 10: (1) Use Green Field preamble */
321abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill#define RATE_MCS_GF_POS 10
322abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill#define RATE_MCS_GF_MSK 0x400
3237aafef1c6e2e24f9a10dc2972bf0ee70624ccc47Wey-Yi Guy
3247aafef1c6e2e24f9a10dc2972bf0ee70624ccc47Wey-Yi Guy/* Bit 11: (1) Use 40Mhz HT40 chnl width, (0) use 20 MHz legacy chnl width */
3257aafef1c6e2e24f9a10dc2972bf0ee70624ccc47Wey-Yi Guy#define RATE_MCS_HT40_POS 11
326abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill#define RATE_MCS_HT40_MSK 0x800
3277aafef1c6e2e24f9a10dc2972bf0ee70624ccc47Wey-Yi Guy
328abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill/* Bit 12: (1) Duplicate data on both 20MHz chnls. HT40 (bit 11) must be set. */
329abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill#define RATE_MCS_DUP_POS 12
330abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill#define RATE_MCS_DUP_MSK 0x1000
331075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill
332abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill/* Bit 13: (1) Short guard interval (0.4 usec), (0) normal GI (0.8 usec) */
333abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill#define RATE_MCS_SGI_POS 13
334abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill#define RATE_MCS_SGI_MSK 0x2000
335abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill
33676eff18bdc5feaa53f1be33709b67df02f1d55e9Tomas Winkler/**
33776eff18bdc5feaa53f1be33709b67df02f1d55e9Tomas Winkler * rate_n_flags Tx antenna masks
33876eff18bdc5feaa53f1be33709b67df02f1d55e9Tomas Winkler * 4965 has 2 transmitters
33976eff18bdc5feaa53f1be33709b67df02f1d55e9Tomas Winkler * 5100 has 1 transmitter B
34076eff18bdc5feaa53f1be33709b67df02f1d55e9Tomas Winkler * 5150 has 1 transmitter A
34176eff18bdc5feaa53f1be33709b67df02f1d55e9Tomas Winkler * 5300 has 3 transmitters
34276eff18bdc5feaa53f1be33709b67df02f1d55e9Tomas Winkler * 5350 has 3 transmitters
343abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill * bit14:16
344600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler */
345600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler#define RATE_MCS_ANT_POS	14
346600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler#define RATE_MCS_ANT_A_MSK	0x04000
347600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler#define RATE_MCS_ANT_B_MSK	0x08000
348600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler#define RATE_MCS_ANT_C_MSK	0x10000
349600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler#define RATE_MCS_ANT_AB_MSK	(RATE_MCS_ANT_A_MSK | RATE_MCS_ANT_B_MSK)
35076eff18bdc5feaa53f1be33709b67df02f1d55e9Tomas Winkler#define RATE_MCS_ANT_ABC_MSK	(RATE_MCS_ANT_AB_MSK | RATE_MCS_ANT_C_MSK)
35180cc0c382db318de88577eff027d5c4097abef81Ben M Cahill#define RATE_ANT_NUM 3
35280cc0c382db318de88577eff027d5c4097abef81Ben M Cahill
35380cc0c382db318de88577eff027d5c4097abef81Ben M Cahill#define POWER_TABLE_NUM_ENTRIES			33
35480cc0c382db318de88577eff027d5c4097abef81Ben M Cahill#define POWER_TABLE_NUM_HT_OFDM_ENTRIES		32
35580cc0c382db318de88577eff027d5c4097abef81Ben M Cahill#define POWER_TABLE_CCK_ENTRY			32
356e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy
357e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy#define IWL_PWR_NUM_HT_OFDM_ENTRIES		24
358e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy#define IWL_PWR_CCK_ENTRIES			2
35980cc0c382db318de88577eff027d5c4097abef81Ben M Cahill
36080cc0c382db318de88577eff027d5c4097abef81Ben M Cahill/**
36180cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * union iwl4965_tx_power_dual_stream
36280cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *
36380cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * Host format used for REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH
36480cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * Use __le32 version (struct tx_power_dual_stream) when building command.
36580cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *
36680cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * Driver provides radio gain and DSP attenuation settings to device in pairs,
36780cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * one value for each transmitter chain.  The first value is for transmitter A,
36880cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * second for transmitter B.
36980cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *
37080cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * For SISO bit rates, both values in a pair should be identical.
37180cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * For MIMO rates, one value may be different from the other,
37280cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * in order to balance the Tx output between the two transmitters.
37380cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *
37480cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * See more details in doc for TXPOWER in iwl-4965-hw.h.
37580cc0c382db318de88577eff027d5c4097abef81Ben M Cahill */
37680cc0c382db318de88577eff027d5c4097abef81Ben M Cahillunion iwl4965_tx_power_dual_stream {
37780cc0c382db318de88577eff027d5c4097abef81Ben M Cahill	struct {
37880cc0c382db318de88577eff027d5c4097abef81Ben M Cahill		u8 radio_tx_gain[2];
37980cc0c382db318de88577eff027d5c4097abef81Ben M Cahill		u8 dsp_predis_atten[2];
38080cc0c382db318de88577eff027d5c4097abef81Ben M Cahill	} s;
38180cc0c382db318de88577eff027d5c4097abef81Ben M Cahill	u32 dw;
38280cc0c382db318de88577eff027d5c4097abef81Ben M Cahill};
38380cc0c382db318de88577eff027d5c4097abef81Ben M Cahill
38480cc0c382db318de88577eff027d5c4097abef81Ben M Cahill/**
38580cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * struct tx_power_dual_stream
38680cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *
38780cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * Table entries in REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH
38880cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *
38980cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * Same format as iwl_tx_power_dual_stream, but __le32
39080cc0c382db318de88577eff027d5c4097abef81Ben M Cahill */
39180cc0c382db318de88577eff027d5c4097abef81Ben M Cahillstruct tx_power_dual_stream {
39280cc0c382db318de88577eff027d5c4097abef81Ben M Cahill	__le32 dw;
39380cc0c382db318de88577eff027d5c4097abef81Ben M Cahill} __attribute__ ((packed));
39480cc0c382db318de88577eff027d5c4097abef81Ben M Cahill
39580cc0c382db318de88577eff027d5c4097abef81Ben M Cahill/**
39680cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * struct iwl4965_tx_power_db
39780cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *
39880cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * Entire table within REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH
39980cc0c382db318de88577eff027d5c4097abef81Ben M Cahill */
40080cc0c382db318de88577eff027d5c4097abef81Ben M Cahillstruct iwl4965_tx_power_db {
40180cc0c382db318de88577eff027d5c4097abef81Ben M Cahill	struct tx_power_dual_stream power_tbl[POWER_TABLE_NUM_ENTRIES];
40280cc0c382db318de88577eff027d5c4097abef81Ben M Cahill} __attribute__ ((packed));
403630fe9b6f774dd55b71fe94392101eb00df58762Tomas Winkler
404a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler/**
405630fe9b6f774dd55b71fe94392101eb00df58762Tomas Winkler * Command REPLY_TX_POWER_DBM_CMD = 0x98
406630fe9b6f774dd55b71fe94392101eb00df58762Tomas Winkler * struct iwl5000_tx_power_dbm_cmd
407630fe9b6f774dd55b71fe94392101eb00df58762Tomas Winkler */
408853554accce19d16b03476676bdcb1ccdd44caaeGregory Greenman#define IWL50_TX_POWER_AUTO 0x7f
409853554accce19d16b03476676bdcb1ccdd44caaeGregory Greenman#define IWL50_TX_POWER_NO_CLOSED (0x1 << 6)
410630fe9b6f774dd55b71fe94392101eb00df58762Tomas Winkler
411630fe9b6f774dd55b71fe94392101eb00df58762Tomas Winklerstruct iwl5000_tx_power_dbm_cmd {
412630fe9b6f774dd55b71fe94392101eb00df58762Tomas Winkler	s8 global_lmt; /*in half-dBm (e.g. 30 = 15 dBm) */
413630fe9b6f774dd55b71fe94392101eb00df58762Tomas Winkler	u8 flags;
414630fe9b6f774dd55b71fe94392101eb00df58762Tomas Winkler	s8 srv_chan_lmt; /*in half-dBm (e.g. 30 = 15 dBm) */
415630fe9b6f774dd55b71fe94392101eb00df58762Tomas Winkler	u8 reserved;
41680cc0c382db318de88577eff027d5c4097abef81Ben M Cahill} __attribute__ ((packed));
4172f748deceee10bac563df0e859830cc628d1a841Wey-Yi Guy
4182f748deceee10bac563df0e859830cc628d1a841Wey-Yi Guy/**
4192f748deceee10bac563df0e859830cc628d1a841Wey-Yi Guy * Command TX_ANT_CONFIGURATION_CMD = 0x98
4202f748deceee10bac563df0e859830cc628d1a841Wey-Yi Guy * This command is used to configure valid Tx antenna.
4212f748deceee10bac563df0e859830cc628d1a841Wey-Yi Guy * By default uCode concludes the valid antenna according to the radio flavor.
4222f748deceee10bac563df0e859830cc628d1a841Wey-Yi Guy * This command enables the driver to override/modify this conclusion.
4232f748deceee10bac563df0e859830cc628d1a841Wey-Yi Guy */
4242f748deceee10bac563df0e859830cc628d1a841Wey-Yi Guystruct iwl_tx_ant_config_cmd {
4252f748deceee10bac563df0e859830cc628d1a841Wey-Yi Guy	__le32 valid;
4262f748deceee10bac563df0e859830cc628d1a841Wey-Yi Guy} __attribute__ ((packed));
427b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
428b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
429b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (0a)
430b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Alive and Error Commands & Responses:
431b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
432b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
43351e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison
434b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define UCODE_VALID_OK	cpu_to_le32(0x1)
435b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define INITIALIZE_SUBTYPE    (9)
436b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
437075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill/*
438075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * ("Initialize") REPLY_ALIVE = 0x1 (response only, not a command)
439075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *
440075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * uCode issues this "initialize alive" notification once the initialization
441075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * uCode image has completed its work, and is ready to load the runtime image.
442075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * This is the *first* "alive" notification that the driver will receive after
443075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * rebooting uCode; the "initialize" alive is indicated by subtype field == 9.
444075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *
445075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * See comments documenting "BSM" (bootstrap state machine).
446075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *
447075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * For 4965, this notification contains important calibration data for
448075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * calculating txpower settings:
449075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *
450a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler * 1)  Power supply voltage indication.  The voltage sensor outputs higher
451075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *     values for lower voltage, and vice verse.
452075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *
453075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * 2)  Temperature measurement parameters, for each of two channel widths
454075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *     (20 MHz and 40 MHz) supported by the radios.  Temperature sensing
455075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *     is done via one of the receiver chains, and channel width influences
456075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *     the results.
457075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *
458075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * 3)  Tx gain compensation to balance 4965's 2 Tx chains for MIMO operation,
459b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *     for each of 5 frequency ranges.
460885ba202cabd90b8ade1fe59185dc96ed4d69e02Tomas Winkler */
461b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl_init_alive_resp {
462b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ucode_minor;
463b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ucode_major;
464b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved1;
465b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 sw_rev[8];
466075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	u8 ver_type;
467b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ver_subtype;		/* "9" for initialize alive */
468b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved2;
469b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 log_event_table_ptr;
470b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 error_event_table_ptr;
471b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 timestamp;
472075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	__le32 is_valid;
473075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill
474075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	/* calibration values from "initialize" uCode */
4757aafef1c6e2e24f9a10dc2972bf0ee70624ccc47Wey-Yi Guy	__le32 voltage;		/* signed, higher value is lower voltage */
476075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	__le32 therm_r1[2];	/* signed, 1st for normal, 2nd for HT40 */
477075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	__le32 therm_r2[2];	/* signed */
478075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	__le32 therm_r3[2];	/* signed */
479075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	__le32 therm_r4[2];	/* signed */
480075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	__le32 tx_atten[5][2];	/* signed MIMO gain comp, 5 freq groups,
481b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 * 2 Tx chains */
482b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
483075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill
484075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill
485075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill/**
486075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * REPLY_ALIVE = 0x1 (response only, not a command)
487075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *
488075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * uCode issues this "alive" notification once the runtime image is ready
489075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * to receive commands from the driver.  This is the *second* "alive"
490075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * notification that the driver will receive after rebooting uCode;
491075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * this "alive" is indicated by subtype field != 9.
492075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *
493075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * See comments documenting "BSM" (bootstrap state machine).
494075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *
495075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * This response includes two pointers to structures within the device's
496075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * data SRAM (access via HBUS_TARG_MEM_* regs) that are useful for debugging:
497075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *
498075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * 1)  log_event_table_ptr indicates base of the event log.  This traces
499075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *     a 256-entry history of uCode execution within a circular buffer.
500075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *     Its header format is:
501075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *
502075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 log_size;     log capacity (in number of entries)
503075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 type;         (1) timestamp with each entry, (0) no timestamp
504075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 wraps;        # times uCode has wrapped to top of circular buffer
505075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *      __le32 write_index;  next circular buffer entry that uCode would fill
506075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *
507075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *     The header is followed by the circular buffer of log entries.  Entries
508075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *     with timestamps have the following format:
509075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *
510075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 event_id;     range 0 - 1500
511075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 timestamp;    low 32 bits of TSF (of network, if associated)
512075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 data;         event_id-specific data value
513075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *
514075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *     Entries without timestamps contain only event_id and data.
515461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *
516075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *
517461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy * 2)  error_event_table_ptr indicates base of the error log.  This contains
518075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *     information about any uCode error that occurs.  For agn, the format
519075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *     of the error log is:
520075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *
521075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 valid;        (nonzero) valid, (0) log is empty
522075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 error_id;     type of error
523075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 pc;           program counter
524075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 blink1;       branch link
525075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 blink2;       branch link
526075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 ilink1;       interrupt link
527075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 ilink2;       interrupt link
528075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 data1;        error-specific data
529075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 data2;        error-specific data
530075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 line;         source code line of error
531075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 bcon_time;    beacon timer
532075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 tsf_low;      network timestamp function timer
533461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 tsf_hi;       network timestamp function timer
534461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 gp1;          GP1 timer register
535461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 gp2;          GP2 timer register
536461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 gp3;          GP3 timer register
537461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 ucode_ver;    uCode version
538461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 hw_ver;       HW Silicon version
539461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 brd_ver;      HW board version
540461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 log_pc;       log program counter
541461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 frame_ptr;    frame pointer
542461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 stack_ptr;    stack pointer
543461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 hcmd;         last host command
544461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 isr0;         isr status register LMPM_NIC_ISR0: rxtx_flag
545461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 isr1;         isr status register LMPM_NIC_ISR1: host_flag
546461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 isr2;         isr status register LMPM_NIC_ISR2: enc_flag
547461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 isr3;         isr status register LMPM_NIC_ISR3: time_flag
548461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 isr4;         isr status register LMPM_NIC_ISR4: wico interrupt
549461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 isr_pref;     isr status register LMPM_NIC_PREF_STAT
550461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 wait_event;   wait event() caller address
551461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 l2p_control;  L2pControlField
552461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 l2p_duration; L2pDurationField
553461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 l2p_mhvalid;  L2pMhValidBits
554461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 l2p_addr_match; L2pAddrMatchStat
555461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 lmpm_pmg_sel; indicate which clocks are turned on (LMPM_PMG_SEL)
556461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 u_timestamp;  indicate when the date and time of the compilation
557075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 reserved;
558075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *
559075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * The Linux driver can print both logs to the system log when a uCode error
560075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * occurs.
561885ba202cabd90b8ade1fe59185dc96ed4d69e02Tomas Winkler */
562b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl_alive_resp {
563b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ucode_minor;
564b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ucode_major;
565b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved1;
566b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 sw_rev[8];
567075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	u8 ver_type;
568b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ver_subtype;			/* not "9" for runtime alive */
569075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	__le16 reserved2;
570075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	__le32 log_event_table_ptr;	/* SRAM address for event log */
571b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 error_event_table_ptr;	/* SRAM address for error log */
572b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 timestamp;
573b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 is_valid;
574b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
575b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
576b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
577b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_ERROR = 0x2 (response only, not a command)
578885ba202cabd90b8ade1fe59185dc96ed4d69e02Tomas Winkler */
579b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl_error_resp {
580b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 error_type;
581b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 cmd_id;
582b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved1;
583b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 bad_cmd_seq_num;
5843195c1f3499912b207ae600968488759b16037fcTomas Winkler	__le32 error_info;
585b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le64 timestamp;
586b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
587b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
588b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
589b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (1)
590b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * RXON Commands & Responses:
591b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
592b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
593b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
594b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
595b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Rx config defines & structure
596b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
597b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* rx_config device types  */
598b481de9ca074528fe8c429604e2777db8b89806aZhu Yienum {
599b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	RXON_DEV_TYPE_AP = 1,
600b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	RXON_DEV_TYPE_ESS = 3,
601b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	RXON_DEV_TYPE_IBSS = 4,
602b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	RXON_DEV_TYPE_SNIFFER = 6,
603b481de9ca074528fe8c429604e2777db8b89806aZhu Yi};
60414519a0b46085db68e610147098d03386c34801fBen M Cahill
60551e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison
6067b841727d2715d97592f46164804b34d6241644fRick Farrington#define RXON_RX_CHAIN_DRIVER_FORCE_MSK		cpu_to_le16(0x1 << 0)
60751e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_RX_CHAIN_DRIVER_FORCE_POS		(0)
60814519a0b46085db68e610147098d03386c34801fBen M Cahill#define RXON_RX_CHAIN_VALID_MSK			cpu_to_le16(0x7 << 1)
60951e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_RX_CHAIN_VALID_POS			(1)
61014519a0b46085db68e610147098d03386c34801fBen M Cahill#define RXON_RX_CHAIN_FORCE_SEL_MSK		cpu_to_le16(0x7 << 4)
61151e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_RX_CHAIN_FORCE_SEL_POS		(4)
61214519a0b46085db68e610147098d03386c34801fBen M Cahill#define RXON_RX_CHAIN_FORCE_MIMO_SEL_MSK	cpu_to_le16(0x7 << 7)
61351e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_RX_CHAIN_FORCE_MIMO_SEL_POS	(7)
61414519a0b46085db68e610147098d03386c34801fBen M Cahill#define RXON_RX_CHAIN_CNT_MSK			cpu_to_le16(0x3 << 10)
61551e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_RX_CHAIN_CNT_POS			(10)
61614519a0b46085db68e610147098d03386c34801fBen M Cahill#define RXON_RX_CHAIN_MIMO_CNT_MSK		cpu_to_le16(0x3 << 12)
61751e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_RX_CHAIN_MIMO_CNT_POS		(12)
61814519a0b46085db68e610147098d03386c34801fBen M Cahill#define RXON_RX_CHAIN_MIMO_FORCE_MSK		cpu_to_le16(0x1 << 14)
61914519a0b46085db68e610147098d03386c34801fBen M Cahill#define RXON_RX_CHAIN_MIMO_FORCE_POS		(14)
620b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
621b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* rx_config flags */
62251e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison/* band & modulation selection */
62351e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_BAND_24G_MSK           cpu_to_le32(1 << 0)
624b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define RXON_FLG_CCK_MSK                cpu_to_le32(1 << 1)
62551e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison/* auto detection enable */
626b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define RXON_FLG_AUTO_DETECT_MSK        cpu_to_le32(1 << 2)
62751e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison/* TGg protection when tx */
628b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define RXON_FLG_TGG_PROTECT_MSK        cpu_to_le32(1 << 3)
62951e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison/* cck short slot & preamble */
63051e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_SHORT_SLOT_MSK          cpu_to_le32(1 << 4)
631b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define RXON_FLG_SHORT_PREAMBLE_MSK     cpu_to_le32(1 << 5)
63251e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison/* antenna selection */
63351e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_DIS_DIV_MSK            cpu_to_le32(1 << 7)
63451e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_ANT_SEL_MSK            cpu_to_le32(0x0f00)
63551e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_ANT_A_MSK              cpu_to_le32(1 << 8)
636b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define RXON_FLG_ANT_B_MSK              cpu_to_le32(1 << 9)
63751e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison/* radar detection enable */
63851e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_RADAR_DETECT_MSK       cpu_to_le32(1 << 12)
639b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define RXON_FLG_TGJ_NARROW_BAND_MSK    cpu_to_le32(1 << 13)
640b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* rx response to host with 8-byte TSF
64151e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison* (according to ON_AIR deassertion) */
642b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define RXON_FLG_TSF2HOST_MSK           cpu_to_le32(1 << 15)
64314519a0b46085db68e610147098d03386c34801fBen M Cahill
64414519a0b46085db68e610147098d03386c34801fBen M Cahill
64514519a0b46085db68e610147098d03386c34801fBen M Cahill/* HT flags */
64651e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_CTRL_CHANNEL_LOC_POS		(22)
64714519a0b46085db68e610147098d03386c34801fBen M Cahill#define RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK	cpu_to_le32(0x1 << 22)
64814519a0b46085db68e610147098d03386c34801fBen M Cahill
64914519a0b46085db68e610147098d03386c34801fBen M Cahill#define RXON_FLG_HT_OPERATING_MODE_POS		(23)
65051e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison
6517aafef1c6e2e24f9a10dc2972bf0ee70624ccc47Wey-Yi Guy#define RXON_FLG_HT_PROT_MSK			cpu_to_le32(0x1 << 23)
65214519a0b46085db68e610147098d03386c34801fBen M Cahill#define RXON_FLG_HT40_PROT_MSK			cpu_to_le32(0x2 << 23)
65314519a0b46085db68e610147098d03386c34801fBen M Cahill
65451e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_CHANNEL_MODE_POS		(25)
655a2b0f02e4795bfde5f11720a10af8923cb98b654Wey-Yi Guy#define RXON_FLG_CHANNEL_MODE_MSK		cpu_to_le32(0x3 << 25)
656a2b0f02e4795bfde5f11720a10af8923cb98b654Wey-Yi Guy
657a2b0f02e4795bfde5f11720a10af8923cb98b654Wey-Yi Guy/* channel mode */
658a2b0f02e4795bfde5f11720a10af8923cb98b654Wey-Yi Guyenum {
659a2b0f02e4795bfde5f11720a10af8923cb98b654Wey-Yi Guy	CHANNEL_MODE_LEGACY = 0,
660a2b0f02e4795bfde5f11720a10af8923cb98b654Wey-Yi Guy	CHANNEL_MODE_PURE_40 = 1,
661a2b0f02e4795bfde5f11720a10af8923cb98b654Wey-Yi Guy	CHANNEL_MODE_MIXED = 2,
662a2b0f02e4795bfde5f11720a10af8923cb98b654Wey-Yi Guy	CHANNEL_MODE_RESERVED = 3,
663a2b0f02e4795bfde5f11720a10af8923cb98b654Wey-Yi Guy};
664a2b0f02e4795bfde5f11720a10af8923cb98b654Wey-Yi Guy#define RXON_FLG_CHANNEL_MODE_LEGACY	cpu_to_le32(CHANNEL_MODE_LEGACY << RXON_FLG_CHANNEL_MODE_POS)
665a2b0f02e4795bfde5f11720a10af8923cb98b654Wey-Yi Guy#define RXON_FLG_CHANNEL_MODE_PURE_40	cpu_to_le32(CHANNEL_MODE_PURE_40 << RXON_FLG_CHANNEL_MODE_POS)
666a2b0f02e4795bfde5f11720a10af8923cb98b654Wey-Yi Guy#define RXON_FLG_CHANNEL_MODE_MIXED	cpu_to_le32(CHANNEL_MODE_MIXED << RXON_FLG_CHANNEL_MODE_POS)
667a326a5d096f031af46c0073dd78eb80dea1f311aEmmanuel Grumbach
66851e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison/* CTS to self (if spec allows) flag */
66914519a0b46085db68e610147098d03386c34801fBen M Cahill#define RXON_FLG_SELF_CTS_EN			cpu_to_le32(0x1<<30)
670b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
671b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* rx_config filter flags */
67251e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison/* accept all data frames */
673b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define RXON_FILTER_PROMISC_MSK         cpu_to_le32(1 << 0)
67451e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison/* pass control & management to host */
675b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define RXON_FILTER_CTL2HOST_MSK        cpu_to_le32(1 << 1)
67651e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison/* accept multi-cast */
677b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define RXON_FILTER_ACCEPT_GRP_MSK      cpu_to_le32(1 << 2)
67851e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison/* don't decrypt uni-cast frames */
679b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define RXON_FILTER_DIS_DECRYPT_MSK     cpu_to_le32(1 << 3)
68051e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison/* don't decrypt multi-cast frames */
681b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define RXON_FILTER_DIS_GRP_DECRYPT_MSK cpu_to_le32(1 << 4)
68251e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison/* STA is associated */
683b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define RXON_FILTER_ASSOC_MSK           cpu_to_le32(1 << 5)
68451e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison/* transfer to host non bssid beacons in associated state */
685b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define RXON_FILTER_BCON_AWARE_MSK      cpu_to_le32(1 << 6)
68680cc0c382db318de88577eff027d5c4097abef81Ben M Cahill
687b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/**
68880cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * REPLY_RXON = 0x10 (command, has simple generic response)
68980cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *
69080cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * RXON tunes the radio tuner to a service channel, and sets up a number
69180cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * of parameters that are used primarily for Rx, but also for Tx operations.
69280cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *
69380cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * NOTE:  When tuning to a new channel, driver must set the
69480cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *        RXON_FILTER_ASSOC_MSK to 0.  This will clear station-dependent
69580cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *        info within the device, including the station tables, tx retry
69680cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *        rate tables, and txpower tables.  Driver must build a new station
69780cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *        table and txpower table before transmitting anything on the RXON
69880cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *        channel.
69980cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *
70080cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * NOTE:  All RXONs wipe clean the internal txpower table.  Driver must
70180cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *        issue a new REPLY_TX_PWR_TABLE_CMD after each REPLY_RXON (0x10),
702b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *        regardless of whether RXON_FILTER_ASSOC_MSK is set.
7033d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler */
7043d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
7053d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_rxon_cmd {
7063d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 node_addr[6];
7073d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 reserved1;
7083d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 bssid_addr[6];
7093d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 reserved2;
7103d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 wlap_bssid_addr[6];
7113d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 reserved3;
7123d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 dev_type;
7133d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 air_propagation;
7143d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 reserved4;
7153d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 ofdm_basic_rates;
7163d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 cck_basic_rates;
7173d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 assoc_id;
7183d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 flags;
7193d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 filter_flags;
7203d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 channel;
7213d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 reserved5;
7223d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler} __attribute__ ((packed));
723bb8c093bdea62f2ae371b98ebff81b0407852fafChristoph Hellwig
724b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl4965_rxon_cmd {
725b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 node_addr[6];
726b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved1;
727b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 bssid_addr[6];
728b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved2;
729b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 wlap_bssid_addr[6];
730b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved3;
731b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 dev_type;
732b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 air_propagation;
733b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 rx_chain;
734b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ofdm_basic_rates;
735b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 cck_basic_rates;
736b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 assoc_id;
737b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 flags;
738b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 filter_flags;
739b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 channel;
740b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ofdm_ht_single_stream_basic_rates;
741b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ofdm_ht_dual_stream_basic_rates;
742b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
743a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler
744c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman/* 5000 HW just extend this command */
745c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenmanstruct iwl_rxon_cmd {
746c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 node_addr[6];
747c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	__le16 reserved1;
748c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 bssid_addr[6];
749c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	__le16 reserved2;
750c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 wlap_bssid_addr[6];
751c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	__le16 reserved3;
752c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 dev_type;
753c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 air_propagation;
754c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	__le16 rx_chain;
755c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 ofdm_basic_rates;
756c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 cck_basic_rates;
757c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	__le16 assoc_id;
758c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	__le32 flags;
759c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	__le32 filter_flags;
760c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	__le16 channel;
761c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 ofdm_ht_single_stream_basic_rates;
762c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 ofdm_ht_dual_stream_basic_rates;
763c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 ofdm_ht_triple_stream_basic_rates;
764c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 reserved5;
765c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	__le16 acquisition_data;
766c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	__le16 reserved6;
767c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman} __attribute__ ((packed));
7683d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
7693d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler/*
7703d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * REPLY_RXON_ASSOC = 0x11 (command, has simple generic response)
7713d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler */
7723d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_rxon_assoc_cmd {
7733d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 flags;
7743d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 filter_flags;
7753d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 ofdm_basic_rates;
7763d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 cck_basic_rates;
7773d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 reserved;
7783d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler} __attribute__ ((packed));
7793d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
780fe7a90c2b73f0c1da0882861cd015c835ed28781Ron Rindjunskystruct iwl4965_rxon_assoc_cmd {
781fe7a90c2b73f0c1da0882861cd015c835ed28781Ron Rindjunsky	__le32 flags;
782fe7a90c2b73f0c1da0882861cd015c835ed28781Ron Rindjunsky	__le32 filter_flags;
783fe7a90c2b73f0c1da0882861cd015c835ed28781Ron Rindjunsky	u8 ofdm_basic_rates;
784fe7a90c2b73f0c1da0882861cd015c835ed28781Ron Rindjunsky	u8 cck_basic_rates;
785fe7a90c2b73f0c1da0882861cd015c835ed28781Ron Rindjunsky	u8 ofdm_ht_single_stream_basic_rates;
786fe7a90c2b73f0c1da0882861cd015c835ed28781Ron Rindjunsky	u8 ofdm_ht_dual_stream_basic_rates;
7873d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 rx_chain_select_flags;
788fe7a90c2b73f0c1da0882861cd015c835ed28781Ron Rindjunsky	__le16 reserved;
789c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman} __attribute__ ((packed));
7903d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
791b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl5000_rxon_assoc_cmd {
792b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 flags;
793b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 filter_flags;
794b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ofdm_basic_rates;
7953d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 cck_basic_rates;
796b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved1;
797b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ofdm_ht_single_stream_basic_rates;
7983d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 ofdm_ht_dual_stream_basic_rates;
7993d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 ofdm_ht_triple_stream_basic_rates;
800b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved2;
8013d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 rx_chain_select_flags;
8023d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 acquisition_data;
803b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 reserved3;
804b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
805b5d7be5e665f29274cfe6645b661acb38cb1d19bTomas Winkler
8062c2f3b33888419fb9e7d015b9dc67b9db4437efaTomas Winkler#define IWL_CONN_MAX_LISTEN_INTERVAL	10
8072c2f3b33888419fb9e7d015b9dc67b9db4437efaTomas Winkler#define IWL_MAX_UCODE_BEACON_INTERVAL	4 /* 4096 */
808fe7a90c2b73f0c1da0882861cd015c835ed28781Ron Rindjunsky#define IWL39_MAX_UCODE_BEACON_INTERVAL	1 /* 1024 */
809b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
810b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
811b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_RXON_TIMING = 0x14 (command, has simple generic response)
8123195c1f3499912b207ae600968488759b16037fcTomas Winkler */
8133195c1f3499912b207ae600968488759b16037fcTomas Winklerstruct iwl_rxon_time_cmd {
814b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le64 timestamp;
815b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 beacon_interval;
816b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 atim_window;
817b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_init_val;
818b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 listen_interval;
819b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved;
820b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
821b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
822b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
823b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_CHANNEL_SWITCH = 0x72 (command, has simple generic response)
8243d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler */
8253d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_channel_switch_cmd {
8263d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 band;
8273d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 expect_beacon;
8283d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 channel;
8293d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 rxon_flags;
8303d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 rxon_filter_flags;
8313d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 switch_time;
8323d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct iwl3945_power_per_rate power[IWL_MAX_RATES];
8333d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler} __attribute__ ((packed));
834e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy
835b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl4965_channel_switch_cmd {
836b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 band;
837b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 expect_beacon;
838b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 channel;
839b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 rxon_flags;
840b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 rxon_filter_flags;
841bb8c093bdea62f2ae371b98ebff81b0407852fafChristoph Hellwig	__le32 switch_time;
842b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct iwl4965_tx_power_db tx_power;
843b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
844e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy
845e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy/**
846e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * struct iwl5000_channel_switch_cmd
847e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * @band: 0- 5.2GHz, 1- 2.4GHz
848e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * @expect_beacon: 0- resume transmits after channel switch
849e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy *		   1- wait for beacon to resume transmits
850e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * @channel: new channel number
851e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * @rxon_flags: Rx on flags
852e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * @rxon_filter_flags: filtering parameters
853e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * @switch_time: switch time in extended beacon format
854e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * @reserved: reserved bytes
855e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy */
856e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guystruct iwl5000_channel_switch_cmd {
857e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy	u8 band;
858e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy	u8 expect_beacon;
859e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy	__le16 channel;
860e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy	__le32 rxon_flags;
861e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy	__le32 rxon_filter_flags;
862e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy	__le32 switch_time;
863e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy	__le32 reserved[2][IWL_PWR_NUM_HT_OFDM_ENTRIES + IWL_PWR_CCK_ENTRIES];
864e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy} __attribute__ ((packed));
865e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy
866e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy/**
867e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * struct iwl6000_channel_switch_cmd
868e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * @band: 0- 5.2GHz, 1- 2.4GHz
869e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * @expect_beacon: 0- resume transmits after channel switch
870e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy *		   1- wait for beacon to resume transmits
871e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * @channel: new channel number
872e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * @rxon_flags: Rx on flags
873e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * @rxon_filter_flags: filtering parameters
874e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * @switch_time: switch time in extended beacon format
875e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * @reserved: reserved bytes
876e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy */
877e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guystruct iwl6000_channel_switch_cmd {
878e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy	u8 band;
879e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy	u8 expect_beacon;
880e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy	__le16 channel;
881e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy	__le32 rxon_flags;
882e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy	__le32 rxon_filter_flags;
883e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy	__le32 switch_time;
884e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy	__le32 reserved[3][IWL_PWR_NUM_HT_OFDM_ENTRIES + IWL_PWR_CCK_ENTRIES];
885e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy} __attribute__ ((packed));
886b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
887b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
888b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * CHANNEL_SWITCH_NOTIFICATION = 0x73 (notification only, not a command)
8892aa6ab86bc475a115f56645591d2413981846509Tomas Winkler */
890b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl_csa_notification {
891b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 band;
892b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 channel;
893b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 status;		/* 0 - OK, 1 - fail */
894b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
895b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
896b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
897b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (2)
898b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Quality-of-Service (QOS) Commands & Responses:
899b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
9002054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *****************************************************************************/
9012054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill
9022054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill/**
9032054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * struct iwl_ac_qos -- QOS timing params for REPLY_QOS_PARAM
9042054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * One for each of 4 EDCA access categories in struct iwl_qosparam_cmd
9052054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *
9062054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * @cw_min: Contention window, start value in numbers of slots.
9072054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *          Should be a power-of-2, minus 1.  Device's default is 0x0f.
9082054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * @cw_max: Contention window, max value in numbers of slots.
9092054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *          Should be a power-of-2, minus 1.  Device's default is 0x3f.
9102054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * @aifsn:  Number of slots in Arbitration Interframe Space (before
9112054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *          performing random backoff timing prior to Tx).  Device default 1.
9122054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * @edca_txop:  Length of Tx opportunity, in uSecs.  Device default is 0.
9132054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *
9142054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * Device will automatically increase contention window by (2*CW) + 1 for each
9152054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * transmission retry.  Device uses cw_max as a bit mask, ANDed with new CW
9162054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * value, to cap the CW value.
9171ff50bda6eef4466366e197541508fc69af0f0c0Emmanuel Grumbach */
918b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl_ac_qos {
919b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 cw_min;
920b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 cw_max;
921b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 aifsn;
922b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved1;
923b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 edca_txop;
924b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
925b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
92651e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison/* QoS flags defines */
92751e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define QOS_PARAM_FLG_UPDATE_EDCA_MSK	cpu_to_le32(0x01)
92851e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define QOS_PARAM_FLG_TGN_MSK		cpu_to_le32(0x02)
929b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define QOS_PARAM_FLG_TXOP_TYPE_MSK	cpu_to_le32(0x10)
9302054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill
931b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* Number of Access Categories (AC) (EDCA), queues 0..3 */
932b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define AC_NUM                4
933b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
934b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
9352054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * REPLY_QOS_PARAM = 0x13 (command, has simple generic response)
9362054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *
9372054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * This command sets up timings for each of the 4 prioritized EDCA Tx FIFOs
938b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * 0: Background, 1: Best Effort, 2: Video, 3: Voice.
9391ff50bda6eef4466366e197541508fc69af0f0c0Emmanuel Grumbach */
940b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl_qosparam_cmd {
9411ff50bda6eef4466366e197541508fc69af0f0c0Emmanuel Grumbach	__le32 qos_flags;
942b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct iwl_ac_qos ac[AC_NUM];
943b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
944b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
945b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
946b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (3)
947b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Add/Modify Stations Commands & Responses:
948b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
949b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
950b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
951b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Multi station support
9522054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill */
9532054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill
954b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* Special, dedicated locations within device's station table */
955b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	IWL_AP_ID		0
956b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	IWL_STA_ID		2
9574c897253cc9ae1c6a2798b27b5fe8e6d94ab6185Tomas Winkler#define	IWL3945_BROADCAST_ID	24
9584c897253cc9ae1c6a2798b27b5fe8e6d94ab6185Tomas Winkler#define IWL3945_STATION_COUNT	25
959b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define IWL4965_BROADCAST_ID	31
960b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	IWL4965_STATION_COUNT	32
961fdd3e8a4ff96d03121b21946bfa684f3b5d783c6Tomas Winkler#define IWLAGN_BROADCAST_ID	15
962fdd3e8a4ff96d03121b21946bfa684f3b5d783c6Tomas Winkler#define	IWLAGN_STATION_COUNT	16
963b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
964b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	IWL_STATION_COUNT	32 	/* MAX(3945,4965)*/
965b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	IWL_INVALID_STATION 	255
966b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
9674c897253cc9ae1c6a2798b27b5fe8e6d94ab6185Tomas Winkler#define STA_FLG_TX_RATE_MSK		cpu_to_le32(1 << 2);
9684c897253cc9ae1c6a2798b27b5fe8e6d94ab6185Tomas Winkler#define STA_FLG_PWR_SAVE_MSK		cpu_to_le32(1 << 8);
96951e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_FLG_RTS_MIMO_PROT_MSK	cpu_to_le32(1 << 17)
97051e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_FLG_AGG_MPDU_8US_MSK	cpu_to_le32(1 << 18)
97174093ddf4c42da74922b63fb6844989e21164d9eBen M Cahill#define STA_FLG_MAX_AGG_SIZE_POS	(19)
97251e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_FLG_MAX_AGG_SIZE_MSK	cpu_to_le32(3 << 19)
9737aafef1c6e2e24f9a10dc2972bf0ee70624ccc47Wey-Yi Guy#define STA_FLG_HT40_EN_MSK		cpu_to_le32(1 << 21)
97451e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_FLG_MIMO_DIS_MSK		cpu_to_le32(1 << 22)
97574093ddf4c42da74922b63fb6844989e21164d9eBen M Cahill#define STA_FLG_AGG_MPDU_DENSITY_POS	(23)
97651e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_FLG_AGG_MPDU_DENSITY_MSK	cpu_to_le32(7 << 23)
977b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
9782054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill/* Use in mode field.  1: modify existing entry, 0: add new station entry */
979b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define STA_CONTROL_MODIFY_MSK		0x01
980b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
981b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* key flags __le16*/
98251e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_KEY_FLG_ENCRYPT_MSK	cpu_to_le16(0x0007)
98351e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_KEY_FLG_NO_ENC	cpu_to_le16(0x0000)
98451e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_KEY_FLG_WEP		cpu_to_le16(0x0001)
98551e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_KEY_FLG_CCMP	cpu_to_le16(0x0002)
98651e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_KEY_FLG_TKIP	cpu_to_le16(0x0003)
987b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
988b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define STA_KEY_FLG_KEYID_POS	8
98951e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_KEY_FLG_INVALID 	cpu_to_le16(0x0800)
990eaaf7894959d413d1e01443a622c507e1b4f61dbEmmanuel Grumbach/* wep key is either from global key (0) or from station info array (1) */
99151e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_KEY_FLG_MAP_KEY_MSK	cpu_to_le16(0x0008)
992eaaf7894959d413d1e01443a622c507e1b4f61dbEmmanuel Grumbach
993eaaf7894959d413d1e01443a622c507e1b4f61dbEmmanuel Grumbach/* wep key in STA: 5-bytes (0) or 13-bytes (1) */
99451e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_KEY_FLG_KEY_SIZE_MSK     cpu_to_le16(0x1000)
99551e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_KEY_MULTICAST_MSK        cpu_to_le16(0x4000)
996deb09c435e3f947f8b2c9d5df6a9c0a5b472b125Emmanuel Grumbach#define STA_KEY_MAX_NUM		8
997b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
9982054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill/* Flags indicate whether to modify vs. don't change various station params */
999b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	STA_MODIFY_KEY_MASK		0x01
1000b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	STA_MODIFY_TID_DISABLE_TX	0x02
1001b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	STA_MODIFY_TX_RATE_MSK		0x04
1002b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define STA_MODIFY_ADDBA_TID_MSK	0x08
1003b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define STA_MODIFY_DELBA_TID_MSK	0x10
10046ab10ff8738dfb098fd32132b7ebcf5cdb43ebdeJohannes Berg#define STA_MODIFY_SLEEP_TX_COUNT_MSK	0x20
10052054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill
10062054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill/* Receiver address (actually, Rx station's index into station table),
10072054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * combined with Traffic ID (QOS priority), in format used by Tx Scheduler */
1008b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define BUILD_RAxTID(sta_id, tid)	(((sta_id) << 4) + (tid))
1009b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1010bb8c093bdea62f2ae371b98ebff81b0407852fafChristoph Hellwigstruct iwl4965_keyinfo {
1011b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 key_flags;
1012b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 tkip_rx_tsc_byte2;	/* TSC[2] for key mix ph1 detection */
1013b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved1;
1014b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 tkip_rx_ttak[5];	/* 10-byte unicast TKIP TTAK */
1015eaaf7894959d413d1e01443a622c507e1b4f61dbEmmanuel Grumbach	u8 key_offset;
1016eaaf7894959d413d1e01443a622c507e1b4f61dbEmmanuel Grumbach	u8 reserved2;
1017b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 key[16];		/* 16-byte unicast decryption key */
1018b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
1019b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1020133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler/* 5000 */
1021133636deffc86809f59a0c8b768408d13237a9a2Tomas Winklerstruct iwl_keyinfo {
1022133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	__le16 key_flags;
1023133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	u8 tkip_rx_tsc_byte2;	/* TSC[2] for key mix ph1 detection */
1024133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	u8 reserved1;
1025133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	__le16 tkip_rx_ttak[5];	/* 10-byte unicast TKIP TTAK */
1026133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	u8 key_offset;
1027133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	u8 reserved2;
1028133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	u8 key[16];		/* 16-byte unicast decryption key */
1029133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	__le64 tx_secur_seq_cnt;
1030133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	__le64 hw_tkip_mic_rx_key;
1031133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	__le64 hw_tkip_mic_tx_key;
1032133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler} __attribute__ ((packed));
1033133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler
10342054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill/**
10352054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * struct sta_id_modify
10362054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * @addr[ETH_ALEN]: station's MAC address
10372054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * @sta_id: index of station in uCode's station table
10382054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * @modify_mask: STA_MODIFY_*, 1: modify, 0: don't change
10392054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *
10402054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * Driver selects unused table index when adding new station,
10412054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * or the index to a pre-existing station entry when modifying that station.
10422054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * Some indexes have special purposes (IWL_AP_ID, index 0, is for AP).
10432054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *
10442054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * modify_mask flags select which parameters to modify vs. leave alone.
10452054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill */
1046b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct sta_id_modify {
1047b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 addr[ETH_ALEN];
1048b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved1;
1049b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 sta_id;
1050b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 modify_mask;
1051b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved2;
1052b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
1053b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1054b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
1055b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_ADD_STA = 0x18 (command)
10562054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *
10572054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * The device contains an internal table of per-station information,
10582054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * with info on security keys, aggregation parameters, and Tx rates for
10592054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * initial Tx attempt and any retries (4965 uses REPLY_TX_LINK_QUALITY_CMD,
10602054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * 3945 uses REPLY_RATE_SCALE to set up rate tables).
10612054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *
10622054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * REPLY_ADD_STA sets up the table entry for one station, either creating
10632054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * a new entry, or modifying a pre-existing one.
10642054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *
10652054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * NOTE:  RXON command (without "associated" bit set) wipes the station table
10662054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        clean.  Moving into RF_KILL state does this also.  Driver must set up
10672054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        new station table before transmitting anything on the RXON channel
10682054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        (except active scans or active measurements; those commands carry
10692054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        their own txpower/rate setup data).
10702054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *
10712054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        When getting started on a new channel, driver must set up the
10722054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        IWL_BROADCAST_ID entry (last entry in the table).  For a client
10732054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        station in a BSS, once an AP is selected, driver sets up the AP STA
10742054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        in the IWL_AP_ID entry (1st entry in the table).  BROADCAST and AP
10752054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        are all that are needed for a BSS client station.  If the device is
10762054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        used as AP, or in an IBSS network, driver must set up station table
10772054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        entries for all STAs in network, starting with index IWL_STA_ID.
1078b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
10793d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
10803d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_addsta_cmd {
10813d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 mode;		/* 1: modify existing, 0: add new station */
10823d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 reserved[3];
10833d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct sta_id_modify sta;
10843d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct iwl4965_keyinfo key;
10853d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 station_flags;		/* STA_FLG_* */
10863d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 station_flags_msk;	/* STA_FLG_* */
10873d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
10883d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	/* bit field to disable (1) or enable (0) Tx for Traffic ID (TID)
10893d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * corresponding to bit (e.g. bit 5 controls TID 5).
10903d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */
10913d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 tid_disable_tx;
10923d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
10933d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 rate_n_flags;
10943d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
10953d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	/* TID for which to add block-ack support.
10963d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
10973d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 add_immediate_ba_tid;
10983d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
10993d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	/* TID for which to remove block-ack support.
11003d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * Set modify_mask bit STA_MODIFY_DELBA_TID_MSK to use this field. */
11013d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 remove_immediate_ba_tid;
11023d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
11033d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	/* Starting Sequence Number for added block-ack support.
11043d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
11053d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 add_immediate_ba_ssn;
11063d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler} __attribute__ ((packed));
11073d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
1108bb8c093bdea62f2ae371b98ebff81b0407852fafChristoph Hellwigstruct iwl4965_addsta_cmd {
11092054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	u8 mode;		/* 1: modify existing, 0: add new station */
1110b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved[3];
1111b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct sta_id_modify sta;
1112bb8c093bdea62f2ae371b98ebff81b0407852fafChristoph Hellwig	struct iwl4965_keyinfo key;
11132054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	__le32 station_flags;		/* STA_FLG_* */
11142054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	__le32 station_flags_msk;	/* STA_FLG_* */
11152054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill
11162054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	/* bit field to disable (1) or enable (0) Tx for Traffic ID (TID)
11172054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	 * corresponding to bit (e.g. bit 5 controls TID 5).
11182054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	 * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */
1119b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 tid_disable_tx;
11202054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill
1121b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16	reserved1;
11222054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill
11232054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	/* TID for which to add block-ack support.
11242054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
1125b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 add_immediate_ba_tid;
11262054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill
11272054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	/* TID for which to remove block-ack support.
11282054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	 * Set modify_mask bit STA_MODIFY_DELBA_TID_MSK to use this field. */
1129b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 remove_immediate_ba_tid;
11302054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill
11312054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	/* Starting Sequence Number for added block-ack support.
11322054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
1133b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 add_immediate_ba_ssn;
11342054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill
11359bb487b406692e172b15eba58de7d69358ac2005Johannes Berg	/*
11369bb487b406692e172b15eba58de7d69358ac2005Johannes Berg	 * Number of packets OK to transmit to station even though
11379bb487b406692e172b15eba58de7d69358ac2005Johannes Berg	 * it is asleep -- used to synchronise PS-poll and u-APSD
11389bb487b406692e172b15eba58de7d69358ac2005Johannes Berg	 * responses while ucode keeps track of STA sleep state.
11399bb487b406692e172b15eba58de7d69358ac2005Johannes Berg	 */
11409bb487b406692e172b15eba58de7d69358ac2005Johannes Berg	__le16 sleep_tx_count;
11419bb487b406692e172b15eba58de7d69358ac2005Johannes Berg
11429bb487b406692e172b15eba58de7d69358ac2005Johannes Berg	__le16 reserved2;
1143b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
1144b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1145133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler/* 5000 */
1146133636deffc86809f59a0c8b768408d13237a9a2Tomas Winklerstruct iwl_addsta_cmd {
1147133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	u8 mode;		/* 1: modify existing, 0: add new station */
1148133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	u8 reserved[3];
1149133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	struct sta_id_modify sta;
1150133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	struct iwl_keyinfo key;
1151133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	__le32 station_flags;		/* STA_FLG_* */
1152133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	__le32 station_flags_msk;	/* STA_FLG_* */
1153133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler
1154133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	/* bit field to disable (1) or enable (0) Tx for Traffic ID (TID)
1155133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	 * corresponding to bit (e.g. bit 5 controls TID 5).
1156133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	 * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */
1157133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	__le16 tid_disable_tx;
1158133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler
1159c587de0b8d6e194f7a1719fc6af8a81b4e8916d2Tomas Winkler	__le16	rate_n_flags;		/* 3945 only */
1160133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler
1161133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	/* TID for which to add block-ack support.
1162133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
1163133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	u8 add_immediate_ba_tid;
1164133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler
1165133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	/* TID for which to remove block-ack support.
1166133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	 * Set modify_mask bit STA_MODIFY_DELBA_TID_MSK to use this field. */
1167133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	u8 remove_immediate_ba_tid;
1168133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler
1169133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	/* Starting Sequence Number for added block-ack support.
1170133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
1171133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	__le16 add_immediate_ba_ssn;
1172133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler
11739bb487b406692e172b15eba58de7d69358ac2005Johannes Berg	/*
11749bb487b406692e172b15eba58de7d69358ac2005Johannes Berg	 * Number of packets OK to transmit to station even though
11759bb487b406692e172b15eba58de7d69358ac2005Johannes Berg	 * it is asleep -- used to synchronise PS-poll and u-APSD
11769bb487b406692e172b15eba58de7d69358ac2005Johannes Berg	 * responses while ucode keeps track of STA sleep state.
11779bb487b406692e172b15eba58de7d69358ac2005Johannes Berg	 */
11789bb487b406692e172b15eba58de7d69358ac2005Johannes Berg	__le16 sleep_tx_count;
11799bb487b406692e172b15eba58de7d69358ac2005Johannes Berg
11809bb487b406692e172b15eba58de7d69358ac2005Johannes Berg	__le16 reserved2;
1181133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler} __attribute__ ((packed));
1182133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler
1183133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler
11842054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill#define ADD_STA_SUCCESS_MSK		0x1
11852054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill#define ADD_STA_NO_ROOM_IN_TABLE	0x2
11862054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill#define ADD_STA_NO_BLOCK_ACK_RESOURCE	0x4
11872054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill#define ADD_STA_MODIFY_NON_EXIST_STA	0x8
1188b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
1189b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_ADD_STA = 0x18 (response)
1190b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
11917a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winklerstruct iwl_add_sta_resp {
11922054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	u8 status;	/* ADD_STA_* */
1193b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
1194b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
11957a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler#define REM_STA_SUCCESS_MSK              0x1
11967a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler/*
11977a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler *  REPLY_REM_STA = 0x19 (response)
11987a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler */
11997a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winklerstruct iwl_rem_sta_resp {
12007a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler	u8 status;
12017a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler} __attribute__ ((packed));
12027a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler
12037a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler/*
12047a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler *  REPLY_REM_STA = 0x19 (command)
12057a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler */
12067a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winklerstruct iwl_rem_sta_cmd {
12077a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler	u8 num_sta;     /* number of removed stations */
12087a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler	u8 reserved[3];
12097a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler	u8 addr[ETH_ALEN]; /* MAC addr of the first station */
12107a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler	u8 reserved2[2];
12117a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler} __attribute__ ((packed));
12127a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler
12130a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach#define IWL_TX_FIFO_BK_MSK		cpu_to_le32(BIT(0))
12140a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach#define IWL_TX_FIFO_BE_MSK		cpu_to_le32(BIT(1))
12150a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach#define IWL_TX_FIFO_VI_MSK		cpu_to_le32(BIT(2))
12160a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach#define IWL_TX_FIFO_VO_MSK		cpu_to_le32(BIT(3))
12170a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach#define IWL_AGG_TX_QUEUE_MSK		cpu_to_le32(0xffc00)
12180a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach
12190a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach#define IWL_DROP_SINGLE		0
12200a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach#define IWL_DROP_SELECTED	1
12210a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach#define IWL_DROP_ALL		2
12220a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach
12230a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach/*
12240a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach * REPLY_TXFIFO_FLUSH = 0x1e(command and response)
12250a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach *
12260a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach * When using full FIFO flush this command checks the scheduler HW block WR/RD
12270a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach * pointers to check if all the frames were transferred by DMA into the
12280a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach * relevant TX FIFO queue. Only when the DMA is finished and the queue is
12290a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach * empty the command can finish.
12300a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach * This command is used to flush the TXFIFO from transmit commands, it may
12310a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach * operate on single or multiple queues, the command queue can't be flushed by
12320a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach * this command. The command response is returned when all the queue flush
12330a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach * operations are done. Each TX command flushed return response with the FLUSH
12340a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach * status set in the TX response status. When FIFO flush operation is used,
12350a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach * the flush operation ends when both the scheduler DMA done and TXFIFO empty
12364564ce8b0e17d91d047aa875843deb2cccf3f268Emmanuel Grumbach * are set.
12370a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach *
1238b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * @fifo_control: bit mask for which queues to flush
1239b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * @flush_control: flush controls
1240b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *	0: Dump single MSDU
1241b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *	1: Dump multiple MSDU according to PS, INVALID STA, TTL, TID disable.
1242b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *	2: Dump all FIFO
1243b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
1244b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl_txfifo_flush_cmd {
124551e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison	__le32 fifo_control;
124651e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison	__le16 flush_control;
12478211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler	__le16 reserved;
124851e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison} __attribute__ ((packed));
124951e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison
125051e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison/*
125151e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison * REPLY_WEP_KEY = 0x20
12529024adf5c81c94f7b5c6fd26942b075e2a26e085Reinette Chatre */
12539f30e04e041cf9943940f71fd76094dd5a237018Daniel C Halperinstruct iwl_wep_key {
12548211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler	u8 key_index;
12558211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler	u8 key_offset;
12568211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler	u8 reserved1[2];
12578211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler	u8 key_size;
12588211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler	u8 reserved2[3];
12598211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler	u8 key[16];
126017e476b8db13790c03e2c46d93abc71468fca47eEmmanuel Grumbach} __attribute__ ((packed));
126117e476b8db13790c03e2c46d93abc71468fca47eEmmanuel Grumbach
126217e476b8db13790c03e2c46d93abc71468fca47eEmmanuel Grumbachstruct iwl_wep_cmd {
126317e476b8db13790c03e2c46d93abc71468fca47eEmmanuel Grumbach	u8 num_keys;
12648211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler	u8 global_key_type;
12658211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler	u8 flags;
12668211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler	u8 reserved;
12678211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler	struct iwl_wep_key key[0];
12688211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler} __attribute__ ((packed));
12698211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler
1270b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define WEP_KEY_WEP_TYPE 1
127117e476b8db13790c03e2c46d93abc71468fca47eEmmanuel Grumbach#define WEP_KEYS_MAX 4
127217e476b8db13790c03e2c46d93abc71468fca47eEmmanuel Grumbach#define WEP_INVALID_OFFSET 0xff
127317e476b8db13790c03e2c46d93abc71468fca47eEmmanuel Grumbach#define WEP_KEY_LEN_64 5
127417e476b8db13790c03e2c46d93abc71468fca47eEmmanuel Grumbach#define WEP_KEY_LEN_128 13
127517e476b8db13790c03e2c46d93abc71468fca47eEmmanuel Grumbach
12763d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler/******************************************************************************
12773d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * (4)
12783d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * Rx Responses:
12793d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler *
12803d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler *****************************************************************************/
12813d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
12823d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define RX_RES_STATUS_NO_CRC32_ERROR	cpu_to_le32(1 << 0)
12833d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define RX_RES_STATUS_NO_RXE_OVERFLOW	cpu_to_le32(1 << 1)
12843d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
12853d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define RX_RES_PHY_FLAGS_BAND_24_MSK	cpu_to_le16(1 << 0)
12863d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define RX_RES_PHY_FLAGS_MOD_CCK_MSK		cpu_to_le16(1 << 1)
12873d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK	cpu_to_le16(1 << 2)
12883d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define RX_RES_PHY_FLAGS_NARROW_BAND_MSK	cpu_to_le16(1 << 3)
12893d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define RX_RES_PHY_FLAGS_ANTENNA_MSK		0xf0
12903d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define RX_RES_PHY_FLAGS_ANTENNA_POS		4
12913d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
12923d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define RX_RES_STATUS_SEC_TYPE_MSK	(0x7 << 8)
12933d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define RX_RES_STATUS_SEC_TYPE_NONE	(0x0 << 8)
12943d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define RX_RES_STATUS_SEC_TYPE_WEP	(0x1 << 8)
12953d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define RX_RES_STATUS_SEC_TYPE_CCMP	(0x2 << 8)
12963d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define RX_RES_STATUS_SEC_TYPE_TKIP	(0x3 << 8)
12973d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define	RX_RES_STATUS_SEC_TYPE_ERR	(0x7 << 8)
12983d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
12993d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define RX_RES_STATUS_STATION_FOUND	(1<<6)
13003d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define RX_RES_STATUS_NO_STATION_INFO_MISMATCH	(1<<7)
13013d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
13023d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define RX_RES_STATUS_DECRYPT_TYPE_MSK	(0x3 << 11)
13033d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define RX_RES_STATUS_NOT_DECRYPT	(0x0 << 11)
13043d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define RX_RES_STATUS_DECRYPT_OK	(0x3 << 11)
13053d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define RX_RES_STATUS_BAD_ICV_MIC	(0x1 << 11)
13063d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define RX_RES_STATUS_BAD_KEY_TTAK	(0x2 << 11)
13073d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
13083d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define RX_MPDU_RES_STATUS_ICV_OK	(0x20)
13093d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define RX_MPDU_RES_STATUS_MIC_OK	(0x40)
13103d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define RX_MPDU_RES_STATUS_TTAK_OK	(1 << 7)
13113d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define RX_MPDU_RES_STATUS_DEC_DONE_MSK	(0x800)
13123d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
13133d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
13143d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_rx_frame_stats {
13153d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 phy_count;
13163d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 id;
13173d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 rssi;
1318b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 agc;
1319caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler	__le16 sig_avg;
1320caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler	__le16 noise_diff;
1321caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler	u8 payload[0];
1322caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler} __attribute__ ((packed));
1323caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler
1324caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winklerstruct iwl3945_rx_frame_hdr {
1325b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 channel;
1326b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 phy_flags;
1327b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved1;
1328b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 rate;
1329b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 len;
1330b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 payload[0];
1331b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
1332caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler
1333caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winklerstruct iwl3945_rx_frame_end {
1334caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler	__le32 status;
1335caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler	__le64 timestamp;
1336caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler	__le32 beacon_timestamp;
1337caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler} __attribute__ ((packed));
1338caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler
1339caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler/*
1340caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler * REPLY_3945_RX = 0x1b (response only, not a command)
1341caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler *
1342caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler * NOTE:  DO NOT dereference from casts to this structure
1343caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler * It is provided only for calculating minimum data set size.
1344caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler * The actual offsets of the hdr and end are dynamic based on
1345caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler * stats.phy_count
1346caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler */
1347a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winklerstruct iwl3945_rx_frame {
1348caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler	struct iwl3945_rx_frame_stats stats;
1349caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler	struct iwl3945_rx_frame_hdr hdr;
1350caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler	struct iwl3945_rx_frame_end end;
1351b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
1352857485c0c46ceee5c658c1761bba4d9a5ddf433fTomas Winkler
1353b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define IWL39_RX_FRAME_SIZE	(4 + sizeof(struct iwl3945_rx_frame))
1354b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1355caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler/* Fixed (non-configurable) rx data from phy */
1356b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1357b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define IWL49_RX_RES_PHY_CNT 14
1358b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define IWL49_RX_PHY_FLAGS_ANTENNAE_OFFSET	(4)
1359b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define IWL49_RX_PHY_FLAGS_ANTENNAE_MASK	(0x70)
1360b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define IWL49_AGC_DB_MASK			(0x3f80)	/* MASK(7,13) */
1361b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define IWL49_AGC_DB_POS			(7)
1362b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl4965_rx_non_cfg_phy {
1363b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 ant_selection;	/* ant A bit 4, ant B bit 5, ant C bit 6 */
1364caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler	__le16 agc_info;	/* agc code 0:6, agc dB 7:13, reserved 14:15 */
1365529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	u8 rssi_info[6];	/* we use even entries, 0/2/4 for A/B/C rssi */
1366529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	u8 pad[0];
1367b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
1368b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1369b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1370b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define IWL50_RX_RES_PHY_CNT 8
1371b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define IWL50_RX_RES_AGC_IDX     1
1372b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define IWL50_RX_RES_RSSI_AB_IDX 2
1373b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define IWL50_RX_RES_RSSI_C_IDX  3
1374b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define IWL50_OFDM_AGC_MSK 0xfe00
1375b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define IWL50_OFDM_AGC_BIT_POS 9
1376b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define IWL50_OFDM_RSSI_A_MSK 0x00ff
1377b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define IWL50_OFDM_RSSI_A_BIT_POS 0
1378b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define IWL50_OFDM_RSSI_B_MSK 0xff0000
1379b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define IWL50_OFDM_RSSI_B_BIT_POS 16
1380529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill#define IWL50_OFDM_RSSI_C_MSK 0x00ff
1381529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill#define IWL50_OFDM_RSSI_C_BIT_POS 0
1382529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1383529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahillstruct iwl5000_non_cfg_phy {
1384529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	__le32 non_cfg_phy[IWL50_RX_RES_PHY_CNT];  /* up to 8 phy entries */
1385529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill} __attribute__ ((packed));
1386529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1387529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1388529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/*
1389529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * REPLY_RX = 0xc3 (response only, not a command)
1390529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Used only for legacy (non 11n) frames.
1391529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill */
1392529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahillstruct iwl_rx_phy_res {
1393529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	u8 non_cfg_phy_cnt;     /* non configurable DSP phy data byte count */
1394529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	u8 cfg_phy_cnt;		/* configurable DSP phy data byte count */
1395529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	u8 stat_id;		/* configurable DSP phy data set ID */
1396529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	u8 reserved1;
1397529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	__le64 timestamp;	/* TSF at on air rise */
1398529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	__le32 beacon_time_stamp; /* beacon at on-air rise */
1399b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 phy_flags;	/* general phy flags: band, modulation, ... */
1400b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 channel;		/* channel number */
1401529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	u8 non_cfg_phy_buf[32]; /* for various implementations of non_cfg_phy */
1402529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	__le32 rate_n_flags;	/* RATE_MCS_* */
1403a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler	__le16 byte_count;	/* frame's byte-count */
1404a326a5d096f031af46c0073dd78eb80dea1f311aEmmanuel Grumbach	__le16 reserved3;
1405a326a5d096f031af46c0073dd78eb80dea1f311aEmmanuel Grumbach} __attribute__ ((packed));
140651e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison
1407a326a5d096f031af46c0073dd78eb80dea1f311aEmmanuel Grumbachstruct iwl_rx_mpdu_res_start {
1408529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	__le16 byte_count;
1409529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	__le16 reserved;
141051e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison} __attribute__ ((packed));
1411529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1412529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1413529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/******************************************************************************
1414529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * (5)
141551e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison * Tx Commands & Responses:
1416529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *
1417529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Driver must place each REPLY_TX command into one of the prioritized Tx
1418529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * queues in host DRAM, shared between driver and device (see comments for
1419529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * SCD registers and Tx/Rx Queues).  When the device's Tx scheduler and uCode
142051e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison * are preparing to transmit, the device pulls the Tx command over the PCI
1421529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * bus via one of the device's Tx DMA channels, to fill an internal FIFO
1422529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * from which data will be transmitted.
1423529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *
1424529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * uCode handles all timing and protocol related to control frames
1425529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * (RTS/CTS/ACK), based on flags in the Tx command.  uCode and Tx scheduler
1426529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * handle reception of block-acks; uCode updates the host driver via
1427529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * REPLY_COMPRESSED_BA (4965).
142851e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison *
1429529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * uCode handles retrying Tx when an ACK is expected but not received.
1430529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * This includes trying lower data rates than the one requested in the Tx
1431529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * command, as set up by the REPLY_RATE_SCALE (for 3945) or
143251e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison * REPLY_TX_LINK_QUALITY_CMD (4965).
1433529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *
1434529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Driver sets up transmit power for various rates via REPLY_TX_PWR_TABLE_CMD.
1435529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * This command must be executed after every RXON command, before Tx can occur.
143651e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison *****************************************************************************/
1437529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1438529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* REPLY_TX Tx flags field */
1439529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
144051e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison/*
144151e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison * 1: Use RTS/CTS protocol or CTS-to-self if spec allows it
144251e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison * before this frame. if CTS-to-self required check
1443b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * RXON_FLG_SELF_CTS_EN status.
1444529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * unused in 3945/4965, used in 5000 series and after
1445529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill */
1446b2e8690d5a4d1868ee12f50aa00c138bec985b3cJohannes Berg#define TX_CMD_FLG_PROT_REQUIRE_MSK cpu_to_le32(1 << 0)
1447b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1448529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/*
1449529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * 1: Use Request-To-Send protocol before this frame.
1450529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Mutually exclusive vs. TX_CMD_FLG_CTS_MSK.
1451529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * used in 3945/4965, unused in 5000 series and after
145251e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison */
1453b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define TX_CMD_FLG_RTS_MSK cpu_to_le32(1 << 1)
1454529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1455529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/*
145651e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison * 1: Transmit Clear-To-Send to self before this frame.
1457b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Driver should set this for AUTH/DEAUTH/ASSOC-REQ/REASSOC mgmnt frames.
1458529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Mutually exclusive vs. TX_CMD_FLG_RTS_MSK.
1459529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * used in 3945/4965, unused in 5000 series and after
1460529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill */
146151e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_CTS_MSK cpu_to_le32(1 << 2)
1462b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1463529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* 1: Expect ACK from receiving station
1464529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * 0: Don't expect ACK (MAC header's duration field s/b 0)
1465529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Set this for unicast frames, but not broadcast/multicast. */
1466529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill#define TX_CMD_FLG_ACK_MSK cpu_to_le32(1 << 3)
1467529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1468529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* For 4965:
146951e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison * 1: Use rate scale table (see REPLY_TX_LINK_QUALITY_CMD).
1470b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *    Tx command's initial_rate_index indicates first rate to try;
14718236e183fc53be2b5d81a4f547f9c5b645e10fe0Max Stepanov *    uCode walks through table for additional Tx attempts.
14728236e183fc53be2b5d81a4f547f9c5b645e10fe0Max Stepanov * 0: Use Tx rate/MCS from Tx command's rate_n_flags field.
147351e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison *    This rate will be used for all Tx attempts; it will not be scaled. */
14748236e183fc53be2b5d81a4f547f9c5b645e10fe0Max Stepanov#define TX_CMD_FLG_STA_RATE_MSK cpu_to_le32(1 << 4)
1475b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
147651e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison/* 1: Expect immediate block-ack.
1477b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Set when Txing a block-ack request frame.  Also set TX_CMD_FLG_ACK_MSK. */
1478529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill#define TX_CMD_FLG_IMM_BA_RSP_MASK  cpu_to_le32(1 << 6)
1479b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1480b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
1481b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * 1: Frame requires full Tx-Op protection.
1482b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Set this if either RTS or CTS Tx Flag gets set.
1483b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * used in 3945/4965, unused in 5000 series and after
1484b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
1485b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define TX_CMD_FLG_FULL_TXOP_PROT_MSK cpu_to_le32(1 << 7)
1486b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1487b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* Tx antenna selection field; used only for 3945, reserved (0) for 4965.
1488b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Set field to "0" to allow 3945 uCode to select antenna (normal usage). */
1489b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define TX_CMD_FLG_ANT_SEL_MSK cpu_to_le32(0xf00)
14903195cdb7424b4207f6903f1f3ddadcab49fa22f2Tomas Winkler#define TX_CMD_FLG_ANT_A_MSK cpu_to_le32(1 << 8)
14913195cdb7424b4207f6903f1f3ddadcab49fa22f2Tomas Winkler#define TX_CMD_FLG_ANT_B_MSK cpu_to_le32(1 << 9)
14923195cdb7424b4207f6903f1f3ddadcab49fa22f2Tomas Winkler
14933195cdb7424b4207f6903f1f3ddadcab49fa22f2Tomas Winkler/* 1: Ignore Bluetooth priority for this frame.
14943195cdb7424b4207f6903f1f3ddadcab49fa22f2Tomas Winkler * 0: Delay Tx until Bluetooth device is done (normal usage). */
14953195cdb7424b4207f6903f1f3ddadcab49fa22f2Tomas Winkler#define TX_CMD_FLG_IGNORE_BT cpu_to_le32(1 << 12)
14963195cdb7424b4207f6903f1f3ddadcab49fa22f2Tomas Winkler
14973195cdb7424b4207f6903f1f3ddadcab49fa22f2Tomas Winkler/* 1: uCode overrides sequence control field in MAC header.
14983d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * 0: Driver provides sequence control field in MAC header.
14993d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * Set this for management frames, non-QOS data frames, non-unicast frames,
15003d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * and also in Tx command embedded in REPLY_SCAN_CMD for active scans. */
15013d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define TX_CMD_FLG_SEQ_CTL_MSK cpu_to_le32(1 << 13)
15023d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
15033d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler/* 1: This frame is non-last MPDU; more fragments are coming.
15043d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * 0: Last fragment, or not using fragmentation. */
15053d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define TX_CMD_FLG_MORE_FRAG_MSK cpu_to_le32(1 << 14)
15063d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
15073d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler/* 1: uCode calculates and inserts Timestamp Function (TSF) in outgoing frame.
15083d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * 0: No TSF required in outgoing frame.
15093d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * Set this for transmitting beacons and probe responses. */
15103d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define TX_CMD_FLG_TSF_MSK cpu_to_le32(1 << 16)
15113d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
15123d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler/* 1: Driver inserted 2 bytes pad after the MAC header, for (required) dword
15133d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler *    alignment of frame's payload data field.
15143d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * 0: No pad
15153d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * Set this for MAC headers with 26 or 30 bytes, i.e. those with QOS or ADDR4
15163d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * field (but not both).  Driver must align frame data (i.e. data following
15173d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * MAC header) to DWORD boundary. */
15183d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define TX_CMD_FLG_MH_PAD_MSK cpu_to_le32(1 << 20)
15193d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
15203d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler/* accelerate aggregation support
15213d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * 0 - no CCMP encryption; 1 - CCMP encryption */
15223d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define TX_CMD_FLG_AGG_CCMP_MSK cpu_to_le32(1 << 22)
15233d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
15243d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler/* HCCA-AP - disable duration overwriting. */
15253d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define TX_CMD_FLG_DUR_MSK cpu_to_le32(1 << 25)
15263d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
15273d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
15283d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler/*
15293d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * TX command security control
15303d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler */
15313d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define TX_CMD_SEC_WEP  	0x01
15323d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define TX_CMD_SEC_CCM  	0x02
15333d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define TX_CMD_SEC_TKIP		0x03
15343d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define TX_CMD_SEC_MSK		0x03
15353d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define TX_CMD_SEC_SHIFT	6
15363d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define TX_CMD_SEC_KEY128	0x08
15373d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
15383d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler/*
15393d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * security overhead sizes
15403d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler */
15413d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define WEP_IV_LEN 4
15423d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define WEP_ICV_LEN 4
15433d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define CCMP_MIC_LEN 8
15443d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define TKIP_ICV_LEN 4
15453d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
15463d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler/*
15473d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * REPLY_TX = 0x1c (command)
15483d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler */
15493d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
15503d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_tx_cmd {
15513d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	/*
15523d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * MPDU byte count:
15533d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * MAC header (24/26/30/32 bytes) + 2 bytes pad if 26/30 header size,
15543d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * + 8 byte IV for CCM or TKIP (not used for WEP)
15553d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * + Data payload
15563d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * + 8-byte MIC (not used for CCM/WEP)
15573d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * NOTE:  Does not include Tx command bytes, post-MAC pad bytes,
15583d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 *        MIC (CCM) 8 bytes, ICV (WEP/TKIP/CKIP) 4 bytes, CRC 4 bytes.i
15593d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * Range: 14-2342 bytes.
15603d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 */
15613d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 len;
15623d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
15633d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	/*
15643d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * MPDU or MSDU byte count for next frame.
15653d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * Used for fragmentation and bursting, but not 11n aggregation.
15663d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * Same as "len", but for next frame.  Set to 0 if not applicable.
15673d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 */
15683d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 next_frame_len;
15693d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
15703d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 tx_flags;	/* TX_CMD_FLG_* */
15713d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
15723d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 rate;
15733d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
15743d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	/* Index of recipient station in uCode's station table */
15753d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 sta_id;
1576529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	u8 tid_tspec;
1577529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	u8 sec_ctl;
1578529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	u8 key[16];
1579b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	union {
15802aa6ab86bc475a115f56645591d2413981846509Tomas Winkler		u8 byte[8];
1581529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill		__le16 word[4];
1582529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill		__le32 dw[2];
1583b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	} tkip_mic;
1584b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 next_frame_info;
1585b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	union {
158683d527d9e8f9aff92cbd33f208f77c055dabb499Tomas Winkler		__le32 life_time;
1587529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill		__le32 attempt;
1588529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	} stop_time;
1589529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	u8 supp_rates[2];
1590529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	u8 rts_retry_limit;	/*byte 50 */
1591529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	u8 data_retry_limit;	/*byte 51 */
1592529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	union {
1593529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill		__le16 pm_frame_timeout;
1594529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill		__le16 attempt_duration;
1595529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	} timeout;
1596529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1597b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/*
1598529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * Duration of EDCA burst Tx Opportunity, in 32-usec units.
1599529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * Set this if txop time is not specified by HCCA protocol (e.g. by AP).
1600529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 */
1601529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	__le16 driver_txop;
1602529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1603529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	/*
1604b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * MAC header goes here, followed by 2 bytes padding if MAC header
1605529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * length is 26 or 30 bytes, followed by payload data
1606529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 */
1607529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	u8 payload[0];
16082aa6ab86bc475a115f56645591d2413981846509Tomas Winkler	struct ieee80211_hdr hdr[0];
1609529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill} __attribute__ ((packed));
16102aa6ab86bc475a115f56645591d2413981846509Tomas Winkler
1611529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/*
1612529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * REPLY_TX = 0x1c (response)
1613529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill */
1614529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahillstruct iwl3945_tx_resp {
1615529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	u8 failure_rts;
1616b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 failure_frame;
1617529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	u8 bt_kill_count;
1618529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	u8 rate;
1619529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	__le32 wireless_media_time;
1620529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	__le32 status;		/* TX status */
1621529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill} __attribute__ ((packed));
1622529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1623529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1624529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/*
1625529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * 4965 uCode updates these Tx attempt count values in host DRAM.
1626529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Used for managing Tx retries when expecting block-acks.
1627529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Driver should set these fields to 0.
1628b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
1629b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl_dram_scratch {
1630b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 try_cnt;		/* Tx attempts */
1631b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 bt_kill_cnt;		/* Tx attempts blocked by Bluetooth device */
1632b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved;
1633b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
1634b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1635b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl_tx_cmd {
1636b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/*
1637529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * MPDU byte count:
1638529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * MAC header (24/26/30/32 bytes) + 2 bytes pad if 26/30 header size,
1639529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * + 8 byte IV for CCM or TKIP (not used for WEP)
1640b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * + Data payload
1641b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * + 8-byte MIC (not used for CCM/WEP)
1642529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * NOTE:  Does not include Tx command bytes, post-MAC pad bytes,
1643b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 *        MIC (CCM) 8 bytes, ICV (WEP/TKIP/CKIP) 4 bytes, CRC 4 bytes.i
1644b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * Range: 14-2342 bytes.
1645b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 */
1646b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 len;
1647b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1648b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/*
1649b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * MPDU or MSDU byte count for next frame.
1650529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * Used for fragmentation and bursting, but not 11n aggregation.
1651529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * Same as "len", but for next frame.  Set to 0 if not applicable.
1652529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 */
1653529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	__le16 next_frame_len;
1654529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1655b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 tx_flags;	/* TX_CMD_FLG_* */
1656529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1657529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	/* uCode may modify this field of the Tx command (in host DRAM!).
1658529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * Driver must also set dram_lsb_ptr and dram_msb_ptr in this cmd. */
1659529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	struct iwl_dram_scratch scratch;
1660529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1661b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* Rate for *all* Tx attempts, if TX_CMD_FLG_STA_RATE_MSK is cleared. */
1662b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 rate_n_flags;	/* RATE_MCS_* */
1663b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1664b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* Index of destination station in uCode's station table */
166504569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	u8 sta_id;
1666b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1667b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* Type of security encryption:  CCM or TKIP */
1668b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 sec_ctl;		/* TX_CMD_SEC_* */
1669b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1670b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/*
1671b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * Index into rate table (see REPLY_TX_LINK_QUALITY_CMD) for initial
1672b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * Tx attempt, if TX_CMD_FLG_STA_RATE_MSK is set.  Normally "0" for
1673b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * data frames, this field may be used to selectively reduce initial
1674b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * rate (via non-0 value) for special frames (e.g. management), while
1675b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * still supporting rate scaling for all frames.
1676b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 */
1677b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 initial_rate_index;
1678b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved;
1679b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 key[16];
1680b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 next_frame_flags;
1681b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved2;
1682b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	union {
1683b481de9ca074528fe8c429604e2777db8b89806aZhu Yi		__le32 life_time;
1684b481de9ca074528fe8c429604e2777db8b89806aZhu Yi		__le32 attempt;
1685b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	} stop_time;
1686b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1687b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* Host DRAM physical address pointer to "scratch" in this command.
1688b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * Must be dword aligned.  "0" in dram_lsb_ptr disables usage. */
1689b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 dram_lsb_ptr;
1690b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 dram_msb_ptr;
1691b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1692b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 rts_retry_limit;	/*byte 50 */
169304569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	u8 data_retry_limit;	/*byte 51 */
169404569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	u8 tid_tspec;
169504569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	union {
169604569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy		__le16 pm_frame_timeout;
169704569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy		__le16 attempt_duration;
169804569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	} timeout;
169904569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy
170004569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	/*
170104569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	 * Duration of EDCA burst Tx Opportunity, in 32-usec units.
170204569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	 * Set this if txop time is not specified by HCCA protocol (e.g. by AP).
170304569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	 */
170404569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	__le16 driver_txop;
170504569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy
170604569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	/*
170704569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	 * MAC header goes here, followed by 2 bytes padding if MAC header
170804569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	 * length is 26 or 30 bytes, followed by payload data
170904569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	 */
171004569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	u8 payload[0];
171104569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	struct ieee80211_hdr hdr[0];
171204569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy} __attribute__ ((packed));
171304569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy
171404569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy/* TX command response is sent after *3945* transmission attempts.
171504569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy *
171604569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy * NOTES:
171704569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy *
171804569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy * TX_STATUS_FAIL_NEXT_FRAG
171904569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy *
172004569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy * If the fragment flag in the MAC header for the frame being transmitted
1721b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * is set and there is insufficient time to transmit the next frame, the
1722b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * TX status will be returned with 'TX_STATUS_FAIL_NEXT_FRAG'.
172304569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy *
172404569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy * TX_STATUS_FIFO_UNDERRUN
172504569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy *
172604569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy * Indicates the host did not provide bytes to the FIFO fast enough while
172704569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy * a TX was in progress.
172804569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy *
172904569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy * TX_STATUS_FAIL_MGMNT_ABORT
173004569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy *
1731b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * This status is only possible if the ABORT ON MGMT RX parameter was
1732b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * set to true with the TX command.
1733b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
173404569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy * If the MSB of the status parameter is set then an abort sequence is
173504569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy * required.  This sequence consists of the host activating the TX Abort
1736b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * control line, and then waiting for the TX Abort command response.  This
1737b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * indicates that a the device is no longer in a transmit state, and that the
173804569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy * command FIFO has been cleared.  The host must then deactivate the TX Abort
1739b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * control line.  Receiving is still allowed in this case.
1740b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
1741b481de9ca074528fe8c429604e2777db8b89806aZhu Yienum {
1742b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_3945_STATUS_SUCCESS = 0x01,
174304569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	TX_3945_STATUS_DIRECT_DONE = 0x02,
1744b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_3945_STATUS_FAIL_SHORT_LIMIT = 0x82,
174504569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	TX_3945_STATUS_FAIL_LONG_LIMIT = 0x83,
174604569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	TX_3945_STATUS_FAIL_FIFO_UNDERRUN = 0x84,
174704569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	TX_3945_STATUS_FAIL_MGMNT_ABORT = 0x85,
174804569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	TX_3945_STATUS_FAIL_NEXT_FRAG = 0x86,
174904569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	TX_3945_STATUS_FAIL_LIFE_EXPIRE = 0x87,
175004569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	TX_3945_STATUS_FAIL_DEST_PS = 0x88,
175104569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	TX_3945_STATUS_FAIL_ABORTED = 0x89,
1752b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_3945_STATUS_FAIL_BT_RETRY = 0x8a,
1753b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_3945_STATUS_FAIL_STA_INVALID = 0x8b,
1754b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_3945_STATUS_FAIL_FRAG_DROPPED = 0x8c,
1755b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_3945_STATUS_FAIL_TID_DISABLE = 0x8d,
1756b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_3945_STATUS_FAIL_FRAME_FLUSHED = 0x8e,
1757b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_3945_STATUS_FAIL_INSUFFICIENT_CF_POLL = 0x8f,
1758b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_3945_STATUS_FAIL_TX_LOCKED = 0x90,
1759b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_3945_STATUS_FAIL_NO_BEACON_ON_RADAR = 0x91,
1760b481de9ca074528fe8c429604e2777db8b89806aZhu Yi};
1761b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1762b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
17633fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler * TX command response is sent after *agn* transmission attempts.
1764b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
1765b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * both postpone and abort status are expected behavior from uCode. there is
1766b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * no special operation required from driver; except for RFKILL_FLUSH,
1767b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * which required tx flush host command to flush all the tx frames in queues
17683fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler */
1769b481de9ca074528fe8c429604e2777db8b89806aZhu Yienum {
1770b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_SUCCESS = 0x01,
1771b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_DIRECT_DONE = 0x02,
1772b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* postpone TX */
1773b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_POSTPONE_DELAY = 0x40,
1774529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	TX_STATUS_POSTPONE_FEW_BYTES = 0x41,
1775b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_POSTPONE_BT_PRIO = 0x42,
1776b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_POSTPONE_QUIET_PERIOD = 0x43,
1777b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_POSTPONE_CALC_TTAK = 0x44,
1778b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* abort TX */
1779b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_INTERNAL_CROSSED_RETRY = 0x81,
1780b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_SHORT_LIMIT = 0x82,
1781b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_LONG_LIMIT = 0x83,
1782b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_FIFO_UNDERRUN = 0x84,
1783b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_DRAIN_FLOW = 0x85,
1784b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_RFKILL_FLUSH = 0x86,
1785b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_LIFE_EXPIRE = 0x87,
1786b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_DEST_PS = 0x88,
1787b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_HOST_ABORTED = 0x89,
1788b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_BT_RETRY = 0x8a,
1789b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_STA_INVALID = 0x8b,
1790b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_FRAG_DROPPED = 0x8c,
1791b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_TID_DISABLE = 0x8d,
1792b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_FIFO_FLUSHED = 0x8e,
17933fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	TX_STATUS_FAIL_INSUFFICIENT_CF_POLL = 0x8f,
17943fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	/* uCode drop due to FW drop request */
17953fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	TX_STATUS_FAIL_FW_DROP = 0x90,
1796b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/*
1797529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * uCode drop due to station color mismatch
1798b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * between tx command and station table
1799b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 */
1800b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_STA_COLOR_MISMATCH_DROP = 0x91,
1801529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill};
1802b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1803b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	TX_PACKET_MODE_REGULAR		0x0000
1804b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	TX_PACKET_MODE_BURST_SEQ	0x0100
1805b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	TX_PACKET_MODE_BURST_FIRST	0x0200
1806b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1807529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahillenum {
1808529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	TX_POWER_PA_NOT_ACTIVE = 0x0,
1809529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill};
1810529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1811529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahillenum {
1812529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	TX_STATUS_MSK = 0x000000ff,		/* bits 0:7 */
1813529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	TX_STATUS_DELAY_MSK = 0x00000040,
1814529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	TX_STATUS_ABORT_MSK = 0x00000080,
1815529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	TX_PACKET_MODE_MSK = 0x0000ff00,	/* bits 8:15 */
1816529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	TX_FIFO_NUMBER_MSK = 0x00070000,	/* bits 16:18 */
1817529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	TX_RESERVED = 0x00780000,		/* bits 19:22 */
1818529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	TX_POWER_PA_DETECT_MSK = 0x7f800000,	/* bits 23:30 */
1819529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	TX_ABORT_REQUIRED_MSK = 0x80000000,	/* bits 31:31 */
1820529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill};
1821529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1822529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* *******************************
1823529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * TX aggregation status
1824529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill ******************************* */
1825b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1826001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunskyenum {
1827001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	AGG_TX_STATE_TRANSMITTED = 0x00,
1828001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	AGG_TX_STATE_UNDERRUN_MSK = 0x01,
1829001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	AGG_TX_STATE_BT_PRIO_MSK = 0x02,
1830001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	AGG_TX_STATE_FEW_BYTES_MSK = 0x04,
1831bb8c093bdea62f2ae371b98ebff81b0407852fafChristoph Hellwig	AGG_TX_STATE_ABORT_MSK = 0x08,
1832b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	AGG_TX_STATE_LAST_SENT_TTL_MSK = 0x10,
1833529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK = 0x20,
1834529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	AGG_TX_STATE_LAST_SENT_BT_KILL_MSK = 0x40,
1835529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	AGG_TX_STATE_SCD_QUERY_MSK = 0x80,
1836529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	AGG_TX_STATE_TEST_BAD_CRC32_MSK = 0x100,
1837529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	AGG_TX_STATE_RESPONSE_MSK = 0x1ff,
1838529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	AGG_TX_STATE_DUMP_TX_MSK = 0x200,
1839529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	AGG_TX_STATE_DELAY_TX_MSK = 0x400
1840529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill};
1841529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1842529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill#define AGG_TX_STATE_LAST_SENT_MSK  (AGG_TX_STATE_LAST_SENT_TTL_MSK | \
1843529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill				     AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK | \
1844529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill				     AGG_TX_STATE_LAST_SENT_BT_KILL_MSK)
1845b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1846529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* # tx attempts for first frame in aggregation */
1847b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define AGG_TX_STATE_TRY_CNT_POS 12
1848529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill#define AGG_TX_STATE_TRY_CNT_MSK 0xf000
1849529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1850529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* Command ID and sequence number of Tx command for this frame */
1851529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill#define AGG_TX_STATE_SEQ_NUM_POS 16
1852529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill#define AGG_TX_STATE_SEQ_NUM_MSK 0xffff0000
1853529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1854529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/*
1855529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * REPLY_TX = 0x1c (response)
1856529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *
1857529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * This response may be in one of two slightly different formats, indicated
1858529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * by the frame_count field:
1859529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *
1860529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * 1)  No aggregation (frame_count == 1).  This reports Tx results for
1861529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *     a single frame.  Multiple attempts, at various bit rates, may have
186225a6572cc13ba2a3fefc02a63a077ff3664a1ca9Tomas Winkler *     been made for this frame.
186325a6572cc13ba2a3fefc02a63a077ff3664a1ca9Tomas Winkler *
186425a6572cc13ba2a3fefc02a63a077ff3664a1ca9Tomas Winkler * 2)  Aggregation (frame_count > 1).  This reports Tx results for
186525a6572cc13ba2a3fefc02a63a077ff3664a1ca9Tomas Winkler *     2 or more frames that used block-acknowledge.  All frames were
1866fe01b477bbd23e69c3bdc6bce5be510ddad8297dRon Rindjunsky *     transmitted at same rate.  Rate scaling may have been used if first
1867fe01b477bbd23e69c3bdc6bce5be510ddad8297dRon Rindjunsky *     frame in this new agg block failed in previous agg block(s).
18683fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler *
18693fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler *     Note that, for aggregation, ACK (block-ack) status is not delivered here;
1870a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler *     block-ack has not been received by the time the 4965 records this status.
18713fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler *     This status relates to reasons the tx might have been blocked or aborted
18723fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler *     within the sending station (this 4965), rather than whether it was
18733fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler *     received successfully by the destination station.
18743fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler */
18753fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winklerstruct agg_tx_status {
18763fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	__le16 status;
18773fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	__le16 sequence;
18783fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler} __attribute__ ((packed));
18793fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler
18803fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winklerstruct iwl4965_tx_resp {
18813fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	u8 frame_count;		/* 1 no aggregation, >1 aggregation */
18823fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	u8 bt_kill_count;	/* # blocked by bluetooth (unused for agg) */
18833fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	u8 failure_rts;		/* # failures due to unsuccessful RTS */
18843fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	u8 failure_frame;	/* # failures due to no ACK (unused for agg) */
18853fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler
18863fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	/* For non-agg:  Rate at which frame was successful.
18873fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	 * For agg:  Rate at which all frames were transmitted. */
18883fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	__le32 rate_n_flags;	/* RATE_MCS_*  */
18893fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler
1890001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	/* For non-agg:  RTS + CTS + frame tx attempts time + ACK.
1891001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 * For agg:  RTS + CTS + aggregation tx time + block-ack time. */
1892001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	__le16 wireless_media_time;	/* uSecs */
1893001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky
1894001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	__le16 reserved;
1895001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	__le32 pa_power1;	/* RF power amplifier measurement (not used) */
1896001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	__le32 pa_power2;
1897001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky
1898001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	/*
1899001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 * For non-agg:  frame status TX_STATUS_*
1900001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 * For agg:  status of 1st frame, AGG_TX_STATE_*; other frame status
1901001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 *           fields follow this one, up to frame_count.
1902001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 *           Bit fields:
1903001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 *           11- 0:  AGG_TX_STATE_* status code
19043fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	 *           15-12:  Retry count for 1st frame in aggregation (retries
19053fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	 *                   occur if tx failed for this frame when it was a
19063fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	 *                   member of a previous aggregation block).  If rate
19073fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	 *                   scaling is used, retry count indicates the rate
1908001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 *                   table entry used for all frames in the new agg.
1909001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 *           31-16:  Sequence # for this frame's Tx cmd (not SSN!)
1910001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 */
1911001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	union {
19123fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler		__le32 status;
19133fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler		struct agg_tx_status agg_status[0]; /* for each agg frame */
19143fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	} u;
1915001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky} __attribute__ ((packed));
1916001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky
1917001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky/*
1918001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky * definitions for initial rate index field
1919001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky * bits [3:0] initial rate index
1920001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky * bits [6:4] rate table color, used for the initial rate
1921001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky * bit-7 invalid rate indication
1922001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky *   i.e. rate was not chosen from rate table
1923001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky *   or rate table color was changed during frame retries
1924001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky * refer tlc rate info
1925001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky */
1926001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky
1927001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky#define IWL50_TX_RES_INIT_RATE_INDEX_POS	0
1928001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky#define IWL50_TX_RES_INIT_RATE_INDEX_MSK	0x0f
1929001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky#define IWL50_TX_RES_RATE_TABLE_COLOR_POS	4
1930001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky#define IWL50_TX_RES_RATE_TABLE_COLOR_MSK	0x70
1931b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define IWL50_TX_RES_INV_RATE_INDEX_MSK	0x80
1932b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1933529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* refer to ra_tid */
1934529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill#define IWL50_TX_RES_TID_POS	0
1935b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define IWL50_TX_RES_TID_MSK	0x0f
1936653fa4a07525e4cd9e7b90e6fc1f792119910636Emmanuel Grumbach#define IWL50_TX_RES_RA_POS	4
1937b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define IWL50_TX_RES_RA_MSK	0xf0
1938b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1939b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl5000_tx_resp {
1940529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	u8 frame_count;		/* 1 no aggregation, >1 aggregation */
1941529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	u8 bt_kill_count;	/* # blocked by bluetooth (unused for agg) */
1942b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 failure_rts;		/* # failures due to unsuccessful RTS */
1943b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 failure_frame;	/* # failures due to no ACK (unused for agg) */
1944fe01b477bbd23e69c3bdc6bce5be510ddad8297dRon Rindjunsky
1945fe01b477bbd23e69c3bdc6bce5be510ddad8297dRon Rindjunsky	/* For non-agg:  Rate at which frame was successful.
1946b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * For agg:  Rate at which all frames were transmitted. */
1947b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 rate_n_flags;	/* RATE_MCS_*  */
1948b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1949b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* For non-agg:  RTS + CTS + frame tx attempts time + ACK.
1950b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * For agg:  RTS + CTS + aggregation tx time + block-ack time. */
1951b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 wireless_media_time;	/* uSecs */
19522bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
19532bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	u8 pa_status;		/* RF power amplifier measurement (not used) */
1954b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 pa_integ_res_a[3];
19553d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 pa_integ_res_b[3];
19563d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 pa_integ_res_C[3];
19573d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
19583d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 tfd_info;
19593d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 seq_ctl;
19603d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 byte_cnt;
19613d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 tlc_info;
19623d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 ra_tid;		/* tid (0:3), sta_id (4:7) */
1963bb8c093bdea62f2ae371b98ebff81b0407852fafChristoph Hellwig	__le16 frame_ctrl;
1964b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/*
1965b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * For non-agg:  frame status TX_STATUS_*
1966b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * For agg:  status of 1st frame, AGG_TX_STATE_*; other frame status
1967bb8c093bdea62f2ae371b98ebff81b0407852fafChristoph Hellwig	 *           fields follow this one, up to frame_count.
1968b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 *           Bit fields:
1969b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 *           11- 0:  AGG_TX_STATE_* status code
19703d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 *           15-12:  Retry count for 1st frame in aggregation (retries
19713d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 *                   occur if tx failed for this frame when it was a
19723d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 *                   member of a previous aggregation block).  If rate
19733d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 *                   scaling is used, retry count indicates the rate
19743d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 *                   table entry used for all frames in the new agg.
19753d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 *           31-16:  Sequence # for this frame's Tx cmd (not SSN!)
19763d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 */
19773d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct agg_tx_status status;	/* TX status (in aggregation -
19783d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler					 * status of 1st frame) */
19793d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler} __attribute__ ((packed));
19803d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler/*
19813d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * REPLY_COMPRESSED_BA = 0xc5 (response only, not a command)
19823d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler *
19833d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * Reports Block-Acknowledge from recipient station
19843d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler */
19853d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl_compressed_ba_resp {
19863d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 sta_addr_lo32;
19873d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 sta_addr_hi16;
19883d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 reserved;
19893d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
19903d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	/* Index of recipient (BA-sending) station in uCode's station table */
19913d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 sta_id;
19923d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 tid;
19933d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 seq_ctl;
19943d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le64 bitmap;
19953d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 scd_flow;
19963d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 scd_ssn;
19973d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler} __attribute__ ((packed));
19983d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
1999b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
20008a1b02452862dd30980ad0ef493eed687bc81474Reinette Chatre * REPLY_TX_PWR_TABLE_CMD = 0x97 (command, has simple generic response)
2001b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
20022bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * See details under "TXPOWER" in iwl-4965-hw.h.
2003b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
20042bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
20052bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahillstruct iwl3945_txpowertable_cmd {
2006b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 band;		/* 0: 5 GHz, 1: 2.4 GHz */
2007b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved;
20082bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	__le16 channel;
20098a1b02452862dd30980ad0ef493eed687bc81474Reinette Chatre	struct iwl3945_power_per_rate power[IWL_MAX_RATES];
20108a1b02452862dd30980ad0ef493eed687bc81474Reinette Chatre} __attribute__ ((packed));
2011b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2012b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl4965_txpowertable_cmd {
20132bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	u8 band;		/* 0: 5 GHz, 1: 2.4 GHz */
20142bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	u8 reserved;
201566c73db7c6f7672e40c0bb1d2689f2d0d0922aadTomas Winkler	__le16 channel;
20162bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	struct iwl4965_tx_power_db tx_power;
20172bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill} __attribute__ ((packed));
20182bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
201966c73db7c6f7672e40c0bb1d2689f2d0d0922aadTomas Winkler
2020b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/**
20212bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * struct iwl3945_rate_scaling_cmd - Rate Scaling Command & Response
20222bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
2023b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_RATE_SCALE = 0x47 (command, has simple generic response)
20242bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
20252bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * NOTE: The table of rates passed to the uCode via the
20262bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * RATE_SCALE command sets up the corresponding order of
20272bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * rates used for all related commands, including rate
20282bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * masks, etc.
20292bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
20302bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * For example, if you set 9MB (PLCP 0x0f) as the first
20312bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * rate in the rate table, the bit mask for that rate
20322bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * when passed through ofdm_basic_rates on the REPLY_RXON
20332bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * command would be bit 0 (1 << 0)
20342bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill */
20352bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahillstruct iwl3945_rate_scaling_info {
20362bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	__le16 rate_n_flags;
20372bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	u8 try_cnt;
20382bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	u8 next_rate_index;
20392bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill} __attribute__ ((packed));
20402bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
20412bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahillstruct iwl3945_rate_scaling_cmd {
2042b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 table_id;
2043b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved[3];
2044b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct iwl3945_rate_scaling_info table[IWL_MAX_RATES];
204513c33a09b3703c2956345482017600434c853889Wey-Yi Guy} __attribute__ ((packed));
204613c33a09b3703c2956345482017600434c853889Wey-Yi Guy
204713c33a09b3703c2956345482017600434c853889Wey-Yi Guy
204813c33a09b3703c2956345482017600434c853889Wey-Yi Guy/*RS_NEW_API: only TLC_RTS remains and moved to bit 0 */
204913c33a09b3703c2956345482017600434c853889Wey-Yi Guy#define  LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK	(1 << 0)
205013c33a09b3703c2956345482017600434c853889Wey-Yi Guy
205113c33a09b3703c2956345482017600434c853889Wey-Yi Guy/* # of EDCA prioritized tx fifos */
205213c33a09b3703c2956345482017600434c853889Wey-Yi Guy#define  LINK_QUAL_AC_NUM AC_NUM
205313c33a09b3703c2956345482017600434c853889Wey-Yi Guy
2054b623a9f7c488e51dbe4320d8b5cdd0ba242d0067Johannes Berg/* # entries in rate scale table to support Tx retries */
205513c33a09b3703c2956345482017600434c853889Wey-Yi Guy#define  LINK_QUAL_MAX_RETRY_NUM 16
205613c33a09b3703c2956345482017600434c853889Wey-Yi Guy
20572bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill/* Tx antenna selection values */
205866c73db7c6f7672e40c0bb1d2689f2d0d0922aadTomas Winkler#define  LINK_QUAL_ANT_A_MSK (1 << 0)
20592bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill#define  LINK_QUAL_ANT_B_MSK (1 << 1)
20602bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill#define  LINK_QUAL_ANT_MSK   (LINK_QUAL_ANT_A_MSK|LINK_QUAL_ANT_B_MSK)
20612bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
206266c73db7c6f7672e40c0bb1d2689f2d0d0922aadTomas Winkler
20632bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill/**
20642bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * struct iwl_link_qual_general_params
20652bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
2066b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Used in REPLY_TX_LINK_QUALITY_CMD
20672bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill */
20682bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahillstruct iwl_link_qual_general_params {
20692bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	u8 flags;
20702bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
20712bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	/* No entries at or above this (driver chosen) index contain MIMO */
20722bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	u8 mimo_delimiter;
20732bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
2074b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* Best single antenna to use for single stream (legacy, SISO). */
20752bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	u8 single_stream_ant_msk;	/* LINK_QUAL_ANT_* */
20762bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
20772bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	/* Best antennas to use for MIMO (unused for 4965, assumes both). */
20782bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	u8 dual_stream_ant_msk;		/* LINK_QUAL_ANT_* */
20792bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
20802bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	/*
2081b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * If driver needs to use different initial rates for different
20822bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * EDCA QOS access categories (as implemented by tx fifos 0-3),
2083b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * this table will set that up, by indicating the indexes in the
2084b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * rs_table[LINK_QUAL_MAX_RETRY_NUM] rate table at which to start.
2085b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * Otherwise, driver should set all entries to 0.
2086b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 *
2087b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * Entry usage:
20882bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * 0 = Background, 1 = Best Effort (normal), 2 = Video, 3 = Voice
20892bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * TX FIFOs above 3 use same value (typically 0) as TX FIFO 3.
20902bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 */
20912bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	u8 start_rate_index[LINK_QUAL_AC_NUM];
20922bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill} __attribute__ ((packed));
20932bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
20942bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill#define LINK_QUAL_AGG_TIME_LIMIT_DEF	(4000) /* 4 milliseconds */
20952bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill#define LINK_QUAL_AGG_TIME_LIMIT_MAX	(65535)
20962bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill#define LINK_QUAL_AGG_TIME_LIMIT_MIN	(0)
20972bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
20982bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill#define LINK_QUAL_AGG_DISABLE_START_DEF	(3)
20992bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill#define LINK_QUAL_AGG_DISABLE_START_MAX	(255)
21002bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill#define LINK_QUAL_AGG_DISABLE_START_MIN	(0)
21012bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
21022bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill#define LINK_QUAL_AGG_FRAME_LIMIT_DEF	(31)
21032bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill#define LINK_QUAL_AGG_FRAME_LIMIT_MAX	(63)
21042bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill#define LINK_QUAL_AGG_FRAME_LIMIT_MIN	(0)
21052bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
21062bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill/**
21072bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * struct iwl_link_qual_agg_params
21082bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21092bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * Used in REPLY_TX_LINK_QUALITY_CMD
21102bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill */
21112bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahillstruct iwl_link_qual_agg_params {
21122bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
21132bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	/* Maximum number of uSec in aggregation.
21147aafef1c6e2e24f9a10dc2972bf0ee70624ccc47Wey-Yi Guy	 * Driver should set this to 4000 (4 milliseconds). */
21152bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	__le16 agg_time_limit;
21162bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
21177aafef1c6e2e24f9a10dc2972bf0ee70624ccc47Wey-Yi Guy	/*
21182bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * Number of Tx retries allowed for a frame, before that frame will
21192bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * no longer be considered for the start of an aggregation sequence
21202bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * (scheduler will then try to tx it as single frame).
21212bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * Driver should set this to 3.
21222bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 */
21232bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	u8 agg_dis_start_th;
21242bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
21252bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	/*
21262bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * Maximum number of frames in aggregation.
21272bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * 0 = no limit (default).  1 = no aggregation.
21282bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * Other values = max # frames in aggregation.
21292bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 */
21302bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	u8 agg_frame_cnt_limit;
21312bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
21322bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	__le32 reserved;
21332bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill} __attribute__ ((packed));
21342bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
21352bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill/*
21362bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * REPLY_TX_LINK_QUALITY_CMD = 0x4e (command, has simple generic response)
21372bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21382bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * For 4965 only; 3945 uses REPLY_RATE_SCALE.
21392bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21402bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * Each station in the 4965's internal station table has its own table of 16
21412bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * Tx rates and modulation modes (e.g. legacy/SISO/MIMO) for retrying Tx when
21422bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * an ACK is not received.  This command replaces the entire table for
21432bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * one station.
21442bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21452bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * NOTE:  Station must already be in 4965's station table.  Use REPLY_ADD_STA.
21462bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21472bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * The rate scaling procedures described below work well.  Of course, other
21482bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * procedures are possible, and may work better for particular environments.
21492bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21502bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21512bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * FILLING THE RATE TABLE
21522bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21532bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * Given a particular initial rate and mode, as determined by the rate
21542bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * scaling algorithm described below, the Linux driver uses the following
21552bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * formula to fill the rs_table[LINK_QUAL_MAX_RETRY_NUM] rate table in the
21562bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * Link Quality command:
21572bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
2158a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler *
21592bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * 1)  If using High-throughput (HT) (SISO or MIMO) initial rate:
21602bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     a) Use this same initial rate for first 3 entries.
21612bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     b) Find next lower available rate using same mode (SISO or MIMO),
21622bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *        use for next 3 entries.  If no lower rate available, switch to
21632bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *        legacy mode (no HT40 channel, no MIMO, no short guard interval).
21642bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     c) If using MIMO, set command's mimo_delimiter to number of entries
21652bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *        using MIMO (3 or 6).
21662bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     d) After trying 2 HT rates, switch to legacy mode (no HT40 channel,
21672bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *        no MIMO, no short guard interval), at the next lower bit rate
21682bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *        (e.g. if second HT bit rate was 54, try 48 legacy), and follow
21692bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *        legacy procedure for remaining table entries.
21702bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21712bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * 2)  If using legacy initial rate:
21722bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     a) Use the initial rate for only one entry.
21732bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     b) For each following entry, reduce the rate to next lower available
21742bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *        rate, until reaching the lowest available rate.
21752bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     c) When reducing rate, also switch antenna selection.
21762bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     d) Once lowest available rate is reached, repeat this rate until
21772bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *        rate table is filled (16 entries), switching antenna each entry.
21782bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21792bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21802bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * ACCUMULATING HISTORY
21812bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21822bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * The rate scaling algorithm for 4965, as implemented in Linux driver, uses
21832bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * two sets of frame Tx success history:  One for the current/active modulation
21842bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * mode, and one for a speculative/search mode that is being attempted.  If the
21852bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * speculative mode turns out to be more effective (i.e. actual transfer
21862bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * rate is better), then the driver continues to use the speculative mode
21872bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * as the new current active mode.
21882bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21892bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * Each history set contains, separately for each possible rate, data for a
21902bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * sliding window of the 62 most recent tx attempts at that rate.  The data
21912bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * includes a shifting bitmap of success(1)/failure(0), and sums of successful
21922bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * and attempted frames, from which the driver can additionally calculate a
21932bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * success ratio (success / attempted) and number of failures
21942bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * (attempted - success), and control the size of the window (attempted).
21952bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * The driver uses the bit map to remove successes from the success sum, as
21962bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * the oldest tx attempts fall out of the window.
21972bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21982bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * When the 4965 makes multiple tx attempts for a given frame, each attempt
21992bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * might be at a different rate, and have different modulation characteristics
22002bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * (e.g. antenna, fat channel, short guard interval), as set up in the rate
22012bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * scaling table in the Link Quality command.  The driver must determine
22022bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * which rate table entry was used for each tx attempt, to determine which
22032bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * rate-specific history to update, and record only those attempts that
22042bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * match the modulation characteristics of the history set.
22052bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
22062bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * When using block-ack (aggregation), all frames are transmitted at the same
22072bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * rate, since there is no per-attempt acknowledgment from the destination
22082bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * station.  The Tx response struct iwl_tx_resp indicates the Tx rate in
22092bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * rate_n_flags field.  After receiving a block-ack, the driver can update
22102bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * history for the entire block all at once.
22112bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
22122bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
22132bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * FINDING BEST STARTING RATE:
22142bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
22152bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * When working with a selected initial modulation mode (see below), the
22162bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * driver attempts to find a best initial rate.  The initial rate is the
22172bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * first entry in the Link Quality command's rate table.
22182bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
22192bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * 1)  Calculate actual throughput (success ratio * expected throughput, see
22202bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     table below) for current initial rate.  Do this only if enough frames
22212bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     have been attempted to make the value meaningful:  at least 6 failed
22222bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     tx attempts, or at least 8 successes.  If not enough, don't try rate
22232bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     scaling yet.
22242bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
22252bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * 2)  Find available rates adjacent to current initial rate.  Available means:
22262bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     a)  supported by hardware &&
22272bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     b)  supported by association &&
22282bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     c)  within any constraints selected by user
22292bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
22302bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * 3)  Gather measured throughputs for adjacent rates.  These might not have
22312bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     enough history to calculate a throughput.  That's okay, we might try
22322bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     using one of them anyway!
22332bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
22342bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * 4)  Try decreasing rate if, for current rate:
22352bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     a)  success ratio is < 15% ||
22362bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     b)  lower adjacent rate has better measured throughput ||
22372bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     c)  higher adjacent rate has worse throughput, and lower is unmeasured
22382bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
22392bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     As a sanity check, if decrease was determined above, leave rate
22402bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     unchanged if:
22412bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     a)  lower rate unavailable
22422bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     b)  success ratio at current rate > 85% (very good)
22432bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     c)  current measured throughput is better than expected throughput
22442bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *         of lower rate (under perfect 100% tx conditions, see table below)
22452bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
22462bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * 5)  Try increasing rate if, for current rate:
22472bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     a)  success ratio is < 15% ||
22482bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     b)  both adjacent rates' throughputs are unmeasured (try it!) ||
22492bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     b)  higher adjacent rate has better measured throughput ||
22502bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     c)  lower adjacent rate has worse throughput, and higher is unmeasured
22512bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
22522bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     As a sanity check, if increase was determined above, leave rate
22532bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     unchanged if:
22542bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     a)  success ratio at current rate < 70%.  This is not particularly
22552bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *         good performance; higher rate is sure to have poorer success.
22562bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
22572bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * 6)  Re-evaluate the rate after each tx frame.  If working with block-
22582bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     acknowledge, history and statistics may be calculated for the entire
22592bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     block (including prior history that fits within the history windows),
22602bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     before re-evaluation.
22612bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
22622bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * FINDING BEST STARTING MODULATION MODE:
22632bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
22642bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * After working with a modulation mode for a "while" (and doing rate scaling),
22652bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * the driver searches for a new initial mode in an attempt to improve
22662bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * throughput.  The "while" is measured by numbers of attempted frames:
22672bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
22682bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * For legacy mode, search for new mode after:
22692bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *   480 successful frames, or 160 failed frames
22702bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * For high-throughput modes (SISO or MIMO), search for new mode after:
2271b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *   4500 successful frames, or 400 failed frames
227266c73db7c6f7672e40c0bb1d2689f2d0d0922aadTomas Winkler *
22732bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * Mode switch possibilities are (3 for each mode):
22742bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
2275b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * For legacy:
2276b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *   Change antenna, try SISO (if HT association), try MIMO (if HT association)
22772bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * For SISO:
227866c73db7c6f7672e40c0bb1d2689f2d0d0922aadTomas Winkler *   Change antenna, try MIMO, try shortened guard interval (SGI)
227966c73db7c6f7672e40c0bb1d2689f2d0d0922aadTomas Winkler * For MIMO:
22802bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *   Try SISO antenna A, SISO antenna B, try shortened guard interval (SGI)
22812bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
22822bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * When trying a new mode, use the same bit rate as the old/current mode when
22832bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * trying antenna switches and shortened guard interval.  When switching to
22842bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * SISO from MIMO or legacy, or to MIMO from SISO or legacy, use a rate
22852bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * for which the expected throughput (under perfect conditions) is about the
2286b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * same or slightly better than the actual measured throughput delivered by
22872bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * the old/current mode.
2288b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
2289b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Actual throughput can be estimated by multiplying the expected throughput
2290b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * by the success ratio (successful / attempted tx frames).  Frame size is
2291b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * not considered in this calculation; it assumes that frame size will average
2292dab1c161fed18eb6b3472bdbfd827264caae097fWey-Yi Guy * out to be fairly consistent over several samples.  The following are
2293dab1c161fed18eb6b3472bdbfd827264caae097fWey-Yi Guy * metric values for expected throughput assuming 100% success ratio.
2294dab1c161fed18eb6b3472bdbfd827264caae097fWey-Yi Guy * Only G band has support for CCK rates:
2295dab1c161fed18eb6b3472bdbfd827264caae097fWey-Yi Guy *
2296dab1c161fed18eb6b3472bdbfd827264caae097fWey-Yi Guy *           RATE:  1    2    5   11    6   9   12   18   24   36   48   54   60
2297dab1c161fed18eb6b3472bdbfd827264caae097fWey-Yi Guy *
2298dab1c161fed18eb6b3472bdbfd827264caae097fWey-Yi Guy *              G:  7   13   35   58   40  57   72   98  121  154  177  186  186
2299dab1c161fed18eb6b3472bdbfd827264caae097fWey-Yi Guy *              A:  0    0    0    0   40  57   72   98  121  154  177  186  186
2300dab1c161fed18eb6b3472bdbfd827264caae097fWey-Yi Guy *     SISO 20MHz:  0    0    0    0   42  42   76  102  124  159  183  193  202
2301456d0f76727ba6f97aa1cee63f1bae84642768c4Wey-Yi Guy * SGI SISO 20MHz:  0    0    0    0   46  46   82  110  132  168  192  202  211
2302dab1c161fed18eb6b3472bdbfd827264caae097fWey-Yi Guy *     MIMO 20MHz:  0    0    0    0   74  74  123  155  179  214  236  244  251
2303dab1c161fed18eb6b3472bdbfd827264caae097fWey-Yi Guy * SGI MIMO 20MHz:  0    0    0    0   81  81  131  164  188  222  243  251  257
2304dab1c161fed18eb6b3472bdbfd827264caae097fWey-Yi Guy *     SISO 40MHz:  0    0    0    0   77  77  127  160  184  220  242  250  257
2305456d0f76727ba6f97aa1cee63f1bae84642768c4Wey-Yi Guy * SGI SISO 40MHz:  0    0    0    0   83  83  135  169  193  229  250  257  264
230606702a735eacf8679e9ff0d49eb3c989bc6b96ceWey-Yi Guy *     MIMO 40MHz:  0    0    0    0  123 123  182  214  235  264  279  285  289
230706702a735eacf8679e9ff0d49eb3c989bc6b96ceWey-Yi Guy * SGI MIMO 40MHz:  0    0    0    0  131 131  191  222  242  270  284  289  293
230806702a735eacf8679e9ff0d49eb3c989bc6b96ceWey-Yi Guy *
2309456d0f76727ba6f97aa1cee63f1bae84642768c4Wey-Yi Guy * After the new mode has been tried for a short while (minimum of 6 failed
2310456d0f76727ba6f97aa1cee63f1bae84642768c4Wey-Yi Guy * frames or 8 successful frames), compare success ratio and actual throughput
2311456d0f76727ba6f97aa1cee63f1bae84642768c4Wey-Yi Guy * estimate of the new mode with the old.  If either is better with the new
2312456d0f76727ba6f97aa1cee63f1bae84642768c4Wey-Yi Guy * mode, continue to use the new mode.
2313456d0f76727ba6f97aa1cee63f1bae84642768c4Wey-Yi Guy *
2314456d0f76727ba6f97aa1cee63f1bae84642768c4Wey-Yi Guy * Continue comparing modes until all 3 possibilities have been tried.
2315456d0f76727ba6f97aa1cee63f1bae84642768c4Wey-Yi Guy * If moving from legacy to HT, try all 3 possibilities from the new HT
2316456d0f76727ba6f97aa1cee63f1bae84642768c4Wey-Yi Guy * mode.  After trying all 3, a best mode is found.  Continue to use this mode
2317b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * for the longer "while" described above (e.g. 480 successful frames for
2318b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * legacy), and then repeat the search process.
23193058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *
23203058f02137359efb412975cf94a9fa7c25413387Ben M Cahill */
23213058f02137359efb412975cf94a9fa7c25413387Ben M Cahillstruct iwl_link_quality_cmd {
2322a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler
2323b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* Index of destination/recipient station in uCode's station table */
23242aa6ab86bc475a115f56645591d2413981846509Tomas Winkler	u8 sta_id;
2325b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved1;
2326b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 control;		/* not used */
2327b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct iwl_link_qual_general_params general_params;
2328b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct iwl_link_qual_agg_params agg_params;
2329b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2330b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/*
2331b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * Rate info; when using rate-scaling, Tx command's initial_rate_index
2332b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * specifies 1st Tx rate attempted, via index into this table.
2333b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * 4965 works its way through table when retrying Tx.
2334b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 */
2335b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct {
2336b481de9ca074528fe8c429604e2777db8b89806aZhu Yi		__le32 rate_n_flags;	/* RATE_MCS_*, IWL_RATE_* */
2337b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	} rs_table[LINK_QUAL_MAX_RETRY_NUM];
2338b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 reserved2;
2339b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2340b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2341b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2342b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * BT configuration enable flags:
2343b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *   bit 0 - 1: BT channel announcement enabled
2344b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *           0: disable
2345b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *   bit 1 - 1: priority of BT device enabled
2346b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *           0: disable
2347b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *   bit 2 - 1: BT 2 wire support enabled
2348b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *           0: disable
2349b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
23502aa6ab86bc475a115f56645591d2413981846509Tomas Winkler#define BT_COEX_DISABLE (0x0)
2351b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define BT_ENABLE_CHANNEL_ANNOUNCE BIT(0)
2352b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define BT_ENABLE_PRIORITY	   BIT(1)
2353b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define BT_ENABLE_2_WIRE	   BIT(2)
23542aa6ab86bc475a115f56645591d2413981846509Tomas Winkler
2355b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define BT_COEX_DISABLE (0x0)
2356b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define BT_COEX_ENABLE  (BT_ENABLE_CHANNEL_ANNOUNCE | BT_ENABLE_PRIORITY)
2357b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2358b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define BT_LEAD_TIME_MIN (0x0)
2359b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define BT_LEAD_TIME_DEF (0x1E)
2360b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define BT_LEAD_TIME_MAX (0xFF)
23612aa6ab86bc475a115f56645591d2413981846509Tomas Winkler
2362b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define BT_MAX_KILL_MIN (0x1)
2363b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define BT_MAX_KILL_DEF (0x5)
2364b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define BT_MAX_KILL_MAX (0xFF)
2365b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2366b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2367b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_BT_CONFIG = 0x9b (command, has simple generic response)
2368b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
2369b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * 3945 and 4965 support hardware handshake with Bluetooth device on
2370b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * same platform.  Bluetooth device alerts wireless device when it will Tx;
2371b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * wireless device can delay or kill its own Tx to accommodate.
2372b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
2373b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl_bt_cmd {
23742aa6ab86bc475a115f56645591d2413981846509Tomas Winkler	u8 flags;
2375b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 lead_time;
2376b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 max_kill;
2377b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved;
2378b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 kill_ack_mask;
2379b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 kill_cts_mask;
23802aa6ab86bc475a115f56645591d2413981846509Tomas Winkler} __attribute__ ((packed));
2381b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2382b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
2383b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (6)
2384b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Spectrum Management (802.11h) Commands, Responses, Notifications:
2385b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
2386b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
2387b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
23882aa6ab86bc475a115f56645591d2413981846509Tomas Winkler/*
2389b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Spectrum Management
2390b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
2391b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define MEASUREMENT_FILTER_FLAG (RXON_FILTER_PROMISC_MSK         | \
2392b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 RXON_FILTER_CTL2HOST_MSK        | \
23932aa6ab86bc475a115f56645591d2413981846509Tomas Winkler				 RXON_FILTER_ACCEPT_GRP_MSK      | \
2394b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 RXON_FILTER_DIS_DECRYPT_MSK     | \
2395b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 RXON_FILTER_DIS_GRP_DECRYPT_MSK | \
2396b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 RXON_FILTER_ASSOC_MSK           | \
2397b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 RXON_FILTER_BCON_AWARE_MSK)
2398b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2399b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl_measure_channel {
2400b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 duration;	/* measurement duration in extended beacon
2401b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 * format */
2402b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 channel;		/* channel to measure */
2403b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 type;		/* see enum iwl_measure_type */
2404b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved;
2405b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
24062aa6ab86bc475a115f56645591d2413981846509Tomas Winkler
2407b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2408b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74 (command)
2409b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
2410b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl_spectrum_cmd {
2411b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 len;		/* number of bytes starting from token */
24122aa6ab86bc475a115f56645591d2413981846509Tomas Winkler	u8 token;		/* token id */
2413b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 id;			/* measurement id -- 0 or 1 */
2414b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 origin;		/* 0 = TGh, 1 = other, 2 = TGk */
2415b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 periodic;		/* 1 = periodic */
2416b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 path_loss_timeout;
24172aa6ab86bc475a115f56645591d2413981846509Tomas Winkler	__le32 start_time;	/* start time in extended beacon format */
2418b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 reserved2;
2419b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 flags;		/* rxon flags */
2420b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 filter_flags;	/* rxon filter flags */
2421b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 channel_count;	/* minimum 1, maximum 10 */
2422b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved3;
2423b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct iwl_measure_channel channels[10];
2424b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2425b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2426b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2427b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74 (response)
2428b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
2429b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl_spectrum_resp {
24302aa6ab86bc475a115f56645591d2413981846509Tomas Winkler	u8 token;
2431b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 id;			/* id of the prior command replaced, or 0xff */
2432b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 status;		/* 0 - command will be handled
2433b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 * 1 - cannot handle (conflicts with another
2434b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 *     measurement) */
2435b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2436b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2437b481de9ca074528fe8c429604e2777db8b89806aZhu Yienum iwl_measurement_state {
24382aa6ab86bc475a115f56645591d2413981846509Tomas Winkler	IWL_MEASUREMENT_START = 0,
2439b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASUREMENT_STOP = 1,
2440b481de9ca074528fe8c429604e2777db8b89806aZhu Yi};
2441b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2442b481de9ca074528fe8c429604e2777db8b89806aZhu Yienum iwl_measurement_status {
2443b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASUREMENT_OK = 0,
2444b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASUREMENT_CONCURRENT = 1,
2445b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASUREMENT_CSA_CONFLICT = 2,
2446b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASUREMENT_TGH_CONFLICT = 3,
2447b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* 4-5 reserved */
24482aa6ab86bc475a115f56645591d2413981846509Tomas Winkler	IWL_MEASUREMENT_STOPPED = 6,
2449b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASUREMENT_TIMEOUT = 7,
24502aa6ab86bc475a115f56645591d2413981846509Tomas Winkler	IWL_MEASUREMENT_PERIODIC_FAILED = 8,
2451b481de9ca074528fe8c429604e2777db8b89806aZhu Yi};
2452b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2453b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define NUM_ELEMENTS_IN_HISTOGRAM 8
2454b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2455b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl_measurement_histogram {
2456b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 ofdm[NUM_ELEMENTS_IN_HISTOGRAM];	/* in 0.8usec counts */
2457b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 cck[NUM_ELEMENTS_IN_HISTOGRAM];	/* in 1usec counts */
2458b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2459b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2460ca579617d81baf5865498eb5fae58e453ee77c2cMohamed Abbas/* clear channel availability counters */
2461b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl_measurement_cca_counters {
2462b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 ofdm;
2463b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 cck;
2464b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2465b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2466b481de9ca074528fe8c429604e2777db8b89806aZhu Yienum iwl_measure_type {
2467b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASURE_BASIC = (1 << 0),
2468e312c24cf8229f9b6e76dbfd5d99eefe21f4ac0aJohannes Berg	IWL_MEASURE_CHANNEL_LOAD = (1 << 1),
2469b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASURE_HISTOGRAM_RPI = (1 << 2),
2470b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASURE_HISTOGRAM_NOISE = (1 << 3),
2471b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASURE_FRAME = (1 << 4),
2472e312c24cf8229f9b6e76dbfd5d99eefe21f4ac0aJohannes Berg	/* bits 5:6 are reserved */
2473b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASURE_IDLE = (1 << 7),
2474b481de9ca074528fe8c429604e2777db8b89806aZhu Yi};
2475b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2476e312c24cf8229f9b6e76dbfd5d99eefe21f4ac0aJohannes Berg/*
2477b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * SPECTRUM_MEASURE_NOTIFICATION = 0x75 (notification only, not a command)
2478e7b635814b640c6fd9dca1c254dc22fac6fb9a1aTomas Winkler */
2479e7b635814b640c6fd9dca1c254dc22fac6fb9a1aTomas Winklerstruct iwl_spectrum_notification {
2480e312c24cf8229f9b6e76dbfd5d99eefe21f4ac0aJohannes Berg	u8 id;			/* measurement id -- 0 or 1 */
2481e312c24cf8229f9b6e76dbfd5d99eefe21f4ac0aJohannes Berg	u8 token;
2482e312c24cf8229f9b6e76dbfd5d99eefe21f4ac0aJohannes Berg	u8 channel_index;	/* index in measurement channel list */
2483e312c24cf8229f9b6e76dbfd5d99eefe21f4ac0aJohannes Berg	u8 state;		/* 0 - start, 1 - stop */
2484b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 start_time;	/* lower 32-bits of TSF */
2485b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 band;		/* 0 - 5.2GHz, 1 - 2.4GHz */
2486b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 channel;
2487b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 type;		/* see enum iwl_measurement_type */
2488b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved1;
2489b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* NOTE:  cca_ofdm, cca_cck, basic_type, and histogram are only only
2490b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * valid if applicable for measurement type requested. */
2491a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler	__le32 cca_ofdm;	/* cca fraction time in 40Mhz clock periods */
2492b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 cca_cck;		/* cca fraction time in 44Mhz clock periods */
2493b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 cca_time;	/* channel load time in usecs */
2494b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 basic_type;		/* 0 - bss, 1 - ofdm preamble, 2 -
2495b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 * unidentified */
2496600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler	u8 reserved2[3];
2497600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler	struct iwl_measurement_histogram histogram;
2498600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler	__le32 stop_time;	/* lower 32-bits of TSF */
2499600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler	__le32 status;		/* see iwl_measurement_status */
2500600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler} __attribute__ ((packed));
2501600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler
2502600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler/******************************************************************************
2503600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler * (7)
2504600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler * Power Management Commands, Responses, Notifications:
2505600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler *
2506600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler *****************************************************************************/
2507600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler
2508b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/**
2509ca579617d81baf5865498eb5fae58e453ee77c2cMohamed Abbas * struct iwl_powertable_cmd - Power Table Command
2510b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * @flags: See below:
2511600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler *
2512600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler * POWER_TABLE_CMD = 0x77 (command, has simple generic response)
2513b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
2514b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * PM allow:
2515b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *   bit 0 - '0' Driver not allow power management
2516b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *           '1' Driver allow PM (use rest of parameters)
2517b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
2518b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * uCode send sleep notifications:
2519b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *   bit 1 - '0' Don't send sleep notification
2520b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *           '1' send sleep notification (SEND_PM_NOTIFICATION)
2521b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
2522b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Sleep over DTIM
25232aa6ab86bc475a115f56645591d2413981846509Tomas Winkler *   bit 2 - '0' PM have to walk up every DTIM
2524b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *           '1' PM could sleep over DTIM till listen Interval.
2525b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
2526b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * PCI power managed
2527b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *   bit 3 - '0' (PCI_CFG_LINK_CTRL & 0x1)
2528b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *           '1' !(PCI_CFG_LINK_CTRL & 0x1)
2529b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
2530b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Fast PD
2531b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *   bit 4 - '1' Put radio to sleep when receiving frame for others
2532b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
2533b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Force sleep Modes
2534b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *   bit 31/30- '00' use both mac/xtal sleeps
2535b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *              '01' force Mac sleep
2536b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *              '10' force xtal sleep
2537b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *              '11' Illegal set
2538b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
2539b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * NOTE: if sleep_interval[SLEEP_INTRVL_TABLE_SIZE-1] > DTIM period then
2540b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * ucode assume sleep over DTIM is allowed and we don't need to wake up
2541b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * for every DTIM.
2542b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
2543b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define IWL_POWER_VEC_SIZE 5
2544b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2545b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define IWL_POWER_DRIVER_ALLOW_SLEEP_MSK	cpu_to_le16(BIT(0))
2546b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define IWL_POWER_SLEEP_OVER_DTIM_MSK		cpu_to_le16(BIT(2))
2547b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define IWL_POWER_PCI_PM_MSK			cpu_to_le16(BIT(3))
2548b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define IWL_POWER_FAST_PD			cpu_to_le16(BIT(4))
2549b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2550b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl3945_powertable_cmd {
2551b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 flags;
2552b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved[2];
25532aa6ab86bc475a115f56645591d2413981846509Tomas Winkler	__le32 rx_data_timeout;
2554b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 tx_data_timeout;
2555b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 sleep_interval[IWL_POWER_VEC_SIZE];
2556b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2557b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2558b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl_powertable_cmd {
2559b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 flags;
25602aa6ab86bc475a115f56645591d2413981846509Tomas Winkler	u8 keep_alive_seconds;		/* 3945 reserved */
2561b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 debug_flags;			/* 3945 reserved */
2562b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 rx_data_timeout;
2563b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 tx_data_timeout;
2564b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 sleep_interval[IWL_POWER_VEC_SIZE];
2565b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 keep_alive_beacons;
25663a41bbd515d449604f3488c5f8dd62802f09d19bWey-Yi Guy} __attribute__ ((packed));
2567b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2568b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
256947f4a5871614756627d7209e0569b58faf99b0d9Emmanuel Grumbach * PM_SLEEP_NOTIFICATION = 0x7A (notification only, not a command)
2570b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * 3945 and 4965 identical.
2571b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
2572b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl_sleep_notification {
2573b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 pm_sleep_mode;
2574b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 pm_wakeup_src;
2575672639de13c4db92ed6a47e68043a4317e219902Wey-Yi Guy	__le16 reserved;
2576672639de13c4db92ed6a47e68043a4317e219902Wey-Yi Guy	__le32 sleep_time;
2577672639de13c4db92ed6a47e68043a4317e219902Wey-Yi Guy	__le32 tsf_low;
2578672639de13c4db92ed6a47e68043a4317e219902Wey-Yi Guy	__le32 bcon_timer;
2579672639de13c4db92ed6a47e68043a4317e219902Wey-Yi Guy} __attribute__ ((packed));
2580672639de13c4db92ed6a47e68043a4317e219902Wey-Yi Guy
2581672639de13c4db92ed6a47e68043a4317e219902Wey-Yi Guy/* Sleep states.  3945 and 4965 identical. */
2582b481de9ca074528fe8c429604e2777db8b89806aZhu Yienum {
2583b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_PM_NO_SLEEP = 0,
2584b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_PM_SLP_MAC = 1,
2585b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_PM_SLP_FULL_MAC_UNASSOCIATE = 2,
2586b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_PM_SLP_FULL_MAC_CARD_STATE = 3,
2587b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_PM_SLP_PHY = 4,
258851e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison	IWL_PM_SLP_REPENT = 5,
258951e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison	IWL_PM_WAKEUP_BY_TIMER = 6,
2590d16dc48a2ea14af9980d0ea79d041f4b53e47b62Tomas Winkler	IWL_PM_WAKEUP_BY_DRIVER = 7,
25913058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	IWL_PM_WAKEUP_BY_RFKILL = 8,
25922a421b91d6fe89e27ded7544a25449c0b050098fTomas Winkler	/* 3 reserved */
25933058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	IWL_PM_NUM_OF_MODES = 12,
25943058f02137359efb412975cf94a9fa7c25413387Ben M Cahill};
25953058f02137359efb412975cf94a9fa7c25413387Ben M Cahill
25963058f02137359efb412975cf94a9fa7c25413387Ben M Cahill/*
25973058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * REPLY_CARD_STATE_CMD = 0xa0 (command, has simple generic response)
25983058f02137359efb412975cf94a9fa7c25413387Ben M Cahill */
25993058f02137359efb412975cf94a9fa7c25413387Ben M Cahill#define CARD_STATE_CMD_DISABLE 0x00	/* Put card to sleep */
26003058f02137359efb412975cf94a9fa7c25413387Ben M Cahill#define CARD_STATE_CMD_ENABLE  0x01	/* Wake up card */
26013058f02137359efb412975cf94a9fa7c25413387Ben M Cahill#define CARD_STATE_CMD_HALT    0x02	/* Power down permanently */
26022a421b91d6fe89e27ded7544a25449c0b050098fTomas Winklerstruct iwl_card_state_cmd {
26033058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le32 status;		/* CARD_STATE_CMD_* request new power state */
26043058f02137359efb412975cf94a9fa7c25413387Ben M Cahill} __attribute__ ((packed));
26053058f02137359efb412975cf94a9fa7c25413387Ben M Cahill
26063058f02137359efb412975cf94a9fa7c25413387Ben M Cahill/*
26073058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * CARD_STATE_NOTIFICATION = 0xa1 (notification only, not a command)
26083058f02137359efb412975cf94a9fa7c25413387Ben M Cahill */
26093058f02137359efb412975cf94a9fa7c25413387Ben M Cahillstruct iwl_card_state_notif {
26103d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 flags;
26113d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler} __attribute__ ((packed));
26123d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
26133d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define HW_CARD_DISABLED   0x01
26143d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define SW_CARD_DISABLED   0x02
26153d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define CT_CARD_DISABLED   0x04
26163d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define RXON_CARD_DISABLED 0x10
26173d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
26183d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl_ct_kill_config {
26193d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32   reserved;
26203d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32   critical_temperature_M;
26213d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32   critical_temperature_R;
26223d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler}  __attribute__ ((packed));
26233d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
26243d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler/* 1000, and 6x00 */
26253d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl_ct_kill_throttling_config {
26263d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32   critical_temperature_exit;
26270d21044effa10044930419c6f837f75191229c3aWinkler, Tomas	__le32   reserved;
26280d21044effa10044930419c6f837f75191229c3aWinkler, Tomas	__le32   critical_temperature_enter;
26290d21044effa10044930419c6f837f75191229c3aWinkler, Tomas}  __attribute__ ((packed));
26302a421b91d6fe89e27ded7544a25449c0b050098fTomas Winkler
26313058f02137359efb412975cf94a9fa7c25413387Ben M Cahill/******************************************************************************
26323058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * (8)
26333058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * Scan Commands, Responses, Notifications:
2634d16dc48a2ea14af9980d0ea79d041f4b53e47b62Tomas Winkler *
26353058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *****************************************************************************/
2636d16dc48a2ea14af9980d0ea79d041f4b53e47b62Tomas Winkler
2637b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define SCAN_CHANNEL_TYPE_PASSIVE cpu_to_le32(0)
2638d16dc48a2ea14af9980d0ea79d041f4b53e47b62Tomas Winkler#define SCAN_CHANNEL_TYPE_ACTIVE  cpu_to_le32(1)
2639d16dc48a2ea14af9980d0ea79d041f4b53e47b62Tomas Winkler
2640f53696de6722a4aac00b76e25a5321c01e88a55fTomas Winkler/**
2641f53696de6722a4aac00b76e25a5321c01e88a55fTomas Winkler * struct iwl_scan_channel - entry in REPLY_SCAN_CMD channel table
26423058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *
26433058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * One for each channel in the scan list.
2644b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Each channel can independently select:
2645b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * 1)  SSID for directed active scans
26460d21044effa10044930419c6f837f75191229c3aWinkler, Tomas * 2)  Txpower setting (for rate specified within Tx command)
26470d21044effa10044930419c6f837f75191229c3aWinkler, Tomas * 3)  How long to stay on-channel (behavior may be modified by quiet_time,
26480d21044effa10044930419c6f837f75191229c3aWinkler, Tomas *     quiet_plcp_th, good_CRC_th)
26493058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *
26502a421b91d6fe89e27ded7544a25449c0b050098fTomas Winkler * To avoid uCode errors, make sure the following are true (see comments
26513058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * under struct iwl_scan_cmd about max_out_time and quiet_time):
26522a3b793d6a0ff30ad4a541230a6dba2ecb6fff1bBen M Cahill * 1)  If using passive_dwell (i.e. passive_dwell != 0):
26532a3b793d6a0ff30ad4a541230a6dba2ecb6fff1bBen M Cahill *     active_dwell <= passive_dwell (< max_out_time if max_out_time != 0)
26542a3b793d6a0ff30ad4a541230a6dba2ecb6fff1bBen M Cahill * 2)  quiet_time <= active_dwell
26552a3b793d6a0ff30ad4a541230a6dba2ecb6fff1bBen M Cahill * 3)  If restricting off-channel time (i.e. max_out_time !=0):
26563058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *     passive_dwell < max_out_time
26572a421b91d6fe89e27ded7544a25449c0b050098fTomas Winkler *     active_dwell < max_out_time
2658b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
2659b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2660b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* FIXME: rename to AP1, remove tpc */
2661b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl3945_scan_channel {
2662b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/*
26639b3bf06abad70db820c74c90118ea49358549d22Johannes Berg	 * type is defined as:
26649b3bf06abad70db820c74c90118ea49358549d22Johannes Berg	 * 0:0 1 = active, 0 = passive
266551e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison	 * 1:4 SSID direct bit map; if a bit is set, then corresponding
266696ff56419504ac6a610ff1af42330e0423242e16Johannes Berg	 *     SSID IE is transmitted in probe request.
266796ff56419504ac6a610ff1af42330e0423242e16Johannes Berg	 * 5:7 reserved
266896ff56419504ac6a610ff1af42330e0423242e16Johannes Berg	 */
2669b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 type;
267089612124d6d62230043ebd827a2b54ea5ea5280cAbhijeet Kolekar	u8 channel;	/* band is selected by iwl3945_scan_cmd "flags" field */
2671b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct iwl3945_tx_power tpc;
2672b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 active_dwell;	/* in 1024-uSec TU (time units), typ 5-50 */
2673b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 passive_dwell;	/* in 1024-uSec TU (time units), typ 20-500 */
26743058f02137359efb412975cf94a9fa7c25413387Ben M Cahill} __attribute__ ((packed));
26753058f02137359efb412975cf94a9fa7c25413387Ben M Cahill
26763058f02137359efb412975cf94a9fa7c25413387Ben M Cahill/* set number of direct probes u8 type */
26773058f02137359efb412975cf94a9fa7c25413387Ben M Cahill#define IWL39_SCAN_PROBE_MASK(n) ((BIT(n) | (BIT(n) - BIT(1))))
26783058f02137359efb412975cf94a9fa7c25413387Ben M Cahill
26793058f02137359efb412975cf94a9fa7c25413387Ben M Cahillstruct iwl_scan_channel {
26803058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	/*
26813058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 * type is defined as:
26823058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 * 0:0 1 = active, 0 = passive
26833058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 * 1:20 SSID direct bit map; if a bit is set, then corresponding
26843058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 *     SSID IE is transmitted in probe request.
26853058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 * 21:31 reserved
26863058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 */
26873058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le32 type;
26883058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le16 channel;	/* band is selected by iwl_scan_cmd "flags" field */
26893058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	u8 tx_gain;		/* gain for analog radio */
26903058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	u8 dsp_atten;		/* gain for DSP */
26913058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le16 active_dwell;	/* in 1024-uSec TU (time units), typ 5-50 */
26923058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le16 passive_dwell;	/* in 1024-uSec TU (time units), typ 20-500 */
26933058f02137359efb412975cf94a9fa7c25413387Ben M Cahill} __attribute__ ((packed));
26943058f02137359efb412975cf94a9fa7c25413387Ben M Cahill
26953058f02137359efb412975cf94a9fa7c25413387Ben M Cahill/* set number of direct probes __le32 type */
26963058f02137359efb412975cf94a9fa7c25413387Ben M Cahill#define IWL_SCAN_PROBE_MASK(n) 	cpu_to_le32((BIT(n) | (BIT(n) - BIT(1))))
26973058f02137359efb412975cf94a9fa7c25413387Ben M Cahill
26983058f02137359efb412975cf94a9fa7c25413387Ben M Cahill/**
26993058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * struct iwl_ssid_ie - directed scan network information element
27003058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *
27013058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * Up to 20 of these may appear in REPLY_SCAN_CMD (Note: Only 4 are in
27023058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 3945 SCAN api), selected by "type" bit field in struct iwl_scan_channel;
27033058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * each channel may select different ssids from among the 20 (4) entries.
27043058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * SSID IEs get transmitted in reverse order of entry.
27053058f02137359efb412975cf94a9fa7c25413387Ben M Cahill */
27063058f02137359efb412975cf94a9fa7c25413387Ben M Cahillstruct iwl_ssid_ie {
27073058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	u8 id;
27083058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	u8 len;
27093058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	u8 ssid[32];
27103058f02137359efb412975cf94a9fa7c25413387Ben M Cahill} __attribute__ ((packed));
27113058f02137359efb412975cf94a9fa7c25413387Ben M Cahill
27123058f02137359efb412975cf94a9fa7c25413387Ben M Cahill#define PROBE_OPTION_MAX_3945		4
27133058f02137359efb412975cf94a9fa7c25413387Ben M Cahill#define PROBE_OPTION_MAX		20
27143058f02137359efb412975cf94a9fa7c25413387Ben M Cahill#define TX_CMD_LIFE_TIME_INFINITE	cpu_to_le32(0xFFFFFFFF)
27153058f02137359efb412975cf94a9fa7c25413387Ben M Cahill#define IWL_GOOD_CRC_TH_DISABLED	0
27163058f02137359efb412975cf94a9fa7c25413387Ben M Cahill#define IWL_GOOD_CRC_TH_DEFAULT		cpu_to_le16(1)
27173058f02137359efb412975cf94a9fa7c25413387Ben M Cahill#define IWL_GOOD_CRC_TH_NEVER		cpu_to_le16(0xffff)
27183058f02137359efb412975cf94a9fa7c25413387Ben M Cahill#define IWL_MAX_SCAN_SIZE 1024
27193058f02137359efb412975cf94a9fa7c25413387Ben M Cahill#define IWL_MAX_CMD_SIZE 4096
27203058f02137359efb412975cf94a9fa7c25413387Ben M Cahill
27213058f02137359efb412975cf94a9fa7c25413387Ben M Cahill/*
27222a421b91d6fe89e27ded7544a25449c0b050098fTomas Winkler * REPLY_SCAN_CMD = 0x80 (command)
2723b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
27243d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * The hardware scan command is very powerful; the driver can set it up to
27253d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * maintain (relatively) normal network traffic while doing a scan in the
27263d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * background.  The max_out_time and suspend_time control the ratio of how
27273d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * long the device stays on an associated network channel ("service channel")
27283d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * vs. how long it's away from the service channel, i.e. tuned to other channels
27293d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * for scanning.
27303d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler *
27313d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * max_out_time is the max time off-channel (in usec), and suspend_time
27323d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * is how long (in "extended beacon" format) that the scan is "suspended"
27333d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * after returning to the service channel.  That is, suspend_time is the
27343d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * time that we stay on the service channel, doing normal work, between
27353d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * scan segments.  The driver may set these parameters differently to support
27363d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * scanning when associated vs. not associated, and light vs. heavy traffic
27373d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * loads when associated.
27383d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler *
27393d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * After receiving this command, the device's scan engine does the following;
27403d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler *
27413d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * 1)  Sends SCAN_START notification to driver
27423d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * 2)  Checks to see if it has time to do scan for one channel
27433d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * 3)  Sends NULL packet, with power-save (PS) bit set to 1,
27443d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler *     to tell AP that we're going off-channel
27453d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * 4)  Tunes to first channel in scan list, does active or passive scan
27463d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * 5)  Sends SCAN_RESULT notification to driver
27473d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * 6)  Checks to see if it has time to do scan on *next* channel in list
27483d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * 7)  Repeats 4-6 until it no longer has time to scan the next channel
27499b3bf06abad70db820c74c90118ea49358549d22Johannes Berg *     before max_out_time expires
27503d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * 8)  Returns to service channel
27513d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * 9)  Sends NULL packet with PS=0 to tell AP that we're back
27523d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * 10) Stays on service channel until suspend_time expires
27533d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * 11) Repeats entire process 2-10 until list is complete
27543d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * 12) Sends SCAN_COMPLETE notification
27553d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler *
27563d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * For fast, efficient scans, the scan command also has support for staying on
27573d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * a channel for just a short time, if doing active scanning and getting no
27583d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * responses to the transmitted probe request.  This time is controlled by
27593d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * quiet_time, and the number of received packets below which a channel is
27603d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * considered "quiet" is controlled by quiet_plcp_threshold.
27613d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler *
27623d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * For active scanning on channels that have regulatory restrictions against
27633d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * blindly transmitting, the scan can listen before transmitting, to make sure
27643d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * that there is already legitimate activity on the channel.  If enough
27653d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * packets are cleanly received on the channel (controlled by good_CRC_th,
27663d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * typical value 1), the scan engine starts transmitting probe requests.
27673d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler *
27683d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * Driver must use separate scan commands for 2.4 vs. 5 GHz bands.
27692a421b91d6fe89e27ded7544a25449c0b050098fTomas Winkler *
2770b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * To avoid uCode errors, see timing restrictions described under
2771b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * struct iwl_scan_channel.
27723058f02137359efb412975cf94a9fa7c25413387Ben M Cahill */
27733058f02137359efb412975cf94a9fa7c25413387Ben M Cahill
27743058f02137359efb412975cf94a9fa7c25413387Ben M Cahillstruct iwl3945_scan_cmd {
27753058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le16 len;
27763058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	u8 reserved0;
27773058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	u8 channel_count;	/* # channels in channel list */
27783058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le16 quiet_time;	/* dwell only this # millisecs on quiet channel
27793058f02137359efb412975cf94a9fa7c25413387Ben M Cahill				 * (only for active scan) */
27803058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le16 quiet_plcp_th;	/* quiet chnl is < this # pkts (typ. 1) */
27813058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le16 good_CRC_th;	/* passive -> active promotion threshold */
27823058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le16 reserved1;
27833058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le32 max_out_time;	/* max usec to be away from associated (service)
27843058f02137359efb412975cf94a9fa7c25413387Ben M Cahill				 * channel */
27853058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le32 suspend_time;	/* pause scan this long (in "extended beacon
27863058f02137359efb412975cf94a9fa7c25413387Ben M Cahill				 * format") when returning to service channel:
27873058f02137359efb412975cf94a9fa7c25413387Ben M Cahill				 * 3945; 31:24 # beacons, 19:0 additional usec,
27883058f02137359efb412975cf94a9fa7c25413387Ben M Cahill				 * 4965; 31:22 # beacons, 21:0 additional usec.
27893058f02137359efb412975cf94a9fa7c25413387Ben M Cahill				 */
279083d527d9e8f9aff92cbd33f208f77c055dabb499Tomas Winkler	__le32 flags;		/* RXON_FLG_* */
27913058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le32 filter_flags;	/* RXON_FILTER_* */
27923058f02137359efb412975cf94a9fa7c25413387Ben M Cahill
27932a421b91d6fe89e27ded7544a25449c0b050098fTomas Winkler	/* For active scans (set to all-0s for passive scans).
2794b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * Does not include payload.  Must specify Tx rate; no rate scaling. */
2795b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct iwl3945_tx_cmd tx_cmd;
27963058f02137359efb412975cf94a9fa7c25413387Ben M Cahill
27973058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	/* For directed active scans (set to all-0s otherwise) */
27983058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX_3945];
27993058f02137359efb412975cf94a9fa7c25413387Ben M Cahill
28003058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	/*
28013058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 * Probe request frame, followed by channel list.
2802b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 *
28032aa6ab86bc475a115f56645591d2413981846509Tomas Winkler	 * Size of probe request frame is specified by byte count in tx_cmd.
2804b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * Channel list follows immediately after probe request frame.
2805b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * Number of channels in list is specified by channel_count.
28063058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 * Each channel in list is of type:
28073058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 *
28083058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 * struct iwl3945_scan_channel channels[0];
2809b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 *
28103058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 * NOTE:  Only one band of channels can be scanned per pass.  You
2811b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * must not mix 2.4GHz channels and 5.2GHz channels, and you must wait
2812b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * for one scan to complete (i.e. receive SCAN_COMPLETE_NOTIFICATION)
2813b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * before requesting another scan.
281451e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison	 */
2815b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 data[0];
2816b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2817b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2818b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl_scan_cmd {
2819b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 len;
2820b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved0;
28212a421b91d6fe89e27ded7544a25449c0b050098fTomas Winkler	u8 channel_count;	/* # channels in channel list */
2822b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 quiet_time;	/* dwell only this # millisecs on quiet channel
2823b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 * (only for active scan) */
2824b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 quiet_plcp_th;	/* quiet chnl is < this # pkts (typ. 1) */
2825b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 good_CRC_th;	/* passive -> active promotion threshold */
2826b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 rx_chain;	/* RXON_RX_CHAIN_* */
2827b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 max_out_time;	/* max usec to be away from associated (service)
28282a421b91d6fe89e27ded7544a25449c0b050098fTomas Winkler				 * channel */
2829b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 suspend_time;	/* pause scan this long (in "extended beacon
2830b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 * format") when returning to service chnl:
2831b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 * 3945; 31:24 # beacons, 19:0 additional usec,
2832b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 * 4965; 31:22 # beacons, 21:0 additional usec.
2833b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 */
2834b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 flags;		/* RXON_FLG_* */
2835b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 filter_flags;	/* RXON_FILTER_* */
2836b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2837b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* For active scans (set to all-0s for passive scans).
2838b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * Does not include payload.  Must specify Tx rate; no rate scaling. */
2839b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct iwl_tx_cmd tx_cmd;
2840b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2841b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* For directed active scans (set to all-0s otherwise) */
2842b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX];
2843b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2844b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/*
28452a421b91d6fe89e27ded7544a25449c0b050098fTomas Winkler	 * Probe request frame, followed by channel list.
2846b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 *
2847b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * Size of probe request frame is specified by byte count in tx_cmd.
2848b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * Channel list follows immediately after probe request frame.
2849b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * Number of channels in list is specified by channel_count.
2850b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * Each channel in list is of type:
2851b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 *
2852b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * struct iwl_scan_channel channels[0];
2853b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 *
2854b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * NOTE:  Only one band of channels can be scanned per pass.  You
2855b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * must not mix 2.4GHz channels and 5.2GHz channels, and you must wait
2856b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * for one scan to complete (i.e. receive SCAN_COMPLETE_NOTIFICATION)
28572a421b91d6fe89e27ded7544a25449c0b050098fTomas Winkler	 * before requesting another scan.
2858b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 */
2859b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 data[0];
2860b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2861b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2862b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* Can abort will notify by complete notification with abort status. */
2863b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define CAN_ABORT_STATUS	cpu_to_le32(0x1)
2864b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* complete notification statuses */
2865b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define ABORT_STATUS            0x2
2866b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2867b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2868b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_SCAN_CMD = 0x80 (response)
2869b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
2870b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl_scanreq_notification {
2871b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 status;		/* 1: okay, 2: cannot fulfill request */
2872b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2873b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2874b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2875b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * SCAN_START_NOTIFICATION = 0x82 (notification only, not a command)
28763d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler */
28773d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl_scanstart_notification {
28783d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 tsf_low;
28793d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 tsf_high;
28803d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 beacon_timer;
28813d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 channel;
28823d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 band;
28833d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 reserved[2];
2884bb8c093bdea62f2ae371b98ebff81b0407852fafChristoph Hellwig	__le32 status;
2885bb8c093bdea62f2ae371b98ebff81b0407852fafChristoph Hellwig} __attribute__ ((packed));
2886b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2887b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define  SCAN_OWNER_STATUS 0x1;
2888b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define  MEASURE_OWNER_STATUS 0x2;
2889b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2890b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define NUMBER_OF_STATISTICS 1	/* first __le32 is good CRC */
2891b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2892b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * SCAN_RESULTS_NOTIFICATION = 0x83 (notification only, not a command)
2893b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
28943d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl_scanresults_notification {
28953d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 channel;
28963d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 band;
28973d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 reserved[2];
28983d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 tsf_low;
28993d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 tsf_high;
29003d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 statistics[NUMBER_OF_STATISTICS];
29013d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler} __attribute__ ((packed));
29023d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
29034bf64efd26f5610cde4fb7846e2f37bd1f62d3a9Tomas Winkler/*
290483d527d9e8f9aff92cbd33f208f77c055dabb499Tomas Winkler * SCAN_COMPLETE_NOTIFICATION = 0x84 (notification only, not a command)
2905b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
2906b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl_scancomplete_notification {
2907b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 scanned_channels;
2908b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 status;
2909b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved;
2910b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 last_channel;
2911b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 tsf_low;
2912b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 tsf_high;
2913b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2914b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2915b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2916b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
2917b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (9)
2918b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * IBSS/AP Commands and Notifications:
2919b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
2920b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
2921b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2922b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2923b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * BEACON_NOTIFICATION = 0x90 (notification only, not a command)
2924b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
2925b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2926b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl3945_beacon_notif {
2927b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct iwl3945_tx_resp beacon_notify_hdr;
2928b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 low_tsf;
2929b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 high_tsf;
2930b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 ibss_mgr_status;
2931b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2932b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2933b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl4965_beacon_notif {
2934b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct iwl4965_tx_resp beacon_notify_hdr;
2935b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 low_tsf;
2936b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 high_tsf;
2937b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 ibss_mgr_status;
2938b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
29393d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
29403d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler/*
29413d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * REPLY_TX_BEACON = 0x91 (command, has simple generic response)
29423d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler */
29433d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
29443d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_tx_beacon_cmd {
29453d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct iwl3945_tx_cmd tx;
29463d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 tim_idx;
29473d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 tim_size;
29483d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 reserved1;
29493d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct ieee80211_hdr frame[0];	/* beacon frame */
29503d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler} __attribute__ ((packed));
29513d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
29523d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl_tx_beacon_cmd {
29533d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct iwl_tx_cmd tx;
29543d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 tim_idx;
29553d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 tim_size;
29563d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 reserved1;
29573d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct ieee80211_hdr frame[0];	/* beacon frame */
29583d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler} __attribute__ ((packed));
29593d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
29603d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler/******************************************************************************
29613d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * (10)
29623d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * Statistics Commands and Notifications:
29633d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler *
29643d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler *****************************************************************************/
29653d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
29663d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define IWL_TEMP_CONVERT 260
29673d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
29683d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define SUP_RATE_11A_MAX_NUM_CHANNELS  8
29693d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define SUP_RATE_11B_MAX_NUM_CHANNELS  4
29703d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define SUP_RATE_11G_MAX_NUM_CHANNELS  12
29713d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
29723d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler/* Used for passing to driver number of successes and failures per rate */
29733d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct rate_histogram {
29743d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	union {
29753d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler		__le32 a[SUP_RATE_11A_MAX_NUM_CHANNELS];
29763d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler		__le32 b[SUP_RATE_11B_MAX_NUM_CHANNELS];
29773d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler		__le32 g[SUP_RATE_11G_MAX_NUM_CHANNELS];
29783d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	} success;
29793d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	union {
29803d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler		__le32 a[SUP_RATE_11A_MAX_NUM_CHANNELS];
29813d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler		__le32 b[SUP_RATE_11B_MAX_NUM_CHANNELS];
29823d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler		__le32 g[SUP_RATE_11G_MAX_NUM_CHANNELS];
29833d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	} failed;
29843d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler} __attribute__ ((packed));
29853d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
29863d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler/* statistics command response */
29873d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
29883d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl39_statistics_rx_phy {
29893d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 ina_cnt;
29903d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 fina_cnt;
29913d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 plcp_err;
29923d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 crc32_err;
29933d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 overrun_err;
29943d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 early_overrun_err;
29953d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 crc32_good;
29963d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 false_alarm_cnt;
29973d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 fina_sync_err_cnt;
29983d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 sfd_timeout;
29993d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 fina_timeout;
30003d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 unresponded_rts;
30013d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 rxe_frame_limit_overrun;
30023d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 sent_ack_cnt;
30033d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 sent_cts_cnt;
30043d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler} __attribute__ ((packed));
30053d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
30063d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl39_statistics_rx_non_phy {
30073d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 bogus_cts;	/* CTS received when not expecting CTS */
30083d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 bogus_ack;	/* ACK received when not expecting ACK */
3009b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 non_bssid_frames;	/* number of frames with BSSID that
3010b481de9ca074528fe8c429604e2777db8b89806aZhu Yi					 * doesn't belong to the STA BSSID */
3011b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 filtered_frames;	/* count frames that were dumped in the
3012b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 * filtering process */
3013b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 non_channel_beacons;	/* beacons with our bss id but not on
3014b481de9ca074528fe8c429604e2777db8b89806aZhu Yi					 * our serving channel */
3015b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
3016b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3017b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl39_statistics_rx {
3018b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct iwl39_statistics_rx_phy ofdm;
3019b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct iwl39_statistics_rx_phy cck;
3020b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct iwl39_statistics_rx_non_phy general;
3021b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
3022b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3023b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl39_statistics_tx {
3024b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 preamble_cnt;
3025b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 rx_detected_cnt;
3026b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 bt_prio_defer_cnt;
3027b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 bt_prio_kill_cnt;
3028b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 few_bytes_cnt;
3029b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 cts_timeout;
3030b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 ack_timeout;
3031b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 expected_ack_cnt;
3032b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 actual_ack_cnt;
3033b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
3034b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3035b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct statistics_dbg {
3036b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 burst_check;
3037b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 burst_count;
3038b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 reserved[4];
3039b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
3040b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3041b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl39_statistics_div {
3042f0118a4575d45ce3074c830660de938bc6e17bdaWey-Yi Guy	__le32 tx_on_a;
3043b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 tx_on_b;
3044b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 exec_time;
3045c1b4aa3fb619782213af2af6652663c8f9cef373Harvey Harrison	__le32 probe_time;
304634c22cf93d1446791c966c878cc691e07c39d8d3Winkler, Tomas} __attribute__ ((packed));
3047b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3048b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl39_statistics_general {
3049b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 temperature;
3050b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct statistics_dbg dbg;
3051b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 sleep_time;
3052b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 slots_out;
3053b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 slots_idle;
3054b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 ttl_timestamp;
3055b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct iwl39_statistics_div div;
3056b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
3057b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3058b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct statistics_rx_phy {
3059b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 ina_cnt;
3060b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 fina_cnt;
3061b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 plcp_err;
3062b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 crc32_err;
3063b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 overrun_err;
3064b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 early_overrun_err;
3065b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 crc32_good;
3066b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 false_alarm_cnt;
3067b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 fina_sync_err_cnt;
3068b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 sfd_timeout;
30693058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le32 fina_timeout;
3070b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 unresponded_rts;
3071b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 rxe_frame_limit_overrun;
3072b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 sent_ack_cnt;
3073b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 sent_cts_cnt;
3074b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 sent_ba_rsp_cnt;
3075b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 dsp_self_kill;
3076b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 mh_format_err;
3077b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 re_acq_main_rssi_sum;
3078b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 reserved3;
3079b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
3080b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3081b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct statistics_rx_ht_phy {
3082b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 plcp_err;
3083b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 overrun_err;
3084b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 early_overrun_err;
3085b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 crc32_good;
3086b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 crc32_err;
3087fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy	__le32 mh_format_err;
3088fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy	__le32 agg_crc32_good;
3089fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy	__le32 agg_mpdu_cnt;
3090fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy	__le32 agg_cnt;
3091fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy	__le32 unsupport_mcs;
3092fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy} __attribute__ ((packed));
3093fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy
3094fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy#define INTERFERENCE_DATA_AVAILABLE      cpu_to_le32(1)
3095fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy
3096fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guystruct statistics_rx_non_phy {
3097fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy	__le32 bogus_cts;	/* CTS received when not expecting CTS */
3098fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy	__le32 bogus_ack;	/* ACK received when not expecting ACK */
3099fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy	__le32 non_bssid_frames;	/* number of frames with BSSID that
3100fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy					 * doesn't belong to the STA BSSID */
3101b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 filtered_frames;	/* count frames that were dumped in the
3102b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 * filtering process */
3103b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 non_channel_beacons;	/* beacons with our bss id but not on
3104b481de9ca074528fe8c429604e2777db8b89806aZhu Yi					 * our serving channel */
3105b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 channel_beacons;	/* beacons with our bss id and in our
3106b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 * serving channel */
3107b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 num_missed_bcon;	/* number of missed beacons */
3108b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 adc_rx_saturation_time;	/* count in 0.8us units the time the
3109b481de9ca074528fe8c429604e2777db8b89806aZhu Yi					 * ADC was in saturation */
3110b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 ina_detection_search_time;/* total time (in 0.8us) searched
3111b481de9ca074528fe8c429604e2777db8b89806aZhu Yi					  * for INA */
3112b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_silence_rssi_a;	/* RSSI silence after beacon frame */
3113b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_silence_rssi_b;	/* RSSI silence after beacon frame */
3114b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_silence_rssi_c;	/* RSSI silence after beacon frame */
3115b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 interference_data_flag;	/* flag for interference data
3116b481de9ca074528fe8c429604e2777db8b89806aZhu Yi					 * availability. 1 when data is
3117b481de9ca074528fe8c429604e2777db8b89806aZhu Yi					 * available. */
3118b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 channel_load;		/* counts RX Enable time in uSec */
3119b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 dsp_false_alarms;	/* DSP false alarm (both OFDM
3120b481de9ca074528fe8c429604e2777db8b89806aZhu Yi					 * and CCK) counter */
3121b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_rssi_a;
3122b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_rssi_b;
3123b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_rssi_c;
3124b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_energy_a;
3125b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_energy_b;
3126b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_energy_c;
3127b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
3128b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3129b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct statistics_rx {
3130470356b891f1d18e87d5fdc393976fab6d0a978dWey-Yi Guy	struct statistics_rx_phy ofdm;
3131470356b891f1d18e87d5fdc393976fab6d0a978dWey-Yi Guy	struct statistics_rx_phy cck;
3132470356b891f1d18e87d5fdc393976fab6d0a978dWey-Yi Guy	struct statistics_rx_non_phy general;
3133470356b891f1d18e87d5fdc393976fab6d0a978dWey-Yi Guy	struct statistics_rx_ht_phy ofdm_ht;
3134470356b891f1d18e87d5fdc393976fab6d0a978dWey-Yi Guy} __attribute__ ((packed));
3135fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy
3136fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy/**
3137b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * struct statistics_tx_power - current tx power
3138b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
3139b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * @ant_a: current tx power on chain a in 1/2 dB step
3140b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * @ant_b: current tx power on chain b in 1/2 dB step
3141b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * @ant_c: current tx power on chain c in 1/2 dB step
3142b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
3143b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct statistics_tx_power {
3144b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ant_a;
3145b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ant_b;
3146b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ant_c;
3147b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved;
3148b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
3149b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3150f0118a4575d45ce3074c830660de938bc6e17bdaWey-Yi Guystruct statistics_tx_non_phy_agg {
3151f0118a4575d45ce3074c830660de938bc6e17bdaWey-Yi Guy	__le32 ba_timeout;
3152b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 ba_reschedule_frames;
3153b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 scd_query_agg_frame_cnt;
3154b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 scd_query_no_agg;
3155b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 scd_query_agg;
3156b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 scd_query_mismatch;
3157b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 frame_not_ready;
3158b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 underrun;
315911fc524941248dc717f1af5dfa844eceb7c0217fWey-Yi Guy	__le32 bt_prio_kill;
316011fc524941248dc717f1af5dfa844eceb7c0217fWey-Yi Guy	__le32 rx_ba_rsp_cnt;
316111fc524941248dc717f1af5dfa844eceb7c0217fWey-Yi Guy} __attribute__ ((packed));
316211fc524941248dc717f1af5dfa844eceb7c0217fWey-Yi Guy
316311fc524941248dc717f1af5dfa844eceb7c0217fWey-Yi Guystruct statistics_tx {
316411fc524941248dc717f1af5dfa844eceb7c0217fWey-Yi Guy	__le32 preamble_cnt;
3165b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 rx_detected_cnt;
3166b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 bt_prio_defer_cnt;
3167b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 bt_prio_kill_cnt;
3168b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 few_bytes_cnt;
3169ef8d5529b015d4c5db7fad1adfc91edfd5abad56Wey-Yi Guy	__le32 cts_timeout;
3170ef8d5529b015d4c5db7fad1adfc91edfd5abad56Wey-Yi Guy	__le32 ack_timeout;
3171ef8d5529b015d4c5db7fad1adfc91edfd5abad56Wey-Yi Guy	__le32 expected_ack_cnt;
3172ef8d5529b015d4c5db7fad1adfc91edfd5abad56Wey-Yi Guy	__le32 actual_ack_cnt;
3173b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 dump_msdu_cnt;
3174b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 burst_abort_next_frame_mismatch_cnt;
3175b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 burst_abort_missing_next_frame_cnt;
3176b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 cts_timeout_collision;
3177b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 ack_or_ba_timeout_collision;
3178b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct statistics_tx_non_phy_agg agg;
3179b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/*
3180b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * "tx_power" are optional parameters provided by uCode,
3181b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * 6000 series is the only device provide the information,
3182b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * Those are reserved fields for all the other devices
3183b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 */
3184b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct statistics_tx_power tx_power;
3185b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 reserved1;
3186b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
3187b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
318851e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison
318951e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrisonstruct statistics_div {
31908f91aecb4cdc2d786df8941e827b9dff3c10a4e4Emmanuel Grumbach	__le32 tx_on_a;
3191b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 tx_on_b;
3192b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 exec_time;
3193b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 probe_time;
3194b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 reserved1;
3195b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 reserved2;
3196b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
3197b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3198b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct statistics_general {
3199b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 temperature;   /* radio temperature */
3200b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 temperature_m; /* for 5000 and up, this is radio voltage */
3201b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct statistics_dbg dbg;
3202b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 sleep_time;
3203b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 slots_out;
3204b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 slots_idle;
3205b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 ttl_timestamp;
3206b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct statistics_div div;
3207b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 rx_enable_counter;
3208b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/*
320951e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison	 * num_of_sos_states:
32107aafef1c6e2e24f9a10dc2972bf0ee70624ccc47Wey-Yi Guy	 *  count the number of times we have to re-tune
32113d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 *  in order to get out of bad PHY status
32123d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 */
32133d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 num_of_sos_states;
32143d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 reserved2;
32153d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 reserved3;
32163d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler} __attribute__ ((packed));
32173d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
32183d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define UCODE_STATISTICS_CLEAR_MSK		(0x1 << 0)
32198f91aecb4cdc2d786df8941e827b9dff3c10a4e4Emmanuel Grumbach#define UCODE_STATISTICS_FREQUENCY_MSK		(0x1 << 1)
3220b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define UCODE_STATISTICS_NARROW_BAND_MSK	(0x1 << 2)
3221b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3222b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
3223b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_STATISTICS_CMD = 0x9c,
3224b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * 3945 and 4965 identical.
3225b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
3226b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * This command triggers an immediate response containing uCode statistics.
3227b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * The response is in the same format as STATISTICS_NOTIFICATION 0x9d, below.
3228b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
3229a13d276f1e49ae0bc4ad18ce8ea3c90656c9e8d4Wey-Yi Guy * If the CLEAR_STATS configuration flag is set, uCode will clear its
3230a13d276f1e49ae0bc4ad18ce8ea3c90656c9e8d4Wey-Yi Guy * internal copy of the statistics (counters) after issuing the response.
3231a13d276f1e49ae0bc4ad18ce8ea3c90656c9e8d4Wey-Yi Guy * This flag does not affect STATISTICS_NOTIFICATIONs after beacons (see below).
3232a13d276f1e49ae0bc4ad18ce8ea3c90656c9e8d4Wey-Yi Guy *
3233a13d276f1e49ae0bc4ad18ce8ea3c90656c9e8d4Wey-Yi Guy * If the DISABLE_NOTIF configuration flag is set, uCode will not issue
3234a13d276f1e49ae0bc4ad18ce8ea3c90656c9e8d4Wey-Yi Guy * STATISTICS_NOTIFICATIONs after received beacons (see below).  This flag
3235a13d276f1e49ae0bc4ad18ce8ea3c90656c9e8d4Wey-Yi Guy * does not affect the response to the REPLY_STATISTICS_CMD 0x9c itself.
3236a13d276f1e49ae0bc4ad18ce8ea3c90656c9e8d4Wey-Yi Guy */
3237a13d276f1e49ae0bc4ad18ce8ea3c90656c9e8d4Wey-Yi Guy#define IWL_STATS_CONF_CLEAR_STATS cpu_to_le32(0x1)	/* see above */
3238a13d276f1e49ae0bc4ad18ce8ea3c90656c9e8d4Wey-Yi Guy#define IWL_STATS_CONF_DISABLE_NOTIF cpu_to_le32(0x2)/* see above */
3239a13d276f1e49ae0bc4ad18ce8ea3c90656c9e8d4Wey-Yi Guystruct iwl_statistics_cmd {
3240a13d276f1e49ae0bc4ad18ce8ea3c90656c9e8d4Wey-Yi Guy	__le32 configuration_flags;	/* IWL_STATS_CONF_* */
3241a13d276f1e49ae0bc4ad18ce8ea3c90656c9e8d4Wey-Yi Guy} __attribute__ ((packed));
3242a13d276f1e49ae0bc4ad18ce8ea3c90656c9e8d4Wey-Yi Guy
3243a13d276f1e49ae0bc4ad18ce8ea3c90656c9e8d4Wey-Yi Guy/*
3244a13d276f1e49ae0bc4ad18ce8ea3c90656c9e8d4Wey-Yi Guy * STATISTICS_NOTIFICATION = 0x9d (notification only, not a command)
3245b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
3246a13d276f1e49ae0bc4ad18ce8ea3c90656c9e8d4Wey-Yi Guy * By default, uCode issues this notification after receiving a beacon
3247a13d276f1e49ae0bc4ad18ce8ea3c90656c9e8d4Wey-Yi Guy * while associated.  To disable this behavior, set DISABLE_NOTIF flag in the
3248a13d276f1e49ae0bc4ad18ce8ea3c90656c9e8d4Wey-Yi Guy * REPLY_STATISTICS_CMD 0x9c, above.
3249a13d276f1e49ae0bc4ad18ce8ea3c90656c9e8d4Wey-Yi Guy *
3250b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Statistics counters continue to increment beacon after beacon, but are
32512aa6ab86bc475a115f56645591d2413981846509Tomas Winkler * cleared when changing channels or when driver issues REPLY_STATISTICS_CMD
3252a13d276f1e49ae0bc4ad18ce8ea3c90656c9e8d4Wey-Yi Guy * 0x9c with CLEAR_STATS bit set (see above).
3253b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
3254b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * uCode also issues this notification during scans.  uCode clears statistics
3255b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * appropriately so that each notification contains statistics for only the
3256b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * one channel that has just been scanned.
3257b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
3258f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define STATISTICS_REPLY_FLG_BAND_24G_MSK         cpu_to_le32(0x2)
3259b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define STATISTICS_REPLY_FLG_HT40_MODE_MSK        cpu_to_le32(0x8)
3260b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3261b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl3945_notif_statistics {
3262b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 flag;
3263f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill	struct iwl39_statistics_rx rx;
3264f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill	struct iwl39_statistics_tx tx;
3265f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill	struct iwl39_statistics_general general;
3266f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill} __attribute__ ((packed));
3267f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill
3268f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahillstruct iwl_notif_statistics {
3269f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill	__le32 flag;
3270f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill	struct statistics_rx rx;
3271b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct statistics_tx tx;
3272b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct statistics_general general;
3273f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill} __attribute__ ((packed));
3274f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill
3275f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill
3276f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill/*
3277f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * MISSED_BEACONS_NOTIFICATION = 0xa2 (notification only, not a command)
3278f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3279f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * uCode send MISSED_BEACONS_NOTIFICATION to driver when detect beacon missed
3280f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * in regardless of how many missed beacons, which mean when driver receive the
3281f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * notification, inside the command, it can find all the beacons information
3282f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * which include number of total missed beacons, number of consecutive missed
3283f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * beacons, number of beacons received and number of beacons expected to
3284f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * receive.
3285f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3286f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * If uCode detected consecutive_missed_beacons > 5, it will reset the radio
3287f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * in order to bring the radio/PHY back to working state; which has no relation
3288f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * to when driver will perform sensitivity calibration.
3289f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3290f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * Driver should set it own missed_beacon_threshold to decide when to perform
3291f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * sensitivity calibration based on number of consecutive missed beacons in
3292f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * order to improve overall performance, especially in noisy environment.
3293f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3294f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill */
3295f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill
3296f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define IWL_MISSED_BEACON_THRESHOLD_MIN	(1)
3297f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define IWL_MISSED_BEACON_THRESHOLD_DEF	(5)
3298f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define IWL_MISSED_BEACON_THRESHOLD_MAX	IWL_MISSED_BEACON_THRESHOLD_DEF
3299f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill
3300f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahillstruct iwl_missed_beacon_notif {
3301f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill	__le32 consecutive_missed_beacons;
3302f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill	__le32 total_missed_becons;
3303f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill	__le32 num_expected_beacons;
3304f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill	__le32 num_recvd_beacons;
3305f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill} __attribute__ ((packed));
3306f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill
3307f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill
3308f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill/******************************************************************************
3309f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * (11)
3310f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * Rx Calibration Commands:
3311f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3312f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * With the uCode used for open source drivers, most Tx calibration (except
3313f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * for Tx Power) and most Rx calibration is done by uCode during the
3314f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * "initialize" phase of uCode boot.  Driver must calibrate only:
3315f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3316f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * 1)  Tx power (depends on temperature), described elsewhere
3317f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * 2)  Receiver gain balance (optimize MIMO, and detect disconnected antennas)
3318f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * 3)  Receiver sensitivity (to optimize signal detection)
3319f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3320f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *****************************************************************************/
3321f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill
3322f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill/**
3323f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * SENSITIVITY_CMD = 0xa8 (command, has simple generic response)
3324f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3325f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * This command sets up the Rx signal detector for a sensitivity level that
3326f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * is high enough to lock onto all signals within the associated network,
3327f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * but low enough to ignore signals that are below a certain threshold, so as
3328f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * not to have too many "false alarms".  False alarms are signals that the
3329f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * Rx DSP tries to lock onto, but then discards after determining that they
3330f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * are noise.
3331f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3332f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * The optimum number of false alarms is between 5 and 50 per 200 TUs
3333f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * (200 * 1024 uSecs, i.e. 204.8 milliseconds) of actual Rx time (i.e.
3334f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * time listening, not transmitting).  Driver must adjust sensitivity so that
3335f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * the ratio of actual false alarms to actual Rx time falls within this range.
3336f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3337f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * While associated, uCode delivers STATISTICS_NOTIFICATIONs after each
3338f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * received beacon.  These provide information to the driver to analyze the
3339f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * sensitivity.  Don't analyze statistics that come in from scanning, or any
3340f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * other non-associated-network source.  Pertinent statistics include:
3341f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3342f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * From "general" statistics (struct statistics_rx_non_phy):
3343f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3344f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * (beacon_energy_[abc] & 0x0FF00) >> 8 (unsigned, higher value is lower level)
3345f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   Measure of energy of desired signal.  Used for establishing a level
3346f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   below which the device does not detect signals.
3347f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3348f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * (beacon_silence_rssi_[abc] & 0x0FF00) >> 8 (unsigned, units in dB)
3349f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   Measure of background noise in silent period after beacon.
3350f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3351f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * channel_load
3352f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   uSecs of actual Rx time during beacon period (varies according to
3353f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   how much time was spent transmitting).
3354f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3355f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * From "cck" and "ofdm" statistics (struct statistics_rx_phy), separately:
3356f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3357f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * false_alarm_cnt
3358f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   Signal locks abandoned early (before phy-level header).
3359f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3360f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * plcp_err
3361f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   Signal locks abandoned late (during phy-level header).
3362f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3363f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * NOTE:  Both false_alarm_cnt and plcp_err increment monotonically from
3364f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        beacon to beacon, i.e. each value is an accumulation of all errors
3365f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        before and including the latest beacon.  Values will wrap around to 0
3366f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        after counting up to 2^32 - 1.  Driver must differentiate vs.
3367f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        previous beacon's values to determine # false alarms in the current
3368f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        beacon period.
3369f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3370f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * Total number of false alarms = false_alarms + plcp_errs
3371f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3372f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * For OFDM, adjust the following table entries in struct iwl_sensitivity_cmd
3373f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * (notice that the start points for OFDM are at or close to settings for
3374f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * maximum sensitivity):
3375f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3376f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *                                             START  /  MIN  /  MAX
3377f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   HD_AUTO_CORR32_X1_TH_ADD_MIN_INDEX          90   /   85  /  120
3378f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_INDEX     170   /  170  /  210
3379f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX         105   /  105  /  140
3380f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_INDEX     220   /  220  /  270
3381f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3382f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   If actual rate of OFDM false alarms (+ plcp_errors) is too high
3383f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   (greater than 50 for each 204.8 msecs listening), reduce sensitivity
3384f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   by *adding* 1 to all 4 of the table entries above, up to the max for
3385f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   each entry.  Conversely, if false alarm rate is too low (less than 5
3386f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   for each 204.8 msecs listening), *subtract* 1 from each entry to
3387f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   increase sensitivity.
3388f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3389f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * For CCK sensitivity, keep track of the following:
3390f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3391f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   1).  20-beacon history of maximum background noise, indicated by
3392f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        (beacon_silence_rssi_[abc] & 0x0FF00), units in dB, across the
3393f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        3 receivers.  For any given beacon, the "silence reference" is
3394f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        the maximum of last 60 samples (20 beacons * 3 receivers).
3395f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3396f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   2).  10-beacon history of strongest signal level, as indicated
3397f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        by (beacon_energy_[abc] & 0x0FF00) >> 8, across the 3 receivers,
3398f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        i.e. the strength of the signal through the best receiver at the
3399f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        moment.  These measurements are "upside down", with lower values
3400f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        for stronger signals, so max energy will be *minimum* value.
3401f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3402f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        Then for any given beacon, the driver must determine the *weakest*
3403f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        of the strongest signals; this is the minimum level that needs to be
3404f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        successfully detected, when using the best receiver at the moment.
3405f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        "Max cck energy" is the maximum (higher value means lower energy!)
3406f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        of the last 10 minima.  Once this is determined, driver must add
3407f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        a little margin by adding "6" to it.
3408f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3409f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   3).  Number of consecutive beacon periods with too few false alarms.
3410f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        Reset this to 0 at the first beacon period that falls within the
3411f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        "good" range (5 to 50 false alarms per 204.8 milliseconds rx).
3412f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3413f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * Then, adjust the following CCK table entries in struct iwl_sensitivity_cmd
3414f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * (notice that the start points for CCK are at maximum sensitivity):
3415f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3416f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *                                             START  /  MIN  /  MAX
3417f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX         125   /  125  /  200
3418f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX     200   /  200  /  400
3419f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   HD_MIN_ENERGY_CCK_DET_INDEX                100   /    0  /  100
3420f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3421f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   If actual rate of CCK false alarms (+ plcp_errors) is too high
3422f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   (greater than 50 for each 204.8 msecs listening), method for reducing
3423f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   sensitivity is:
3424f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3425f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   1)  *Add* 3 to value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX,
3426f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       up to max 400.
3427f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3428f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   2)  If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX is < 160,
3429f0832f137c21d130998a0f97f97ac01a2d97210bEmmanuel Grumbach *       sensitivity has been reduced a significant amount; bring it up to
3430f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       a moderate 161.  Otherwise, *add* 3, up to max 200.
3431f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3432f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   3)  a)  If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX is > 160,
3433f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       sensitivity has been reduced only a moderate or small amount;
3434f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       *subtract* 2 from value in HD_MIN_ENERGY_CCK_DET_INDEX,
3435f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       down to min 0.  Otherwise (if gain has been significantly reduced),
3436f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       don't change the HD_MIN_ENERGY_CCK_DET_INDEX value.
3437f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3438f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       b)  Save a snapshot of the "silence reference".
3439f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3440f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   If actual rate of CCK false alarms (+ plcp_errors) is too low
3441f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   (less than 5 for each 204.8 msecs listening), method for increasing
3442f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   sensitivity is used only if:
3443f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3444f0832f137c21d130998a0f97f97ac01a2d97210bEmmanuel Grumbach *   1a)  Previous beacon did not have too many false alarms
344551e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison *   1b)  AND difference between previous "silence reference" and current
344651e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison *        "silence reference" (prev - current) is 2 or more,
3447b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *   OR 2)  100 or more consecutive beacon periods have had rate of
3448f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *          less than 5 false alarms per 204.8 milliseconds rx time.
3449f0832f137c21d130998a0f97f97ac01a2d97210bEmmanuel Grumbach *
3450f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   Method for increasing sensitivity:
3451f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3452f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   1)  *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX,
3453f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       down to min 125.
3454f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3455f0832f137c21d130998a0f97f97ac01a2d97210bEmmanuel Grumbach *   2)  *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX,
3456f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       down to min 200.
3457f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3458b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *   3)  *Add* 2 to value in HD_MIN_ENERGY_CCK_DET_INDEX, up to max 100.
3459b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
3460f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   If actual rate of CCK false alarms (+ plcp_errors) is within good range
3461f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   (between 5 and 50 for each 204.8 msecs listening):
3462f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3463f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   1)  Save a snapshot of the silence reference.
3464f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3465f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   2)  If previous beacon had too many CCK false alarms (+ plcp_errors),
3466f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       give some extra margin to energy threshold by *subtracting* 8
3467f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       from value in HD_MIN_ENERGY_CCK_DET_INDEX.
3468f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3469f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   For all cases (too few, too many, good range), make sure that the CCK
3470f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   detection threshold (energy) is below the energy level for robust
3471f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   detection over the past 10 beacon periods, the "Max cck energy".
3472f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   Lower values mean higher energy; this means making sure that the value
3473f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   in HD_MIN_ENERGY_CCK_DET_INDEX is at or *above* "Max cck energy".
3474f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3475f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill */
3476f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill
3477f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill/*
3478f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * Table entries in SENSITIVITY_CMD (struct iwl_sensitivity_cmd)
3479f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill */
3480f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_TABLE_SIZE  (11)	/* number of entries */
3481f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_MIN_ENERGY_CCK_DET_INDEX                 (0)	/* table indexes */
3482f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_MIN_ENERGY_OFDM_DET_INDEX                (1)
3483f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_AUTO_CORR32_X1_TH_ADD_MIN_INDEX          (2)
3484f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_INDEX      (3)
3485f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX      (4)
3486f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX          (5)
3487f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_INDEX      (6)
3488f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_BARKER_CORR_TH_ADD_MIN_INDEX             (7)
3489f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_BARKER_CORR_TH_ADD_MIN_MRC_INDEX         (8)
3490f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX          (9)
3491f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_OFDM_ENERGY_TH_IN_INDEX                  (10)
3492f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill
3493f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill/* Control field in struct iwl_sensitivity_cmd */
3494f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define SENSITIVITY_CMD_CONTROL_DEFAULT_TABLE	cpu_to_le16(0)
3495f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define SENSITIVITY_CMD_CONTROL_WORK_TABLE	cpu_to_le16(1)
3496f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill
3497f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill/**
3498f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * struct iwl_sensitivity_cmd
3499f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * @control:  (1) updates working table, (0) updates default table
3500f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * @table:  energy threshold values, use HD_* as index into table
3501f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3502f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * Always use "1" in "control" to update uCode's working table and DSP.
3503f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill */
3504f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahillstruct iwl_sensitivity_cmd {
3505f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill	__le16 control;			/* always use "1" */
3506f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill	__le16 table[HD_TABLE_SIZE];	/* use HD_* as index */
3507f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill} __attribute__ ((packed));
3508f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill
3509f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill
3510f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill/**
3511f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * REPLY_PHY_CALIBRATION_CMD = 0xb0 (command, has simple generic response)
3512f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3513f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * This command sets the relative gains of 4965's 3 radio receiver chains.
3514f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3515f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * After the first association, driver should accumulate signal and noise
3516f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler * statistics from the STATISTICS_NOTIFICATIONs that follow the first 20
351733fd503346ad86bd7470a0f8c4c3080393d14233Emmanuel Grumbach * beacons from the associated network (don't collect statistics that come
351833fd503346ad86bd7470a0f8c4c3080393d14233Emmanuel Grumbach * in from scanning, or any other non-network source).
3519f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler *
3520f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler * DISCONNECTED ANTENNA:
3521f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler *
3522f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler * Driver should determine which antennas are actually connected, by comparing
3523f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler * average beacon signal levels for the 3 Rx chains.  Accumulate (add) the
3524f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler * following values over 20 beacons, one accumulator for each of the chains
3525f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler * a/b/c, from struct statistics_rx_non_phy:
3526f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler *
3527f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler * beacon_rssi_[abc] & 0x0FF (unsigned, units in dB)
352833fd503346ad86bd7470a0f8c4c3080393d14233Emmanuel Grumbach *
352933fd503346ad86bd7470a0f8c4c3080393d14233Emmanuel Grumbach * Find the strongest signal from among a/b/c.  Compare the other two to the
3530f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler * strongest.  If any signal is more than 15 dB (times 20, unless you
353151e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison * divide the accumulated values by 20) below the strongest, the driver
35327c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler * considers that antenna to be disconnected, and should not try to use that
35337c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler * antenna/chain for Rx or Tx.  If both A and B seem to be disconnected,
35347c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler * driver should declare the stronger one as connected, and attempt to use it
35357c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler * (A and B are the only 2 Tx chains!).
35367c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler *
35377c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler *
35387c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler * RX BALANCE:
35397c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler *
35407c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler * Driver should balance the 3 receivers (but just the ones that are connected
35417c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler * to antennas, see above) for gain, by comparing the average signal levels
35427c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler * detected during the silence after each beacon (background noise).
35437c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler * Accumulate (add) the following values over 20 beacons, one accumulator for
35447c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler * each of the chains a/b/c, from struct statistics_rx_non_phy:
35457c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler *
35467c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler * beacon_silence_rssi_[abc] & 0x0FF (unsigned, units in dB)
3547f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler *
35487c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler * Find the weakest background noise level from among a/b/c.  This Rx chain
35497c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler * will be the reference, with 0 gain adjustment.  Attenuate other channels by
35507c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler * finding noise difference:
35517c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler *
35527c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler * (accum_noise[i] - accum_noise[reference]) / 30
3553f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler *
35547c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler * The "30" adjusts the dB in the 20 accumulated samples to units of 1.5 dB.
35557c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler * For use in diff_gain_[abc] fields of struct iwl_calibration_cmd, the
35567c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler * driver should limit the difference results to a range of 0-3 (0-4.5 dB),
35577c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler * and set bit 2 to indicate "reduce gain".  The value for the reference
35587c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler * (weakest) chain should be "0".
35597c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler *
3560f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler * diff_gain_[abc] bit fields:
3561f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler *   2: (1) reduce gain, (0) increase gain
3562be5d56ed885a2897ec813eab4a8055d495816e9aTomas Winkler * 1-0: amount of gain, units of 1.5 dB
3563be5d56ed885a2897ec813eab4a8055d495816e9aTomas Winkler */
3564be5d56ed885a2897ec813eab4a8055d495816e9aTomas Winkler
35650d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler/* Phy calibration command for series */
3566f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler
35670d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winklerenum {
3568f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	IWL_PHY_CALIBRATE_DIFF_GAIN_CMD		= 7,
3569f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	IWL_PHY_CALIBRATE_DC_CMD		= 8,
3570f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	IWL_PHY_CALIBRATE_LO_CMD		= 9,
3571f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	IWL_PHY_CALIBRATE_TX_IQ_CMD		= 11,
3572f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	IWL_PHY_CALIBRATE_CRYSTAL_FRQ_CMD	= 15,
3573f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	IWL_PHY_CALIBRATE_BASE_BAND_CMD		= 16,
35740d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler	IWL_PHY_CALIBRATE_TX_IQ_PERD_CMD	= 17,
35750d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler	IWL_PHY_CALIBRATE_CHAIN_NOISE_RESET_CMD	= 18,
35760d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler	IWL_PHY_CALIBRATE_CHAIN_NOISE_GAIN_CMD	= 19,
35770d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler};
35780d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler
357933fd503346ad86bd7470a0f8c4c3080393d14233Emmanuel Grumbach
358033fd503346ad86bd7470a0f8c4c3080393d14233Emmanuel Grumbach#define IWL_CALIB_INIT_CFG_ALL	cpu_to_le32(0xffffffff)
35810d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler
35820d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winklerstruct iwl_calib_cfg_elmnt_s {
35830d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler	__le32 is_enable;
35840d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler	__le32 start;
35850d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler	__le32 send_res;
35860d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler	__le32 apply_res;
35870d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler	__le32 reserved;
3588f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler} __attribute__ ((packed));
35890d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler
359033fd503346ad86bd7470a0f8c4c3080393d14233Emmanuel Grumbachstruct iwl_calib_cfg_status_s {
359133fd503346ad86bd7470a0f8c4c3080393d14233Emmanuel Grumbach	struct iwl_calib_cfg_elmnt_s once;
35920d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler	struct iwl_calib_cfg_elmnt_s perd;
359333fd503346ad86bd7470a0f8c4c3080393d14233Emmanuel Grumbach	__le32 flags;
359433fd503346ad86bd7470a0f8c4c3080393d14233Emmanuel Grumbach} __attribute__ ((packed));
3595b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3596b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl_calib_cfg_cmd {
3597b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct iwl_calib_cfg_status_s ucd_calib_cfg;
3598b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct iwl_calib_cfg_status_s drv_calib_cfg;
3599b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 reserved1;
3600b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
3601b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3602b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl_calib_hdr {
3603b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 op_code;
3604b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 first_group;
3605b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 groups_num;
3606b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 data_valid;
3607b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
3608ec1a746042ea4c1c93065185897d6e8d3e7de894Tomas Winkler
3609b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl_calib_cmd {
3610b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct iwl_calib_hdr hdr;
3611b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 data[0];
3612b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
3613b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3614b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* IWL_PHY_CALIBRATE_DIFF_GAIN_CMD (7) */
3615b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl_calib_diff_gain_cmd {
3616b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct iwl_calib_hdr hdr;
3617b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	s8 diff_gain_a;		/* see above */
36189636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	s8 diff_gain_b;
3619fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	s8 diff_gain_c;
3620fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	u8 reserved1;
3621fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy} __attribute__ ((packed));
36229636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky
36231933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guystruct iwl_calib_xtal_freq_cmd {
36241933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	struct iwl_calib_hdr hdr;
36251933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	u8 cap_pin1;
36261933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	u8 cap_pin2;
36271933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	u8 pad[2];
36281933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy} __attribute__ ((packed));
36291933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy
36301933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy/* IWL_PHY_CALIBRATE_CHAIN_NOISE_RESET_CMD */
36311933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guystruct iwl_calib_chain_noise_reset_cmd {
36321933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	struct iwl_calib_hdr hdr;
36331933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	u8 data[0];
36341933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy};
36351933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy
36361933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy/* IWL_PHY_CALIBRATE_CHAIN_NOISE_GAIN_CMD */
36371933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guystruct iwl_calib_chain_noise_gain_cmd {
36381933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	struct iwl_calib_hdr hdr;
36391933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	u8 delta_gain_1;
36401933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	u8 delta_gain_2;
36411933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	u8 pad[2];
36421933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy} __attribute__ ((packed));
36431933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy
36441933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy/******************************************************************************
36451933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy * (12)
36461933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy * Miscellaneous Commands:
36471933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy *
36481933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy *****************************************************************************/
36491933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy
36501933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy/*
36511933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy * LEDs Command & Response
36521933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy * REPLY_LEDS_CMD = 0x48 (command, has simple generic response)
36531933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy *
36541933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy * For each of 3 possible LEDs (Activity/Link/Tech, selected by "id" field),
36551933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy * this command turns it on or off, or sets up a periodic blinking cycle.
36561933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy */
36571933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guystruct iwl_led_cmd {
36581933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	__le32 interval;	/* "interval" in uSec */
36591933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	u8 id;			/* 1: Activity, 2: Link, 3: Tech */
36601933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	u8 off;			/* # intervals off while blinking;
36611933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy				 * "0", with >0 "on" value, turns LED on */
36621933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	u8 on;			/* # intervals on while blinking;
36631933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy				 * "0", regardless of "off", turns LED off */
36641933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	u8 reserved;
36651933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy} __attribute__ ((packed));
36661933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy
36671933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy/*
36681933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy * station priority table entries
36691933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy * also used as potential "events" value for both
36701933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy * COEX_MEDIUM_NOTIFICATION and COEX_EVENT_CMD
36711933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy */
36721933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy
36731933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy/*
36741933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy * COEX events entry flag masks
36751933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy * RP - Requested Priority
36761933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy * WP - Win Medium Priority: priority assigned when the contention has been won
36771933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy */
36781933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG        (0x1)
36791933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG        (0x2)
36801933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_EVT_FLAG_DELAY_MEDIUM_FREE_NTFY_FLG  (0x4)
36811933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy
36821933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_UNASSOC_IDLE_RP               4
36831933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_UNASSOC_MANUAL_SCAN_RP        4
36841933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_UNASSOC_AUTO_SCAN_RP          4
36851933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_CALIBRATION_RP                4
36861933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_PERIODIC_CALIBRATION_RP       4
36871933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_CONNECTION_ESTAB_RP           4
36881933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_ASSOCIATED_IDLE_RP            4
36891933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_ASSOC_MANUAL_SCAN_RP          4
36901933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_ASSOC_AUTO_SCAN_RP            4
36911933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_ASSOC_ACTIVE_LEVEL_RP         4
36921933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_RF_ON_RP                      6
36931933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_RF_OFF_RP                     4
36941933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_STAND_ALONE_DEBUG_RP          6
36951933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_IPAN_ASSOC_LEVEL_RP           4
36961933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_RSRVD1_RP                     4
36971933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_RSRVD2_RP                     4
36981933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy
36991933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_UNASSOC_IDLE_WP               3
37001933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_UNASSOC_MANUAL_SCAN_WP        3
37011933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_UNASSOC_AUTO_SCAN_WP          3
37021933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_CALIBRATION_WP                3
37031933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_PERIODIC_CALIBRATION_WP       3
37041933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_CONNECTION_ESTAB_WP           3
37051933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_ASSOCIATED_IDLE_WP            3
37061933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_ASSOC_MANUAL_SCAN_WP          3
37071933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_ASSOC_AUTO_SCAN_WP            3
37081933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_ASSOC_ACTIVE_LEVEL_WP         3
37091933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_RF_ON_WP                      3
37101933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_RF_OFF_WP                     3
37111933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_STAND_ALONE_DEBUG_WP          6
37121933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_IPAN_ASSOC_LEVEL_WP           3
37131933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_RSRVD1_WP                     3
37141933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_RSRVD2_WP                     3
37159636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky
3716fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy#define COEX_UNASSOC_IDLE_FLAGS                     0
37179636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky#define COEX_UNASSOC_MANUAL_SCAN_FLAGS		\
37189636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	(COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG |	\
37199636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
3720fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy#define COEX_UNASSOC_AUTO_SCAN_FLAGS		\
37219636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	(COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG |	\
37229636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
3723fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy#define COEX_CALIBRATION_FLAGS			\
37249636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	(COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG |	\
3725fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
37269636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky#define COEX_PERIODIC_CALIBRATION_FLAGS             0
37279636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky/*
37289636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky * COEX_CONNECTION_ESTAB:
37299636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky * we need DELAY_MEDIUM_FREE_NTFY to let WiMAX disconnect from network.
3730fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy */
37319636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky#define COEX_CONNECTION_ESTAB_FLAGS		\
37329636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	(COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG |	\
37339636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG |	\
3734fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	COEX_EVT_FLAG_DELAY_MEDIUM_FREE_NTFY_FLG)
37359636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky#define COEX_ASSOCIATED_IDLE_FLAGS                  0
3736fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy#define COEX_ASSOC_MANUAL_SCAN_FLAGS		\
37379636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	(COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG |	\
37389636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
37399636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky#define COEX_ASSOC_AUTO_SCAN_FLAGS		\
37409636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	(COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG |	\
37419636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
3742fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy#define COEX_ASSOC_ACTIVE_LEVEL_FLAGS               0
3743fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy#define COEX_RF_ON_FLAGS                            0
3744fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy#define COEX_RF_OFF_FLAGS                           0
3745fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy#define COEX_STAND_ALONE_DEBUG_FLAGS		\
3746fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	(COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG |	\
37479636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
37489636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky#define COEX_IPAN_ASSOC_LEVEL_FLAGS		\
37499636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	(COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG |	\
37509636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG |	\
37519636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	 COEX_EVT_FLAG_DELAY_MEDIUM_FREE_NTFY_FLG)
37529636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky#define COEX_RSRVD1_FLAGS                           0
37539636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky#define COEX_RSRVD2_FLAGS                           0
37549636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky/*
37559636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky * COEX_CU_RF_ON is the event wrapping all radio ownership.
3756a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler * We need DELAY_MEDIUM_FREE_NTFY to let WiMAX disconnect from network.
37579636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky */
3758a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler#define COEX_CU_RF_ON_FLAGS			\
37599636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	(COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG |	\
3760a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler	 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG |	\
37619636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	 COEX_EVT_FLAG_DELAY_MEDIUM_FREE_NTFY_FLG)
37629636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky
37639636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky
37649636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunskyenum {
37659636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	/* un-association part */
37669636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_UNASSOC_IDLE		= 0,
37679636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_UNASSOC_MANUAL_SCAN	= 1,
37689636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_UNASSOC_AUTO_SCAN		= 2,
37699636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	/* calibration */
37709636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_CALIBRATION		= 3,
3771fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	COEX_PERIODIC_CALIBRATION	= 4,
3772fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	/* connection */
3773fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	COEX_CONNECTION_ESTAB		= 5,
3774fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	/* association part */
3775fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	COEX_ASSOCIATED_IDLE		= 6,
3776fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	COEX_ASSOC_MANUAL_SCAN		= 7,
3777fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	COEX_ASSOC_AUTO_SCAN		= 8,
3778fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	COEX_ASSOC_ACTIVE_LEVEL		= 9,
3779fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	/* RF ON/OFF */
3780fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	COEX_RF_ON			= 10,
3781fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	COEX_RF_OFF			= 11,
3782fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	COEX_STAND_ALONE_DEBUG		= 12,
3783fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	/* IPAN */
3784fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	COEX_IPAN_ASSOC_LEVEL		= 13,
3785fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	/* reserved */
3786fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	COEX_RSRVD1			= 14,
3787fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	COEX_RSRVD2			= 15,
3788fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	COEX_NUM_OF_EVENTS		= 16
3789fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy};
3790fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy
3791fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy/*
3792fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy * Coexistence WIFI/WIMAX  Command
3793fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy * COEX_PRIORITY_TABLE_CMD = 0x5a
3794fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy *
3795fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy */
3796fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guystruct iwl_wimax_coex_event_entry {
3797fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	u8 request_prio;
3798fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	u8 win_medium_prio;
3799fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	u8 reserved;
3800fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	u8 flags;
3801fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy} __attribute__ ((packed));
3802fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy
3803fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy/* COEX flag masks */
3804fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy
3805fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy/* Station table is valid */
3806fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy#define COEX_FLAGS_STA_TABLE_VALID_MSK      (0x1)
3807fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy/* UnMask wake up src at unassociated sleep */
3808fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy#define COEX_FLAGS_UNASSOC_WA_UNMASK_MSK    (0x4)
3809fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy/* UnMask wake up src at associated sleep */
3810fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy#define COEX_FLAGS_ASSOC_WA_UNMASK_MSK      (0x8)
3811fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy/* Enable CoEx feature. */
3812fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy#define COEX_FLAGS_COEX_ENABLE_MSK          (0x80)
3813fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy
3814fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guystruct iwl_wimax_coex_cmd {
3815fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	u8 flags;
3816fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	u8 reserved[3];
3817fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	struct iwl_wimax_coex_event_entry sta_prio[COEX_NUM_OF_EVENTS];
3818fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy} __attribute__ ((packed));
3819fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy
3820b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
3821b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Coexistence MEDIUM NOTIFICATION
3822b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * COEX_MEDIUM_NOTIFICATION = 0x5b
3823b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
3824b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * notification from uCode to host to indicate medium changes
3825b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
3826db11d6343aa14ab61258bfad9178042d4be49333Tomas Winkler */
38272f301227a1ede57504694e1f64839839f5737cacZhu Yi/*
38282f301227a1ede57504694e1f64839839f5737cacZhu Yi * status field
38292f301227a1ede57504694e1f64839839f5737cacZhu Yi * bit 0 - 2: medium status
38302f301227a1ede57504694e1f64839839f5737cacZhu Yi * bit 3: medium change indication
38312f301227a1ede57504694e1f64839839f5737cacZhu Yi * bit 4 - 31: reserved
38322f301227a1ede57504694e1f64839839f5737cacZhu Yi */
38332f301227a1ede57504694e1f64839839f5737cacZhu Yi/* status option values, (0 - 2 bits) */
38342f301227a1ede57504694e1f64839839f5737cacZhu Yi#define COEX_MEDIUM_BUSY	(0x0) /* radio belongs to WiMAX */
38352f301227a1ede57504694e1f64839839f5737cacZhu Yi#define COEX_MEDIUM_ACTIVE	(0x1) /* radio belongs to WiFi */
38362f301227a1ede57504694e1f64839839f5737cacZhu Yi#define COEX_MEDIUM_PRE_RELEASE	(0x2) /* received radio release */
3837396887a2b2ad1ef5e5526fec34dec582baf39b81Daniel C Halperin#define COEX_MEDIUM_MSK		(0x7)
3838857485c0c46ceee5c658c1761bba4d9a5ddf433fTomas Winkler
3839b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* send notification status (1 bit) */
38403d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define COEX_MEDIUM_CHANGED	(0x8)
38413d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define COEX_MEDIUM_CHANGED_MSK	(0x8)
38423d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define COEX_MEDIUM_SHIFT	(3)
38433d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
3844885ba202cabd90b8ade1fe59185dc96ed4d69e02Tomas Winklerstruct iwl_coex_medium_notification {
38452aa6ab86bc475a115f56645591d2413981846509Tomas Winkler	__le32 status;
38462aa6ab86bc475a115f56645591d2413981846509Tomas Winkler	__le32 events;
3847885ba202cabd90b8ade1fe59185dc96ed4d69e02Tomas Winkler} __attribute__ ((packed));
38482aa6ab86bc475a115f56645591d2413981846509Tomas Winkler
38497a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler/*
38507a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler * Coexistence EVENT  Command
38512aa6ab86bc475a115f56645591d2413981846509Tomas Winkler * COEX_EVENT_CMD = 0x5c
38522aa6ab86bc475a115f56645591d2413981846509Tomas Winkler *
38538f91aecb4cdc2d786df8941e827b9dff3c10a4e4Emmanuel Grumbach * send from host to uCode for coex event request.
3854653fa4a07525e4cd9e7b90e6fc1f792119910636Emmanuel Grumbach */
38552aa6ab86bc475a115f56645591d2413981846509Tomas Winkler/* flags options */
3856fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy#define COEX_EVENT_REQUEST_MSK	(0x1)
3857fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy
3858b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl_coex_event_cmd {
3859b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 flags;
3860b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 event;
3861b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved;
3862b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
3863a3139c5956702c9ff957ac9fe2d902de355b063eSamuel Ortiz
38648f5c87dcf6d1a5e6d7ffe642cfd4debb5ccbec49Winkler, Tomasstruct iwl_coex_event_resp {
38656a63578ddf6148927a80c07a73b40ccc8f3ac8e2Emmanuel Grumbach	__le32 status;
3866} __attribute__ ((packed));
3867
3868
3869/******************************************************************************
3870 * (13)
3871 * Union of all expected notifications/responses:
3872 *
3873 *****************************************************************************/
3874
3875struct iwl_rx_packet {
3876	/*
3877	 * The first 4 bytes of the RX frame header contain both the RX frame
3878	 * size and some flags.
3879	 * Bit fields:
3880	 * 31:    flag flush RB request
3881	 * 30:    flag ignore TC (terminal counter) request
3882	 * 29:    flag fast IRQ request
3883	 * 28-14: Reserved
3884	 * 13-00: RX frame size
3885	 */
3886	__le32 len_n_flags;
3887	struct iwl_cmd_header hdr;
3888	union {
3889		struct iwl3945_rx_frame rx_frame;
3890		struct iwl3945_tx_resp tx_resp;
3891		struct iwl3945_beacon_notif beacon_status;
3892
3893		struct iwl_alive_resp alive_frame;
3894		struct iwl_spectrum_notification spectrum_notif;
3895		struct iwl_csa_notification csa_notif;
3896		struct iwl_error_resp err_resp;
3897		struct iwl_card_state_notif card_state_notif;
3898		struct iwl_add_sta_resp add_sta;
3899		struct iwl_rem_sta_resp rem_sta;
3900		struct iwl_sleep_notification sleep_notif;
3901		struct iwl_spectrum_resp spectrum;
3902		struct iwl_notif_statistics stats;
3903		struct iwl_compressed_ba_resp compressed_ba;
3904		struct iwl_missed_beacon_notif missed_beacon;
3905		struct iwl_coex_medium_notification coex_medium_notif;
3906		struct iwl_coex_event_resp coex_event;
3907		__le32 status;
3908		u8 raw[0];
3909	} u;
3910} __attribute__ ((packed));
3911
3912int iwl_agn_check_rxon_cmd(struct iwl_priv *priv);
3913
3914#endif				/* __iwl_commands_h__ */
3915