iwl-commands.h revision 6ab10ff8738dfb098fd32132b7ebcf5cdb43ebde
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 *
801f8162a854df7f9c259c839ad3c1168ac13b7b8Reinette Chatre * Copyright(c) 2005 - 2009 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 *
3301f8162a854df7f9c259c839ad3c1168ac13b7b8Reinette Chatre * Copyright(c) 2005 - 2009 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,	/* not used */
99b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_REMOVE_ALL_STA = 0x1a,	/* not used */
100b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1010a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach	/* Security */
1020a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach	REPLY_WEPKEY = 0x20,
1030a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach
104b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* RX, TX, LEDs */
1052aa6ab86bc475a115f56645591d2413981846509Tomas Winkler	REPLY_3945_RX = 0x1b,           /* 3945 only */
106b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_TX = 0x1c,
107b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_RATE_SCALE = 0x47,	/* 3945 only */
108b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_LEDS_CMD = 0x48,
109b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_TX_LINK_QUALITY_CMD = 0x4e, /* 4965 only */
110b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1119636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	/* WiMAX coexistence */
112d23000cd8992823e06ca0745564f2c25fe923ce4Wey-Yi Guy	COEX_PRIORITY_TABLE_CMD = 0x5a,	/* for 5000 series and up */
1139636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_MEDIUM_NOTIFICATION = 0x5b,
1149636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_EVENT_CMD = 0x5c,
1159636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky
116be5d56ed885a2897ec813eab4a8055d495816e9aTomas Winkler	/* Calibration */
1171a5c3d61993f56daf15c35bea8d3943f4e835638Jay Sternberg	TEMPERATURE_NOTIFICATION = 0x62,
118be5d56ed885a2897ec813eab4a8055d495816e9aTomas Winkler	CALIBRATION_CFG_CMD = 0x65,
119be5d56ed885a2897ec813eab4a8055d495816e9aTomas Winkler	CALIBRATION_RES_NOTIFICATION = 0x66,
120be5d56ed885a2897ec813eab4a8055d495816e9aTomas Winkler	CALIBRATION_COMPLETE_NOTIFICATION = 0x67,
121be5d56ed885a2897ec813eab4a8055d495816e9aTomas Winkler
122b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* 802.11h related */
123b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	RADAR_NOTIFICATION = 0x70,	/* not used */
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
147b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* Miscellaneous commands */
14876a2407a5b043d0950d5657184118e89860d545cJay Sternberg	REPLY_TX_POWER_DBM_CMD = 0x95,
149b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	QUIET_NOTIFICATION = 0x96,		/* not used */
150b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_TX_PWR_TABLE_CMD = 0x97,
15176a2407a5b043d0950d5657184118e89860d545cJay Sternberg	REPLY_TX_POWER_DBM_CMD_V1 = 0x98,	/* old version of API */
1522f748deceee10bac563df0e859830cc628d1a841Wey-Yi Guy	TX_ANT_CONFIGURATION_CMD = 0x98,
153b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	MEASURE_ABORT_NOTIFICATION = 0x99,	/* not used */
154b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
155a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler	/* Bluetooth device coexistence config command */
156b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_BT_CONFIG = 0x9b,
157b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
15880cc0c382db318de88577eff027d5c4097abef81Ben M Cahill	/* 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,
173b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_RX_MPDU_CMD = 0xc1,
174857485c0c46ceee5c658c1761bba4d9a5ddf433fTomas Winkler	REPLY_RX = 0xc3,
175b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_COMPRESSED_BA = 0xc5,
176b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_MAX = 0xff
177b481de9ca074528fe8c429604e2777db8b89806aZhu Yi};
178b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
179b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
180b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (0)
181abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill * Commonly used structures and definitions:
18280cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * Command header, rate_n_flags, txpower
183b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
184b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
185b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
186857485c0c46ceee5c658c1761bba4d9a5ddf433fTomas Winkler/* iwl_cmd_header flags value */
187b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define IWL_CMD_FAILED_MSK 0x40
188b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
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)
1929734cb23a02f8de5fa99225ca61c7019ca9f232fTomas Winkler#define INDEX_TO_SEQ(i)	((i) & 0xff)
19351e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define SEQ_HUGE_FRAME	cpu_to_le16(0x4000)
19451e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define SEQ_RX_FRAME	cpu_to_le16(0x8000)
1959734cb23a02f8de5fa99225ca61c7019ca9f232fTomas Winkler
196075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill/**
197857485c0c46ceee5c658c1761bba4d9a5ddf433fTomas Winkler * 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.
201075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill */
202857485c0c46ceee5c658c1761bba4d9a5ddf433fTomas Winklerstruct iwl_cmd_header {
203075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	u8 cmd;		/* Command ID:  REPLY_RXON, etc. */
2049734cb23a02f8de5fa99225ca61c7019ca9f232fTomas Winkler	u8 flags;	/* 0:5 reserved, 6 abort, 7 internal */
205075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	/*
206a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler	 * 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
210075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	 * don't get used by uCode, the driver may set up an arbitrary format.
211b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 *
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
216075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	 * to the driver; it is not a direct response to any driver command.
217b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 *
218075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	 * The Linux driver uses the following format:
219075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	 *
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
2259734cb23a02f8de5fa99225ca61c7019ca9f232fTomas Winkler	 *  15		unsolicited RX or uCode-originated notification
226b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 */
227b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 sequence;
228b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
229075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	/* command or response/notification data follows immediately */
230b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 data[0];
231b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
232b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
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));
2633d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
264abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill/**
2655c5aa3f13a50881b8f6e529e321bbefb5faec37bHalperin, Daniel C * iwlagn rate_n_flags bit fields
266abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *
2675c5aa3f13a50881b8f6e529e321bbefb5faec37bHalperin, Daniel C * rate_n_flags format is used in following iwlagn commands:
268857485c0c46ceee5c658c1761bba4d9a5ddf433fTomas Winkler *  REPLY_RX (response only)
2695c5aa3f13a50881b8f6e529e321bbefb5faec37bHalperin, Daniel C *  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
282abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *
2835c5aa3f13a50881b8f6e529e321bbefb5faec37bHalperin, Daniel C *  4-3:  0)  Single stream (SISO)
284abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *        1)  Dual stream (MIMO)
2855c5aa3f13a50881b8f6e529e321bbefb5faec37bHalperin, Daniel C *        2)  Triple stream (MIMO)
286abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill *
2877aafef1c6e2e24f9a10dc2972bf0ee70624ccc47Wey-Yi Guy *    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 *
299abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill * Legacy CCK rate format for bits 7:0 (bit 8 must be "0", bit 9 "1"):
3001061787967db03975dc02030d6815811f4eb9231Daniel Wu *  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 */
305abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill#define RATE_MCS_CODE_MSK 0x7
3065c5aa3f13a50881b8f6e529e321bbefb5faec37bHalperin, Daniel C#define RATE_MCS_SPATIAL_POS 3
3075c5aa3f13a50881b8f6e529e321bbefb5faec37bHalperin, Daniel C#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
310abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill
311075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben 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
315abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill
316075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben 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
319abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill
320075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben 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
323abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill
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
3267aafef1c6e2e24f9a10dc2972bf0ee70624ccc47Wey-Yi Guy#define RATE_MCS_HT40_MSK 0x800
327abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill
3287aafef1c6e2e24f9a10dc2972bf0ee70624ccc47Wey-Yi Guy/* 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
331abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill
332075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben 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
336abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill/**
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
34376eff18bdc5feaa53f1be33709b67df02f1d55e9Tomas Winkler * bit14:16
344abceddb40728397fcfd0b295d7530920a606ab88Ben M Cahill */
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)
350600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler#define RATE_MCS_ANT_ABC_MSK	(RATE_MCS_ANT_AB_MSK | RATE_MCS_ANT_C_MSK)
35176eff18bdc5feaa53f1be33709b67df02f1d55e9Tomas Winkler#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
35680cc0c382db318de88577eff027d5c4097abef81Ben M Cahill
357e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy#define IWL_PWR_NUM_HT_OFDM_ENTRIES		24
358e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy#define IWL_PWR_CCK_ENTRIES			2
359e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy
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));
40380cc0c382db318de88577eff027d5c4097abef81Ben M Cahill
404630fe9b6f774dd55b71fe94392101eb00df58762Tomas Winkler/**
405a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler * Command REPLY_TX_POWER_DBM_CMD = 0x98
406630fe9b6f774dd55b71fe94392101eb00df58762Tomas Winkler * struct iwl5000_tx_power_dbm_cmd
407630fe9b6f774dd55b71fe94392101eb00df58762Tomas Winkler */
408630fe9b6f774dd55b71fe94392101eb00df58762Tomas Winkler#define IWL50_TX_POWER_AUTO 0x7f
409853554accce19d16b03476676bdcb1ccdd44caaeGregory Greenman#define IWL50_TX_POWER_NO_CLOSED (0x1 << 6)
410853554accce19d16b03476676bdcb1ccdd44caaeGregory Greenman
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;
416630fe9b6f774dd55b71fe94392101eb00df58762Tomas Winkler} __attribute__ ((packed));
41780cc0c382db318de88577eff027d5c4097abef81Ben M Cahill
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));
4272f748deceee10bac563df0e859830cc628d1a841Wey-Yi Guy
428b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
429b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (0a)
430b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Alive and Error Commands & Responses:
431b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
432b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
433b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
43451e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define UCODE_VALID_OK	cpu_to_le32(0x1)
435b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define INITIALIZE_SUBTYPE    (9)
436b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
437b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
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 *
450075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * 1)  Power supply voltage indication.  The voltage sensor outputs higher
451a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler *     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,
459075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *     for each of 5 frequency ranges.
460b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
461885ba202cabd90b8ade1fe59185dc96ed4d69e02Tomas Winklerstruct iwl_init_alive_resp {
462b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ucode_minor;
463b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ucode_major;
464b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved1;
465b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 sw_rev[8];
466b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ver_type;
467075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	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;
472b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 is_valid;
473075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill
474075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	/* calibration values from "initialize" uCode */
475075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	__le32 voltage;		/* signed, higher value is lower voltage */
4767aafef1c6e2e24f9a10dc2972bf0ee70624ccc47Wey-Yi Guy	__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,
481075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill				 * 2 Tx chains */
482b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
483b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
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.
515075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *
516075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * 2)  error_event_table_ptr indicates base of the error log.  This contains
517075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *     information about any uCode error that occurs.  For 4965, the format
518075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *     of the error log is:
519075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *
520075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 valid;        (nonzero) valid, (0) log is empty
521075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 error_id;     type of error
522075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 pc;           program counter
523075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 blink1;       branch link
524075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 blink2;       branch link
525075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 ilink1;       interrupt link
526075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 ilink2;       interrupt link
527075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 data1;        error-specific data
528075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 data2;        error-specific data
529075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 line;         source code line of error
530075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 bcon_time;    beacon timer
531075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 tsf_low;      network timestamp function timer
532075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 tsf_hi;       network timestamp function timer
533075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *
534075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * The Linux driver can print both logs to the system log when a uCode error
535075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * occurs.
536075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill */
537885ba202cabd90b8ade1fe59185dc96ed4d69e02Tomas Winklerstruct iwl_alive_resp {
538b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ucode_minor;
539b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ucode_major;
540b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved1;
541b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 sw_rev[8];
542b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ver_type;
543075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	u8 ver_subtype;			/* not "9" for runtime alive */
544b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved2;
545075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	__le32 log_event_table_ptr;	/* SRAM address for event log */
546075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	__le32 error_event_table_ptr;	/* SRAM address for error log */
547b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 timestamp;
548b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 is_valid;
549b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
550b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
551b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
552b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_ERROR = 0x2 (response only, not a command)
553b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
554885ba202cabd90b8ade1fe59185dc96ed4d69e02Tomas Winklerstruct iwl_error_resp {
555b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 error_type;
556b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 cmd_id;
557b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved1;
558b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 bad_cmd_seq_num;
559b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 error_info;
5603195c1f3499912b207ae600968488759b16037fcTomas Winkler	__le64 timestamp;
561b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
562b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
563b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
564b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (1)
565b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * RXON Commands & Responses:
566b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
567b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
568b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
569b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
570b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Rx config defines & structure
571b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
572b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* rx_config device types  */
573b481de9ca074528fe8c429604e2777db8b89806aZhu Yienum {
574b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	RXON_DEV_TYPE_AP = 1,
575b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	RXON_DEV_TYPE_ESS = 3,
576b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	RXON_DEV_TYPE_IBSS = 4,
577b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	RXON_DEV_TYPE_SNIFFER = 6,
578b481de9ca074528fe8c429604e2777db8b89806aZhu Yi};
579b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
58014519a0b46085db68e610147098d03386c34801fBen M Cahill
58151e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_RX_CHAIN_DRIVER_FORCE_MSK		cpu_to_le16(0x1 << 0)
5827b841727d2715d97592f46164804b34d6241644fRick Farrington#define RXON_RX_CHAIN_DRIVER_FORCE_POS		(0)
58351e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_RX_CHAIN_VALID_MSK			cpu_to_le16(0x7 << 1)
58414519a0b46085db68e610147098d03386c34801fBen M Cahill#define RXON_RX_CHAIN_VALID_POS			(1)
58551e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_RX_CHAIN_FORCE_SEL_MSK		cpu_to_le16(0x7 << 4)
58614519a0b46085db68e610147098d03386c34801fBen M Cahill#define RXON_RX_CHAIN_FORCE_SEL_POS		(4)
58751e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_RX_CHAIN_FORCE_MIMO_SEL_MSK	cpu_to_le16(0x7 << 7)
58814519a0b46085db68e610147098d03386c34801fBen M Cahill#define RXON_RX_CHAIN_FORCE_MIMO_SEL_POS	(7)
58951e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_RX_CHAIN_CNT_MSK			cpu_to_le16(0x3 << 10)
59014519a0b46085db68e610147098d03386c34801fBen M Cahill#define RXON_RX_CHAIN_CNT_POS			(10)
59151e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_RX_CHAIN_MIMO_CNT_MSK		cpu_to_le16(0x3 << 12)
59214519a0b46085db68e610147098d03386c34801fBen M Cahill#define RXON_RX_CHAIN_MIMO_CNT_POS		(12)
59351e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_RX_CHAIN_MIMO_FORCE_MSK		cpu_to_le16(0x1 << 14)
59414519a0b46085db68e610147098d03386c34801fBen M Cahill#define RXON_RX_CHAIN_MIMO_FORCE_POS		(14)
59514519a0b46085db68e610147098d03386c34801fBen M Cahill
596b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* rx_config flags */
597b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* band & modulation selection */
59851e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_BAND_24G_MSK           cpu_to_le32(1 << 0)
59951e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_CCK_MSK                cpu_to_le32(1 << 1)
600b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* auto detection enable */
60151e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_AUTO_DETECT_MSK        cpu_to_le32(1 << 2)
602b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* TGg protection when tx */
60351e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_TGG_PROTECT_MSK        cpu_to_le32(1 << 3)
604b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* cck short slot & preamble */
60551e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_SHORT_SLOT_MSK          cpu_to_le32(1 << 4)
60651e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_SHORT_PREAMBLE_MSK     cpu_to_le32(1 << 5)
607b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* antenna selection */
60851e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_DIS_DIV_MSK            cpu_to_le32(1 << 7)
60951e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_ANT_SEL_MSK            cpu_to_le32(0x0f00)
61051e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_ANT_A_MSK              cpu_to_le32(1 << 8)
61151e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_ANT_B_MSK              cpu_to_le32(1 << 9)
612b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* radar detection enable */
61351e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_RADAR_DETECT_MSK       cpu_to_le32(1 << 12)
61451e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_TGJ_NARROW_BAND_MSK    cpu_to_le32(1 << 13)
615b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* rx response to host with 8-byte TSF
616b481de9ca074528fe8c429604e2777db8b89806aZhu Yi* (according to ON_AIR deassertion) */
61751e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_TSF2HOST_MSK           cpu_to_le32(1 << 15)
618b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
61914519a0b46085db68e610147098d03386c34801fBen M Cahill
62014519a0b46085db68e610147098d03386c34801fBen M Cahill/* HT flags */
62114519a0b46085db68e610147098d03386c34801fBen M Cahill#define RXON_FLG_CTRL_CHANNEL_LOC_POS		(22)
62251e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK	cpu_to_le32(0x1 << 22)
62314519a0b46085db68e610147098d03386c34801fBen M Cahill
62414519a0b46085db68e610147098d03386c34801fBen M Cahill#define RXON_FLG_HT_OPERATING_MODE_POS		(23)
62514519a0b46085db68e610147098d03386c34801fBen M Cahill
62651e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_HT_PROT_MSK			cpu_to_le32(0x1 << 23)
6277aafef1c6e2e24f9a10dc2972bf0ee70624ccc47Wey-Yi Guy#define RXON_FLG_HT40_PROT_MSK			cpu_to_le32(0x2 << 23)
62814519a0b46085db68e610147098d03386c34801fBen M Cahill
62914519a0b46085db68e610147098d03386c34801fBen M Cahill#define RXON_FLG_CHANNEL_MODE_POS		(25)
63051e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_CHANNEL_MODE_MSK		cpu_to_le32(0x3 << 25)
631a2b0f02e4795bfde5f11720a10af8923cb98b654Wey-Yi Guy
632a2b0f02e4795bfde5f11720a10af8923cb98b654Wey-Yi Guy/* channel mode */
633a2b0f02e4795bfde5f11720a10af8923cb98b654Wey-Yi Guyenum {
634a2b0f02e4795bfde5f11720a10af8923cb98b654Wey-Yi Guy	CHANNEL_MODE_LEGACY = 0,
635a2b0f02e4795bfde5f11720a10af8923cb98b654Wey-Yi Guy	CHANNEL_MODE_PURE_40 = 1,
636a2b0f02e4795bfde5f11720a10af8923cb98b654Wey-Yi Guy	CHANNEL_MODE_MIXED = 2,
637a2b0f02e4795bfde5f11720a10af8923cb98b654Wey-Yi Guy	CHANNEL_MODE_RESERVED = 3,
638a2b0f02e4795bfde5f11720a10af8923cb98b654Wey-Yi Guy};
639a2b0f02e4795bfde5f11720a10af8923cb98b654Wey-Yi Guy#define RXON_FLG_CHANNEL_MODE_LEGACY	cpu_to_le32(CHANNEL_MODE_LEGACY << RXON_FLG_CHANNEL_MODE_POS)
640a2b0f02e4795bfde5f11720a10af8923cb98b654Wey-Yi Guy#define RXON_FLG_CHANNEL_MODE_PURE_40	cpu_to_le32(CHANNEL_MODE_PURE_40 << RXON_FLG_CHANNEL_MODE_POS)
641a2b0f02e4795bfde5f11720a10af8923cb98b654Wey-Yi Guy#define RXON_FLG_CHANNEL_MODE_MIXED	cpu_to_le32(CHANNEL_MODE_MIXED << RXON_FLG_CHANNEL_MODE_POS)
642a2b0f02e4795bfde5f11720a10af8923cb98b654Wey-Yi Guy
643a326a5d096f031af46c0073dd78eb80dea1f311aEmmanuel Grumbach/* CTS to self (if spec allows) flag */
64451e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_SELF_CTS_EN			cpu_to_le32(0x1<<30)
64514519a0b46085db68e610147098d03386c34801fBen M Cahill
646b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* rx_config filter flags */
647b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* accept all data frames */
64851e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FILTER_PROMISC_MSK         cpu_to_le32(1 << 0)
649b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* pass control & management to host */
65051e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FILTER_CTL2HOST_MSK        cpu_to_le32(1 << 1)
651b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* accept multi-cast */
65251e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FILTER_ACCEPT_GRP_MSK      cpu_to_le32(1 << 2)
653b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* don't decrypt uni-cast frames */
65451e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FILTER_DIS_DECRYPT_MSK     cpu_to_le32(1 << 3)
655b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* don't decrypt multi-cast frames */
65651e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FILTER_DIS_GRP_DECRYPT_MSK cpu_to_le32(1 << 4)
657b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* STA is associated */
65851e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FILTER_ASSOC_MSK           cpu_to_le32(1 << 5)
659b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* transfer to host non bssid beacons in associated state */
66051e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FILTER_BCON_AWARE_MSK      cpu_to_le32(1 << 6)
661b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
66280cc0c382db318de88577eff027d5c4097abef81Ben M Cahill/**
663b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_RXON = 0x10 (command, has simple generic response)
66480cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *
66580cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * RXON tunes the radio tuner to a service channel, and sets up a number
66680cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * of parameters that are used primarily for Rx, but also for Tx operations.
66780cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *
66880cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * NOTE:  When tuning to a new channel, driver must set the
66980cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *        RXON_FILTER_ASSOC_MSK to 0.  This will clear station-dependent
67080cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *        info within the device, including the station tables, tx retry
67180cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *        rate tables, and txpower tables.  Driver must build a new station
67280cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *        table and txpower table before transmitting anything on the RXON
67380cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *        channel.
67480cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *
67580cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * NOTE:  All RXONs wipe clean the internal txpower table.  Driver must
67680cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *        issue a new REPLY_TX_PWR_TABLE_CMD after each REPLY_RXON (0x10),
67780cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *        regardless of whether RXON_FILTER_ASSOC_MSK is set.
678b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
6793d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
6803d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_rxon_cmd {
6813d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 node_addr[6];
6823d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 reserved1;
6833d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 bssid_addr[6];
6843d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 reserved2;
6853d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 wlap_bssid_addr[6];
6863d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 reserved3;
6873d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 dev_type;
6883d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 air_propagation;
6893d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 reserved4;
6903d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 ofdm_basic_rates;
6913d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 cck_basic_rates;
6923d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 assoc_id;
6933d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 flags;
6943d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 filter_flags;
6953d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 channel;
6963d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 reserved5;
6973d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler} __attribute__ ((packed));
6983d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
699bb8c093bdea62f2ae371b98ebff81b0407852fafChristoph Hellwigstruct iwl4965_rxon_cmd {
700b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 node_addr[6];
701b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved1;
702b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 bssid_addr[6];
703b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved2;
704b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 wlap_bssid_addr[6];
705b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved3;
706b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 dev_type;
707b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 air_propagation;
708b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 rx_chain;
709b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ofdm_basic_rates;
710b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 cck_basic_rates;
711b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 assoc_id;
712b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 flags;
713b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 filter_flags;
714b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 channel;
715b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ofdm_ht_single_stream_basic_rates;
716b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ofdm_ht_dual_stream_basic_rates;
717b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
718b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
719a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler/* 5000 HW just extend this command */
720c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenmanstruct iwl_rxon_cmd {
721c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 node_addr[6];
722c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	__le16 reserved1;
723c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 bssid_addr[6];
724c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	__le16 reserved2;
725c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 wlap_bssid_addr[6];
726c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	__le16 reserved3;
727c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 dev_type;
728c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 air_propagation;
729c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	__le16 rx_chain;
730c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 ofdm_basic_rates;
731c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 cck_basic_rates;
732c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	__le16 assoc_id;
733c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	__le32 flags;
734c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	__le32 filter_flags;
735c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	__le16 channel;
736c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 ofdm_ht_single_stream_basic_rates;
737c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 ofdm_ht_dual_stream_basic_rates;
738c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 ofdm_ht_triple_stream_basic_rates;
739c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 reserved5;
740c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	__le16 acquisition_data;
741c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	__le16 reserved6;
742c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman} __attribute__ ((packed));
743c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman
7443d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler/*
7453d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * REPLY_RXON_ASSOC = 0x11 (command, has simple generic response)
7463d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler */
7473d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_rxon_assoc_cmd {
7483d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 flags;
7493d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 filter_flags;
7503d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 ofdm_basic_rates;
7513d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 cck_basic_rates;
7523d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 reserved;
7533d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler} __attribute__ ((packed));
7543d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
7553d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl4965_rxon_assoc_cmd {
756fe7a90c2b73f0c1da0882861cd015c835ed28781Ron Rindjunsky	__le32 flags;
757fe7a90c2b73f0c1da0882861cd015c835ed28781Ron Rindjunsky	__le32 filter_flags;
758fe7a90c2b73f0c1da0882861cd015c835ed28781Ron Rindjunsky	u8 ofdm_basic_rates;
759fe7a90c2b73f0c1da0882861cd015c835ed28781Ron Rindjunsky	u8 cck_basic_rates;
760fe7a90c2b73f0c1da0882861cd015c835ed28781Ron Rindjunsky	u8 ofdm_ht_single_stream_basic_rates;
761fe7a90c2b73f0c1da0882861cd015c835ed28781Ron Rindjunsky	u8 ofdm_ht_dual_stream_basic_rates;
762fe7a90c2b73f0c1da0882861cd015c835ed28781Ron Rindjunsky	__le16 rx_chain_select_flags;
7633d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 reserved;
764fe7a90c2b73f0c1da0882861cd015c835ed28781Ron Rindjunsky} __attribute__ ((packed));
765c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman
7663d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl5000_rxon_assoc_cmd {
767b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 flags;
768b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 filter_flags;
769b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ofdm_basic_rates;
770b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 cck_basic_rates;
7713d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 reserved1;
772b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ofdm_ht_single_stream_basic_rates;
773b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ofdm_ht_dual_stream_basic_rates;
7743d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 ofdm_ht_triple_stream_basic_rates;
7753d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 reserved2;
776b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 rx_chain_select_flags;
7773d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 acquisition_data;
7783d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 reserved3;
779b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
780b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
781b5d7be5e665f29274cfe6645b661acb38cb1d19bTomas Winkler#define IWL_CONN_MAX_LISTEN_INTERVAL	10
7822c2f3b33888419fb9e7d015b9dc67b9db4437efaTomas Winkler#define IWL_MAX_UCODE_BEACON_INTERVAL	4 /* 4096 */
7832c2f3b33888419fb9e7d015b9dc67b9db4437efaTomas Winkler#define IWL39_MAX_UCODE_BEACON_INTERVAL	1 /* 1024 */
784fe7a90c2b73f0c1da0882861cd015c835ed28781Ron Rindjunsky
785b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
786b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_RXON_TIMING = 0x14 (command, has simple generic response)
787b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
7883195c1f3499912b207ae600968488759b16037fcTomas Winklerstruct iwl_rxon_time_cmd {
7893195c1f3499912b207ae600968488759b16037fcTomas Winkler	__le64 timestamp;
790b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 beacon_interval;
791b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 atim_window;
792b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_init_val;
793b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 listen_interval;
794b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved;
795b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
796b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
797b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
798b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_CHANNEL_SWITCH = 0x72 (command, has simple generic response)
799b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
8003d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_channel_switch_cmd {
8013d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 band;
8023d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 expect_beacon;
8033d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 channel;
8043d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 rxon_flags;
8053d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 rxon_filter_flags;
8063d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 switch_time;
8073d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct iwl3945_power_per_rate power[IWL_MAX_RATES];
8083d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler} __attribute__ ((packed));
8093d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
810e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guystruct iwl4965_channel_switch_cmd {
811b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 band;
812b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 expect_beacon;
813b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 channel;
814b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 rxon_flags;
815b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 rxon_filter_flags;
816b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 switch_time;
817bb8c093bdea62f2ae371b98ebff81b0407852fafChristoph Hellwig	struct iwl4965_tx_power_db tx_power;
818b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
819b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
820e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy/**
821e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * struct iwl5000_channel_switch_cmd
822e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * @band: 0- 5.2GHz, 1- 2.4GHz
823e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * @expect_beacon: 0- resume transmits after channel switch
824e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy *		   1- wait for beacon to resume transmits
825e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * @channel: new channel number
826e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * @rxon_flags: Rx on flags
827e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * @rxon_filter_flags: filtering parameters
828e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * @switch_time: switch time in extended beacon format
829e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * @reserved: reserved bytes
830e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy */
831e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guystruct iwl5000_channel_switch_cmd {
832e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy	u8 band;
833e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy	u8 expect_beacon;
834e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy	__le16 channel;
835e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy	__le32 rxon_flags;
836e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy	__le32 rxon_filter_flags;
837e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy	__le32 switch_time;
838e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy	__le32 reserved[2][IWL_PWR_NUM_HT_OFDM_ENTRIES + IWL_PWR_CCK_ENTRIES];
839e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy} __attribute__ ((packed));
840e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy
841e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy/**
842e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * struct iwl6000_channel_switch_cmd
843e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * @band: 0- 5.2GHz, 1- 2.4GHz
844e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * @expect_beacon: 0- resume transmits after channel switch
845e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy *		   1- wait for beacon to resume transmits
846e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * @channel: new channel number
847e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * @rxon_flags: Rx on flags
848e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * @rxon_filter_flags: filtering parameters
849e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * @switch_time: switch time in extended beacon format
850e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * @reserved: reserved bytes
851e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy */
852e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guystruct iwl6000_channel_switch_cmd {
853e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy	u8 band;
854e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy	u8 expect_beacon;
855e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy	__le16 channel;
856e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy	__le32 rxon_flags;
857e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy	__le32 rxon_filter_flags;
858e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy	__le32 switch_time;
859e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy	__le32 reserved[3][IWL_PWR_NUM_HT_OFDM_ENTRIES + IWL_PWR_CCK_ENTRIES];
860e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy} __attribute__ ((packed));
861e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy
862b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
863b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * CHANNEL_SWITCH_NOTIFICATION = 0x73 (notification only, not a command)
864b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
8652aa6ab86bc475a115f56645591d2413981846509Tomas Winklerstruct iwl_csa_notification {
866b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 band;
867b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 channel;
868b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 status;		/* 0 - OK, 1 - fail */
869b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
870b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
871b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
872b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (2)
873b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Quality-of-Service (QOS) Commands & Responses:
874b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
875b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
8762054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill
8772054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill/**
8782054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * struct iwl_ac_qos -- QOS timing params for REPLY_QOS_PARAM
8792054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * One for each of 4 EDCA access categories in struct iwl_qosparam_cmd
8802054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *
8812054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * @cw_min: Contention window, start value in numbers of slots.
8822054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *          Should be a power-of-2, minus 1.  Device's default is 0x0f.
8832054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * @cw_max: Contention window, max value in numbers of slots.
8842054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *          Should be a power-of-2, minus 1.  Device's default is 0x3f.
8852054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * @aifsn:  Number of slots in Arbitration Interframe Space (before
8862054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *          performing random backoff timing prior to Tx).  Device default 1.
8872054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * @edca_txop:  Length of Tx opportunity, in uSecs.  Device default is 0.
8882054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *
8892054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * Device will automatically increase contention window by (2*CW) + 1 for each
8902054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * transmission retry.  Device uses cw_max as a bit mask, ANDed with new CW
8912054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * value, to cap the CW value.
8922054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill */
8931ff50bda6eef4466366e197541508fc69af0f0c0Emmanuel Grumbachstruct iwl_ac_qos {
894b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 cw_min;
895b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 cw_max;
896b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 aifsn;
897b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved1;
898b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 edca_txop;
899b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
900b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
901b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* QoS flags defines */
90251e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define QOS_PARAM_FLG_UPDATE_EDCA_MSK	cpu_to_le32(0x01)
90351e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define QOS_PARAM_FLG_TGN_MSK		cpu_to_le32(0x02)
90451e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define QOS_PARAM_FLG_TXOP_TYPE_MSK	cpu_to_le32(0x10)
905b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
9062054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill/* Number of Access Categories (AC) (EDCA), queues 0..3 */
907b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define AC_NUM                4
908b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
909b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
910b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_QOS_PARAM = 0x13 (command, has simple generic response)
9112054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *
9122054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * This command sets up timings for each of the 4 prioritized EDCA Tx FIFOs
9132054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * 0: Background, 1: Best Effort, 2: Video, 3: Voice.
914b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
9151ff50bda6eef4466366e197541508fc69af0f0c0Emmanuel Grumbachstruct iwl_qosparam_cmd {
916b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 qos_flags;
9171ff50bda6eef4466366e197541508fc69af0f0c0Emmanuel Grumbach	struct iwl_ac_qos ac[AC_NUM];
918b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
919b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
920b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
921b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (3)
922b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Add/Modify Stations Commands & Responses:
923b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
924b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
925b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
926b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Multi station support
927b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
9282054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill
9292054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill/* Special, dedicated locations within device's station table */
930b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	IWL_AP_ID		0
931b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define IWL_MULTICAST_ID	1
932b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	IWL_STA_ID		2
9334c897253cc9ae1c6a2798b27b5fe8e6d94ab6185Tomas Winkler#define	IWL3945_BROADCAST_ID	24
9344c897253cc9ae1c6a2798b27b5fe8e6d94ab6185Tomas Winkler#define IWL3945_STATION_COUNT	25
935b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define IWL4965_BROADCAST_ID	31
936b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	IWL4965_STATION_COUNT	32
937fdd3e8a4ff96d03121b21946bfa684f3b5d783c6Tomas Winkler#define IWL5000_BROADCAST_ID	15
938fdd3e8a4ff96d03121b21946bfa684f3b5d783c6Tomas Winkler#define	IWL5000_STATION_COUNT	16
939b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
940b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	IWL_STATION_COUNT	32 	/* MAX(3945,4965)*/
941b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	IWL_INVALID_STATION 	255
942b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
9434c897253cc9ae1c6a2798b27b5fe8e6d94ab6185Tomas Winkler#define STA_FLG_TX_RATE_MSK		cpu_to_le32(1 << 2);
9444c897253cc9ae1c6a2798b27b5fe8e6d94ab6185Tomas Winkler#define STA_FLG_PWR_SAVE_MSK		cpu_to_le32(1 << 8);
94551e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_FLG_RTS_MIMO_PROT_MSK	cpu_to_le32(1 << 17)
94651e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_FLG_AGG_MPDU_8US_MSK	cpu_to_le32(1 << 18)
94774093ddf4c42da74922b63fb6844989e21164d9eBen M Cahill#define STA_FLG_MAX_AGG_SIZE_POS	(19)
94851e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_FLG_MAX_AGG_SIZE_MSK	cpu_to_le32(3 << 19)
9497aafef1c6e2e24f9a10dc2972bf0ee70624ccc47Wey-Yi Guy#define STA_FLG_HT40_EN_MSK		cpu_to_le32(1 << 21)
95051e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_FLG_MIMO_DIS_MSK		cpu_to_le32(1 << 22)
95174093ddf4c42da74922b63fb6844989e21164d9eBen M Cahill#define STA_FLG_AGG_MPDU_DENSITY_POS	(23)
95251e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_FLG_AGG_MPDU_DENSITY_MSK	cpu_to_le32(7 << 23)
953b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
9542054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill/* Use in mode field.  1: modify existing entry, 0: add new station entry */
955b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define STA_CONTROL_MODIFY_MSK		0x01
956b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
957b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* key flags __le16*/
95851e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_KEY_FLG_ENCRYPT_MSK	cpu_to_le16(0x0007)
95951e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_KEY_FLG_NO_ENC	cpu_to_le16(0x0000)
96051e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_KEY_FLG_WEP		cpu_to_le16(0x0001)
96151e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_KEY_FLG_CCMP	cpu_to_le16(0x0002)
96251e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_KEY_FLG_TKIP	cpu_to_le16(0x0003)
963b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
964b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define STA_KEY_FLG_KEYID_POS	8
96551e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_KEY_FLG_INVALID 	cpu_to_le16(0x0800)
966eaaf7894959d413d1e01443a622c507e1b4f61dbEmmanuel Grumbach/* wep key is either from global key (0) or from station info array (1) */
96751e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_KEY_FLG_MAP_KEY_MSK	cpu_to_le16(0x0008)
968eaaf7894959d413d1e01443a622c507e1b4f61dbEmmanuel Grumbach
969eaaf7894959d413d1e01443a622c507e1b4f61dbEmmanuel Grumbach/* wep key in STA: 5-bytes (0) or 13-bytes (1) */
97051e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_KEY_FLG_KEY_SIZE_MSK     cpu_to_le16(0x1000)
97151e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_KEY_MULTICAST_MSK        cpu_to_le16(0x4000)
972deb09c435e3f947f8b2c9d5df6a9c0a5b472b125Emmanuel Grumbach#define STA_KEY_MAX_NUM		8
973b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
9742054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill/* Flags indicate whether to modify vs. don't change various station params */
975b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	STA_MODIFY_KEY_MASK		0x01
976b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	STA_MODIFY_TID_DISABLE_TX	0x02
977b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	STA_MODIFY_TX_RATE_MSK		0x04
978b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define STA_MODIFY_ADDBA_TID_MSK	0x08
979b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define STA_MODIFY_DELBA_TID_MSK	0x10
9806ab10ff8738dfb098fd32132b7ebcf5cdb43ebdeJohannes Berg#define STA_MODIFY_SLEEP_TX_COUNT_MSK	0x20
9812054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill
9822054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill/* Receiver address (actually, Rx station's index into station table),
9832054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * combined with Traffic ID (QOS priority), in format used by Tx Scheduler */
984b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define BUILD_RAxTID(sta_id, tid)	(((sta_id) << 4) + (tid))
985b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
986bb8c093bdea62f2ae371b98ebff81b0407852fafChristoph Hellwigstruct iwl4965_keyinfo {
987b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 key_flags;
988b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 tkip_rx_tsc_byte2;	/* TSC[2] for key mix ph1 detection */
989b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved1;
990b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 tkip_rx_ttak[5];	/* 10-byte unicast TKIP TTAK */
991eaaf7894959d413d1e01443a622c507e1b4f61dbEmmanuel Grumbach	u8 key_offset;
992eaaf7894959d413d1e01443a622c507e1b4f61dbEmmanuel Grumbach	u8 reserved2;
993b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 key[16];		/* 16-byte unicast decryption key */
994b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
995b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
996133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler/* 5000 */
997133636deffc86809f59a0c8b768408d13237a9a2Tomas Winklerstruct iwl_keyinfo {
998133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	__le16 key_flags;
999133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	u8 tkip_rx_tsc_byte2;	/* TSC[2] for key mix ph1 detection */
1000133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	u8 reserved1;
1001133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	__le16 tkip_rx_ttak[5];	/* 10-byte unicast TKIP TTAK */
1002133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	u8 key_offset;
1003133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	u8 reserved2;
1004133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	u8 key[16];		/* 16-byte unicast decryption key */
1005133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	__le64 tx_secur_seq_cnt;
1006133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	__le64 hw_tkip_mic_rx_key;
1007133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	__le64 hw_tkip_mic_tx_key;
1008133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler} __attribute__ ((packed));
1009133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler
10102054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill/**
10112054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * struct sta_id_modify
10122054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * @addr[ETH_ALEN]: station's MAC address
10132054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * @sta_id: index of station in uCode's station table
10142054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * @modify_mask: STA_MODIFY_*, 1: modify, 0: don't change
10152054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *
10162054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * Driver selects unused table index when adding new station,
10172054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * or the index to a pre-existing station entry when modifying that station.
10182054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * Some indexes have special purposes (IWL_AP_ID, index 0, is for AP).
10192054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *
10202054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * modify_mask flags select which parameters to modify vs. leave alone.
10212054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill */
1022b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct sta_id_modify {
1023b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 addr[ETH_ALEN];
1024b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved1;
1025b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 sta_id;
1026b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 modify_mask;
1027b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved2;
1028b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
1029b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1030b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
1031b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_ADD_STA = 0x18 (command)
10322054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *
10332054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * The device contains an internal table of per-station information,
10342054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * with info on security keys, aggregation parameters, and Tx rates for
10352054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * initial Tx attempt and any retries (4965 uses REPLY_TX_LINK_QUALITY_CMD,
10362054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * 3945 uses REPLY_RATE_SCALE to set up rate tables).
10372054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *
10382054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * REPLY_ADD_STA sets up the table entry for one station, either creating
10392054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * a new entry, or modifying a pre-existing one.
10402054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *
10412054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * NOTE:  RXON command (without "associated" bit set) wipes the station table
10422054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        clean.  Moving into RF_KILL state does this also.  Driver must set up
10432054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        new station table before transmitting anything on the RXON channel
10442054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        (except active scans or active measurements; those commands carry
10452054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        their own txpower/rate setup data).
10462054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *
10472054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        When getting started on a new channel, driver must set up the
10482054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        IWL_BROADCAST_ID entry (last entry in the table).  For a client
10492054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        station in a BSS, once an AP is selected, driver sets up the AP STA
10502054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        in the IWL_AP_ID entry (1st entry in the table).  BROADCAST and AP
10512054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        are all that are needed for a BSS client station.  If the device is
10522054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        used as AP, or in an IBSS network, driver must set up station table
10532054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        entries for all STAs in network, starting with index IWL_STA_ID.
1054b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
10553d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
10563d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_addsta_cmd {
10573d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 mode;		/* 1: modify existing, 0: add new station */
10583d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 reserved[3];
10593d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct sta_id_modify sta;
10603d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct iwl4965_keyinfo key;
10613d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 station_flags;		/* STA_FLG_* */
10623d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 station_flags_msk;	/* STA_FLG_* */
10633d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
10643d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	/* bit field to disable (1) or enable (0) Tx for Traffic ID (TID)
10653d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * corresponding to bit (e.g. bit 5 controls TID 5).
10663d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */
10673d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 tid_disable_tx;
10683d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
10693d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 rate_n_flags;
10703d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
10713d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	/* TID for which to add block-ack support.
10723d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
10733d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 add_immediate_ba_tid;
10743d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
10753d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	/* TID for which to remove block-ack support.
10763d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * Set modify_mask bit STA_MODIFY_DELBA_TID_MSK to use this field. */
10773d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 remove_immediate_ba_tid;
10783d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
10793d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	/* Starting Sequence Number for added block-ack support.
10803d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
10813d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 add_immediate_ba_ssn;
10823d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler} __attribute__ ((packed));
10833d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
1084bb8c093bdea62f2ae371b98ebff81b0407852fafChristoph Hellwigstruct iwl4965_addsta_cmd {
10852054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	u8 mode;		/* 1: modify existing, 0: add new station */
1086b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved[3];
1087b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct sta_id_modify sta;
1088bb8c093bdea62f2ae371b98ebff81b0407852fafChristoph Hellwig	struct iwl4965_keyinfo key;
10892054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	__le32 station_flags;		/* STA_FLG_* */
10902054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	__le32 station_flags_msk;	/* STA_FLG_* */
10912054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill
10922054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	/* bit field to disable (1) or enable (0) Tx for Traffic ID (TID)
10932054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	 * corresponding to bit (e.g. bit 5 controls TID 5).
10942054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	 * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */
1095b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 tid_disable_tx;
10962054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill
1097b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16	reserved1;
10982054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill
10992054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	/* TID for which to add block-ack support.
11002054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
1101b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 add_immediate_ba_tid;
11022054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill
11032054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	/* TID for which to remove block-ack support.
11042054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	 * Set modify_mask bit STA_MODIFY_DELBA_TID_MSK to use this field. */
1105b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 remove_immediate_ba_tid;
11062054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill
11072054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	/* Starting Sequence Number for added block-ack support.
11082054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
1109b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 add_immediate_ba_ssn;
11102054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill
11119bb487b406692e172b15eba58de7d69358ac2005Johannes Berg	/*
11129bb487b406692e172b15eba58de7d69358ac2005Johannes Berg	 * Number of packets OK to transmit to station even though
11139bb487b406692e172b15eba58de7d69358ac2005Johannes Berg	 * it is asleep -- used to synchronise PS-poll and u-APSD
11149bb487b406692e172b15eba58de7d69358ac2005Johannes Berg	 * responses while ucode keeps track of STA sleep state.
11159bb487b406692e172b15eba58de7d69358ac2005Johannes Berg	 */
11169bb487b406692e172b15eba58de7d69358ac2005Johannes Berg	__le16 sleep_tx_count;
11179bb487b406692e172b15eba58de7d69358ac2005Johannes Berg
11189bb487b406692e172b15eba58de7d69358ac2005Johannes Berg	__le16 reserved2;
1119b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
1120b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1121133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler/* 5000 */
1122133636deffc86809f59a0c8b768408d13237a9a2Tomas Winklerstruct iwl_addsta_cmd {
1123133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	u8 mode;		/* 1: modify existing, 0: add new station */
1124133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	u8 reserved[3];
1125133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	struct sta_id_modify sta;
1126133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	struct iwl_keyinfo key;
1127133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	__le32 station_flags;		/* STA_FLG_* */
1128133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	__le32 station_flags_msk;	/* STA_FLG_* */
1129133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler
1130133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	/* bit field to disable (1) or enable (0) Tx for Traffic ID (TID)
1131133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	 * corresponding to bit (e.g. bit 5 controls TID 5).
1132133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	 * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */
1133133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	__le16 tid_disable_tx;
1134133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler
1135c587de0b8d6e194f7a1719fc6af8a81b4e8916d2Tomas Winkler	__le16	rate_n_flags;		/* 3945 only */
1136133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler
1137133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	/* TID for which to add block-ack support.
1138133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
1139133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	u8 add_immediate_ba_tid;
1140133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler
1141133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	/* TID for which to remove block-ack support.
1142133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	 * Set modify_mask bit STA_MODIFY_DELBA_TID_MSK to use this field. */
1143133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	u8 remove_immediate_ba_tid;
1144133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler
1145133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	/* Starting Sequence Number for added block-ack support.
1146133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
1147133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	__le16 add_immediate_ba_ssn;
1148133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler
11499bb487b406692e172b15eba58de7d69358ac2005Johannes Berg	/*
11509bb487b406692e172b15eba58de7d69358ac2005Johannes Berg	 * Number of packets OK to transmit to station even though
11519bb487b406692e172b15eba58de7d69358ac2005Johannes Berg	 * it is asleep -- used to synchronise PS-poll and u-APSD
11529bb487b406692e172b15eba58de7d69358ac2005Johannes Berg	 * responses while ucode keeps track of STA sleep state.
11539bb487b406692e172b15eba58de7d69358ac2005Johannes Berg	 */
11549bb487b406692e172b15eba58de7d69358ac2005Johannes Berg	__le16 sleep_tx_count;
11559bb487b406692e172b15eba58de7d69358ac2005Johannes Berg
11569bb487b406692e172b15eba58de7d69358ac2005Johannes Berg	__le16 reserved2;
1157133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler} __attribute__ ((packed));
1158133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler
1159133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler
11602054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill#define ADD_STA_SUCCESS_MSK		0x1
11612054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill#define ADD_STA_NO_ROOM_IN_TABLE	0x2
11622054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill#define ADD_STA_NO_BLOCK_ACK_RESOURCE	0x4
11632054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill#define ADD_STA_MODIFY_NON_EXIST_STA	0x8
1164b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
1165b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_ADD_STA = 0x18 (response)
1166b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
11677a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winklerstruct iwl_add_sta_resp {
11682054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	u8 status;	/* ADD_STA_* */
1169b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
1170b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
11717a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler#define REM_STA_SUCCESS_MSK              0x1
11727a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler/*
11737a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler *  REPLY_REM_STA = 0x19 (response)
11747a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler */
11757a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winklerstruct iwl_rem_sta_resp {
11767a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler	u8 status;
11777a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler} __attribute__ ((packed));
11787a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler
11797a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler/*
11807a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler *  REPLY_REM_STA = 0x19 (command)
11817a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler */
11827a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winklerstruct iwl_rem_sta_cmd {
11837a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler	u8 num_sta;     /* number of removed stations */
11847a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler	u8 reserved[3];
11857a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler	u8 addr[ETH_ALEN]; /* MAC addr of the first station */
11867a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler	u8 reserved2[2];
11877a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler} __attribute__ ((packed));
11887a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler
11890a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach/*
11900a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach * REPLY_WEP_KEY = 0x20
11910a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach */
11920a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbachstruct iwl_wep_key {
11930a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach	u8 key_index;
11940a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach	u8 key_offset;
11950a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach	u8 reserved1[2];
11960a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach	u8 key_size;
11970a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach	u8 reserved2[3];
11980a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach	u8 key[16];
11990a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach} __attribute__ ((packed));
12000a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach
12010a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbachstruct iwl_wep_cmd {
12020a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach	u8 num_keys;
12030a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach	u8 global_key_type;
12040a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach	u8 flags;
12050a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach	u8 reserved;
12060a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach	struct iwl_wep_key key[0];
12070a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach} __attribute__ ((packed));
12080a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach
12090a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach#define WEP_KEY_WEP_TYPE 1
12100a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach#define WEP_KEYS_MAX 4
12110a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach#define WEP_INVALID_OFFSET 0xff
12124564ce8b0e17d91d047aa875843deb2cccf3f268Emmanuel Grumbach#define WEP_KEY_LEN_64 5
12130a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach#define WEP_KEY_LEN_128 13
1214b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1215b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
1216b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (4)
1217b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Rx Responses:
1218b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
1219b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
1220b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
122151e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RX_RES_STATUS_NO_CRC32_ERROR	cpu_to_le32(1 << 0)
122251e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RX_RES_STATUS_NO_RXE_OVERFLOW	cpu_to_le32(1 << 1)
12238211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler
122451e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RX_RES_PHY_FLAGS_BAND_24_MSK	cpu_to_le16(1 << 0)
122551e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RX_RES_PHY_FLAGS_MOD_CCK_MSK		cpu_to_le16(1 << 1)
122651e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK	cpu_to_le16(1 << 2)
122751e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RX_RES_PHY_FLAGS_NARROW_BAND_MSK	cpu_to_le16(1 << 3)
12289024adf5c81c94f7b5c6fd26942b075e2a26e085Reinette Chatre#define RX_RES_PHY_FLAGS_ANTENNA_MSK		0xf0
12299f30e04e041cf9943940f71fd76094dd5a237018Daniel C Halperin#define RX_RES_PHY_FLAGS_ANTENNA_POS		4
12308211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler
12318211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler#define RX_RES_STATUS_SEC_TYPE_MSK	(0x7 << 8)
12328211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler#define RX_RES_STATUS_SEC_TYPE_NONE	(0x0 << 8)
12338211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler#define RX_RES_STATUS_SEC_TYPE_WEP	(0x1 << 8)
12348211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler#define RX_RES_STATUS_SEC_TYPE_CCMP	(0x2 << 8)
12358211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler#define RX_RES_STATUS_SEC_TYPE_TKIP	(0x3 << 8)
123617e476b8db13790c03e2c46d93abc71468fca47eEmmanuel Grumbach#define	RX_RES_STATUS_SEC_TYPE_ERR	(0x7 << 8)
123717e476b8db13790c03e2c46d93abc71468fca47eEmmanuel Grumbach
123817e476b8db13790c03e2c46d93abc71468fca47eEmmanuel Grumbach#define RX_RES_STATUS_STATION_FOUND	(1<<6)
123917e476b8db13790c03e2c46d93abc71468fca47eEmmanuel Grumbach#define RX_RES_STATUS_NO_STATION_INFO_MISMATCH	(1<<7)
12408211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler
12418211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler#define RX_RES_STATUS_DECRYPT_TYPE_MSK	(0x3 << 11)
12428211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler#define RX_RES_STATUS_NOT_DECRYPT	(0x0 << 11)
12438211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler#define RX_RES_STATUS_DECRYPT_OK	(0x3 << 11)
12448211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler#define RX_RES_STATUS_BAD_ICV_MIC	(0x1 << 11)
12458211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler#define RX_RES_STATUS_BAD_KEY_TTAK	(0x2 << 11)
1246b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
124717e476b8db13790c03e2c46d93abc71468fca47eEmmanuel Grumbach#define RX_MPDU_RES_STATUS_ICV_OK	(0x20)
124817e476b8db13790c03e2c46d93abc71468fca47eEmmanuel Grumbach#define RX_MPDU_RES_STATUS_MIC_OK	(0x40)
124917e476b8db13790c03e2c46d93abc71468fca47eEmmanuel Grumbach#define RX_MPDU_RES_STATUS_TTAK_OK	(1 << 7)
125017e476b8db13790c03e2c46d93abc71468fca47eEmmanuel Grumbach#define RX_MPDU_RES_STATUS_DEC_DONE_MSK	(0x800)
125117e476b8db13790c03e2c46d93abc71468fca47eEmmanuel Grumbach
12523d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
12533d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_rx_frame_stats {
12543d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 phy_count;
12553d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 id;
12563d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 rssi;
12573d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 agc;
12583d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 sig_avg;
12593d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 noise_diff;
12603d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 payload[0];
12613d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler} __attribute__ ((packed));
12623d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
12633d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_rx_frame_hdr {
12643d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 channel;
12653d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 phy_flags;
12663d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 reserved1;
12673d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 rate;
12683d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 len;
12693d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 payload[0];
12703d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler} __attribute__ ((packed));
12713d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
12723d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_rx_frame_end {
12733d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 status;
12743d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le64 timestamp;
12753d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 beacon_timestamp;
12763d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler} __attribute__ ((packed));
12773d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
12783d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler/*
12793d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * REPLY_3945_RX = 0x1b (response only, not a command)
12803d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler *
12813d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * NOTE:  DO NOT dereference from casts to this structure
12823d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * It is provided only for calculating minimum data set size.
12833d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * The actual offsets of the hdr and end are dynamic based on
12843d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * stats.phy_count
12853d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler */
12863d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_rx_frame {
12873d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct iwl3945_rx_frame_stats stats;
12883d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct iwl3945_rx_frame_hdr hdr;
12893d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct iwl3945_rx_frame_end end;
12903d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler} __attribute__ ((packed));
12913d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
12923d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define IWL39_RX_FRAME_SIZE	(4 + sizeof(struct iwl3945_rx_frame))
12933d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
1294b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* Fixed (non-configurable) rx data from phy */
1295caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler
1296caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL49_RX_RES_PHY_CNT 14
1297caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL49_RX_PHY_FLAGS_ANTENNAE_OFFSET	(4)
1298caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL49_RX_PHY_FLAGS_ANTENNAE_MASK	(0x70)
1299caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL49_AGC_DB_MASK			(0x3f80)	/* MASK(7,13) */
1300caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL49_AGC_DB_POS			(7)
1301b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl4965_rx_non_cfg_phy {
1302b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 ant_selection;	/* ant A bit 4, ant B bit 5, ant C bit 6 */
1303b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 agc_info;	/* agc code 0:6, agc dB 7:13, reserved 14:15 */
1304b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 rssi_info[6];	/* we use even entries, 0/2/4 for A/B/C rssi */
1305b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 pad[0];
1306b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
1307b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1308caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler
1309caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL50_RX_RES_PHY_CNT 8
1310caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL50_RX_RES_AGC_IDX     1
1311caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL50_RX_RES_RSSI_AB_IDX 2
1312caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL50_RX_RES_RSSI_C_IDX  3
1313caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL50_OFDM_AGC_MSK 0xfe00
1314caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL50_OFDM_AGC_BIT_POS 9
1315caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL50_OFDM_RSSI_A_MSK 0x00ff
1316caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL50_OFDM_RSSI_A_BIT_POS 0
1317caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL50_OFDM_RSSI_B_MSK 0xff0000
1318caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL50_OFDM_RSSI_B_BIT_POS 16
1319caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL50_OFDM_RSSI_C_MSK 0x00ff
1320caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL50_OFDM_RSSI_C_BIT_POS 0
1321caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler
1322caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winklerstruct iwl5000_non_cfg_phy {
1323a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler	__le32 non_cfg_phy[IWL50_RX_RES_PHY_CNT];  /* up to 8 phy entries */
1324caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler} __attribute__ ((packed));
1325caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler
1326caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler
1327b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
1328857485c0c46ceee5c658c1761bba4d9a5ddf433fTomas Winkler * REPLY_RX = 0xc3 (response only, not a command)
1329b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Used only for legacy (non 11n) frames.
1330b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
1331caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winklerstruct iwl_rx_phy_res {
1332b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 non_cfg_phy_cnt;     /* non configurable DSP phy data byte count */
1333b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 cfg_phy_cnt;		/* configurable DSP phy data byte count */
1334b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 stat_id;		/* configurable DSP phy data set ID */
1335b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved1;
1336b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le64 timestamp;	/* TSF at on air rise */
1337b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_time_stamp; /* beacon at on-air rise */
1338b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 phy_flags;	/* general phy flags: band, modulation, ... */
1339b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 channel;		/* channel number */
1340caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler	u8 non_cfg_phy_buf[32]; /* for various implementations of non_cfg_phy */
1341529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	__le32 rate_n_flags;	/* RATE_MCS_* */
1342529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	__le16 byte_count;	/* frame's byte-count */
1343b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved3;
1344b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
1345b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1346b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl4965_rx_mpdu_res_start {
1347b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 byte_count;
1348b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved;
1349b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
1350b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1351b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1352b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
1353b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (5)
1354b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Tx Commands & Responses:
1355b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
1356529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Driver must place each REPLY_TX command into one of the prioritized Tx
1357529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * queues in host DRAM, shared between driver and device (see comments for
1358529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * SCD registers and Tx/Rx Queues).  When the device's Tx scheduler and uCode
1359529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * are preparing to transmit, the device pulls the Tx command over the PCI
1360529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * bus via one of the device's Tx DMA channels, to fill an internal FIFO
1361529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * from which data will be transmitted.
1362529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *
1363529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * uCode handles all timing and protocol related to control frames
1364529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * (RTS/CTS/ACK), based on flags in the Tx command.  uCode and Tx scheduler
1365529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * handle reception of block-acks; uCode updates the host driver via
1366529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * REPLY_COMPRESSED_BA (4965).
1367529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *
1368529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * uCode handles retrying Tx when an ACK is expected but not received.
1369529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * This includes trying lower data rates than the one requested in the Tx
1370529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * command, as set up by the REPLY_RATE_SCALE (for 3945) or
1371529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * REPLY_TX_LINK_QUALITY_CMD (4965).
1372529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *
1373529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Driver sets up transmit power for various rates via REPLY_TX_PWR_TABLE_CMD.
1374529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * This command must be executed after every RXON command, before Tx can occur.
1375b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
1376b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1377529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* REPLY_TX Tx flags field */
1378529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1379a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler/* 1: Use RTS/CTS protocol or CTS-to-self if spec allows it
1380a326a5d096f031af46c0073dd78eb80dea1f311aEmmanuel Grumbach * before this frame. if CTS-to-self required check
1381a326a5d096f031af46c0073dd78eb80dea1f311aEmmanuel Grumbach * RXON_FLG_SELF_CTS_EN status. */
138251e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_RTS_CTS_MSK cpu_to_le32(1 << 0)
1383a326a5d096f031af46c0073dd78eb80dea1f311aEmmanuel Grumbach
1384529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* 1: Use Request-To-Send protocol before this frame.
1385529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Mutually exclusive vs. TX_CMD_FLG_CTS_MSK. */
138651e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_RTS_MSK cpu_to_le32(1 << 1)
1387529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1388529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* 1: Transmit Clear-To-Send to self before this frame.
1389529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Driver should set this for AUTH/DEAUTH/ASSOC-REQ/REASSOC mgmnt frames.
1390529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Mutually exclusive vs. TX_CMD_FLG_RTS_MSK. */
139151e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_CTS_MSK cpu_to_le32(1 << 2)
1392529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1393529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* 1: Expect ACK from receiving station
1394529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * 0: Don't expect ACK (MAC header's duration field s/b 0)
1395529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Set this for unicast frames, but not broadcast/multicast. */
139651e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_ACK_MSK cpu_to_le32(1 << 3)
1397529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1398529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* For 4965:
1399529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * 1: Use rate scale table (see REPLY_TX_LINK_QUALITY_CMD).
1400529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *    Tx command's initial_rate_index indicates first rate to try;
1401529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *    uCode walks through table for additional Tx attempts.
1402529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * 0: Use Tx rate/MCS from Tx command's rate_n_flags field.
1403529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *    This rate will be used for all Tx attempts; it will not be scaled. */
140451e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_STA_RATE_MSK cpu_to_le32(1 << 4)
1405529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1406529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* 1: Expect immediate block-ack.
1407529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Set when Txing a block-ack request frame.  Also set TX_CMD_FLG_ACK_MSK. */
140851e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_IMM_BA_RSP_MASK  cpu_to_le32(1 << 6)
1409529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1410529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* 1: Frame requires full Tx-Op protection.
1411529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Set this if either RTS or CTS Tx Flag gets set. */
141251e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_FULL_TXOP_PROT_MSK cpu_to_le32(1 << 7)
1413529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1414529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* Tx antenna selection field; used only for 3945, reserved (0) for 4965.
1415529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Set field to "0" to allow 3945 uCode to select antenna (normal usage). */
141651e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_ANT_SEL_MSK cpu_to_le32(0xf00)
141751e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_ANT_A_MSK cpu_to_le32(1 << 8)
141851e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_ANT_B_MSK cpu_to_le32(1 << 9)
1419b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1420529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* 1: Ignore Bluetooth priority for this frame.
1421529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * 0: Delay Tx until Bluetooth device is done (normal usage). */
142251e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_BT_DIS_MSK cpu_to_le32(1 << 12)
1423b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1424529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* 1: uCode overrides sequence control field in MAC header.
1425529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * 0: Driver provides sequence control field in MAC header.
1426529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Set this for management frames, non-QOS data frames, non-unicast frames,
1427529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * and also in Tx command embedded in REPLY_SCAN_CMD for active scans. */
142851e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_SEQ_CTL_MSK cpu_to_le32(1 << 13)
1429b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1430529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* 1: This frame is non-last MPDU; more fragments are coming.
1431529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * 0: Last fragment, or not using fragmentation. */
143251e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_MORE_FRAG_MSK cpu_to_le32(1 << 14)
1433b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1434529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* 1: uCode calculates and inserts Timestamp Function (TSF) in outgoing frame.
1435529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * 0: No TSF required in outgoing frame.
1436529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Set this for transmitting beacons and probe responses. */
143751e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_TSF_MSK cpu_to_le32(1 << 16)
1438b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1439529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* 1: Driver inserted 2 bytes pad after the MAC header, for (required) dword
1440529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *    alignment of frame's payload data field.
1441529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * 0: No pad
1442529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Set this for MAC headers with 26 or 30 bytes, i.e. those with QOS or ADDR4
1443529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * field (but not both).  Driver must align frame data (i.e. data following
1444529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * MAC header) to DWORD boundary. */
144551e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_MH_PAD_MSK cpu_to_le32(1 << 20)
1446b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
14478236e183fc53be2b5d81a4f547f9c5b645e10fe0Max Stepanov/* accelerate aggregation support
14488236e183fc53be2b5d81a4f547f9c5b645e10fe0Max Stepanov * 0 - no CCMP encryption; 1 - CCMP encryption */
144951e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_AGG_CCMP_MSK cpu_to_le32(1 << 22)
14508236e183fc53be2b5d81a4f547f9c5b645e10fe0Max Stepanov
1451b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* HCCA-AP - disable duration overwriting. */
145251e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_DUR_MSK cpu_to_le32(1 << 25)
1453b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1454529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1455b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
1456b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * TX command security control
1457b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
1458b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define TX_CMD_SEC_WEP  	0x01
1459b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define TX_CMD_SEC_CCM  	0x02
1460b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define TX_CMD_SEC_TKIP		0x03
1461b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define TX_CMD_SEC_MSK		0x03
1462b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define TX_CMD_SEC_SHIFT	6
1463b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define TX_CMD_SEC_KEY128	0x08
1464b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1465b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
14663195cdb7424b4207f6903f1f3ddadcab49fa22f2Tomas Winkler * security overhead sizes
14673195cdb7424b4207f6903f1f3ddadcab49fa22f2Tomas Winkler */
14683195cdb7424b4207f6903f1f3ddadcab49fa22f2Tomas Winkler#define WEP_IV_LEN 4
14693195cdb7424b4207f6903f1f3ddadcab49fa22f2Tomas Winkler#define WEP_ICV_LEN 4
14703195cdb7424b4207f6903f1f3ddadcab49fa22f2Tomas Winkler#define CCMP_MIC_LEN 8
14713195cdb7424b4207f6903f1f3ddadcab49fa22f2Tomas Winkler#define TKIP_ICV_LEN 4
14723195cdb7424b4207f6903f1f3ddadcab49fa22f2Tomas Winkler
14733195cdb7424b4207f6903f1f3ddadcab49fa22f2Tomas Winkler/*
14743d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * REPLY_TX = 0x1c (command)
14753d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler */
14763d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
14773d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_tx_cmd {
14783d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	/*
14793d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * MPDU byte count:
14803d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * MAC header (24/26/30/32 bytes) + 2 bytes pad if 26/30 header size,
14813d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * + 8 byte IV for CCM or TKIP (not used for WEP)
14823d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * + Data payload
14833d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * + 8-byte MIC (not used for CCM/WEP)
14843d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * NOTE:  Does not include Tx command bytes, post-MAC pad bytes,
14853d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 *        MIC (CCM) 8 bytes, ICV (WEP/TKIP/CKIP) 4 bytes, CRC 4 bytes.i
14863d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * Range: 14-2342 bytes.
14873d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 */
14883d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 len;
14893d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
14903d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	/*
14913d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * MPDU or MSDU byte count for next frame.
14923d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * Used for fragmentation and bursting, but not 11n aggregation.
14933d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * Same as "len", but for next frame.  Set to 0 if not applicable.
14943d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 */
14953d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 next_frame_len;
14963d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
14973d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 tx_flags;	/* TX_CMD_FLG_* */
14983d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
14993d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 rate;
15003d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
15013d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	/* Index of recipient station in uCode's station table */
15023d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 sta_id;
15033d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 tid_tspec;
15043d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 sec_ctl;
15053d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 key[16];
15063d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	union {
15073d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler		u8 byte[8];
15083d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler		__le16 word[4];
15093d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler		__le32 dw[2];
15103d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	} tkip_mic;
15113d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 next_frame_info;
15123d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	union {
15133d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler		__le32 life_time;
15143d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler		__le32 attempt;
15153d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	} stop_time;
15163d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 supp_rates[2];
15173d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 rts_retry_limit;	/*byte 50 */
15183d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 data_retry_limit;	/*byte 51 */
15193d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	union {
15203d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler		__le16 pm_frame_timeout;
15213d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler		__le16 attempt_duration;
15223d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	} timeout;
15233d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
15243d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	/*
15253d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * Duration of EDCA burst Tx Opportunity, in 32-usec units.
15263d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * Set this if txop time is not specified by HCCA protocol (e.g. by AP).
15273d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 */
15283d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 driver_txop;
15293d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
15303d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	/*
15313d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * MAC header goes here, followed by 2 bytes padding if MAC header
15323d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * length is 26 or 30 bytes, followed by payload data
15333d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 */
15343d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 payload[0];
15353d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct ieee80211_hdr hdr[0];
15363d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler} __attribute__ ((packed));
15373d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
15383d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler/*
15393d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * REPLY_TX = 0x1c (response)
15403d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler */
15413d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_tx_resp {
15423d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 failure_rts;
15433d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 failure_frame;
15443d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 bt_kill_count;
15453d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 rate;
15463d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 wireless_media_time;
15473d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 status;		/* TX status */
15483d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler} __attribute__ ((packed));
15493d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
15503d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
15513d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler/*
1552529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * 4965 uCode updates these Tx attempt count values in host DRAM.
1553529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Used for managing Tx retries when expecting block-acks.
1554529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Driver should set these fields to 0.
1555b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
15562aa6ab86bc475a115f56645591d2413981846509Tomas Winklerstruct iwl_dram_scratch {
1557529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	u8 try_cnt;		/* Tx attempts */
1558529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	u8 bt_kill_cnt;		/* Tx attempts blocked by Bluetooth device */
1559b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved;
1560b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
1561b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
156283d527d9e8f9aff92cbd33f208f77c055dabb499Tomas Winklerstruct iwl_tx_cmd {
1563529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	/*
1564529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * MPDU byte count:
1565529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * MAC header (24/26/30/32 bytes) + 2 bytes pad if 26/30 header size,
1566529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * + 8 byte IV for CCM or TKIP (not used for WEP)
1567529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * + Data payload
1568529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * + 8-byte MIC (not used for CCM/WEP)
1569529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * NOTE:  Does not include Tx command bytes, post-MAC pad bytes,
1570529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 *        MIC (CCM) 8 bytes, ICV (WEP/TKIP/CKIP) 4 bytes, CRC 4 bytes.i
1571529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * Range: 14-2342 bytes.
1572529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 */
1573b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 len;
1574529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1575529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	/*
1576529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * MPDU or MSDU byte count for next frame.
1577529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * Used for fragmentation and bursting, but not 11n aggregation.
1578529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * Same as "len", but for next frame.  Set to 0 if not applicable.
1579529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 */
1580b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 next_frame_len;
1581529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1582529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	__le32 tx_flags;	/* TX_CMD_FLG_* */
1583529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
15842aa6ab86bc475a115f56645591d2413981846509Tomas Winkler	/* uCode may modify this field of the Tx command (in host DRAM!).
1585529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * Driver must also set dram_lsb_ptr and dram_msb_ptr in this cmd. */
15862aa6ab86bc475a115f56645591d2413981846509Tomas Winkler	struct iwl_dram_scratch scratch;
1587529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1588529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	/* Rate for *all* Tx attempts, if TX_CMD_FLG_STA_RATE_MSK is cleared. */
1589529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	__le32 rate_n_flags;	/* RATE_MCS_* */
1590529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1591529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	/* Index of destination station in uCode's station table */
1592b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 sta_id;
1593529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1594529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	/* Type of security encryption:  CCM or TKIP */
1595529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	u8 sec_ctl;		/* TX_CMD_SEC_* */
1596529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1597529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	/*
1598529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * Index into rate table (see REPLY_TX_LINK_QUALITY_CMD) for initial
1599529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * Tx attempt, if TX_CMD_FLG_STA_RATE_MSK is set.  Normally "0" for
1600529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * data frames, this field may be used to selectively reduce initial
1601529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * rate (via non-0 value) for special frames (e.g. management), while
1602529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * still supporting rate scaling for all frames.
1603529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 */
1604b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 initial_rate_index;
1605b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved;
1606b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 key[16];
1607b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 next_frame_flags;
1608b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved2;
1609b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	union {
1610b481de9ca074528fe8c429604e2777db8b89806aZhu Yi		__le32 life_time;
1611b481de9ca074528fe8c429604e2777db8b89806aZhu Yi		__le32 attempt;
1612b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	} stop_time;
1613529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1614529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	/* Host DRAM physical address pointer to "scratch" in this command.
1615529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * Must be dword aligned.  "0" in dram_lsb_ptr disables usage. */
1616b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 dram_lsb_ptr;
1617b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 dram_msb_ptr;
1618529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1619b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 rts_retry_limit;	/*byte 50 */
1620b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 data_retry_limit;	/*byte 51 */
1621b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 tid_tspec;
1622b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	union {
1623b481de9ca074528fe8c429604e2777db8b89806aZhu Yi		__le16 pm_frame_timeout;
1624b481de9ca074528fe8c429604e2777db8b89806aZhu Yi		__le16 attempt_duration;
1625b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	} timeout;
1626529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1627529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	/*
1628529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * Duration of EDCA burst Tx Opportunity, in 32-usec units.
1629529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * Set this if txop time is not specified by HCCA protocol (e.g. by AP).
1630529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 */
1631b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 driver_txop;
1632529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1633529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	/*
1634529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * MAC header goes here, followed by 2 bytes padding if MAC header
1635529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * length is 26 or 30 bytes, followed by payload data
1636529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 */
1637b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 payload[0];
1638b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct ieee80211_hdr hdr[0];
1639b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
1640b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1641b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* TX command response is sent after *all* transmission attempts.
1642b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
1643b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * NOTES:
1644b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
1645b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * TX_STATUS_FAIL_NEXT_FRAG
1646b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
1647b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * If the fragment flag in the MAC header for the frame being transmitted
1648b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * is set and there is insufficient time to transmit the next frame, the
1649b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * TX status will be returned with 'TX_STATUS_FAIL_NEXT_FRAG'.
1650b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
1651b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * TX_STATUS_FIFO_UNDERRUN
1652b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
1653b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Indicates the host did not provide bytes to the FIFO fast enough while
1654b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * a TX was in progress.
1655b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
1656b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * TX_STATUS_FAIL_MGMNT_ABORT
1657b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
1658b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * This status is only possible if the ABORT ON MGMT RX parameter was
1659b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * set to true with the TX command.
1660b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
1661b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * If the MSB of the status parameter is set then an abort sequence is
1662b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * required.  This sequence consists of the host activating the TX Abort
1663b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * control line, and then waiting for the TX Abort command response.  This
1664b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * indicates that a the device is no longer in a transmit state, and that the
1665b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * command FIFO has been cleared.  The host must then deactivate the TX Abort
1666b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * control line.  Receiving is still allowed in this case.
1667b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
1668b481de9ca074528fe8c429604e2777db8b89806aZhu Yienum {
1669b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_SUCCESS = 0x01,
1670b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_DIRECT_DONE = 0x02,
1671b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_SHORT_LIMIT = 0x82,
1672b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_LONG_LIMIT = 0x83,
1673b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_FIFO_UNDERRUN = 0x84,
1674b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_MGMNT_ABORT = 0x85,
1675b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_NEXT_FRAG = 0x86,
1676b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_LIFE_EXPIRE = 0x87,
1677b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_DEST_PS = 0x88,
1678b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_ABORTED = 0x89,
1679b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_BT_RETRY = 0x8a,
1680b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_STA_INVALID = 0x8b,
1681b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_FRAG_DROPPED = 0x8c,
1682b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_TID_DISABLE = 0x8d,
1683b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_FRAME_FLUSHED = 0x8e,
1684b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_INSUFFICIENT_CF_POLL = 0x8f,
1685b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_TX_LOCKED = 0x90,
1686b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_NO_BEACON_ON_RADAR = 0x91,
1687b481de9ca074528fe8c429604e2777db8b89806aZhu Yi};
1688b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1689b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	TX_PACKET_MODE_REGULAR		0x0000
1690b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	TX_PACKET_MODE_BURST_SEQ	0x0100
1691b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	TX_PACKET_MODE_BURST_FIRST	0x0200
1692b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1693b481de9ca074528fe8c429604e2777db8b89806aZhu Yienum {
1694b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_POWER_PA_NOT_ACTIVE = 0x0,
1695b481de9ca074528fe8c429604e2777db8b89806aZhu Yi};
1696b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1697b481de9ca074528fe8c429604e2777db8b89806aZhu Yienum {
16983fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	TX_STATUS_MSK = 0x000000ff,		/* bits 0:7 */
1699b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_DELAY_MSK = 0x00000040,
1700b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_ABORT_MSK = 0x00000080,
1701b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_PACKET_MODE_MSK = 0x0000ff00,	/* bits 8:15 */
1702b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_FIFO_NUMBER_MSK = 0x00070000,	/* bits 16:18 */
17033fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	TX_RESERVED = 0x00780000,		/* bits 19:22 */
1704b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_POWER_PA_DETECT_MSK = 0x7f800000,	/* bits 23:30 */
1705b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_ABORT_REQUIRED_MSK = 0x80000000,	/* bits 31:31 */
1706b481de9ca074528fe8c429604e2777db8b89806aZhu Yi};
1707b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1708c397bf15a6067ecf39f8a771907f4721a64fd61fJohannes Bergstatic inline u32 iwl_tx_status_to_mac80211(u32 status)
1709c397bf15a6067ecf39f8a771907f4721a64fd61fJohannes Berg{
1710c397bf15a6067ecf39f8a771907f4721a64fd61fJohannes Berg	status &= TX_STATUS_MSK;
1711c397bf15a6067ecf39f8a771907f4721a64fd61fJohannes Berg
1712c397bf15a6067ecf39f8a771907f4721a64fd61fJohannes Berg	switch (status) {
1713c397bf15a6067ecf39f8a771907f4721a64fd61fJohannes Berg	case TX_STATUS_SUCCESS:
1714c397bf15a6067ecf39f8a771907f4721a64fd61fJohannes Berg	case TX_STATUS_DIRECT_DONE:
1715c397bf15a6067ecf39f8a771907f4721a64fd61fJohannes Berg		return IEEE80211_TX_STAT_ACK;
1716c397bf15a6067ecf39f8a771907f4721a64fd61fJohannes Berg	case TX_STATUS_FAIL_DEST_PS:
1717c397bf15a6067ecf39f8a771907f4721a64fd61fJohannes Berg		return IEEE80211_TX_STAT_TX_FILTERED;
1718c397bf15a6067ecf39f8a771907f4721a64fd61fJohannes Berg	default:
1719c397bf15a6067ecf39f8a771907f4721a64fd61fJohannes Berg		return 0;
1720c397bf15a6067ecf39f8a771907f4721a64fd61fJohannes Berg	}
1721c397bf15a6067ecf39f8a771907f4721a64fd61fJohannes Berg}
1722c397bf15a6067ecf39f8a771907f4721a64fd61fJohannes Berg
17233fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winklerstatic inline bool iwl_is_tx_success(u32 status)
1724a332f8d618a7bdb0096c7b21555120a1822cedecTomas Winkler{
1725a332f8d618a7bdb0096c7b21555120a1822cedecTomas Winkler	status &= TX_STATUS_MSK;
17263fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	return (status == TX_STATUS_SUCCESS) ||
17273fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	       (status == TX_STATUS_DIRECT_DONE);
1728a332f8d618a7bdb0096c7b21555120a1822cedecTomas Winkler}
1729a332f8d618a7bdb0096c7b21555120a1822cedecTomas Winkler
1730a332f8d618a7bdb0096c7b21555120a1822cedecTomas Winkler
1731a332f8d618a7bdb0096c7b21555120a1822cedecTomas Winkler
1732b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* *******************************
1733529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * TX aggregation status
1734b481de9ca074528fe8c429604e2777db8b89806aZhu Yi ******************************* */
1735b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1736b481de9ca074528fe8c429604e2777db8b89806aZhu Yienum {
1737b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	AGG_TX_STATE_TRANSMITTED = 0x00,
1738b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	AGG_TX_STATE_UNDERRUN_MSK = 0x01,
1739b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	AGG_TX_STATE_BT_PRIO_MSK = 0x02,
1740b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	AGG_TX_STATE_FEW_BYTES_MSK = 0x04,
1741b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	AGG_TX_STATE_ABORT_MSK = 0x08,
1742b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	AGG_TX_STATE_LAST_SENT_TTL_MSK = 0x10,
1743b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK = 0x20,
1744b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	AGG_TX_STATE_LAST_SENT_BT_KILL_MSK = 0x40,
1745b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	AGG_TX_STATE_SCD_QUERY_MSK = 0x80,
1746b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	AGG_TX_STATE_TEST_BAD_CRC32_MSK = 0x100,
1747b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	AGG_TX_STATE_RESPONSE_MSK = 0x1ff,
1748b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	AGG_TX_STATE_DUMP_TX_MSK = 0x200,
1749b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	AGG_TX_STATE_DELAY_TX_MSK = 0x400
1750b481de9ca074528fe8c429604e2777db8b89806aZhu Yi};
1751b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
17523fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler#define AGG_TX_STATE_LAST_SENT_MSK  (AGG_TX_STATE_LAST_SENT_TTL_MSK | \
17533fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler				     AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK | \
17543fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler				     AGG_TX_STATE_LAST_SENT_BT_KILL_MSK)
1755b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1756529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* # tx attempts for first frame in aggregation */
1757b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define AGG_TX_STATE_TRY_CNT_POS 12
1758b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define AGG_TX_STATE_TRY_CNT_MSK 0xf000
1759b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1760529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* Command ID and sequence number of Tx command for this frame */
1761b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define AGG_TX_STATE_SEQ_NUM_POS 16
1762b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define AGG_TX_STATE_SEQ_NUM_MSK 0xffff0000
1763b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1764b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
1765b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_TX = 0x1c (response)
1766529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *
1767529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * This response may be in one of two slightly different formats, indicated
1768529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * by the frame_count field:
1769529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *
1770529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * 1)  No aggregation (frame_count == 1).  This reports Tx results for
1771529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *     a single frame.  Multiple attempts, at various bit rates, may have
1772529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *     been made for this frame.
1773529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *
1774529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * 2)  Aggregation (frame_count > 1).  This reports Tx results for
1775529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *     2 or more frames that used block-acknowledge.  All frames were
1776529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *     transmitted at same rate.  Rate scaling may have been used if first
1777529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *     frame in this new agg block failed in previous agg block(s).
1778529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *
1779529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *     Note that, for aggregation, ACK (block-ack) status is not delivered here;
1780529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *     block-ack has not been received by the time the 4965 records this status.
1781529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *     This status relates to reasons the tx might have been blocked or aborted
1782529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *     within the sending station (this 4965), rather than whether it was
1783529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *     received successfully by the destination station.
1784b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
1785001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunskystruct agg_tx_status {
1786001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	__le16 status;
1787001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	__le16 sequence;
1788001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky} __attribute__ ((packed));
1789001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky
1790bb8c093bdea62f2ae371b98ebff81b0407852fafChristoph Hellwigstruct iwl4965_tx_resp {
1791b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 frame_count;		/* 1 no aggregation, >1 aggregation */
1792529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	u8 bt_kill_count;	/* # blocked by bluetooth (unused for agg) */
1793529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	u8 failure_rts;		/* # failures due to unsuccessful RTS */
1794529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	u8 failure_frame;	/* # failures due to no ACK (unused for agg) */
1795529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1796529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	/* For non-agg:  Rate at which frame was successful.
1797529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * For agg:  Rate at which all frames were transmitted. */
1798529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	__le32 rate_n_flags;	/* RATE_MCS_*  */
1799529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1800529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	/* For non-agg:  RTS + CTS + frame tx attempts time + ACK.
1801529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * For agg:  RTS + CTS + aggregation tx time + block-ack time. */
1802529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	__le16 wireless_media_time;	/* uSecs */
1803529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1804b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved;
1805529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	__le32 pa_power1;	/* RF power amplifier measurement (not used) */
1806b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 pa_power2;
1807529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1808529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	/*
1809529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * For non-agg:  frame status TX_STATUS_*
1810529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * For agg:  status of 1st frame, AGG_TX_STATE_*; other frame status
1811529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 *           fields follow this one, up to frame_count.
1812529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 *           Bit fields:
1813529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 *           11- 0:  AGG_TX_STATE_* status code
1814529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 *           15-12:  Retry count for 1st frame in aggregation (retries
1815529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 *                   occur if tx failed for this frame when it was a
1816529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 *                   member of a previous aggregation block).  If rate
1817529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 *                   scaling is used, retry count indicates the rate
1818529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 *                   table entry used for all frames in the new agg.
1819529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 *           31-16:  Sequence # for this frame's Tx cmd (not SSN!)
1820529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 */
182125a6572cc13ba2a3fefc02a63a077ff3664a1ca9Tomas Winkler	union {
182225a6572cc13ba2a3fefc02a63a077ff3664a1ca9Tomas Winkler		__le32 status;
182325a6572cc13ba2a3fefc02a63a077ff3664a1ca9Tomas Winkler		struct agg_tx_status agg_status[0]; /* for each agg frame */
182425a6572cc13ba2a3fefc02a63a077ff3664a1ca9Tomas Winkler	} u;
1825fe01b477bbd23e69c3bdc6bce5be510ddad8297dRon Rindjunsky} __attribute__ ((packed));
1826fe01b477bbd23e69c3bdc6bce5be510ddad8297dRon Rindjunsky
18273fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler/*
18283fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler * definitions for initial rate index field
1829a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler * bits [3:0] initial rate index
18303fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler * bits [6:4] rate table color, used for the initial rate
18313fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler * bit-7 invalid rate indication
18323fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler *   i.e. rate was not chosen from rate table
18333fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler *   or rate table color was changed during frame retries
18343fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler * refer tlc rate info
18353fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler */
18363fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler
18373fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler#define IWL50_TX_RES_INIT_RATE_INDEX_POS	0
18383fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler#define IWL50_TX_RES_INIT_RATE_INDEX_MSK	0x0f
18393fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler#define IWL50_TX_RES_RATE_TABLE_COLOR_POS	4
18403fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler#define IWL50_TX_RES_RATE_TABLE_COLOR_MSK	0x70
18413fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler#define IWL50_TX_RES_INV_RATE_INDEX_MSK	0x80
18423fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler
18433fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler/* refer to ra_tid */
18443fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler#define IWL50_TX_RES_TID_POS	0
18453fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler#define IWL50_TX_RES_TID_MSK	0x0f
18463fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler#define IWL50_TX_RES_RA_POS	4
18473fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler#define IWL50_TX_RES_RA_MSK	0xf0
18483fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler
1849001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunskystruct iwl5000_tx_resp {
1850001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	u8 frame_count;		/* 1 no aggregation, >1 aggregation */
1851001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	u8 bt_kill_count;	/* # blocked by bluetooth (unused for agg) */
1852001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	u8 failure_rts;		/* # failures due to unsuccessful RTS */
1853001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	u8 failure_frame;	/* # failures due to no ACK (unused for agg) */
1854001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky
1855001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	/* For non-agg:  Rate at which frame was successful.
1856001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 * For agg:  Rate at which all frames were transmitted. */
1857001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	__le32 rate_n_flags;	/* RATE_MCS_*  */
1858001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky
1859001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	/* For non-agg:  RTS + CTS + frame tx attempts time + ACK.
1860001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 * For agg:  RTS + CTS + aggregation tx time + block-ack time. */
1861001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	__le16 wireless_media_time;	/* uSecs */
1862001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky
18633fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	u8 pa_status;		/* RF power amplifier measurement (not used) */
18643fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	u8 pa_integ_res_a[3];
18653fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	u8 pa_integ_res_b[3];
18663fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	u8 pa_integ_res_C[3];
1867001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky
1868001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	__le32 tfd_info;
1869001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	__le16 seq_ctl;
1870001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	__le16 byte_cnt;
18713fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	u8 tlc_info;
18723fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	u8 ra_tid;		/* tid (0:3), sta_id (4:7) */
18733fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	__le16 frame_ctrl;
1874001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	/*
1875001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 * For non-agg:  frame status TX_STATUS_*
1876001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 * For agg:  status of 1st frame, AGG_TX_STATE_*; other frame status
1877001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 *           fields follow this one, up to frame_count.
1878001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 *           Bit fields:
1879001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 *           11- 0:  AGG_TX_STATE_* status code
1880001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 *           15-12:  Retry count for 1st frame in aggregation (retries
1881001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 *                   occur if tx failed for this frame when it was a
1882001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 *                   member of a previous aggregation block).  If rate
1883001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 *                   scaling is used, retry count indicates the rate
1884001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 *                   table entry used for all frames in the new agg.
1885001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 *           31-16:  Sequence # for this frame's Tx cmd (not SSN!)
1886001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 */
1887001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	struct agg_tx_status status;	/* TX status (in aggregation -
1888001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky					 * status of 1st frame) */
1889001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky} __attribute__ ((packed));
1890b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
1891b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_COMPRESSED_BA = 0xc5 (response only, not a command)
1892529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *
1893529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Reports Block-Acknowledge from recipient station
1894b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
1895653fa4a07525e4cd9e7b90e6fc1f792119910636Emmanuel Grumbachstruct iwl_compressed_ba_resp {
1896b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 sta_addr_lo32;
1897b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 sta_addr_hi16;
1898b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved;
1899529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1900529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	/* Index of recipient (BA-sending) station in uCode's station table */
1901b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 sta_id;
1902b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 tid;
1903fe01b477bbd23e69c3bdc6bce5be510ddad8297dRon Rindjunsky	__le16 seq_ctl;
1904fe01b477bbd23e69c3bdc6bce5be510ddad8297dRon Rindjunsky	__le64 bitmap;
1905b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 scd_flow;
1906b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 scd_ssn;
1907b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
1908b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1909b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
1910b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_TX_PWR_TABLE_CMD = 0x97 (command, has simple generic response)
19112bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
19122bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * See details under "TXPOWER" in iwl-4965-hw.h.
1913b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
19143d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
19153d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_txpowertable_cmd {
19163d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 band;		/* 0: 5 GHz, 1: 2.4 GHz */
19173d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 reserved;
19183d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 channel;
19193d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct iwl3945_power_per_rate power[IWL_MAX_RATES];
19203d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler} __attribute__ ((packed));
19213d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
1922bb8c093bdea62f2ae371b98ebff81b0407852fafChristoph Hellwigstruct iwl4965_txpowertable_cmd {
1923b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 band;		/* 0: 5 GHz, 1: 2.4 GHz */
1924b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved;
1925b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 channel;
1926bb8c093bdea62f2ae371b98ebff81b0407852fafChristoph Hellwig	struct iwl4965_tx_power_db tx_power;
1927b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
1928b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
19293d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
19303d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler/**
19313d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * struct iwl3945_rate_scaling_cmd - Rate Scaling Command & Response
19323d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler *
19333d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * REPLY_RATE_SCALE = 0x47 (command, has simple generic response)
19343d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler *
19353d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * NOTE: The table of rates passed to the uCode via the
19363d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * RATE_SCALE command sets up the corresponding order of
19373d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * rates used for all related commands, including rate
19383d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * masks, etc.
19393d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler *
19403d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * For example, if you set 9MB (PLCP 0x0f) as the first
19413d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * rate in the rate table, the bit mask for that rate
19423d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * when passed through ofdm_basic_rates on the REPLY_RXON
19433d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * command would be bit 0 (1 << 0)
19443d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler */
19453d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_rate_scaling_info {
19463d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 rate_n_flags;
19473d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 try_cnt;
19483d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 next_rate_index;
19493d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler} __attribute__ ((packed));
19503d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
19513d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_rate_scaling_cmd {
19523d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 table_id;
19533d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 reserved[3];
19543d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct iwl3945_rate_scaling_info table[IWL_MAX_RATES];
19553d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler} __attribute__ ((packed));
19563d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
19573d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
1958b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*RS_NEW_API: only TLC_RTS remains and moved to bit 0 */
19598a1b02452862dd30980ad0ef493eed687bc81474Reinette Chatre#define  LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK	(1 << 0)
1960b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
19612bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill/* # of EDCA prioritized tx fifos */
1962b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define  LINK_QUAL_AC_NUM AC_NUM
19632bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
19642bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill/* # entries in rate scale table to support Tx retries */
1965b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define  LINK_QUAL_MAX_RETRY_NUM 16
1966b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
19672bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill/* Tx antenna selection values */
19688a1b02452862dd30980ad0ef493eed687bc81474Reinette Chatre#define  LINK_QUAL_ANT_A_MSK (1 << 0)
19698a1b02452862dd30980ad0ef493eed687bc81474Reinette Chatre#define  LINK_QUAL_ANT_B_MSK (1 << 1)
1970b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define  LINK_QUAL_ANT_MSK   (LINK_QUAL_ANT_A_MSK|LINK_QUAL_ANT_B_MSK)
1971b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
19722bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
19732bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill/**
197466c73db7c6f7672e40c0bb1d2689f2d0d0922aadTomas Winkler * struct iwl_link_qual_general_params
19752bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
19762bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * Used in REPLY_TX_LINK_QUALITY_CMD
19772bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill */
197866c73db7c6f7672e40c0bb1d2689f2d0d0922aadTomas Winklerstruct iwl_link_qual_general_params {
1979b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 flags;
19802bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
19812bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	/* No entries at or above this (driver chosen) index contain MIMO */
1982b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 mimo_delimiter;
19832bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
19842bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	/* Best single antenna to use for single stream (legacy, SISO). */
19852bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	u8 single_stream_ant_msk;	/* LINK_QUAL_ANT_* */
19862bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
19872bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	/* Best antennas to use for MIMO (unused for 4965, assumes both). */
19882bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	u8 dual_stream_ant_msk;		/* LINK_QUAL_ANT_* */
19892bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
19902bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	/*
19912bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * If driver needs to use different initial rates for different
19922bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * EDCA QOS access categories (as implemented by tx fifos 0-3),
19932bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * this table will set that up, by indicating the indexes in the
19942bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * rs_table[LINK_QUAL_MAX_RETRY_NUM] rate table at which to start.
19952bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * Otherwise, driver should set all entries to 0.
19962bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 *
19972bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * Entry usage:
19982bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * 0 = Background, 1 = Best Effort (normal), 2 = Video, 3 = Voice
19992bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * TX FIFOs above 3 use same value (typically 0) as TX FIFO 3.
20002bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 */
2001b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 start_rate_index[LINK_QUAL_AC_NUM];
2002b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2003b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
200413c33a09b3703c2956345482017600434c853889Wey-Yi Guy#define LINK_QUAL_AGG_TIME_LIMIT_DEF	(4000) /* 4 milliseconds */
200513c33a09b3703c2956345482017600434c853889Wey-Yi Guy#define LINK_QUAL_AGG_TIME_LIMIT_MAX	(65535)
200613c33a09b3703c2956345482017600434c853889Wey-Yi Guy#define LINK_QUAL_AGG_TIME_LIMIT_MIN	(0)
200713c33a09b3703c2956345482017600434c853889Wey-Yi Guy
200813c33a09b3703c2956345482017600434c853889Wey-Yi Guy#define LINK_QUAL_AGG_DISABLE_START_DEF	(3)
200913c33a09b3703c2956345482017600434c853889Wey-Yi Guy#define LINK_QUAL_AGG_DISABLE_START_MAX	(255)
201013c33a09b3703c2956345482017600434c853889Wey-Yi Guy#define LINK_QUAL_AGG_DISABLE_START_MIN	(0)
201113c33a09b3703c2956345482017600434c853889Wey-Yi Guy
201213c33a09b3703c2956345482017600434c853889Wey-Yi Guy#define LINK_QUAL_AGG_FRAME_LIMIT_DEF	(31)
2013b623a9f7c488e51dbe4320d8b5cdd0ba242d0067Johannes Berg#define LINK_QUAL_AGG_FRAME_LIMIT_MAX	(63)
201413c33a09b3703c2956345482017600434c853889Wey-Yi Guy#define LINK_QUAL_AGG_FRAME_LIMIT_MIN	(0)
201513c33a09b3703c2956345482017600434c853889Wey-Yi Guy
20162bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill/**
201766c73db7c6f7672e40c0bb1d2689f2d0d0922aadTomas Winkler * struct iwl_link_qual_agg_params
20182bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
20192bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * Used in REPLY_TX_LINK_QUALITY_CMD
20202bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill */
202166c73db7c6f7672e40c0bb1d2689f2d0d0922aadTomas Winklerstruct iwl_link_qual_agg_params {
20222bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
20232bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	/* Maximum number of uSec in aggregation.
20242bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * Driver should set this to 4000 (4 milliseconds). */
2025b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 agg_time_limit;
20262bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
20272bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	/*
20282bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * Number of Tx retries allowed for a frame, before that frame will
20292bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * no longer be considered for the start of an aggregation sequence
20302bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * (scheduler will then try to tx it as single frame).
20312bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * Driver should set this to 3.
20322bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 */
2033b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 agg_dis_start_th;
20342bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
20352bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	/*
20362bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * Maximum number of frames in aggregation.
20372bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * 0 = no limit (default).  1 = no aggregation.
20382bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * Other values = max # frames in aggregation.
20392bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 */
2040b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 agg_frame_cnt_limit;
20412bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
2042b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 reserved;
2043b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2044b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2045b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2046b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_TX_LINK_QUALITY_CMD = 0x4e (command, has simple generic response)
20472bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
20482bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * For 4965 only; 3945 uses REPLY_RATE_SCALE.
20492bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
20502bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * Each station in the 4965's internal station table has its own table of 16
20512bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * Tx rates and modulation modes (e.g. legacy/SISO/MIMO) for retrying Tx when
20522bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * an ACK is not received.  This command replaces the entire table for
20532bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * one station.
20542bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
20552bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * NOTE:  Station must already be in 4965's station table.  Use REPLY_ADD_STA.
20562bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
20572bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * The rate scaling procedures described below work well.  Of course, other
20582bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * procedures are possible, and may work better for particular environments.
20592bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
20602bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
20612bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * FILLING THE RATE TABLE
20622bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
20632bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * Given a particular initial rate and mode, as determined by the rate
20642bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * scaling algorithm described below, the Linux driver uses the following
20652bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * formula to fill the rs_table[LINK_QUAL_MAX_RETRY_NUM] rate table in the
20662bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * Link Quality command:
20672bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
20682bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
20692bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * 1)  If using High-throughput (HT) (SISO or MIMO) initial rate:
20702bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     a) Use this same initial rate for first 3 entries.
20712bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     b) Find next lower available rate using same mode (SISO or MIMO),
20722bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *        use for next 3 entries.  If no lower rate available, switch to
20737aafef1c6e2e24f9a10dc2972bf0ee70624ccc47Wey-Yi Guy *        legacy mode (no HT40 channel, no MIMO, no short guard interval).
20742bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     c) If using MIMO, set command's mimo_delimiter to number of entries
20752bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *        using MIMO (3 or 6).
20767aafef1c6e2e24f9a10dc2972bf0ee70624ccc47Wey-Yi Guy *     d) After trying 2 HT rates, switch to legacy mode (no HT40 channel,
20772bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *        no MIMO, no short guard interval), at the next lower bit rate
20782bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *        (e.g. if second HT bit rate was 54, try 48 legacy), and follow
20792bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *        legacy procedure for remaining table entries.
20802bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
20812bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * 2)  If using legacy initial rate:
20822bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     a) Use the initial rate for only one entry.
20832bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     b) For each following entry, reduce the rate to next lower available
20842bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *        rate, until reaching the lowest available rate.
20852bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     c) When reducing rate, also switch antenna selection.
20862bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     d) Once lowest available rate is reached, repeat this rate until
20872bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *        rate table is filled (16 entries), switching antenna each entry.
20882bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
20892bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
20902bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * ACCUMULATING HISTORY
20912bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
20922bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * The rate scaling algorithm for 4965, as implemented in Linux driver, uses
20932bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * two sets of frame Tx success history:  One for the current/active modulation
20942bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * mode, and one for a speculative/search mode that is being attempted.  If the
20952bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * speculative mode turns out to be more effective (i.e. actual transfer
20962bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * rate is better), then the driver continues to use the speculative mode
20972bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * as the new current active mode.
20982bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
20992bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * Each history set contains, separately for each possible rate, data for a
21002bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * sliding window of the 62 most recent tx attempts at that rate.  The data
21012bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * includes a shifting bitmap of success(1)/failure(0), and sums of successful
21022bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * and attempted frames, from which the driver can additionally calculate a
21032bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * success ratio (success / attempted) and number of failures
21042bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * (attempted - success), and control the size of the window (attempted).
21052bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * The driver uses the bit map to remove successes from the success sum, as
21062bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * the oldest tx attempts fall out of the window.
21072bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21082bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * When the 4965 makes multiple tx attempts for a given frame, each attempt
21092bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * might be at a different rate, and have different modulation characteristics
21102bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * (e.g. antenna, fat channel, short guard interval), as set up in the rate
21112bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * scaling table in the Link Quality command.  The driver must determine
21122bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * which rate table entry was used for each tx attempt, to determine which
21132bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * rate-specific history to update, and record only those attempts that
21142bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * match the modulation characteristics of the history set.
21152bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21162bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * When using block-ack (aggregation), all frames are transmitted at the same
2117a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler * rate, since there is no per-attempt acknowledgment from the destination
21182bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * station.  The Tx response struct iwl_tx_resp indicates the Tx rate in
21192bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * rate_n_flags field.  After receiving a block-ack, the driver can update
21202bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * history for the entire block all at once.
21212bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21222bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21232bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * FINDING BEST STARTING RATE:
21242bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21252bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * When working with a selected initial modulation mode (see below), the
21262bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * driver attempts to find a best initial rate.  The initial rate is the
21272bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * first entry in the Link Quality command's rate table.
21282bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21292bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * 1)  Calculate actual throughput (success ratio * expected throughput, see
21302bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     table below) for current initial rate.  Do this only if enough frames
21312bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     have been attempted to make the value meaningful:  at least 6 failed
21322bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     tx attempts, or at least 8 successes.  If not enough, don't try rate
21332bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     scaling yet.
21342bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21352bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * 2)  Find available rates adjacent to current initial rate.  Available means:
21362bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     a)  supported by hardware &&
21372bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     b)  supported by association &&
21382bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     c)  within any constraints selected by user
21392bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21402bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * 3)  Gather measured throughputs for adjacent rates.  These might not have
21412bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     enough history to calculate a throughput.  That's okay, we might try
21422bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     using one of them anyway!
21432bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21442bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * 4)  Try decreasing rate if, for current rate:
21452bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     a)  success ratio is < 15% ||
21462bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     b)  lower adjacent rate has better measured throughput ||
21472bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     c)  higher adjacent rate has worse throughput, and lower is unmeasured
21482bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21492bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     As a sanity check, if decrease was determined above, leave rate
21502bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     unchanged if:
21512bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     a)  lower rate unavailable
21522bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     b)  success ratio at current rate > 85% (very good)
21532bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     c)  current measured throughput is better than expected throughput
21542bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *         of lower rate (under perfect 100% tx conditions, see table below)
21552bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21562bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * 5)  Try increasing rate if, for current rate:
21572bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     a)  success ratio is < 15% ||
21582bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     b)  both adjacent rates' throughputs are unmeasured (try it!) ||
21592bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     b)  higher adjacent rate has better measured throughput ||
21602bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     c)  lower adjacent rate has worse throughput, and higher is unmeasured
21612bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21622bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     As a sanity check, if increase was determined above, leave rate
21632bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     unchanged if:
21642bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     a)  success ratio at current rate < 70%.  This is not particularly
21652bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *         good performance; higher rate is sure to have poorer success.
21662bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21672bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * 6)  Re-evaluate the rate after each tx frame.  If working with block-
21682bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     acknowledge, history and statistics may be calculated for the entire
21692bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     block (including prior history that fits within the history windows),
21702bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     before re-evaluation.
21712bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21722bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * FINDING BEST STARTING MODULATION MODE:
21732bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21742bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * After working with a modulation mode for a "while" (and doing rate scaling),
21752bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * the driver searches for a new initial mode in an attempt to improve
21762bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * throughput.  The "while" is measured by numbers of attempted frames:
21772bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21782bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * For legacy mode, search for new mode after:
21792bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *   480 successful frames, or 160 failed frames
21802bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * For high-throughput modes (SISO or MIMO), search for new mode after:
21812bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *   4500 successful frames, or 400 failed frames
21822bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21832bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * Mode switch possibilities are (3 for each mode):
21842bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21852bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * For legacy:
21862bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *   Change antenna, try SISO (if HT association), try MIMO (if HT association)
21872bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * For SISO:
21882bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *   Change antenna, try MIMO, try shortened guard interval (SGI)
21892bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * For MIMO:
21902bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *   Try SISO antenna A, SISO antenna B, try shortened guard interval (SGI)
21912bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21922bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * When trying a new mode, use the same bit rate as the old/current mode when
21932bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * trying antenna switches and shortened guard interval.  When switching to
21942bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * SISO from MIMO or legacy, or to MIMO from SISO or legacy, use a rate
21952bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * for which the expected throughput (under perfect conditions) is about the
21962bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * same or slightly better than the actual measured throughput delivered by
21972bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * the old/current mode.
21982bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21992bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * Actual throughput can be estimated by multiplying the expected throughput
22002bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * by the success ratio (successful / attempted tx frames).  Frame size is
22012bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * not considered in this calculation; it assumes that frame size will average
22022bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * out to be fairly consistent over several samples.  The following are
22032bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * metric values for expected throughput assuming 100% success ratio.
22042bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * Only G band has support for CCK rates:
22052bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
22062bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *           RATE:  1    2    5   11    6   9   12   18   24   36   48   54   60
22072bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
22082bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *              G:  7   13   35   58   40  57   72   98  121  154  177  186  186
22092bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *              A:  0    0    0    0   40  57   72   98  121  154  177  186  186
22102bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     SISO 20MHz:  0    0    0    0   42  42   76  102  124  159  183  193  202
22112bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * SGI SISO 20MHz:  0    0    0    0   46  46   82  110  132  168  192  202  211
22122bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     MIMO 20MHz:  0    0    0    0   74  74  123  155  179  214  236  244  251
22132bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * SGI MIMO 20MHz:  0    0    0    0   81  81  131  164  188  222  243  251  257
22142bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     SISO 40MHz:  0    0    0    0   77  77  127  160  184  220  242  250  257
22152bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * SGI SISO 40MHz:  0    0    0    0   83  83  135  169  193  229  250  257  264
22162bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     MIMO 40MHz:  0    0    0    0  123 123  182  214  235  264  279  285  289
22172bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * SGI MIMO 40MHz:  0    0    0    0  131 131  191  222  242  270  284  289  293
22182bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
22192bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * After the new mode has been tried for a short while (minimum of 6 failed
22202bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * frames or 8 successful frames), compare success ratio and actual throughput
22212bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * estimate of the new mode with the old.  If either is better with the new
22222bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * mode, continue to use the new mode.
22232bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
22242bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * Continue comparing modes until all 3 possibilities have been tried.
22252bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * If moving from legacy to HT, try all 3 possibilities from the new HT
22262bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * mode.  After trying all 3, a best mode is found.  Continue to use this mode
22272bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * for the longer "while" described above (e.g. 480 successful frames for
22282bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * legacy), and then repeat the search process.
22292bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
2230b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
223166c73db7c6f7672e40c0bb1d2689f2d0d0922aadTomas Winklerstruct iwl_link_quality_cmd {
22322bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
22332bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	/* Index of destination/recipient station in uCode's station table */
2234b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 sta_id;
2235b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved1;
22362bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	__le16 control;		/* not used */
223766c73db7c6f7672e40c0bb1d2689f2d0d0922aadTomas Winkler	struct iwl_link_qual_general_params general_params;
223866c73db7c6f7672e40c0bb1d2689f2d0d0922aadTomas Winkler	struct iwl_link_qual_agg_params agg_params;
22392bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
22402bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	/*
22412bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * Rate info; when using rate-scaling, Tx command's initial_rate_index
22422bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * specifies 1st Tx rate attempted, via index into this table.
22432bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * 4965 works its way through table when retrying Tx.
22442bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 */
2245b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct {
22462bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill		__le32 rate_n_flags;	/* RATE_MCS_*, IWL_RATE_* */
2247b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	} rs_table[LINK_QUAL_MAX_RETRY_NUM];
2248b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 reserved2;
2249b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2250b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2251456d0f76727ba6f97aa1cee63f1bae84642768c4Wey-Yi Guy#define BT_COEX_DISABLE (0x0)
2252456d0f76727ba6f97aa1cee63f1bae84642768c4Wey-Yi Guy#define BT_COEX_MODE_2W (0x1)
2253456d0f76727ba6f97aa1cee63f1bae84642768c4Wey-Yi Guy#define BT_COEX_MODE_3W (0x2)
2254456d0f76727ba6f97aa1cee63f1bae84642768c4Wey-Yi Guy#define BT_COEX_MODE_4W (0x3)
2255456d0f76727ba6f97aa1cee63f1bae84642768c4Wey-Yi Guy
2256456d0f76727ba6f97aa1cee63f1bae84642768c4Wey-Yi Guy#define BT_LEAD_TIME_MIN (0x0)
2257456d0f76727ba6f97aa1cee63f1bae84642768c4Wey-Yi Guy#define BT_LEAD_TIME_DEF (0x1E)
2258456d0f76727ba6f97aa1cee63f1bae84642768c4Wey-Yi Guy#define BT_LEAD_TIME_MAX (0xFF)
2259456d0f76727ba6f97aa1cee63f1bae84642768c4Wey-Yi Guy
2260456d0f76727ba6f97aa1cee63f1bae84642768c4Wey-Yi Guy#define BT_MAX_KILL_MIN (0x1)
2261456d0f76727ba6f97aa1cee63f1bae84642768c4Wey-Yi Guy#define BT_MAX_KILL_DEF (0x5)
2262456d0f76727ba6f97aa1cee63f1bae84642768c4Wey-Yi Guy#define BT_MAX_KILL_MAX (0xFF)
2263456d0f76727ba6f97aa1cee63f1bae84642768c4Wey-Yi Guy
2264b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2265b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_BT_CONFIG = 0x9b (command, has simple generic response)
22663058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *
22673058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 3945 and 4965 support hardware handshake with Bluetooth device on
22683058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * same platform.  Bluetooth device alerts wireless device when it will Tx;
2269a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler * wireless device can delay or kill its own Tx to accommodate.
2270b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
22712aa6ab86bc475a115f56645591d2413981846509Tomas Winklerstruct iwl_bt_cmd {
2272b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 flags;
2273b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 lead_time;
2274b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 max_kill;
2275b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved;
2276b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 kill_ack_mask;
2277b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 kill_cts_mask;
2278b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2279b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2280b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
2281b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (6)
2282b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Spectrum Management (802.11h) Commands, Responses, Notifications:
2283b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
2284b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
2285b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2286b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2287b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Spectrum Management
2288b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
2289b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define MEASUREMENT_FILTER_FLAG (RXON_FILTER_PROMISC_MSK         | \
2290b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 RXON_FILTER_CTL2HOST_MSK        | \
2291b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 RXON_FILTER_ACCEPT_GRP_MSK      | \
2292b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 RXON_FILTER_DIS_DECRYPT_MSK     | \
2293b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 RXON_FILTER_DIS_GRP_DECRYPT_MSK | \
2294b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 RXON_FILTER_ASSOC_MSK           | \
2295b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 RXON_FILTER_BCON_AWARE_MSK)
2296b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
22972aa6ab86bc475a115f56645591d2413981846509Tomas Winklerstruct iwl_measure_channel {
2298b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 duration;	/* measurement duration in extended beacon
2299b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 * format */
2300b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 channel;		/* channel to measure */
23012aa6ab86bc475a115f56645591d2413981846509Tomas Winkler	u8 type;		/* see enum iwl_measure_type */
2302b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved;
2303b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2304b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2305b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2306b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74 (command)
2307b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
23082aa6ab86bc475a115f56645591d2413981846509Tomas Winklerstruct iwl_spectrum_cmd {
2309b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 len;		/* number of bytes starting from token */
2310b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 token;		/* token id */
2311b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 id;			/* measurement id -- 0 or 1 */
2312b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 origin;		/* 0 = TGh, 1 = other, 2 = TGk */
2313b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 periodic;		/* 1 = periodic */
2314b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 path_loss_timeout;
2315b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 start_time;	/* start time in extended beacon format */
2316b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 reserved2;
2317b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 flags;		/* rxon flags */
2318b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 filter_flags;	/* rxon filter flags */
2319b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 channel_count;	/* minimum 1, maximum 10 */
2320b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved3;
23212aa6ab86bc475a115f56645591d2413981846509Tomas Winkler	struct iwl_measure_channel channels[10];
2322b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2323b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2324b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2325b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74 (response)
2326b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
23272aa6ab86bc475a115f56645591d2413981846509Tomas Winklerstruct iwl_spectrum_resp {
2328b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 token;
2329b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 id;			/* id of the prior command replaced, or 0xff */
2330b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 status;		/* 0 - command will be handled
2331b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 * 1 - cannot handle (conflicts with another
2332b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 *     measurement) */
2333b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2334b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
23352aa6ab86bc475a115f56645591d2413981846509Tomas Winklerenum iwl_measurement_state {
2336b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASUREMENT_START = 0,
2337b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASUREMENT_STOP = 1,
2338b481de9ca074528fe8c429604e2777db8b89806aZhu Yi};
2339b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
23402aa6ab86bc475a115f56645591d2413981846509Tomas Winklerenum iwl_measurement_status {
2341b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASUREMENT_OK = 0,
2342b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASUREMENT_CONCURRENT = 1,
2343b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASUREMENT_CSA_CONFLICT = 2,
2344b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASUREMENT_TGH_CONFLICT = 3,
2345b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* 4-5 reserved */
2346b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASUREMENT_STOPPED = 6,
2347b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASUREMENT_TIMEOUT = 7,
2348b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASUREMENT_PERIODIC_FAILED = 8,
2349b481de9ca074528fe8c429604e2777db8b89806aZhu Yi};
2350b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2351b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define NUM_ELEMENTS_IN_HISTOGRAM 8
2352b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
23532aa6ab86bc475a115f56645591d2413981846509Tomas Winklerstruct iwl_measurement_histogram {
2354b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 ofdm[NUM_ELEMENTS_IN_HISTOGRAM];	/* in 0.8usec counts */
2355b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 cck[NUM_ELEMENTS_IN_HISTOGRAM];	/* in 1usec counts */
2356b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2357b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2358b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* clear channel availability counters */
23592aa6ab86bc475a115f56645591d2413981846509Tomas Winklerstruct iwl_measurement_cca_counters {
2360b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 ofdm;
2361b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 cck;
2362b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2363b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
23642aa6ab86bc475a115f56645591d2413981846509Tomas Winklerenum iwl_measure_type {
2365b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASURE_BASIC = (1 << 0),
2366b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASURE_CHANNEL_LOAD = (1 << 1),
2367b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASURE_HISTOGRAM_RPI = (1 << 2),
2368b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASURE_HISTOGRAM_NOISE = (1 << 3),
2369b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASURE_FRAME = (1 << 4),
2370b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* bits 5:6 are reserved */
2371b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASURE_IDLE = (1 << 7),
2372b481de9ca074528fe8c429604e2777db8b89806aZhu Yi};
2373b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2374b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2375b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * SPECTRUM_MEASURE_NOTIFICATION = 0x75 (notification only, not a command)
2376b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
23772aa6ab86bc475a115f56645591d2413981846509Tomas Winklerstruct iwl_spectrum_notification {
2378b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 id;			/* measurement id -- 0 or 1 */
2379b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 token;
2380b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 channel_index;	/* index in measurement channel list */
2381b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 state;		/* 0 - start, 1 - stop */
2382b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 start_time;	/* lower 32-bits of TSF */
2383b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 band;		/* 0 - 5.2GHz, 1 - 2.4GHz */
2384b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 channel;
23852aa6ab86bc475a115f56645591d2413981846509Tomas Winkler	u8 type;		/* see enum iwl_measurement_type */
2386b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved1;
2387b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* NOTE:  cca_ofdm, cca_cck, basic_type, and histogram are only only
2388b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * valid if applicable for measurement type requested. */
2389b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 cca_ofdm;	/* cca fraction time in 40Mhz clock periods */
2390b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 cca_cck;		/* cca fraction time in 44Mhz clock periods */
2391b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 cca_time;	/* channel load time in usecs */
2392b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 basic_type;		/* 0 - bss, 1 - ofdm preamble, 2 -
2393b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 * unidentified */
2394b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved2[3];
23952aa6ab86bc475a115f56645591d2413981846509Tomas Winkler	struct iwl_measurement_histogram histogram;
2396b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 stop_time;	/* lower 32-bits of TSF */
23972aa6ab86bc475a115f56645591d2413981846509Tomas Winkler	__le32 status;		/* see iwl_measurement_status */
2398b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2399b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2400b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
2401b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (7)
2402b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Power Management Commands, Responses, Notifications:
2403b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
2404b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
2405b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2406b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/**
2407ca579617d81baf5865498eb5fae58e453ee77c2cMohamed Abbas * struct iwl_powertable_cmd - Power Table Command
2408b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * @flags: See below:
2409b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
2410b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * POWER_TABLE_CMD = 0x77 (command, has simple generic response)
2411b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
2412b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * PM allow:
2413b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *   bit 0 - '0' Driver not allow power management
2414b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *           '1' Driver allow PM (use rest of parameters)
2415e312c24cf8229f9b6e76dbfd5d99eefe21f4ac0aJohannes Berg *
2416b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * uCode send sleep notifications:
2417b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *   bit 1 - '0' Don't send sleep notification
2418b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *           '1' send sleep notification (SEND_PM_NOTIFICATION)
2419e312c24cf8229f9b6e76dbfd5d99eefe21f4ac0aJohannes Berg *
2420b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Sleep over DTIM
2421b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *   bit 2 - '0' PM have to walk up every DTIM
2422b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *           '1' PM could sleep over DTIM till listen Interval.
2423e312c24cf8229f9b6e76dbfd5d99eefe21f4ac0aJohannes Berg *
2424b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * PCI power managed
2425e7b635814b640c6fd9dca1c254dc22fac6fb9a1aTomas Winkler *   bit 3 - '0' (PCI_CFG_LINK_CTRL & 0x1)
2426e7b635814b640c6fd9dca1c254dc22fac6fb9a1aTomas Winkler *           '1' !(PCI_CFG_LINK_CTRL & 0x1)
2427e312c24cf8229f9b6e76dbfd5d99eefe21f4ac0aJohannes Berg *
2428e312c24cf8229f9b6e76dbfd5d99eefe21f4ac0aJohannes Berg * Fast PD
2429e312c24cf8229f9b6e76dbfd5d99eefe21f4ac0aJohannes Berg *   bit 4 - '1' Put radio to sleep when receiving frame for others
2430e312c24cf8229f9b6e76dbfd5d99eefe21f4ac0aJohannes Berg *
2431b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Force sleep Modes
2432b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *   bit 31/30- '00' use both mac/xtal sleeps
2433b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *              '01' force Mac sleep
2434b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *              '10' force xtal sleep
2435b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *              '11' Illegal set
2436b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
2437b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * NOTE: if sleep_interval[SLEEP_INTRVL_TABLE_SIZE-1] > DTIM period then
2438a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler * ucode assume sleep over DTIM is allowed and we don't need to wake up
2439b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * for every DTIM.
2440b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
2441b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define IWL_POWER_VEC_SIZE 5
2442b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2443600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler#define IWL_POWER_DRIVER_ALLOW_SLEEP_MSK	cpu_to_le16(BIT(0))
2444600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler#define IWL_POWER_SLEEP_OVER_DTIM_MSK		cpu_to_le16(BIT(2))
2445600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler#define IWL_POWER_PCI_PM_MSK			cpu_to_le16(BIT(3))
2446600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler#define IWL_POWER_FAST_PD			cpu_to_le16(BIT(4))
2447600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler
2448600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winklerstruct iwl3945_powertable_cmd {
2449600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler	__le16 flags;
2450600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler	u8 reserved[2];
2451600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler	__le32 rx_data_timeout;
2452600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler	__le32 tx_data_timeout;
2453600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler	__le32 sleep_interval[IWL_POWER_VEC_SIZE];
2454600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler} __attribute__ ((packed));
2455b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2456ca579617d81baf5865498eb5fae58e453ee77c2cMohamed Abbasstruct iwl_powertable_cmd {
2457b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 flags;
2458600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler	u8 keep_alive_seconds;		/* 3945 reserved */
2459600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler	u8 debug_flags;			/* 3945 reserved */
2460b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 rx_data_timeout;
2461b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 tx_data_timeout;
2462b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 sleep_interval[IWL_POWER_VEC_SIZE];
2463b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 keep_alive_beacons;
2464b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2465b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2466b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2467b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * PM_SLEEP_NOTIFICATION = 0x7A (notification only, not a command)
2468b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * 3945 and 4965 identical.
2469b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
24702aa6ab86bc475a115f56645591d2413981846509Tomas Winklerstruct iwl_sleep_notification {
2471b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 pm_sleep_mode;
2472b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 pm_wakeup_src;
2473b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved;
2474b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 sleep_time;
2475b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 tsf_low;
2476b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 bcon_timer;
2477b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2478b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2479b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* Sleep states.  3945 and 4965 identical. */
2480b481de9ca074528fe8c429604e2777db8b89806aZhu Yienum {
2481b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_PM_NO_SLEEP = 0,
2482b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_PM_SLP_MAC = 1,
2483b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_PM_SLP_FULL_MAC_UNASSOCIATE = 2,
2484b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_PM_SLP_FULL_MAC_CARD_STATE = 3,
2485b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_PM_SLP_PHY = 4,
2486b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_PM_SLP_REPENT = 5,
2487b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_PM_WAKEUP_BY_TIMER = 6,
2488b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_PM_WAKEUP_BY_DRIVER = 7,
2489b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_PM_WAKEUP_BY_RFKILL = 8,
2490b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* 3 reserved */
2491b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_PM_NUM_OF_MODES = 12,
2492b481de9ca074528fe8c429604e2777db8b89806aZhu Yi};
2493b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2494b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2495b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_CARD_STATE_CMD = 0xa0 (command, has simple generic response)
2496b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
2497b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define CARD_STATE_CMD_DISABLE 0x00	/* Put card to sleep */
2498b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define CARD_STATE_CMD_ENABLE  0x01	/* Wake up card */
2499b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define CARD_STATE_CMD_HALT    0x02	/* Power down permanently */
25002aa6ab86bc475a115f56645591d2413981846509Tomas Winklerstruct iwl_card_state_cmd {
2501b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 status;		/* CARD_STATE_CMD_* request new power state */
2502b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2503b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2504b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2505b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * CARD_STATE_NOTIFICATION = 0xa1 (notification only, not a command)
2506b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
25072aa6ab86bc475a115f56645591d2413981846509Tomas Winklerstruct iwl_card_state_notif {
2508b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 flags;
2509b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2510b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2511b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define HW_CARD_DISABLED   0x01
2512b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define SW_CARD_DISABLED   0x02
2513b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define RF_CARD_DISABLED   0x04
2514b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define RXON_CARD_DISABLED 0x10
2515b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
251647f4a5871614756627d7209e0569b58faf99b0d9Emmanuel Grumbachstruct iwl_ct_kill_config {
2517b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32   reserved;
2518b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32   critical_temperature_M;
2519b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32   critical_temperature_R;
2520b481de9ca074528fe8c429604e2777db8b89806aZhu Yi}  __attribute__ ((packed));
2521b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2522672639de13c4db92ed6a47e68043a4317e219902Wey-Yi Guy/* 1000, and 6x00 */
2523672639de13c4db92ed6a47e68043a4317e219902Wey-Yi Guystruct iwl_ct_kill_throttling_config {
2524672639de13c4db92ed6a47e68043a4317e219902Wey-Yi Guy	__le32   critical_temperature_exit;
2525672639de13c4db92ed6a47e68043a4317e219902Wey-Yi Guy	__le32   reserved;
2526672639de13c4db92ed6a47e68043a4317e219902Wey-Yi Guy	__le32   critical_temperature_enter;
2527672639de13c4db92ed6a47e68043a4317e219902Wey-Yi Guy}  __attribute__ ((packed));
2528672639de13c4db92ed6a47e68043a4317e219902Wey-Yi Guy
2529b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
2530b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (8)
2531b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Scan Commands, Responses, Notifications:
2532b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
2533b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
2534b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
253551e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define SCAN_CHANNEL_TYPE_PASSIVE cpu_to_le32(0)
253651e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define SCAN_CHANNEL_TYPE_ACTIVE  cpu_to_le32(1)
2537d16dc48a2ea14af9980d0ea79d041f4b53e47b62Tomas Winkler
25383058f02137359efb412975cf94a9fa7c25413387Ben M Cahill/**
25392a421b91d6fe89e27ded7544a25449c0b050098fTomas Winkler * struct iwl_scan_channel - entry in REPLY_SCAN_CMD channel table
25403058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *
25413058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * One for each channel in the scan list.
25423058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * Each channel can independently select:
25433058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 1)  SSID for directed active scans
25443058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 2)  Txpower setting (for rate specified within Tx command)
25453058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 3)  How long to stay on-channel (behavior may be modified by quiet_time,
25463058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *     quiet_plcp_th, good_CRC_th)
25473058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *
25483058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * To avoid uCode errors, make sure the following are true (see comments
25492a421b91d6fe89e27ded7544a25449c0b050098fTomas Winkler * under struct iwl_scan_cmd about max_out_time and quiet_time):
25503058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 1)  If using passive_dwell (i.e. passive_dwell != 0):
25513058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *     active_dwell <= passive_dwell (< max_out_time if max_out_time != 0)
25523058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 2)  quiet_time <= active_dwell
25533058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 3)  If restricting off-channel time (i.e. max_out_time !=0):
25543058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *     passive_dwell < max_out_time
25553058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *     active_dwell < max_out_time
25563058f02137359efb412975cf94a9fa7c25413387Ben M Cahill */
25573d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
25583d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler/* FIXME: rename to AP1, remove tpc */
25593d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_scan_channel {
25603d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	/*
25613d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * type is defined as:
25623d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * 0:0 1 = active, 0 = passive
25633d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * 1:4 SSID direct bit map; if a bit is set, then corresponding
25643d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 *     SSID IE is transmitted in probe request.
25653d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * 5:7 reserved
25663d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 */
25673d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 type;
25683d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 channel;	/* band is selected by iwl3945_scan_cmd "flags" field */
25693d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct iwl3945_tx_power tpc;
25703d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 active_dwell;	/* in 1024-uSec TU (time units), typ 5-50 */
25713d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 passive_dwell;	/* in 1024-uSec TU (time units), typ 20-500 */
25723d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler} __attribute__ ((packed));
25733d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
25740d21044effa10044930419c6f837f75191229c3aWinkler, Tomas/* set number of direct probes u8 type */
25750d21044effa10044930419c6f837f75191229c3aWinkler, Tomas#define IWL39_SCAN_PROBE_MASK(n) ((BIT(n) | (BIT(n) - BIT(1))))
25760d21044effa10044930419c6f837f75191229c3aWinkler, Tomas
25772a421b91d6fe89e27ded7544a25449c0b050098fTomas Winklerstruct iwl_scan_channel {
25783058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	/*
25793058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 * type is defined as:
25803058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 * 0:0 1 = active, 0 = passive
2581d16dc48a2ea14af9980d0ea79d041f4b53e47b62Tomas Winkler	 * 1:20 SSID direct bit map; if a bit is set, then corresponding
25823058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 *     SSID IE is transmitted in probe request.
2583d16dc48a2ea14af9980d0ea79d041f4b53e47b62Tomas Winkler	 * 21:31 reserved
2584b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 */
2585d16dc48a2ea14af9980d0ea79d041f4b53e47b62Tomas Winkler	__le32 type;
2586d16dc48a2ea14af9980d0ea79d041f4b53e47b62Tomas Winkler	__le16 channel;	/* band is selected by iwl_scan_cmd "flags" field */
2587f53696de6722a4aac00b76e25a5321c01e88a55fTomas Winkler	u8 tx_gain;		/* gain for analog radio */
2588f53696de6722a4aac00b76e25a5321c01e88a55fTomas Winkler	u8 dsp_atten;		/* gain for DSP */
25893058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le16 active_dwell;	/* in 1024-uSec TU (time units), typ 5-50 */
25903058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le16 passive_dwell;	/* in 1024-uSec TU (time units), typ 20-500 */
2591b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2592b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
25930d21044effa10044930419c6f837f75191229c3aWinkler, Tomas/* set number of direct probes __le32 type */
25940d21044effa10044930419c6f837f75191229c3aWinkler, Tomas#define IWL_SCAN_PROBE_MASK(n) 	cpu_to_le32((BIT(n) | (BIT(n) - BIT(1))))
25950d21044effa10044930419c6f837f75191229c3aWinkler, Tomas
25963058f02137359efb412975cf94a9fa7c25413387Ben M Cahill/**
25972a421b91d6fe89e27ded7544a25449c0b050098fTomas Winkler * struct iwl_ssid_ie - directed scan network information element
25983058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *
25992a3b793d6a0ff30ad4a541230a6dba2ecb6fff1bBen M Cahill * Up to 20 of these may appear in REPLY_SCAN_CMD (Note: Only 4 are in
26002a3b793d6a0ff30ad4a541230a6dba2ecb6fff1bBen M Cahill * 3945 SCAN api), selected by "type" bit field in struct iwl_scan_channel;
26012a3b793d6a0ff30ad4a541230a6dba2ecb6fff1bBen M Cahill * each channel may select different ssids from among the 20 (4) entries.
26022a3b793d6a0ff30ad4a541230a6dba2ecb6fff1bBen M Cahill * SSID IEs get transmitted in reverse order of entry.
26033058f02137359efb412975cf94a9fa7c25413387Ben M Cahill */
26042a421b91d6fe89e27ded7544a25449c0b050098fTomas Winklerstruct iwl_ssid_ie {
2605b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 id;
2606b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 len;
2607b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ssid[32];
2608b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2609b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
26109b3bf06abad70db820c74c90118ea49358549d22Johannes Berg#define PROBE_OPTION_MAX_3945		4
26119b3bf06abad70db820c74c90118ea49358549d22Johannes Berg#define PROBE_OPTION_MAX		20
261251e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_LIFE_TIME_INFINITE	cpu_to_le32(0xFFFFFFFF)
261351e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define IWL_GOOD_CRC_TH			cpu_to_le16(1)
2614b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define IWL_MAX_SCAN_SIZE 1024
26151ecf9fc1317f8df91eb1d74360f408558d657478Johannes Berg#define IWL_MAX_PROBE_REQUEST		200
2616b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2617b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2618b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_SCAN_CMD = 0x80 (command)
26193058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *
26203058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * The hardware scan command is very powerful; the driver can set it up to
26213058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * maintain (relatively) normal network traffic while doing a scan in the
26223058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * background.  The max_out_time and suspend_time control the ratio of how
26233058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * long the device stays on an associated network channel ("service channel")
26243058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * vs. how long it's away from the service channel, i.e. tuned to other channels
26253058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * for scanning.
26263058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *
26273058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * max_out_time is the max time off-channel (in usec), and suspend_time
26283058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * is how long (in "extended beacon" format) that the scan is "suspended"
26293058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * after returning to the service channel.  That is, suspend_time is the
26303058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * time that we stay on the service channel, doing normal work, between
26313058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * scan segments.  The driver may set these parameters differently to support
26323058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * scanning when associated vs. not associated, and light vs. heavy traffic
26333058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * loads when associated.
26343058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *
26353058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * After receiving this command, the device's scan engine does the following;
26363058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *
26373058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 1)  Sends SCAN_START notification to driver
26383058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 2)  Checks to see if it has time to do scan for one channel
26393058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 3)  Sends NULL packet, with power-save (PS) bit set to 1,
26403058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *     to tell AP that we're going off-channel
26413058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 4)  Tunes to first channel in scan list, does active or passive scan
26423058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 5)  Sends SCAN_RESULT notification to driver
26433058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 6)  Checks to see if it has time to do scan on *next* channel in list
26443058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 7)  Repeats 4-6 until it no longer has time to scan the next channel
26453058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *     before max_out_time expires
26463058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 8)  Returns to service channel
26473058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 9)  Sends NULL packet with PS=0 to tell AP that we're back
26483058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 10) Stays on service channel until suspend_time expires
26493058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 11) Repeats entire process 2-10 until list is complete
26503058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 12) Sends SCAN_COMPLETE notification
26513058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *
26523058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * For fast, efficient scans, the scan command also has support for staying on
26533058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * a channel for just a short time, if doing active scanning and getting no
26543058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * responses to the transmitted probe request.  This time is controlled by
26553058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * quiet_time, and the number of received packets below which a channel is
26563058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * considered "quiet" is controlled by quiet_plcp_threshold.
26573058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *
26583058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * For active scanning on channels that have regulatory restrictions against
26593058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * blindly transmitting, the scan can listen before transmitting, to make sure
26603058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * that there is already legitimate activity on the channel.  If enough
26613058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * packets are cleanly received on the channel (controlled by good_CRC_th,
26623058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * typical value 1), the scan engine starts transmitting probe requests.
26633058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *
26643058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * Driver must use separate scan commands for 2.4 vs. 5 GHz bands.
26653058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *
26663058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * To avoid uCode errors, see timing restrictions described under
26672a421b91d6fe89e27ded7544a25449c0b050098fTomas Winkler * struct iwl_scan_channel.
2668b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
26693d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
26703d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_scan_cmd {
26713d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 len;
26723d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 reserved0;
26733d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 channel_count;	/* # channels in channel list */
26743d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 quiet_time;	/* dwell only this # millisecs on quiet channel
26753d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler				 * (only for active scan) */
26763d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 quiet_plcp_th;	/* quiet chnl is < this # pkts (typ. 1) */
26773d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 good_CRC_th;	/* passive -> active promotion threshold */
26783d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 reserved1;
26793d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 max_out_time;	/* max usec to be away from associated (service)
26803d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler				 * channel */
26813d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 suspend_time;	/* pause scan this long (in "extended beacon
26823d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler				 * format") when returning to service channel:
26833d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler				 * 3945; 31:24 # beacons, 19:0 additional usec,
26843d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler				 * 4965; 31:22 # beacons, 21:0 additional usec.
26853d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler				 */
26863d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 flags;		/* RXON_FLG_* */
26873d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 filter_flags;	/* RXON_FILTER_* */
26883d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
26893d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	/* For active scans (set to all-0s for passive scans).
26903d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * Does not include payload.  Must specify Tx rate; no rate scaling. */
26913d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct iwl3945_tx_cmd tx_cmd;
26923d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
26933d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	/* For directed active scans (set to all-0s otherwise) */
26949b3bf06abad70db820c74c90118ea49358549d22Johannes Berg	struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX_3945];
26953d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
26963d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	/*
26973d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * Probe request frame, followed by channel list.
26983d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 *
26993d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * Size of probe request frame is specified by byte count in tx_cmd.
27003d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * Channel list follows immediately after probe request frame.
27013d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * Number of channels in list is specified by channel_count.
27023d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * Each channel in list is of type:
27033d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 *
27043d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * struct iwl3945_scan_channel channels[0];
27053d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 *
27063d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * NOTE:  Only one band of channels can be scanned per pass.  You
27073d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * must not mix 2.4GHz channels and 5.2GHz channels, and you must wait
27083d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * for one scan to complete (i.e. receive SCAN_COMPLETE_NOTIFICATION)
27093d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * before requesting another scan.
27103d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 */
27113d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 data[0];
27123d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler} __attribute__ ((packed));
27133d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
27142a421b91d6fe89e27ded7544a25449c0b050098fTomas Winklerstruct iwl_scan_cmd {
2715b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 len;
2716b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved0;
27173058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	u8 channel_count;	/* # channels in channel list */
27183058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le16 quiet_time;	/* dwell only this # millisecs on quiet channel
27193058f02137359efb412975cf94a9fa7c25413387Ben M Cahill				 * (only for active scan) */
27203058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le16 quiet_plcp_th;	/* quiet chnl is < this # pkts (typ. 1) */
27213058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le16 good_CRC_th;	/* passive -> active promotion threshold */
27223058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le16 rx_chain;	/* RXON_RX_CHAIN_* */
27233058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le32 max_out_time;	/* max usec to be away from associated (service)
27243058f02137359efb412975cf94a9fa7c25413387Ben M Cahill				 * channel */
27253058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le32 suspend_time;	/* pause scan this long (in "extended beacon
27263058f02137359efb412975cf94a9fa7c25413387Ben M Cahill				 * format") when returning to service chnl:
27273058f02137359efb412975cf94a9fa7c25413387Ben M Cahill				 * 3945; 31:24 # beacons, 19:0 additional usec,
27283058f02137359efb412975cf94a9fa7c25413387Ben M Cahill				 * 4965; 31:22 # beacons, 21:0 additional usec.
27293058f02137359efb412975cf94a9fa7c25413387Ben M Cahill				 */
27303058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le32 flags;		/* RXON_FLG_* */
27313058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le32 filter_flags;	/* RXON_FILTER_* */
27323058f02137359efb412975cf94a9fa7c25413387Ben M Cahill
27333058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	/* For active scans (set to all-0s for passive scans).
27343058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 * Does not include payload.  Must specify Tx rate; no rate scaling. */
273583d527d9e8f9aff92cbd33f208f77c055dabb499Tomas Winkler	struct iwl_tx_cmd tx_cmd;
27363058f02137359efb412975cf94a9fa7c25413387Ben M Cahill
27373058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	/* For directed active scans (set to all-0s otherwise) */
27382a421b91d6fe89e27ded7544a25449c0b050098fTomas Winkler	struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX];
2739b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2740b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/*
27413058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 * Probe request frame, followed by channel list.
27423058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 *
27433058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 * Size of probe request frame is specified by byte count in tx_cmd.
27443058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 * Channel list follows immediately after probe request frame.
27453058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 * Number of channels in list is specified by channel_count.
27463058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 * Each channel in list is of type:
2747b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 *
27482aa6ab86bc475a115f56645591d2413981846509Tomas Winkler	 * struct iwl_scan_channel channels[0];
2749b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 *
2750b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * NOTE:  Only one band of channels can be scanned per pass.  You
27513058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 * must not mix 2.4GHz channels and 5.2GHz channels, and you must wait
27523058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 * for one scan to complete (i.e. receive SCAN_COMPLETE_NOTIFICATION)
27533058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 * before requesting another scan.
2754b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 */
27553058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	u8 data[0];
2756b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2757b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2758b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* Can abort will notify by complete notification with abort status. */
275951e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define CAN_ABORT_STATUS	cpu_to_le32(0x1)
2760b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* complete notification statuses */
2761b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define ABORT_STATUS            0x2
2762b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2763b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2764b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_SCAN_CMD = 0x80 (response)
2765b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
27662a421b91d6fe89e27ded7544a25449c0b050098fTomas Winklerstruct iwl_scanreq_notification {
2767b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 status;		/* 1: okay, 2: cannot fulfill request */
2768b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2769b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2770b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2771b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * SCAN_START_NOTIFICATION = 0x82 (notification only, not a command)
2772b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
27732a421b91d6fe89e27ded7544a25449c0b050098fTomas Winklerstruct iwl_scanstart_notification {
2774b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 tsf_low;
2775b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 tsf_high;
2776b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_timer;
2777b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 channel;
2778b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 band;
2779b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved[2];
2780b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 status;
2781b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2782b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2783b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define  SCAN_OWNER_STATUS 0x1;
2784b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define  MEASURE_OWNER_STATUS 0x2;
2785b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2786b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define NUMBER_OF_STATISTICS 1	/* first __le32 is good CRC */
2787b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2788b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * SCAN_RESULTS_NOTIFICATION = 0x83 (notification only, not a command)
2789b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
27902a421b91d6fe89e27ded7544a25449c0b050098fTomas Winklerstruct iwl_scanresults_notification {
2791b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 channel;
2792b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 band;
2793b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved[2];
2794b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 tsf_low;
2795b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 tsf_high;
2796b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 statistics[NUMBER_OF_STATISTICS];
2797b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2798b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2799b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2800b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * SCAN_COMPLETE_NOTIFICATION = 0x84 (notification only, not a command)
2801b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
28022a421b91d6fe89e27ded7544a25449c0b050098fTomas Winklerstruct iwl_scancomplete_notification {
2803b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 scanned_channels;
2804b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 status;
2805b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved;
2806b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 last_channel;
2807b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 tsf_low;
2808b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 tsf_high;
2809b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2810b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2811b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2812b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
2813b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (9)
2814b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * IBSS/AP Commands and Notifications:
2815b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
2816b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
2817b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2818b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2819b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * BEACON_NOTIFICATION = 0x90 (notification only, not a command)
2820b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
28213d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
28223d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_beacon_notif {
28233d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct iwl3945_tx_resp beacon_notify_hdr;
28243d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 low_tsf;
28253d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 high_tsf;
28263d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 ibss_mgr_status;
28273d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler} __attribute__ ((packed));
28283d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
2829bb8c093bdea62f2ae371b98ebff81b0407852fafChristoph Hellwigstruct iwl4965_beacon_notif {
2830bb8c093bdea62f2ae371b98ebff81b0407852fafChristoph Hellwig	struct iwl4965_tx_resp beacon_notify_hdr;
2831b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 low_tsf;
2832b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 high_tsf;
2833b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 ibss_mgr_status;
2834b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2835b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2836b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2837b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_TX_BEACON = 0x91 (command, has simple generic response)
2838b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
28393d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
28403d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_tx_beacon_cmd {
28413d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct iwl3945_tx_cmd tx;
28423d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 tim_idx;
28433d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 tim_size;
28443d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 reserved1;
28453d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct ieee80211_hdr frame[0];	/* beacon frame */
28463d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler} __attribute__ ((packed));
28473d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
28484bf64efd26f5610cde4fb7846e2f37bd1f62d3a9Tomas Winklerstruct iwl_tx_beacon_cmd {
284983d527d9e8f9aff92cbd33f208f77c055dabb499Tomas Winkler	struct iwl_tx_cmd tx;
2850b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 tim_idx;
2851b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 tim_size;
2852b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved1;
2853b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct ieee80211_hdr frame[0];	/* beacon frame */
2854b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2855b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2856b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
2857b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (10)
2858b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Statistics Commands and Notifications:
2859b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
2860b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
2861b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2862b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define IWL_TEMP_CONVERT 260
2863b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2864b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define SUP_RATE_11A_MAX_NUM_CHANNELS  8
2865b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define SUP_RATE_11B_MAX_NUM_CHANNELS  4
2866b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define SUP_RATE_11G_MAX_NUM_CHANNELS  12
2867b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2868b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* Used for passing to driver number of successes and failures per rate */
2869b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct rate_histogram {
2870b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	union {
2871b481de9ca074528fe8c429604e2777db8b89806aZhu Yi		__le32 a[SUP_RATE_11A_MAX_NUM_CHANNELS];
2872b481de9ca074528fe8c429604e2777db8b89806aZhu Yi		__le32 b[SUP_RATE_11B_MAX_NUM_CHANNELS];
2873b481de9ca074528fe8c429604e2777db8b89806aZhu Yi		__le32 g[SUP_RATE_11G_MAX_NUM_CHANNELS];
2874b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	} success;
2875b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	union {
2876b481de9ca074528fe8c429604e2777db8b89806aZhu Yi		__le32 a[SUP_RATE_11A_MAX_NUM_CHANNELS];
2877b481de9ca074528fe8c429604e2777db8b89806aZhu Yi		__le32 b[SUP_RATE_11B_MAX_NUM_CHANNELS];
2878b481de9ca074528fe8c429604e2777db8b89806aZhu Yi		__le32 g[SUP_RATE_11G_MAX_NUM_CHANNELS];
2879b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	} failed;
2880b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2881b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2882b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* statistics command response */
2883b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
28843d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl39_statistics_rx_phy {
28853d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 ina_cnt;
28863d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 fina_cnt;
28873d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 plcp_err;
28883d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 crc32_err;
28893d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 overrun_err;
28903d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 early_overrun_err;
28913d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 crc32_good;
28923d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 false_alarm_cnt;
28933d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 fina_sync_err_cnt;
28943d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 sfd_timeout;
28953d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 fina_timeout;
28963d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 unresponded_rts;
28973d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 rxe_frame_limit_overrun;
28983d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 sent_ack_cnt;
28993d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 sent_cts_cnt;
29003d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler} __attribute__ ((packed));
29013d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
29023d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl39_statistics_rx_non_phy {
29033d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 bogus_cts;	/* CTS received when not expecting CTS */
29043d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 bogus_ack;	/* ACK received when not expecting ACK */
29053d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 non_bssid_frames;	/* number of frames with BSSID that
29063d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler					 * doesn't belong to the STA BSSID */
29073d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 filtered_frames;	/* count frames that were dumped in the
29083d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler				 * filtering process */
29093d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 non_channel_beacons;	/* beacons with our bss id but not on
29103d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler					 * our serving channel */
29113d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler} __attribute__ ((packed));
29123d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
29133d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl39_statistics_rx {
29143d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct iwl39_statistics_rx_phy ofdm;
29153d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct iwl39_statistics_rx_phy cck;
29163d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct iwl39_statistics_rx_non_phy general;
29173d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler} __attribute__ ((packed));
29183d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
29193d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl39_statistics_tx {
29203d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 preamble_cnt;
29213d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 rx_detected_cnt;
29223d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 bt_prio_defer_cnt;
29233d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 bt_prio_kill_cnt;
29243d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 few_bytes_cnt;
29253d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 cts_timeout;
29263d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 ack_timeout;
29273d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 expected_ack_cnt;
29283d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 actual_ack_cnt;
29293d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler} __attribute__ ((packed));
29303d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
29313d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct statistics_dbg {
29323d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 burst_check;
29333d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 burst_count;
29343d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 reserved[4];
29353d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler} __attribute__ ((packed));
29363d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
29373d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl39_statistics_div {
29383d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 tx_on_a;
29393d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 tx_on_b;
29403d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 exec_time;
29413d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 probe_time;
29423d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler} __attribute__ ((packed));
29433d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
29443d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl39_statistics_general {
29453d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 temperature;
29463d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct statistics_dbg dbg;
29473d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 sleep_time;
29483d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 slots_out;
29493d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 slots_idle;
29503d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 ttl_timestamp;
29513d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct iwl39_statistics_div div;
29523d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler} __attribute__ ((packed));
29533d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
2954b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct statistics_rx_phy {
2955b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 ina_cnt;
2956b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 fina_cnt;
2957b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 plcp_err;
2958b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 crc32_err;
2959b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 overrun_err;
2960b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 early_overrun_err;
2961b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 crc32_good;
2962b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 false_alarm_cnt;
2963b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 fina_sync_err_cnt;
2964b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 sfd_timeout;
2965b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 fina_timeout;
2966b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 unresponded_rts;
2967b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 rxe_frame_limit_overrun;
2968b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 sent_ack_cnt;
2969b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 sent_cts_cnt;
2970b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 sent_ba_rsp_cnt;
2971b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 dsp_self_kill;
2972b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 mh_format_err;
2973b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 re_acq_main_rssi_sum;
2974b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 reserved3;
2975b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2976b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2977b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct statistics_rx_ht_phy {
2978b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 plcp_err;
2979b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 overrun_err;
2980b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 early_overrun_err;
2981b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 crc32_good;
2982b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 crc32_err;
2983b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 mh_format_err;
2984b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 agg_crc32_good;
2985b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 agg_mpdu_cnt;
2986b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 agg_cnt;
2987b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 reserved2;
2988b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
2989b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2990c1b4aa3fb619782213af2af6652663c8f9cef373Harvey Harrison#define INTERFERENCE_DATA_AVAILABLE      cpu_to_le32(1)
299134c22cf93d1446791c966c878cc691e07c39d8d3Winkler, Tomas
2992b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct statistics_rx_non_phy {
2993b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 bogus_cts;	/* CTS received when not expecting CTS */
2994b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 bogus_ack;	/* ACK received when not expecting ACK */
2995b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 non_bssid_frames;	/* number of frames with BSSID that
2996b481de9ca074528fe8c429604e2777db8b89806aZhu Yi					 * doesn't belong to the STA BSSID */
2997b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 filtered_frames;	/* count frames that were dumped in the
2998b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 * filtering process */
2999b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 non_channel_beacons;	/* beacons with our bss id but not on
3000b481de9ca074528fe8c429604e2777db8b89806aZhu Yi					 * our serving channel */
3001b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 channel_beacons;	/* beacons with our bss id and in our
3002b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 * serving channel */
3003b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 num_missed_bcon;	/* number of missed beacons */
3004b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 adc_rx_saturation_time;	/* count in 0.8us units the time the
3005b481de9ca074528fe8c429604e2777db8b89806aZhu Yi					 * ADC was in saturation */
3006b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 ina_detection_search_time;/* total time (in 0.8us) searched
3007b481de9ca074528fe8c429604e2777db8b89806aZhu Yi					  * for INA */
3008b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_silence_rssi_a;	/* RSSI silence after beacon frame */
3009b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_silence_rssi_b;	/* RSSI silence after beacon frame */
3010b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_silence_rssi_c;	/* RSSI silence after beacon frame */
3011b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 interference_data_flag;	/* flag for interference data
3012b481de9ca074528fe8c429604e2777db8b89806aZhu Yi					 * availability. 1 when data is
3013b481de9ca074528fe8c429604e2777db8b89806aZhu Yi					 * available. */
30143058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le32 channel_load;		/* counts RX Enable time in uSec */
3015b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 dsp_false_alarms;	/* DSP false alarm (both OFDM
3016b481de9ca074528fe8c429604e2777db8b89806aZhu Yi					 * and CCK) counter */
3017b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_rssi_a;
3018b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_rssi_b;
3019b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_rssi_c;
3020b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_energy_a;
3021b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_energy_b;
3022b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_energy_c;
3023b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
3024b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3025b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct statistics_rx {
3026b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct statistics_rx_phy ofdm;
3027b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct statistics_rx_phy cck;
3028b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct statistics_rx_non_phy general;
3029b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct statistics_rx_ht_phy ofdm_ht;
3030b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
3031b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3032fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy/**
3033fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy * struct statistics_tx_power - current tx power
3034fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy *
3035fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy * @ant_a: current tx power on chain a in 1/2 dB step
3036fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy * @ant_b: current tx power on chain b in 1/2 dB step
3037fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy * @ant_c: current tx power on chain c in 1/2 dB step
3038fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy */
3039fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guystruct statistics_tx_power {
3040fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy	u8 ant_a;
3041fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy	u8 ant_b;
3042fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy	u8 ant_c;
3043fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy	u8 reserved;
3044fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy} __attribute__ ((packed));
3045fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy
3046b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct statistics_tx_non_phy_agg {
3047b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 ba_timeout;
3048b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 ba_reschedule_frames;
3049b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 scd_query_agg_frame_cnt;
3050b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 scd_query_no_agg;
3051b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 scd_query_agg;
3052b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 scd_query_mismatch;
3053b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 frame_not_ready;
3054b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 underrun;
3055b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 bt_prio_kill;
3056b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 rx_ba_rsp_cnt;
3057b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
3058b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3059b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct statistics_tx {
3060b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 preamble_cnt;
3061b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 rx_detected_cnt;
3062b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 bt_prio_defer_cnt;
3063b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 bt_prio_kill_cnt;
3064b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 few_bytes_cnt;
3065b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 cts_timeout;
3066b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 ack_timeout;
3067b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 expected_ack_cnt;
3068b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 actual_ack_cnt;
3069b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 dump_msdu_cnt;
3070b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 burst_abort_next_frame_mismatch_cnt;
3071b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 burst_abort_missing_next_frame_cnt;
3072b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 cts_timeout_collision;
3073b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 ack_or_ba_timeout_collision;
3074b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct statistics_tx_non_phy_agg agg;
3075fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy	struct statistics_tx_power tx_power;
3076fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy	__le32 reserved1;
3077b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
3078b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3079b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3080b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct statistics_div {
3081b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 tx_on_a;
3082b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 tx_on_b;
3083b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 exec_time;
3084b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 probe_time;
3085b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 reserved1;
3086b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 reserved2;
3087b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
3088b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3089b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct statistics_general {
3090b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 temperature;
3091b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 temperature_m;
3092b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct statistics_dbg dbg;
3093b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 sleep_time;
3094b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 slots_out;
3095b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 slots_idle;
3096b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 ttl_timestamp;
3097b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct statistics_div div;
3098b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 rx_enable_counter;
3099b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 reserved1;
3100b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 reserved2;
3101b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 reserved3;
3102b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
3103b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3104ef8d5529b015d4c5db7fad1adfc91edfd5abad56Wey-Yi Guy#define UCODE_STATISTICS_CLEAR_MSK		(0x1 << 0)
3105ef8d5529b015d4c5db7fad1adfc91edfd5abad56Wey-Yi Guy#define UCODE_STATISTICS_FREQUENCY_MSK		(0x1 << 1)
3106ef8d5529b015d4c5db7fad1adfc91edfd5abad56Wey-Yi Guy#define UCODE_STATISTICS_NARROW_BAND_MSK	(0x1 << 2)
3107ef8d5529b015d4c5db7fad1adfc91edfd5abad56Wey-Yi Guy
3108b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
3109b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_STATISTICS_CMD = 0x9c,
3110b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * 3945 and 4965 identical.
3111b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
3112b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * This command triggers an immediate response containing uCode statistics.
3113b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * The response is in the same format as STATISTICS_NOTIFICATION 0x9d, below.
3114b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
3115b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * If the CLEAR_STATS configuration flag is set, uCode will clear its
3116b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * internal copy of the statistics (counters) after issuing the response.
3117b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * This flag does not affect STATISTICS_NOTIFICATIONs after beacons (see below).
3118b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
3119b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * If the DISABLE_NOTIF configuration flag is set, uCode will not issue
3120b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * STATISTICS_NOTIFICATIONs after received beacons (see below).  This flag
3121b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * does not affect the response to the REPLY_STATISTICS_CMD 0x9c itself.
3122b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
312351e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define IWL_STATS_CONF_CLEAR_STATS cpu_to_le32(0x1)	/* see above */
312451e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define IWL_STATS_CONF_DISABLE_NOTIF cpu_to_le32(0x2)/* see above */
31258f91aecb4cdc2d786df8941e827b9dff3c10a4e4Emmanuel Grumbachstruct iwl_statistics_cmd {
3126b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 configuration_flags;	/* IWL_STATS_CONF_* */
3127b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
3128b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3129b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
3130b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * STATISTICS_NOTIFICATION = 0x9d (notification only, not a command)
3131b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
3132b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * By default, uCode issues this notification after receiving a beacon
3133b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * while associated.  To disable this behavior, set DISABLE_NOTIF flag in the
3134b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_STATISTICS_CMD 0x9c, above.
3135b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
3136b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Statistics counters continue to increment beacon after beacon, but are
3137b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * cleared when changing channels or when driver issues REPLY_STATISTICS_CMD
3138b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * 0x9c with CLEAR_STATS bit set (see above).
3139b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
3140b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * uCode also issues this notification during scans.  uCode clears statistics
3141b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * appropriately so that each notification contains statistics for only the
3142b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * one channel that has just been scanned.
3143b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
314451e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STATISTICS_REPLY_FLG_BAND_24G_MSK         cpu_to_le32(0x2)
31457aafef1c6e2e24f9a10dc2972bf0ee70624ccc47Wey-Yi Guy#define STATISTICS_REPLY_FLG_HT40_MODE_MSK        cpu_to_le32(0x8)
31463d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
31473d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_notif_statistics {
31483d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 flag;
31493d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct iwl39_statistics_rx rx;
31503d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct iwl39_statistics_tx tx;
31513d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct iwl39_statistics_general general;
31523d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler} __attribute__ ((packed));
31533d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
31548f91aecb4cdc2d786df8941e827b9dff3c10a4e4Emmanuel Grumbachstruct iwl_notif_statistics {
3155b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 flag;
3156b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct statistics_rx rx;
3157b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct statistics_tx tx;
3158b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct statistics_general general;
3159b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
3160b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3161b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3162b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
3163b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * MISSED_BEACONS_NOTIFICATION = 0xa2 (notification only, not a command)
3164b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
3165b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* if ucode missed CONSECUTIVE_MISSED_BCONS_TH beacons in a row,
3166b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * then this notification will be sent. */
3167b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define CONSECUTIVE_MISSED_BCONS_TH 20
3168b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
31692aa6ab86bc475a115f56645591d2413981846509Tomas Winklerstruct iwl_missed_beacon_notif {
3170b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 consequtive_missed_beacons;
3171b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 total_missed_becons;
3172b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 num_expected_beacons;
3173b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 num_recvd_beacons;
3174b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
3175b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3176f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill
3177b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
3178b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (11)
3179b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Rx Calibration Commands:
3180b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
3181f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * With the uCode used for open source drivers, most Tx calibration (except
3182f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * for Tx Power) and most Rx calibration is done by uCode during the
3183f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * "initialize" phase of uCode boot.  Driver must calibrate only:
3184f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3185f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * 1)  Tx power (depends on temperature), described elsewhere
3186f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * 2)  Receiver gain balance (optimize MIMO, and detect disconnected antennas)
3187f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * 3)  Receiver sensitivity (to optimize signal detection)
3188f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3189b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
3190b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3191f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill/**
3192f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * SENSITIVITY_CMD = 0xa8 (command, has simple generic response)
3193f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3194f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * This command sets up the Rx signal detector for a sensitivity level that
3195f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * is high enough to lock onto all signals within the associated network,
3196f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * but low enough to ignore signals that are below a certain threshold, so as
3197f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * not to have too many "false alarms".  False alarms are signals that the
3198f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * Rx DSP tries to lock onto, but then discards after determining that they
3199f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * are noise.
3200f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3201f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * The optimum number of false alarms is between 5 and 50 per 200 TUs
3202f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * (200 * 1024 uSecs, i.e. 204.8 milliseconds) of actual Rx time (i.e.
3203f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * time listening, not transmitting).  Driver must adjust sensitivity so that
3204f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * the ratio of actual false alarms to actual Rx time falls within this range.
3205f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3206f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * While associated, uCode delivers STATISTICS_NOTIFICATIONs after each
3207f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * received beacon.  These provide information to the driver to analyze the
3208f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * sensitivity.  Don't analyze statistics that come in from scanning, or any
3209f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * other non-associated-network source.  Pertinent statistics include:
3210f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3211f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * From "general" statistics (struct statistics_rx_non_phy):
3212f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3213f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * (beacon_energy_[abc] & 0x0FF00) >> 8 (unsigned, higher value is lower level)
3214f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   Measure of energy of desired signal.  Used for establishing a level
3215f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   below which the device does not detect signals.
3216f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3217f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * (beacon_silence_rssi_[abc] & 0x0FF00) >> 8 (unsigned, units in dB)
3218f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   Measure of background noise in silent period after beacon.
3219f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3220f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * channel_load
3221f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   uSecs of actual Rx time during beacon period (varies according to
3222f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   how much time was spent transmitting).
3223f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3224f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * From "cck" and "ofdm" statistics (struct statistics_rx_phy), separately:
3225f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3226f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * false_alarm_cnt
3227f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   Signal locks abandoned early (before phy-level header).
3228f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3229f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * plcp_err
3230f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   Signal locks abandoned late (during phy-level header).
3231f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3232f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * NOTE:  Both false_alarm_cnt and plcp_err increment monotonically from
3233f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        beacon to beacon, i.e. each value is an accumulation of all errors
3234f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        before and including the latest beacon.  Values will wrap around to 0
3235f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        after counting up to 2^32 - 1.  Driver must differentiate vs.
3236f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        previous beacon's values to determine # false alarms in the current
3237f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        beacon period.
3238f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3239f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * Total number of false alarms = false_alarms + plcp_errs
3240f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3241f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * For OFDM, adjust the following table entries in struct iwl_sensitivity_cmd
3242f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * (notice that the start points for OFDM are at or close to settings for
3243f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * maximum sensitivity):
3244f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3245f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *                                             START  /  MIN  /  MAX
3246f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   HD_AUTO_CORR32_X1_TH_ADD_MIN_INDEX          90   /   85  /  120
3247f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_INDEX     170   /  170  /  210
3248f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX         105   /  105  /  140
3249f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_INDEX     220   /  220  /  270
3250f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3251f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   If actual rate of OFDM false alarms (+ plcp_errors) is too high
3252f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   (greater than 50 for each 204.8 msecs listening), reduce sensitivity
3253f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   by *adding* 1 to all 4 of the table entries above, up to the max for
3254f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   each entry.  Conversely, if false alarm rate is too low (less than 5
3255f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   for each 204.8 msecs listening), *subtract* 1 from each entry to
3256f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   increase sensitivity.
3257f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3258f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * For CCK sensitivity, keep track of the following:
3259f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3260f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   1).  20-beacon history of maximum background noise, indicated by
3261f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        (beacon_silence_rssi_[abc] & 0x0FF00), units in dB, across the
3262f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        3 receivers.  For any given beacon, the "silence reference" is
3263f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        the maximum of last 60 samples (20 beacons * 3 receivers).
3264f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3265f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   2).  10-beacon history of strongest signal level, as indicated
3266f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        by (beacon_energy_[abc] & 0x0FF00) >> 8, across the 3 receivers,
3267f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        i.e. the strength of the signal through the best receiver at the
3268f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        moment.  These measurements are "upside down", with lower values
3269f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        for stronger signals, so max energy will be *minimum* value.
3270f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3271f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        Then for any given beacon, the driver must determine the *weakest*
3272f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        of the strongest signals; this is the minimum level that needs to be
3273f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        successfully detected, when using the best receiver at the moment.
3274f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        "Max cck energy" is the maximum (higher value means lower energy!)
3275f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        of the last 10 minima.  Once this is determined, driver must add
3276f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        a little margin by adding "6" to it.
3277f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3278f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   3).  Number of consecutive beacon periods with too few false alarms.
3279f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        Reset this to 0 at the first beacon period that falls within the
3280f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        "good" range (5 to 50 false alarms per 204.8 milliseconds rx).
3281f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3282f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * Then, adjust the following CCK table entries in struct iwl_sensitivity_cmd
3283f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * (notice that the start points for CCK are at maximum sensitivity):
3284f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3285f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *                                             START  /  MIN  /  MAX
3286f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX         125   /  125  /  200
3287f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX     200   /  200  /  400
3288f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   HD_MIN_ENERGY_CCK_DET_INDEX                100   /    0  /  100
3289f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3290f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   If actual rate of CCK false alarms (+ plcp_errors) is too high
3291f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   (greater than 50 for each 204.8 msecs listening), method for reducing
3292f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   sensitivity is:
3293f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3294f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   1)  *Add* 3 to value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX,
3295f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       up to max 400.
3296f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3297f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   2)  If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX is < 160,
3298f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       sensitivity has been reduced a significant amount; bring it up to
3299f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       a moderate 161.  Otherwise, *add* 3, up to max 200.
3300f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3301f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   3)  a)  If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX is > 160,
3302f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       sensitivity has been reduced only a moderate or small amount;
3303f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       *subtract* 2 from value in HD_MIN_ENERGY_CCK_DET_INDEX,
3304f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       down to min 0.  Otherwise (if gain has been significantly reduced),
3305f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       don't change the HD_MIN_ENERGY_CCK_DET_INDEX value.
3306f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3307f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       b)  Save a snapshot of the "silence reference".
3308f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3309f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   If actual rate of CCK false alarms (+ plcp_errors) is too low
3310f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   (less than 5 for each 204.8 msecs listening), method for increasing
3311f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   sensitivity is used only if:
3312f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3313f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   1a)  Previous beacon did not have too many false alarms
3314f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   1b)  AND difference between previous "silence reference" and current
3315f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        "silence reference" (prev - current) is 2 or more,
3316f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   OR 2)  100 or more consecutive beacon periods have had rate of
3317f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *          less than 5 false alarms per 204.8 milliseconds rx time.
3318f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3319f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   Method for increasing sensitivity:
3320f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3321f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   1)  *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX,
3322f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       down to min 125.
3323f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3324f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   2)  *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX,
3325f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       down to min 200.
3326f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3327f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   3)  *Add* 2 to value in HD_MIN_ENERGY_CCK_DET_INDEX, up to max 100.
3328f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3329f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   If actual rate of CCK false alarms (+ plcp_errors) is within good range
3330f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   (between 5 and 50 for each 204.8 msecs listening):
3331f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3332f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   1)  Save a snapshot of the silence reference.
3333f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3334f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   2)  If previous beacon had too many CCK false alarms (+ plcp_errors),
3335f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       give some extra margin to energy threshold by *subtracting* 8
3336f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       from value in HD_MIN_ENERGY_CCK_DET_INDEX.
3337f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3338f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   For all cases (too few, too many, good range), make sure that the CCK
3339f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   detection threshold (energy) is below the energy level for robust
3340f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   detection over the past 10 beacon periods, the "Max cck energy".
3341f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   Lower values mean higher energy; this means making sure that the value
3342f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   in HD_MIN_ENERGY_CCK_DET_INDEX is at or *above* "Max cck energy".
3343f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3344f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill */
3345f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill
3346f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill/*
3347f0832f137c21d130998a0f97f97ac01a2d97210bEmmanuel Grumbach * Table entries in SENSITIVITY_CMD (struct iwl_sensitivity_cmd)
3348f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill */
3349f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_TABLE_SIZE  (11)	/* number of entries */
3350f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_MIN_ENERGY_CCK_DET_INDEX                 (0)	/* table indexes */
3351f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_MIN_ENERGY_OFDM_DET_INDEX                (1)
3352f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_AUTO_CORR32_X1_TH_ADD_MIN_INDEX          (2)
3353f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_INDEX      (3)
3354f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX      (4)
3355f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX          (5)
3356f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_INDEX      (6)
3357f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_BARKER_CORR_TH_ADD_MIN_INDEX             (7)
3358f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_BARKER_CORR_TH_ADD_MIN_MRC_INDEX         (8)
3359f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX          (9)
3360f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_OFDM_ENERGY_TH_IN_INDEX                  (10)
3361f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill
3362f0832f137c21d130998a0f97f97ac01a2d97210bEmmanuel Grumbach/* Control field in struct iwl_sensitivity_cmd */
336351e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define SENSITIVITY_CMD_CONTROL_DEFAULT_TABLE	cpu_to_le16(0)
336451e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define SENSITIVITY_CMD_CONTROL_WORK_TABLE	cpu_to_le16(1)
3365b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3366f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill/**
3367f0832f137c21d130998a0f97f97ac01a2d97210bEmmanuel Grumbach * struct iwl_sensitivity_cmd
3368f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * @control:  (1) updates working table, (0) updates default table
3369f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * @table:  energy threshold values, use HD_* as index into table
3370f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3371f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * Always use "1" in "control" to update uCode's working table and DSP.
3372f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill */
3373f0832f137c21d130998a0f97f97ac01a2d97210bEmmanuel Grumbachstruct iwl_sensitivity_cmd {
3374f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill	__le16 control;			/* always use "1" */
3375f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill	__le16 table[HD_TABLE_SIZE];	/* use HD_* as index */
3376b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
3377b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3378f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill
3379f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill/**
3380f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * REPLY_PHY_CALIBRATION_CMD = 0xb0 (command, has simple generic response)
3381f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3382f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * This command sets the relative gains of 4965's 3 radio receiver chains.
3383f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3384f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * After the first association, driver should accumulate signal and noise
3385f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * statistics from the STATISTICS_NOTIFICATIONs that follow the first 20
3386f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * beacons from the associated network (don't collect statistics that come
3387f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * in from scanning, or any other non-network source).
3388f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3389f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * DISCONNECTED ANTENNA:
3390f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3391f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * Driver should determine which antennas are actually connected, by comparing
3392f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * average beacon signal levels for the 3 Rx chains.  Accumulate (add) the
3393f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * following values over 20 beacons, one accumulator for each of the chains
3394f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * a/b/c, from struct statistics_rx_non_phy:
3395f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3396f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * beacon_rssi_[abc] & 0x0FF (unsigned, units in dB)
3397f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3398f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * Find the strongest signal from among a/b/c.  Compare the other two to the
3399f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * strongest.  If any signal is more than 15 dB (times 20, unless you
3400f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * divide the accumulated values by 20) below the strongest, the driver
3401f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * considers that antenna to be disconnected, and should not try to use that
3402f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * antenna/chain for Rx or Tx.  If both A and B seem to be disconnected,
3403f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * driver should declare the stronger one as connected, and attempt to use it
3404f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * (A and B are the only 2 Tx chains!).
3405f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3406f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3407f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * RX BALANCE:
3408f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3409f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * Driver should balance the 3 receivers (but just the ones that are connected
3410f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * to antennas, see above) for gain, by comparing the average signal levels
3411f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * detected during the silence after each beacon (background noise).
3412f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * Accumulate (add) the following values over 20 beacons, one accumulator for
3413f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * each of the chains a/b/c, from struct statistics_rx_non_phy:
3414f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3415f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * beacon_silence_rssi_[abc] & 0x0FF (unsigned, units in dB)
3416f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3417f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * Find the weakest background noise level from among a/b/c.  This Rx chain
3418f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * will be the reference, with 0 gain adjustment.  Attenuate other channels by
3419f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * finding noise difference:
3420f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3421f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * (accum_noise[i] - accum_noise[reference]) / 30
3422f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3423f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * The "30" adjusts the dB in the 20 accumulated samples to units of 1.5 dB.
3424f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * For use in diff_gain_[abc] fields of struct iwl_calibration_cmd, the
3425f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * driver should limit the difference results to a range of 0-3 (0-4.5 dB),
3426f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * and set bit 2 to indicate "reduce gain".  The value for the reference
3427f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * (weakest) chain should be "0".
3428f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3429f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * diff_gain_[abc] bit fields:
3430f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   2: (1) reduce gain, (0) increase gain
3431f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * 1-0: amount of gain, units of 1.5 dB
3432f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill */
3433f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill
3434f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler/* Phy calibration command for series */
343533fd503346ad86bd7470a0f8c4c3080393d14233Emmanuel Grumbach
343633fd503346ad86bd7470a0f8c4c3080393d14233Emmanuel Grumbachenum {
3437f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	IWL_PHY_CALIBRATE_DIFF_GAIN_CMD		= 7,
3438f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	IWL_PHY_CALIBRATE_DC_CMD		= 8,
3439f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	IWL_PHY_CALIBRATE_LO_CMD		= 9,
3440f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	IWL_PHY_CALIBRATE_RX_BB_CMD		= 10,
3441f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	IWL_PHY_CALIBRATE_TX_IQ_CMD		= 11,
3442f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	IWL_PHY_CALIBRATE_RX_IQ_CMD		= 12,
3443f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	IWL_PHY_CALIBRATION_NOISE_CMD		= 13,
3444f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	IWL_PHY_CALIBRATE_AGC_TABLE_CMD		= 14,
3445f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	IWL_PHY_CALIBRATE_CRYSTAL_FRQ_CMD	= 15,
3446f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	IWL_PHY_CALIBRATE_BASE_BAND_CMD		= 16,
3447f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	IWL_PHY_CALIBRATE_TX_IQ_PERD_CMD	= 17,
3448f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	IWL_PHY_CALIBRATE_CHAIN_NOISE_RESET_CMD	= 18,
3449f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	IWL_PHY_CALIBRATE_CHAIN_NOISE_GAIN_CMD	= 19,
345033fd503346ad86bd7470a0f8c4c3080393d14233Emmanuel Grumbach};
345133fd503346ad86bd7470a0f8c4c3080393d14233Emmanuel Grumbach
3452f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler
345351e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define IWL_CALIB_INIT_CFG_ALL	cpu_to_le32(0xffffffff)
34547c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler
34557c616cba240cd0d579c996be3f3603456acfb0adTomas Winklerstruct iwl_calib_cfg_elmnt_s {
34567c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	__le32 is_enable;
34577c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	__le32 start;
34587c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	__le32 send_res;
34597c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	__le32 apply_res;
34607c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	__le32 reserved;
34617c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler} __attribute__ ((packed));
34627c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler
34637c616cba240cd0d579c996be3f3603456acfb0adTomas Winklerstruct iwl_calib_cfg_status_s {
34647c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	struct iwl_calib_cfg_elmnt_s once;
34657c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	struct iwl_calib_cfg_elmnt_s perd;
34667c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	__le32 flags;
34677c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler} __attribute__ ((packed));
34687c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler
3469f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winklerstruct iwl_calib_cfg_cmd {
34707c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	struct iwl_calib_cfg_status_s ucd_calib_cfg;
34717c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	struct iwl_calib_cfg_status_s drv_calib_cfg;
34727c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	__le32 reserved1;
34737c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler} __attribute__ ((packed));
34747c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler
3475f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winklerstruct iwl_calib_hdr {
34767c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	u8 op_code;
34777c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	u8 first_group;
34787c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	u8 groups_num;
34797c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	u8 data_valid;
34807c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler} __attribute__ ((packed));
34817c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler
3482f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winklerstruct iwl_calib_cmd {
3483f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	struct iwl_calib_hdr hdr;
3484be5d56ed885a2897ec813eab4a8055d495816e9aTomas Winkler	u8 data[0];
3485be5d56ed885a2897ec813eab4a8055d495816e9aTomas Winkler} __attribute__ ((packed));
3486be5d56ed885a2897ec813eab4a8055d495816e9aTomas Winkler
34870d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler/* IWL_PHY_CALIBRATE_DIFF_GAIN_CMD (7) */
3488f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winklerstruct iwl_calib_diff_gain_cmd {
34890d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler	struct iwl_calib_hdr hdr;
3490f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	s8 diff_gain_a;		/* see above */
3491f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	s8 diff_gain_b;
3492f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	s8 diff_gain_c;
3493f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	u8 reserved1;
3494f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler} __attribute__ ((packed));
3495f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler
34960d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winklerstruct iwl_calib_xtal_freq_cmd {
34970d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler	struct iwl_calib_hdr hdr;
34980d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler	u8 cap_pin1;
34990d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler	u8 cap_pin2;
35000d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler	u8 pad[2];
350133fd503346ad86bd7470a0f8c4c3080393d14233Emmanuel Grumbach} __attribute__ ((packed));
350233fd503346ad86bd7470a0f8c4c3080393d14233Emmanuel Grumbach
35030d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler/* IWL_PHY_CALIBRATE_CHAIN_NOISE_RESET_CMD */
35040d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winklerstruct iwl_calib_chain_noise_reset_cmd {
35050d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler	struct iwl_calib_hdr hdr;
35060d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler	u8 data[0];
35070d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler};
35080d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler
35090d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler/* IWL_PHY_CALIBRATE_CHAIN_NOISE_GAIN_CMD */
3510f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winklerstruct iwl_calib_chain_noise_gain_cmd {
35110d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler	struct iwl_calib_hdr hdr;
351233fd503346ad86bd7470a0f8c4c3080393d14233Emmanuel Grumbach	u8 delta_gain_1;
351333fd503346ad86bd7470a0f8c4c3080393d14233Emmanuel Grumbach	u8 delta_gain_2;
35140d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler	u8 pad[2];
351533fd503346ad86bd7470a0f8c4c3080393d14233Emmanuel Grumbach} __attribute__ ((packed));
351633fd503346ad86bd7470a0f8c4c3080393d14233Emmanuel Grumbach
3517b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
3518b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (12)
3519b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Miscellaneous Commands:
3520b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
3521b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
3522b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3523b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
3524b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * LEDs Command & Response
3525b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_LEDS_CMD = 0x48 (command, has simple generic response)
3526b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
3527b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * For each of 3 possible LEDs (Activity/Link/Tech, selected by "id" field),
3528b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * this command turns it on or off, or sets up a periodic blinking cycle.
3529b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
3530ec1a746042ea4c1c93065185897d6e8d3e7de894Tomas Winklerstruct iwl_led_cmd {
3531b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 interval;	/* "interval" in uSec */
3532b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 id;			/* 1: Activity, 2: Link, 3: Tech */
3533b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 off;			/* # intervals off while blinking;
3534b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 * "0", with >0 "on" value, turns LED on */
3535b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 on;			/* # intervals on while blinking;
3536b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 * "0", regardless of "off", turns LED off */
3537b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved;
3538b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
3539b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
35409636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky/*
3541fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy * station priority table entries
3542fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy * also used as potential "events" value for both
3543fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy * COEX_MEDIUM_NOTIFICATION and COEX_EVENT_CMD
35449636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky */
35451933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy
35461933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy/*
35471933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy * COEX events entry flag masks
35481933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy * RP - Requested Priority
35491933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy * WP - Win Medium Priority: priority assigned when the contention has been won
35501933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy */
35511933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG        (0x1)
35521933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG        (0x2)
35531933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_EVT_FLAG_DELAY_MEDIUM_FREE_NTFY_FLG  (0x4)
35541933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy
35551933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_UNASSOC_IDLE_RP               4
35561933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_UNASSOC_MANUAL_SCAN_RP        4
35571933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_UNASSOC_AUTO_SCAN_RP          4
35581933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_CALIBRATION_RP                4
35591933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_PERIODIC_CALIBRATION_RP       4
35601933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_CONNECTION_ESTAB_RP           4
35611933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_ASSOCIATED_IDLE_RP            4
35621933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_ASSOC_MANUAL_SCAN_RP          4
35631933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_ASSOC_AUTO_SCAN_RP            4
35641933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_ASSOC_ACTIVE_LEVEL_RP         4
35651933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_RF_ON_RP                      6
35661933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_RF_OFF_RP                     4
35671933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_STAND_ALONE_DEBUG_RP          6
35681933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_IPAN_ASSOC_LEVEL_RP           4
35691933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_RSRVD1_RP                     4
35701933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_RSRVD2_RP                     4
35711933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy
35721933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_UNASSOC_IDLE_WP               3
35731933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_UNASSOC_MANUAL_SCAN_WP        3
35741933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_UNASSOC_AUTO_SCAN_WP          3
35751933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_CALIBRATION_WP                3
35761933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_PERIODIC_CALIBRATION_WP       3
35771933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_CONNECTION_ESTAB_WP           3
35781933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_ASSOCIATED_IDLE_WP            3
35791933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_ASSOC_MANUAL_SCAN_WP          3
35801933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_ASSOC_AUTO_SCAN_WP            3
35811933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_ASSOC_ACTIVE_LEVEL_WP         3
35821933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_RF_ON_WP                      3
35831933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_RF_OFF_WP                     3
35841933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_STAND_ALONE_DEBUG_WP          6
35851933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_IPAN_ASSOC_LEVEL_WP           3
35861933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_RSRVD1_WP                     3
35871933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_RSRVD2_WP                     3
35881933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy
35891933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_UNASSOC_IDLE_FLAGS                     0
35901933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_UNASSOC_MANUAL_SCAN_FLAGS		\
35911933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	(COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG |	\
35921933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
35931933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_UNASSOC_AUTO_SCAN_FLAGS		\
35941933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	(COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG |	\
35951933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
35961933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CALIBRATION_FLAGS			\
35971933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	(COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG |	\
35981933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
35991933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_PERIODIC_CALIBRATION_FLAGS             0
36001933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy/*
36011933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy * COEX_CONNECTION_ESTAB:
36021933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy * we need DELAY_MEDIUM_FREE_NTFY to let WiMAX disconnect from network.
36031933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy */
36041933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CONNECTION_ESTAB_FLAGS		\
36051933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	(COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG |	\
36061933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG |	\
36071933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	COEX_EVT_FLAG_DELAY_MEDIUM_FREE_NTFY_FLG)
36081933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_ASSOCIATED_IDLE_FLAGS                  0
36091933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_ASSOC_MANUAL_SCAN_FLAGS		\
36101933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	(COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG |	\
36111933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
36121933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_ASSOC_AUTO_SCAN_FLAGS		\
36131933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	(COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG |	\
36141933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
36151933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_ASSOC_ACTIVE_LEVEL_FLAGS               0
36161933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_RF_ON_FLAGS                            0
36171933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_RF_OFF_FLAGS                           0
36181933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_STAND_ALONE_DEBUG_FLAGS		\
36191933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	(COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG |	\
36201933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
36211933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_IPAN_ASSOC_LEVEL_FLAGS		\
36221933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	(COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG |	\
36231933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG |	\
36241933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	 COEX_EVT_FLAG_DELAY_MEDIUM_FREE_NTFY_FLG)
36251933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_RSRVD1_FLAGS                           0
36261933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_RSRVD2_FLAGS                           0
36271933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy/*
36281933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy * COEX_CU_RF_ON is the event wrapping all radio ownership.
36291933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy * We need DELAY_MEDIUM_FREE_NTFY to let WiMAX disconnect from network.
36301933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy */
36311933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_RF_ON_FLAGS			\
36321933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	(COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG |	\
36331933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG |	\
36341933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	 COEX_EVT_FLAG_DELAY_MEDIUM_FREE_NTFY_FLG)
36351933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy
36361933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy
36379636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunskyenum {
3638fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	/* un-association part */
36399636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_UNASSOC_IDLE		= 0,
36409636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_UNASSOC_MANUAL_SCAN	= 1,
36419636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_UNASSOC_AUTO_SCAN		= 2,
3642fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	/* calibration */
36439636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_CALIBRATION		= 3,
36449636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_PERIODIC_CALIBRATION	= 4,
3645fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	/* connection */
36469636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_CONNECTION_ESTAB		= 5,
3647fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	/* association part */
36489636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_ASSOCIATED_IDLE		= 6,
36499636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_ASSOC_MANUAL_SCAN		= 7,
36509636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_ASSOC_AUTO_SCAN		= 8,
36519636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_ASSOC_ACTIVE_LEVEL		= 9,
3652fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	/* RF ON/OFF */
36539636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_RF_ON			= 10,
36549636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_RF_OFF			= 11,
36559636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_STAND_ALONE_DEBUG		= 12,
3656fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	/* IPAN */
36579636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_IPAN_ASSOC_LEVEL		= 13,
3658fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	/* reserved */
36599636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_RSRVD1			= 14,
36609636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_RSRVD2			= 15,
36619636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_NUM_OF_EVENTS		= 16
36629636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky};
36639636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky
3664fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy/*
3665fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy * Coexistence WIFI/WIMAX  Command
3666fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy * COEX_PRIORITY_TABLE_CMD = 0x5a
3667fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy *
3668fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy */
36699636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunskystruct iwl_wimax_coex_event_entry {
36709636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	u8 request_prio;
36719636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	u8 win_medium_prio;
36729636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	u8 reserved;
36739636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	u8 flags;
36749636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky} __attribute__ ((packed));
36759636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky
36769636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky/* COEX flag masks */
36779636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky
3678a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler/* Station table is valid */
36799636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky#define COEX_FLAGS_STA_TABLE_VALID_MSK      (0x1)
3680a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler/* UnMask wake up src at unassociated sleep */
36819636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky#define COEX_FLAGS_UNASSOC_WA_UNMASK_MSK    (0x4)
3682a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler/* UnMask wake up src at associated sleep */
36839636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky#define COEX_FLAGS_ASSOC_WA_UNMASK_MSK      (0x8)
36849636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky/* Enable CoEx feature. */
36859636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky#define COEX_FLAGS_COEX_ENABLE_MSK          (0x80)
36869636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky
36879636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunskystruct iwl_wimax_coex_cmd {
36889636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	u8 flags;
36899636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	u8 reserved[3];
36909636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	struct iwl_wimax_coex_event_entry sta_prio[COEX_NUM_OF_EVENTS];
36919636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky} __attribute__ ((packed));
36929636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky
3693fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy/*
3694fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy * Coexistence MEDIUM NOTIFICATION
3695fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy * COEX_MEDIUM_NOTIFICATION = 0x5b
3696fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy *
3697fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy * notification from uCode to host to indicate medium changes
3698fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy *
3699fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy */
3700fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy/*
3701fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy * status field
3702fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy * bit 0 - 2: medium status
3703fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy * bit 3: medium change indication
3704fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy * bit 4 - 31: reserved
3705fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy */
3706fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy/* status option values, (0 - 2 bits) */
3707fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy#define COEX_MEDIUM_BUSY	(0x0) /* radio belongs to WiMAX */
3708fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy#define COEX_MEDIUM_ACTIVE	(0x1) /* radio belongs to WiFi */
3709fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy#define COEX_MEDIUM_PRE_RELEASE	(0x2) /* received radio release */
3710fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy#define COEX_MEDIUM_MSK		(0x7)
3711fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy
3712fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy/* send notification status (1 bit) */
3713fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy#define COEX_MEDIUM_CHANGED	(0x8)
3714fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy#define COEX_MEDIUM_CHANGED_MSK	(0x8)
3715fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy#define COEX_MEDIUM_SHIFT	(3)
3716fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy
3717fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guystruct iwl_coex_medium_notification {
3718fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	__le32 status;
3719fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	__le32 events;
3720fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy} __attribute__ ((packed));
3721fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy
3722fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy/*
3723fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy * Coexistence EVENT  Command
3724fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy * COEX_EVENT_CMD = 0x5c
3725fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy *
3726fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy * send from host to uCode for coex event request.
3727fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy */
3728fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy/* flags options */
3729fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy#define COEX_EVENT_REQUEST_MSK	(0x1)
3730fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy
3731fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guystruct iwl_coex_event_cmd {
3732fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	u8 flags;
3733fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	u8 event;
3734fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	__le16 reserved;
3735fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy} __attribute__ ((packed));
3736fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy
3737fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guystruct iwl_coex_event_resp {
3738fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	__le32 status;
3739fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy} __attribute__ ((packed));
3740fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy
3741fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy
3742b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
3743b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (13)
3744b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Union of all expected notifications/responses:
3745b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
3746b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
3747b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3748db11d6343aa14ab61258bfad9178042d4be49333Tomas Winklerstruct iwl_rx_packet {
37492f301227a1ede57504694e1f64839839f5737cacZhu Yi	/*
37502f301227a1ede57504694e1f64839839f5737cacZhu Yi	 * The first 4 bytes of the RX frame header contain both the RX frame
37512f301227a1ede57504694e1f64839839f5737cacZhu Yi	 * size and some flags.
37522f301227a1ede57504694e1f64839839f5737cacZhu Yi	 * Bit fields:
37532f301227a1ede57504694e1f64839839f5737cacZhu Yi	 * 31:    flag flush RB request
37542f301227a1ede57504694e1f64839839f5737cacZhu Yi	 * 30:    flag ignore TC (terminal counter) request
37552f301227a1ede57504694e1f64839839f5737cacZhu Yi	 * 29:    flag fast IRQ request
37562f301227a1ede57504694e1f64839839f5737cacZhu Yi	 * 28-14: Reserved
37572f301227a1ede57504694e1f64839839f5737cacZhu Yi	 * 13-00: RX frame size
37582f301227a1ede57504694e1f64839839f5737cacZhu Yi	 */
3759396887a2b2ad1ef5e5526fec34dec582baf39b81Daniel C Halperin	__le32 len_n_flags;
3760857485c0c46ceee5c658c1761bba4d9a5ddf433fTomas Winkler	struct iwl_cmd_header hdr;
3761b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	union {
37623d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler		struct iwl3945_rx_frame rx_frame;
37633d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler		struct iwl3945_tx_resp tx_resp;
37643d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler		struct iwl3945_beacon_notif beacon_status;
37653d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
3766885ba202cabd90b8ade1fe59185dc96ed4d69e02Tomas Winkler		struct iwl_alive_resp alive_frame;
37672aa6ab86bc475a115f56645591d2413981846509Tomas Winkler		struct iwl_spectrum_notification spectrum_notif;
37682aa6ab86bc475a115f56645591d2413981846509Tomas Winkler		struct iwl_csa_notification csa_notif;
3769885ba202cabd90b8ade1fe59185dc96ed4d69e02Tomas Winkler		struct iwl_error_resp err_resp;
37702aa6ab86bc475a115f56645591d2413981846509Tomas Winkler		struct iwl_card_state_notif card_state_notif;
37717a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler		struct iwl_add_sta_resp add_sta;
37727a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler		struct iwl_rem_sta_resp rem_sta;
37732aa6ab86bc475a115f56645591d2413981846509Tomas Winkler		struct iwl_sleep_notification sleep_notif;
37742aa6ab86bc475a115f56645591d2413981846509Tomas Winkler		struct iwl_spectrum_resp spectrum;
37758f91aecb4cdc2d786df8941e827b9dff3c10a4e4Emmanuel Grumbach		struct iwl_notif_statistics stats;
3776653fa4a07525e4cd9e7b90e6fc1f792119910636Emmanuel Grumbach		struct iwl_compressed_ba_resp compressed_ba;
37772aa6ab86bc475a115f56645591d2413981846509Tomas Winkler		struct iwl_missed_beacon_notif missed_beacon;
3778fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy		struct iwl_coex_medium_notification coex_medium_notif;
3779fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy		struct iwl_coex_event_resp coex_event;
3780b481de9ca074528fe8c429604e2777db8b89806aZhu Yi		__le32 status;
3781b481de9ca074528fe8c429604e2777db8b89806aZhu Yi		u8 raw[0];
3782b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	} u;
3783b481de9ca074528fe8c429604e2777db8b89806aZhu Yi} __attribute__ ((packed));
3784b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3785a3139c5956702c9ff957ac9fe2d902de355b063eSamuel Ortizint iwl_agn_check_rxon_cmd(struct iwl_priv *priv);
37868f5c87dcf6d1a5e6d7ffe642cfd4debb5ccbec49Winkler, Tomas
37876a63578ddf6148927a80c07a73b40ccc8f3ac8e2Emmanuel Grumbach#endif				/* __iwl_commands_h__ */
3788