iwl-commands.h revision 30c1b0f7e96144e42e2be0bdec18d2475f5af31b
1b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
2b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
3b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * This file is provided under a dual BSD/GPLv2 license.  When using or
4b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * redistributing this file, you may do so under either license.
5b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
6b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * GPL LICENSE SUMMARY
7b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
81f44780827c6bbbcd1f12d5c6b6ce84f49a96bc0Reinette Chatre * Copyright(c) 2005 - 2010 Intel Corporation. All rights reserved.
9b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
10b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * This program is free software; you can redistribute it and/or modify
1101ebd063e11bdcf1ddc605d968ea89aef48e34e0Ian Schram * it under the terms of version 2 of the GNU General Public License as
12b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * published by the Free Software Foundation.
13b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
14b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * This program is distributed in the hope that it will be useful, but
15b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * WITHOUT ANY WARRANTY; without even the implied warranty of
16b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * General Public License for more details.
18b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
19b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * You should have received a copy of the GNU General Public License
20b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * along with this program; if not, write to the Free Software
21b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
22b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * USA
23b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
24b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * The full GNU General Public License is included in this distribution
25b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * in the file called LICENSE.GPL.
26b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
27b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Contact Information:
28759ef89fb096c4a6ef078d3cfd5682ac037bd789Winkler, Tomas *  Intel Linux Wireless <ilw@linux.intel.com>
29b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
30b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
31b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * BSD LICENSE
32b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
331f44780827c6bbbcd1f12d5c6b6ce84f49a96bc0Reinette Chatre * Copyright(c) 2005 - 2010 Intel Corporation. All rights reserved.
34b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * All rights reserved.
35b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
36b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Redistribution and use in source and binary forms, with or without
37b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * modification, are permitted provided that the following conditions
38b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * are met:
39b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
40b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *  * Redistributions of source code must retain the above copyright
41b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *    notice, this list of conditions and the following disclaimer.
42b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *  * Redistributions in binary form must reproduce the above copyright
43b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *    notice, this list of conditions and the following disclaimer in
44b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *    the documentation and/or other materials provided with the
45b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *    distribution.
46b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *  * Neither the name Intel Corporation nor the names of its
47b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *    contributors may be used to endorse or promote products derived
48b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *    from this software without specific prior written permission.
49b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
50b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
51b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
52b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
53b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
54b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
56b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
57b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
58b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
59b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
60b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
61b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
62b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
63fcd427bbba10fc315d1c958b85bba74448db4eb4Ben M Cahill/*
645a36ba0e412a0e12a8bf2648a075226c1dd7870dTomas Winkler * Please use this file (iwl-commands.h) only for uCode API definitions.
65fcd427bbba10fc315d1c958b85bba74448db4eb4Ben M Cahill * Please use iwl-4965-hw.h for hardware-related definitions.
663e0d4cb12f6fd97193a455b49125398b2231c87cTomas Winkler * Please use iwl-dev.h for driver implementation definitions.
67fcd427bbba10fc315d1c958b85bba74448db4eb4Ben M Cahill */
68b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
696a63578ddf6148927a80c07a73b40ccc8f3ac8e2Emmanuel Grumbach#ifndef __iwl_commands_h__
706a63578ddf6148927a80c07a73b40ccc8f3ac8e2Emmanuel Grumbach#define __iwl_commands_h__
71b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
72a3139c5956702c9ff957ac9fe2d902de355b063eSamuel Ortizstruct iwl_priv;
73a3139c5956702c9ff957ac9fe2d902de355b063eSamuel Ortiz
74c02b3acd29766c6f79c2411cb5b85e1ee72c4c8fChatre, Reinette/* uCode version contains 4 values: Major/Minor/API/Serial */
75c02b3acd29766c6f79c2411cb5b85e1ee72c4c8fChatre, Reinette#define IWL_UCODE_MAJOR(ver)	(((ver) & 0xFF000000) >> 24)
76c02b3acd29766c6f79c2411cb5b85e1ee72c4c8fChatre, Reinette#define IWL_UCODE_MINOR(ver)	(((ver) & 0x00FF0000) >> 16)
77c02b3acd29766c6f79c2411cb5b85e1ee72c4c8fChatre, Reinette#define IWL_UCODE_API(ver)	(((ver) & 0x0000FF00) >> 8)
78c02b3acd29766c6f79c2411cb5b85e1ee72c4c8fChatre, Reinette#define IWL_UCODE_SERIAL(ver)	((ver) & 0x000000FF)
79c02b3acd29766c6f79c2411cb5b85e1ee72c4c8fChatre, Reinette
804c897253cc9ae1c6a2798b27b5fe8e6d94ab6185Tomas Winkler
814c897253cc9ae1c6a2798b27b5fe8e6d94ab6185Tomas Winkler/* Tx rates */
824c897253cc9ae1c6a2798b27b5fe8e6d94ab6185Tomas Winkler#define IWL_CCK_RATES	4
834c897253cc9ae1c6a2798b27b5fe8e6d94ab6185Tomas Winkler#define IWL_OFDM_RATES	8
844c897253cc9ae1c6a2798b27b5fe8e6d94ab6185Tomas Winkler#define IWL_MAX_RATES	(IWL_CCK_RATES + IWL_OFDM_RATES)
854c897253cc9ae1c6a2798b27b5fe8e6d94ab6185Tomas Winkler
86b481de9ca074528fe8c429604e2777db8b89806aZhu Yienum {
87b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_ALIVE = 0x1,
88b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_ERROR = 0x2,
89b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
90b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* RXON and QOS commands */
91b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_RXON = 0x10,
92b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_RXON_ASSOC = 0x11,
93b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_QOS_PARAM = 0x13,
94b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_RXON_TIMING = 0x14,
95b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
96b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* Multi-Station support */
97b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_ADD_STA = 0x18,
98fc66be2a808724d61134e420ef9d7082653c72ebWey-Yi Guy	REPLY_REMOVE_STA = 0x19,
99b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_REMOVE_ALL_STA = 0x1a,	/* not used */
100947279eefb77f79015a79b032eb825a065ab035fWey-Yi Guy	REPLY_TXFIFO_FLUSH = 0x1e,
101b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1020a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach	/* Security */
1030a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach	REPLY_WEPKEY = 0x20,
1040a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach
105b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* RX, TX, LEDs */
1062aa6ab86bc475a115f56645591d2413981846509Tomas Winkler	REPLY_3945_RX = 0x1b,           /* 3945 only */
107b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_TX = 0x1c,
108b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_RATE_SCALE = 0x47,	/* 3945 only */
109b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_LEDS_CMD = 0x48,
1104c8d1913ac1baab64080c1030cb94e24cbd9a0f8Wey-Yi Guy	REPLY_TX_LINK_QUALITY_CMD = 0x4e, /* for 4965 and up */
111b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1129636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	/* WiMAX coexistence */
113d23000cd8992823e06ca0745564f2c25fe923ce4Wey-Yi Guy	COEX_PRIORITY_TABLE_CMD = 0x5a,	/* for 5000 series and up */
1149636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_MEDIUM_NOTIFICATION = 0x5b,
1159636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_EVENT_CMD = 0x5c,
1169636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky
117be5d56ed885a2897ec813eab4a8055d495816e9aTomas Winkler	/* Calibration */
1181a5c3d61993f56daf15c35bea8d3943f4e835638Jay Sternberg	TEMPERATURE_NOTIFICATION = 0x62,
119be5d56ed885a2897ec813eab4a8055d495816e9aTomas Winkler	CALIBRATION_CFG_CMD = 0x65,
120be5d56ed885a2897ec813eab4a8055d495816e9aTomas Winkler	CALIBRATION_RES_NOTIFICATION = 0x66,
121be5d56ed885a2897ec813eab4a8055d495816e9aTomas Winkler	CALIBRATION_COMPLETE_NOTIFICATION = 0x67,
122be5d56ed885a2897ec813eab4a8055d495816e9aTomas Winkler
123b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* 802.11h related */
124b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_QUIET_CMD = 0x71,		/* not used */
125b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_CHANNEL_SWITCH = 0x72,
126b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	CHANNEL_SWITCH_NOTIFICATION = 0x73,
127b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74,
128b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	SPECTRUM_MEASURE_NOTIFICATION = 0x75,
129b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
130b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* Power Management */
131b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	POWER_TABLE_CMD = 0x77,
132b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	PM_SLEEP_NOTIFICATION = 0x7A,
133b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	PM_DEBUG_STATISTIC_NOTIFIC = 0x7B,
134b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
135b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* Scan commands and notifications */
136b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_SCAN_CMD = 0x80,
137b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_SCAN_ABORT_CMD = 0x81,
138b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	SCAN_START_NOTIFICATION = 0x82,
139b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	SCAN_RESULTS_NOTIFICATION = 0x83,
140b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	SCAN_COMPLETE_NOTIFICATION = 0x84,
141b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
142b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* IBSS/AP commands */
143b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	BEACON_NOTIFICATION = 0x90,
144b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	REPLY_TX_BEACON = 0x91,
145b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	WHO_IS_AWAKE_NOTIFICATION = 0x94,	/* not used */
146b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
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];
231ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __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 */
251ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __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;
262ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __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;
393ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __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];
402ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __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;
416ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __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;
426ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __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 */
482ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __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 *
516461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *
517075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * 2)  error_event_table_ptr indicates base of the error log.  This contains
518461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *     information about any uCode error that occurs.  For agn, the format
519075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *     of the error log is:
520075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *
521075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 valid;        (nonzero) valid, (0) log is empty
522075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 error_id;     type of error
523075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 pc;           program counter
524075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 blink1;       branch link
525075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 blink2;       branch link
526075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 ilink1;       interrupt link
527075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 ilink2;       interrupt link
528075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 data1;        error-specific data
529075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 data2;        error-specific data
530075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 line;         source code line of error
531075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 bcon_time;    beacon timer
532075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 tsf_low;      network timestamp function timer
533075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *	__le32 tsf_hi;       network timestamp function timer
534461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 gp1;          GP1 timer register
535461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 gp2;          GP2 timer register
536461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 gp3;          GP3 timer register
537461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 ucode_ver;    uCode version
538461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 hw_ver;       HW Silicon version
539461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 brd_ver;      HW board version
540461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 log_pc;       log program counter
541461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 frame_ptr;    frame pointer
542461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 stack_ptr;    stack pointer
543461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 hcmd;         last host command
544461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 isr0;         isr status register LMPM_NIC_ISR0: rxtx_flag
545461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 isr1;         isr status register LMPM_NIC_ISR1: host_flag
546461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 isr2;         isr status register LMPM_NIC_ISR2: enc_flag
547461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 isr3;         isr status register LMPM_NIC_ISR3: time_flag
548461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 isr4;         isr status register LMPM_NIC_ISR4: wico interrupt
549461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 isr_pref;     isr status register LMPM_NIC_PREF_STAT
550461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 wait_event;   wait event() caller address
551461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 l2p_control;  L2pControlField
552461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 l2p_duration; L2pDurationField
553461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 l2p_mhvalid;  L2pMhValidBits
554461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 l2p_addr_match; L2pAddrMatchStat
555461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 lmpm_pmg_sel; indicate which clocks are turned on (LMPM_PMG_SEL)
556461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 u_timestamp;  indicate when the date and time of the compilation
557461ef382fd68f02b7bac8f94f7f2b85162bad896Wey-Yi Guy *	__le32 reserved;
558075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill *
559075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * The Linux driver can print both logs to the system log when a uCode error
560075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill * occurs.
561075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill */
562885ba202cabd90b8ade1fe59185dc96ed4d69e02Tomas Winklerstruct iwl_alive_resp {
563b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ucode_minor;
564b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ucode_major;
565b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved1;
566b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 sw_rev[8];
567b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ver_type;
568075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	u8 ver_subtype;			/* not "9" for runtime alive */
569b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved2;
570075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	__le32 log_event_table_ptr;	/* SRAM address for event log */
571075416cd18cb4a7ed057d9a96b388bc23b43c4b1Ben M Cahill	__le32 error_event_table_ptr;	/* SRAM address for error log */
572b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 timestamp;
573b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 is_valid;
574ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
575b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
576b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
577b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_ERROR = 0x2 (response only, not a command)
578b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
579885ba202cabd90b8ade1fe59185dc96ed4d69e02Tomas Winklerstruct iwl_error_resp {
580b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 error_type;
581b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 cmd_id;
582b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved1;
583b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 bad_cmd_seq_num;
584b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 error_info;
5853195c1f3499912b207ae600968488759b16037fcTomas Winkler	__le64 timestamp;
586ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
587b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
588b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
589b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (1)
590b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * RXON Commands & Responses:
591b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
592b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
593b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
594b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
595b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Rx config defines & structure
596b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
597b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* rx_config device types  */
598b481de9ca074528fe8c429604e2777db8b89806aZhu Yienum {
599b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	RXON_DEV_TYPE_AP = 1,
600b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	RXON_DEV_TYPE_ESS = 3,
601b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	RXON_DEV_TYPE_IBSS = 4,
602b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	RXON_DEV_TYPE_SNIFFER = 6,
603b481de9ca074528fe8c429604e2777db8b89806aZhu Yi};
604b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
60514519a0b46085db68e610147098d03386c34801fBen M Cahill
60651e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_RX_CHAIN_DRIVER_FORCE_MSK		cpu_to_le16(0x1 << 0)
6077b841727d2715d97592f46164804b34d6241644fRick Farrington#define RXON_RX_CHAIN_DRIVER_FORCE_POS		(0)
60851e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_RX_CHAIN_VALID_MSK			cpu_to_le16(0x7 << 1)
60914519a0b46085db68e610147098d03386c34801fBen M Cahill#define RXON_RX_CHAIN_VALID_POS			(1)
61051e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_RX_CHAIN_FORCE_SEL_MSK		cpu_to_le16(0x7 << 4)
61114519a0b46085db68e610147098d03386c34801fBen M Cahill#define RXON_RX_CHAIN_FORCE_SEL_POS		(4)
61251e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_RX_CHAIN_FORCE_MIMO_SEL_MSK	cpu_to_le16(0x7 << 7)
61314519a0b46085db68e610147098d03386c34801fBen M Cahill#define RXON_RX_CHAIN_FORCE_MIMO_SEL_POS	(7)
61451e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_RX_CHAIN_CNT_MSK			cpu_to_le16(0x3 << 10)
61514519a0b46085db68e610147098d03386c34801fBen M Cahill#define RXON_RX_CHAIN_CNT_POS			(10)
61651e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_RX_CHAIN_MIMO_CNT_MSK		cpu_to_le16(0x3 << 12)
61714519a0b46085db68e610147098d03386c34801fBen M Cahill#define RXON_RX_CHAIN_MIMO_CNT_POS		(12)
61851e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_RX_CHAIN_MIMO_FORCE_MSK		cpu_to_le16(0x1 << 14)
61914519a0b46085db68e610147098d03386c34801fBen M Cahill#define RXON_RX_CHAIN_MIMO_FORCE_POS		(14)
62014519a0b46085db68e610147098d03386c34801fBen M Cahill
621b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* rx_config flags */
622b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* band & modulation selection */
62351e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_BAND_24G_MSK           cpu_to_le32(1 << 0)
62451e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_CCK_MSK                cpu_to_le32(1 << 1)
625b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* auto detection enable */
62651e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_AUTO_DETECT_MSK        cpu_to_le32(1 << 2)
627b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* TGg protection when tx */
62851e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_TGG_PROTECT_MSK        cpu_to_le32(1 << 3)
629b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* cck short slot & preamble */
63051e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_SHORT_SLOT_MSK          cpu_to_le32(1 << 4)
63151e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_SHORT_PREAMBLE_MSK     cpu_to_le32(1 << 5)
632b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* antenna selection */
63351e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_DIS_DIV_MSK            cpu_to_le32(1 << 7)
63451e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_ANT_SEL_MSK            cpu_to_le32(0x0f00)
63551e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_ANT_A_MSK              cpu_to_le32(1 << 8)
63651e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_ANT_B_MSK              cpu_to_le32(1 << 9)
637b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* radar detection enable */
63851e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_RADAR_DETECT_MSK       cpu_to_le32(1 << 12)
63951e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_TGJ_NARROW_BAND_MSK    cpu_to_le32(1 << 13)
640b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* rx response to host with 8-byte TSF
641b481de9ca074528fe8c429604e2777db8b89806aZhu Yi* (according to ON_AIR deassertion) */
64251e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_TSF2HOST_MSK           cpu_to_le32(1 << 15)
643b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
64414519a0b46085db68e610147098d03386c34801fBen M Cahill
64514519a0b46085db68e610147098d03386c34801fBen M Cahill/* HT flags */
64614519a0b46085db68e610147098d03386c34801fBen M Cahill#define RXON_FLG_CTRL_CHANNEL_LOC_POS		(22)
64751e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK	cpu_to_le32(0x1 << 22)
64814519a0b46085db68e610147098d03386c34801fBen M Cahill
64914519a0b46085db68e610147098d03386c34801fBen M Cahill#define RXON_FLG_HT_OPERATING_MODE_POS		(23)
65014519a0b46085db68e610147098d03386c34801fBen M Cahill
65151e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_HT_PROT_MSK			cpu_to_le32(0x1 << 23)
6527aafef1c6e2e24f9a10dc2972bf0ee70624ccc47Wey-Yi Guy#define RXON_FLG_HT40_PROT_MSK			cpu_to_le32(0x2 << 23)
65314519a0b46085db68e610147098d03386c34801fBen M Cahill
65414519a0b46085db68e610147098d03386c34801fBen M Cahill#define RXON_FLG_CHANNEL_MODE_POS		(25)
65551e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_CHANNEL_MODE_MSK		cpu_to_le32(0x3 << 25)
656a2b0f02e4795bfde5f11720a10af8923cb98b654Wey-Yi Guy
657a2b0f02e4795bfde5f11720a10af8923cb98b654Wey-Yi Guy/* channel mode */
658a2b0f02e4795bfde5f11720a10af8923cb98b654Wey-Yi Guyenum {
659a2b0f02e4795bfde5f11720a10af8923cb98b654Wey-Yi Guy	CHANNEL_MODE_LEGACY = 0,
660a2b0f02e4795bfde5f11720a10af8923cb98b654Wey-Yi Guy	CHANNEL_MODE_PURE_40 = 1,
661a2b0f02e4795bfde5f11720a10af8923cb98b654Wey-Yi Guy	CHANNEL_MODE_MIXED = 2,
662a2b0f02e4795bfde5f11720a10af8923cb98b654Wey-Yi Guy	CHANNEL_MODE_RESERVED = 3,
663a2b0f02e4795bfde5f11720a10af8923cb98b654Wey-Yi Guy};
664a2b0f02e4795bfde5f11720a10af8923cb98b654Wey-Yi Guy#define RXON_FLG_CHANNEL_MODE_LEGACY	cpu_to_le32(CHANNEL_MODE_LEGACY << RXON_FLG_CHANNEL_MODE_POS)
665a2b0f02e4795bfde5f11720a10af8923cb98b654Wey-Yi Guy#define RXON_FLG_CHANNEL_MODE_PURE_40	cpu_to_le32(CHANNEL_MODE_PURE_40 << RXON_FLG_CHANNEL_MODE_POS)
666a2b0f02e4795bfde5f11720a10af8923cb98b654Wey-Yi Guy#define RXON_FLG_CHANNEL_MODE_MIXED	cpu_to_le32(CHANNEL_MODE_MIXED << RXON_FLG_CHANNEL_MODE_POS)
667a2b0f02e4795bfde5f11720a10af8923cb98b654Wey-Yi Guy
668a326a5d096f031af46c0073dd78eb80dea1f311aEmmanuel Grumbach/* CTS to self (if spec allows) flag */
66951e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FLG_SELF_CTS_EN			cpu_to_le32(0x1<<30)
67014519a0b46085db68e610147098d03386c34801fBen M Cahill
671b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* rx_config filter flags */
672b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* accept all data frames */
67351e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FILTER_PROMISC_MSK         cpu_to_le32(1 << 0)
674b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* pass control & management to host */
67551e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FILTER_CTL2HOST_MSK        cpu_to_le32(1 << 1)
676b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* accept multi-cast */
67751e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FILTER_ACCEPT_GRP_MSK      cpu_to_le32(1 << 2)
678b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* don't decrypt uni-cast frames */
67951e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FILTER_DIS_DECRYPT_MSK     cpu_to_le32(1 << 3)
680b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* don't decrypt multi-cast frames */
68151e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FILTER_DIS_GRP_DECRYPT_MSK cpu_to_le32(1 << 4)
682b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* STA is associated */
68351e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FILTER_ASSOC_MSK           cpu_to_le32(1 << 5)
684b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* transfer to host non bssid beacons in associated state */
68551e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RXON_FILTER_BCON_AWARE_MSK      cpu_to_le32(1 << 6)
686b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
68780cc0c382db318de88577eff027d5c4097abef81Ben M Cahill/**
688b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_RXON = 0x10 (command, has simple generic response)
68980cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *
69080cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * RXON tunes the radio tuner to a service channel, and sets up a number
69180cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * of parameters that are used primarily for Rx, but also for Tx operations.
69280cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *
69380cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * NOTE:  When tuning to a new channel, driver must set the
69480cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *        RXON_FILTER_ASSOC_MSK to 0.  This will clear station-dependent
69580cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *        info within the device, including the station tables, tx retry
69680cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *        rate tables, and txpower tables.  Driver must build a new station
69780cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *        table and txpower table before transmitting anything on the RXON
69880cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *        channel.
69980cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *
70080cc0c382db318de88577eff027d5c4097abef81Ben M Cahill * NOTE:  All RXONs wipe clean the internal txpower table.  Driver must
70180cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *        issue a new REPLY_TX_PWR_TABLE_CMD after each REPLY_RXON (0x10),
70280cc0c382db318de88577eff027d5c4097abef81Ben M Cahill *        regardless of whether RXON_FILTER_ASSOC_MSK is set.
703b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
7043d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
7053d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_rxon_cmd {
7063d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 node_addr[6];
7073d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 reserved1;
7083d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 bssid_addr[6];
7093d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 reserved2;
7103d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 wlap_bssid_addr[6];
7113d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 reserved3;
7123d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 dev_type;
7133d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 air_propagation;
7143d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 reserved4;
7153d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 ofdm_basic_rates;
7163d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 cck_basic_rates;
7173d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 assoc_id;
7183d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 flags;
7193d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 filter_flags;
7203d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 channel;
7213d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 reserved5;
722ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
7233d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
724bb8c093bdea62f2ae371b98ebff81b0407852fafChristoph Hellwigstruct iwl4965_rxon_cmd {
725b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 node_addr[6];
726b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved1;
727b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 bssid_addr[6];
728b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved2;
729b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 wlap_bssid_addr[6];
730b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved3;
731b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 dev_type;
732b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 air_propagation;
733b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 rx_chain;
734b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ofdm_basic_rates;
735b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 cck_basic_rates;
736b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 assoc_id;
737b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 flags;
738b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 filter_flags;
739b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 channel;
740b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ofdm_ht_single_stream_basic_rates;
741b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ofdm_ht_dual_stream_basic_rates;
742ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
743b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
744a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler/* 5000 HW just extend this command */
745c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenmanstruct iwl_rxon_cmd {
746c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 node_addr[6];
747c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	__le16 reserved1;
748c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 bssid_addr[6];
749c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	__le16 reserved2;
750c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 wlap_bssid_addr[6];
751c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	__le16 reserved3;
752c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 dev_type;
753c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 air_propagation;
754c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	__le16 rx_chain;
755c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 ofdm_basic_rates;
756c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 cck_basic_rates;
757c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	__le16 assoc_id;
758c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	__le32 flags;
759c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	__le32 filter_flags;
760c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	__le16 channel;
761c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 ofdm_ht_single_stream_basic_rates;
762c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 ofdm_ht_dual_stream_basic_rates;
763c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 ofdm_ht_triple_stream_basic_rates;
764c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	u8 reserved5;
765c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	__le16 acquisition_data;
766c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman	__le16 reserved6;
767ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
768c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman
7693d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler/*
7703d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * REPLY_RXON_ASSOC = 0x11 (command, has simple generic response)
7713d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler */
7723d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_rxon_assoc_cmd {
7733d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 flags;
7743d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 filter_flags;
7753d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 ofdm_basic_rates;
7763d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 cck_basic_rates;
7773d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 reserved;
778ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
7793d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
7803d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl4965_rxon_assoc_cmd {
781fe7a90c2b73f0c1da0882861cd015c835ed28781Ron Rindjunsky	__le32 flags;
782fe7a90c2b73f0c1da0882861cd015c835ed28781Ron Rindjunsky	__le32 filter_flags;
783fe7a90c2b73f0c1da0882861cd015c835ed28781Ron Rindjunsky	u8 ofdm_basic_rates;
784fe7a90c2b73f0c1da0882861cd015c835ed28781Ron Rindjunsky	u8 cck_basic_rates;
785fe7a90c2b73f0c1da0882861cd015c835ed28781Ron Rindjunsky	u8 ofdm_ht_single_stream_basic_rates;
786fe7a90c2b73f0c1da0882861cd015c835ed28781Ron Rindjunsky	u8 ofdm_ht_dual_stream_basic_rates;
787fe7a90c2b73f0c1da0882861cd015c835ed28781Ron Rindjunsky	__le16 rx_chain_select_flags;
7883d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 reserved;
789ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
790c1adf9fb31e31ee753d613bd5bc6aef9b762b747Gregory Greenman
7913d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl5000_rxon_assoc_cmd {
792b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 flags;
793b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 filter_flags;
794b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ofdm_basic_rates;
795b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 cck_basic_rates;
7963d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 reserved1;
797b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ofdm_ht_single_stream_basic_rates;
798b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ofdm_ht_dual_stream_basic_rates;
7993d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 ofdm_ht_triple_stream_basic_rates;
8003d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 reserved2;
801b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 rx_chain_select_flags;
8023d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 acquisition_data;
8033d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 reserved3;
804ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
805b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
806b5d7be5e665f29274cfe6645b661acb38cb1d19bTomas Winkler#define IWL_CONN_MAX_LISTEN_INTERVAL	10
8072c2f3b33888419fb9e7d015b9dc67b9db4437efaTomas Winkler#define IWL_MAX_UCODE_BEACON_INTERVAL	4 /* 4096 */
8082c2f3b33888419fb9e7d015b9dc67b9db4437efaTomas Winkler#define IWL39_MAX_UCODE_BEACON_INTERVAL	1 /* 1024 */
809fe7a90c2b73f0c1da0882861cd015c835ed28781Ron Rindjunsky
810b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
811b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_RXON_TIMING = 0x14 (command, has simple generic response)
812b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
8133195c1f3499912b207ae600968488759b16037fcTomas Winklerstruct iwl_rxon_time_cmd {
8143195c1f3499912b207ae600968488759b16037fcTomas Winkler	__le64 timestamp;
815b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 beacon_interval;
816b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 atim_window;
817b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_init_val;
818b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 listen_interval;
819b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved;
820ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
821b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
822b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
823b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_CHANNEL_SWITCH = 0x72 (command, has simple generic response)
824b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
8253d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_channel_switch_cmd {
8263d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 band;
8273d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 expect_beacon;
8283d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 channel;
8293d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 rxon_flags;
8303d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 rxon_filter_flags;
8313d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 switch_time;
8323d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct iwl3945_power_per_rate power[IWL_MAX_RATES];
833ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
8343d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
835e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guystruct iwl4965_channel_switch_cmd {
836b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 band;
837b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 expect_beacon;
838b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 channel;
839b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 rxon_flags;
840b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 rxon_filter_flags;
841b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 switch_time;
842bb8c093bdea62f2ae371b98ebff81b0407852fafChristoph Hellwig	struct iwl4965_tx_power_db tx_power;
843ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
844b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
845e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy/**
846e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * struct iwl5000_channel_switch_cmd
847e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * @band: 0- 5.2GHz, 1- 2.4GHz
848e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * @expect_beacon: 0- resume transmits after channel switch
849e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy *		   1- wait for beacon to resume transmits
850e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * @channel: new channel number
851e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * @rxon_flags: Rx on flags
852e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * @rxon_filter_flags: filtering parameters
853e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * @switch_time: switch time in extended beacon format
854e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * @reserved: reserved bytes
855e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy */
856e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guystruct iwl5000_channel_switch_cmd {
857e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy	u8 band;
858e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy	u8 expect_beacon;
859e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy	__le16 channel;
860e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy	__le32 rxon_flags;
861e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy	__le32 rxon_filter_flags;
862e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy	__le32 switch_time;
863e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy	__le32 reserved[2][IWL_PWR_NUM_HT_OFDM_ENTRIES + IWL_PWR_CCK_ENTRIES];
864ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
865e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy
866e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy/**
867e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * struct iwl6000_channel_switch_cmd
868e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * @band: 0- 5.2GHz, 1- 2.4GHz
869e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * @expect_beacon: 0- resume transmits after channel switch
870e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy *		   1- wait for beacon to resume transmits
871e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * @channel: new channel number
872e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * @rxon_flags: Rx on flags
873e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * @rxon_filter_flags: filtering parameters
874e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * @switch_time: switch time in extended beacon format
875e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy * @reserved: reserved bytes
876e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy */
877e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guystruct iwl6000_channel_switch_cmd {
878e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy	u8 band;
879e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy	u8 expect_beacon;
880e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy	__le16 channel;
881e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy	__le32 rxon_flags;
882e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy	__le32 rxon_filter_flags;
883e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy	__le32 switch_time;
884e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy	__le32 reserved[3][IWL_PWR_NUM_HT_OFDM_ENTRIES + IWL_PWR_CCK_ENTRIES];
885ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
886e57f14895bf6bc7f16df760963427ac6ee6ff7e1Wey-Yi Guy
887b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
888b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * CHANNEL_SWITCH_NOTIFICATION = 0x73 (notification only, not a command)
889b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
8902aa6ab86bc475a115f56645591d2413981846509Tomas Winklerstruct iwl_csa_notification {
891b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 band;
892b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 channel;
893b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 status;		/* 0 - OK, 1 - fail */
894ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
895b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
896b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
897b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (2)
898b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Quality-of-Service (QOS) Commands & Responses:
899b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
900b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
9012054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill
9022054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill/**
9032054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * struct iwl_ac_qos -- QOS timing params for REPLY_QOS_PARAM
9042054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * One for each of 4 EDCA access categories in struct iwl_qosparam_cmd
9052054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *
9062054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * @cw_min: Contention window, start value in numbers of slots.
9072054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *          Should be a power-of-2, minus 1.  Device's default is 0x0f.
9082054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * @cw_max: Contention window, max value in numbers of slots.
9092054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *          Should be a power-of-2, minus 1.  Device's default is 0x3f.
9102054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * @aifsn:  Number of slots in Arbitration Interframe Space (before
9112054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *          performing random backoff timing prior to Tx).  Device default 1.
9122054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * @edca_txop:  Length of Tx opportunity, in uSecs.  Device default is 0.
9132054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *
9142054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * Device will automatically increase contention window by (2*CW) + 1 for each
9152054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * transmission retry.  Device uses cw_max as a bit mask, ANDed with new CW
9162054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * value, to cap the CW value.
9172054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill */
9181ff50bda6eef4466366e197541508fc69af0f0c0Emmanuel Grumbachstruct iwl_ac_qos {
919b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 cw_min;
920b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 cw_max;
921b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 aifsn;
922b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved1;
923b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 edca_txop;
924ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
925b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
926b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* QoS flags defines */
92751e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define QOS_PARAM_FLG_UPDATE_EDCA_MSK	cpu_to_le32(0x01)
92851e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define QOS_PARAM_FLG_TGN_MSK		cpu_to_le32(0x02)
92951e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define QOS_PARAM_FLG_TXOP_TYPE_MSK	cpu_to_le32(0x10)
930b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
9312054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill/* Number of Access Categories (AC) (EDCA), queues 0..3 */
932b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define AC_NUM                4
933b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
934b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
935b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_QOS_PARAM = 0x13 (command, has simple generic response)
9362054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *
9372054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * This command sets up timings for each of the 4 prioritized EDCA Tx FIFOs
9382054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * 0: Background, 1: Best Effort, 2: Video, 3: Voice.
939b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
9401ff50bda6eef4466366e197541508fc69af0f0c0Emmanuel Grumbachstruct iwl_qosparam_cmd {
941b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 qos_flags;
9421ff50bda6eef4466366e197541508fc69af0f0c0Emmanuel Grumbach	struct iwl_ac_qos ac[AC_NUM];
943ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
944b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
945b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
946b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (3)
947b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Add/Modify Stations Commands & Responses:
948b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
949b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
950b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
951b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Multi station support
952b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
9532054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill
9542054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill/* Special, dedicated locations within device's station table */
955b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	IWL_AP_ID		0
956b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	IWL_STA_ID		2
9574c897253cc9ae1c6a2798b27b5fe8e6d94ab6185Tomas Winkler#define	IWL3945_BROADCAST_ID	24
9584c897253cc9ae1c6a2798b27b5fe8e6d94ab6185Tomas Winkler#define IWL3945_STATION_COUNT	25
959b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define IWL4965_BROADCAST_ID	31
960b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	IWL4965_STATION_COUNT	32
961bf3c7fddf9dffb0e5c76da3a94b8f5817a72f92cWey-Yi Guy#define IWLAGN_BROADCAST_ID	15
962bf3c7fddf9dffb0e5c76da3a94b8f5817a72f92cWey-Yi Guy#define	IWLAGN_STATION_COUNT	16
963b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
964b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	IWL_STATION_COUNT	32 	/* MAX(3945,4965)*/
965b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	IWL_INVALID_STATION 	255
966b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
9671bd14eaf9e2e790c79c6060b9c630afddc67dfacJohannes Berg#define STA_FLG_TX_RATE_MSK		cpu_to_le32(1 << 2)
9681bd14eaf9e2e790c79c6060b9c630afddc67dfacJohannes Berg#define STA_FLG_PWR_SAVE_MSK		cpu_to_le32(1 << 8)
96951e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_FLG_RTS_MIMO_PROT_MSK	cpu_to_le32(1 << 17)
97051e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_FLG_AGG_MPDU_8US_MSK	cpu_to_le32(1 << 18)
97174093ddf4c42da74922b63fb6844989e21164d9eBen M Cahill#define STA_FLG_MAX_AGG_SIZE_POS	(19)
97251e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_FLG_MAX_AGG_SIZE_MSK	cpu_to_le32(3 << 19)
9737aafef1c6e2e24f9a10dc2972bf0ee70624ccc47Wey-Yi Guy#define STA_FLG_HT40_EN_MSK		cpu_to_le32(1 << 21)
97451e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_FLG_MIMO_DIS_MSK		cpu_to_le32(1 << 22)
97574093ddf4c42da74922b63fb6844989e21164d9eBen M Cahill#define STA_FLG_AGG_MPDU_DENSITY_POS	(23)
97651e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_FLG_AGG_MPDU_DENSITY_MSK	cpu_to_le32(7 << 23)
977b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
9782054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill/* Use in mode field.  1: modify existing entry, 0: add new station entry */
979b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define STA_CONTROL_MODIFY_MSK		0x01
980b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
981b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* key flags __le16*/
98251e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_KEY_FLG_ENCRYPT_MSK	cpu_to_le16(0x0007)
98351e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_KEY_FLG_NO_ENC	cpu_to_le16(0x0000)
98451e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_KEY_FLG_WEP		cpu_to_le16(0x0001)
98551e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_KEY_FLG_CCMP	cpu_to_le16(0x0002)
98651e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_KEY_FLG_TKIP	cpu_to_le16(0x0003)
987b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
988b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define STA_KEY_FLG_KEYID_POS	8
98951e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_KEY_FLG_INVALID 	cpu_to_le16(0x0800)
990eaaf7894959d413d1e01443a622c507e1b4f61dbEmmanuel Grumbach/* wep key is either from global key (0) or from station info array (1) */
99151e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_KEY_FLG_MAP_KEY_MSK	cpu_to_le16(0x0008)
992eaaf7894959d413d1e01443a622c507e1b4f61dbEmmanuel Grumbach
993eaaf7894959d413d1e01443a622c507e1b4f61dbEmmanuel Grumbach/* wep key in STA: 5-bytes (0) or 13-bytes (1) */
99451e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_KEY_FLG_KEY_SIZE_MSK     cpu_to_le16(0x1000)
99551e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STA_KEY_MULTICAST_MSK        cpu_to_le16(0x4000)
996deb09c435e3f947f8b2c9d5df6a9c0a5b472b125Emmanuel Grumbach#define STA_KEY_MAX_NUM		8
997b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
9982054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill/* Flags indicate whether to modify vs. don't change various station params */
999b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	STA_MODIFY_KEY_MASK		0x01
1000b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	STA_MODIFY_TID_DISABLE_TX	0x02
1001b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	STA_MODIFY_TX_RATE_MSK		0x04
1002b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define STA_MODIFY_ADDBA_TID_MSK	0x08
1003b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define STA_MODIFY_DELBA_TID_MSK	0x10
10046ab10ff8738dfb098fd32132b7ebcf5cdb43ebdeJohannes Berg#define STA_MODIFY_SLEEP_TX_COUNT_MSK	0x20
10052054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill
10062054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill/* Receiver address (actually, Rx station's index into station table),
10072054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * combined with Traffic ID (QOS priority), in format used by Tx Scheduler */
1008b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define BUILD_RAxTID(sta_id, tid)	(((sta_id) << 4) + (tid))
1009b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1010bb8c093bdea62f2ae371b98ebff81b0407852fafChristoph Hellwigstruct iwl4965_keyinfo {
1011b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 key_flags;
1012b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 tkip_rx_tsc_byte2;	/* TSC[2] for key mix ph1 detection */
1013b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved1;
1014b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 tkip_rx_ttak[5];	/* 10-byte unicast TKIP TTAK */
1015eaaf7894959d413d1e01443a622c507e1b4f61dbEmmanuel Grumbach	u8 key_offset;
1016eaaf7894959d413d1e01443a622c507e1b4f61dbEmmanuel Grumbach	u8 reserved2;
1017b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 key[16];		/* 16-byte unicast decryption key */
1018ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
1019b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1020133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler/* 5000 */
1021133636deffc86809f59a0c8b768408d13237a9a2Tomas Winklerstruct iwl_keyinfo {
1022133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	__le16 key_flags;
1023133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	u8 tkip_rx_tsc_byte2;	/* TSC[2] for key mix ph1 detection */
1024133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	u8 reserved1;
1025133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	__le16 tkip_rx_ttak[5];	/* 10-byte unicast TKIP TTAK */
1026133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	u8 key_offset;
1027133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	u8 reserved2;
1028133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	u8 key[16];		/* 16-byte unicast decryption key */
1029133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	__le64 tx_secur_seq_cnt;
1030133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	__le64 hw_tkip_mic_rx_key;
1031133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	__le64 hw_tkip_mic_tx_key;
1032ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
1033133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler
10342054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill/**
10352054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * struct sta_id_modify
10362054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * @addr[ETH_ALEN]: station's MAC address
10372054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * @sta_id: index of station in uCode's station table
10382054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * @modify_mask: STA_MODIFY_*, 1: modify, 0: don't change
10392054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *
10402054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * Driver selects unused table index when adding new station,
10412054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * or the index to a pre-existing station entry when modifying that station.
10422054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * Some indexes have special purposes (IWL_AP_ID, index 0, is for AP).
10432054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *
10442054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * modify_mask flags select which parameters to modify vs. leave alone.
10452054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill */
1046b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct sta_id_modify {
1047b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 addr[ETH_ALEN];
1048b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved1;
1049b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 sta_id;
1050b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 modify_mask;
1051b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved2;
1052ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
1053b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1054b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
1055b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_ADD_STA = 0x18 (command)
10562054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *
10572054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * The device contains an internal table of per-station information,
10582054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * with info on security keys, aggregation parameters, and Tx rates for
10592054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * initial Tx attempt and any retries (4965 uses REPLY_TX_LINK_QUALITY_CMD,
10602054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * 3945 uses REPLY_RATE_SCALE to set up rate tables).
10612054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *
10622054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * REPLY_ADD_STA sets up the table entry for one station, either creating
10632054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * a new entry, or modifying a pre-existing one.
10642054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *
10652054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill * NOTE:  RXON command (without "associated" bit set) wipes the station table
10662054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        clean.  Moving into RF_KILL state does this also.  Driver must set up
10672054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        new station table before transmitting anything on the RXON channel
10682054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        (except active scans or active measurements; those commands carry
10692054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        their own txpower/rate setup data).
10702054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *
10712054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        When getting started on a new channel, driver must set up the
10722054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        IWL_BROADCAST_ID entry (last entry in the table).  For a client
10732054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        station in a BSS, once an AP is selected, driver sets up the AP STA
10742054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        in the IWL_AP_ID entry (1st entry in the table).  BROADCAST and AP
10752054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        are all that are needed for a BSS client station.  If the device is
10762054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        used as AP, or in an IBSS network, driver must set up station table
10772054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill *        entries for all STAs in network, starting with index IWL_STA_ID.
1078b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
10793d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
10803d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_addsta_cmd {
10813d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 mode;		/* 1: modify existing, 0: add new station */
10823d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 reserved[3];
10833d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct sta_id_modify sta;
10843d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct iwl4965_keyinfo key;
10853d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 station_flags;		/* STA_FLG_* */
10863d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 station_flags_msk;	/* STA_FLG_* */
10873d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
10883d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	/* bit field to disable (1) or enable (0) Tx for Traffic ID (TID)
10893d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * corresponding to bit (e.g. bit 5 controls TID 5).
10903d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */
10913d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 tid_disable_tx;
10923d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
10933d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 rate_n_flags;
10943d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
10953d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	/* TID for which to add block-ack support.
10963d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
10973d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 add_immediate_ba_tid;
10983d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
10993d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	/* TID for which to remove block-ack support.
11003d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * Set modify_mask bit STA_MODIFY_DELBA_TID_MSK to use this field. */
11013d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 remove_immediate_ba_tid;
11023d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
11033d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	/* Starting Sequence Number for added block-ack support.
11043d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
11053d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 add_immediate_ba_ssn;
1106ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
11073d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
1108bb8c093bdea62f2ae371b98ebff81b0407852fafChristoph Hellwigstruct iwl4965_addsta_cmd {
11092054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	u8 mode;		/* 1: modify existing, 0: add new station */
1110b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved[3];
1111b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct sta_id_modify sta;
1112bb8c093bdea62f2ae371b98ebff81b0407852fafChristoph Hellwig	struct iwl4965_keyinfo key;
11132054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	__le32 station_flags;		/* STA_FLG_* */
11142054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	__le32 station_flags_msk;	/* STA_FLG_* */
11152054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill
11162054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	/* bit field to disable (1) or enable (0) Tx for Traffic ID (TID)
11172054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	 * corresponding to bit (e.g. bit 5 controls TID 5).
11182054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	 * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */
1119b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 tid_disable_tx;
11202054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill
1121b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16	reserved1;
11222054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill
11232054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	/* TID for which to add block-ack support.
11242054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
1125b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 add_immediate_ba_tid;
11262054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill
11272054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	/* TID for which to remove block-ack support.
11282054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	 * Set modify_mask bit STA_MODIFY_DELBA_TID_MSK to use this field. */
1129b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 remove_immediate_ba_tid;
11302054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill
11312054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	/* Starting Sequence Number for added block-ack support.
11322054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
1133b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 add_immediate_ba_ssn;
11342054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill
11359bb487b406692e172b15eba58de7d69358ac2005Johannes Berg	/*
11369bb487b406692e172b15eba58de7d69358ac2005Johannes Berg	 * Number of packets OK to transmit to station even though
11379bb487b406692e172b15eba58de7d69358ac2005Johannes Berg	 * it is asleep -- used to synchronise PS-poll and u-APSD
11389bb487b406692e172b15eba58de7d69358ac2005Johannes Berg	 * responses while ucode keeps track of STA sleep state.
11399bb487b406692e172b15eba58de7d69358ac2005Johannes Berg	 */
11409bb487b406692e172b15eba58de7d69358ac2005Johannes Berg	__le16 sleep_tx_count;
11419bb487b406692e172b15eba58de7d69358ac2005Johannes Berg
11429bb487b406692e172b15eba58de7d69358ac2005Johannes Berg	__le16 reserved2;
1143ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
1144b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1145133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler/* 5000 */
1146133636deffc86809f59a0c8b768408d13237a9a2Tomas Winklerstruct iwl_addsta_cmd {
1147133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	u8 mode;		/* 1: modify existing, 0: add new station */
1148133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	u8 reserved[3];
1149133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	struct sta_id_modify sta;
1150133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	struct iwl_keyinfo key;
1151133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	__le32 station_flags;		/* STA_FLG_* */
1152133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	__le32 station_flags_msk;	/* STA_FLG_* */
1153133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler
1154133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	/* bit field to disable (1) or enable (0) Tx for Traffic ID (TID)
1155133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	 * corresponding to bit (e.g. bit 5 controls TID 5).
1156133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	 * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */
1157133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	__le16 tid_disable_tx;
1158133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler
1159c587de0b8d6e194f7a1719fc6af8a81b4e8916d2Tomas Winkler	__le16	rate_n_flags;		/* 3945 only */
1160133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler
1161133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	/* TID for which to add block-ack support.
1162133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
1163133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	u8 add_immediate_ba_tid;
1164133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler
1165133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	/* TID for which to remove block-ack support.
1166133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	 * Set modify_mask bit STA_MODIFY_DELBA_TID_MSK to use this field. */
1167133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	u8 remove_immediate_ba_tid;
1168133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler
1169133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	/* Starting Sequence Number for added block-ack support.
1170133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	 * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */
1171133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler	__le16 add_immediate_ba_ssn;
1172133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler
11739bb487b406692e172b15eba58de7d69358ac2005Johannes Berg	/*
11749bb487b406692e172b15eba58de7d69358ac2005Johannes Berg	 * Number of packets OK to transmit to station even though
11759bb487b406692e172b15eba58de7d69358ac2005Johannes Berg	 * it is asleep -- used to synchronise PS-poll and u-APSD
11769bb487b406692e172b15eba58de7d69358ac2005Johannes Berg	 * responses while ucode keeps track of STA sleep state.
11779bb487b406692e172b15eba58de7d69358ac2005Johannes Berg	 */
11789bb487b406692e172b15eba58de7d69358ac2005Johannes Berg	__le16 sleep_tx_count;
11799bb487b406692e172b15eba58de7d69358ac2005Johannes Berg
11809bb487b406692e172b15eba58de7d69358ac2005Johannes Berg	__le16 reserved2;
1181ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
1182133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler
1183133636deffc86809f59a0c8b768408d13237a9a2Tomas Winkler
11842054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill#define ADD_STA_SUCCESS_MSK		0x1
11852054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill#define ADD_STA_NO_ROOM_IN_TABLE	0x2
11862054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill#define ADD_STA_NO_BLOCK_ACK_RESOURCE	0x4
11872054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill#define ADD_STA_MODIFY_NON_EXIST_STA	0x8
1188b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
1189b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_ADD_STA = 0x18 (response)
1190b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
11917a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winklerstruct iwl_add_sta_resp {
11922054a00bb83409345d14a944e25c15e6ea317651Ben M Cahill	u8 status;	/* ADD_STA_* */
1193ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
1194b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
11957a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler#define REM_STA_SUCCESS_MSK              0x1
11967a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler/*
11977a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler *  REPLY_REM_STA = 0x19 (response)
11987a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler */
11997a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winklerstruct iwl_rem_sta_resp {
12007a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler	u8 status;
1201ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
12027a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler
12037a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler/*
12047a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler *  REPLY_REM_STA = 0x19 (command)
12057a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler */
12067a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winklerstruct iwl_rem_sta_cmd {
12077a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler	u8 num_sta;     /* number of removed stations */
12087a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler	u8 reserved[3];
12097a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler	u8 addr[ETH_ALEN]; /* MAC addr of the first station */
12107a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler	u8 reserved2[2];
1211ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
12127a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler
1213947279eefb77f79015a79b032eb825a065ab035fWey-Yi Guy#define IWL_TX_FIFO_BK_MSK		cpu_to_le32(BIT(0))
1214947279eefb77f79015a79b032eb825a065ab035fWey-Yi Guy#define IWL_TX_FIFO_BE_MSK		cpu_to_le32(BIT(1))
1215947279eefb77f79015a79b032eb825a065ab035fWey-Yi Guy#define IWL_TX_FIFO_VI_MSK		cpu_to_le32(BIT(2))
1216947279eefb77f79015a79b032eb825a065ab035fWey-Yi Guy#define IWL_TX_FIFO_VO_MSK		cpu_to_le32(BIT(3))
1217947279eefb77f79015a79b032eb825a065ab035fWey-Yi Guy#define IWL_AGG_TX_QUEUE_MSK		cpu_to_le32(0xffc00)
1218947279eefb77f79015a79b032eb825a065ab035fWey-Yi Guy
1219716c74b00717ad9caedb4a46059fb64a3da99808Wey-Yi Guy#define IWL_DROP_SINGLE		0
1220716c74b00717ad9caedb4a46059fb64a3da99808Wey-Yi Guy#define IWL_DROP_SELECTED	1
1221716c74b00717ad9caedb4a46059fb64a3da99808Wey-Yi Guy#define IWL_DROP_ALL		2
1222716c74b00717ad9caedb4a46059fb64a3da99808Wey-Yi Guy
1223947279eefb77f79015a79b032eb825a065ab035fWey-Yi Guy/*
1224947279eefb77f79015a79b032eb825a065ab035fWey-Yi Guy * REPLY_TXFIFO_FLUSH = 0x1e(command and response)
1225947279eefb77f79015a79b032eb825a065ab035fWey-Yi Guy *
1226947279eefb77f79015a79b032eb825a065ab035fWey-Yi Guy * When using full FIFO flush this command checks the scheduler HW block WR/RD
1227947279eefb77f79015a79b032eb825a065ab035fWey-Yi Guy * pointers to check if all the frames were transferred by DMA into the
1228947279eefb77f79015a79b032eb825a065ab035fWey-Yi Guy * relevant TX FIFO queue. Only when the DMA is finished and the queue is
1229947279eefb77f79015a79b032eb825a065ab035fWey-Yi Guy * empty the command can finish.
1230947279eefb77f79015a79b032eb825a065ab035fWey-Yi Guy * This command is used to flush the TXFIFO from transmit commands, it may
1231947279eefb77f79015a79b032eb825a065ab035fWey-Yi Guy * operate on single or multiple queues, the command queue can't be flushed by
1232947279eefb77f79015a79b032eb825a065ab035fWey-Yi Guy * this command. The command response is returned when all the queue flush
1233947279eefb77f79015a79b032eb825a065ab035fWey-Yi Guy * operations are done. Each TX command flushed return response with the FLUSH
1234947279eefb77f79015a79b032eb825a065ab035fWey-Yi Guy * status set in the TX response status. When FIFO flush operation is used,
1235947279eefb77f79015a79b032eb825a065ab035fWey-Yi Guy * the flush operation ends when both the scheduler DMA done and TXFIFO empty
1236947279eefb77f79015a79b032eb825a065ab035fWey-Yi Guy * are set.
1237947279eefb77f79015a79b032eb825a065ab035fWey-Yi Guy *
1238947279eefb77f79015a79b032eb825a065ab035fWey-Yi Guy * @fifo_control: bit mask for which queues to flush
1239947279eefb77f79015a79b032eb825a065ab035fWey-Yi Guy * @flush_control: flush controls
1240947279eefb77f79015a79b032eb825a065ab035fWey-Yi Guy *	0: Dump single MSDU
1241947279eefb77f79015a79b032eb825a065ab035fWey-Yi Guy *	1: Dump multiple MSDU according to PS, INVALID STA, TTL, TID disable.
1242947279eefb77f79015a79b032eb825a065ab035fWey-Yi Guy *	2: Dump all FIFO
1243947279eefb77f79015a79b032eb825a065ab035fWey-Yi Guy */
1244947279eefb77f79015a79b032eb825a065ab035fWey-Yi Guystruct iwl_txfifo_flush_cmd {
1245947279eefb77f79015a79b032eb825a065ab035fWey-Yi Guy	__le32 fifo_control;
1246947279eefb77f79015a79b032eb825a065ab035fWey-Yi Guy	__le16 flush_control;
1247947279eefb77f79015a79b032eb825a065ab035fWey-Yi Guy	__le16 reserved;
12480e954099b7910524b7fae831fbf2933bd25cb6d0John W. Linville} __packed;
1249947279eefb77f79015a79b032eb825a065ab035fWey-Yi Guy
12500a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach/*
12510a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach * REPLY_WEP_KEY = 0x20
12520a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach */
12530a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbachstruct iwl_wep_key {
12540a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach	u8 key_index;
12550a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach	u8 key_offset;
12560a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach	u8 reserved1[2];
12570a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach	u8 key_size;
12580a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach	u8 reserved2[3];
12590a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach	u8 key[16];
1260ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
12610a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach
12620a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbachstruct iwl_wep_cmd {
12630a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach	u8 num_keys;
12640a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach	u8 global_key_type;
12650a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach	u8 flags;
12660a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach	u8 reserved;
12670a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach	struct iwl_wep_key key[0];
1268ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
12690a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach
12700a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach#define WEP_KEY_WEP_TYPE 1
12710a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach#define WEP_KEYS_MAX 4
12720a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach#define WEP_INVALID_OFFSET 0xff
12734564ce8b0e17d91d047aa875843deb2cccf3f268Emmanuel Grumbach#define WEP_KEY_LEN_64 5
12740a0bed1d10105a9f58cd14ebe216e8479dd31fdaEmmanuel Grumbach#define WEP_KEY_LEN_128 13
1275b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1276b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
1277b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (4)
1278b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Rx Responses:
1279b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
1280b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
1281b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
128251e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RX_RES_STATUS_NO_CRC32_ERROR	cpu_to_le32(1 << 0)
128351e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RX_RES_STATUS_NO_RXE_OVERFLOW	cpu_to_le32(1 << 1)
12848211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler
128551e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RX_RES_PHY_FLAGS_BAND_24_MSK	cpu_to_le16(1 << 0)
128651e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RX_RES_PHY_FLAGS_MOD_CCK_MSK		cpu_to_le16(1 << 1)
128751e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK	cpu_to_le16(1 << 2)
128851e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define RX_RES_PHY_FLAGS_NARROW_BAND_MSK	cpu_to_le16(1 << 3)
12899024adf5c81c94f7b5c6fd26942b075e2a26e085Reinette Chatre#define RX_RES_PHY_FLAGS_ANTENNA_MSK		0xf0
12909f30e04e041cf9943940f71fd76094dd5a237018Daniel C Halperin#define RX_RES_PHY_FLAGS_ANTENNA_POS		4
12918211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler
12928211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler#define RX_RES_STATUS_SEC_TYPE_MSK	(0x7 << 8)
12938211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler#define RX_RES_STATUS_SEC_TYPE_NONE	(0x0 << 8)
12948211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler#define RX_RES_STATUS_SEC_TYPE_WEP	(0x1 << 8)
12958211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler#define RX_RES_STATUS_SEC_TYPE_CCMP	(0x2 << 8)
12968211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler#define RX_RES_STATUS_SEC_TYPE_TKIP	(0x3 << 8)
129717e476b8db13790c03e2c46d93abc71468fca47eEmmanuel Grumbach#define	RX_RES_STATUS_SEC_TYPE_ERR	(0x7 << 8)
129817e476b8db13790c03e2c46d93abc71468fca47eEmmanuel Grumbach
129917e476b8db13790c03e2c46d93abc71468fca47eEmmanuel Grumbach#define RX_RES_STATUS_STATION_FOUND	(1<<6)
130017e476b8db13790c03e2c46d93abc71468fca47eEmmanuel Grumbach#define RX_RES_STATUS_NO_STATION_INFO_MISMATCH	(1<<7)
13018211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler
13028211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler#define RX_RES_STATUS_DECRYPT_TYPE_MSK	(0x3 << 11)
13038211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler#define RX_RES_STATUS_NOT_DECRYPT	(0x0 << 11)
13048211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler#define RX_RES_STATUS_DECRYPT_OK	(0x3 << 11)
13058211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler#define RX_RES_STATUS_BAD_ICV_MIC	(0x1 << 11)
13068211ef78d9023a8772e5acf6b7934598156b2fc8Tomas Winkler#define RX_RES_STATUS_BAD_KEY_TTAK	(0x2 << 11)
1307b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
130817e476b8db13790c03e2c46d93abc71468fca47eEmmanuel Grumbach#define RX_MPDU_RES_STATUS_ICV_OK	(0x20)
130917e476b8db13790c03e2c46d93abc71468fca47eEmmanuel Grumbach#define RX_MPDU_RES_STATUS_MIC_OK	(0x40)
131017e476b8db13790c03e2c46d93abc71468fca47eEmmanuel Grumbach#define RX_MPDU_RES_STATUS_TTAK_OK	(1 << 7)
131117e476b8db13790c03e2c46d93abc71468fca47eEmmanuel Grumbach#define RX_MPDU_RES_STATUS_DEC_DONE_MSK	(0x800)
131217e476b8db13790c03e2c46d93abc71468fca47eEmmanuel Grumbach
13133d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
13143d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_rx_frame_stats {
13153d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 phy_count;
13163d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 id;
13173d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 rssi;
13183d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 agc;
13193d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 sig_avg;
13203d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 noise_diff;
13213d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 payload[0];
1322ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
13233d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
13243d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_rx_frame_hdr {
13253d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 channel;
13263d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 phy_flags;
13273d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 reserved1;
13283d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 rate;
13293d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 len;
13303d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 payload[0];
1331ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
13323d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
13333d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_rx_frame_end {
13343d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 status;
13353d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le64 timestamp;
13363d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 beacon_timestamp;
1337ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
13383d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
13393d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler/*
13403d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * REPLY_3945_RX = 0x1b (response only, not a command)
13413d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler *
13423d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * NOTE:  DO NOT dereference from casts to this structure
13433d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * It is provided only for calculating minimum data set size.
13443d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * The actual offsets of the hdr and end are dynamic based on
13453d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * stats.phy_count
13463d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler */
13473d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_rx_frame {
13483d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct iwl3945_rx_frame_stats stats;
13493d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct iwl3945_rx_frame_hdr hdr;
13503d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct iwl3945_rx_frame_end end;
1351ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
13523d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
13533d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler#define IWL39_RX_FRAME_SIZE	(4 + sizeof(struct iwl3945_rx_frame))
13543d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
1355b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* Fixed (non-configurable) rx data from phy */
1356caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler
1357caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL49_RX_RES_PHY_CNT 14
1358caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL49_RX_PHY_FLAGS_ANTENNAE_OFFSET	(4)
1359caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL49_RX_PHY_FLAGS_ANTENNAE_MASK	(0x70)
1360caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL49_AGC_DB_MASK			(0x3f80)	/* MASK(7,13) */
1361caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL49_AGC_DB_POS			(7)
1362b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct iwl4965_rx_non_cfg_phy {
1363b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 ant_selection;	/* ant A bit 4, ant B bit 5, ant C bit 6 */
1364b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 agc_info;	/* agc code 0:6, agc dB 7:13, reserved 14:15 */
1365b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 rssi_info[6];	/* we use even entries, 0/2/4 for A/B/C rssi */
1366b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 pad[0];
1367ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
1368b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1369caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler
1370caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL50_RX_RES_PHY_CNT 8
1371caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL50_RX_RES_AGC_IDX     1
1372caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL50_RX_RES_RSSI_AB_IDX 2
1373caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL50_RX_RES_RSSI_C_IDX  3
1374caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL50_OFDM_AGC_MSK 0xfe00
1375caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL50_OFDM_AGC_BIT_POS 9
1376caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL50_OFDM_RSSI_A_MSK 0x00ff
1377caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL50_OFDM_RSSI_A_BIT_POS 0
1378caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL50_OFDM_RSSI_B_MSK 0xff0000
1379caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL50_OFDM_RSSI_B_BIT_POS 16
1380caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL50_OFDM_RSSI_C_MSK 0x00ff
1381caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler#define IWL50_OFDM_RSSI_C_BIT_POS 0
1382caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler
1383caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winklerstruct iwl5000_non_cfg_phy {
1384a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler	__le32 non_cfg_phy[IWL50_RX_RES_PHY_CNT];  /* up to 8 phy entries */
1385ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
1386caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler
1387caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler
1388b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
1389857485c0c46ceee5c658c1761bba4d9a5ddf433fTomas Winkler * REPLY_RX = 0xc3 (response only, not a command)
1390b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Used only for legacy (non 11n) frames.
1391b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
1392caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winklerstruct iwl_rx_phy_res {
1393b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 non_cfg_phy_cnt;     /* non configurable DSP phy data byte count */
1394b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 cfg_phy_cnt;		/* configurable DSP phy data byte count */
1395b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 stat_id;		/* configurable DSP phy data set ID */
1396b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved1;
1397b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le64 timestamp;	/* TSF at on air rise */
1398b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_time_stamp; /* beacon at on-air rise */
1399b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 phy_flags;	/* general phy flags: band, modulation, ... */
1400b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 channel;		/* channel number */
1401caab8f1a5d0da583b6ffe41afea2774c676444caTomas Winkler	u8 non_cfg_phy_buf[32]; /* for various implementations of non_cfg_phy */
1402529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	__le32 rate_n_flags;	/* RATE_MCS_* */
1403529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	__le16 byte_count;	/* frame's byte-count */
140430c1b0f7e96144e42e2be0bdec18d2475f5af31bWey-Yi Guy	__le16 frame_time;	/* frame's time on the air */
1405ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
1406b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
14072fb291eea70353618fe10d94f05d16caf51f435fEmmanuel Grumbachstruct iwl_rx_mpdu_res_start {
1408b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 byte_count;
1409b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved;
1410ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
1411b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1412b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1413b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
1414b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (5)
1415b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Tx Commands & Responses:
1416b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
1417529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Driver must place each REPLY_TX command into one of the prioritized Tx
1418529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * queues in host DRAM, shared between driver and device (see comments for
1419529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * SCD registers and Tx/Rx Queues).  When the device's Tx scheduler and uCode
1420529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * are preparing to transmit, the device pulls the Tx command over the PCI
1421529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * bus via one of the device's Tx DMA channels, to fill an internal FIFO
1422529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * from which data will be transmitted.
1423529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *
1424529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * uCode handles all timing and protocol related to control frames
1425529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * (RTS/CTS/ACK), based on flags in the Tx command.  uCode and Tx scheduler
1426529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * handle reception of block-acks; uCode updates the host driver via
1427529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * REPLY_COMPRESSED_BA (4965).
1428529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *
1429529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * uCode handles retrying Tx when an ACK is expected but not received.
1430529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * This includes trying lower data rates than the one requested in the Tx
1431529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * command, as set up by the REPLY_RATE_SCALE (for 3945) or
1432529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * REPLY_TX_LINK_QUALITY_CMD (4965).
1433529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *
1434529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Driver sets up transmit power for various rates via REPLY_TX_PWR_TABLE_CMD.
1435529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * This command must be executed after every RXON command, before Tx can occur.
1436b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
1437b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1438529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* REPLY_TX Tx flags field */
1439529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
14404e3243f549540235d180e446715a14c1b5827902Wey-Yi Guy/*
14414e3243f549540235d180e446715a14c1b5827902Wey-Yi Guy * 1: Use RTS/CTS protocol or CTS-to-self if spec allows it
1442a326a5d096f031af46c0073dd78eb80dea1f311aEmmanuel Grumbach * before this frame. if CTS-to-self required check
14434e3243f549540235d180e446715a14c1b5827902Wey-Yi Guy * RXON_FLG_SELF_CTS_EN status.
14444e3243f549540235d180e446715a14c1b5827902Wey-Yi Guy * unused in 3945/4965, used in 5000 series and after
14454e3243f549540235d180e446715a14c1b5827902Wey-Yi Guy */
14464e3243f549540235d180e446715a14c1b5827902Wey-Yi Guy#define TX_CMD_FLG_PROT_REQUIRE_MSK cpu_to_le32(1 << 0)
1447a326a5d096f031af46c0073dd78eb80dea1f311aEmmanuel Grumbach
14484e3243f549540235d180e446715a14c1b5827902Wey-Yi Guy/*
14494e3243f549540235d180e446715a14c1b5827902Wey-Yi Guy * 1: Use Request-To-Send protocol before this frame.
14504e3243f549540235d180e446715a14c1b5827902Wey-Yi Guy * Mutually exclusive vs. TX_CMD_FLG_CTS_MSK.
14514e3243f549540235d180e446715a14c1b5827902Wey-Yi Guy * used in 3945/4965, unused in 5000 series and after
14524e3243f549540235d180e446715a14c1b5827902Wey-Yi Guy */
145351e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_RTS_MSK cpu_to_le32(1 << 1)
1454529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
14554e3243f549540235d180e446715a14c1b5827902Wey-Yi Guy/*
14564e3243f549540235d180e446715a14c1b5827902Wey-Yi Guy * 1: Transmit Clear-To-Send to self before this frame.
1457529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Driver should set this for AUTH/DEAUTH/ASSOC-REQ/REASSOC mgmnt frames.
14584e3243f549540235d180e446715a14c1b5827902Wey-Yi Guy * Mutually exclusive vs. TX_CMD_FLG_RTS_MSK.
14594e3243f549540235d180e446715a14c1b5827902Wey-Yi Guy * used in 3945/4965, unused in 5000 series and after
14604e3243f549540235d180e446715a14c1b5827902Wey-Yi Guy */
146151e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_CTS_MSK cpu_to_le32(1 << 2)
1462529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1463529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* 1: Expect ACK from receiving station
1464529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * 0: Don't expect ACK (MAC header's duration field s/b 0)
1465529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Set this for unicast frames, but not broadcast/multicast. */
146651e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_ACK_MSK cpu_to_le32(1 << 3)
1467529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1468529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* For 4965:
1469529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * 1: Use rate scale table (see REPLY_TX_LINK_QUALITY_CMD).
1470529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *    Tx command's initial_rate_index indicates first rate to try;
1471529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *    uCode walks through table for additional Tx attempts.
1472529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * 0: Use Tx rate/MCS from Tx command's rate_n_flags field.
1473529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *    This rate will be used for all Tx attempts; it will not be scaled. */
147451e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_STA_RATE_MSK cpu_to_le32(1 << 4)
1475529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1476529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* 1: Expect immediate block-ack.
1477529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Set when Txing a block-ack request frame.  Also set TX_CMD_FLG_ACK_MSK. */
147851e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_IMM_BA_RSP_MASK  cpu_to_le32(1 << 6)
1479529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
14804e3243f549540235d180e446715a14c1b5827902Wey-Yi Guy/*
14814e3243f549540235d180e446715a14c1b5827902Wey-Yi Guy * 1: Frame requires full Tx-Op protection.
14824e3243f549540235d180e446715a14c1b5827902Wey-Yi Guy * Set this if either RTS or CTS Tx Flag gets set.
14834e3243f549540235d180e446715a14c1b5827902Wey-Yi Guy * used in 3945/4965, unused in 5000 series and after
14844e3243f549540235d180e446715a14c1b5827902Wey-Yi Guy */
148551e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_FULL_TXOP_PROT_MSK cpu_to_le32(1 << 7)
1486529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1487529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* Tx antenna selection field; used only for 3945, reserved (0) for 4965.
1488529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Set field to "0" to allow 3945 uCode to select antenna (normal usage). */
148951e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_ANT_SEL_MSK cpu_to_le32(0xf00)
149051e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_ANT_A_MSK cpu_to_le32(1 << 8)
149151e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_ANT_B_MSK cpu_to_le32(1 << 9)
1492b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1493529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* 1: Ignore Bluetooth priority for this frame.
1494529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * 0: Delay Tx until Bluetooth device is done (normal usage). */
1495b2e8690d5a4d1868ee12f50aa00c138bec985b3cJohannes Berg#define TX_CMD_FLG_IGNORE_BT cpu_to_le32(1 << 12)
1496b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1497529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* 1: uCode overrides sequence control field in MAC header.
1498529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * 0: Driver provides sequence control field in MAC header.
1499529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Set this for management frames, non-QOS data frames, non-unicast frames,
1500529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * and also in Tx command embedded in REPLY_SCAN_CMD for active scans. */
150151e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_SEQ_CTL_MSK cpu_to_le32(1 << 13)
1502b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1503529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* 1: This frame is non-last MPDU; more fragments are coming.
1504529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * 0: Last fragment, or not using fragmentation. */
150551e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_MORE_FRAG_MSK cpu_to_le32(1 << 14)
1506b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1507529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* 1: uCode calculates and inserts Timestamp Function (TSF) in outgoing frame.
1508529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * 0: No TSF required in outgoing frame.
1509529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Set this for transmitting beacons and probe responses. */
151051e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_TSF_MSK cpu_to_le32(1 << 16)
1511b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1512529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* 1: Driver inserted 2 bytes pad after the MAC header, for (required) dword
1513529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *    alignment of frame's payload data field.
1514529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * 0: No pad
1515529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Set this for MAC headers with 26 or 30 bytes, i.e. those with QOS or ADDR4
1516529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * field (but not both).  Driver must align frame data (i.e. data following
1517529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * MAC header) to DWORD boundary. */
151851e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_MH_PAD_MSK cpu_to_le32(1 << 20)
1519b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
15208236e183fc53be2b5d81a4f547f9c5b645e10fe0Max Stepanov/* accelerate aggregation support
15218236e183fc53be2b5d81a4f547f9c5b645e10fe0Max Stepanov * 0 - no CCMP encryption; 1 - CCMP encryption */
152251e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_AGG_CCMP_MSK cpu_to_le32(1 << 22)
15238236e183fc53be2b5d81a4f547f9c5b645e10fe0Max Stepanov
1524b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* HCCA-AP - disable duration overwriting. */
152551e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_FLG_DUR_MSK cpu_to_le32(1 << 25)
1526b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1527529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1528b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
1529b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * TX command security control
1530b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
1531b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define TX_CMD_SEC_WEP  	0x01
1532b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define TX_CMD_SEC_CCM  	0x02
1533b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define TX_CMD_SEC_TKIP		0x03
1534b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define TX_CMD_SEC_MSK		0x03
1535b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define TX_CMD_SEC_SHIFT	6
1536b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define TX_CMD_SEC_KEY128	0x08
1537b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1538b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
15393195cdb7424b4207f6903f1f3ddadcab49fa22f2Tomas Winkler * security overhead sizes
15403195cdb7424b4207f6903f1f3ddadcab49fa22f2Tomas Winkler */
15413195cdb7424b4207f6903f1f3ddadcab49fa22f2Tomas Winkler#define WEP_IV_LEN 4
15423195cdb7424b4207f6903f1f3ddadcab49fa22f2Tomas Winkler#define WEP_ICV_LEN 4
15433195cdb7424b4207f6903f1f3ddadcab49fa22f2Tomas Winkler#define CCMP_MIC_LEN 8
15443195cdb7424b4207f6903f1f3ddadcab49fa22f2Tomas Winkler#define TKIP_ICV_LEN 4
15453195cdb7424b4207f6903f1f3ddadcab49fa22f2Tomas Winkler
15463195cdb7424b4207f6903f1f3ddadcab49fa22f2Tomas Winkler/*
15473d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * REPLY_TX = 0x1c (command)
15483d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler */
15493d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
15503d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_tx_cmd {
15513d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	/*
15523d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * MPDU byte count:
15533d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * MAC header (24/26/30/32 bytes) + 2 bytes pad if 26/30 header size,
15543d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * + 8 byte IV for CCM or TKIP (not used for WEP)
15553d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * + Data payload
15563d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * + 8-byte MIC (not used for CCM/WEP)
15573d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * NOTE:  Does not include Tx command bytes, post-MAC pad bytes,
15583d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 *        MIC (CCM) 8 bytes, ICV (WEP/TKIP/CKIP) 4 bytes, CRC 4 bytes.i
15593d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * Range: 14-2342 bytes.
15603d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 */
15613d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 len;
15623d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
15633d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	/*
15643d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * MPDU or MSDU byte count for next frame.
15653d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * Used for fragmentation and bursting, but not 11n aggregation.
15663d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * Same as "len", but for next frame.  Set to 0 if not applicable.
15673d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 */
15683d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 next_frame_len;
15693d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
15703d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 tx_flags;	/* TX_CMD_FLG_* */
15713d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
15723d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 rate;
15733d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
15743d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	/* Index of recipient station in uCode's station table */
15753d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 sta_id;
15763d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 tid_tspec;
15773d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 sec_ctl;
15783d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 key[16];
15793d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	union {
15803d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler		u8 byte[8];
15813d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler		__le16 word[4];
15823d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler		__le32 dw[2];
15833d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	} tkip_mic;
15843d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 next_frame_info;
15853d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	union {
15863d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler		__le32 life_time;
15873d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler		__le32 attempt;
15883d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	} stop_time;
15893d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 supp_rates[2];
15903d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 rts_retry_limit;	/*byte 50 */
15913d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 data_retry_limit;	/*byte 51 */
15923d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	union {
15933d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler		__le16 pm_frame_timeout;
15943d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler		__le16 attempt_duration;
15953d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	} timeout;
15963d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
15973d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	/*
15983d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * Duration of EDCA burst Tx Opportunity, in 32-usec units.
15993d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * Set this if txop time is not specified by HCCA protocol (e.g. by AP).
16003d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 */
16013d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 driver_txop;
16023d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
16033d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	/*
16043d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * MAC header goes here, followed by 2 bytes padding if MAC header
16053d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * length is 26 or 30 bytes, followed by payload data
16063d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 */
16073d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 payload[0];
16083d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct ieee80211_hdr hdr[0];
1609ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
16103d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
16113d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler/*
16123d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * REPLY_TX = 0x1c (response)
16133d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler */
16143d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_tx_resp {
16153d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 failure_rts;
16163d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 failure_frame;
16173d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 bt_kill_count;
16183d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 rate;
16193d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 wireless_media_time;
16203d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 status;		/* TX status */
1621ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
16223d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
16233d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
16243d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler/*
1625529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * 4965 uCode updates these Tx attempt count values in host DRAM.
1626529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Used for managing Tx retries when expecting block-acks.
1627529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Driver should set these fields to 0.
1628b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
16292aa6ab86bc475a115f56645591d2413981846509Tomas Winklerstruct iwl_dram_scratch {
1630529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	u8 try_cnt;		/* Tx attempts */
1631529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	u8 bt_kill_cnt;		/* Tx attempts blocked by Bluetooth device */
1632b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved;
1633ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
1634b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
163583d527d9e8f9aff92cbd33f208f77c055dabb499Tomas Winklerstruct iwl_tx_cmd {
1636529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	/*
1637529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * MPDU byte count:
1638529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * MAC header (24/26/30/32 bytes) + 2 bytes pad if 26/30 header size,
1639529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * + 8 byte IV for CCM or TKIP (not used for WEP)
1640529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * + Data payload
1641529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * + 8-byte MIC (not used for CCM/WEP)
1642529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * NOTE:  Does not include Tx command bytes, post-MAC pad bytes,
1643529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 *        MIC (CCM) 8 bytes, ICV (WEP/TKIP/CKIP) 4 bytes, CRC 4 bytes.i
1644529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * Range: 14-2342 bytes.
1645529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 */
1646b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 len;
1647529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1648529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	/*
1649529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * MPDU or MSDU byte count for next frame.
1650529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * Used for fragmentation and bursting, but not 11n aggregation.
1651529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * Same as "len", but for next frame.  Set to 0 if not applicable.
1652529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 */
1653b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 next_frame_len;
1654529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1655529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	__le32 tx_flags;	/* TX_CMD_FLG_* */
1656529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
16572aa6ab86bc475a115f56645591d2413981846509Tomas Winkler	/* uCode may modify this field of the Tx command (in host DRAM!).
1658529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * Driver must also set dram_lsb_ptr and dram_msb_ptr in this cmd. */
16592aa6ab86bc475a115f56645591d2413981846509Tomas Winkler	struct iwl_dram_scratch scratch;
1660529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1661529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	/* Rate for *all* Tx attempts, if TX_CMD_FLG_STA_RATE_MSK is cleared. */
1662529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	__le32 rate_n_flags;	/* RATE_MCS_* */
1663529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1664529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	/* Index of destination station in uCode's station table */
1665b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 sta_id;
1666529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1667529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	/* Type of security encryption:  CCM or TKIP */
1668529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	u8 sec_ctl;		/* TX_CMD_SEC_* */
1669529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1670529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	/*
1671529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * Index into rate table (see REPLY_TX_LINK_QUALITY_CMD) for initial
1672529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * Tx attempt, if TX_CMD_FLG_STA_RATE_MSK is set.  Normally "0" for
1673529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * data frames, this field may be used to selectively reduce initial
1674529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * rate (via non-0 value) for special frames (e.g. management), while
1675529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * still supporting rate scaling for all frames.
1676529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 */
1677b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 initial_rate_index;
1678b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved;
1679b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 key[16];
1680b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 next_frame_flags;
1681b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved2;
1682b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	union {
1683b481de9ca074528fe8c429604e2777db8b89806aZhu Yi		__le32 life_time;
1684b481de9ca074528fe8c429604e2777db8b89806aZhu Yi		__le32 attempt;
1685b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	} stop_time;
1686529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1687529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	/* Host DRAM physical address pointer to "scratch" in this command.
1688529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * Must be dword aligned.  "0" in dram_lsb_ptr disables usage. */
1689b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 dram_lsb_ptr;
1690b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 dram_msb_ptr;
1691529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1692b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 rts_retry_limit;	/*byte 50 */
1693b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 data_retry_limit;	/*byte 51 */
1694b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 tid_tspec;
1695b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	union {
1696b481de9ca074528fe8c429604e2777db8b89806aZhu Yi		__le16 pm_frame_timeout;
1697b481de9ca074528fe8c429604e2777db8b89806aZhu Yi		__le16 attempt_duration;
1698b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	} timeout;
1699529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1700529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	/*
1701529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * Duration of EDCA burst Tx Opportunity, in 32-usec units.
1702529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * Set this if txop time is not specified by HCCA protocol (e.g. by AP).
1703529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 */
1704b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 driver_txop;
1705529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1706529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	/*
1707529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * MAC header goes here, followed by 2 bytes padding if MAC header
1708529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * length is 26 or 30 bytes, followed by payload data
1709529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 */
1710b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 payload[0];
1711b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct ieee80211_hdr hdr[0];
1712ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
1713b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
171404569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy/* TX command response is sent after *3945* transmission attempts.
1715b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
1716b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * NOTES:
1717b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
1718b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * TX_STATUS_FAIL_NEXT_FRAG
1719b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
1720b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * If the fragment flag in the MAC header for the frame being transmitted
1721b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * is set and there is insufficient time to transmit the next frame, the
1722b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * TX status will be returned with 'TX_STATUS_FAIL_NEXT_FRAG'.
1723b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
1724b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * TX_STATUS_FIFO_UNDERRUN
1725b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
1726b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Indicates the host did not provide bytes to the FIFO fast enough while
1727b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * a TX was in progress.
1728b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
1729b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * TX_STATUS_FAIL_MGMNT_ABORT
1730b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
1731b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * This status is only possible if the ABORT ON MGMT RX parameter was
1732b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * set to true with the TX command.
1733b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
1734b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * If the MSB of the status parameter is set then an abort sequence is
1735b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * required.  This sequence consists of the host activating the TX Abort
1736b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * control line, and then waiting for the TX Abort command response.  This
1737b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * indicates that a the device is no longer in a transmit state, and that the
1738b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * command FIFO has been cleared.  The host must then deactivate the TX Abort
1739b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * control line.  Receiving is still allowed in this case.
1740b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
1741b481de9ca074528fe8c429604e2777db8b89806aZhu Yienum {
174204569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	TX_3945_STATUS_SUCCESS = 0x01,
174304569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	TX_3945_STATUS_DIRECT_DONE = 0x02,
174404569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	TX_3945_STATUS_FAIL_SHORT_LIMIT = 0x82,
174504569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	TX_3945_STATUS_FAIL_LONG_LIMIT = 0x83,
174604569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	TX_3945_STATUS_FAIL_FIFO_UNDERRUN = 0x84,
174704569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	TX_3945_STATUS_FAIL_MGMNT_ABORT = 0x85,
174804569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	TX_3945_STATUS_FAIL_NEXT_FRAG = 0x86,
174904569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	TX_3945_STATUS_FAIL_LIFE_EXPIRE = 0x87,
175004569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	TX_3945_STATUS_FAIL_DEST_PS = 0x88,
175104569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	TX_3945_STATUS_FAIL_ABORTED = 0x89,
175204569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	TX_3945_STATUS_FAIL_BT_RETRY = 0x8a,
175304569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	TX_3945_STATUS_FAIL_STA_INVALID = 0x8b,
175404569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	TX_3945_STATUS_FAIL_FRAG_DROPPED = 0x8c,
175504569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	TX_3945_STATUS_FAIL_TID_DISABLE = 0x8d,
175604569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	TX_3945_STATUS_FAIL_FRAME_FLUSHED = 0x8e,
175704569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	TX_3945_STATUS_FAIL_INSUFFICIENT_CF_POLL = 0x8f,
175804569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	TX_3945_STATUS_FAIL_TX_LOCKED = 0x90,
175904569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	TX_3945_STATUS_FAIL_NO_BEACON_ON_RADAR = 0x91,
176004569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy};
176104569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy
176204569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy/*
176304569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy * TX command response is sent after *agn* transmission attempts.
176404569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy *
176504569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy * both postpone and abort status are expected behavior from uCode. there is
176604569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy * no special operation required from driver; except for RFKILL_FLUSH,
176704569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy * which required tx flush host command to flush all the tx frames in queues
176804569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy */
176904569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guyenum {
1770b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_SUCCESS = 0x01,
1771b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_DIRECT_DONE = 0x02,
177204569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	/* postpone TX */
177304569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	TX_STATUS_POSTPONE_DELAY = 0x40,
177404569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	TX_STATUS_POSTPONE_FEW_BYTES = 0x41,
177504569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	TX_STATUS_POSTPONE_BT_PRIO = 0x42,
177604569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	TX_STATUS_POSTPONE_QUIET_PERIOD = 0x43,
177704569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	TX_STATUS_POSTPONE_CALC_TTAK = 0x44,
177804569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	/* abort TX */
177904569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	TX_STATUS_FAIL_INTERNAL_CROSSED_RETRY = 0x81,
1780b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_SHORT_LIMIT = 0x82,
1781b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_LONG_LIMIT = 0x83,
1782b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_FIFO_UNDERRUN = 0x84,
178304569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	TX_STATUS_FAIL_DRAIN_FLOW = 0x85,
178404569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	TX_STATUS_FAIL_RFKILL_FLUSH = 0x86,
1785b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_LIFE_EXPIRE = 0x87,
1786b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_DEST_PS = 0x88,
178704569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	TX_STATUS_FAIL_HOST_ABORTED = 0x89,
1788b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_BT_RETRY = 0x8a,
1789b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_STA_INVALID = 0x8b,
1790b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_FRAG_DROPPED = 0x8c,
1791b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_TID_DISABLE = 0x8d,
179204569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	TX_STATUS_FAIL_FIFO_FLUSHED = 0x8e,
1793b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_FAIL_INSUFFICIENT_CF_POLL = 0x8f,
179404569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	/* uCode drop due to FW drop request */
179504569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	TX_STATUS_FAIL_FW_DROP = 0x90,
179604569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	/*
179704569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	 * uCode drop due to station color mismatch
179804569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	 * between tx command and station table
179904569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	 */
180004569cbe7653fe0057acc46afc07f2c2fd2508b3Wey-Yi Guy	TX_STATUS_FAIL_STA_COLOR_MISMATCH_DROP = 0x91,
1801b481de9ca074528fe8c429604e2777db8b89806aZhu Yi};
1802b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1803b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	TX_PACKET_MODE_REGULAR		0x0000
1804b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	TX_PACKET_MODE_BURST_SEQ	0x0100
1805b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define	TX_PACKET_MODE_BURST_FIRST	0x0200
1806b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1807b481de9ca074528fe8c429604e2777db8b89806aZhu Yienum {
1808b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_POWER_PA_NOT_ACTIVE = 0x0,
1809b481de9ca074528fe8c429604e2777db8b89806aZhu Yi};
1810b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1811b481de9ca074528fe8c429604e2777db8b89806aZhu Yienum {
18123fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	TX_STATUS_MSK = 0x000000ff,		/* bits 0:7 */
1813b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_DELAY_MSK = 0x00000040,
1814b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_STATUS_ABORT_MSK = 0x00000080,
1815b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_PACKET_MODE_MSK = 0x0000ff00,	/* bits 8:15 */
1816b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_FIFO_NUMBER_MSK = 0x00070000,	/* bits 16:18 */
18173fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	TX_RESERVED = 0x00780000,		/* bits 19:22 */
1818b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_POWER_PA_DETECT_MSK = 0x7f800000,	/* bits 23:30 */
1819b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	TX_ABORT_REQUIRED_MSK = 0x80000000,	/* bits 31:31 */
1820b481de9ca074528fe8c429604e2777db8b89806aZhu Yi};
1821b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1822b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* *******************************
1823529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * TX aggregation status
1824b481de9ca074528fe8c429604e2777db8b89806aZhu Yi ******************************* */
1825b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1826b481de9ca074528fe8c429604e2777db8b89806aZhu Yienum {
1827b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	AGG_TX_STATE_TRANSMITTED = 0x00,
1828b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	AGG_TX_STATE_UNDERRUN_MSK = 0x01,
1829b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	AGG_TX_STATE_BT_PRIO_MSK = 0x02,
1830b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	AGG_TX_STATE_FEW_BYTES_MSK = 0x04,
1831b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	AGG_TX_STATE_ABORT_MSK = 0x08,
1832b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	AGG_TX_STATE_LAST_SENT_TTL_MSK = 0x10,
1833b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK = 0x20,
1834b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	AGG_TX_STATE_LAST_SENT_BT_KILL_MSK = 0x40,
1835b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	AGG_TX_STATE_SCD_QUERY_MSK = 0x80,
1836b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	AGG_TX_STATE_TEST_BAD_CRC32_MSK = 0x100,
1837b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	AGG_TX_STATE_RESPONSE_MSK = 0x1ff,
1838b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	AGG_TX_STATE_DUMP_TX_MSK = 0x200,
1839b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	AGG_TX_STATE_DELAY_TX_MSK = 0x400
1840b481de9ca074528fe8c429604e2777db8b89806aZhu Yi};
1841b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
18423fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler#define AGG_TX_STATE_LAST_SENT_MSK  (AGG_TX_STATE_LAST_SENT_TTL_MSK | \
18433fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler				     AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK | \
18443fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler				     AGG_TX_STATE_LAST_SENT_BT_KILL_MSK)
1845b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1846529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* # tx attempts for first frame in aggregation */
1847b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define AGG_TX_STATE_TRY_CNT_POS 12
1848b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define AGG_TX_STATE_TRY_CNT_MSK 0xf000
1849b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1850529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill/* Command ID and sequence number of Tx command for this frame */
1851b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define AGG_TX_STATE_SEQ_NUM_POS 16
1852b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define AGG_TX_STATE_SEQ_NUM_MSK 0xffff0000
1853b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1854b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
1855b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_TX = 0x1c (response)
1856529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *
1857529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * This response may be in one of two slightly different formats, indicated
1858529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * by the frame_count field:
1859529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *
1860529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * 1)  No aggregation (frame_count == 1).  This reports Tx results for
1861529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *     a single frame.  Multiple attempts, at various bit rates, may have
1862529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *     been made for this frame.
1863529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *
1864529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * 2)  Aggregation (frame_count > 1).  This reports Tx results for
1865529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *     2 or more frames that used block-acknowledge.  All frames were
1866529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *     transmitted at same rate.  Rate scaling may have been used if first
1867529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *     frame in this new agg block failed in previous agg block(s).
1868529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *
1869529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *     Note that, for aggregation, ACK (block-ack) status is not delivered here;
1870529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *     block-ack has not been received by the time the 4965 records this status.
1871529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *     This status relates to reasons the tx might have been blocked or aborted
1872529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *     within the sending station (this 4965), rather than whether it was
1873529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *     received successfully by the destination station.
1874b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
1875001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunskystruct agg_tx_status {
1876001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	__le16 status;
1877001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	__le16 sequence;
1878ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
1879001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky
1880bb8c093bdea62f2ae371b98ebff81b0407852fafChristoph Hellwigstruct iwl4965_tx_resp {
1881b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 frame_count;		/* 1 no aggregation, >1 aggregation */
1882529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	u8 bt_kill_count;	/* # blocked by bluetooth (unused for agg) */
1883529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	u8 failure_rts;		/* # failures due to unsuccessful RTS */
1884529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	u8 failure_frame;	/* # failures due to no ACK (unused for agg) */
1885529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1886529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	/* For non-agg:  Rate at which frame was successful.
1887529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * For agg:  Rate at which all frames were transmitted. */
1888529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	__le32 rate_n_flags;	/* RATE_MCS_*  */
1889529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1890529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	/* For non-agg:  RTS + CTS + frame tx attempts time + ACK.
1891529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * For agg:  RTS + CTS + aggregation tx time + block-ack time. */
1892529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	__le16 wireless_media_time;	/* uSecs */
1893529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1894b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved;
1895529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	__le32 pa_power1;	/* RF power amplifier measurement (not used) */
1896b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 pa_power2;
1897529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1898529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	/*
1899529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * For non-agg:  frame status TX_STATUS_*
1900529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 * For agg:  status of 1st frame, AGG_TX_STATE_*; other frame status
1901529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 *           fields follow this one, up to frame_count.
1902529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 *           Bit fields:
1903529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 *           11- 0:  AGG_TX_STATE_* status code
1904529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 *           15-12:  Retry count for 1st frame in aggregation (retries
1905529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 *                   occur if tx failed for this frame when it was a
1906529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 *                   member of a previous aggregation block).  If rate
1907529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 *                   scaling is used, retry count indicates the rate
1908529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 *                   table entry used for all frames in the new agg.
1909529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 *           31-16:  Sequence # for this frame's Tx cmd (not SSN!)
1910529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	 */
191125a6572cc13ba2a3fefc02a63a077ff3664a1ca9Tomas Winkler	union {
191225a6572cc13ba2a3fefc02a63a077ff3664a1ca9Tomas Winkler		__le32 status;
191325a6572cc13ba2a3fefc02a63a077ff3664a1ca9Tomas Winkler		struct agg_tx_status agg_status[0]; /* for each agg frame */
191425a6572cc13ba2a3fefc02a63a077ff3664a1ca9Tomas Winkler	} u;
1915ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
1916fe01b477bbd23e69c3bdc6bce5be510ddad8297dRon Rindjunsky
19173fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler/*
19183fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler * definitions for initial rate index field
1919a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler * bits [3:0] initial rate index
19203fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler * bits [6:4] rate table color, used for the initial rate
19213fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler * bit-7 invalid rate indication
19223fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler *   i.e. rate was not chosen from rate table
19233fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler *   or rate table color was changed during frame retries
19243fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler * refer tlc rate info
19253fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler */
19263fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler
19273fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler#define IWL50_TX_RES_INIT_RATE_INDEX_POS	0
19283fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler#define IWL50_TX_RES_INIT_RATE_INDEX_MSK	0x0f
19293fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler#define IWL50_TX_RES_RATE_TABLE_COLOR_POS	4
19303fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler#define IWL50_TX_RES_RATE_TABLE_COLOR_MSK	0x70
19313fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler#define IWL50_TX_RES_INV_RATE_INDEX_MSK	0x80
19323fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler
19333fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler/* refer to ra_tid */
19343fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler#define IWL50_TX_RES_TID_POS	0
19353fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler#define IWL50_TX_RES_TID_MSK	0x0f
19363fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler#define IWL50_TX_RES_RA_POS	4
19373fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler#define IWL50_TX_RES_RA_MSK	0xf0
19383fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler
1939001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunskystruct iwl5000_tx_resp {
1940001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	u8 frame_count;		/* 1 no aggregation, >1 aggregation */
1941001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	u8 bt_kill_count;	/* # blocked by bluetooth (unused for agg) */
1942001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	u8 failure_rts;		/* # failures due to unsuccessful RTS */
1943001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	u8 failure_frame;	/* # failures due to no ACK (unused for agg) */
1944001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky
1945001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	/* For non-agg:  Rate at which frame was successful.
1946001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 * For agg:  Rate at which all frames were transmitted. */
1947001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	__le32 rate_n_flags;	/* RATE_MCS_*  */
1948001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky
1949001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	/* For non-agg:  RTS + CTS + frame tx attempts time + ACK.
1950001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 * For agg:  RTS + CTS + aggregation tx time + block-ack time. */
1951001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	__le16 wireless_media_time;	/* uSecs */
1952001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky
19533fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	u8 pa_status;		/* RF power amplifier measurement (not used) */
19543fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	u8 pa_integ_res_a[3];
19553fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	u8 pa_integ_res_b[3];
19563fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	u8 pa_integ_res_C[3];
1957001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky
1958001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	__le32 tfd_info;
1959001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	__le16 seq_ctl;
1960001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	__le16 byte_cnt;
19613fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	u8 tlc_info;
19623fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	u8 ra_tid;		/* tid (0:3), sta_id (4:7) */
19633fd07a1e5aba89d4be3696c46cb7297f1873195aTomas Winkler	__le16 frame_ctrl;
1964001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	/*
1965001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 * For non-agg:  frame status TX_STATUS_*
1966001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 * For agg:  status of 1st frame, AGG_TX_STATE_*; other frame status
1967001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 *           fields follow this one, up to frame_count.
1968001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 *           Bit fields:
1969001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 *           11- 0:  AGG_TX_STATE_* status code
1970001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 *           15-12:  Retry count for 1st frame in aggregation (retries
1971001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 *                   occur if tx failed for this frame when it was a
1972001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 *                   member of a previous aggregation block).  If rate
1973001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 *                   scaling is used, retry count indicates the rate
1974001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 *                   table entry used for all frames in the new agg.
1975001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 *           31-16:  Sequence # for this frame's Tx cmd (not SSN!)
1976001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	 */
1977001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky	struct agg_tx_status status;	/* TX status (in aggregation -
1978001caff0da8784989ef208af0f39d55ea07dfef5Ron Rindjunsky					 * status of 1st frame) */
1979ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
1980b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
1981b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_COMPRESSED_BA = 0xc5 (response only, not a command)
1982529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill *
1983529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill * Reports Block-Acknowledge from recipient station
1984b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
1985653fa4a07525e4cd9e7b90e6fc1f792119910636Emmanuel Grumbachstruct iwl_compressed_ba_resp {
1986b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 sta_addr_lo32;
1987b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 sta_addr_hi16;
1988b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved;
1989529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill
1990529699815b79f15a6644786dc4d6e9dd5153a447Ben M Cahill	/* Index of recipient (BA-sending) station in uCode's station table */
1991b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 sta_id;
1992b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 tid;
1993fe01b477bbd23e69c3bdc6bce5be510ddad8297dRon Rindjunsky	__le16 seq_ctl;
1994fe01b477bbd23e69c3bdc6bce5be510ddad8297dRon Rindjunsky	__le64 bitmap;
1995b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 scd_flow;
1996b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 scd_ssn;
1997ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
1998b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
1999b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2000b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_TX_PWR_TABLE_CMD = 0x97 (command, has simple generic response)
20012bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
20022bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * See details under "TXPOWER" in iwl-4965-hw.h.
2003b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
20043d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
20053d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_txpowertable_cmd {
20063d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 band;		/* 0: 5 GHz, 1: 2.4 GHz */
20073d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 reserved;
20083d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 channel;
20093d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct iwl3945_power_per_rate power[IWL_MAX_RATES];
2010ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
20113d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
2012bb8c093bdea62f2ae371b98ebff81b0407852fafChristoph Hellwigstruct iwl4965_txpowertable_cmd {
2013b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 band;		/* 0: 5 GHz, 1: 2.4 GHz */
2014b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved;
2015b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 channel;
2016bb8c093bdea62f2ae371b98ebff81b0407852fafChristoph Hellwig	struct iwl4965_tx_power_db tx_power;
2017ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
2018b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
20193d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
20203d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler/**
20213d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * struct iwl3945_rate_scaling_cmd - Rate Scaling Command & Response
20223d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler *
20233d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * REPLY_RATE_SCALE = 0x47 (command, has simple generic response)
20243d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler *
20253d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * NOTE: The table of rates passed to the uCode via the
20263d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * RATE_SCALE command sets up the corresponding order of
20273d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * rates used for all related commands, including rate
20283d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * masks, etc.
20293d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler *
20303d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * For example, if you set 9MB (PLCP 0x0f) as the first
20313d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * rate in the rate table, the bit mask for that rate
20323d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * when passed through ofdm_basic_rates on the REPLY_RXON
20333d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler * command would be bit 0 (1 << 0)
20343d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler */
20353d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_rate_scaling_info {
20363d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 rate_n_flags;
20373d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 try_cnt;
20383d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 next_rate_index;
2039ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
20403d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
20413d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_rate_scaling_cmd {
20423d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 table_id;
20433d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 reserved[3];
20443d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct iwl3945_rate_scaling_info table[IWL_MAX_RATES];
2045ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
20463d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
20473d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
2048b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*RS_NEW_API: only TLC_RTS remains and moved to bit 0 */
20498a1b02452862dd30980ad0ef493eed687bc81474Reinette Chatre#define  LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK	(1 << 0)
2050b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
20512bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill/* # of EDCA prioritized tx fifos */
2052b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define  LINK_QUAL_AC_NUM AC_NUM
20532bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
20542bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill/* # entries in rate scale table to support Tx retries */
2055b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define  LINK_QUAL_MAX_RETRY_NUM 16
2056b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
20572bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill/* Tx antenna selection values */
20588a1b02452862dd30980ad0ef493eed687bc81474Reinette Chatre#define  LINK_QUAL_ANT_A_MSK (1 << 0)
20598a1b02452862dd30980ad0ef493eed687bc81474Reinette Chatre#define  LINK_QUAL_ANT_B_MSK (1 << 1)
2060b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define  LINK_QUAL_ANT_MSK   (LINK_QUAL_ANT_A_MSK|LINK_QUAL_ANT_B_MSK)
2061b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
20622bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
20632bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill/**
206466c73db7c6f7672e40c0bb1d2689f2d0d0922aadTomas Winkler * struct iwl_link_qual_general_params
20652bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
20662bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * Used in REPLY_TX_LINK_QUALITY_CMD
20672bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill */
206866c73db7c6f7672e40c0bb1d2689f2d0d0922aadTomas Winklerstruct iwl_link_qual_general_params {
2069b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 flags;
20702bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
20712bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	/* No entries at or above this (driver chosen) index contain MIMO */
2072b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 mimo_delimiter;
20732bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
20742bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	/* Best single antenna to use for single stream (legacy, SISO). */
20752bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	u8 single_stream_ant_msk;	/* LINK_QUAL_ANT_* */
20762bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
20772bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	/* Best antennas to use for MIMO (unused for 4965, assumes both). */
20782bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	u8 dual_stream_ant_msk;		/* LINK_QUAL_ANT_* */
20792bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
20802bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	/*
20812bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * If driver needs to use different initial rates for different
20822bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * EDCA QOS access categories (as implemented by tx fifos 0-3),
20832bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * this table will set that up, by indicating the indexes in the
20842bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * rs_table[LINK_QUAL_MAX_RETRY_NUM] rate table at which to start.
20852bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * Otherwise, driver should set all entries to 0.
20862bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 *
20872bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * Entry usage:
20882bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * 0 = Background, 1 = Best Effort (normal), 2 = Video, 3 = Voice
20892bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * TX FIFOs above 3 use same value (typically 0) as TX FIFO 3.
20902bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 */
2091b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 start_rate_index[LINK_QUAL_AC_NUM];
2092ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
2093b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
209413c33a09b3703c2956345482017600434c853889Wey-Yi Guy#define LINK_QUAL_AGG_TIME_LIMIT_DEF	(4000) /* 4 milliseconds */
2095b15826a795969cbdd85a0b5100165e240e6508e4Wey-Yi Guy#define LINK_QUAL_AGG_TIME_LIMIT_MAX	(8000)
2096b15826a795969cbdd85a0b5100165e240e6508e4Wey-Yi Guy#define LINK_QUAL_AGG_TIME_LIMIT_MIN	(100)
209713c33a09b3703c2956345482017600434c853889Wey-Yi Guy
209813c33a09b3703c2956345482017600434c853889Wey-Yi Guy#define LINK_QUAL_AGG_DISABLE_START_DEF	(3)
209913c33a09b3703c2956345482017600434c853889Wey-Yi Guy#define LINK_QUAL_AGG_DISABLE_START_MAX	(255)
210013c33a09b3703c2956345482017600434c853889Wey-Yi Guy#define LINK_QUAL_AGG_DISABLE_START_MIN	(0)
210113c33a09b3703c2956345482017600434c853889Wey-Yi Guy
210213c33a09b3703c2956345482017600434c853889Wey-Yi Guy#define LINK_QUAL_AGG_FRAME_LIMIT_DEF	(31)
2103b623a9f7c488e51dbe4320d8b5cdd0ba242d0067Johannes Berg#define LINK_QUAL_AGG_FRAME_LIMIT_MAX	(63)
210413c33a09b3703c2956345482017600434c853889Wey-Yi Guy#define LINK_QUAL_AGG_FRAME_LIMIT_MIN	(0)
210513c33a09b3703c2956345482017600434c853889Wey-Yi Guy
21062bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill/**
210766c73db7c6f7672e40c0bb1d2689f2d0d0922aadTomas Winkler * struct iwl_link_qual_agg_params
21082bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21092bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * Used in REPLY_TX_LINK_QUALITY_CMD
21102bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill */
211166c73db7c6f7672e40c0bb1d2689f2d0d0922aadTomas Winklerstruct iwl_link_qual_agg_params {
21122bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
21137469701e10adb6bcc3d66544bd9f6d553fc678c9Wey-Yi Guy	/*
21147469701e10adb6bcc3d66544bd9f6d553fc678c9Wey-Yi Guy	 *Maximum number of uSec in aggregation.
21157469701e10adb6bcc3d66544bd9f6d553fc678c9Wey-Yi Guy	 * default set to 4000 (4 milliseconds) if not configured in .cfg
21167469701e10adb6bcc3d66544bd9f6d553fc678c9Wey-Yi Guy	 */
2117b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 agg_time_limit;
21182bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
21192bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	/*
21202bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * Number of Tx retries allowed for a frame, before that frame will
21212bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * no longer be considered for the start of an aggregation sequence
21222bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * (scheduler will then try to tx it as single frame).
21232bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * Driver should set this to 3.
21242bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 */
2125b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 agg_dis_start_th;
21262bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
21272bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	/*
21282bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * Maximum number of frames in aggregation.
21292bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * 0 = no limit (default).  1 = no aggregation.
21302bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * Other values = max # frames in aggregation.
21312bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 */
2132b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 agg_frame_cnt_limit;
21332bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
2134b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 reserved;
2135ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
2136b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2137b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2138b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_TX_LINK_QUALITY_CMD = 0x4e (command, has simple generic response)
21392bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21402bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * For 4965 only; 3945 uses REPLY_RATE_SCALE.
21412bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21422bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * Each station in the 4965's internal station table has its own table of 16
21432bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * Tx rates and modulation modes (e.g. legacy/SISO/MIMO) for retrying Tx when
21442bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * an ACK is not received.  This command replaces the entire table for
21452bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * one station.
21462bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21472bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * NOTE:  Station must already be in 4965's station table.  Use REPLY_ADD_STA.
21482bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21492bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * The rate scaling procedures described below work well.  Of course, other
21502bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * procedures are possible, and may work better for particular environments.
21512bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21522bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21532bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * FILLING THE RATE TABLE
21542bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21552bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * Given a particular initial rate and mode, as determined by the rate
21562bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * scaling algorithm described below, the Linux driver uses the following
21572bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * formula to fill the rs_table[LINK_QUAL_MAX_RETRY_NUM] rate table in the
21582bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * Link Quality command:
21592bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21602bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21612bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * 1)  If using High-throughput (HT) (SISO or MIMO) initial rate:
21622bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     a) Use this same initial rate for first 3 entries.
21632bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     b) Find next lower available rate using same mode (SISO or MIMO),
21642bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *        use for next 3 entries.  If no lower rate available, switch to
21657aafef1c6e2e24f9a10dc2972bf0ee70624ccc47Wey-Yi Guy *        legacy mode (no HT40 channel, no MIMO, no short guard interval).
21662bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     c) If using MIMO, set command's mimo_delimiter to number of entries
21672bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *        using MIMO (3 or 6).
21687aafef1c6e2e24f9a10dc2972bf0ee70624ccc47Wey-Yi Guy *     d) After trying 2 HT rates, switch to legacy mode (no HT40 channel,
21692bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *        no MIMO, no short guard interval), at the next lower bit rate
21702bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *        (e.g. if second HT bit rate was 54, try 48 legacy), and follow
21712bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *        legacy procedure for remaining table entries.
21722bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21732bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * 2)  If using legacy initial rate:
21742bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     a) Use the initial rate for only one entry.
21752bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     b) For each following entry, reduce the rate to next lower available
21762bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *        rate, until reaching the lowest available rate.
21772bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     c) When reducing rate, also switch antenna selection.
21782bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     d) Once lowest available rate is reached, repeat this rate until
21792bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *        rate table is filled (16 entries), switching antenna each entry.
21802bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21812bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21822bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * ACCUMULATING HISTORY
21832bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21842bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * The rate scaling algorithm for 4965, as implemented in Linux driver, uses
21852bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * two sets of frame Tx success history:  One for the current/active modulation
21862bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * mode, and one for a speculative/search mode that is being attempted.  If the
21872bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * speculative mode turns out to be more effective (i.e. actual transfer
21882bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * rate is better), then the driver continues to use the speculative mode
21892bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * as the new current active mode.
21902bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
21912bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * Each history set contains, separately for each possible rate, data for a
21922bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * sliding window of the 62 most recent tx attempts at that rate.  The data
21932bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * includes a shifting bitmap of success(1)/failure(0), and sums of successful
21942bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * and attempted frames, from which the driver can additionally calculate a
21952bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * success ratio (success / attempted) and number of failures
21962bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * (attempted - success), and control the size of the window (attempted).
21972bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * The driver uses the bit map to remove successes from the success sum, as
21982bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * the oldest tx attempts fall out of the window.
21992bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
22002bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * When the 4965 makes multiple tx attempts for a given frame, each attempt
22012bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * might be at a different rate, and have different modulation characteristics
22022bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * (e.g. antenna, fat channel, short guard interval), as set up in the rate
22032bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * scaling table in the Link Quality command.  The driver must determine
22042bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * which rate table entry was used for each tx attempt, to determine which
22052bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * rate-specific history to update, and record only those attempts that
22062bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * match the modulation characteristics of the history set.
22072bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
22082bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * When using block-ack (aggregation), all frames are transmitted at the same
2209a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler * rate, since there is no per-attempt acknowledgment from the destination
22102bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * station.  The Tx response struct iwl_tx_resp indicates the Tx rate in
22112bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * rate_n_flags field.  After receiving a block-ack, the driver can update
22122bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * history for the entire block all at once.
22132bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
22142bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
22152bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * FINDING BEST STARTING RATE:
22162bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
22172bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * When working with a selected initial modulation mode (see below), the
22182bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * driver attempts to find a best initial rate.  The initial rate is the
22192bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * first entry in the Link Quality command's rate table.
22202bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
22212bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * 1)  Calculate actual throughput (success ratio * expected throughput, see
22222bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     table below) for current initial rate.  Do this only if enough frames
22232bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     have been attempted to make the value meaningful:  at least 6 failed
22242bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     tx attempts, or at least 8 successes.  If not enough, don't try rate
22252bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     scaling yet.
22262bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
22272bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * 2)  Find available rates adjacent to current initial rate.  Available means:
22282bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     a)  supported by hardware &&
22292bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     b)  supported by association &&
22302bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     c)  within any constraints selected by user
22312bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
22322bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * 3)  Gather measured throughputs for adjacent rates.  These might not have
22332bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     enough history to calculate a throughput.  That's okay, we might try
22342bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     using one of them anyway!
22352bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
22362bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * 4)  Try decreasing rate if, for current rate:
22372bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     a)  success ratio is < 15% ||
22382bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     b)  lower adjacent rate has better measured throughput ||
22392bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     c)  higher adjacent rate has worse throughput, and lower is unmeasured
22402bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
22412bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     As a sanity check, if decrease was determined above, leave rate
22422bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     unchanged if:
22432bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     a)  lower rate unavailable
22442bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     b)  success ratio at current rate > 85% (very good)
22452bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     c)  current measured throughput is better than expected throughput
22462bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *         of lower rate (under perfect 100% tx conditions, see table below)
22472bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
22482bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * 5)  Try increasing rate if, for current rate:
22492bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     a)  success ratio is < 15% ||
22502bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     b)  both adjacent rates' throughputs are unmeasured (try it!) ||
22512bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     b)  higher adjacent rate has better measured throughput ||
22522bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     c)  lower adjacent rate has worse throughput, and higher is unmeasured
22532bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
22542bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     As a sanity check, if increase was determined above, leave rate
22552bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     unchanged if:
22562bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     a)  success ratio at current rate < 70%.  This is not particularly
22572bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *         good performance; higher rate is sure to have poorer success.
22582bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
22592bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * 6)  Re-evaluate the rate after each tx frame.  If working with block-
22602bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     acknowledge, history and statistics may be calculated for the entire
22612bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     block (including prior history that fits within the history windows),
22622bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     before re-evaluation.
22632bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
22642bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * FINDING BEST STARTING MODULATION MODE:
22652bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
22662bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * After working with a modulation mode for a "while" (and doing rate scaling),
22672bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * the driver searches for a new initial mode in an attempt to improve
22682bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * throughput.  The "while" is measured by numbers of attempted frames:
22692bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
22702bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * For legacy mode, search for new mode after:
22712bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *   480 successful frames, or 160 failed frames
22722bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * For high-throughput modes (SISO or MIMO), search for new mode after:
22732bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *   4500 successful frames, or 400 failed frames
22742bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
22752bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * Mode switch possibilities are (3 for each mode):
22762bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
22772bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * For legacy:
22782bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *   Change antenna, try SISO (if HT association), try MIMO (if HT association)
22792bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * For SISO:
22802bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *   Change antenna, try MIMO, try shortened guard interval (SGI)
22812bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * For MIMO:
22822bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *   Try SISO antenna A, SISO antenna B, try shortened guard interval (SGI)
22832bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
22842bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * When trying a new mode, use the same bit rate as the old/current mode when
22852bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * trying antenna switches and shortened guard interval.  When switching to
22862bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * SISO from MIMO or legacy, or to MIMO from SISO or legacy, use a rate
22872bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * for which the expected throughput (under perfect conditions) is about the
22882bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * same or slightly better than the actual measured throughput delivered by
22892bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * the old/current mode.
22902bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
22912bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * Actual throughput can be estimated by multiplying the expected throughput
22922bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * by the success ratio (successful / attempted tx frames).  Frame size is
22932bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * not considered in this calculation; it assumes that frame size will average
22942bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * out to be fairly consistent over several samples.  The following are
22952bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * metric values for expected throughput assuming 100% success ratio.
22962bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * Only G band has support for CCK rates:
22972bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
22982bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *           RATE:  1    2    5   11    6   9   12   18   24   36   48   54   60
22992bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
23002bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *              G:  7   13   35   58   40  57   72   98  121  154  177  186  186
23012bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *              A:  0    0    0    0   40  57   72   98  121  154  177  186  186
23022bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     SISO 20MHz:  0    0    0    0   42  42   76  102  124  159  183  193  202
23032bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * SGI SISO 20MHz:  0    0    0    0   46  46   82  110  132  168  192  202  211
23042bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     MIMO 20MHz:  0    0    0    0   74  74  123  155  179  214  236  244  251
23052bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * SGI MIMO 20MHz:  0    0    0    0   81  81  131  164  188  222  243  251  257
23062bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     SISO 40MHz:  0    0    0    0   77  77  127  160  184  220  242  250  257
23072bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * SGI SISO 40MHz:  0    0    0    0   83  83  135  169  193  229  250  257  264
23082bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *     MIMO 40MHz:  0    0    0    0  123 123  182  214  235  264  279  285  289
23092bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * SGI MIMO 40MHz:  0    0    0    0  131 131  191  222  242  270  284  289  293
23102bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
23112bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * After the new mode has been tried for a short while (minimum of 6 failed
23122bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * frames or 8 successful frames), compare success ratio and actual throughput
23132bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * estimate of the new mode with the old.  If either is better with the new
23142bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * mode, continue to use the new mode.
23152bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
23162bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * Continue comparing modes until all 3 possibilities have been tried.
23172bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * If moving from legacy to HT, try all 3 possibilities from the new HT
23182bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * mode.  After trying all 3, a best mode is found.  Continue to use this mode
23192bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * for the longer "while" described above (e.g. 480 successful frames for
23202bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill * legacy), and then repeat the search process.
23212bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill *
2322b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
232366c73db7c6f7672e40c0bb1d2689f2d0d0922aadTomas Winklerstruct iwl_link_quality_cmd {
23242bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
23252bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	/* Index of destination/recipient station in uCode's station table */
2326b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 sta_id;
2327b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved1;
23282bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	__le16 control;		/* not used */
232966c73db7c6f7672e40c0bb1d2689f2d0d0922aadTomas Winkler	struct iwl_link_qual_general_params general_params;
233066c73db7c6f7672e40c0bb1d2689f2d0d0922aadTomas Winkler	struct iwl_link_qual_agg_params agg_params;
23312bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill
23322bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	/*
23332bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * Rate info; when using rate-scaling, Tx command's initial_rate_index
23342bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * specifies 1st Tx rate attempted, via index into this table.
23352bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 * 4965 works its way through table when retrying Tx.
23362bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill	 */
2337b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct {
23382bdc7031f9ea1826e16bffc3540d05de891c98bcBen M Cahill		__le32 rate_n_flags;	/* RATE_MCS_*, IWL_RATE_* */
2339b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	} rs_table[LINK_QUAL_MAX_RETRY_NUM];
2340b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 reserved2;
2341ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
2342b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2343dab1c161fed18eb6b3472bdbfd827264caae097fWey-Yi Guy/*
2344dab1c161fed18eb6b3472bdbfd827264caae097fWey-Yi Guy * BT configuration enable flags:
2345dab1c161fed18eb6b3472bdbfd827264caae097fWey-Yi Guy *   bit 0 - 1: BT channel announcement enabled
2346dab1c161fed18eb6b3472bdbfd827264caae097fWey-Yi Guy *           0: disable
2347dab1c161fed18eb6b3472bdbfd827264caae097fWey-Yi Guy *   bit 1 - 1: priority of BT device enabled
2348dab1c161fed18eb6b3472bdbfd827264caae097fWey-Yi Guy *           0: disable
2349dab1c161fed18eb6b3472bdbfd827264caae097fWey-Yi Guy *   bit 2 - 1: BT 2 wire support enabled
2350dab1c161fed18eb6b3472bdbfd827264caae097fWey-Yi Guy *           0: disable
2351dab1c161fed18eb6b3472bdbfd827264caae097fWey-Yi Guy */
2352456d0f76727ba6f97aa1cee63f1bae84642768c4Wey-Yi Guy#define BT_COEX_DISABLE (0x0)
2353dab1c161fed18eb6b3472bdbfd827264caae097fWey-Yi Guy#define BT_ENABLE_CHANNEL_ANNOUNCE BIT(0)
2354dab1c161fed18eb6b3472bdbfd827264caae097fWey-Yi Guy#define BT_ENABLE_PRIORITY	   BIT(1)
2355dab1c161fed18eb6b3472bdbfd827264caae097fWey-Yi Guy#define BT_ENABLE_2_WIRE	   BIT(2)
2356456d0f76727ba6f97aa1cee63f1bae84642768c4Wey-Yi Guy
235706702a735eacf8679e9ff0d49eb3c989bc6b96ceWey-Yi Guy#define BT_COEX_DISABLE (0x0)
235806702a735eacf8679e9ff0d49eb3c989bc6b96ceWey-Yi Guy#define BT_COEX_ENABLE  (BT_ENABLE_CHANNEL_ANNOUNCE | BT_ENABLE_PRIORITY)
235906702a735eacf8679e9ff0d49eb3c989bc6b96ceWey-Yi Guy
2360456d0f76727ba6f97aa1cee63f1bae84642768c4Wey-Yi Guy#define BT_LEAD_TIME_MIN (0x0)
2361456d0f76727ba6f97aa1cee63f1bae84642768c4Wey-Yi Guy#define BT_LEAD_TIME_DEF (0x1E)
2362456d0f76727ba6f97aa1cee63f1bae84642768c4Wey-Yi Guy#define BT_LEAD_TIME_MAX (0xFF)
2363456d0f76727ba6f97aa1cee63f1bae84642768c4Wey-Yi Guy
2364456d0f76727ba6f97aa1cee63f1bae84642768c4Wey-Yi Guy#define BT_MAX_KILL_MIN (0x1)
2365456d0f76727ba6f97aa1cee63f1bae84642768c4Wey-Yi Guy#define BT_MAX_KILL_DEF (0x5)
2366456d0f76727ba6f97aa1cee63f1bae84642768c4Wey-Yi Guy#define BT_MAX_KILL_MAX (0xFF)
2367456d0f76727ba6f97aa1cee63f1bae84642768c4Wey-Yi Guy
2368b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2369b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_BT_CONFIG = 0x9b (command, has simple generic response)
23703058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *
23713058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 3945 and 4965 support hardware handshake with Bluetooth device on
23723058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * same platform.  Bluetooth device alerts wireless device when it will Tx;
2373a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler * wireless device can delay or kill its own Tx to accommodate.
2374b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
23752aa6ab86bc475a115f56645591d2413981846509Tomas Winklerstruct iwl_bt_cmd {
2376b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 flags;
2377b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 lead_time;
2378b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 max_kill;
2379b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved;
2380b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 kill_ack_mask;
2381b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 kill_cts_mask;
2382ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
2383b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2384b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
2385b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (6)
2386b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Spectrum Management (802.11h) Commands, Responses, Notifications:
2387b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
2388b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
2389b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2390b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2391b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Spectrum Management
2392b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
2393b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define MEASUREMENT_FILTER_FLAG (RXON_FILTER_PROMISC_MSK         | \
2394b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 RXON_FILTER_CTL2HOST_MSK        | \
2395b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 RXON_FILTER_ACCEPT_GRP_MSK      | \
2396b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 RXON_FILTER_DIS_DECRYPT_MSK     | \
2397b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 RXON_FILTER_DIS_GRP_DECRYPT_MSK | \
2398b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 RXON_FILTER_ASSOC_MSK           | \
2399b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 RXON_FILTER_BCON_AWARE_MSK)
2400b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
24012aa6ab86bc475a115f56645591d2413981846509Tomas Winklerstruct iwl_measure_channel {
2402b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 duration;	/* measurement duration in extended beacon
2403b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 * format */
2404b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 channel;		/* channel to measure */
24052aa6ab86bc475a115f56645591d2413981846509Tomas Winkler	u8 type;		/* see enum iwl_measure_type */
2406b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved;
2407ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
2408b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2409b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2410b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74 (command)
2411b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
24122aa6ab86bc475a115f56645591d2413981846509Tomas Winklerstruct iwl_spectrum_cmd {
2413b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 len;		/* number of bytes starting from token */
2414b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 token;		/* token id */
2415b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 id;			/* measurement id -- 0 or 1 */
2416b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 origin;		/* 0 = TGh, 1 = other, 2 = TGk */
2417b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 periodic;		/* 1 = periodic */
2418b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 path_loss_timeout;
2419b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 start_time;	/* start time in extended beacon format */
2420b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 reserved2;
2421b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 flags;		/* rxon flags */
2422b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 filter_flags;	/* rxon filter flags */
2423b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 channel_count;	/* minimum 1, maximum 10 */
2424b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved3;
24252aa6ab86bc475a115f56645591d2413981846509Tomas Winkler	struct iwl_measure_channel channels[10];
2426ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
2427b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2428b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2429b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74 (response)
2430b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
24312aa6ab86bc475a115f56645591d2413981846509Tomas Winklerstruct iwl_spectrum_resp {
2432b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 token;
2433b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 id;			/* id of the prior command replaced, or 0xff */
2434b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 status;		/* 0 - command will be handled
2435b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 * 1 - cannot handle (conflicts with another
2436b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 *     measurement) */
2437ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
2438b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
24392aa6ab86bc475a115f56645591d2413981846509Tomas Winklerenum iwl_measurement_state {
2440b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASUREMENT_START = 0,
2441b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASUREMENT_STOP = 1,
2442b481de9ca074528fe8c429604e2777db8b89806aZhu Yi};
2443b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
24442aa6ab86bc475a115f56645591d2413981846509Tomas Winklerenum iwl_measurement_status {
2445b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASUREMENT_OK = 0,
2446b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASUREMENT_CONCURRENT = 1,
2447b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASUREMENT_CSA_CONFLICT = 2,
2448b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASUREMENT_TGH_CONFLICT = 3,
2449b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* 4-5 reserved */
2450b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASUREMENT_STOPPED = 6,
2451b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASUREMENT_TIMEOUT = 7,
2452b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASUREMENT_PERIODIC_FAILED = 8,
2453b481de9ca074528fe8c429604e2777db8b89806aZhu Yi};
2454b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2455b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define NUM_ELEMENTS_IN_HISTOGRAM 8
2456b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
24572aa6ab86bc475a115f56645591d2413981846509Tomas Winklerstruct iwl_measurement_histogram {
2458b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 ofdm[NUM_ELEMENTS_IN_HISTOGRAM];	/* in 0.8usec counts */
2459b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 cck[NUM_ELEMENTS_IN_HISTOGRAM];	/* in 1usec counts */
2460ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
2461b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2462b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* clear channel availability counters */
24632aa6ab86bc475a115f56645591d2413981846509Tomas Winklerstruct iwl_measurement_cca_counters {
2464b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 ofdm;
2465b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 cck;
2466ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
2467b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
24682aa6ab86bc475a115f56645591d2413981846509Tomas Winklerenum iwl_measure_type {
2469b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASURE_BASIC = (1 << 0),
2470b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASURE_CHANNEL_LOAD = (1 << 1),
2471b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASURE_HISTOGRAM_RPI = (1 << 2),
2472b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASURE_HISTOGRAM_NOISE = (1 << 3),
2473b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASURE_FRAME = (1 << 4),
2474b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* bits 5:6 are reserved */
2475b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_MEASURE_IDLE = (1 << 7),
2476b481de9ca074528fe8c429604e2777db8b89806aZhu Yi};
2477b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2478b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2479b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * SPECTRUM_MEASURE_NOTIFICATION = 0x75 (notification only, not a command)
2480b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
24812aa6ab86bc475a115f56645591d2413981846509Tomas Winklerstruct iwl_spectrum_notification {
2482b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 id;			/* measurement id -- 0 or 1 */
2483b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 token;
2484b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 channel_index;	/* index in measurement channel list */
2485b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 state;		/* 0 - start, 1 - stop */
2486b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 start_time;	/* lower 32-bits of TSF */
2487b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 band;		/* 0 - 5.2GHz, 1 - 2.4GHz */
2488b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 channel;
24892aa6ab86bc475a115f56645591d2413981846509Tomas Winkler	u8 type;		/* see enum iwl_measurement_type */
2490b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved1;
2491b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* NOTE:  cca_ofdm, cca_cck, basic_type, and histogram are only only
2492b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * valid if applicable for measurement type requested. */
2493b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 cca_ofdm;	/* cca fraction time in 40Mhz clock periods */
2494b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 cca_cck;		/* cca fraction time in 44Mhz clock periods */
2495b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 cca_time;	/* channel load time in usecs */
2496b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 basic_type;		/* 0 - bss, 1 - ofdm preamble, 2 -
2497b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 * unidentified */
2498b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved2[3];
24992aa6ab86bc475a115f56645591d2413981846509Tomas Winkler	struct iwl_measurement_histogram histogram;
2500b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 stop_time;	/* lower 32-bits of TSF */
25012aa6ab86bc475a115f56645591d2413981846509Tomas Winkler	__le32 status;		/* see iwl_measurement_status */
2502ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
2503b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2504b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
2505b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (7)
2506b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Power Management Commands, Responses, Notifications:
2507b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
2508b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
2509b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2510b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/**
2511ca579617d81baf5865498eb5fae58e453ee77c2cMohamed Abbas * struct iwl_powertable_cmd - Power Table Command
2512b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * @flags: See below:
2513b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
2514b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * POWER_TABLE_CMD = 0x77 (command, has simple generic response)
2515b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
2516b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * PM allow:
2517b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *   bit 0 - '0' Driver not allow power management
2518b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *           '1' Driver allow PM (use rest of parameters)
2519e312c24cf8229f9b6e76dbfd5d99eefe21f4ac0aJohannes Berg *
2520b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * uCode send sleep notifications:
2521b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *   bit 1 - '0' Don't send sleep notification
2522b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *           '1' send sleep notification (SEND_PM_NOTIFICATION)
2523e312c24cf8229f9b6e76dbfd5d99eefe21f4ac0aJohannes Berg *
2524b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Sleep over DTIM
2525b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *   bit 2 - '0' PM have to walk up every DTIM
2526b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *           '1' PM could sleep over DTIM till listen Interval.
2527e312c24cf8229f9b6e76dbfd5d99eefe21f4ac0aJohannes Berg *
2528b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * PCI power managed
2529e7b635814b640c6fd9dca1c254dc22fac6fb9a1aTomas Winkler *   bit 3 - '0' (PCI_CFG_LINK_CTRL & 0x1)
2530e7b635814b640c6fd9dca1c254dc22fac6fb9a1aTomas Winkler *           '1' !(PCI_CFG_LINK_CTRL & 0x1)
2531e312c24cf8229f9b6e76dbfd5d99eefe21f4ac0aJohannes Berg *
2532e312c24cf8229f9b6e76dbfd5d99eefe21f4ac0aJohannes Berg * Fast PD
2533e312c24cf8229f9b6e76dbfd5d99eefe21f4ac0aJohannes Berg *   bit 4 - '1' Put radio to sleep when receiving frame for others
2534e312c24cf8229f9b6e76dbfd5d99eefe21f4ac0aJohannes Berg *
2535b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Force sleep Modes
2536b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *   bit 31/30- '00' use both mac/xtal sleeps
2537b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *              '01' force Mac sleep
2538b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *              '10' force xtal sleep
2539b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *              '11' Illegal set
2540b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
2541b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * NOTE: if sleep_interval[SLEEP_INTRVL_TABLE_SIZE-1] > DTIM period then
2542a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler * ucode assume sleep over DTIM is allowed and we don't need to wake up
2543b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * for every DTIM.
2544b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
2545b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define IWL_POWER_VEC_SIZE 5
2546b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2547600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler#define IWL_POWER_DRIVER_ALLOW_SLEEP_MSK	cpu_to_le16(BIT(0))
2548600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler#define IWL_POWER_SLEEP_OVER_DTIM_MSK		cpu_to_le16(BIT(2))
2549600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler#define IWL_POWER_PCI_PM_MSK			cpu_to_le16(BIT(3))
2550600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler#define IWL_POWER_FAST_PD			cpu_to_le16(BIT(4))
2551600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler
2552600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winklerstruct iwl3945_powertable_cmd {
2553600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler	__le16 flags;
2554600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler	u8 reserved[2];
2555600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler	__le32 rx_data_timeout;
2556600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler	__le32 tx_data_timeout;
2557600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler	__le32 sleep_interval[IWL_POWER_VEC_SIZE];
2558ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
2559b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2560ca579617d81baf5865498eb5fae58e453ee77c2cMohamed Abbasstruct iwl_powertable_cmd {
2561b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 flags;
2562600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler	u8 keep_alive_seconds;		/* 3945 reserved */
2563600c0e11ea6161e00e8cb4b4dda39a64ce988c60Tomas Winkler	u8 debug_flags;			/* 3945 reserved */
2564b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 rx_data_timeout;
2565b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 tx_data_timeout;
2566b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 sleep_interval[IWL_POWER_VEC_SIZE];
2567b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 keep_alive_beacons;
2568ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
2569b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2570b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2571b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * PM_SLEEP_NOTIFICATION = 0x7A (notification only, not a command)
2572b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * 3945 and 4965 identical.
2573b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
25742aa6ab86bc475a115f56645591d2413981846509Tomas Winklerstruct iwl_sleep_notification {
2575b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 pm_sleep_mode;
2576b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 pm_wakeup_src;
2577b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 reserved;
2578b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 sleep_time;
2579b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 tsf_low;
2580b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 bcon_timer;
2581ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
2582b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2583b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* Sleep states.  3945 and 4965 identical. */
2584b481de9ca074528fe8c429604e2777db8b89806aZhu Yienum {
2585b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_PM_NO_SLEEP = 0,
2586b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_PM_SLP_MAC = 1,
2587b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_PM_SLP_FULL_MAC_UNASSOCIATE = 2,
2588b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_PM_SLP_FULL_MAC_CARD_STATE = 3,
2589b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_PM_SLP_PHY = 4,
2590b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_PM_SLP_REPENT = 5,
2591b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_PM_WAKEUP_BY_TIMER = 6,
2592b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_PM_WAKEUP_BY_DRIVER = 7,
2593b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_PM_WAKEUP_BY_RFKILL = 8,
2594b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/* 3 reserved */
2595b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	IWL_PM_NUM_OF_MODES = 12,
2596b481de9ca074528fe8c429604e2777db8b89806aZhu Yi};
2597b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2598b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2599b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_CARD_STATE_CMD = 0xa0 (command, has simple generic response)
2600b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
2601b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define CARD_STATE_CMD_DISABLE 0x00	/* Put card to sleep */
2602b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define CARD_STATE_CMD_ENABLE  0x01	/* Wake up card */
2603b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define CARD_STATE_CMD_HALT    0x02	/* Power down permanently */
26042aa6ab86bc475a115f56645591d2413981846509Tomas Winklerstruct iwl_card_state_cmd {
2605b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 status;		/* CARD_STATE_CMD_* request new power state */
2606ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
2607b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2608b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2609b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * CARD_STATE_NOTIFICATION = 0xa1 (notification only, not a command)
2610b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
26112aa6ab86bc475a115f56645591d2413981846509Tomas Winklerstruct iwl_card_state_notif {
2612b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 flags;
2613ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
2614b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2615b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define HW_CARD_DISABLED   0x01
2616b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define SW_CARD_DISABLED   0x02
26173a41bbd515d449604f3488c5f8dd62802f09d19bWey-Yi Guy#define CT_CARD_DISABLED   0x04
2618b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define RXON_CARD_DISABLED 0x10
2619b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
262047f4a5871614756627d7209e0569b58faf99b0d9Emmanuel Grumbachstruct iwl_ct_kill_config {
2621b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32   reserved;
2622b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32   critical_temperature_M;
2623b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32   critical_temperature_R;
2624ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet}  __packed;
2625b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2626672639de13c4db92ed6a47e68043a4317e219902Wey-Yi Guy/* 1000, and 6x00 */
2627672639de13c4db92ed6a47e68043a4317e219902Wey-Yi Guystruct iwl_ct_kill_throttling_config {
2628672639de13c4db92ed6a47e68043a4317e219902Wey-Yi Guy	__le32   critical_temperature_exit;
2629672639de13c4db92ed6a47e68043a4317e219902Wey-Yi Guy	__le32   reserved;
2630672639de13c4db92ed6a47e68043a4317e219902Wey-Yi Guy	__le32   critical_temperature_enter;
2631ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet}  __packed;
2632672639de13c4db92ed6a47e68043a4317e219902Wey-Yi Guy
2633b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
2634b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (8)
2635b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Scan Commands, Responses, Notifications:
2636b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
2637b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
2638b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
263951e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define SCAN_CHANNEL_TYPE_PASSIVE cpu_to_le32(0)
264051e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define SCAN_CHANNEL_TYPE_ACTIVE  cpu_to_le32(1)
2641d16dc48a2ea14af9980d0ea79d041f4b53e47b62Tomas Winkler
26423058f02137359efb412975cf94a9fa7c25413387Ben M Cahill/**
26432a421b91d6fe89e27ded7544a25449c0b050098fTomas Winkler * struct iwl_scan_channel - entry in REPLY_SCAN_CMD channel table
26443058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *
26453058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * One for each channel in the scan list.
26463058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * Each channel can independently select:
26473058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 1)  SSID for directed active scans
26483058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 2)  Txpower setting (for rate specified within Tx command)
26493058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 3)  How long to stay on-channel (behavior may be modified by quiet_time,
26503058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *     quiet_plcp_th, good_CRC_th)
26513058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *
26523058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * To avoid uCode errors, make sure the following are true (see comments
26532a421b91d6fe89e27ded7544a25449c0b050098fTomas Winkler * under struct iwl_scan_cmd about max_out_time and quiet_time):
26543058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 1)  If using passive_dwell (i.e. passive_dwell != 0):
26553058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *     active_dwell <= passive_dwell (< max_out_time if max_out_time != 0)
26563058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 2)  quiet_time <= active_dwell
26573058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 3)  If restricting off-channel time (i.e. max_out_time !=0):
26583058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *     passive_dwell < max_out_time
26593058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *     active_dwell < max_out_time
26603058f02137359efb412975cf94a9fa7c25413387Ben M Cahill */
26613d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
26623d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler/* FIXME: rename to AP1, remove tpc */
26633d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_scan_channel {
26643d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	/*
26653d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * type is defined as:
26663d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * 0:0 1 = active, 0 = passive
26673d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * 1:4 SSID direct bit map; if a bit is set, then corresponding
26683d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 *     SSID IE is transmitted in probe request.
26693d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * 5:7 reserved
26703d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 */
26713d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 type;
26723d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 channel;	/* band is selected by iwl3945_scan_cmd "flags" field */
26733d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct iwl3945_tx_power tpc;
26743d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 active_dwell;	/* in 1024-uSec TU (time units), typ 5-50 */
26753d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 passive_dwell;	/* in 1024-uSec TU (time units), typ 20-500 */
2676ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
26773d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
26780d21044effa10044930419c6f837f75191229c3aWinkler, Tomas/* set number of direct probes u8 type */
26790d21044effa10044930419c6f837f75191229c3aWinkler, Tomas#define IWL39_SCAN_PROBE_MASK(n) ((BIT(n) | (BIT(n) - BIT(1))))
26800d21044effa10044930419c6f837f75191229c3aWinkler, Tomas
26812a421b91d6fe89e27ded7544a25449c0b050098fTomas Winklerstruct iwl_scan_channel {
26823058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	/*
26833058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 * type is defined as:
26843058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 * 0:0 1 = active, 0 = passive
2685d16dc48a2ea14af9980d0ea79d041f4b53e47b62Tomas Winkler	 * 1:20 SSID direct bit map; if a bit is set, then corresponding
26863058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 *     SSID IE is transmitted in probe request.
2687d16dc48a2ea14af9980d0ea79d041f4b53e47b62Tomas Winkler	 * 21:31 reserved
2688b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 */
2689d16dc48a2ea14af9980d0ea79d041f4b53e47b62Tomas Winkler	__le32 type;
2690d16dc48a2ea14af9980d0ea79d041f4b53e47b62Tomas Winkler	__le16 channel;	/* band is selected by iwl_scan_cmd "flags" field */
2691f53696de6722a4aac00b76e25a5321c01e88a55fTomas Winkler	u8 tx_gain;		/* gain for analog radio */
2692f53696de6722a4aac00b76e25a5321c01e88a55fTomas Winkler	u8 dsp_atten;		/* gain for DSP */
26933058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le16 active_dwell;	/* in 1024-uSec TU (time units), typ 5-50 */
26943058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le16 passive_dwell;	/* in 1024-uSec TU (time units), typ 20-500 */
2695ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
2696b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
26970d21044effa10044930419c6f837f75191229c3aWinkler, Tomas/* set number of direct probes __le32 type */
26980d21044effa10044930419c6f837f75191229c3aWinkler, Tomas#define IWL_SCAN_PROBE_MASK(n) 	cpu_to_le32((BIT(n) | (BIT(n) - BIT(1))))
26990d21044effa10044930419c6f837f75191229c3aWinkler, Tomas
27003058f02137359efb412975cf94a9fa7c25413387Ben M Cahill/**
27012a421b91d6fe89e27ded7544a25449c0b050098fTomas Winkler * struct iwl_ssid_ie - directed scan network information element
27023058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *
27032a3b793d6a0ff30ad4a541230a6dba2ecb6fff1bBen M Cahill * Up to 20 of these may appear in REPLY_SCAN_CMD (Note: Only 4 are in
27042a3b793d6a0ff30ad4a541230a6dba2ecb6fff1bBen M Cahill * 3945 SCAN api), selected by "type" bit field in struct iwl_scan_channel;
27052a3b793d6a0ff30ad4a541230a6dba2ecb6fff1bBen M Cahill * each channel may select different ssids from among the 20 (4) entries.
27062a3b793d6a0ff30ad4a541230a6dba2ecb6fff1bBen M Cahill * SSID IEs get transmitted in reverse order of entry.
27073058f02137359efb412975cf94a9fa7c25413387Ben M Cahill */
27082a421b91d6fe89e27ded7544a25449c0b050098fTomas Winklerstruct iwl_ssid_ie {
2709b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 id;
2710b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 len;
2711b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 ssid[32];
2712ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
2713b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
27149b3bf06abad70db820c74c90118ea49358549d22Johannes Berg#define PROBE_OPTION_MAX_3945		4
27159b3bf06abad70db820c74c90118ea49358549d22Johannes Berg#define PROBE_OPTION_MAX		20
271651e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define TX_CMD_LIFE_TIME_INFINITE	cpu_to_le32(0xFFFFFFFF)
271796ff56419504ac6a610ff1af42330e0423242e16Johannes Berg#define IWL_GOOD_CRC_TH_DISABLED	0
271896ff56419504ac6a610ff1af42330e0423242e16Johannes Berg#define IWL_GOOD_CRC_TH_DEFAULT		cpu_to_le16(1)
271996ff56419504ac6a610ff1af42330e0423242e16Johannes Berg#define IWL_GOOD_CRC_TH_NEVER		cpu_to_le16(0xffff)
2720b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define IWL_MAX_SCAN_SIZE 1024
272189612124d6d62230043ebd827a2b54ea5ea5280cAbhijeet Kolekar#define IWL_MAX_CMD_SIZE 4096
2722b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2723b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2724b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_SCAN_CMD = 0x80 (command)
27253058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *
27263058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * The hardware scan command is very powerful; the driver can set it up to
27273058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * maintain (relatively) normal network traffic while doing a scan in the
27283058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * background.  The max_out_time and suspend_time control the ratio of how
27293058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * long the device stays on an associated network channel ("service channel")
27303058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * vs. how long it's away from the service channel, i.e. tuned to other channels
27313058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * for scanning.
27323058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *
27333058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * max_out_time is the max time off-channel (in usec), and suspend_time
27343058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * is how long (in "extended beacon" format) that the scan is "suspended"
27353058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * after returning to the service channel.  That is, suspend_time is the
27363058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * time that we stay on the service channel, doing normal work, between
27373058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * scan segments.  The driver may set these parameters differently to support
27383058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * scanning when associated vs. not associated, and light vs. heavy traffic
27393058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * loads when associated.
27403058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *
27413058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * After receiving this command, the device's scan engine does the following;
27423058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *
27433058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 1)  Sends SCAN_START notification to driver
27443058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 2)  Checks to see if it has time to do scan for one channel
27453058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 3)  Sends NULL packet, with power-save (PS) bit set to 1,
27463058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *     to tell AP that we're going off-channel
27473058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 4)  Tunes to first channel in scan list, does active or passive scan
27483058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 5)  Sends SCAN_RESULT notification to driver
27493058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 6)  Checks to see if it has time to do scan on *next* channel in list
27503058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 7)  Repeats 4-6 until it no longer has time to scan the next channel
27513058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *     before max_out_time expires
27523058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 8)  Returns to service channel
27533058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 9)  Sends NULL packet with PS=0 to tell AP that we're back
27543058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 10) Stays on service channel until suspend_time expires
27553058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 11) Repeats entire process 2-10 until list is complete
27563058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * 12) Sends SCAN_COMPLETE notification
27573058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *
27583058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * For fast, efficient scans, the scan command also has support for staying on
27593058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * a channel for just a short time, if doing active scanning and getting no
27603058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * responses to the transmitted probe request.  This time is controlled by
27613058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * quiet_time, and the number of received packets below which a channel is
27623058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * considered "quiet" is controlled by quiet_plcp_threshold.
27633058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *
27643058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * For active scanning on channels that have regulatory restrictions against
27653058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * blindly transmitting, the scan can listen before transmitting, to make sure
27663058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * that there is already legitimate activity on the channel.  If enough
27673058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * packets are cleanly received on the channel (controlled by good_CRC_th,
27683058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * typical value 1), the scan engine starts transmitting probe requests.
27693058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *
27703058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * Driver must use separate scan commands for 2.4 vs. 5 GHz bands.
27713058f02137359efb412975cf94a9fa7c25413387Ben M Cahill *
27723058f02137359efb412975cf94a9fa7c25413387Ben M Cahill * To avoid uCode errors, see timing restrictions described under
27732a421b91d6fe89e27ded7544a25449c0b050098fTomas Winkler * struct iwl_scan_channel.
2774b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
27753d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
27763d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_scan_cmd {
27773d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 len;
27783d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 reserved0;
27793d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 channel_count;	/* # channels in channel list */
27803d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 quiet_time;	/* dwell only this # millisecs on quiet channel
27813d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler				 * (only for active scan) */
27823d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 quiet_plcp_th;	/* quiet chnl is < this # pkts (typ. 1) */
27833d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 good_CRC_th;	/* passive -> active promotion threshold */
27843d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 reserved1;
27853d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 max_out_time;	/* max usec to be away from associated (service)
27863d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler				 * channel */
27873d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 suspend_time;	/* pause scan this long (in "extended beacon
27883d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler				 * format") when returning to service channel:
27893d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler				 * 3945; 31:24 # beacons, 19:0 additional usec,
27903d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler				 * 4965; 31:22 # beacons, 21:0 additional usec.
27913d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler				 */
27923d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 flags;		/* RXON_FLG_* */
27933d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 filter_flags;	/* RXON_FILTER_* */
27943d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
27953d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	/* For active scans (set to all-0s for passive scans).
27963d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * Does not include payload.  Must specify Tx rate; no rate scaling. */
27973d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct iwl3945_tx_cmd tx_cmd;
27983d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
27993d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	/* For directed active scans (set to all-0s otherwise) */
28009b3bf06abad70db820c74c90118ea49358549d22Johannes Berg	struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX_3945];
28013d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
28023d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	/*
28033d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * Probe request frame, followed by channel list.
28043d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 *
28053d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * Size of probe request frame is specified by byte count in tx_cmd.
28063d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * Channel list follows immediately after probe request frame.
28073d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * Number of channels in list is specified by channel_count.
28083d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * Each channel in list is of type:
28093d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 *
28103d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * struct iwl3945_scan_channel channels[0];
28113d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 *
28123d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * NOTE:  Only one band of channels can be scanned per pass.  You
28133d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * must not mix 2.4GHz channels and 5.2GHz channels, and you must wait
28143d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * for one scan to complete (i.e. receive SCAN_COMPLETE_NOTIFICATION)
28153d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 * before requesting another scan.
28163d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	 */
28173d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 data[0];
2818ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
28193d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
28202a421b91d6fe89e27ded7544a25449c0b050098fTomas Winklerstruct iwl_scan_cmd {
2821b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 len;
2822b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved0;
28233058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	u8 channel_count;	/* # channels in channel list */
28243058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le16 quiet_time;	/* dwell only this # millisecs on quiet channel
28253058f02137359efb412975cf94a9fa7c25413387Ben M Cahill				 * (only for active scan) */
28263058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le16 quiet_plcp_th;	/* quiet chnl is < this # pkts (typ. 1) */
28273058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le16 good_CRC_th;	/* passive -> active promotion threshold */
28283058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le16 rx_chain;	/* RXON_RX_CHAIN_* */
28293058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le32 max_out_time;	/* max usec to be away from associated (service)
28303058f02137359efb412975cf94a9fa7c25413387Ben M Cahill				 * channel */
28313058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le32 suspend_time;	/* pause scan this long (in "extended beacon
28323058f02137359efb412975cf94a9fa7c25413387Ben M Cahill				 * format") when returning to service chnl:
28333058f02137359efb412975cf94a9fa7c25413387Ben M Cahill				 * 3945; 31:24 # beacons, 19:0 additional usec,
28343058f02137359efb412975cf94a9fa7c25413387Ben M Cahill				 * 4965; 31:22 # beacons, 21:0 additional usec.
28353058f02137359efb412975cf94a9fa7c25413387Ben M Cahill				 */
28363058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le32 flags;		/* RXON_FLG_* */
28373058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le32 filter_flags;	/* RXON_FILTER_* */
28383058f02137359efb412975cf94a9fa7c25413387Ben M Cahill
28393058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	/* For active scans (set to all-0s for passive scans).
28403058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 * Does not include payload.  Must specify Tx rate; no rate scaling. */
284183d527d9e8f9aff92cbd33f208f77c055dabb499Tomas Winkler	struct iwl_tx_cmd tx_cmd;
28423058f02137359efb412975cf94a9fa7c25413387Ben M Cahill
28433058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	/* For directed active scans (set to all-0s otherwise) */
28442a421b91d6fe89e27ded7544a25449c0b050098fTomas Winkler	struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX];
2845b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2846b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	/*
28473058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 * Probe request frame, followed by channel list.
28483058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 *
28493058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 * Size of probe request frame is specified by byte count in tx_cmd.
28503058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 * Channel list follows immediately after probe request frame.
28513058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 * Number of channels in list is specified by channel_count.
28523058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 * Each channel in list is of type:
2853b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 *
28542aa6ab86bc475a115f56645591d2413981846509Tomas Winkler	 * struct iwl_scan_channel channels[0];
2855b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 *
2856b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 * NOTE:  Only one band of channels can be scanned per pass.  You
28573058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 * must not mix 2.4GHz channels and 5.2GHz channels, and you must wait
28583058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 * for one scan to complete (i.e. receive SCAN_COMPLETE_NOTIFICATION)
28593058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	 * before requesting another scan.
2860b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	 */
28613058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	u8 data[0];
2862ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
2863b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2864b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* Can abort will notify by complete notification with abort status. */
286551e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define CAN_ABORT_STATUS	cpu_to_le32(0x1)
2866b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* complete notification statuses */
2867b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define ABORT_STATUS            0x2
2868b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2869b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2870b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_SCAN_CMD = 0x80 (response)
2871b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
28722a421b91d6fe89e27ded7544a25449c0b050098fTomas Winklerstruct iwl_scanreq_notification {
2873b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 status;		/* 1: okay, 2: cannot fulfill request */
2874ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
2875b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2876b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2877b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * SCAN_START_NOTIFICATION = 0x82 (notification only, not a command)
2878b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
28792a421b91d6fe89e27ded7544a25449c0b050098fTomas Winklerstruct iwl_scanstart_notification {
2880b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 tsf_low;
2881b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 tsf_high;
2882b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_timer;
2883b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 channel;
2884b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 band;
2885b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved[2];
2886b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 status;
2887ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
2888b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2889b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define  SCAN_OWNER_STATUS 0x1;
2890b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define  MEASURE_OWNER_STATUS 0x2;
2891b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2892b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define NUMBER_OF_STATISTICS 1	/* first __le32 is good CRC */
2893b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2894b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * SCAN_RESULTS_NOTIFICATION = 0x83 (notification only, not a command)
2895b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
28962a421b91d6fe89e27ded7544a25449c0b050098fTomas Winklerstruct iwl_scanresults_notification {
2897b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 channel;
2898b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 band;
2899b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved[2];
2900b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 tsf_low;
2901b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 tsf_high;
2902b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 statistics[NUMBER_OF_STATISTICS];
2903ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
2904b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2905b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2906b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * SCAN_COMPLETE_NOTIFICATION = 0x84 (notification only, not a command)
2907b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
29082a421b91d6fe89e27ded7544a25449c0b050098fTomas Winklerstruct iwl_scancomplete_notification {
2909b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 scanned_channels;
2910b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 status;
2911b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved;
2912b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 last_channel;
2913b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 tsf_low;
2914b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 tsf_high;
2915ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
2916b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2917b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2918b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
2919b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (9)
2920b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * IBSS/AP Commands and Notifications:
2921b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
2922b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
2923b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2924a85d7cca1204f2dba86d2f61693f0fe8c48f0fa5Johannes Bergenum iwl_ibss_manager {
2925a85d7cca1204f2dba86d2f61693f0fe8c48f0fa5Johannes Berg	IWL_NOT_IBSS_MANAGER = 0,
2926a85d7cca1204f2dba86d2f61693f0fe8c48f0fa5Johannes Berg	IWL_IBSS_MANAGER = 1,
2927a85d7cca1204f2dba86d2f61693f0fe8c48f0fa5Johannes Berg};
2928a85d7cca1204f2dba86d2f61693f0fe8c48f0fa5Johannes Berg
2929b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2930b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * BEACON_NOTIFICATION = 0x90 (notification only, not a command)
2931b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
29323d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
29333d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_beacon_notif {
29343d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct iwl3945_tx_resp beacon_notify_hdr;
29353d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 low_tsf;
29363d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 high_tsf;
29373d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 ibss_mgr_status;
2938ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
29393d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
2940bb8c093bdea62f2ae371b98ebff81b0407852fafChristoph Hellwigstruct iwl4965_beacon_notif {
2941bb8c093bdea62f2ae371b98ebff81b0407852fafChristoph Hellwig	struct iwl4965_tx_resp beacon_notify_hdr;
2942b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 low_tsf;
2943b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 high_tsf;
2944b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 ibss_mgr_status;
2945ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
2946b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2947b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
2948b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_TX_BEACON = 0x91 (command, has simple generic response)
2949b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
29503d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
29513d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_tx_beacon_cmd {
29523d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct iwl3945_tx_cmd tx;
29533d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le16 tim_idx;
29543d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 tim_size;
29553d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	u8 reserved1;
29563d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct ieee80211_hdr frame[0];	/* beacon frame */
2957ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
29583d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
29594bf64efd26f5610cde4fb7846e2f37bd1f62d3a9Tomas Winklerstruct iwl_tx_beacon_cmd {
296083d527d9e8f9aff92cbd33f208f77c055dabb499Tomas Winkler	struct iwl_tx_cmd tx;
2961b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le16 tim_idx;
2962b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 tim_size;
2963b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved1;
2964b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct ieee80211_hdr frame[0];	/* beacon frame */
2965ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
2966b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2967b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
2968b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (10)
2969b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Statistics Commands and Notifications:
2970b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
2971b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
2972b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2973b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define IWL_TEMP_CONVERT 260
2974b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2975b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define SUP_RATE_11A_MAX_NUM_CHANNELS  8
2976b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define SUP_RATE_11B_MAX_NUM_CHANNELS  4
2977b481de9ca074528fe8c429604e2777db8b89806aZhu Yi#define SUP_RATE_11G_MAX_NUM_CHANNELS  12
2978b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2979b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* Used for passing to driver number of successes and failures per rate */
2980b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct rate_histogram {
2981b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	union {
2982b481de9ca074528fe8c429604e2777db8b89806aZhu Yi		__le32 a[SUP_RATE_11A_MAX_NUM_CHANNELS];
2983b481de9ca074528fe8c429604e2777db8b89806aZhu Yi		__le32 b[SUP_RATE_11B_MAX_NUM_CHANNELS];
2984b481de9ca074528fe8c429604e2777db8b89806aZhu Yi		__le32 g[SUP_RATE_11G_MAX_NUM_CHANNELS];
2985b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	} success;
2986b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	union {
2987b481de9ca074528fe8c429604e2777db8b89806aZhu Yi		__le32 a[SUP_RATE_11A_MAX_NUM_CHANNELS];
2988b481de9ca074528fe8c429604e2777db8b89806aZhu Yi		__le32 b[SUP_RATE_11B_MAX_NUM_CHANNELS];
2989b481de9ca074528fe8c429604e2777db8b89806aZhu Yi		__le32 g[SUP_RATE_11G_MAX_NUM_CHANNELS];
2990b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	} failed;
2991ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
2992b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
2993b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/* statistics command response */
2994b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
29953d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl39_statistics_rx_phy {
29963d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 ina_cnt;
29973d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 fina_cnt;
29983d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 plcp_err;
29993d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 crc32_err;
30003d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 overrun_err;
30013d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 early_overrun_err;
30023d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 crc32_good;
30033d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 false_alarm_cnt;
30043d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 fina_sync_err_cnt;
30053d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 sfd_timeout;
30063d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 fina_timeout;
30073d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 unresponded_rts;
30083d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 rxe_frame_limit_overrun;
30093d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 sent_ack_cnt;
30103d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 sent_cts_cnt;
3011ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
30123d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
30133d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl39_statistics_rx_non_phy {
30143d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 bogus_cts;	/* CTS received when not expecting CTS */
30153d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 bogus_ack;	/* ACK received when not expecting ACK */
30163d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 non_bssid_frames;	/* number of frames with BSSID that
30173d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler					 * doesn't belong to the STA BSSID */
30183d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 filtered_frames;	/* count frames that were dumped in the
30193d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler				 * filtering process */
30203d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 non_channel_beacons;	/* beacons with our bss id but not on
30213d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler					 * our serving channel */
3022ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
30233d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
30243d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl39_statistics_rx {
30253d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct iwl39_statistics_rx_phy ofdm;
30263d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct iwl39_statistics_rx_phy cck;
30273d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct iwl39_statistics_rx_non_phy general;
3028ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
30293d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
30303d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl39_statistics_tx {
30313d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 preamble_cnt;
30323d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 rx_detected_cnt;
30333d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 bt_prio_defer_cnt;
30343d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 bt_prio_kill_cnt;
30353d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 few_bytes_cnt;
30363d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 cts_timeout;
30373d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 ack_timeout;
30383d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 expected_ack_cnt;
30393d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 actual_ack_cnt;
3040ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
30413d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
30423d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct statistics_dbg {
30433d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 burst_check;
30443d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 burst_count;
30457c094c5cc4d28062abf0d33ca022dbea6c522558Wey-Yi Guy	__le32 wait_for_silence_timeout_cnt;
30467c094c5cc4d28062abf0d33ca022dbea6c522558Wey-Yi Guy	__le32 reserved[3];
3047ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
30483d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
30493d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl39_statistics_div {
30503d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 tx_on_a;
30513d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 tx_on_b;
30523d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 exec_time;
30533d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 probe_time;
3054ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
30553d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
30563d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl39_statistics_general {
30573d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 temperature;
30583d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct statistics_dbg dbg;
30593d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 sleep_time;
30603d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 slots_out;
30613d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 slots_idle;
30623d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 ttl_timestamp;
30633d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct iwl39_statistics_div div;
3064ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
30653d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
3066b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct statistics_rx_phy {
3067b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 ina_cnt;
3068b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 fina_cnt;
3069b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 plcp_err;
3070b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 crc32_err;
3071b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 overrun_err;
3072b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 early_overrun_err;
3073b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 crc32_good;
3074b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 false_alarm_cnt;
3075b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 fina_sync_err_cnt;
3076b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 sfd_timeout;
3077b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 fina_timeout;
3078b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 unresponded_rts;
3079b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 rxe_frame_limit_overrun;
3080b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 sent_ack_cnt;
3081b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 sent_cts_cnt;
3082b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 sent_ba_rsp_cnt;
3083b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 dsp_self_kill;
3084b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 mh_format_err;
3085b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 re_acq_main_rssi_sum;
3086b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 reserved3;
3087ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
3088b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3089b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct statistics_rx_ht_phy {
3090b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 plcp_err;
3091b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 overrun_err;
3092b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 early_overrun_err;
3093b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 crc32_good;
3094b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 crc32_err;
3095b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 mh_format_err;
3096b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 agg_crc32_good;
3097b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 agg_mpdu_cnt;
3098b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 agg_cnt;
3099f0118a4575d45ce3074c830660de938bc6e17bdaWey-Yi Guy	__le32 unsupport_mcs;
3100ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
3101b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3102c1b4aa3fb619782213af2af6652663c8f9cef373Harvey Harrison#define INTERFERENCE_DATA_AVAILABLE      cpu_to_le32(1)
310334c22cf93d1446791c966c878cc691e07c39d8d3Winkler, Tomas
3104b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct statistics_rx_non_phy {
3105b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 bogus_cts;	/* CTS received when not expecting CTS */
3106b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 bogus_ack;	/* ACK received when not expecting ACK */
3107b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 non_bssid_frames;	/* number of frames with BSSID that
3108b481de9ca074528fe8c429604e2777db8b89806aZhu Yi					 * doesn't belong to the STA BSSID */
3109b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 filtered_frames;	/* count frames that were dumped in the
3110b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 * filtering process */
3111b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 non_channel_beacons;	/* beacons with our bss id but not on
3112b481de9ca074528fe8c429604e2777db8b89806aZhu Yi					 * our serving channel */
3113b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 channel_beacons;	/* beacons with our bss id and in our
3114b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 * serving channel */
3115b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 num_missed_bcon;	/* number of missed beacons */
3116b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 adc_rx_saturation_time;	/* count in 0.8us units the time the
3117b481de9ca074528fe8c429604e2777db8b89806aZhu Yi					 * ADC was in saturation */
3118b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 ina_detection_search_time;/* total time (in 0.8us) searched
3119b481de9ca074528fe8c429604e2777db8b89806aZhu Yi					  * for INA */
3120b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_silence_rssi_a;	/* RSSI silence after beacon frame */
3121b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_silence_rssi_b;	/* RSSI silence after beacon frame */
3122b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_silence_rssi_c;	/* RSSI silence after beacon frame */
3123b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 interference_data_flag;	/* flag for interference data
3124b481de9ca074528fe8c429604e2777db8b89806aZhu Yi					 * availability. 1 when data is
3125b481de9ca074528fe8c429604e2777db8b89806aZhu Yi					 * available. */
31263058f02137359efb412975cf94a9fa7c25413387Ben M Cahill	__le32 channel_load;		/* counts RX Enable time in uSec */
3127b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 dsp_false_alarms;	/* DSP false alarm (both OFDM
3128b481de9ca074528fe8c429604e2777db8b89806aZhu Yi					 * and CCK) counter */
3129b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_rssi_a;
3130b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_rssi_b;
3131b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_rssi_c;
3132b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_energy_a;
3133b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_energy_b;
3134b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 beacon_energy_c;
3135ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
3136b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3137325322ee34d726bff922853d509e135c8d262e2fWey-Yi Guystruct statistics_rx_non_phy_bt {
3138325322ee34d726bff922853d509e135c8d262e2fWey-Yi Guy	struct statistics_rx_non_phy common;
3139325322ee34d726bff922853d509e135c8d262e2fWey-Yi Guy	/* additional stats for bt */
3140325322ee34d726bff922853d509e135c8d262e2fWey-Yi Guy	__le32 num_bt_kills;
3141325322ee34d726bff922853d509e135c8d262e2fWey-Yi Guy	__le32 reserved[2];
3142da22f795cefb7c9f8a7bc6f22b1c16f1ff15a392John W. Linville} __packed;
3143325322ee34d726bff922853d509e135c8d262e2fWey-Yi Guy
3144b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct statistics_rx {
3145b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct statistics_rx_phy ofdm;
3146b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct statistics_rx_phy cck;
3147b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct statistics_rx_non_phy general;
3148b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct statistics_rx_ht_phy ofdm_ht;
3149ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
3150b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3151325322ee34d726bff922853d509e135c8d262e2fWey-Yi Guystruct statistics_rx_bt {
3152325322ee34d726bff922853d509e135c8d262e2fWey-Yi Guy	struct statistics_rx_phy ofdm;
3153325322ee34d726bff922853d509e135c8d262e2fWey-Yi Guy	struct statistics_rx_phy cck;
3154325322ee34d726bff922853d509e135c8d262e2fWey-Yi Guy	struct statistics_rx_non_phy_bt general;
3155325322ee34d726bff922853d509e135c8d262e2fWey-Yi Guy	struct statistics_rx_ht_phy ofdm_ht;
3156da22f795cefb7c9f8a7bc6f22b1c16f1ff15a392John W. Linville} __packed;
3157325322ee34d726bff922853d509e135c8d262e2fWey-Yi Guy
3158fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy/**
3159fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy * struct statistics_tx_power - current tx power
3160fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy *
3161fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy * @ant_a: current tx power on chain a in 1/2 dB step
3162fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy * @ant_b: current tx power on chain b in 1/2 dB step
3163fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy * @ant_c: current tx power on chain c in 1/2 dB step
3164fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy */
3165fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guystruct statistics_tx_power {
3166fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy	u8 ant_a;
3167fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy	u8 ant_b;
3168fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy	u8 ant_c;
3169fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy	u8 reserved;
3170ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
3171fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy
3172b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct statistics_tx_non_phy_agg {
3173b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 ba_timeout;
3174b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 ba_reschedule_frames;
3175b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 scd_query_agg_frame_cnt;
3176b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 scd_query_no_agg;
3177b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 scd_query_agg;
3178b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 scd_query_mismatch;
3179b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 frame_not_ready;
3180b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 underrun;
3181b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 bt_prio_kill;
3182b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 rx_ba_rsp_cnt;
3183ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
3184b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3185b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct statistics_tx {
3186b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 preamble_cnt;
3187b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 rx_detected_cnt;
3188b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 bt_prio_defer_cnt;
3189b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 bt_prio_kill_cnt;
3190b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 few_bytes_cnt;
3191b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 cts_timeout;
3192b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 ack_timeout;
3193b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 expected_ack_cnt;
3194b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 actual_ack_cnt;
3195b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 dump_msdu_cnt;
3196b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 burst_abort_next_frame_mismatch_cnt;
3197b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 burst_abort_missing_next_frame_cnt;
3198b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 cts_timeout_collision;
3199b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 ack_or_ba_timeout_collision;
3200b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct statistics_tx_non_phy_agg agg;
3201470356b891f1d18e87d5fdc393976fab6d0a978dWey-Yi Guy	/*
3202470356b891f1d18e87d5fdc393976fab6d0a978dWey-Yi Guy	 * "tx_power" are optional parameters provided by uCode,
3203470356b891f1d18e87d5fdc393976fab6d0a978dWey-Yi Guy	 * 6000 series is the only device provide the information,
3204470356b891f1d18e87d5fdc393976fab6d0a978dWey-Yi Guy	 * Those are reserved fields for all the other devices
3205470356b891f1d18e87d5fdc393976fab6d0a978dWey-Yi Guy	 */
3206fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy	struct statistics_tx_power tx_power;
3207fcbaf8b06da385c73cb6218f079e9ddba9ee9f7cWey-Yi Guy	__le32 reserved1;
3208ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
3209b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3210b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3211b481de9ca074528fe8c429604e2777db8b89806aZhu Yistruct statistics_div {
3212b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 tx_on_a;
3213b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 tx_on_b;
3214b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 exec_time;
3215b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 probe_time;
3216b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 reserved1;
3217b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 reserved2;
3218ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
3219b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3220325322ee34d726bff922853d509e135c8d262e2fWey-Yi Guystruct statistics_general_common {
3221f0118a4575d45ce3074c830660de938bc6e17bdaWey-Yi Guy	__le32 temperature;   /* radio temperature */
3222f0118a4575d45ce3074c830660de938bc6e17bdaWey-Yi Guy	__le32 temperature_m; /* for 5000 and up, this is radio voltage */
3223b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct statistics_dbg dbg;
3224b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 sleep_time;
3225b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 slots_out;
3226b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 slots_idle;
3227b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 ttl_timestamp;
3228b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct statistics_div div;
3229b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 rx_enable_counter;
323011fc524941248dc717f1af5dfa844eceb7c0217fWey-Yi Guy	/*
323111fc524941248dc717f1af5dfa844eceb7c0217fWey-Yi Guy	 * num_of_sos_states:
323211fc524941248dc717f1af5dfa844eceb7c0217fWey-Yi Guy	 *  count the number of times we have to re-tune
323311fc524941248dc717f1af5dfa844eceb7c0217fWey-Yi Guy	 *  in order to get out of bad PHY status
323411fc524941248dc717f1af5dfa844eceb7c0217fWey-Yi Guy	 */
323511fc524941248dc717f1af5dfa844eceb7c0217fWey-Yi Guy	__le32 num_of_sos_states;
3236da22f795cefb7c9f8a7bc6f22b1c16f1ff15a392John W. Linville} __packed;
3237325322ee34d726bff922853d509e135c8d262e2fWey-Yi Guy
3238325322ee34d726bff922853d509e135c8d262e2fWey-Yi Guystruct statistics_bt_activity {
3239325322ee34d726bff922853d509e135c8d262e2fWey-Yi Guy	/* Tx statistics */
3240325322ee34d726bff922853d509e135c8d262e2fWey-Yi Guy	__le32 hi_priority_tx_req_cnt;
3241325322ee34d726bff922853d509e135c8d262e2fWey-Yi Guy	__le32 hi_priority_tx_denied_cnt;
3242325322ee34d726bff922853d509e135c8d262e2fWey-Yi Guy	__le32 lo_priority_tx_req_cnt;
3243325322ee34d726bff922853d509e135c8d262e2fWey-Yi Guy	__le32 lo_priority_tx_denied_cnt;
3244325322ee34d726bff922853d509e135c8d262e2fWey-Yi Guy	/* Rx statistics */
3245325322ee34d726bff922853d509e135c8d262e2fWey-Yi Guy	__le32 hi_priority_rx_req_cnt;
3246325322ee34d726bff922853d509e135c8d262e2fWey-Yi Guy	__le32 hi_priority_rx_denied_cnt;
3247325322ee34d726bff922853d509e135c8d262e2fWey-Yi Guy	__le32 lo_priority_rx_req_cnt;
3248325322ee34d726bff922853d509e135c8d262e2fWey-Yi Guy	__le32 lo_priority_rx_denied_cnt;
3249da22f795cefb7c9f8a7bc6f22b1c16f1ff15a392John W. Linville} __packed;
3250325322ee34d726bff922853d509e135c8d262e2fWey-Yi Guy
3251325322ee34d726bff922853d509e135c8d262e2fWey-Yi Guystruct statistics_general {
3252325322ee34d726bff922853d509e135c8d262e2fWey-Yi Guy	struct statistics_general_common common;
3253325322ee34d726bff922853d509e135c8d262e2fWey-Yi Guy	__le32 reserved2;
3254325322ee34d726bff922853d509e135c8d262e2fWey-Yi Guy	__le32 reserved3;
3255da22f795cefb7c9f8a7bc6f22b1c16f1ff15a392John W. Linville} __packed;
3256325322ee34d726bff922853d509e135c8d262e2fWey-Yi Guy
3257325322ee34d726bff922853d509e135c8d262e2fWey-Yi Guystruct statistics_general_bt {
3258325322ee34d726bff922853d509e135c8d262e2fWey-Yi Guy	struct statistics_general_common common;
3259325322ee34d726bff922853d509e135c8d262e2fWey-Yi Guy	struct statistics_bt_activity activity;
3260b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 reserved2;
3261b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 reserved3;
3262ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
3263b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3264ef8d5529b015d4c5db7fad1adfc91edfd5abad56Wey-Yi Guy#define UCODE_STATISTICS_CLEAR_MSK		(0x1 << 0)
3265ef8d5529b015d4c5db7fad1adfc91edfd5abad56Wey-Yi Guy#define UCODE_STATISTICS_FREQUENCY_MSK		(0x1 << 1)
3266ef8d5529b015d4c5db7fad1adfc91edfd5abad56Wey-Yi Guy#define UCODE_STATISTICS_NARROW_BAND_MSK	(0x1 << 2)
3267ef8d5529b015d4c5db7fad1adfc91edfd5abad56Wey-Yi Guy
3268b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
3269b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_STATISTICS_CMD = 0x9c,
3270b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * 3945 and 4965 identical.
3271b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
3272b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * This command triggers an immediate response containing uCode statistics.
3273b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * The response is in the same format as STATISTICS_NOTIFICATION 0x9d, below.
3274b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
3275b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * If the CLEAR_STATS configuration flag is set, uCode will clear its
3276b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * internal copy of the statistics (counters) after issuing the response.
3277b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * This flag does not affect STATISTICS_NOTIFICATIONs after beacons (see below).
3278b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
3279b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * If the DISABLE_NOTIF configuration flag is set, uCode will not issue
3280b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * STATISTICS_NOTIFICATIONs after received beacons (see below).  This flag
3281b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * does not affect the response to the REPLY_STATISTICS_CMD 0x9c itself.
3282b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
328351e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define IWL_STATS_CONF_CLEAR_STATS cpu_to_le32(0x1)	/* see above */
328451e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define IWL_STATS_CONF_DISABLE_NOTIF cpu_to_le32(0x2)/* see above */
32858f91aecb4cdc2d786df8941e827b9dff3c10a4e4Emmanuel Grumbachstruct iwl_statistics_cmd {
3286b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 configuration_flags;	/* IWL_STATS_CONF_* */
3287ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
3288b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3289b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
3290b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * STATISTICS_NOTIFICATION = 0x9d (notification only, not a command)
3291b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
3292b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * By default, uCode issues this notification after receiving a beacon
3293b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * while associated.  To disable this behavior, set DISABLE_NOTIF flag in the
3294b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_STATISTICS_CMD 0x9c, above.
3295b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
3296b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Statistics counters continue to increment beacon after beacon, but are
3297b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * cleared when changing channels or when driver issues REPLY_STATISTICS_CMD
3298b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * 0x9c with CLEAR_STATS bit set (see above).
3299b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
3300b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * uCode also issues this notification during scans.  uCode clears statistics
3301b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * appropriately so that each notification contains statistics for only the
3302b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * one channel that has just been scanned.
3303b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
330451e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define STATISTICS_REPLY_FLG_BAND_24G_MSK         cpu_to_le32(0x2)
33057aafef1c6e2e24f9a10dc2972bf0ee70624ccc47Wey-Yi Guy#define STATISTICS_REPLY_FLG_HT40_MODE_MSK        cpu_to_le32(0x8)
33063d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
33073d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winklerstruct iwl3945_notif_statistics {
33083d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	__le32 flag;
33093d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct iwl39_statistics_rx rx;
33103d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct iwl39_statistics_tx tx;
33113d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler	struct iwl39_statistics_general general;
3312ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
33133d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
33148f91aecb4cdc2d786df8941e827b9dff3c10a4e4Emmanuel Grumbachstruct iwl_notif_statistics {
3315b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 flag;
3316b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct statistics_rx rx;
3317b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct statistics_tx tx;
3318b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	struct statistics_general general;
3319ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
3320b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3321325322ee34d726bff922853d509e135c8d262e2fWey-Yi Guystruct iwl_bt_notif_statistics {
3322325322ee34d726bff922853d509e135c8d262e2fWey-Yi Guy	__le32 flag;
3323325322ee34d726bff922853d509e135c8d262e2fWey-Yi Guy	struct statistics_rx_bt rx;
3324325322ee34d726bff922853d509e135c8d262e2fWey-Yi Guy	struct statistics_tx tx;
3325325322ee34d726bff922853d509e135c8d262e2fWey-Yi Guy	struct statistics_general_bt general;
3326da22f795cefb7c9f8a7bc6f22b1c16f1ff15a392John W. Linville} __packed;
3327b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3328b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
3329b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * MISSED_BEACONS_NOTIFICATION = 0xa2 (notification only, not a command)
3330a13d276f1e49ae0bc4ad18ce8ea3c90656c9e8d4Wey-Yi Guy *
3331a13d276f1e49ae0bc4ad18ce8ea3c90656c9e8d4Wey-Yi Guy * uCode send MISSED_BEACONS_NOTIFICATION to driver when detect beacon missed
3332a13d276f1e49ae0bc4ad18ce8ea3c90656c9e8d4Wey-Yi Guy * in regardless of how many missed beacons, which mean when driver receive the
3333a13d276f1e49ae0bc4ad18ce8ea3c90656c9e8d4Wey-Yi Guy * notification, inside the command, it can find all the beacons information
3334a13d276f1e49ae0bc4ad18ce8ea3c90656c9e8d4Wey-Yi Guy * which include number of total missed beacons, number of consecutive missed
3335a13d276f1e49ae0bc4ad18ce8ea3c90656c9e8d4Wey-Yi Guy * beacons, number of beacons received and number of beacons expected to
3336a13d276f1e49ae0bc4ad18ce8ea3c90656c9e8d4Wey-Yi Guy * receive.
3337a13d276f1e49ae0bc4ad18ce8ea3c90656c9e8d4Wey-Yi Guy *
3338a13d276f1e49ae0bc4ad18ce8ea3c90656c9e8d4Wey-Yi Guy * If uCode detected consecutive_missed_beacons > 5, it will reset the radio
3339a13d276f1e49ae0bc4ad18ce8ea3c90656c9e8d4Wey-Yi Guy * in order to bring the radio/PHY back to working state; which has no relation
3340a13d276f1e49ae0bc4ad18ce8ea3c90656c9e8d4Wey-Yi Guy * to when driver will perform sensitivity calibration.
3341a13d276f1e49ae0bc4ad18ce8ea3c90656c9e8d4Wey-Yi Guy *
3342a13d276f1e49ae0bc4ad18ce8ea3c90656c9e8d4Wey-Yi Guy * Driver should set it own missed_beacon_threshold to decide when to perform
3343a13d276f1e49ae0bc4ad18ce8ea3c90656c9e8d4Wey-Yi Guy * sensitivity calibration based on number of consecutive missed beacons in
3344a13d276f1e49ae0bc4ad18ce8ea3c90656c9e8d4Wey-Yi Guy * order to improve overall performance, especially in noisy environment.
3345a13d276f1e49ae0bc4ad18ce8ea3c90656c9e8d4Wey-Yi Guy *
3346b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
3347a13d276f1e49ae0bc4ad18ce8ea3c90656c9e8d4Wey-Yi Guy
3348a13d276f1e49ae0bc4ad18ce8ea3c90656c9e8d4Wey-Yi Guy#define IWL_MISSED_BEACON_THRESHOLD_MIN	(1)
3349a13d276f1e49ae0bc4ad18ce8ea3c90656c9e8d4Wey-Yi Guy#define IWL_MISSED_BEACON_THRESHOLD_DEF	(5)
3350a13d276f1e49ae0bc4ad18ce8ea3c90656c9e8d4Wey-Yi Guy#define IWL_MISSED_BEACON_THRESHOLD_MAX	IWL_MISSED_BEACON_THRESHOLD_DEF
3351b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
33522aa6ab86bc475a115f56645591d2413981846509Tomas Winklerstruct iwl_missed_beacon_notif {
3353a13d276f1e49ae0bc4ad18ce8ea3c90656c9e8d4Wey-Yi Guy	__le32 consecutive_missed_beacons;
3354b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 total_missed_becons;
3355b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 num_expected_beacons;
3356b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 num_recvd_beacons;
3357ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
3358b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3359f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill
3360b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
3361b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (11)
3362b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Rx Calibration Commands:
3363b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
3364f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * With the uCode used for open source drivers, most Tx calibration (except
3365f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * for Tx Power) and most Rx calibration is done by uCode during the
3366f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * "initialize" phase of uCode boot.  Driver must calibrate only:
3367f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3368f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * 1)  Tx power (depends on temperature), described elsewhere
3369f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * 2)  Receiver gain balance (optimize MIMO, and detect disconnected antennas)
3370f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * 3)  Receiver sensitivity (to optimize signal detection)
3371f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3372b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
3373b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3374f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill/**
3375f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * SENSITIVITY_CMD = 0xa8 (command, has simple generic response)
3376f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3377f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * This command sets up the Rx signal detector for a sensitivity level that
3378f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * is high enough to lock onto all signals within the associated network,
3379f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * but low enough to ignore signals that are below a certain threshold, so as
3380f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * not to have too many "false alarms".  False alarms are signals that the
3381f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * Rx DSP tries to lock onto, but then discards after determining that they
3382f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * are noise.
3383f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3384f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * The optimum number of false alarms is between 5 and 50 per 200 TUs
3385f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * (200 * 1024 uSecs, i.e. 204.8 milliseconds) of actual Rx time (i.e.
3386f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * time listening, not transmitting).  Driver must adjust sensitivity so that
3387f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * the ratio of actual false alarms to actual Rx time falls within this range.
3388f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3389f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * While associated, uCode delivers STATISTICS_NOTIFICATIONs after each
3390f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * received beacon.  These provide information to the driver to analyze the
3391f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * sensitivity.  Don't analyze statistics that come in from scanning, or any
3392f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * other non-associated-network source.  Pertinent statistics include:
3393f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3394f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * From "general" statistics (struct statistics_rx_non_phy):
3395f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3396f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * (beacon_energy_[abc] & 0x0FF00) >> 8 (unsigned, higher value is lower level)
3397f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   Measure of energy of desired signal.  Used for establishing a level
3398f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   below which the device does not detect signals.
3399f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3400f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * (beacon_silence_rssi_[abc] & 0x0FF00) >> 8 (unsigned, units in dB)
3401f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   Measure of background noise in silent period after beacon.
3402f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3403f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * channel_load
3404f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   uSecs of actual Rx time during beacon period (varies according to
3405f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   how much time was spent transmitting).
3406f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3407f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * From "cck" and "ofdm" statistics (struct statistics_rx_phy), separately:
3408f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3409f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * false_alarm_cnt
3410f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   Signal locks abandoned early (before phy-level header).
3411f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3412f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * plcp_err
3413f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   Signal locks abandoned late (during phy-level header).
3414f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3415f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * NOTE:  Both false_alarm_cnt and plcp_err increment monotonically from
3416f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        beacon to beacon, i.e. each value is an accumulation of all errors
3417f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        before and including the latest beacon.  Values will wrap around to 0
3418f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        after counting up to 2^32 - 1.  Driver must differentiate vs.
3419f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        previous beacon's values to determine # false alarms in the current
3420f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        beacon period.
3421f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3422f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * Total number of false alarms = false_alarms + plcp_errs
3423f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3424f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * For OFDM, adjust the following table entries in struct iwl_sensitivity_cmd
3425f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * (notice that the start points for OFDM are at or close to settings for
3426f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * maximum sensitivity):
3427f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3428f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *                                             START  /  MIN  /  MAX
3429f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   HD_AUTO_CORR32_X1_TH_ADD_MIN_INDEX          90   /   85  /  120
3430f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_INDEX     170   /  170  /  210
3431f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX         105   /  105  /  140
3432f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_INDEX     220   /  220  /  270
3433f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3434f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   If actual rate of OFDM false alarms (+ plcp_errors) is too high
3435f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   (greater than 50 for each 204.8 msecs listening), reduce sensitivity
3436f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   by *adding* 1 to all 4 of the table entries above, up to the max for
3437f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   each entry.  Conversely, if false alarm rate is too low (less than 5
3438f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   for each 204.8 msecs listening), *subtract* 1 from each entry to
3439f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   increase sensitivity.
3440f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3441f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * For CCK sensitivity, keep track of the following:
3442f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3443f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   1).  20-beacon history of maximum background noise, indicated by
3444f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        (beacon_silence_rssi_[abc] & 0x0FF00), units in dB, across the
3445f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        3 receivers.  For any given beacon, the "silence reference" is
3446f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        the maximum of last 60 samples (20 beacons * 3 receivers).
3447f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3448f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   2).  10-beacon history of strongest signal level, as indicated
3449f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        by (beacon_energy_[abc] & 0x0FF00) >> 8, across the 3 receivers,
3450f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        i.e. the strength of the signal through the best receiver at the
3451f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        moment.  These measurements are "upside down", with lower values
3452f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        for stronger signals, so max energy will be *minimum* value.
3453f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3454f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        Then for any given beacon, the driver must determine the *weakest*
3455f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        of the strongest signals; this is the minimum level that needs to be
3456f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        successfully detected, when using the best receiver at the moment.
3457f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        "Max cck energy" is the maximum (higher value means lower energy!)
3458f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        of the last 10 minima.  Once this is determined, driver must add
3459f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        a little margin by adding "6" to it.
3460f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3461f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   3).  Number of consecutive beacon periods with too few false alarms.
3462f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        Reset this to 0 at the first beacon period that falls within the
3463f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        "good" range (5 to 50 false alarms per 204.8 milliseconds rx).
3464f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3465f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * Then, adjust the following CCK table entries in struct iwl_sensitivity_cmd
3466f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * (notice that the start points for CCK are at maximum sensitivity):
3467f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3468f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *                                             START  /  MIN  /  MAX
3469f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX         125   /  125  /  200
3470f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX     200   /  200  /  400
3471f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   HD_MIN_ENERGY_CCK_DET_INDEX                100   /    0  /  100
3472f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3473f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   If actual rate of CCK false alarms (+ plcp_errors) is too high
3474f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   (greater than 50 for each 204.8 msecs listening), method for reducing
3475f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   sensitivity is:
3476f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3477f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   1)  *Add* 3 to value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX,
3478f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       up to max 400.
3479f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3480f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   2)  If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX is < 160,
3481f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       sensitivity has been reduced a significant amount; bring it up to
3482f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       a moderate 161.  Otherwise, *add* 3, up to max 200.
3483f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3484f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   3)  a)  If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX is > 160,
3485f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       sensitivity has been reduced only a moderate or small amount;
3486f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       *subtract* 2 from value in HD_MIN_ENERGY_CCK_DET_INDEX,
3487f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       down to min 0.  Otherwise (if gain has been significantly reduced),
3488f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       don't change the HD_MIN_ENERGY_CCK_DET_INDEX value.
3489f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3490f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       b)  Save a snapshot of the "silence reference".
3491f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3492f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   If actual rate of CCK false alarms (+ plcp_errors) is too low
3493f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   (less than 5 for each 204.8 msecs listening), method for increasing
3494f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   sensitivity is used only if:
3495f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3496f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   1a)  Previous beacon did not have too many false alarms
3497f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   1b)  AND difference between previous "silence reference" and current
3498f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *        "silence reference" (prev - current) is 2 or more,
3499f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   OR 2)  100 or more consecutive beacon periods have had rate of
3500f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *          less than 5 false alarms per 204.8 milliseconds rx time.
3501f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3502f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   Method for increasing sensitivity:
3503f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3504f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   1)  *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX,
3505f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       down to min 125.
3506f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3507f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   2)  *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX,
3508f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       down to min 200.
3509f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3510f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   3)  *Add* 2 to value in HD_MIN_ENERGY_CCK_DET_INDEX, up to max 100.
3511f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3512f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   If actual rate of CCK false alarms (+ plcp_errors) is within good range
3513f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   (between 5 and 50 for each 204.8 msecs listening):
3514f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3515f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   1)  Save a snapshot of the silence reference.
3516f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3517f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   2)  If previous beacon had too many CCK false alarms (+ plcp_errors),
3518f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       give some extra margin to energy threshold by *subtracting* 8
3519f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *       from value in HD_MIN_ENERGY_CCK_DET_INDEX.
3520f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3521f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   For all cases (too few, too many, good range), make sure that the CCK
3522f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   detection threshold (energy) is below the energy level for robust
3523f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   detection over the past 10 beacon periods, the "Max cck energy".
3524f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   Lower values mean higher energy; this means making sure that the value
3525f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   in HD_MIN_ENERGY_CCK_DET_INDEX is at or *above* "Max cck energy".
3526f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3527f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill */
3528f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill
3529f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill/*
3530f0832f137c21d130998a0f97f97ac01a2d97210bEmmanuel Grumbach * Table entries in SENSITIVITY_CMD (struct iwl_sensitivity_cmd)
3531f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill */
3532f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_TABLE_SIZE  (11)	/* number of entries */
3533f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_MIN_ENERGY_CCK_DET_INDEX                 (0)	/* table indexes */
3534f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_MIN_ENERGY_OFDM_DET_INDEX                (1)
3535f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_AUTO_CORR32_X1_TH_ADD_MIN_INDEX          (2)
3536f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_INDEX      (3)
3537f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX      (4)
3538f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX          (5)
3539f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_INDEX      (6)
3540f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_BARKER_CORR_TH_ADD_MIN_INDEX             (7)
3541f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_BARKER_CORR_TH_ADD_MIN_MRC_INDEX         (8)
3542f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX          (9)
3543f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill#define HD_OFDM_ENERGY_TH_IN_INDEX                  (10)
3544f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill
3545c8312facd99b4cd05998fe3440926b667a896c9eWey-Yi Guy/*
3546c8312facd99b4cd05998fe3440926b667a896c9eWey-Yi Guy * Additional table entries in enhance SENSITIVITY_CMD
3547c8312facd99b4cd05998fe3440926b667a896c9eWey-Yi Guy */
3548c8312facd99b4cd05998fe3440926b667a896c9eWey-Yi Guy#define HD_INA_NON_SQUARE_DET_OFDM_INDEX		(11)
3549c8312facd99b4cd05998fe3440926b667a896c9eWey-Yi Guy#define HD_INA_NON_SQUARE_DET_CCK_INDEX			(12)
3550c8312facd99b4cd05998fe3440926b667a896c9eWey-Yi Guy#define HD_CORR_11_INSTEAD_OF_CORR_9_EN_INDEX		(13)
3551c8312facd99b4cd05998fe3440926b667a896c9eWey-Yi Guy#define HD_OFDM_NON_SQUARE_DET_SLOPE_MRC_INDEX		(14)
3552c8312facd99b4cd05998fe3440926b667a896c9eWey-Yi Guy#define HD_OFDM_NON_SQUARE_DET_INTERCEPT_MRC_INDEX	(15)
3553c8312facd99b4cd05998fe3440926b667a896c9eWey-Yi Guy#define HD_OFDM_NON_SQUARE_DET_SLOPE_INDEX		(16)
3554c8312facd99b4cd05998fe3440926b667a896c9eWey-Yi Guy#define HD_OFDM_NON_SQUARE_DET_INTERCEPT_INDEX		(17)
3555c8312facd99b4cd05998fe3440926b667a896c9eWey-Yi Guy#define HD_CCK_NON_SQUARE_DET_SLOPE_MRC_INDEX		(18)
3556c8312facd99b4cd05998fe3440926b667a896c9eWey-Yi Guy#define HD_CCK_NON_SQUARE_DET_INTERCEPT_MRC_INDEX	(19)
3557c8312facd99b4cd05998fe3440926b667a896c9eWey-Yi Guy#define HD_CCK_NON_SQUARE_DET_SLOPE_INDEX		(20)
3558c8312facd99b4cd05998fe3440926b667a896c9eWey-Yi Guy#define HD_CCK_NON_SQUARE_DET_INTERCEPT_INDEX		(21)
3559c8312facd99b4cd05998fe3440926b667a896c9eWey-Yi Guy#define HD_RESERVED					(22)
3560c8312facd99b4cd05998fe3440926b667a896c9eWey-Yi Guy
3561c8312facd99b4cd05998fe3440926b667a896c9eWey-Yi Guy/* number of entries for enhanced tbl */
3562c8312facd99b4cd05998fe3440926b667a896c9eWey-Yi Guy#define ENHANCE_HD_TABLE_SIZE  (23)
3563c8312facd99b4cd05998fe3440926b667a896c9eWey-Yi Guy
3564c8312facd99b4cd05998fe3440926b667a896c9eWey-Yi Guy/* number of additional entries for enhanced tbl */
3565c8312facd99b4cd05998fe3440926b667a896c9eWey-Yi Guy#define ENHANCE_HD_TABLE_ENTRIES  (ENHANCE_HD_TABLE_SIZE - HD_TABLE_SIZE)
3566c8312facd99b4cd05998fe3440926b667a896c9eWey-Yi Guy
3567c8312facd99b4cd05998fe3440926b667a896c9eWey-Yi Guy#define HD_INA_NON_SQUARE_DET_OFDM_DATA			cpu_to_le16(0)
3568c8312facd99b4cd05998fe3440926b667a896c9eWey-Yi Guy#define HD_INA_NON_SQUARE_DET_CCK_DATA			cpu_to_le16(0)
3569c8312facd99b4cd05998fe3440926b667a896c9eWey-Yi Guy#define HD_CORR_11_INSTEAD_OF_CORR_9_EN_DATA		cpu_to_le16(0)
3570c8312facd99b4cd05998fe3440926b667a896c9eWey-Yi Guy#define HD_OFDM_NON_SQUARE_DET_SLOPE_MRC_DATA		cpu_to_le16(668)
3571c8312facd99b4cd05998fe3440926b667a896c9eWey-Yi Guy#define HD_OFDM_NON_SQUARE_DET_INTERCEPT_MRC_DATA	cpu_to_le16(4)
3572c8312facd99b4cd05998fe3440926b667a896c9eWey-Yi Guy#define HD_OFDM_NON_SQUARE_DET_SLOPE_DATA		cpu_to_le16(486)
3573c8312facd99b4cd05998fe3440926b667a896c9eWey-Yi Guy#define HD_OFDM_NON_SQUARE_DET_INTERCEPT_DATA		cpu_to_le16(37)
3574c8312facd99b4cd05998fe3440926b667a896c9eWey-Yi Guy#define HD_CCK_NON_SQUARE_DET_SLOPE_MRC_DATA		cpu_to_le16(853)
3575c8312facd99b4cd05998fe3440926b667a896c9eWey-Yi Guy#define HD_CCK_NON_SQUARE_DET_INTERCEPT_MRC_DATA	cpu_to_le16(4)
3576c8312facd99b4cd05998fe3440926b667a896c9eWey-Yi Guy#define HD_CCK_NON_SQUARE_DET_SLOPE_DATA		cpu_to_le16(476)
3577c8312facd99b4cd05998fe3440926b667a896c9eWey-Yi Guy#define HD_CCK_NON_SQUARE_DET_INTERCEPT_DATA		cpu_to_le16(99)
3578c8312facd99b4cd05998fe3440926b667a896c9eWey-Yi Guy
3579c8312facd99b4cd05998fe3440926b667a896c9eWey-Yi Guy
3580f0832f137c21d130998a0f97f97ac01a2d97210bEmmanuel Grumbach/* Control field in struct iwl_sensitivity_cmd */
358151e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define SENSITIVITY_CMD_CONTROL_DEFAULT_TABLE	cpu_to_le16(0)
358251e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define SENSITIVITY_CMD_CONTROL_WORK_TABLE	cpu_to_le16(1)
3583b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3584f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill/**
3585f0832f137c21d130998a0f97f97ac01a2d97210bEmmanuel Grumbach * struct iwl_sensitivity_cmd
3586f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * @control:  (1) updates working table, (0) updates default table
3587f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * @table:  energy threshold values, use HD_* as index into table
3588f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3589f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * Always use "1" in "control" to update uCode's working table and DSP.
3590f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill */
3591f0832f137c21d130998a0f97f97ac01a2d97210bEmmanuel Grumbachstruct iwl_sensitivity_cmd {
3592f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill	__le16 control;			/* always use "1" */
3593f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill	__le16 table[HD_TABLE_SIZE];	/* use HD_* as index */
3594ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
3595b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3596c8312facd99b4cd05998fe3440926b667a896c9eWey-Yi Guy/*
3597c8312facd99b4cd05998fe3440926b667a896c9eWey-Yi Guy *
3598c8312facd99b4cd05998fe3440926b667a896c9eWey-Yi Guy */
3599c8312facd99b4cd05998fe3440926b667a896c9eWey-Yi Guystruct iwl_enhance_sensitivity_cmd {
3600c8312facd99b4cd05998fe3440926b667a896c9eWey-Yi Guy	__le16 control;			/* always use "1" */
3601c8312facd99b4cd05998fe3440926b667a896c9eWey-Yi Guy	__le16 enhance_table[ENHANCE_HD_TABLE_SIZE];	/* use HD_* as index */
36020e954099b7910524b7fae831fbf2933bd25cb6d0John W. Linville} __packed;
3603c8312facd99b4cd05998fe3440926b667a896c9eWey-Yi Guy
3604f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill
3605f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill/**
3606f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * REPLY_PHY_CALIBRATION_CMD = 0xb0 (command, has simple generic response)
3607f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3608f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * This command sets the relative gains of 4965's 3 radio receiver chains.
3609f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3610f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * After the first association, driver should accumulate signal and noise
3611f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * statistics from the STATISTICS_NOTIFICATIONs that follow the first 20
3612f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * beacons from the associated network (don't collect statistics that come
3613f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * in from scanning, or any other non-network source).
3614f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3615f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * DISCONNECTED ANTENNA:
3616f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3617f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * Driver should determine which antennas are actually connected, by comparing
3618f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * average beacon signal levels for the 3 Rx chains.  Accumulate (add) the
3619f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * following values over 20 beacons, one accumulator for each of the chains
3620f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * a/b/c, from struct statistics_rx_non_phy:
3621f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3622f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * beacon_rssi_[abc] & 0x0FF (unsigned, units in dB)
3623f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3624f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * Find the strongest signal from among a/b/c.  Compare the other two to the
3625f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * strongest.  If any signal is more than 15 dB (times 20, unless you
3626f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * divide the accumulated values by 20) below the strongest, the driver
3627f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * considers that antenna to be disconnected, and should not try to use that
3628f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * antenna/chain for Rx or Tx.  If both A and B seem to be disconnected,
3629f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * driver should declare the stronger one as connected, and attempt to use it
3630f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * (A and B are the only 2 Tx chains!).
3631f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3632f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3633f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * RX BALANCE:
3634f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3635f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * Driver should balance the 3 receivers (but just the ones that are connected
3636f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * to antennas, see above) for gain, by comparing the average signal levels
3637f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * detected during the silence after each beacon (background noise).
3638f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * Accumulate (add) the following values over 20 beacons, one accumulator for
3639f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * each of the chains a/b/c, from struct statistics_rx_non_phy:
3640f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3641f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * beacon_silence_rssi_[abc] & 0x0FF (unsigned, units in dB)
3642f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3643f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * Find the weakest background noise level from among a/b/c.  This Rx chain
3644f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * will be the reference, with 0 gain adjustment.  Attenuate other channels by
3645f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * finding noise difference:
3646f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3647f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * (accum_noise[i] - accum_noise[reference]) / 30
3648f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3649f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * The "30" adjusts the dB in the 20 accumulated samples to units of 1.5 dB.
3650f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * For use in diff_gain_[abc] fields of struct iwl_calibration_cmd, the
3651f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * driver should limit the difference results to a range of 0-3 (0-4.5 dB),
3652f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * and set bit 2 to indicate "reduce gain".  The value for the reference
3653f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * (weakest) chain should be "0".
3654f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *
3655f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * diff_gain_[abc] bit fields:
3656f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill *   2: (1) reduce gain, (0) increase gain
3657f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill * 1-0: amount of gain, units of 1.5 dB
3658f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill */
3659f7d09d7c453f197d802c50172b27170a43e1a816Ben M Cahill
3660f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler/* Phy calibration command for series */
366133fd503346ad86bd7470a0f8c4c3080393d14233Emmanuel Grumbach
366233fd503346ad86bd7470a0f8c4c3080393d14233Emmanuel Grumbachenum {
3663f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	IWL_PHY_CALIBRATE_DIFF_GAIN_CMD		= 7,
3664f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	IWL_PHY_CALIBRATE_DC_CMD		= 8,
3665f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	IWL_PHY_CALIBRATE_LO_CMD		= 9,
3666f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	IWL_PHY_CALIBRATE_TX_IQ_CMD		= 11,
3667f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	IWL_PHY_CALIBRATE_CRYSTAL_FRQ_CMD	= 15,
3668f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	IWL_PHY_CALIBRATE_BASE_BAND_CMD		= 16,
3669f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	IWL_PHY_CALIBRATE_TX_IQ_PERD_CMD	= 17,
36706a822d060c439bb700f2369767105f49135b94f8Wey-Yi Guy	IWL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE	= 18,
367133fd503346ad86bd7470a0f8c4c3080393d14233Emmanuel Grumbach};
367233fd503346ad86bd7470a0f8c4c3080393d14233Emmanuel Grumbach
36736a822d060c439bb700f2369767105f49135b94f8Wey-Yi Guy#define IWL_MAX_PHY_CALIBRATE_TBL_SIZE		(253)
3674f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler
367551e9bf5d795b8e01e54391f1790974c7b166d286Harvey Harrison#define IWL_CALIB_INIT_CFG_ALL	cpu_to_le32(0xffffffff)
36767c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler
36777c616cba240cd0d579c996be3f3603456acfb0adTomas Winklerstruct iwl_calib_cfg_elmnt_s {
36787c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	__le32 is_enable;
36797c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	__le32 start;
36807c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	__le32 send_res;
36817c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	__le32 apply_res;
36827c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	__le32 reserved;
3683ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
36847c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler
36857c616cba240cd0d579c996be3f3603456acfb0adTomas Winklerstruct iwl_calib_cfg_status_s {
36867c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	struct iwl_calib_cfg_elmnt_s once;
36877c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	struct iwl_calib_cfg_elmnt_s perd;
36887c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	__le32 flags;
3689ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
36907c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler
3691f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winklerstruct iwl_calib_cfg_cmd {
36927c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	struct iwl_calib_cfg_status_s ucd_calib_cfg;
36937c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	struct iwl_calib_cfg_status_s drv_calib_cfg;
36947c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	__le32 reserved1;
3695ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
36967c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler
3697f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winklerstruct iwl_calib_hdr {
36987c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	u8 op_code;
36997c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	u8 first_group;
37007c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	u8 groups_num;
37017c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler	u8 data_valid;
3702ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
37037c616cba240cd0d579c996be3f3603456acfb0adTomas Winkler
3704f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winklerstruct iwl_calib_cmd {
3705f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	struct iwl_calib_hdr hdr;
3706be5d56ed885a2897ec813eab4a8055d495816e9aTomas Winkler	u8 data[0];
3707ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
3708be5d56ed885a2897ec813eab4a8055d495816e9aTomas Winkler
37090d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler/* IWL_PHY_CALIBRATE_DIFF_GAIN_CMD (7) */
3710f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winklerstruct iwl_calib_diff_gain_cmd {
37110d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler	struct iwl_calib_hdr hdr;
3712f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	s8 diff_gain_a;		/* see above */
3713f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	s8 diff_gain_b;
3714f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	s8 diff_gain_c;
3715f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler	u8 reserved1;
3716ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
3717f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winkler
37180d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winklerstruct iwl_calib_xtal_freq_cmd {
37190d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler	struct iwl_calib_hdr hdr;
37200d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler	u8 cap_pin1;
37210d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler	u8 cap_pin2;
37220d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler	u8 pad[2];
3723ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
372433fd503346ad86bd7470a0f8c4c3080393d14233Emmanuel Grumbach
37250d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler/* IWL_PHY_CALIBRATE_CHAIN_NOISE_RESET_CMD */
37260d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winklerstruct iwl_calib_chain_noise_reset_cmd {
37270d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler	struct iwl_calib_hdr hdr;
37280d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler	u8 data[0];
37290d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler};
37300d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler
37310d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler/* IWL_PHY_CALIBRATE_CHAIN_NOISE_GAIN_CMD */
3732f69f42a6bbefb311ccb1626fdb61f723160afbfdTomas Winklerstruct iwl_calib_chain_noise_gain_cmd {
37330d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler	struct iwl_calib_hdr hdr;
373433fd503346ad86bd7470a0f8c4c3080393d14233Emmanuel Grumbach	u8 delta_gain_1;
373533fd503346ad86bd7470a0f8c4c3080393d14233Emmanuel Grumbach	u8 delta_gain_2;
37360d950d84d9d16f7d4edf380a238c5b534ff00d11Tomas Winkler	u8 pad[2];
3737ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
373833fd503346ad86bd7470a0f8c4c3080393d14233Emmanuel Grumbach
3739b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
3740b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (12)
3741b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Miscellaneous Commands:
3742b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
3743b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
3744b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3745b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/*
3746b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * LEDs Command & Response
3747b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * REPLY_LEDS_CMD = 0x48 (command, has simple generic response)
3748b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
3749b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * For each of 3 possible LEDs (Activity/Link/Tech, selected by "id" field),
3750b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * this command turns it on or off, or sets up a periodic blinking cycle.
3751b481de9ca074528fe8c429604e2777db8b89806aZhu Yi */
3752ec1a746042ea4c1c93065185897d6e8d3e7de894Tomas Winklerstruct iwl_led_cmd {
3753b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	__le32 interval;	/* "interval" in uSec */
3754b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 id;			/* 1: Activity, 2: Link, 3: Tech */
3755b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 off;			/* # intervals off while blinking;
3756b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 * "0", with >0 "on" value, turns LED on */
3757b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 on;			/* # intervals on while blinking;
3758b481de9ca074528fe8c429604e2777db8b89806aZhu Yi				 * "0", regardless of "off", turns LED off */
3759b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	u8 reserved;
3760ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
3761b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
37629636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky/*
3763fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy * station priority table entries
3764fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy * also used as potential "events" value for both
3765fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy * COEX_MEDIUM_NOTIFICATION and COEX_EVENT_CMD
37669636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky */
37671933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy
37681933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy/*
37691933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy * COEX events entry flag masks
37701933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy * RP - Requested Priority
37711933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy * WP - Win Medium Priority: priority assigned when the contention has been won
37721933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy */
37731933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG        (0x1)
37741933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG        (0x2)
37751933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_EVT_FLAG_DELAY_MEDIUM_FREE_NTFY_FLG  (0x4)
37761933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy
37771933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_UNASSOC_IDLE_RP               4
37781933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_UNASSOC_MANUAL_SCAN_RP        4
37791933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_UNASSOC_AUTO_SCAN_RP          4
37801933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_CALIBRATION_RP                4
37811933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_PERIODIC_CALIBRATION_RP       4
37821933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_CONNECTION_ESTAB_RP           4
37831933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_ASSOCIATED_IDLE_RP            4
37841933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_ASSOC_MANUAL_SCAN_RP          4
37851933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_ASSOC_AUTO_SCAN_RP            4
37861933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_ASSOC_ACTIVE_LEVEL_RP         4
37871933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_RF_ON_RP                      6
37881933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_RF_OFF_RP                     4
37891933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_STAND_ALONE_DEBUG_RP          6
37901933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_IPAN_ASSOC_LEVEL_RP           4
37911933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_RSRVD1_RP                     4
37921933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_RSRVD2_RP                     4
37931933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy
37941933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_UNASSOC_IDLE_WP               3
37951933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_UNASSOC_MANUAL_SCAN_WP        3
37961933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_UNASSOC_AUTO_SCAN_WP          3
37971933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_CALIBRATION_WP                3
37981933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_PERIODIC_CALIBRATION_WP       3
37991933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_CONNECTION_ESTAB_WP           3
38001933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_ASSOCIATED_IDLE_WP            3
38011933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_ASSOC_MANUAL_SCAN_WP          3
38021933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_ASSOC_AUTO_SCAN_WP            3
38031933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_ASSOC_ACTIVE_LEVEL_WP         3
38041933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_RF_ON_WP                      3
38051933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_RF_OFF_WP                     3
38061933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_STAND_ALONE_DEBUG_WP          6
38071933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_IPAN_ASSOC_LEVEL_WP           3
38081933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_RSRVD1_WP                     3
38091933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_RSRVD2_WP                     3
38101933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy
38111933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_UNASSOC_IDLE_FLAGS                     0
38121933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_UNASSOC_MANUAL_SCAN_FLAGS		\
38131933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	(COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG |	\
38141933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
38151933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_UNASSOC_AUTO_SCAN_FLAGS		\
38161933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	(COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG |	\
38171933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
38181933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CALIBRATION_FLAGS			\
38191933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	(COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG |	\
38201933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
38211933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_PERIODIC_CALIBRATION_FLAGS             0
38221933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy/*
38231933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy * COEX_CONNECTION_ESTAB:
38241933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy * we need DELAY_MEDIUM_FREE_NTFY to let WiMAX disconnect from network.
38251933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy */
38261933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CONNECTION_ESTAB_FLAGS		\
38271933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	(COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG |	\
38281933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG |	\
38291933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	COEX_EVT_FLAG_DELAY_MEDIUM_FREE_NTFY_FLG)
38301933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_ASSOCIATED_IDLE_FLAGS                  0
38311933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_ASSOC_MANUAL_SCAN_FLAGS		\
38321933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	(COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG |	\
38331933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
38341933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_ASSOC_AUTO_SCAN_FLAGS		\
38351933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	(COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG |	\
38361933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
38371933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_ASSOC_ACTIVE_LEVEL_FLAGS               0
38381933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_RF_ON_FLAGS                            0
38391933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_RF_OFF_FLAGS                           0
38401933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_STAND_ALONE_DEBUG_FLAGS		\
38411933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	(COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG |	\
38421933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG)
38431933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_IPAN_ASSOC_LEVEL_FLAGS		\
38441933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	(COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG |	\
38451933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG |	\
38461933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	 COEX_EVT_FLAG_DELAY_MEDIUM_FREE_NTFY_FLG)
38471933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_RSRVD1_FLAGS                           0
38481933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_RSRVD2_FLAGS                           0
38491933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy/*
38501933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy * COEX_CU_RF_ON is the event wrapping all radio ownership.
38511933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy * We need DELAY_MEDIUM_FREE_NTFY to let WiMAX disconnect from network.
38521933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy */
38531933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy#define COEX_CU_RF_ON_FLAGS			\
38541933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	(COEX_EVT_FLAG_MEDIUM_FREE_NTFY_FLG |	\
38551933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	 COEX_EVT_FLAG_MEDIUM_ACTV_NTFY_FLG |	\
38561933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy	 COEX_EVT_FLAG_DELAY_MEDIUM_FREE_NTFY_FLG)
38571933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy
38581933ac4d9377ed44caba45abe1531ec1bc14bb63Wey-Yi Guy
38599636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunskyenum {
3860fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	/* un-association part */
38619636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_UNASSOC_IDLE		= 0,
38629636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_UNASSOC_MANUAL_SCAN	= 1,
38639636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_UNASSOC_AUTO_SCAN		= 2,
3864fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	/* calibration */
38659636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_CALIBRATION		= 3,
38669636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_PERIODIC_CALIBRATION	= 4,
3867fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	/* connection */
38689636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_CONNECTION_ESTAB		= 5,
3869fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	/* association part */
38709636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_ASSOCIATED_IDLE		= 6,
38719636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_ASSOC_MANUAL_SCAN		= 7,
38729636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_ASSOC_AUTO_SCAN		= 8,
38739636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_ASSOC_ACTIVE_LEVEL		= 9,
3874fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	/* RF ON/OFF */
38759636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_RF_ON			= 10,
38769636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_RF_OFF			= 11,
38779636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_STAND_ALONE_DEBUG		= 12,
3878fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	/* IPAN */
38799636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_IPAN_ASSOC_LEVEL		= 13,
3880fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	/* reserved */
38819636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_RSRVD1			= 14,
38829636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_RSRVD2			= 15,
38839636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	COEX_NUM_OF_EVENTS		= 16
38849636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky};
38859636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky
3886fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy/*
3887fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy * Coexistence WIFI/WIMAX  Command
3888fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy * COEX_PRIORITY_TABLE_CMD = 0x5a
3889fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy *
3890fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy */
38919636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunskystruct iwl_wimax_coex_event_entry {
38929636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	u8 request_prio;
38939636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	u8 win_medium_prio;
38949636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	u8 reserved;
38959636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	u8 flags;
3896ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
38979636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky
38989636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky/* COEX flag masks */
38999636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky
3900a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler/* Station table is valid */
39019636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky#define COEX_FLAGS_STA_TABLE_VALID_MSK      (0x1)
3902a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler/* UnMask wake up src at unassociated sleep */
39039636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky#define COEX_FLAGS_UNASSOC_WA_UNMASK_MSK    (0x4)
3904a96a27f97f2bbfc1fca54bc3c0b0d41484152740Tomas Winkler/* UnMask wake up src at associated sleep */
39059636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky#define COEX_FLAGS_ASSOC_WA_UNMASK_MSK      (0x8)
39069636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky/* Enable CoEx feature. */
39079636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky#define COEX_FLAGS_COEX_ENABLE_MSK          (0x80)
39089636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky
39099636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunskystruct iwl_wimax_coex_cmd {
39109636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	u8 flags;
39119636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	u8 reserved[3];
39129636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky	struct iwl_wimax_coex_event_entry sta_prio[COEX_NUM_OF_EVENTS];
3913ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
39149636e583d2c641f8cb32d0681f5052b2885edd79Ron Rindjunsky
3915fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy/*
3916fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy * Coexistence MEDIUM NOTIFICATION
3917fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy * COEX_MEDIUM_NOTIFICATION = 0x5b
3918fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy *
3919fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy * notification from uCode to host to indicate medium changes
3920fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy *
3921fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy */
3922fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy/*
3923fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy * status field
3924fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy * bit 0 - 2: medium status
3925fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy * bit 3: medium change indication
3926fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy * bit 4 - 31: reserved
3927fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy */
3928fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy/* status option values, (0 - 2 bits) */
3929fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy#define COEX_MEDIUM_BUSY	(0x0) /* radio belongs to WiMAX */
3930fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy#define COEX_MEDIUM_ACTIVE	(0x1) /* radio belongs to WiFi */
3931fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy#define COEX_MEDIUM_PRE_RELEASE	(0x2) /* received radio release */
3932fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy#define COEX_MEDIUM_MSK		(0x7)
3933fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy
3934fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy/* send notification status (1 bit) */
3935fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy#define COEX_MEDIUM_CHANGED	(0x8)
3936fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy#define COEX_MEDIUM_CHANGED_MSK	(0x8)
3937fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy#define COEX_MEDIUM_SHIFT	(3)
3938fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy
3939fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guystruct iwl_coex_medium_notification {
3940fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	__le32 status;
3941fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	__le32 events;
3942ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
3943fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy
3944fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy/*
3945fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy * Coexistence EVENT  Command
3946fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy * COEX_EVENT_CMD = 0x5c
3947fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy *
3948fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy * send from host to uCode for coex event request.
3949fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy */
3950fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy/* flags options */
3951fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy#define COEX_EVENT_REQUEST_MSK	(0x1)
3952fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy
3953fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guystruct iwl_coex_event_cmd {
3954fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	u8 flags;
3955fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	u8 event;
3956fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	__le16 reserved;
3957ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
3958fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy
3959fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guystruct iwl_coex_event_resp {
3960fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy	__le32 status;
3961ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
3962fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy
3963fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy
3964b481de9ca074528fe8c429604e2777db8b89806aZhu Yi/******************************************************************************
3965b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * (13)
3966b481de9ca074528fe8c429604e2777db8b89806aZhu Yi * Union of all expected notifications/responses:
3967b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *
3968b481de9ca074528fe8c429604e2777db8b89806aZhu Yi *****************************************************************************/
3969b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
3970db11d6343aa14ab61258bfad9178042d4be49333Tomas Winklerstruct iwl_rx_packet {
39712f301227a1ede57504694e1f64839839f5737cacZhu Yi	/*
39722f301227a1ede57504694e1f64839839f5737cacZhu Yi	 * The first 4 bytes of the RX frame header contain both the RX frame
39732f301227a1ede57504694e1f64839839f5737cacZhu Yi	 * size and some flags.
39742f301227a1ede57504694e1f64839839f5737cacZhu Yi	 * Bit fields:
39752f301227a1ede57504694e1f64839839f5737cacZhu Yi	 * 31:    flag flush RB request
39762f301227a1ede57504694e1f64839839f5737cacZhu Yi	 * 30:    flag ignore TC (terminal counter) request
39772f301227a1ede57504694e1f64839839f5737cacZhu Yi	 * 29:    flag fast IRQ request
39782f301227a1ede57504694e1f64839839f5737cacZhu Yi	 * 28-14: Reserved
39792f301227a1ede57504694e1f64839839f5737cacZhu Yi	 * 13-00: RX frame size
39802f301227a1ede57504694e1f64839839f5737cacZhu Yi	 */
3981396887a2b2ad1ef5e5526fec34dec582baf39b81Daniel C Halperin	__le32 len_n_flags;
3982857485c0c46ceee5c658c1761bba4d9a5ddf433fTomas Winkler	struct iwl_cmd_header hdr;
3983b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	union {
39843d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler		struct iwl3945_rx_frame rx_frame;
39853d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler		struct iwl3945_tx_resp tx_resp;
39863d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler		struct iwl3945_beacon_notif beacon_status;
39873d24a9f790c0e39cfdef1446c7100e89c542805cTomas Winkler
3988885ba202cabd90b8ade1fe59185dc96ed4d69e02Tomas Winkler		struct iwl_alive_resp alive_frame;
39892aa6ab86bc475a115f56645591d2413981846509Tomas Winkler		struct iwl_spectrum_notification spectrum_notif;
39902aa6ab86bc475a115f56645591d2413981846509Tomas Winkler		struct iwl_csa_notification csa_notif;
3991885ba202cabd90b8ade1fe59185dc96ed4d69e02Tomas Winkler		struct iwl_error_resp err_resp;
39922aa6ab86bc475a115f56645591d2413981846509Tomas Winkler		struct iwl_card_state_notif card_state_notif;
39937a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler		struct iwl_add_sta_resp add_sta;
39947a999bf0c5eb19b20ac6ab0f21f6e5013400fa51Tomas Winkler		struct iwl_rem_sta_resp rem_sta;
39952aa6ab86bc475a115f56645591d2413981846509Tomas Winkler		struct iwl_sleep_notification sleep_notif;
39962aa6ab86bc475a115f56645591d2413981846509Tomas Winkler		struct iwl_spectrum_resp spectrum;
39978f91aecb4cdc2d786df8941e827b9dff3c10a4e4Emmanuel Grumbach		struct iwl_notif_statistics stats;
39987980fba54ec42f7c206b2bb469baeb3a0a2e8a93Wey-Yi Guy		struct iwl_bt_notif_statistics stats_bt;
3999653fa4a07525e4cd9e7b90e6fc1f792119910636Emmanuel Grumbach		struct iwl_compressed_ba_resp compressed_ba;
40002aa6ab86bc475a115f56645591d2413981846509Tomas Winkler		struct iwl_missed_beacon_notif missed_beacon;
4001fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy		struct iwl_coex_medium_notification coex_medium_notif;
4002fe1bcbfda77bf6fa3bbad8bf26b9e9ab23fbe345Wey-Yi Guy		struct iwl_coex_event_resp coex_event;
4003b481de9ca074528fe8c429604e2777db8b89806aZhu Yi		__le32 status;
4004b481de9ca074528fe8c429604e2777db8b89806aZhu Yi		u8 raw[0];
4005b481de9ca074528fe8c429604e2777db8b89806aZhu Yi	} u;
4006ba2d3587912f82d1ab4367975b1df460db60fb1eEric Dumazet} __packed;
4007b481de9ca074528fe8c429604e2777db8b89806aZhu Yi
4008a3139c5956702c9ff957ac9fe2d902de355b063eSamuel Ortizint iwl_agn_check_rxon_cmd(struct iwl_priv *priv);
40098f5c87dcf6d1a5e6d7ffe642cfd4debb5ccbec49Winkler, Tomas
40106a63578ddf6148927a80c07a73b40ccc8f3ac8e2Emmanuel Grumbach#endif				/* __iwl_commands_h__ */
4011